From 2f5feeceae2f50db56ea8cc52c2d91e59fc97bec Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 22 Sep 2020 13:01:00 +0100 Subject: [PATCH] add jtag interface to issuer_verilog --- src/soc/debug/dmi.py | 8 ++++++++ src/soc/debug/dmi2jtag.py | 3 +++ src/soc/debug/jtag.py | 8 +++++++- src/soc/simple/issuer.py | 17 ++++++++++++++++- src/soc/simple/issuer_verilog.py | 1 + 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/soc/debug/dmi.py b/src/soc/debug/dmi.py index 5875813c..39ea799b 100644 --- a/src/soc/debug/dmi.py +++ b/src/soc/debug/dmi.py @@ -61,6 +61,14 @@ class DMIInterface(RecordObject): self.we_i = Signal() # DMI write-enable self.ack_o = Signal() # DMI ack request + def connect_to(self, other): + return [self.addr_i.eq(other.addr_i), + self.req_i.eq(other.req_i), + self.we_i.eq(other.we_i), + self.din.eq(other.din), + other.ack_o.eq(self.ack_o), + other.dout.eq(self.dout), + ] class DbgReg(RecordObject): def __init__(self, name): diff --git a/src/soc/debug/dmi2jtag.py b/src/soc/debug/dmi2jtag.py index d178c14a..96b13b2d 100644 --- a/src/soc/debug/dmi2jtag.py +++ b/src/soc/debug/dmi2jtag.py @@ -133,6 +133,9 @@ class DMITAP(TAP): dmi.we_i.eq(ds.ongoing("WRRD")), ] + def external_ports(self): + return [self.bus.tdo, self.bus.tdi, self.bus.tms, self.bus.tck] + if __name__ == '__main__': dut = DMITAP(ir_width=4) diff --git a/src/soc/debug/jtag.py b/src/soc/debug/jtag.py index 9e28e47b..67dadd7b 100644 --- a/src/soc/debug/jtag.py +++ b/src/soc/debug/jtag.py @@ -19,7 +19,8 @@ class JTAG(DMITAP): # create and connect wishbone self.wb = self.add_wishbone(ircodes=[5, 6, 7], - address_width=29, data_width=64) + address_width=29, data_width=64, + name="jtag_wb") # create DMI2JTAG (goes through to dmi_sim()) self.dmi = self.add_dmi(ircodes=[8, 9, 10]) @@ -27,6 +28,11 @@ class JTAG(DMITAP): def elaborate(self, platform): return super().elaborate(platform) + def external_ports(self): + ports = super().external_ports() + ports += list(self.wb.fields.values()) + return ports + if __name__ == '__main__': dut = JTAG() diff --git a/src/soc/simple/issuer.py b/src/soc/simple/issuer.py index f0b2b1bf..332dda80 100644 --- a/src/soc/simple/issuer.py +++ b/src/soc/simple/issuer.py @@ -32,6 +32,7 @@ from soc.config.test.test_loadstore import TestMemPspec from soc.config.ifetch import ConfigFetchUnit from soc.decoder.power_enums import MicrOp from soc.debug.dmi import CoreDebug, DMIInterface +from soc.debug.jtag import JTAG from soc.config.state import CoreState from soc.interrupts.xics import XICS_ICP, XICS_ICS from soc.bus.simple_gpio import SimpleGPIO @@ -77,6 +78,11 @@ class TestIssuer(Elaboratable): # DMI interface self.dbg = CoreDebug() + # JTAG interface + self.jtag_en = hasattr(pspec, "debug") and pspec.debug == 'jtag' + if self.jtag_en: + self.jtag = JTAG() + # instruction go/monitor self.pc_o = Signal(64, reset_less=True) self.pc_i = Data(64, "pc_i") # set "ok" to indicate "please change me" @@ -109,6 +115,9 @@ class TestIssuer(Elaboratable): m.submodules.core = core = DomainRenamer("coresync")(self.core) m.submodules.imem = imem = self.imem m.submodules.dbg = dbg = self.dbg + if self.jtag_en: + m.submodules.jtag = jtag = self.jtag + comb += dbg.dmi.connect_to(jtag.dmi) cur_state = self.cur_state @@ -400,7 +409,13 @@ class TestIssuer(Elaboratable): ports += [self.pc_o, self.memerr_o, self.core_bigendian_i, self.busy_o, ClockSignal(), ResetSignal(), ] - ports += list(self.dbg.dmi.ports()) + + if self.jtag_en: + ports += list(self.jtag.external_ports()) + else: + # don't add DMI if JTAG is enabled + ports += list(self.dbg.dmi.ports()) + ports += list(self.imem.ibus.fields.values()) ports += list(self.core.l0.cmpi.lsmem.lsi.slavebus.fields.values()) diff --git a/src/soc/simple/issuer_verilog.py b/src/soc/simple/issuer_verilog.py index 8cd713f8..820e5fd3 100644 --- a/src/soc/simple/issuer_verilog.py +++ b/src/soc/simple/issuer_verilog.py @@ -29,6 +29,7 @@ if __name__ == '__main__': #wb_data_wid=32, xics=True, gpio=False, # for test purposes + debug="jtag", # set to jtag or dmi units=units) dut = TestIssuer(pspec) -- 2.30.2