Skip to content

Commit af42e4f

Browse files
chore: Expand user design top wrapper gen
Expand the user design top wrapper generation to include the whole fabric. Signed-off-by: Jonas K. <[email protected]>
1 parent 8dd2a49 commit af42e4f

File tree

1 file changed

+51
-50
lines changed

1 file changed

+51
-50
lines changed

FABulous/fabric_cad/gen_design_top_wrapper.py

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -62,59 +62,60 @@ def generateUserDesignTopWrapper(
6262
bel_outputs: dict[str, list[str]] = {}
6363

6464
# generate component instantioations
65-
# we walk backwards through the list, since there is something mixed up with the coordinate system
66-
for y in range(fabric.numberOfRows - 1, -1, -1):
67-
bels = fabric.getBelsByTileXY(0, y)
68-
if not bels:
69-
continue
70-
for i, bel in enumerate(
71-
reversed(bels)
72-
): # we walk backwards trough the bel list
73-
belstr = ""
74-
# we only add bels with external ports to the top wrapper.
75-
if not bel.externalInput and not bel.externalOutput:
76-
logger.info(
77-
f"Skipping bel {bel.name} in tile X0Y{y} since it has no external ports"
78-
)
65+
for x in range(fabric.numberOfColumns):
66+
# we walk backwards through the Y list, since there is something mixed up with the coordinate system
67+
for y in range(fabric.numberOfRows - 1, -1, -1):
68+
bels = fabric.getBelsByTileXY(x, y)
69+
if not bels:
7970
continue
80-
if len(bel.inputs and bel.outputs) == 0:
81-
logger.info(
82-
f"{bel.name} in tile X0Y{y} has no internal ports, only external ports, we just add a dummy to the user design top wrapper!"
83-
)
84-
belstr += "//"
85-
86-
if bel.name not in bel_count:
87-
bel_count[bel.name] = 0
88-
bel_inputs[bel.name] = [
89-
port.removeprefix(bel.prefix) for port in bel.inputs
90-
]
91-
bel_outputs[bel.name] = [
92-
port.removeprefix(bel.prefix) for port in bel.outputs
93-
]
94-
else:
95-
# count number of times a BEL type is used
96-
bel_count[bel.name] += 1
97-
98-
# This is done similar in the npnr model gen, to get the bel prefix
99-
# So we assume to get the same Bel prefix here.
100-
# convert number of bel i to character A,B,C ...
101-
# But we need to do this backwards, starting with the highest letter for a tile
102-
prefix = chr(ord("A") + len(bels) - 1 - i)
103-
belstr += (
104-
f'(* keep, BEL="X0Y{y}.{prefix}" *) {bel.name} bel_X0Y{y}_{prefix} ('
105-
)
106-
107-
first = True
108-
for port in bel.inputs + bel.outputs:
109-
port_name = port.removeprefix(bel.prefix)
110-
if first:
111-
first = False
71+
for i, bel in enumerate(
72+
reversed(bels)
73+
): # we walk backwards trough the bel list
74+
belstr = ""
75+
# we only add bels with external ports to the top wrapper.
76+
if not bel.externalInput and not bel.externalOutput:
77+
logger.info(
78+
f"Skipping bel {bel.name} in tile X{x}Y{y} since it has no external ports"
79+
)
80+
continue
81+
if len(bel.inputs and bel.outputs) == 0:
82+
logger.info(
83+
f"{bel.name} in tile X{x}Y{y} has no internal ports, only external ports, we just add a dummy to the user design top wrapper!"
84+
)
85+
belstr += "//"
86+
87+
if bel.name not in bel_count:
88+
bel_count[bel.name] = 0
89+
bel_inputs[bel.name] = [
90+
port.removeprefix(bel.prefix) for port in bel.inputs
91+
]
92+
bel_outputs[bel.name] = [
93+
port.removeprefix(bel.prefix) for port in bel.outputs
94+
]
11295
else:
113-
belstr += ", "
114-
belstr += f".{port_name}({bel.name}_{port_name}[{bel_count[bel.name]}])"
96+
# count number of times a BEL type is used
97+
bel_count[bel.name] += 1
98+
99+
# This is done similar in the npnr model gen, to get the bel prefix
100+
# So we assume to get the same Bel prefix here.
101+
# convert number of bel i to character A,B,C ...
102+
# But we need to do this backwards, starting with the highest letter for a tile
103+
prefix = chr(ord("A") + len(bels) - 1 - i)
104+
belstr += (
105+
f'(* keep, BEL="X{x}Y{y}.{prefix}" *) {bel.name} bel_X{x}Y{y}_{prefix} ('
106+
)
115107

116-
belstr += ");"
117-
top_wrapper.append(belstr)
108+
first = True
109+
for port in bel.inputs + bel.outputs:
110+
port_name = port.removeprefix(bel.prefix)
111+
if first:
112+
first = False
113+
else:
114+
belstr += ", "
115+
belstr += f".{port_name}({bel.name}_{port_name}[{bel_count[bel.name]}])"
116+
117+
belstr += ");"
118+
top_wrapper.append(belstr)
118119

119120
top_wrapper.append("\n")
120121

0 commit comments

Comments
 (0)