a11e45dff5081091884082dbf30eee6b018c929d
4 def missing_numbers(num_list
):
5 original_list
= [x
for x
in range(num_list
[0], num_list
[-1] + 1)]
6 num_list
= set(num_list
)
7 return (list(num_list ^
set(original_list
)))
12 N_MUX
= 1 # number of selection lines for the mux per io
20 # Generating the number of bits for memory map #
22 if(Addressing
== 'BYTE'):
24 elif(Addressing
== 'HWORD'):
26 elif(Addressing
== 'WORD'):
28 elif(Addressing
== 'DWORD'):
31 print('ERROR: Addressing should be one of: BYTE, HWORD, WORD, DWORD')
34 # == capture the number of IO cells required == #
35 pinmapfile
= open('pinmap.txt', 'r')
41 for lineno
, line
in enumerate(pinmapfile
):
45 pinnumbers
.append(int(line1
[0]))
46 if len(line1
) == 2: # dedicated
47 dedicated_cells
.append(line1
)
49 muxed_cells
.append(line1
)
51 pinnumbers
= sorted(pinnumbers
)
52 upper_offset
= lower_offset
+ int(math
.log(len(muxed_cells
), 2))
54 # ============================================= #
55 # ======= Multiple checks to see if the user has not screwed ======#
56 missing_pins
= missing_numbers(pinnumbers
)
58 # Check-1: ensure that no pin is present in both muxed and dedicated pins
59 for muxcell
in muxed_cells
:
60 for dedcel
in dedicated_cells
:
61 if(dedcel
[1] in muxcell
):
62 print("ERROR: " + str(dedcel
[1]) + " present \
63 in dedicated & muxed lists")
66 # Check-2: if pin numbering is consistent:
68 print("ERROR: Following pins have no assignment: " +
69 str(missing_numbers(pinnumbers
)))
71 unique
= set(pinnumbers
)
74 count
= pinnumbers
.count(each
)
76 print("ERROR: Multiple assignment for pin: " + str(each
))
81 # Check-2: confirm if N_* matches the instances in the pinmap
82 # ============================================================== #
84 # == user info after parsin ================= #
85 N_IO
= len(dedicated_cells
) + len(muxed_cells
)
86 print("Max number of IO: " + str(N_IO
))
87 print("Muxed IOs: " + str(len(muxed_cells
)))
88 print("Dedicated IOs: " + str(len(dedicated_cells
)))
89 # ============================================ #
92 if __name__
== '__main__':