Skip to content

Commit 472db87

Browse files
[FASM] Updated Documentation Based on PR Review
1 parent 46cfea0 commit 472db87

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

utils/fasm/src/fasm.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ static bool is_pin_used(const t_pb_graph_pin* pin, const t_pb_routes &top_pb_rou
234234
*
235235
* Wires in VPR are a special primitive which is a LUT which acts like a wire
236236
* 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.
237243
*/
238244
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) {
239245
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,
254260
* @brief Returns true if the given wire is used.
255261
*
256262
* 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.
257268
*/
258269
static bool is_wire_used(const t_pb_routes &top_pb_route, const t_pb_graph_node* pb_graph_node) {
259270
// 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*
314325
}
315326

316327
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.
317330
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.
318333
const t_pb_graph_pin* wire_input_pin = get_wire_input_pin(pb_routes, pb_graph_node);
319334
VTR_ASSERT_MSG(wire_input_pin != nullptr,
320335
"Wire found with no used input pins");
336+
337+
// Get the route going into this pin.
321338
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.
322341
const int num_inputs = *route.pb_graph_pin->parent_node->num_input_pins;
323342
const auto *lut_definition = find_lut(route.pb_graph_pin->parent_node);
324343
VTR_ASSERT(lut_definition->num_inputs == num_inputs);
325344

345+
// Create a wire implementation for the LUT.
326346
output_fasm_features(lut_definition->CreateWire(route.pb_graph_pin->pin_number));
327347
} 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.
328351
VTR_ASSERT_MSG(get_wire_input_pin(pb_routes, pb_graph_node) == nullptr,
329352
"Wire found with a used input pin, but no used output pin");
330353
}

0 commit comments

Comments
 (0)