Advertisement
1WaKa_WaKa1

counter_tb

Apr 6th, 2023
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module counter_tb;
  4.  
  5. reg clock, reset, enable;
  6. wire[31:0] cnt_out;
  7.  
  8. counter cnt(
  9.     .clk (clock),
  10.     .rst (reset),
  11.     .count (cnt_out),
  12.     .en (enable)
  13. );
  14.  
  15. integer i;
  16. initial begin
  17.    i = 0;
  18.     enable = 1;
  19.     clock = 1;
  20.     reset = 1;
  21.     #5 reset = 0;
  22.     for (i = 0 ; i < 32 ; i = i + 1) begin
  23.         #5 clock = ~clock;
  24.         #5 clock = ~clock;
  25.     end
  26.         i = 0;
  27.         enable = 0;
  28.     for (i = 0 ; i < 32 ; i = i + 1) begin
  29.         #5 clock = ~clock;
  30.         #5 clock = ~clock;
  31.     end
  32.  
  33.     reset = 1;
  34.     #5 clock = ~clock;
  35.     enable = 0;
  36.     #5 enable = 1;
  37.     #5 clock = ~clock;
  38.     for (i = 47 ; i < 56 ; i = i + 1) begin
  39.         #5 clock = ~clock;
  40.         #5 clock = ~clock;
  41.     end
  42.     $stop;
  43. end
  44.  
  45. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement