rework jtag test to use JTAG class not DMITAP
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 8 Oct 2020 12:47:42 +0000 (13:47 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 8 Oct 2020 12:47:42 +0000 (13:47 +0100)
src/soc/debug/jtag.py
src/soc/debug/jtagutils.py
src/soc/debug/test/dmi_sim.py
src/soc/debug/test/test_jtag_tap_srv.py

index c7c96454aba09e314cd58237a3e941a23827f429..2a9507a12a7098e7b2f892b7f024bcb29b39394d 100644 (file)
@@ -60,7 +60,7 @@ class Pins:
 
 
 class JTAG(DMITAP, Pins):
 
 
 class JTAG(DMITAP, Pins):
-    def __init__(self, pinset):
+    def __init__(self, pinset, wb_data_wid=64):
         DMITAP.__init__(self, ir_width=4)
         Pins.__init__(self, pinset)
 
         DMITAP.__init__(self, ir_width=4)
         Pins.__init__(self, pinset)
 
@@ -77,7 +77,7 @@ class JTAG(DMITAP, Pins):
 
         # create and connect wishbone 
         self.wb = self.add_wishbone(ircodes=[5, 6, 7],
 
         # create and connect wishbone 
         self.wb = self.add_wishbone(ircodes=[5, 6, 7],
-                                   address_width=29, data_width=64,
+                                   address_width=29, data_width=wb_data_wid,
                                    name="jtag_wb")
 
         # create DMI2JTAG (goes through to dmi_sim())
                                    name="jtag_wb")
 
         # create DMI2JTAG (goes through to dmi_sim())
index 1dee686c2dd2678d47317476b198de544cc2eae2..f0b1830d23cfe4c4f5ae762191cc5b653e29ddd2 100644 (file)
@@ -41,7 +41,7 @@ def tms_data_getset(dut, tms, d_len, d_in=0):
         tdi = 1 if (d_in & (1<<i)) else 0
         yield dut.cbus.tck.eq(1)
         yield from client_sync(dut)
         tdi = 1 if (d_in & (1<<i)) else 0
         yield dut.cbus.tck.eq(1)
         yield from client_sync(dut)
-        res |= (1<<i) if (yield dut.bus.tdo) else 0
+        res |= (1<<i) if (yield dut.cbus.tdo) else 0
         yield
         yield from client_sync(dut)
         yield dut.cbus.tdi.eq(tdi)
         yield
         yield from client_sync(dut)
         yield dut.cbus.tdi.eq(tdi)
@@ -98,7 +98,7 @@ def jtag_srv(dut):
         yield dut.bus.tms.eq(tms)
         yield dut.bus.tdi.eq(tdi)
         yield
         yield dut.bus.tms.eq(tms)
         yield dut.bus.tdi.eq(tdi)
         yield
-
+    print ("jtag srv stopping")
 
 
 def get_data(s, length=1024, timeout=None):
 
 
 def get_data(s, length=1024, timeout=None):
index c0d376dde36ace8039b09b41d25f684b8126ab27..66d544d1993e95739d416edc7a7fbbbae003b224 100644 (file)
@@ -43,3 +43,4 @@ def dmi_sim(dut):
             yield
             yield dmi.ack_o.eq(0)
 
             yield
             yield dmi.ack_o.eq(0)
 
+    print ("dmi sim stopping")
index 45b4ffb9fb64b10b7092a57d72011a2792d3828f..597eb0a6940a3cea2d2df6b01da53ed6e56814e4 100644 (file)
@@ -9,7 +9,7 @@ from c4m.nmigen.jtag.tap import TAP, IOType
 from c4m.nmigen.jtag.bus import Interface as JTAGInterface
 from soc.debug.dmi import DMIInterface, DBGCore
 from soc.debug.test.dmi_sim import dmi_sim
 from c4m.nmigen.jtag.bus import Interface as JTAGInterface
 from soc.debug.dmi import DMIInterface, DBGCore
 from soc.debug.test.dmi_sim import dmi_sim
-from soc.debug.dmi2jtag import DMITAP
+from soc.debug.jtag import JTAG, dummy_pinset
 from soc.debug.test.jtagremote import JTAGServer, JTAGClient
 
 from nmigen_soc.wishbone.sram import SRAM
 from soc.debug.test.jtagremote import JTAGServer, JTAGClient
 
 from nmigen_soc.wishbone.sram import SRAM
@@ -31,7 +31,7 @@ WB_READ = 6
 WB_WRRD = 7
 
 
 WB_WRRD = 7
 
 
-def jtag_sim(dut):
+def jtag_sim(dut, srv_dut):
 
     ####### JTAGy stuff (IDCODE) ######
 
 
     ####### JTAGy stuff (IDCODE) ######
 
@@ -78,64 +78,57 @@ def jtag_sim(dut):
     ####### JTAG to Wishbone ######
 
     # write Wishbone address
     ####### JTAG to Wishbone ######
 
     # write Wishbone address
-    yield from jtag_read_write_reg(dut, WB_ADDR, 16, 0x18)
+    yield from jtag_read_write_reg(dut, WB_ADDR, 64, 0x18)
 
     # write/read wishbone data
 
     # write/read wishbone data
-    data = yield from jtag_read_write_reg(dut, WB_WRRD, 16, 0xfeef)
+    data = yield from jtag_read_write_reg(dut, WB_WRRD, 64, 0xfeef)
     print ("wb write", hex(data))
 
     # write Wishbone address
     print ("wb write", hex(data))
 
     # write Wishbone address
-    yield from jtag_read_write_reg(dut, WB_ADDR, 16, 0x18)
+    yield from jtag_read_write_reg(dut, WB_ADDR, 64, 0x18)
 
     # write/read wishbone data
 
     # write/read wishbone data
-    data = yield from jtag_read_write_reg(dut, WB_READ, 16, 0)
+    data = yield from jtag_read_write_reg(dut, WB_READ, 64, 0)
     print ("wb read", hex(data))
 
     ####### done - tell dmi_sim to stop (otherwise it won't) ########
 
     print ("wb read", hex(data))
 
     ####### done - tell dmi_sim to stop (otherwise it won't) ########
 
-    dut.stop = True
+    srv_dut.stop = True
+    print ("jtag sim stopping")
 
 
 if __name__ == '__main__':
 
 
 if __name__ == '__main__':
-    dut = DMITAP(ir_width=4)
+    dut = JTAG(dummy_pinset(), wb_data_wid=64)
     dut.stop = False
 
     dut.stop = False
 
+    # rather than the client access the JTAG bus directly
+    # create an alternative that the client sets
+    class Dummy: pass
+    cdut = Dummy()
+    cdut.cbus = JTAGInterface()
+    cdut._ir_width = 4
+
     # set up client-server on port 44843-something
     dut.s = JTAGServer()
     if len(sys.argv) != 2 or sys.argv[1] != 'server':
     # set up client-server on port 44843-something
     dut.s = JTAGServer()
     if len(sys.argv) != 2 or sys.argv[1] != 'server':
-        dut.c = JTAGClient()
+        cdut.c = JTAGClient()
         dut.s.get_connection()
     else:
         dut.s.get_connection(None) # block waiting for connection
 
         dut.s.get_connection()
     else:
         dut.s.get_connection(None) # block waiting for connection
 
-    # rather than the client access the JTAG bus directly
-    # create an alternative that the client sets
-    dut.cbus = JTAGInterface()
-
-    iotypes = (IOType.In, IOType.Out, IOType.TriOut, IOType.InTriOut)
-    ios = [dut.add_io(iotype=iotype) for iotype in iotypes]
-    dut.sr = dut.add_shiftreg(ircode=4, length=3) # test loopback register
-
-    # create and connect wishbone SRAM (a quick way to do WB test)
-    dut.wb = dut.add_wishbone(ircodes=[WB_ADDR, WB_READ, WB_WRRD],
-                               address_width=16, data_width=16)
-    memory = Memory(width=16, depth=16)
+    memory = Memory(width=64, depth=16)
     sram = SRAM(memory=memory, bus=dut.wb)
 
     sram = SRAM(memory=memory, bus=dut.wb)
 
-    # create DMI2JTAG (goes through to dmi_sim())
-    dut.dmi = dut.add_dmi(ircodes=[DMI_ADDR, DMI_READ, DMI_WRRD])
-
     m = Module()
     m.submodules.ast = dut
     m.submodules.sram = sram
     m = Module()
     m.submodules.ast = dut
     m.submodules.sram = sram
-    m.d.comb += dut.sr.i.eq(dut.sr.o) # loopback
 
     sim = Simulator(m)
     sim.add_clock(1e-6, domain="sync")      # standard clock
 
     sim.add_sync_process(wrap(jtag_srv(dut))) # jtag server
     if len(sys.argv) != 2 or sys.argv[1] != 'server':
 
     sim = Simulator(m)
     sim.add_clock(1e-6, domain="sync")      # standard clock
 
     sim.add_sync_process(wrap(jtag_srv(dut))) # jtag server
     if len(sys.argv) != 2 or sys.argv[1] != 'server':
-        sim.add_sync_process(wrap(jtag_sim(dut))) # actual jtag tester
+        sim.add_sync_process(wrap(jtag_sim(cdut, dut))) # actual jtag tester
     else:
         print ("running server only as requested, use openocd remote to test")
     sim.add_sync_process(wrap(dmi_sim(dut)))  # handles (pretends to be) DMI
     else:
         print ("running server only as requested, use openocd remote to test")
     sim.add_sync_process(wrap(dmi_sim(dut)))  # handles (pretends to be) DMI