| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- `timescale 1ns/1ps
- module prod2u_p4_cdc_sync_depth_tb;
- reg clk = 1'b0;
- reg rst_n = 1'b0;
- reg limit_raw = 1'b0;
- always #5 clk = ~clk;
- prod2u_p4_axis_executor #(
- .STANDARD_STEPS(4),
- .LIMIT_CONFIRM_US(8),
- .DIR_SETUP_US(2),
- .SPEED0_HALF_US(2),
- .SPEED1_HALF_US(2),
- .SPEED2_HALF_US(2),
- .SPEED3_HALF_US(2)
- ) dut (
- .clk(clk),
- .rst_n(rst_n),
- .tick_1us(1'b1),
- .force_stop(1'b0),
- .limit_raw(limit_raw),
- .jog_start(1'b0),
- .jog_dir(1'b0),
- .jog_speed_code(2'd0),
- .jog_steps(16'd1),
- .standard_start(1'b0),
- .standard_target_open(1'b0),
- .step_out(),
- .dir_out(),
- .busy(),
- .drive_active(),
- .position_valid(),
- .current_aperture(),
- .target_aperture()
- );
- task expect_pipe;
- input [2:0] expected;
- input [8*48-1:0] label_text;
- begin
- @(posedge clk);
- #1;
- if (dut.limit_sync_pipe !== expected) begin
- $display("CDC_FAIL %0s pipe=%03b expected=%03b",
- label_text, dut.limit_sync_pipe, expected);
- $fatal(1);
- end
- end
- endtask
- initial begin
- repeat (3) @(negedge clk);
- rst_n = 1'b1;
- expect_pipe(3'b000, "reset low");
- @(negedge clk);
- limit_raw = 1'b1;
- expect_pipe(3'b001, "rise stage 1");
- expect_pipe(3'b011, "rise stage 2");
- expect_pipe(3'b111, "rise stage 3");
- @(negedge clk);
- limit_raw = 1'b0;
- expect_pipe(3'b110, "fall stage 1");
- expect_pipe(3'b100, "fall stage 2");
- expect_pipe(3'b000, "fall stage 3");
- $display("PASS: prod2u_p4_cdc_sync_depth_tb");
- $finish;
- end
- endmodule
|