From 7dfe31a4639898fb51d2a8ca6dc3aebe19682eb6 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 10 Jul 2018 05:30:02 +0100 Subject: [PATCH] move cell bit width function to Parse class --- src/bsv/actual_pinmux.py | 8 -------- src/parse.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bsv/actual_pinmux.py b/src/bsv/actual_pinmux.py index d2ce816..fd61085 100644 --- a/src/bsv/actual_pinmux.py +++ b/src/bsv/actual_pinmux.py @@ -24,13 +24,6 @@ dedicated_wire = ''' digits = maketrans('0123456789', ' ' * 10) # delete space later -def get_cell_bit_width(p): - max_num_cells = 0 - for cell in p.muxed_cells: - max_num_cells = max(len(cell) - 1, max_num_cells) - return int(math.log(max_num_cells + 1, 2)) - - def cn(idx): # idx is an integer return "cell%s_mux" % str(idx) @@ -147,7 +140,6 @@ def init(p, ifaces): the last one, and we do not want the "default" (last line) to be the output. """ - p.cell_bitwidth = get_cell_bit_width(p) p.pinmux = ' ' global dedicated_wire for cell in p.muxed_cells: diff --git a/src/parse.py b/src/parse.py index af70d1a..9c45944 100644 --- a/src/parse.py +++ b/src/parse.py @@ -61,9 +61,12 @@ class Parse(object): 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() -- 2.30.2