`timescale 1ns/1ps module host_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; always #1 clk = ~clk; initial begin #100000; $fatal(1, "watchdog production-boundary timeout count=%0d active=%b event=%b", dut.tick_count, watchdog_active, timeout_event); end // Production-boundary simulation. Formal proves the same ordering with a // small timeout parameter to keep the proof reachable. host_watchdog #(.TIMEOUT_TICKS(20000)) dut ( .clk(clk), .rst_n(rst_n), .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); if (dut.tick_count !== 0 || watchdog_active || timeout_event) $fatal(1, "watchdog reset state is not idle"); rst_n = 1'b1; repeat (19999) pulse_tick(); if (dut.tick_count !== 19999 || watchdog_active || timeout_event) $fatal(1, "watchdog pre-timeout boundary mismatch count=%0d", dut.tick_count); pulse_tick(); if (!timeout_event || !watchdog_active) $fatal(1, "watchdog did not expire at timeout"); @(posedge clk); @(negedge clk); if (timeout_event) $fatal(1, "watchdog timeout event was not one cycle"); @(negedge clk); valid_set_all_commit = 1'b1; tick_500us = 1'b1; @(negedge clk); valid_set_all_commit = 1'b0; tick_500us = 1'b0; repeat (3) pulse_tick(); if (watchdog_active || timeout_event) $fatal(1, "valid commit did not reset watchdog"); $display("host_watchdog_tb PASS"); $finish; end endmodule