lib: add test helpers for timeouts and sequential test running

This commit is contained in:
David Anderson 2024-08-13 20:53:47 -07:00
parent 730d11ecea
commit 39e17f8e42
1 changed files with 23 additions and 0 deletions

23
lib/Testing.bsv Normal file
View File

@ -0,0 +1,23 @@
package Testing;
import Assert::*;
import StmtFSM::*;
module mkTestCycleLimit#(Integer max_cycles)();
Reg#(UInt#(64)) c <- mkReg(fromInteger(max_cycles));
rule count;
dynamicAssert(c > 0, "FAIL: test timed out");
c <= c-1;
endrule
endmodule
module mkTest#(String name, RStmt#(Bit#(0)) test)();
mkAutoFSM(seq
$display("RUN ", name);
test;
$display("OK ", name);
endseq);
endmodule
endpackage