Skip to content

fasm.cpp: return from visit if pb is open #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions utils/fasm/src/fasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static std::string handle_fasm_prefix(const t_metadata_dict *meta,
return fasm_prefix.at(pb_graph_node->placement_index) + ".";
}

std::string FasmWriterVisitor::build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node) const {
std::string FasmWriterVisitor::build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node, bool* is_parent_pb_null) const {
std::string clb_prefix = "";

const t_pb *pb_for_graph_node = nullptr;
Expand All @@ -146,22 +146,24 @@ std::string FasmWriterVisitor::build_clb_prefix(const t_pb *pb, const t_pb_graph
if(root_clb_ != pb_graph_node && pb_graph_node->parent_pb_graph_node != root_clb_) {
VTR_ASSERT(pb_graph_node->parent_pb_graph_node != nullptr);
if(pb != nullptr) {
while(pb_for_graph_node == nullptr) {
pb_for_graph_node = pb->find_pb(pb_graph_node);
if(pb_for_graph_node == nullptr) {
if(pb->parent_pb == nullptr) {
break;
}
pb = pb->parent_pb;
}
}
while(pb_for_graph_node == nullptr) {
pb_for_graph_node = pb->find_pb(pb_graph_node);

if(pb_for_graph_node != nullptr) {
mode_index = pb_for_graph_node->mode;
if(pb_for_graph_node == nullptr) {
if(pb->parent_pb == nullptr) {
*is_parent_pb_null = true;
break;
}
pb = pb->parent_pb;
}
}

if(pb_for_graph_node != nullptr) {
mode_index = pb_for_graph_node->mode;
}
}

clb_prefix = build_clb_prefix(pb, pb_graph_node->parent_pb_graph_node);
clb_prefix = build_clb_prefix(pb, pb_graph_node->parent_pb_graph_node, is_parent_pb_null);
}

const auto *pb_type = pb_graph_node->pb_type;
Expand All @@ -172,9 +174,9 @@ std::string FasmWriterVisitor::build_clb_prefix(const t_pb *pb, const t_pb_graph
VTR_ASSERT(mode_index < pb_type->num_modes);

clb_prefix += handle_fasm_prefix(&pb_type->modes[mode_index].meta,
pb_graph_node, pb_type);
pb_graph_node, pb_type);
} else {
VTR_ASSERT(mode_index == 0);
VTR_ASSERT(mode_index == 0);
}

return clb_prefix;
Expand Down Expand Up @@ -220,7 +222,13 @@ void FasmWriterVisitor::visit_all_impl(const t_pb_routes &pb_routes, const t_pb*

const t_pb_graph_node *pb_graph_node = pb->pb_graph_node;

clb_prefix_ = build_clb_prefix(pb, pb_graph_node);
// Check if this PB is `open` and has to be skipped
bool is_parent_pb_null = false;
std::string clb_prefix = build_clb_prefix(pb, pb_graph_node, &is_parent_pb_null);
if (is_parent_pb_null == true) {
return;
}
clb_prefix_ = clb_prefix;

t_pb_type *pb_type = pb_graph_node->pb_type;
auto *mode = &pb_type->modes[pb->mode];
Expand All @@ -233,7 +241,7 @@ void FasmWriterVisitor::visit_all_impl(const t_pb_routes &pb_routes, const t_pb*
if(mode != nullptr && std::string(mode->name) == "wire") {
auto io_pin = is_node_used(pb_routes, pb_graph_node);
if(io_pin != nullptr) {
const auto& route = pb_routes.at(io_pin->pin_count_in_cluster);
const auto& route = pb_routes.at(io_pin->pin_count_in_cluster);
const int num_inputs = *route.pb_graph_pin->parent_node->num_input_pins;
const auto *lut_definition = find_lut(route.pb_graph_pin->parent_node);
VTR_ASSERT(lut_definition->num_inputs == num_inputs);
Expand Down
2 changes: 1 addition & 1 deletion utils/fasm/src/fasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class FasmWriterVisitor : public NetlistVisitor {
void output_fasm_mux(std::string fasm_mux, t_interconnect *interconnect, t_pb_graph_pin *mux_input_pin);
void walk_routing();
void walk_route_tree(const t_rt_node *root);
std::string build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node) const;
std::string build_clb_prefix(const t_pb *pb, const t_pb_graph_node* pb_graph_node, bool* is_parent_pb_null) const;
const LutOutputDefinition* find_lut(const t_pb_graph_node* pb_graph_node);
void check_for_param(const t_pb *atom);

Expand Down