@@ -234,6 +234,12 @@ static bool is_pin_used(const t_pb_graph_pin* pin, const t_pb_routes &top_pb_rou
234
234
*
235
235
* Wires in VPR are a special primitive which is a LUT which acts like a wire
236
236
* pass-through. Only one input of this LUT should be used.
237
+ *
238
+ * @param top_pb_route
239
+ * The top pb route for the cluster that contains the wire.
240
+ * @param pb_graph_node
241
+ * The pb_graph_node of the wire primitive that we are getting the input
242
+ * pin for.
237
243
*/
238
244
static const t_pb_graph_pin* get_wire_input_pin (const t_pb_routes &top_pb_route, const t_pb_graph_node* pb_graph_node) {
239
245
const t_pb_graph_pin* wire_input_pin = nullptr ;
@@ -254,6 +260,11 @@ static const t_pb_graph_pin* get_wire_input_pin(const t_pb_routes &top_pb_route,
254
260
* @brief Returns true if the given wire is used.
255
261
*
256
262
* A wire is used if it has a used output pin.
263
+ *
264
+ * @param top_pb_route
265
+ * The top pb route for the cluster that contains the wire.
266
+ * @param pb_graph_node
267
+ * The pb_graph_node of the wire primitive that we are checking is used.
257
268
*/
258
269
static bool is_wire_used (const t_pb_routes &top_pb_route, const t_pb_graph_node* pb_graph_node) {
259
270
// A wire is used if it has a used output pin.
@@ -314,17 +325,29 @@ void FasmWriterVisitor::visit_all_impl(const t_pb_routes &pb_routes, const t_pb*
314
325
}
315
326
316
327
if (mode != nullptr && std::string (mode->name ) == " wire" ) {
328
+ // Check if the wire is used. If the wire is unused (i.e. it does not connect
329
+ // to anything), it does not need to be created.
317
330
if (is_wire_used (pb_routes, pb_graph_node)) {
331
+ // Get the input pin of the LUT that feeds the wire. There should be one
332
+ // and only one.
318
333
const t_pb_graph_pin* wire_input_pin = get_wire_input_pin (pb_routes, pb_graph_node);
319
334
VTR_ASSERT_MSG (wire_input_pin != nullptr ,
320
335
" Wire found with no used input pins" );
336
+
337
+ // Get the route going into this pin.
321
338
const auto & route = pb_routes.at (wire_input_pin->pin_count_in_cluster );
339
+
340
+ // Find the lut definition for the parent of this wire.
322
341
const int num_inputs = *route.pb_graph_pin ->parent_node ->num_input_pins ;
323
342
const auto *lut_definition = find_lut (route.pb_graph_pin ->parent_node );
324
343
VTR_ASSERT (lut_definition->num_inputs == num_inputs);
325
344
345
+ // Create a wire implementation for the LUT.
326
346
output_fasm_features (lut_definition->CreateWire (route.pb_graph_pin ->pin_number ));
327
347
} else {
348
+ // If the wire is not used, ensure that the inputs to the wire are also
349
+ // unused. This is just a sanity check to ensure that all wires are
350
+ // either completely unused or have one input and one output.
328
351
VTR_ASSERT_MSG (get_wire_input_pin (pb_routes, pb_graph_node) == nullptr ,
329
352
" Wire found with a used input pin, but no used output pin" );
330
353
}
0 commit comments