add JTAG bus module
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 22 Sep 2020 11:23:25 +0000 (12:23 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 22 Sep 2020 11:23:25 +0000 (12:23 +0100)
src/soc/debug/jtag.py [new file with mode: 0644]

diff --git a/src/soc/debug/jtag.py b/src/soc/debug/jtag.py
new file mode 100644 (file)
index 0000000..9e28e47
--- /dev/null
@@ -0,0 +1,37 @@
+"""JTAG interface
+
+using Staf Verhaegen (Chips4Makers) wishbone TAP
+"""
+
+from nmigen import (Module, Signal, Elaboratable)
+from nmigen.cli import rtlil
+from c4m.nmigen.jtag.tap import IOType
+from soc.debug.dmi import  DMIInterface, DBGCore
+from soc.debug.dmi2jtag import DMITAP
+
+
+class JTAG(DMITAP):
+    iotypes = (IOType.In, IOType.Out, IOType.TriOut, IOType.InTriOut)
+    def __init__(self):
+        super().__init__(ir_width=4)
+        self.ios = [self.add_io(iotype=iotype) for iotype in self.iotypes]
+        self.sr = self.add_shiftreg(ircode=4, length=3)
+
+        # create and connect wishbone 
+        self.wb = self.add_wishbone(ircodes=[5, 6, 7],
+                                   address_width=29, data_width=64)
+
+        # create DMI2JTAG (goes through to dmi_sim())
+        self.dmi = self.add_dmi(ircodes=[8, 9, 10])
+
+    def elaborate(self, platform):
+        return super().elaborate(platform)
+
+
+if __name__ == '__main__':
+    dut = JTAG()
+
+    vl = rtlil.convert(dut)
+    with open("test_jtag.il", "w") as f:
+        f.write(vl)
+