fix bug in dedicated cell type detection
[pinmux.git] / src / bsv / actual_pinmux.py
index 1975e480c090ee5b392ccd433df2edc9a43c540e..e37fc5888f0a548dfa2d4d9d70072cdc2077ab74 100644 (file)
@@ -64,12 +64,14 @@ def fmt(ifaces, cell, idx, suffix=None):
     temp = transfn(cell)
     x = ifaces.getifacetype(temp)
     if x == 'input':
-        return '0' # inputs don't get passed through to the out mux
+        return '0'  # inputs don't get passed through to the out mux
     if suffix == '_outen' and x == 'out':
         return '1'
     return "wr%s%s" % (cell, suffix or '')
 
 # XXX this needs to move into interface_decl.py
+
+
 def mkcomment(ifaces, cell, idx, outenmode=False):
     """ returns a comment string for the cell when muxed
     """
@@ -93,6 +95,10 @@ def mkcomment(ifaces, cell, idx, outenmode=False):
 
 
 def mkmux(p, ifaces, cell, suffix, outenmode):
+    """ creates a straight many-to-one muxer that accepts
+        multiple inputs and, based on an "address" routes
+        a given indexed input through to the (one) output
+    """
     comment = 'outen' if outenmode else 'output'
     fmtstr = "\t\t\twr%s==%d?%s:%s\n"  # mux-selector format
     ret = ''
@@ -104,11 +110,12 @@ def mkmux(p, ifaces, cell, suffix, outenmode):
         cf = fmt(ifaces, cell, i, suffix)
         ret += fmtstr % (cn(cell[0]), i, cf, comment)
     comment = mkcomment(ifaces, cell, i + 1, outenmode)
-    ret += "\t\t\t" + fmt(ifaces, cell, i + 1, suffix) # last line
+    ret += "\t\t\t" + fmt(ifaces, cell, i + 1, suffix)  # last line
     ret += ";%s\n" % comment
 
     return ret
 
+
 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
@@ -171,14 +178,20 @@ def init(p, ifaces):
     # ============================================================ #
 
     # ==================  Logic for dedicated pins ========= #
+    p.pinmux += "\n      /*=========================================*/\n"
+    p.pinmux += "      // dedicated cells\n\n"
     for cell in p.dedicated_cells:
+        p.pinmux += "      // dedicated cell idx %s\n" % (cell[0])
         p.pinmux += "      %s_out=%s_io;\n" % (cn(cell[0]), cell[1])
-        temp = cell[1].translate(digits)
+        temp = transfn(cell[1])
         x = ifaces.getifacetype(temp)
+        #print cell, temp, x
         if x == "input":
-            pinmux = pinmux + \
+            p.pinmux += \
                 dedicated_wire.format(cell[0], "wr" + cell[1]) + "\n"
         elif x == "inout":
-            pinmux = pinmux + \
+            p.pinmux += \
                 dedicated_wire.format(cell[0], "wr" + cell[1] + "_in") + "\n"
+        else:
+            p.pinmux += "\n"
     # =======================================================#