3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-20 07:36:39 +00:00
This commit is contained in:
N. Engelhardt 2025-04-17 16:23:05 +00:00 committed by GitHub
commit 4313d332ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -349,6 +349,10 @@ struct FlattenPass : public Pass {
log(" -separator <char>\n");
log(" Use this separator char instead of '.' when concatenating design levels.\n");
log("\n");
log(" -nocleanup\n");
log(" Don't remove unused submodules, leave a flattened version of each\n");
log(" submodule in the design.\n");
log("\n");
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
@ -360,6 +364,8 @@ struct FlattenPass : public Pass {
if (design->scratchpad.count("flatten.separator"))
worker.separator = design->scratchpad_get_string("flatten.separator");
bool cleanup = true;
size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++) {
if (args[argidx] == "-wb") {
@ -378,6 +384,10 @@ struct FlattenPass : public Pass {
worker.separator = args[++argidx];
continue;
}
if (args[argidx] == "-nocleanup") {
cleanup = false;
continue;
}
break;
}
extra_args(args, argidx, design);
@ -414,7 +424,7 @@ struct FlattenPass : public Pass {
for (auto module : topo_modules.sorted)
worker.flatten_module(design, module, used_modules, worker.separator);
if (top != nullptr)
if (cleanup && top != nullptr)
for (auto module : design->modules().to_vector())
if (!used_modules[module] && !module->get_blackbox_attribute(worker.ignore_wb)) {
log("Deleting now unused module %s.\n", log_id(module));