aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@gmail.com>2021-07-19 09:23:41 +0100
committerZachary Snow <zachary.j.snow@gmail.com>2021-07-20 10:13:15 -0400
commit7a25246a7ebf0b7495beae4a19569f619ca19c78 (patch)
tree085af19b8dbb6bb056b692b87863711a4bdb4098
parent8fd6b45a3c828d87e7e7fd2030026981d679d32b (diff)
downloadyosys-7a25246a7ebf0b7495beae4a19569f619ca19c78.tar.gz
yosys-7a25246a7ebf0b7495beae4a19569f619ca19c78.tar.bz2
yosys-7a25246a7ebf0b7495beae4a19569f619ca19c78.zip
Use new read_id_num helper function elsewhere in hierarchy.cc
-rw-r--r--passes/hierarchy/hierarchy.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc
index 5839a6c75..650036580 100644
--- a/passes/hierarchy/hierarchy.cc
+++ b/passes/hierarchy/hierarchy.cc
@@ -1106,8 +1106,8 @@ struct HierarchyPass : public Pass {
pool<std::pair<IdString, IdString>> params_rename;
for (const auto &p : cell->parameters) {
- if (p.first[0] == '$' && '0' <= p.first[1] && p.first[1] <= '9') {
- int id = atoi(p.first.c_str()+1);
+ int id;
+ if (read_id_num(p.first, &id)) {
if (id <= 0 || id > GetSize(cell_mod->avail_parameters)) {
log(" Failed to map positional parameter %d of cell %s.%s (%s).\n",
id, RTLIL::id2cstr(mod->name), RTLIL::id2cstr(cell->name), RTLIL::id2cstr(cell->type));
@@ -1134,9 +1134,9 @@ struct HierarchyPass : public Pass {
log("Mapping positional arguments of cell %s.%s (%s).\n",
RTLIL::id2cstr(module->name), RTLIL::id2cstr(cell->name), RTLIL::id2cstr(cell->type));
dict<RTLIL::IdString, RTLIL::SigSpec> new_connections;
- for (auto &conn : cell->connections())
- if (conn.first[0] == '$' && '0' <= conn.first[1] && conn.first[1] <= '9') {
- int id = atoi(conn.first.c_str()+1);
+ for (auto &conn : cell->connections()) {
+ int id;
+ if (read_id_num(conn.first, &id)) {
std::pair<RTLIL::Module*,int> key(design->module(cell->type), id);
if (pos_map.count(key) == 0) {
log(" Failed to map positional argument %d of cell %s.%s (%s).\n",
@@ -1146,6 +1146,7 @@ struct HierarchyPass : public Pass {
new_connections[pos_map.at(key)] = conn.second;
} else
new_connections[conn.first] = conn.second;
+ }
cell->connections_ = new_connections;
}
}