use new soc.config.state CoreState class in DMI and test_issuer
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 3 Aug 2020 19:04:56 +0000 (20:04 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 3 Aug 2020 19:04:59 +0000 (20:04 +0100)
src/soc/config/state.py [new file with mode: 0644]
src/soc/debug/dmi.py
src/soc/simple/issuer.py

diff --git a/src/soc/config/state.py b/src/soc/config/state.py
new file mode 100644 (file)
index 0000000..4035543
--- /dev/null
@@ -0,0 +1,9 @@
+from nmutil.iocontrol import RecordObject
+from nmigen import Signal
+
+
+class CoreState(RecordObject):
+    def __init__(self, name):
+        super().__init__(name=name)
+        self.pc = Signal(64)         # Program Counter (CIA, NIA)
+        self.msr = Signal(64)        # Machine Status Register (MSR)
index 2a72786f44f19ce97b70890f0e34a531e4db7b90..bff07d70f569670f752f6dfa63a2fc285f6fd6d7 100644 (file)
@@ -10,6 +10,7 @@ from nmigen import Elaboratable, Module, Signal, Cat, Const, Record, Array, Mux
 from nmutil.iocontrol import RecordObject
 from nmigen.utils import log2_int
 from nmigen.cli import rtlil
+from soc.config.state import CoreState
 
 
 # DMI register addresses
@@ -82,8 +83,7 @@ class CoreDebug(Elaboratable):
         # Core status inputs
         self.terminate_i    = Signal()
         self.core_stopped_i = Signal()
-        self.nia            = Signal(64)
-        self.msr            = Signal(64)
+        self.state = CoreState("core_dbg")
 
         # GSPR register read port
         self.dbg_gpr = DbgReg("dbg_gpr")
@@ -141,9 +141,9 @@ class CoreDebug(Elaboratable):
             with m.Case( DBGCore.STAT):
                 comb += self.dmi.dout.eq(stat_reg)
             with m.Case( DBGCore.NIA):
-                comb += self.dmi.dout.eq(self.nia)
+                comb += self.dmi.dout.eq(self.state.pc)
             with m.Case( DBGCore.MSR):
-                comb += self.dmi.dout.eq(self.msr)
+                comb += self.dmi.dout.eq(self.state.msr)
             with m.Case( DBGCore.GSPR_DATA):
                 comb += self.dmi.dout.eq(self.dbg_gpr.data_i)
             with m.Case( DBGCore.LOG_ADDR):
@@ -313,8 +313,7 @@ class CoreDebug(Elaboratable):
         yield self.icache_rst_o
         yield self.terminate_i
         yield self.core_stopped_i
-        yield self.nia
-        yield self.msr
+        yield from self.state
         yield from self.dbg_gpr
         yield self.log_data_i
         yield self.log_read_addr_i
index e625b8dd9f2ab0f806846b86a82d6fef74355df1..c111f958feb0035bf1cbe5f471c9130966a573eb 100644 (file)
@@ -119,6 +119,8 @@ class TestIssuer(Elaboratable):
         # TODO comb += core.reset_i.eq(dbg.core_rst_o)
         # TODO comb += core.icache_rst_i.eq(dbg.icache_rst_o)
         comb += dbg.terminate_i.eq(core.core_terminate_o)
+        comb += dbg.state.pc.eq(cur_pc)
+        comb += dbg.state.msr.eq(cur_msr)
 
         # temporaries
         core_busy_o = core.busy_o         # core is busy