| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- `timescale 1ns/1ps
- module prod2u_6400_watchdog_tb;
- reg clk = 1'b0;
- reg rst_n = 1'b0;
- reg tick_500us = 1'b0;
- reg valid_set_all_commit = 1'b0;
- wire watchdog_active;
- wire timeout_event;
- integer i;
- always #1 clk = ~clk;
- host_watchdog #(.TIMEOUT_TICKS(60000)) dut (
- .clk(clk), .rst_n(rst_n), .enable(1'b1), .tick_500us(tick_500us),
- .valid_set_all_commit(valid_set_all_commit),
- .watchdog_active(watchdog_active), .timeout_event(timeout_event)
- );
- task pulse_tick;
- begin
- @(negedge clk);
- tick_500us = 1'b1;
- @(negedge clk);
- tick_500us = 1'b0;
- end
- endtask
- initial begin
- repeat (2) @(posedge clk);
- rst_n = 1'b1;
- repeat (59999) pulse_tick();
- if (watchdog_active || timeout_event)
- $fatal(1, "watchdog tripped before tick 60000 count=%0d", dut.tick_count);
- if (dut.tick_count !== 59999)
- $fatal(1, "pre-timeout count=%0d", dut.tick_count);
- pulse_tick();
- if (!watchdog_active || !timeout_event)
- $fatal(1, "watchdog did not trip at tick 60000");
- @(posedge clk);
- @(negedge clk);
- if (timeout_event) $fatal(1, "timeout_event was not one cycle");
- @(negedge clk);
- valid_set_all_commit = 1'b1;
- @(negedge clk);
- valid_set_all_commit = 1'b0;
- if (watchdog_active) $fatal(1, "legal commit did not clear watchdog");
- $display("prod2u_6400_watchdog_tb PASS");
- $finish;
- end
- endmodule
|