remove write_ptp, add bitwidths.txt file
[pinmux.git] / src / parse.py
index 16927efa841235a3d27c110def4e7868b9fea02c..6ab3dd094230c4a3ce66f34f8f0f8228da78342c 100644 (file)
@@ -13,33 +13,27 @@ class Parse(object):
     N_MUX = 1          # number of selection lines for the mux per io
     N_IO = 0
     N_MUX_IO = 0
-    Addressing = 'WORD'
     ADDR_WIDTH = 64  # TODO parameterise
     PADDR_WIDTH = 32  # TODO parameterise
     DATA_WIDTH = 64  # TODO parameterise
     # ================ #
 
-    # Generating the number of bits for memory map #
-    lower_offset = 0
-    if Addressing == 'BYTE':
-        lower_offset = 0
-    elif Addressing == 'HWORD':
-        lower_offset = 1
-    elif Addressing == 'WORD':
-        lower_offset = 2
-    elif Addressing == 'DWORD':
-        lower_offset = 3
-    else:
-        print('ERROR: Addressing should be one of: BYTE, HWORD, WORD, DWORD')
-        exit(1)
-
     def __init__(self, pth=None, verify=True):
 
         max_io = 0
         self.muxed_cells = []
         self.dedicated_cells = []
         self.pinnumbers = []
+        self.bankwidths = {} 
 
+        fname = 'bankwidths.txt'
+        if pth:
+            fname = os.path.join(pth, fname)
+        with open(fname) as bankwidths:
+            for lineno, line in enumerate(bankwidths):
+                line1 = line[:-1].split('\t')
+                self.bankwidths[line1[0]] = int(line1[1])
+            
         # == capture the number of IO cells required == #
         fname = 'pinmap.txt'
         if pth:
@@ -47,7 +41,7 @@ class Parse(object):
         with open(fname) as pinmapfile:
             for lineno, line in enumerate(pinmapfile):
                 line1 = line[:-1].split('\t')
-                if len(line1) <= 1:
+                if len(line1) <= 2:
                     continue
                 self.pinnumbers.append(int(line1[0]))
                 # XXX TODO: dedicated pins in separate file
@@ -61,20 +55,19 @@ class Parse(object):
                 self.muxed_cells.append(line1)
 
         self.pinnumbers = sorted(self.pinnumbers)
-        self.upper_offset = self.lower_offset + \
-            int(math.log(len(self.muxed_cells), 2))
 
         if verify:
             self.do_checks()
 
-        self.cell_bitwidth = self.get_cell_bit_width()
+        #self.cell_bitwidth = self.get_cell_bit_widths()
 
         # == 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("Muxer bit width: " + str(self.cell_bitwidth))
         print("Muxed IOs: " + str(len(self.muxed_cells)))
         print("Dedicated IOs: " + str(len(self.dedicated_cells)))
+        #sys.exit(0)
 
     def do_checks(self):
         """ Multiple checks to see if the user has not screwed up
@@ -109,9 +102,10 @@ class Parse(object):
 
         # TODO
 
-    def get_cell_bit_width(self):
+    def get_cell_bit_widths(self, banks):
         max_num_cells = 0
         for cell in self.muxed_cells:
+            print cell
             max_num_cells = max(len(cell) - 1, max_num_cells)
         return int(math.log(max_num_cells + 1, 2))