d9358779b4cf06fcaed5af18c2d6e7f77b2f8322
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')
40 for lineno
, line
in enumerate(pinmapfile
):
43 pinnumbers
.append(int(line1
[0]))
44 if(len(line1
) == 2): # dedicated
45 dedicated_cells
.append(line1
)
47 muxed_cells
.append(line1
)
48 pinnumbers
= sorted(pinnumbers
)
50 upper_offset
= lower_offset
+ int(math
.log(len(muxed_cells
), 2))
51 # ============================================= #
52 # ======= Multiple checks to see if the user has not screwed ======#
53 missing_pins
= missing_numbers(pinnumbers
)
55 # Check-1: ensure that no pin is present in both muxed and dedicated pins
56 for muxcell
in muxed_cells
:
57 for dedcel
in dedicated_cells
:
58 if(dedcel
[1] in muxcell
):
59 print("ERROR: " + str(dedcel
[1]) + " present \
60 in dedicated & muxed lists")
63 # Check-2: if pin numbering is consistent:
65 print("ERROR: Following pins have no assignment: " +
66 str(missing_numbers(pinnumbers
)))
68 unique
= set(pinnumbers
)
71 count
= pinnumbers
.count(each
)
73 print("ERROR: Multiple assignment for pin: " + str(each
))
78 # Check-2: confirm if N_* matches the instances in the pinmap
79 # ============================================================== #
81 # == user info after parsin ================= #
82 N_IO
= len(dedicated_cells
) + len(muxed_cells
)
83 print("Max number of IO: " + str(N_IO
))
84 print("Muxed IOs: " + str(len(muxed_cells
)))
85 print("Dedicated IOs: " + str(len(dedicated_cells
)))
86 # ============================================ #
89 if __name__
== '__main__':