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 def __init__(self
, verify
=True):
36 # == capture the number of IO cells required == #
37 pinmapfile
= open('pinmap.txt', 'r')
40 self
.dedicated_cells
= []
43 for lineno
, line
in enumerate(pinmapfile
):
47 self
.pinnumbers
.append(int(line1
[0]))
48 if len(line1
) == 2: # dedicated
49 self
.dedicated_cells
.append(line1
)
51 self
.muxed_cells
.append(line1
)
53 self
.pinnumbers
= sorted(self
.pinnumbers
)
54 self
.upper_offset
= self
.lower_offset
+ \
55 int(math
.log(len(self
.muxed_cells
), 2))
60 # == user info after parsing ================= #
61 self
.N_IO
= len(self
.dedicated_cells
) + len(self
.muxed_cells
)
62 print("Max number of IO: " + str(self
.N_IO
))
63 print("Muxed IOs: " + str(len(self
.muxed_cells
)))
64 print("Dedicated IOs: " + str(len(self
.dedicated_cells
)))
67 """ Multiple checks to see if the user has not screwed up
69 missing_pins
= missing_numbers(self
.pinnumbers
)
71 # Check-1: ensure no pin is present in both muxed and dedicated pins
72 for muxcell
in self
.muxed_cells
:
73 for dedcel
in self
.dedicated_cells
:
74 if dedcel
[1] in muxcell
:
75 print("ERROR: " + str(dedcel
[1]) + " present \
76 in dedicated & muxed lists")
79 # Check-2: if pin numbering is consistent:
81 print("ERROR: Following pins have no assignment: " +
82 str(missing_numbers(self
.pinnumbers
)))
84 unique
= set(self
.pinnumbers
)
87 count
= self
.pinnumbers
.count(each
)
89 print("ERROR: Multiple assignment for pin: " + str(each
))
94 # Check-3: confirm if N_* matches the instances in the pinmap
95 # ============================================================== #
99 if __name__
== '__main__':