3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-17 08:42:16 +00:00

update verilog_backend according to Github comments

This commit is contained in:
Hongce Zhang 2025-08-08 16:17:37 +08:00
parent b635ab72bf
commit 76e507f307

View file

@ -2358,16 +2358,12 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
dump_attributes(f, indent, module->attributes, "\n", /*modattr=*/true); dump_attributes(f, indent, module->attributes, "\n", /*modattr=*/true);
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());
int cnt = 0; int cnt = 0;
std::vector<Wire *> port_ordered;
for (auto port : module->ports) { for (auto port : module->ports) {
Wire *wire = module->wire(port); Wire *wire = module->wire(port);
if (wire) { if (wire) {
if (port != module->ports[0]) if (port != module->ports[0])
f << stringf(", "); f << stringf(", ");
f << stringf("%s", id(wire->name).c_str()); f << stringf("%s", id(wire->name).c_str());
port_ordered.push_back(wire);
if (cnt==20) { f << stringf("\n"); cnt = 0; } else cnt++; if (cnt==20) { f << stringf("\n"); cnt = 0; } else cnt++;
continue; continue;
} }
@ -2378,13 +2374,13 @@ void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
f << indent + " " << "reg " << id(initial_id) << " = 0;\n"; f << indent + " " << "reg " << id(initial_id) << " = 0;\n";
} }
// first dump input / output according to port_ordered; // first dump input / output according to their order in module->ports
for (auto w : port_ordered) for (auto port : module->ports)
dump_wire(f, indent + " ", w); dump_wire(f, indent + " ", module->wire(port));
for (auto w : module->wires()) { for (auto w : module->wires()) {
// avoid duplication // avoid duplication
if (std::find(port_ordered.begin(), port_ordered.end(), w) != port_ordered.end()) if (w->port_id)
continue; continue;
dump_wire(f, indent + " ", w); dump_wire(f, indent + " ", w);
} }