From f44d86ac7c52af943bd71c80e9b7f4c59af264e7 Mon Sep 17 00:00:00 2001 From: Neel Date: Tue, 13 Mar 2018 17:36:03 +0530 Subject: [PATCH] mux selection lines for a IO should be log of the number of muxes. --- src/pinmux_generator.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pinmux_generator.py b/src/pinmux_generator.py index 0de361f..06c45ac 100644 --- a/src/pinmux_generator.py +++ b/src/pinmux_generator.py @@ -19,6 +19,7 @@ import os import sys import time +import math # project module imports from interface_decl import * @@ -75,7 +76,8 @@ bsv_file.write(''' // where each IO will have the same number of muxes.''') for cell in muxed_cells: - bsv_file.write(mux_interface.format(cell[0], len(cell) - 1)) + bsv_file.write(mux_interface.format(cell[0], + int(math.log(len(cell) - 1, 2)))) bsv_file.write(''' @@ -118,7 +120,7 @@ bsv_file.write(''' // values for each mux assigned to a CELL ''') for cell in muxed_cells: - bsv_file.write(muxwire.format(cell[0], len(cell) - 1)) + bsv_file.write(muxwire.format(cell[0], int(math.log(len(cell) - 1, 2)))) bsv_file.write( @@ -156,7 +158,8 @@ bsv_file.write(''' # ==================================================================== # ================= interface definitions for each method =============# for cell in muxed_cells: - bsv_file.write(mux_interface_def.format(cell[0], len(cell) - 1)) + bsv_file.write(mux_interface_def.format(cell[0], + int(math.log(len(cell) - 1, 2)))) for i in range(0, N_IO): bsv_file.write(io_interface_def.format(i)) for i in range(0, N_UART): -- 2.30.2