flipflop.comp
1 component flipflop "D type flip-flop"; 2 pin in bit data_ "data input"; 3 pin in bit clk "clock, rising edge writes data to out"; 4 pin in bit set "when true, force out true"; 5 pin in bit reset "when true, force out false; overrides set"; 6 pin io bit out "output"; 7 option data flipflop_data; 8 9 function _ nofp; 10 license "GPL"; 11 ;; 12 13 typedef struct { int oldclk; } flipflop_data; 14 15 FUNCTION(_) { 16 int c; 17 18 c = clk; 19 if ( reset ) { 20 out = 0; 21 } else if ( set ) { 22 out = 1; 23 } else if ( c && ! data.oldclk ) { 24 out = data_; 25 } 26 data.oldclk = c; 27 }