| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- `timescale 1ns/1ps
- module intake_solenoid_adapter_tb;
- reg clk = 1'b0;
- reg rst_n = 1'b0;
- reg door_action_valid = 1'b0;
- reg [1:0] intake_door_cmd = 2'd0;
- reg watchdog_inactive = 1'b0;
- wire solenoid_out;
- always #1 clk = ~clk;
- intake_solenoid_adapter #(.OPEN_LEVEL(1'b1), .CLOSED_LEVEL(1'b0), .INACTIVE_LEVEL(1'b0)) dut (
- .clk(clk), .rst_n(rst_n), .door_action_valid(door_action_valid),
- .intake_door_cmd(intake_door_cmd), .watchdog_inactive(watchdog_inactive),
- .solenoid_out(solenoid_out)
- );
- task pulse_cmd;
- input [1:0] cmd;
- begin
- @(negedge clk);
- intake_door_cmd = cmd;
- door_action_valid = 1'b1;
- @(posedge clk);
- @(negedge clk);
- door_action_valid = 1'b0;
- end
- endtask
- initial begin
- repeat (3) @(posedge clk);
- rst_n = 1'b1;
- pulse_cmd(2'd1);
- if (solenoid_out !== 1'b1) $fatal(1, "open level");
- pulse_cmd(2'd0);
- if (solenoid_out !== 1'b1) $fatal(1, "hold open");
- pulse_cmd(2'd2);
- if (solenoid_out !== 1'b0) $fatal(1, "closed level");
- watchdog_inactive = 1'b1;
- @(posedge clk);
- @(negedge clk);
- if (solenoid_out !== 1'b0) $fatal(1, "watchdog inactive");
- $display("intake_solenoid_adapter_tb PASS");
- $finish;
- end
- endmodule
|