Fixed fasm output for top-level blocks without prefixes.
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
diff --git a/utils/fasm/src/fasm.cpp b/utils/fasm/src/fasm.cpp
index d5a3552..0b9844c 100644
--- a/utils/fasm/src/fasm.cpp
+++ b/utils/fasm/src/fasm.cpp
@@ -56,7 +56,8 @@
auto &grid_loc = device_ctx.grid[x][y];
blk_type_ = grid_loc.type;
- current_blk_has_prefix_ = true;
+ blk_prefix_ = "";
+ clb_prefix_ = "";
clb_prefix_map_.clear();
// Get placeholder list (if provided)
@@ -93,13 +94,11 @@
prefix_unsplit.c_str(), fasm_prefixes.size(), blk_type_->name, blk_type_->capacity);
}
grid_prefix = fasm_prefixes[z];
- } else {
- current_blk_has_prefix_= false;
- }
-
- if(current_blk_has_prefix_) {
blk_prefix_ = grid_prefix + ".";
}
+ else {
+ blk_prefix_ = "";
+ }
}
void FasmWriterVisitor::check_interconnect(const t_pb_routes &pb_routes, int inode) {
@@ -614,8 +613,7 @@
for (t_linked_rt_edge* edge = root->u.child_list; edge != nullptr; edge = edge->next) {
auto *meta = vpr::rr_edge_metadata(root->inode, edge->child->inode, edge->iswitch, "fasm_features");
if(meta != nullptr) {
- current_blk_has_prefix_ = false;
- output_fasm_features(meta->as_string());
+ output_fasm_features(meta->as_string(), "", "");
}
walk_route_tree(edge->child);
@@ -646,6 +644,13 @@
void FasmWriterVisitor::find_clb_prefix(const t_pb_graph_node *node,
bool *have_prefix, std::string *clb_prefix) const {
+<<<<<<< HEAD
+=======
+
+ *have_prefix = false;
+ *clb_prefix = "";
+
+>>>>>>> Fixed fasm output for top-level blocks without prefixes.
while(node != nullptr) {
auto clb_prefix_itr = clb_prefix_map_.find(node);
*have_prefix = clb_prefix_itr != clb_prefix_map_.end();
@@ -710,7 +715,11 @@
// pb_type_prefixes_, not on the mux input.
if(mux_pb_name == pb_name && mux_port_name == port_name && mux_pin_index == pin_index) {
if(mux_parts[1] != "NULL") {
+<<<<<<< HEAD
output_fasm_features(have_prefix, clb_prefix, fasm_features);
+=======
+ output_fasm_features(fasm_features, clb_prefix, blk_prefix_);
+>>>>>>> Fixed fasm output for top-level blocks without prefixes.
}
return;
}
@@ -719,7 +728,7 @@
mux_port_name == port_name &&
mux_pin_index == pin_index) {
if(mux_parts[1] != "NULL") {
- output_fasm_features(have_prefix, clb_prefix, fasm_features);
+ output_fasm_features(fasm_features, clb_prefix, blk_prefix_);
}
return;
}
@@ -730,11 +739,11 @@
pb_name, pb_index, port_name, pin_index, fasm_mux.c_str());
}
-void FasmWriterVisitor::output_fasm_features(std::string features) const {
- output_fasm_features(current_blk_has_prefix_, clb_prefix_, features);
+void FasmWriterVisitor::output_fasm_features(const std::string features) const {
+ output_fasm_features(features, clb_prefix_, blk_prefix_);
}
-void FasmWriterVisitor::output_fasm_features(bool have_clb_prefix, std::string clb_prefix, std::string features) const {
+void FasmWriterVisitor::output_fasm_features(const std::string features, const std::string clb_prefix, const std::string blk_prefix) const {
std::stringstream os(features);
while(os) {
@@ -742,10 +751,8 @@
os >> feature;
if(os) {
std::string out_feature;
- if(have_clb_prefix) {
- out_feature += blk_prefix_;
- out_feature += clb_prefix;
- }
+ out_feature += blk_prefix;
+ out_feature += clb_prefix;
out_feature += feature;
// Substitute tags
os_ << substitute_tags(out_feature, tags_) << std::endl;
diff --git a/utils/fasm/src/fasm.h b/utils/fasm/src/fasm.h
index 1326c4c..3e92a5f 100644
--- a/utils/fasm/src/fasm.h
+++ b/utils/fasm/src/fasm.h
@@ -66,8 +66,8 @@
void finish_impl() override;
private:
- void output_fasm_features(std::string features) const;
- void output_fasm_features(bool have_clb_prefix, std::string clb_prefix, std::string features) const;
+ void output_fasm_features(const std::string features) const;
+ void output_fasm_features(const std::string features, const std::string clb_prefix, const std::string blk_prefix) const;
void check_features(const t_metadata_dict *meta) const;
void check_interconnect(const t_pb_routes &pb_route, int inode);
void check_for_lut(const t_pb* atom);
@@ -85,7 +85,6 @@
std::ostream& os_;
t_pb_graph_node *root_clb_;
- bool current_blk_has_prefix_;
t_physical_tile_type_ptr blk_type_;
std::string blk_prefix_;
std::string clb_prefix_;
diff --git a/utils/fasm/test/test_fasm.cpp b/utils/fasm/test/test_fasm.cpp
index 6ec278d..36fbe09 100644
--- a/utils/fasm/test/test_fasm.cpp
+++ b/utils/fasm/test/test_fasm.cpp
@@ -120,7 +120,7 @@
found_mux3 = true;
}
- if(line.find("CLB") != std::string::npos) {
+ if(line.find("CLB") != std::string::npos || line.find("FLE") != std::string::npos) {
auto pos = line.find("LUT[");
if(pos != std::string::npos) {
CHECK_THAT(line.substr(pos), Equals(
diff --git a/utils/fasm/test/test_fasm_arch.xml b/utils/fasm/test/test_fasm_arch.xml
index 6f6cf2a..c45ec19 100644
--- a/utils/fasm/test/test_fasm_arch.xml
+++ b/utils/fasm/test/test_fasm_arch.xml
@@ -96,7 +96,7 @@
<single type="clb" priority="10" x="3" y="4">
<metadata> <meta name="fasm_placeholders">
LOC=X3Y4
- </meta> <meta name="fasm_prefix">CLB</meta> </metadata>
+ </meta> <meta name="fasm_prefix">CLB</meta> </metadata>
</single>
<single type="clb" priority="10" x="4" y="1">