Skip to content

Commit

Permalink
Merge pull request #4753 from akashlevy/write_verilog_port_dump_fix
Browse files Browse the repository at this point in the history
`write_verilog`: Fix `O(N^2)` port dumping to `O(N)`
  • Loading branch information
povik authored Nov 17, 2024
2 parents 81011ad + ace558e commit 020dd0a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions backends/verilog/verilog_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2332,19 +2332,15 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)

dump_attributes(f, indent, module->attributes, "\n", /*modattr=*/true);
f << stringf("%s" "module %s(", indent.c_str(), id(module->name, false).c_str());
bool keep_running = true;
int cnt = 0;
for (int port_id = 1; keep_running; port_id++) {
keep_running = false;
for (auto wire : module->wires()) {
if (wire->port_id == port_id) {
if (port_id != 1)
f << stringf(", ");
f << stringf("%s", id(wire->name).c_str());
keep_running = true;
if (cnt==20) { f << stringf("\n"); cnt = 0; } else cnt++;
continue;
}
for (auto port : module->ports) {
Wire *wire = module->wire(port);
if (wire) {
if (port != module->ports[0])
f << stringf(", ");
f << stringf("%s", id(wire->name).c_str());
if (cnt==20) { f << stringf("\n"); cnt = 0; } else cnt++;
continue;
}
}
f << stringf(");\n");
Expand Down

0 comments on commit 020dd0a

Please sign in to comment.