skip blank-string entries
[pinmux.git] / src / bsv / actual_pinmux.py
index 982cf46bf2f44113eb9799e46f125d9e341b42e0..65473e099acb2cb10e6fda2ff4bfce2e200a28af 100644 (file)
@@ -10,8 +10,10 @@ except ImportError:
 # second argument is the mux value.
 # Third argument is the signal from the pinmap file
 mux_wire = '''
-        if(wrcell{0}_mux=={1})
-            {2}<=cell{0}_mux_in;'''
+      rule assign_{2}_on_cell{0}(wrcell{0}_mux=={1});
+        {2}<=cell{0}_mux_in;
+      endrule
+'''
 dedicated_wire = '''
       rule assign_{1}_on_cell{0};
         {1}<=cell{0}_mux_in;
@@ -21,11 +23,13 @@ dedicated_wire = '''
 digits = maketrans('0123456789', ' ' * 10)  # delete space later
 
 
-def cn(idx):
+def cn(idx):  # idx is an integer
     return "cell%s_mux" % str(idx)
 
 
 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)
@@ -34,9 +38,14 @@ def transfn(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]) + \
@@ -45,15 +54,15 @@ def init(p, ifaces):
         p.pinmux += ";\n"
         # ======================================================== #
 
-    # check each cell if "peripheral input/inout" then assign its wire
-    # Here we check the direction of each signal in the dictionary.
-    # We choose to keep the dictionary within the code and not user-input
-    # since the interfaces are always standard and cannot change from
-    # user-to-user. Plus this also reduces human-error as well :)
-    p.pinmux += "      rule assign_inputs_from_io_to_wires;"
-    for cell in p.muxed_cells:
+        # check each cell if "peripheral input/inout" then assign its wire
+        # Here we check the direction of each signal in the dictionary.
+        # We choose to keep the dictionary within the code and not user-input
+        # 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):
             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)
@@ -68,7 +77,6 @@ def init(p, ifaces):
                 p.pinmux += \
                     mux_wire.format(cell[0], i, "wr" + cname +
                                                 "_in") + "\n"
-    p.pinmux += "      endrule\n"
     # ============================================================ #
 
     # ==================  Logic for dedicated pins ========= #