From: Neel Date: Tue, 13 Mar 2018 12:43:35 +0000 (+0530) Subject: renaming params.py to parse.py. Adding checks on input X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=445782ffd34ed8dc35fc12319d5eb0aff1db535e;p=pinmux.git renaming params.py to parse.py. Adding checks on input See #3. Added check to see if muxed lists and dedicated lists do not have any duplciates. This can simulated by replacing uart1_tx to uart2_tx in pinmap.txt. --- diff --git a/src/actual_pinmux.py b/src/actual_pinmux.py index 37c8cdf..02603a9 100644 --- a/src/actual_pinmux.py +++ b/src/actual_pinmux.py @@ -1,4 +1,4 @@ -from params import * +from parse import * from string import digits diff --git a/src/interface_decl.py b/src/interface_decl.py index 145eeaf..826614d 100644 --- a/src/interface_decl.py +++ b/src/interface_decl.py @@ -1,5 +1,3 @@ -from params import * - # ========= Interface declarations ================ # mux_interface = ''' method Action cell{0}_mux(Bit#({1}) in);''' diff --git a/src/interface_def.py b/src/interface_def.py index 12fa6c9..209cb7a 100644 --- a/src/interface_def.py +++ b/src/interface_def.py @@ -1,4 +1,3 @@ -from params import * # === templates for interface definitions ====== # mux_interface_def = ''' method Action cell{0}_mux (Bit#({1}) in ); diff --git a/src/params.py b/src/params.py deleted file mode 100644 index d191697..0000000 --- a/src/params.py +++ /dev/null @@ -1,32 +0,0 @@ -# == Parameters == # -N_MUX = 1 # number of selection lines for the mux per io -N_IO = 0 -N_MUX_IO = 0 -N_UART = 4 -N_SPI = 1 -N_TWI = 2 -# ================ # -# == capture the number of IO cells required == # -pinmapfile = open('pinmap.txt', 'r') -max_io = 0 -muxed_cells = [] -dedicated_cells = [] -for lineno, line in enumerate(pinmapfile): - line1 = line.split() - if(len(line1) > 1): - if(len(line1) == 2): # dedicated - dedicated_cells.append(line1) - if(len(line1) > 2): - muxed_cells.append(line1) -# ============================================= # - -# check if the user has not screwed up by ensuring that no pin is -# present in both muxed and dedicated pins -# TODO - -# =========================================== # -N_IO = len(dedicated_cells) + len(muxed_cells) -print("Max number of IO: " + str(N_IO)) -print("Muxed IOs: " + str(len(muxed_cells))) -print("Dedicated IOs: " + str(len(dedicated_cells))) -# ============================================ # diff --git a/src/parse.py b/src/parse.py new file mode 100644 index 0000000..db7a48a --- /dev/null +++ b/src/parse.py @@ -0,0 +1,40 @@ +# == Parameters == # +N_MUX = 1 # number of selection lines for the mux per io +N_IO = 0 +N_MUX_IO = 0 +N_UART = 4 +N_SPI = 1 +N_TWI = 2 +# ================ # +# == capture the number of IO cells required == # +pinmapfile = open('pinmap.txt', 'r') +max_io = 0 +muxed_cells = [] +dedicated_cells = [] +for lineno, line in enumerate(pinmapfile): + line1 = line.split() + if(len(line1) > 1): + if(len(line1) == 2): # dedicated + dedicated_cells.append(line1) + if(len(line1) > 2): + muxed_cells.append(line1) +# ============================================= # + +# ======= Multiple checks to see if the user has not screwed ======# + +# Check-1: ensure that no pin is present in both muxed and dedicated pins +for muxcell in muxed_cells: + for dedcel in dedicated_cells: + if(dedcel[1] in muxcell): + print("ERROR: " + str(dedcel[1]) + " present \ + in dedicated & muxed lists") + exit(1) +# Check-2: confirm if N_* matches the instances in the pinmap +# ============================================================== # + +# == user info after parsin ================= # +N_IO = len(dedicated_cells) + len(muxed_cells) +print("Max number of IO: " + str(N_IO)) +print("Muxed IOs: " + str(len(muxed_cells))) +print("Dedicated IOs: " + str(len(dedicated_cells))) +# ============================================ # diff --git a/src/pinmux_generator.py b/src/pinmux_generator.py index 06c45ac..8b25d9e 100644 --- a/src/pinmux_generator.py +++ b/src/pinmux_generator.py @@ -24,7 +24,7 @@ import math # project module imports from interface_decl import * from interface_def import * -from params import * +from parse import * from wire_def import * from actual_pinmux import * diff --git a/src/wire_def.py b/src/wire_def.py index 0cd9cb2..da5fbef 100644 --- a/src/wire_def.py +++ b/src/wire_def.py @@ -1,4 +1,3 @@ -from params import * # == Intermediate wire definitions ==# muxwire = ''' Wire#(Bit#({1})) wrmux{0} <-mkDWire(0);'''