2019-08-22 14:20:18 -05:00
|
|
|
module dff
|
2019-08-21 13:52:07 -05:00
|
|
|
( input d, clk, output reg q );
|
2019-08-19 23:50:05 -05:00
|
|
|
always @( posedge clk )
|
|
|
|
q <= d;
|
|
|
|
endmodule
|
2019-08-22 14:20:18 -05:00
|
|
|
|
|
|
|
module dffe
|
|
|
|
( input d, clk, en, output reg q );
|
|
|
|
initial begin
|
|
|
|
q = 0;
|
|
|
|
end
|
|
|
|
always @( posedge clk )
|
|
|
|
if ( en )
|
|
|
|
q <= d;
|
|
|
|
endmodule
|
|
|
|
|
|
|
|
module top (
|
|
|
|
input clk,
|
|
|
|
input en,
|
|
|
|
input a,
|
|
|
|
output b,b1,
|
|
|
|
);
|
|
|
|
|
|
|
|
dff u_dff (
|
|
|
|
.clk (clk ),
|
|
|
|
.d (a ),
|
|
|
|
.q (b )
|
|
|
|
);
|
|
|
|
|
|
|
|
dffe u_ndffe (
|
|
|
|
.clk (clk ),
|
|
|
|
.en (en),
|
|
|
|
.d (a ),
|
|
|
|
.q (b1 )
|
|
|
|
);
|
|
|
|
|
|
|
|
endmodule
|