-from soc.debug.jtag import Pins, dummy_pinset # TODO move to suitable location
-from c4m.nmigen.jtag.tap import IOType
-from litex.build.generic_platform import ConstraintManager
-
-
-def make_pad(res, dirn, name, suffix, cpup, iop):
- cpud, iod = ('i', 'o') if dirn else ('o', 'i')
- res['%s_%s__core__%s' % (cpud, name, suffix)] = cpup
- res['%s_%s__pad__%s' % (iod, name, suffix)] = iop
-
-
-def make_jtag_ioconn(res, pin, cpupads, iopads):
- (fn, pin, iotype, pin_name, scan_idx) = pin
- #serial_tx__core__o, serial_rx__pad__i,
- print ("cpupads", cpupads)
- print ("iopads", iopads)
- print ("pin", fn, pin, iotype, pin_name)
- cpu = cpupads[fn]
- io = iopads[fn]
- sigs = []
-
- name = "%s_%s" % (fn, pin)
-
- if iotype in (IOType.In, IOType.Out):
- cpup = getattr(cpu, pin)
- iop = getattr(io, pin)
-
- if iotype == IOType.Out:
- # output from the pad is routed through C4M JTAG and so
- # is an *INPUT* into core. ls180soc connects this to "real" peripheral
- make_pad(res, True, name, "o", cpup, iop)
-
- elif iotype == IOType.In:
- # input to the pad is routed through C4M JTAG and so
- # is an *OUTPUT* into core. ls180soc connects this to "real" peripheral
- make_pad(res, False, name, "i", cpup, iop)
-
- elif iotype == IOType.InTriOut:
- if fn == 'gpio': # sigh decode GPIO special-case
- idx = int(pin[4:])
- cpup, iop = cpu.i[idx], io.i[idx]
- make_pad(res, False, name, "i", cpup, iop)
- cpup, iop = cpu.o[idx], io.o[idx]
- make_pad(res, True, name, "o", cpup, iop)
- cpup, iop = cpu.oe[idx], io.oe[idx]
- make_pad(res, True, name, "oe", cpup, iop)
-
- if iotype in (IOType.In, IOType.InTriOut):
- sigs.append(("i", 1))
- if iotype in (IOType.Out, IOType.TriOut, IOType.InTriOut):
- sigs.append(("o", 1))
- if iotype in (IOType.TriOut, IOType.InTriOut):
- sigs.append(("oe", 1))
-