3 N_MUX
= 1 # number of selection lines for the mux per io
17 # Generating the number of bits for memory map #
19 if(Addressing
== 'BYTE'):
21 elif(Addressing
== 'HWORD'):
23 elif(Addressing
== 'WORD'):
25 elif(Addressing
== 'DWORD'):
28 print('ERROR: Addressing should be one of: BYTE, HWORD, WORD, DWORD')
32 def missing_numbers(num_list
):
33 original_list
= [x
for x
in range(num_list
[0], num_list
[-1] + 1)]
34 num_list
= set(num_list
)
35 return (list(num_list ^
set(original_list
)))
38 # == capture the number of IO cells required == #
39 pinmapfile
= open('pinmap.txt', 'r')
44 for lineno
, line
in enumerate(pinmapfile
):
47 pinnumbers
.append(int(line1
[0]))
48 if(len(line1
) == 2): # dedicated
49 dedicated_cells
.append(line1
)
51 muxed_cells
.append(line1
)
52 pinnumbers
= sorted(pinnumbers
)
54 upper_offset
= lower_offset
+ int(math
.log(len(muxed_cells
), 2))
55 # ============================================= #
56 # ======= Multiple checks to see if the user has not screwed ======#
57 missing_pins
= missing_numbers(pinnumbers
)
59 # Check-1: ensure that no pin is present in both muxed and dedicated pins
60 for muxcell
in muxed_cells
:
61 for dedcel
in dedicated_cells
:
62 if(dedcel
[1] in muxcell
):
63 print("ERROR: " + str(dedcel
[1]) + " present \
64 in dedicated & muxed lists")
67 # Check-2: if pin numbering is consistent:
69 print("ERROR: Following pins have no assignment: " +
70 str(missing_numbers(pinnumbers
)))
72 unique
= set(pinnumbers
)
75 count
= pinnumbers
.count(each
)
77 print("ERROR: Multiple assignment for pin: " + str(each
))
82 # Check-2: confirm if N_* matches the instances in the pinmap
83 # ============================================================== #
85 # == user info after parsin ================= #
86 N_IO
= len(dedicated_cells
) + len(muxed_cells
)
87 print("Max number of IO: " + str(N_IO
))
88 print("Muxed IOs: " + str(len(muxed_cells
)))
89 print("Dedicated IOs: " + str(len(dedicated_cells
)))
90 # ============================================ #