Advertisement
kekellner

Lab10 - Ej04 - FF 8 bits y su Testbench

Nov 8th, 2021
2,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module FF_8bits (input clk, en, reset, input [7:0] D, output reg [7:0] Q);
  2.  
  3.     always @ (posedge clk or posedge reset)
  4.         if (reset)
  5.             Q <= 8'b0;
  6.         else if (en)
  7.             Q <= D;
  8.  
  9. endmodule
  10.  
  11. module tb();
  12.  
  13.     reg clk, en, reset;
  14.     reg [7:0] D;
  15.     wire [7:0] Q;
  16.  
  17.     FF_8bits 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 = 8'b01010001;
  32.         #22
  33.         reset = 1;
  34.         #2
  35.         reset = 0;
  36.         #16
  37.         en = 1;
  38.         #10
  39.         D = 8'b11001100;
  40.         #20
  41.         D = 8'b10101010;
  42.     end
  43.  
  44. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement