fix bug in alu_fsm.py found by cxxsim: missing one cycle hold of ready_i
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 19 Jul 2020 14:53:36 +0000 (15:53 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 19 Jul 2020 14:53:36 +0000 (15:53 +0100)
src/soc/experiment/alu_fsm.py
src/soc/fu/alu/test/test_pipe_caller.py

index f85703c832156e7f2c91f11d3bb90e9e51f27ba1..b3ab5b175a1edd9128d3cbd9db29c1e634e7a1ab 100644 (file)
@@ -17,7 +17,11 @@ The basic rules are:
 """
 
 from nmigen import Elaboratable, Signal, Module, Cat
-from nmigen.back.pysim import Simulator
+cxxsim = False
+if cxxsim:
+    from nmigen.sim.cxxsim import Simulator, Settle
+else:
+    from nmigen.back.pysim import Simulator, Settle
 from nmigen.cli import rtlil
 from math import log2
 from nmutil.iocontrol import PrevControl, NextControl
@@ -236,6 +240,9 @@ def test_shifter():
             yield
         # read result
         result = yield dut.n.data_o.data
+
+        # must leave ready_i valid for 1 cycle, ready_i to register for 1 cycle
+        yield
         # negate n.ready_i
         yield dut.n.ready_i.eq(0)
         # check result
@@ -263,8 +270,6 @@ def test_shifter():
     sim.add_sync_process(consumer)
     sim_writer = sim.write_vcd(
         "test_shifter.vcd",
-        "test_shifter.gtkw",
-        traces=dut.ports()
     )
     with sim_writer:
         sim.run()
index 88b61b70abbbb302eabc26726b45d2d3a92ae6bd..b2233ca85a039259ad8bc59482ecabced27b3fcf 100644 (file)
@@ -1,6 +1,6 @@
 from nmigen import Module, Signal
 from nmigen.back.pysim import Delay, Settle
-cxxsim = False
+cxxsim = True
 if cxxsim:
     from nmigen.sim.cxxsim import Simulator
 else: