Advertisement
1WaKa_WaKa1

fsm4_tb

Apr 6th, 2023
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module fsm4_tb;
  4.  
  5. reg clock, rst, enab;
  6. reg [31:0] A_test, B_test;
  7. wire [35:0] res;
  8. reg [35:0] expected_res;
  9.  
  10. fsm4 func(
  11.     .clk(clock),
  12.     .reset(rst),
  13.     .enable(enab),
  14.     .A(A_test),
  15.     .B(B_test),
  16.     .res(res)
  17. );
  18.  
  19. integer i;
  20.  
  21. initial begin
  22.     i = 0;
  23.     clock = 0;
  24.     rst = 0;
  25.     enab = 0;
  26.     A_test = 5;
  27.     B_test = 6;
  28.    
  29.     expected_res = ((A_test + B_test)*4 + B_test)/2 + (B_test/2 + A_test*4);
  30.     enab = 1;
  31.    
  32.     for (i = 0; i < 10; i = i + 1) begin
  33.         #5 clock = ~clock;
  34.         $display ("Current state: %d", func.cur_state);
  35.         #5 clock = ~clock;
  36.         $display ("Current state: %d", func.cur_state);
  37.         $display ("sum_1: %d", func.sum_1);
  38.         if(func.cur_state == 8)
  39.             $display ("Module result: %d; expected: %d", res, expected_res);
  40.     end
  41.    
  42.     $stop;
  43. end
  44. endmodule
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement