makefile for gpio and removing dependent files in gpio
[pinmux.git] / src / parse.py
index aeb0c8b429d29a4f960d847fb272e409dc76648b..3d508d651b63612de1385adb7f42076f1faa99aa 100644 (file)
@@ -45,7 +45,7 @@ class Parse(object):
             fname = os.path.join(pth, fname)
         with open(fname) as pinmapfile:
             for lineno, line in enumerate(pinmapfile):
-                line1 = line.split()
+                line1 = line[:-1].split('\t')
                 if len(line1) <= 1:
                     continue
                 self.pinnumbers.append(int(line1[0]))
@@ -56,14 +56,17 @@ class Parse(object):
 
         self.pinnumbers = sorted(self.pinnumbers)
         self.upper_offset = self.lower_offset + \
-                            int(math.log(len(self.muxed_cells), 2))
+            int(math.log(len(self.muxed_cells), 2))
 
         if verify:
             self.do_checks()
 
+        self.cell_bitwidth = self.get_cell_bit_width()
+
         # == user info after parsing ================= #
         self.N_IO = len(self.dedicated_cells) + len(self.muxed_cells)
         print("Max number of IO: " + str(self.N_IO))
+        print("Muxer bit width: " + str(self.cell_bitwidth))
         print("Muxed IOs: " + str(len(self.muxed_cells)))
         print("Dedicated IOs: " + str(len(self.dedicated_cells)))
 
@@ -100,6 +103,13 @@ class Parse(object):
 
         # TODO
 
+    def get_cell_bit_width(self):
+        max_num_cells = 0
+        for cell in self.muxed_cells:
+            max_num_cells = max(len(cell) - 1, max_num_cells)
+        return int(math.log(max_num_cells + 1, 2))
+
+
 if __name__ == '__main__':
     p = Parse()
-    print p.N_IO
+    print (p.N_IO)