diff --git a/lib/Testing.bsv b/lib/Testing.bsv new file mode 100644 index 0000000..4135a50 --- /dev/null +++ b/lib/Testing.bsv @@ -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