Added timeout check to testbench.

A watchdog checks the value of PCW.  If it does not change within 1M cycles immediately stop simulation and report an error.
This commit is contained in:
Ross Thompson 2022-12-21 09:18:00 -06:00
parent ac94b55e74
commit 3d95aa3423

View File

@ -428,6 +428,27 @@ logic [3:0] dummy;
end end
end end
end end
// check for hange up.
logic [`XLEN-1:0] OldPCW;
integer WatchDogTimerCount;
localparam WatchDogTimerThreshold = 1000000;
logic WatchDogTimeOut;
always_ff @(posedge clk) begin
OldPCW <= PCW;
if(OldPCW == PCW) WatchDogTimerCount = WatchDogTimerCount + 1'b1;
else WatchDogTimerCount = '0;
end
always_comb begin
WatchDogTimeOut = WatchDogTimerCount >= WatchDogTimerThreshold;
if(WatchDogTimeOut) begin
$display("FAILURE: Watch Dog Time Out triggered. PCW stuck at %x for more than %d cycles", PCW, WatchDogTimerCount);
$stop;
end
end
endmodule endmodule
module riscvassertions; module riscvassertions;