@@ -103,41 +103,75 @@ void FasmWriterVisitor::check_interconnect(const t_pb_routes &pb_route, int inod
103
103
}
104
104
}
105
105
106
- std::string FasmWriterVisitor::build_clb_prefix (const t_pb_graph_node* pb_graph_node) const {
107
- std::string clb_prefix = " " ;
108
-
109
- if (root_clb_ != pb_graph_node && pb_graph_node->parent_pb_graph_node != root_clb_) {
110
- VTR_ASSERT (pb_graph_node->parent_pb_graph_node != nullptr );
111
- clb_prefix = build_clb_prefix (pb_graph_node->parent_pb_graph_node );
112
- }
113
-
114
- const auto *pb_type = pb_graph_node->pb_type ;
115
- bool has_prefix = pb_type->meta != nullptr
116
- && pb_type->meta ->has (" fasm_prefix" );
117
-
106
+ static std::string handle_fasm_prefix (const t_metadata_dict *meta,
107
+ const t_pb_graph_node *pb_graph_node, const t_pb_type *pb_type) {
108
+ bool has_prefix = meta != nullptr && meta->has (" fasm_prefix" );
118
109
if (!has_prefix) {
119
- return clb_prefix ;
110
+ return " " ;
120
111
}
121
112
122
- auto fasm_prefix_unsplit = pb_type-> meta ->get (" fasm_prefix" )->front ().as_string ();
113
+ auto fasm_prefix_unsplit = meta->get (" fasm_prefix" )->front ().as_string ();
123
114
auto fasm_prefix = vtr::split (fasm_prefix_unsplit, " " );
124
115
VTR_ASSERT (pb_type->num_pb >= 0 );
125
116
if (fasm_prefix.size () != static_cast <size_t >(pb_type->num_pb )) {
126
117
vpr_throw (VPR_ERROR_OTHER,
127
- __FILE__, __LINE__,
128
- " number of fasm_prefix (%s) options (%d) for block (%s) must match capacity(%d)" ,
129
- fasm_prefix_unsplit, fasm_prefix.size (), pb_type->name , pb_type->num_pb );
118
+ __FILE__, __LINE__,
119
+ " number of fasm_prefix (%s) options (%d) for block (%s) must match capacity(%d)" ,
120
+ fasm_prefix_unsplit, fasm_prefix.size (), pb_type->name , pb_type->num_pb );
130
121
}
131
122
132
123
if (pb_graph_node->placement_index >= pb_type->num_pb ) {
133
- vpr_throw (VPR_ERROR_OTHER,
124
+ vpr_throw (VPR_ERROR_OTHER,
134
125
__FILE__, __LINE__,
135
126
" pb_graph_node->placement_index = %d >= pb_type->num_pb = %d" ,
136
127
fasm_prefix_unsplit.c_str (), pb_type->num_pb );
137
128
}
138
129
139
- return clb_prefix + fasm_prefix.at (pb_graph_node->placement_index ) + " ." ;
130
+ return fasm_prefix.at (pb_graph_node->placement_index ) + " ." ;
131
+ }
132
+
133
+ std::string FasmWriterVisitor::build_clb_prefix (const t_pb *pb, const t_pb_graph_node* pb_graph_node) const {
134
+ std::string clb_prefix = " " ;
135
+
136
+ const t_pb *pb_for_graph_node = nullptr ;
137
+
138
+ // If not t_pb, mode_index is always 0.
139
+ int mode_index = 0 ;
140
+ if (root_clb_ != pb_graph_node && pb_graph_node->parent_pb_graph_node != root_clb_) {
141
+ VTR_ASSERT (pb_graph_node->parent_pb_graph_node != nullptr );
142
+ if (pb != nullptr ) {
143
+ while (pb_for_graph_node == nullptr ) {
144
+ pb_for_graph_node = pb->find_pb (pb_graph_node);
145
+ if (pb_for_graph_node == nullptr ) {
146
+ if (pb->parent_pb == nullptr ) {
147
+ break ;
148
+ }
149
+ pb = pb->parent_pb ;
150
+ }
151
+ }
152
+
153
+ if (pb_for_graph_node != nullptr ) {
154
+ mode_index = pb_for_graph_node->mode ;
155
+ }
156
+ }
157
+
158
+ clb_prefix = build_clb_prefix (pb, pb_graph_node->parent_pb_graph_node );
159
+ }
160
+
161
+ const auto *pb_type = pb_graph_node->pb_type ;
162
+
163
+ clb_prefix += handle_fasm_prefix (pb_type->meta , pb_graph_node, pb_type);
164
+
165
+ if (pb_type->modes != nullptr ) {
166
+ VTR_ASSERT (mode_index < pb_type->num_modes );
167
+
168
+ clb_prefix += handle_fasm_prefix (pb_type->modes [mode_index].meta ,
169
+ pb_graph_node, pb_type);
170
+ } else {
171
+ VTR_ASSERT (mode_index == 0 );
172
+ }
140
173
174
+ return clb_prefix;
141
175
}
142
176
143
177
static const t_pb_graph_pin* is_node_used (const t_pb_routes &top_pb_route, const t_pb_graph_node* pb_graph_node) {
@@ -176,7 +210,8 @@ void FasmWriterVisitor::check_features(t_metadata_dict *meta) const {
176
210
177
211
void FasmWriterVisitor::visit_all_impl (const t_pb_routes &pb_route, const t_pb* pb,
178
212
const t_pb_graph_node* pb_graph_node) {
179
- clb_prefix_ = build_clb_prefix (pb_graph_node);
213
+ clb_prefix_ = build_clb_prefix (pb, pb_graph_node);
214
+ std::cerr << " CLB prefix: " << clb_prefix_ << std::endl;
180
215
181
216
if (pb_graph_node && pb) {
182
217
t_pb_type *pb_type = pb_graph_node->pb_type ;
0 commit comments