| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- `timescale 1ns/1ps
- module prod2u_p4_production_defaults_tb;
- reg sys_clk = 1'b0;
- reg host_uart_rx = 1'b1;
- reg x_limit_raw = 1'b0;
- reg y_limit_raw = 1'b0;
- wire host_uart_tx;
- wire [23:0] ptc_pwm_out;
- wire [3:0] fan_pwm_out;
- wire solenoid_out;
- wire motor_en_n;
- wire x_step;
- wire x_dir;
- wire y_step;
- wire y_dir;
- wire z_step;
- wire z_dir;
- always #20 sys_clk = ~sys_clk;
- prod2u_p4_normal_v3_top #(
- .POR_CYCLES(4),
- .SOLENOID_ACTIVE_HIGH(1)
- ) dut (
- .sys_clk(sys_clk),
- .host_uart_rx(host_uart_rx),
- .host_uart_tx(host_uart_tx),
- .ptc_pwm_out(ptc_pwm_out),
- .fan_pwm_out(fan_pwm_out),
- .solenoid_out(solenoid_out),
- .motor_en_n(motor_en_n),
- .x_step(x_step),
- .x_dir(x_dir),
- .y_step(y_step),
- .y_dir(y_dir),
- .z_step(z_step),
- .z_dir(z_dir),
- .x_limit_raw(x_limit_raw),
- .y_limit_raw(y_limit_raw)
- );
- task check_integer;
- input [8*48-1:0] label_text;
- input integer actual;
- input integer expected;
- begin
- if (actual != expected) begin
- $display("DEFAULT_FAIL %0s actual=%0d expected=%0d",
- label_text, actual, expected);
- $fatal(1);
- end
- end
- endtask
- initial begin
- #1;
- check_integer("watchdog seconds", dut.WATCHDOG_SECONDS, 5);
- check_integer("dir setup cycles", dut.MOTOR_DIR_SETUP_CYCLES, 25000);
- check_integer("step half cycles", dut.MOTOR_STEP_HALF_CYCLES, 12500);
- check_integer("core dir setup", dut.u_core.DIR_SETUP_CYCLES, 25000);
- check_integer("core step half", dut.u_core.STEP_HALF_CYCLES, 12500);
- check_integer("hub dir setup", dut.u_core.u_motors.DIR_SETUP_CYCLES, 25000);
- check_integer("hub step half", dut.u_core.u_motors.STEP_HALF_CYCLES, 12500);
- check_integer("X dir setup", dut.u_core.u_motors.u_x_axis.DIR_SETUP_CYCLES, 25000);
- check_integer("Y dir setup", dut.u_core.u_motors.u_y_axis.DIR_SETUP_CYCLES, 25000);
- check_integer("X step half", dut.u_core.u_motors.u_x_axis.STEP_HALF_CYCLES, 12500);
- check_integer("Y step half", dut.u_core.u_motors.u_y_axis.STEP_HALF_CYCLES, 12500);
- check_integer("X JOG counter bits", $bits(dut.u_core.u_motors.u_x_axis.remaining_steps), 16);
- check_integer("Y JOG counter bits", $bits(dut.u_core.u_motors.u_y_axis.remaining_steps), 16);
- wait (dut.sys_rst_n === 1'b1);
- repeat (4) @(posedge sys_clk);
- #1;
- if (motor_en_n || x_step || y_step || z_step ||
- dut.disabled !== 1'b1 || dut.watchdog_timeout !== 1'b0) begin
- $display("DEFAULT_SAFE_FAIL en_n=%0d step=%0d%0d%0d disabled=%0d timeout=%0d",
- motor_en_n, z_step, y_step, x_step,
- dut.disabled, dut.watchdog_timeout);
- $fatal(1);
- end
- $display("PASS: prod2u_p4_production_defaults_tb");
- $finish;
- end
- endmodule
|