renaming params.py to parse.py. Adding checks on input
[pinmux.git] / src / parse.py
1 # == Parameters == #
2 N_MUX = 1 # number of selection lines for the mux per io
3 N_IO = 0
4 N_MUX_IO = 0
5 N_UART = 4
6 N_SPI = 1
7 N_TWI = 2
8 # ================ #
9 # == capture the number of IO cells required == #
10 pinmapfile = open('pinmap.txt', 'r')
11 max_io = 0
12 muxed_cells = []
13 dedicated_cells = []
14 for lineno, line in enumerate(pinmapfile):
15 line1 = line.split()
16 if(len(line1) > 1):
17 if(len(line1) == 2): # dedicated
18 dedicated_cells.append(line1)
19 if(len(line1) > 2):
20 muxed_cells.append(line1)
21 # ============================================= #
22
23 # ======= Multiple checks to see if the user has not screwed ======#
24
25 # Check-1: ensure that no pin is present in both muxed and dedicated pins
26 for muxcell in muxed_cells:
27 for dedcel in dedicated_cells:
28 if(dedcel[1] in muxcell):
29 print("ERROR: " + str(dedcel[1]) + " present \
30 in dedicated & muxed lists")
31 exit(1)
32 # Check-2: confirm if N_* matches the instances in the pinmap
33 # ============================================================== #
34
35 # == user info after parsin ================= #
36 N_IO = len(dedicated_cells) + len(muxed_cells)
37 print("Max number of IO: " + str(N_IO))
38 print("Muxed IOs: " + str(len(muxed_cells)))
39 print("Dedicated IOs: " + str(len(dedicated_cells)))
40 # ============================================ #