get litex sim to kick off a "STEP" via the DMI interface every N cycles
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 4 Aug 2020 11:44:13 +0000 (12:44 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 4 Aug 2020 11:44:13 +0000 (12:44 +0100)
src/soc/litex/florent/sim.py

index 50ab2a980074ec1f62599c5be0ec3e4cc69d43ee..d9046f759c80023ca2d54a7b6e7dcce7f2fe9aec 100755 (executable)
@@ -47,8 +47,8 @@ class LibreSoCSim(SoCCore):
         # setup running of DMI FSM
         dmi_addr = Signal(3)
         dmi_din = Signal(64)
-        dmi_wen = Signal(64)
         dmi_dout = Signal(64)
+        dmi_wen = Signal(1)
         dmi_req = Signal(1)
 
         uptime = Signal(64)
@@ -69,10 +69,6 @@ class LibreSoCSim(SoCCore):
                  self.cpu.dmi_wr.eq(1),    # DMI write
                  If(self.cpu.dmi_ack,
                     (NextState("IDLE"),
-                     self.cpu.dmi_addr.eq(0),
-                     self.cpu.dmi_din.eq(0),
-                     self.cpu.dmi_req.eq(0),
-                     self.cpu.dmi_wr.eq(0),
                     )
                  ),
                 ),
@@ -81,11 +77,15 @@ class LibreSoCSim(SoCCore):
 
         dmifsm.act("IDLE",
             (NextValue(dmi_req, 0),
+             NextValue(dmi_addr, 0),
+             NextValue(dmi_din, 0),
+             NextValue(dmi_wen, 0),
+             NextState("START"), # back to start on next cycle
             )
         )
 
         # kick off a "stop"
-        self.comb += If(uptime == 0,
+        self.sync += If(uptime == 0,
             (dmi_addr.eq(0), # CTRL
              dmi_din.eq(1<<0), # STOP
              dmi_req.eq(1),
@@ -93,6 +93,18 @@ class LibreSoCSim(SoCCore):
             )
         )
 
+        # loop every 1<<N cycles
+        cyclewid = 7
+
+        # kick off a "step"
+        self.sync += If(uptime[0:cyclewid] == 4,
+            (dmi_addr.eq(0), # CTRL
+             dmi_din.eq(1<<3), # STEP
+             dmi_req.eq(1),
+             dmi_wen.eq(1),
+            )
+        )
+
         # monitor ibus write
         self.sync += If(self.cpu.ibus.stb & self.cpu.ibus.ack &
                         self.cpu.ibus.we,