Advertisement
kekellner

Lab10 - Ej04 - FF 2 bits y su Testbench

Nov 8th, 2021
1,955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module FF_2bits (input clk, en, reset, input [1:0] D, output reg [1:0] Q);
  2.  
  3.     always @ (posedge clk or posedge reset)
  4.         if (reset)
  5.             Q <= 2'b0;
  6.         else if (en)
  7.             Q <= D;
  8.  
  9. endmodule
  10.  
  11. module tb();
  12.  
  13.     reg clk, en, reset;
  14.     reg [1:0] D;
  15.     wire [1:0] Q;
  16.  
  17.     FF_2bits DUT(clk, en, reset, D, Q);
  18.  
  19.     initial begin
  20.         $dumpfile("timing.vcd");
  21.         $dumpvars(0, tb);
  22.     end
  23.  
  24.     initial
  25.         #100 $finish;
  26.  
  27.     always
  28.         #5 clk = ~clk;
  29.  
  30.     initial begin
  31.         clk = 0; en = 0; reset = 0; D = 2'b01;
  32.         #22
  33.         reset = 1;
  34.         #2
  35.         reset = 0;
  36.         #16
  37.         en = 1;
  38.         #10
  39.         D = 2'b11;
  40.         #20
  41.         D = 2'b10;
  42.     end
  43.  
  44. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement