wait until pipeline indicates that its output is valid in compunit test
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 25 Jul 2020 14:33:38 +0000 (15:33 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 25 Jul 2020 14:33:38 +0000 (15:33 +0100)
DIV and other long pipelines only set wrmask when a result is available
the previous test, "is wrmask zero if so exit" was therefore reading
invalid data.

it was a matter of coincidence that all other compunit tests were only
one stage long that the wrmask *happened* to be valid

src/soc/fu/compunits/test/test_compunit.py

index 09c1beee30dfb1d4d655887b4fc232c5c404bf43..9ac469f410f6c20d233cc0540d6ca74a4c28b26f 100644 (file)
@@ -80,6 +80,13 @@ def set_operand(cu, dec2, sim):
 
 def get_cu_outputs(cu, code):
     res = {}
+    # wait for pipeline to indicate valid.  this because for long
+    # pipelines (or FSMs) the write mask is only valid at that time.
+    while True:
+        valid_o = yield cu.alu.n.valid_o
+        if valid_o:
+            break
+        yield
     wrmask = yield cu.wrmask
     wr_rel_o = yield cu.wr.rel
     print("get_cu_outputs", cu.n_dst, wrmask, wr_rel_o)