From bf08f76841dab3d8ee3ce2a38d3a717216279d13 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 14 Apr 2018 12:16:19 +0100 Subject: [PATCH] put cell width at fixed (max) bits --- src/bsv/pinmux_generator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bsv/pinmux_generator.py b/src/bsv/pinmux_generator.py index b80f65b..7a01fb3 100644 --- a/src/bsv/pinmux_generator.py +++ b/src/bsv/pinmux_generator.py @@ -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) -- 2.30.2