| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- `timescale 1ns/1ps
- module prod2u_p4_axis_jog_16bit_tb;
- reg clk = 1'b0;
- reg rst_n = 1'b0;
- reg command_start = 1'b0;
- reg command_dir = 1'b0;
- reg [15:0] command_steps = 16'hffff;
- wire step_out;
- wire dir_out;
- wire started_pulse;
- integer rises = 0;
- integer started = 0;
- integer guard = 0;
- always #5 clk = ~clk;
- always @(posedge step_out) rises = rises + 1;
- always @(posedge clk) begin
- #1;
- if (started_pulse) started = started + 1;
- end
- prod2u_p4_axis_executor #(
- .DIR_SETUP_CYCLES(1),
- .STEP_HALF_CYCLES(1)
- ) dut (
- .clk(clk), .rst_n(rst_n),
- .command_start(command_start), .command_dir(command_dir),
- .command_steps(command_steps), .step_out(step_out),
- .dir_out(dir_out), .started_pulse(started_pulse)
- );
- initial begin
- repeat (3) @(negedge clk);
- rst_n = 1'b1;
- @(negedge clk);
- command_dir = 1'b1;
- command_start = 1'b1;
- @(negedge clk);
- command_start = 1'b0;
- while ((rises < 65535) && (guard < 140000)) begin
- @(negedge clk);
- guard = guard + 1;
- end
- repeat (4) @(negedge clk);
- if ((rises != 65535) || (started != 1) || !dir_out || step_out) begin
- $fatal(1, "16-bit JOG mismatch rises=%0d started=%0d dir=%0d step=%0d",
- rises, started, dir_out, step_out);
- end
- $display("PASS: prod2u_p4_axis_jog_16bit_tb");
- $finish;
- end
- endmodule
|