Create a new signal for the Simulator to wait on
authorCesar Strauss <cestrauss@gmail.com>
Tue, 9 Mar 2021 10:49:03 +0000 (07:49 -0300)
committerCesar Strauss <cestrauss@gmail.com>
Tue, 9 Mar 2021 10:55:36 +0000 (07:55 -0300)
We wait on "core busy" before simulating an instruction. Trouble is, on a
VL==0 loop, there is no issue, so busy is never toggled. As a solution,
export a new insn_done signal with is pulsed either at end of Execute, or
when going back to Fetch due to skipping a vector instruction.

src/soc/simple/issuer.py
src/soc/simple/test/test_runner.py

index 5aa8788e071ebf7756c5167e8761d5102c606b2b..e0bd35951644d10041c7635d3ee0f252879639ee 100644 (file)
@@ -153,6 +153,9 @@ class TestIssuerInternal(Elaboratable):
         self.state_nia = self.core.regs.rf['state'].w_ports['nia']
         self.state_nia.wen.name = 'state_nia_wen'
 
+        # pulse to synchronize the simulator at instruction end
+        self.insn_done = Signal()
+
     def fetch_fsm(self, m, core, pc, svstate, nia,
                         fetch_pc_ready_o, fetch_pc_valid_i,
                         fetch_insn_valid_o, fetch_insn_ready_i):
@@ -322,6 +325,7 @@ class TestIssuerInternal(Elaboratable):
                         # executed that we could be overwriting
                         comb += self.state_w_pc.wen.eq(1 << StateRegs.PC)
                         comb += self.state_w_pc.data_i.eq(nia)
+                        comb += self.insn_done.eq(1)
                         m.next = "INSN_FETCH"
                     with m.Else():
                         m.next = "INSN_EXECUTE"  # move to "execute"
@@ -448,6 +452,7 @@ class TestIssuerInternal(Elaboratable):
                 with m.If(~core_busy_o): # instruction done!
                     comb += exec_pc_valid_o.eq(1)
                     with m.If(exec_pc_ready_i):
+                        comb += self.insn_done.eq(1)
                         m.next = "INSN_START"  # back to fetch
 
     def elaborate(self, platform):
index 9e06b8c2a4c4f25b55749682b5fc25a6e1d11ccf..957cd080b4c92d6b7e6a7c042b6b49cfba5e7850 100644 (file)
@@ -257,8 +257,12 @@ class TestRunner(FHDLTestCase):
                     counter = counter + 1
 
                     # wait until executed
-                    yield from wait_for_busy_hi(core)
-                    yield from wait_for_busy_clear(core)
+                    # wait for insn_done high
+                    while not (yield issuer.insn_done):
+                        yield
+                    # wait for insn_done low
+                    while (yield issuer.insn_done):
+                        yield
 
                     # set up simulated instruction (in simdec2)
                     try: