schoeberl/chisel-lab

Missing dut.clock.step(1) in lab3 AccuSpec test

Closed this issue · 1 comments

When working through the lab, in lab3 I have a failing test for AccuSpec:

[info] AccuSpec:
[info] Accu
[info] Count15Spec:
[info] - should pass *** FAILED ***
[info]   io_dout=0 (0x0) did not equal expected=3 (0x3) (lines in AccuSpec.scala: 7) (AccuSpec.scala:25)

In the AccuSpec.scala file, there is no dut.clock.step(1) between the last poke and expect. Adding this (see the diff below) made the test case stop failing. I do believe that this is the intended behaviour.

diff --git a/lab3/src/test/scala/AccuSpec.scala b/lab3/src/test/scala/AccuSpec.scala
index 9f861dd..47c1376 100644
--- a/lab3/src/test/scala/AccuSpec.scala
+++ b/lab3/src/test/scala/AccuSpec.scala
@@ -21,6 +21,7 @@ class AccuSpec extends AnyFlatSpec with ChiselScalatestTester {
       dut.io.dout.expect(0.U)
       dut.io.setZero.poke(false.B)
       dut.io.din.poke(3.U)
+      dut.clock.step(1)
       dut.io.dout.expect(3.U)
     }
   }

Thanks for pointing this out. It is fixed.