prod2u_p4_axis_jog_16bit_tb.v 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. `timescale 1ns/1ps
  2. module prod2u_p4_axis_jog_16bit_tb;
  3. reg clk = 1'b0;
  4. reg rst_n = 1'b0;
  5. reg command_start = 1'b0;
  6. reg command_dir = 1'b0;
  7. reg [15:0] command_steps = 16'hffff;
  8. wire step_out;
  9. wire dir_out;
  10. wire started_pulse;
  11. integer rises = 0;
  12. integer started = 0;
  13. integer guard = 0;
  14. always #5 clk = ~clk;
  15. always @(posedge step_out) rises = rises + 1;
  16. always @(posedge clk) begin
  17. #1;
  18. if (started_pulse) started = started + 1;
  19. end
  20. prod2u_p4_axis_executor #(
  21. .DIR_SETUP_CYCLES(1),
  22. .STEP_HALF_CYCLES(1)
  23. ) dut (
  24. .clk(clk), .rst_n(rst_n),
  25. .command_start(command_start), .command_dir(command_dir),
  26. .command_steps(command_steps), .step_out(step_out),
  27. .dir_out(dir_out), .started_pulse(started_pulse)
  28. );
  29. initial begin
  30. repeat (3) @(negedge clk);
  31. rst_n = 1'b1;
  32. @(negedge clk);
  33. command_dir = 1'b1;
  34. command_start = 1'b1;
  35. @(negedge clk);
  36. command_start = 1'b0;
  37. while ((rises < 65535) && (guard < 140000)) begin
  38. @(negedge clk);
  39. guard = guard + 1;
  40. end
  41. repeat (4) @(negedge clk);
  42. if ((rises != 65535) || (started != 1) || !dir_out || step_out) begin
  43. $fatal(1, "16-bit JOG mismatch rises=%0d started=%0d dir=%0d step=%0d",
  44. rises, started, dir_out, step_out);
  45. end
  46. $display("PASS: prod2u_p4_axis_jog_16bit_tb");
  47. $finish;
  48. end
  49. endmodule