got test_issuer FSM operating. bit of a hack
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 17 Jun 2020 05:39:53 +0000 (06:39 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 17 Jun 2020 05:39:53 +0000 (06:39 +0100)
src/soc/decoder/isa/caller.py
src/soc/simple/core.py
src/soc/simple/test/test_issuer.py

index 1ed3cc909a1c9eee31886102b187ee57fa970492..af28a996fcd7d03d7de0738b452239e5c1f8cf9e 100644 (file)
@@ -321,6 +321,7 @@ class ISACaller:
             imm = yield self.dec2.e.imm_data.data
             inputs.append(SelectableInt(imm, 64))
         assert len(outputs) >= 1
+        print ("handle_overflow", inputs, outputs)
         if len(inputs) >= 2:
             output = outputs[0]
 
index 9962233698afa468fd38cddd1471526a6848d1e1..cb234628e2d512b964753a79aadb47b1957126b2 100644 (file)
@@ -352,10 +352,11 @@ class TestIssuer(Elaboratable):
         current_insn = Signal(32) # current fetched instruction (note sync)
         current_pc = Signal(64) # current PC (note it is reset/sync)
         comb += self.pc_o.eq(current_pc)
+        ilatch = Signal(32)
 
         # next instruction (+4 on current)
         nia = Signal(64, reset_less=True)
-        comb += nia.eq(current_insn + 4)
+        comb += nia.eq(current_pc + 4)
 
         # temporaries
         core_busy_o = core.busy_o         # core is busy
@@ -382,24 +383,25 @@ class TestIssuer(Elaboratable):
                     # capture the PC and also drop it into Insn Memory
                     # we have joined a pair of combinatorial memory
                     # lookups together.  this is Generally Bad.
-                    sync += current_pc.eq(pc)
-                    comb += self.i_rd.addr.eq(pc)
-                    #comb += self.i_rd.en.eq(1) # comb-read (no need to set)
-                    sync += current_insn.eq(self.i_rd.data)
+                    comb += self.i_rd.addr.eq(pc[2:]) # ignore last 2 bits
+                    comb += current_insn.eq(self.i_rd.data)
+                    comb += current_pc.eq(pc)
                     m.next = "INSN_READ" # move to "issue" phase
 
             # got the instruction: start issue
             with m.State("INSN_READ"):
+                comb += current_insn.eq(self.i_rd.data)
                 comb += core_ivalid_i.eq(1) # say instruction is valid
                 comb += core_issue_i.eq(1)  # and issued (ivalid_i redundant)
                 comb += core_be_i.eq(0)     # little-endian mode
                 comb += core_opcode_i.eq(current_insn) # actual opcode
+                sync += ilatch.eq(current_insn)
                 m.next = "INSN_ACTIVE" # move to "wait for completion" phase
 
             # instruction started: must wait till it finishes
             with m.State("INSN_ACTIVE"):
                 comb += core_ivalid_i.eq(1) # say instruction is valid
-                comb += core_opcode_i.eq(current_insn) # actual opcode
+                comb += core_opcode_i.eq(ilatch) # actual opcode
                 #sync += core_issue_i.eq(0) # issue raises for only one cycle
                 with m.If(~core_busy_o): # instruction done!
                     #sync += core_ivalid_i.eq(0) # say instruction is invalid
index cd07b500cc0b33338aebcedad81e817e949f1bc2..54a41b2a10069f4ff46f0fc5da2b97b02da4b771 100644 (file)
@@ -53,6 +53,7 @@ class TestRunner(FHDLTestCase):
         m = Module()
         comb = m.d.comb
         go_insn_i = Signal()
+        pc_i = Signal(32)
 
         m.submodules.issuer = issuer = TestIssuer()
         imem = issuer.imem.mem
@@ -60,6 +61,7 @@ class TestRunner(FHDLTestCase):
         pdecode2 = core.pdecode2
         l0 = core.l0
 
+        comb += issuer.pc_i.data.eq(pc_i)
         comb += issuer.go_insn_i.eq(go_insn_i)
 
         # nmigen Simulation
@@ -83,7 +85,7 @@ class TestRunner(FHDLTestCase):
                 yield from setup_test_memory(l0, sim)
                 yield from setup_regs(core, test)
 
-                yield issuer.pc_i.data.eq(pc)
+                yield pc_i.eq(pc)
                 yield issuer.pc_i.ok.eq(1)
 
                 index = sim.pc.CIA.value//4
@@ -115,6 +117,8 @@ class TestRunner(FHDLTestCase):
                     # Memory check
                     yield from check_sim_memory(self, l0, sim, code)
 
+                    yield
+
         sim.add_sync_process(process)
         with sim.write_vcd("issuer_simulator.vcd",
                             traces=[]):