maketrans = str.maketrans
-# dictionary of properties of signals that are supported.
-dictionary = {
- "uart_rx" : "input",
- "uart_tx" : "output",
- "spi_sclk" : "output",
- "spi_mosi" : "output",
- "spi_ss" : "output",
- "spi_miso" : "input",
- "twi_sda" : "inout",
- "twi_scl" : "inout",
- "sd_clk": "output",
- "sd_cmd": "output",
- "sd_d": "inout",
- "pwm_pwm": "output"
-}
-
-
# ============== common bsv templates ============ #
# first argument is the io-cell number being assigned.
# second argument is the mux value.
return "cell%s_mux" % str(idx)
-def init(p):
+def transfn(temp):
+ temp = temp.split('_')
+ if len(temp) == 2:
+ temp[0] = temp[0].translate(digits)
+ temp[0] = temp[0] .replace(' ', '')
+ return '_'.join(temp)
+
+
+def init(p, ifaces):
p.pinmux = ' '
global dedicated_wire
for cell in p.muxed_cells:
# since the interfaces are always standard and cannot change from
# user-to-user. Plus this also reduces human-error as well :)
for i in range(0, len(cell) - 1):
- temp = cell[i + 1].translate(digits)
- temp = temp.replace(' ', '')
- x = dictionary.get(temp)
+ cname = cell[i+1]
+ temp = transfn(cname)
+ x = ifaces.getifacetype(temp)
+ print cname, temp, x
assert x is not None, "ERROR: The signal : " + \
- str(cell[i + 1]) + \
+ str(cname) + \
" of pinmap.txt isn't present \nin the current" + \
" dictionary. Update dictionary or fix-typo."
if x == "input":
p.pinmux += \
- mux_wire.format(cell[0], i, "wr" + cell[i + 1]) + "\n"
+ mux_wire.format(cell[0], i, "wr" + cname) + "\n"
elif x == "inout":
p.pinmux += \
- mux_wire.format(cell[0], i, "wr" + cell[i + 1] +
+ mux_wire.format(cell[0], i, "wr" + cname +
"_in") + "\n"
# ============================================================ #
# ================== Logic for dedicated pins ========= #
for cell in p.dedicated_cells:
- p.pinmux += " %s" % cn(cell[0]) + \
- "_out=" + cell[1] + "_io;\n"
+ p.pinmux += " %s_out=%s_io;\n" % (cn(cell[0]), cell[1])
temp = cell[1].translate(digits)
- x = dictionary.get(temp)
+ x = ifaces.getifacetype(temp)
if x == "input":
pinmux = pinmux + \
dedicated_wire.format(cell[0], "wr" + cell[1]) + "\n"
_p['name'] = self.pname(p['name'])
self.pins.append(Pin(**_p))
+ def getifacetype(self, name):
+ for p in self.pinspecs:
+ fname = "%s_%s" % (self.ifacename, p['name'])
+ print "search", self.ifacename, name, fname
+ if fname == name:
+ if p.get('action'):
+ return 'out'
+ elif p.get('outen'):
+ return 'inout'
+ return 'input'
+ return None
+
def pname(self, name):
return '%s{0}_%s' % (self.ifacename, name)
spec = self.read_spec(pth, name)
self.ifaceadd(name, count, Interface(name, spec))
+ def getifacetype(self, fname):
+ # finds the interface type, e.g sd_d0 returns "inout"
+ for iface in self.values():
+ typ = iface.getifacetype(fname)
+ if typ:
+ return typ
+ return None
+
def ifaceadd(self, name, count, iface, at=None):
if at is None:
at = len(self.ifacecount)