from wishbone import Wishbone
__all__ = [
- "PmodJTAGMasterResource",
- "PmodJTAGMasterAResource",
- "PmodJTAGSlaveResource",
- "PmodJTAGSlaveAResource",
"JTAG",
]
#TODO: Provide more documentation
-def PmodJTAGMasterResource(name, number, *, pmod, attrs=Attrs(IOSTANDARD="LVCMOS33")):
- return Resource(name, number,
- Subsignal("TCK", Pins("1", dir="o", conn=("pmod", pmod))),
- Subsignal("TMS", Pins("2", dir="o", conn=("pmod", pmod))),
- Subsignal("TDO", Pins("3", dir="o", conn=("pmod", pmod))),
- Subsignal("TDI", Pins("4", dir="i", conn=("pmod", pmod))),
- attrs,
- )
-
-def PmodJTAGMasterAResource(name, number, *, pmod, attrs=Attrs(IOSTANDARD="LVCMOS33")):
- return Resource(name, number,
- Subsignal("TCK", Pins("1", dir="o", conn=("pmod", pmod))),
- Subsignal("TMS", Pins("2", dir="o", conn=("pmod", pmod))),
- Subsignal("TDO", Pins("3", dir="o", conn=("pmod", pmod))),
- Subsignal("TDI", Pins("4", dir="i", conn=("pmod", pmod))),
- Subsignal("TRST", PinsN("7", dir="o", conn=("pmod", pmod))),
- attrs,
- )
-
-def PmodJTAGSlaveResource(name, number, *, pmod, attrs=Attrs(IOSTANDARD="LVCMOS33")):
- return Resource(name, number,
- Subsignal("TCK", Pins("1", dir="i", conn=("pmod", pmod))),
- Subsignal("TMS", Pins("2", dir="i", conn=("pmod", pmod))),
- Subsignal("TDI", Pins("3", dir="i", conn=("pmod", pmod))),
- Subsignal("TDO", Pins("4", dir="o", conn=("pmod", pmod))),
- attrs,
- )
-
-def PmodJTAGSlaveAResource(name, number, *, pmod, attrs=Attrs(IOSTANDARD="LVCMOS33")):
- return Resource(name, number,
- Subsignal("TCK", Pins("1", dir="i", conn=("pmod", pmod))),
- Subsignal("TMS", Pins("2", dir="i", conn=("pmod", pmod))),
- Subsignal("TDI", Pins("3", dir="i", conn=("pmod", pmod))),
- Subsignal("TDO", Pins("4", dir="o", conn=("pmod", pmod))),
- Subsignal("TRST", PinsN("7", dir="i", conn=("pmod", pmod))),
- attrs,
- )
-
class ShiftReg(Elaboratable):
def __init__(self, ircodes, length, domain):
--- /dev/null
+from nmigen.build import *
+
+__all__ = [
+ "PmodJTAGResource",
+]
+
+
+def PmodJTAGResource(*args, pmod_name="pmod", pmod_number, attrs=None,
+ master=False, reset=False):
+ """Get a resource for a JTAG pins on a pmod.
+
+ The pins are configured in such a way that the master pmod jtag can
+ be connected to the tap pmod with a straight cable.
+
+ Args:
+ *args: either number or name, number.
+ pmod_name (str): name of the pmod connector; default = "pmod"
+ pmod_number (int): number of pmod connector
+ attrs (Attrs): attributes for the ``Resource``
+ master (bool): wether if this a master interface
+ reset (bool): wether to include a reset signal
+ """
+ if master:
+ mosi = "o"
+ miso = "i"
+ tdo_pin = "3"
+ tdi_pin = "4"
+ else:
+ mosi = "i"
+ miso = "o"
+ tdo_pin = "4"
+ tdi_pin = "3"
+ conn = (pmod_name, pmod_number)
+
+ ios = [
+ Subsignal("tck", Pins("1", dir=mosi, conn=conn)),
+ Subsignal("tms", Pins("2", dir=mosi, conn=conn)),
+ Subsignal("tdo", Pins(tdo_pin, dir="o", conn=conn)),
+ Subsignal("tdi", Pins(tdi_pin, dir="i", conn=conn)),
+ ]
+ if reset:
+ ios.append(Subsignal("trst", PinsN("7", dir=mosi, conn=conn)))
+ if attrs is not None:
+ ios.append(attrs)
+
+ return Resource.family(*args, default_name="jtag", ios=ios)