@@ -62,59 +62,60 @@ def generateUserDesignTopWrapper(
62
62
bel_outputs : dict [str , list [str ]] = {}
63
63
64
64
# 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 :
79
70
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
+ ]
112
95
else :
113
- belstr += ", "
114
- belstr += f".{ port_name } ({ bel .name } _{ port_name } [{ bel_count [bel .name ]} ])"
115
-
116
- belstr += ");"
117
- top_wrapper .append (belstr )
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 += f'(* keep, BEL="X{ x } Y{ y } .{ prefix } " *) { bel .name } bel_X{ x } Y{ y } _{ prefix } ('
105
+
106
+ first = True
107
+ for port in bel .inputs + bel .outputs :
108
+ port_name = port .removeprefix (bel .prefix )
109
+ if first :
110
+ first = False
111
+ else :
112
+ belstr += ", "
113
+ belstr += (
114
+ f".{ port_name } ({ bel .name } _{ port_name } [{ bel_count [bel .name ]} ])"
115
+ )
116
+
117
+ belstr += ");"
118
+ top_wrapper .append (belstr )
118
119
119
120
top_wrapper .append ("\n " )
120
121
0 commit comments