3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-13 12:28:44 +00:00

Fix O(N^2) port dump down to O(N)

This commit is contained in:
Akash Levy 2024-11-16 22:56:41 -08:00
parent 81011ad926
commit 8f9a0b680a

View file

@ -2334,10 +2334,17 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
f << stringf("%s" "module %s(", indent.c_str(), id(module->name, false).c_str()); f << stringf("%s" "module %s(", indent.c_str(), id(module->name, false).c_str());
bool keep_running = true; bool keep_running = true;
int cnt = 0; int cnt = 0;
for (int port_id = 1; keep_running; port_id++) { int max_port_id = 0;
keep_running = false;
for (auto wire : module->wires()) { for (auto wire : module->wires()) {
if (wire->port_id == port_id) { max_port_id = std::max(wire->port_id, max_port_id);
}
std::vector<Wire *> wires(max_port_id + 1, nullptr);
for (auto wire : module->wires()) {
wires[wire->port_id] = wire;
}
for (int port_id = 1; port_id <= max_port_id; port_id++) {
Wire *wire = wires[port_id];
if (wire) {
if (port_id != 1) if (port_id != 1)
f << stringf(", "); f << stringf(", ");
f << stringf("%s", id(wire->name).c_str()); f << stringf("%s", id(wire->name).c_str());
@ -2346,7 +2353,6 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
continue; continue;
} }
} }
}
f << stringf(");\n"); f << stringf(");\n");
if (!systemverilog && !module->processes.empty()) { if (!systemverilog && !module->processes.empty()) {
initial_id = NEW_ID; initial_id = NEW_ID;