res['o_%s__%s' % (prefix, o)] = getattr(obj, o)
return res
+def make_pad(res, dirn, name, suffix, cpup, iop):
+ cpud, iod = ('i', 'o') if dirn else ('o', 'i')
+ res['%s_%s__%s' % (cpud, name, suffix)] = cpup
+ res['%s_%s__%s' % (iod, name, suffix)] = iop
+
def make_jtag_ioconn(res, pin, cpupads, iopads):
(fn, pin, iotype, pin_name) = pin
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
- res['i_%s_%s_core__o' % (fn, pin)] = getattr(cpu, pin)
- res['o_%s_%s_pad__o' % (fn, pin)] = getattr(io, pin)
+ 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
- res['o_%s_%s_core__i' % (fn, pin)] = getattr(cpu, pin)
- res['i_%s_%s_pad__i' % (fn, pin)] = getattr(io, pin)
+ 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.TriOut, IOType.InTriOut):
sigs.append(("oe", 1))
+
class LibreSoC(CPU):
name = "libre_soc"
human_name = "Libre-SoC"
self.irq.add("uart", use_loc_if_exists=True)
# GPIOs (bi-directional)
- if False:
- gpio_core_pads = self.cpu.cpupads['gpio']
- self.submodules.gpio = GPIOTristateASIC(gpio_core_pads)
- self.add_csr("gpio")
-
- gpio_pads = platform.request("gpio_litex")
- gpio_io_pads = self.cpu.iopads['gpio'] # C4M JTAG pads
- self.comb += gpio_pads.i.eq(gpio_io_pads.i)
- self.comb += gpio_io_pads.o.eq(gpio_pads.o)
- self.comb += gpio_io_pads.oe.eq(gpio_pads.oe)
+ gpio_core_pads = self.cpu.cpupads['gpio']
+ self.submodules.gpio = GPIOTristateASIC(gpio_core_pads)
+ self.add_csr("gpio")
+
+ gpio_pads = platform.request("gpio_litex")
+ gpio_io_pads = self.cpu.iopads['gpio'] # C4M JTAG pads
+ self.comb += gpio_pads.i.eq(gpio_io_pads.i)
+ self.comb += gpio_io_pads.o.eq(gpio_pads.o)
+ self.comb += gpio_io_pads.oe.eq(gpio_pads.oe)
# SPI Master
self.submodules.spi_master = SPIMaster(