3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-14 14:55:26 +00:00

fixup! box_derive: add -apply

This commit is contained in:
Emil J. Tywoniak 2025-06-25 14:14:31 +02:00
parent 424f9f91aa
commit b85bd37360
2 changed files with 18 additions and 17 deletions

View file

@ -86,7 +86,6 @@ struct BoxDerivePass : Pass {
for (auto module : d->selected_modules()) { for (auto module : d->selected_modules()) {
for (auto cell : module->selected_cells()) { for (auto cell : module->selected_cells()) {
log_cell(cell);
Module *inst_module = d->module(cell->type); Module *inst_module = d->module(cell->type);
if (!inst_module || !inst_module->get_blackbox_attribute()) if (!inst_module || !inst_module->get_blackbox_attribute())
continue; continue;
@ -97,13 +96,14 @@ struct BoxDerivePass : Pass {
auto index = std::make_pair(base->name, cell->parameters); auto index = std::make_pair(base->name, cell->parameters);
if (cell->parameters.empty() || done.count(index)) if (cell->parameters.empty())
continue; continue;
if (!done.count(index)) {
IdString derived_type = base->derive(d, cell->parameters); IdString derived_type = base->derive(d, cell->parameters);
Module *derived = d->module(derived_type); Module *derived = d->module(derived_type);
log_assert(derived && "Failed to derive module\n"); log_assert(derived && "Failed to derive module\n");
log_debug("derived %s\n", derived_type.c_str()); log("derived %s\n", derived_type.c_str());
if (!naming_attr.empty() && derived->has_attribute(naming_attr)) { if (!naming_attr.empty() && derived->has_attribute(naming_attr)) {
IdString new_name = RTLIL::escape_id(derived->get_string_attribute(naming_attr)); IdString new_name = RTLIL::escape_id(derived->get_string_attribute(naming_attr));
@ -115,9 +115,10 @@ struct BoxDerivePass : Pass {
} }
done[index] = derived; done[index] = derived;
}
if (apply_mode) if (apply_mode)
cell->type = derived_type; cell->type = done[index]->name;
log_cell(cell);
} }
} }
} }

View file

@ -22,7 +22,7 @@ public:
log("\n"); log("\n");
log(" publish\n"); log(" publish\n");
log("Makes all module names and cell types public by prefixing\n"); log("Makes all module names and cell types public by prefixing\n");
log("% with \\.\n"); log("%% with \\.\n");
} }
void execute(std::vector<std::string> args, RTLIL::Design *design) override void execute(std::vector<std::string> args, RTLIL::Design *design) override
{ {