Skip to content

Commit

Permalink
Adding autoname patch.
Browse files Browse the repository at this point in the history
Signed-off-by: Tim 'mithro' Ansell <[email protected]>
  • Loading branch information
mithro committed Jan 6, 2024
1 parent e003a69 commit 8e83e68
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions dependency_support/at_clifford_yosys/at_clifford_yosys.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ def at_clifford_yosys():
build_file = Label("@rules_hdl//dependency_support:at_clifford_yosys/bundled.BUILD.bazel"),
patches = [
Label("@rules_hdl//dependency_support:at_clifford_yosys/yosys.patch"),
Label("@rules_hdl//dependency_support:at_clifford_yosys/autoname.patch"),
],
)
36 changes: 36 additions & 0 deletions dependency_support/at_clifford_yosys/autoname.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/passes/cmds/autoname.cc b/passes/cmds/autoname.cc
index 737bd3e58..474303263 100644
--- passes/cmds/autoname.cc
+++ passes/cmds/autoname.cc
@@ -34,8 +34,13 @@ int autoname_worker(Module *module, const dict<Wire*, int>& wire_score)
string suffix;
for (auto bit : conn.second)
if (bit.wire != nullptr && bit.wire->name[0] != '$') {
- if (suffix.empty())
- suffix = stringf("_%s_%s", log_id(cell->type), log_id(conn.first));
+ if (suffix.empty()) {
+ if (bit.wire->width > 1) {
+ suffix = stringf("%i_%s_%s", bit.offset, log_id(cell->type), log_id(conn.first));
+ } else {
+ suffix = stringf("_%s_%s", log_id(cell->type), log_id(conn.first));
+ }
+ }
string new_name(bit.wire->name.str() + suffix);
int score = wire_score.at(bit.wire);
if (cell->output(conn.first)) score = 0;
@@ -52,8 +57,13 @@ int autoname_worker(Module *module, const dict<Wire*, int>& wire_score)
string suffix;
for (auto bit : conn.second)
if (bit.wire != nullptr && bit.wire->name[0] == '$' && !bit.wire->port_id) {
- if (suffix.empty())
- suffix = stringf("_%s", log_id(conn.first));
+ if (suffix.empty()) {
+ if (bit.wire->width > 1) {
+ suffix = stringf("%i_%s", bit.offset, log_id(conn.first));
+ } else {
+ suffix = stringf("_%s", log_id(conn.first));
+ }
+ }
string new_name(cell->name.str() + suffix);
int score = wire_score.at(bit.wire);
if (cell->output(conn.first)) score = 0;

0 comments on commit 8e83e68

Please sign in to comment.