3 N_MUX
= 1 # number of selection lines for the mux per io
11 # Generating the number of bits for memory map #
13 if(Addressing
== 'BYTE'):
15 elif(Addressing
== 'HWORD'):
17 elif(Addressing
== 'WORD'):
19 elif(Addressing
== 'DWORD'):
22 print('ERROR: Addressing should be one of: BYTE, HWORD, WORD, DWORD')
26 def missing_numbers(num_list
):
27 original_list
= [x
for x
in range(num_list
[0], num_list
[-1] + 1)]
28 num_list
= set(num_list
)
29 return (list(num_list ^
set(original_list
)))
32 # == capture the number of IO cells required == #
33 pinmapfile
= open('pinmap.txt', 'r')
38 for lineno
, line
in enumerate(pinmapfile
):
41 pinnumbers
.append(int(line1
[0]))
42 if(len(line1
) == 2): # dedicated
43 dedicated_cells
.append(line1
)
45 muxed_cells
.append(line1
)
46 pinnumbers
= sorted(pinnumbers
)
48 upper_offset
= lower_offset
+ int(math
.log(len(muxed_cells
), 2))
49 # ============================================= #
50 # ======= Multiple checks to see if the user has not screwed ======#
51 missing_pins
= missing_numbers(pinnumbers
)
53 # Check-1: ensure that no pin is present in both muxed and dedicated pins
54 for muxcell
in muxed_cells
:
55 for dedcel
in dedicated_cells
:
56 if(dedcel
[1] in muxcell
):
57 print("ERROR: " + str(dedcel
[1]) + " present \
58 in dedicated & muxed lists")
61 # Check-2: if pin numbering is consistent:
63 print("ERROR: Following pins have no assignment: " +
64 str(missing_numbers(pinnumbers
)))
66 unique
= set(pinnumbers
)
69 count
= pinnumbers
.count(each
)
71 print("ERROR: Multiple assignment for pin: " + str(each
))
76 # Check-2: confirm if N_* matches the instances in the pinmap
77 # ============================================================== #
79 # == user info after parsin ================= #
80 N_IO
= len(dedicated_cells
) + len(muxed_cells
)
81 print("Max number of IO: " + str(N_IO
))
82 print("Muxed IOs: " + str(len(muxed_cells
)))
83 print("Dedicated IOs: " + str(len(dedicated_cells
)))
84 # ============================================ #