put cell width at fixed (max) bits
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 14 Apr 2018 11:16:19 +0000 (12:16 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 14 Apr 2018 11:16:55 +0000 (12:16 +0100)
src/bsv/pinmux_generator.py

index b80f65b9f05f54d03f53f6b86bd3d7de9150a1d8..7a01fb33ccfc8589f3c029fbd93e27b0f3b681d0 100644 (file)
@@ -141,9 +141,14 @@ def write_pmp(pmp, p, ifaces):
       // the followins wires capture the pin-mux selection
       // values for each mux assigned to a CELL
 ''')
+        max_num_cells = 0
+        for cell in p.muxed_cells:
+                max_num_cells = max(len(cell)-1, max_num_cells)
+        cell_bit_width = 'Bit#(%d)' %int(math.log(max_num_cells, 2))
+
         for cell in p.muxed_cells:
             bsv_file.write(mux_interface.wirefmt(
-                cell[0], 'Bit#(' + str(int(math.log(len(cell) - 1, 2))) + ')'))
+                cell[0], cell_bit_width))
 
         ifaces.wirefmt(bsv_file)