Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module FF_2bits (input clk, en, reset, input [1:0] D, output reg [1:0] Q);
- always @ (posedge clk or posedge reset)
- if (reset)
- Q <= 2'b0;
- else if (en)
- Q <= D;
- endmodule
- module tb();
- reg clk, en, reset;
- reg [1:0] D;
- wire [1:0] Q;
- FF_2bits DUT(clk, en, reset, D, Q);
- initial begin
- $dumpfile("timing.vcd");
- $dumpvars(0, tb);
- end
- initial
- #100 $finish;
- always
- #5 clk = ~clk;
- initial begin
- clk = 0; en = 0; reset = 0; D = 2'b01;
- #22
- reset = 1;
- #2
- reset = 0;
- #16
- en = 1;
- #10
- D = 2'b11;
- #20
- D = 2'b10;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement