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.
digits = maketrans('0123456789', ' ' * 10) # delete space later
-def cn(idx):
+def cn(idx): # idx is an integer
return "cell%s_mux" % str(idx)
-def init(p):
+def transfn(temp):
+ """ removes the number from the string of signal name.
+ """
+ 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):
+ """ generates the actual output pinmux for each io-cell. blank lines
+ need to output "0" to the iopad, if there is no entry in
+ that column.
+ """
p.pinmux = ' '
global dedicated_wire
for cell in p.muxed_cells:
+ p.pinmux += " // output muxer for cell idx %s\n" % cell[0]
p.pinmux += " %s_out=" % cn(cell[0])
for i in range(0, len(cell) - 2):
p.pinmux += "wr%s" % cn(cell[0]) + \
# 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]
+ if not cname: # skip blank entries, no need to test
+ continue
+ 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"