mirror of
https://github.com/YosysHQ/yosys
synced 2025-10-09 01:11:58 +00:00
box_derive: add -apply
This commit is contained in:
parent
ba4f9f5f67
commit
7c61c30288
1 changed files with 24 additions and 13 deletions
|
@ -51,6 +51,9 @@ struct BoxDerivePass : Pass {
|
|||
log(" replaces the internal Yosys naming scheme in which the names of derived\n");
|
||||
log(" modules start with '$paramod$')\n");
|
||||
log("\n");
|
||||
log(" -apply\n");
|
||||
log(" use the derived modules\n");
|
||||
log("\n");
|
||||
}
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *d) override
|
||||
{
|
||||
|
@ -59,11 +62,14 @@ struct BoxDerivePass : Pass {
|
|||
size_t argidx;
|
||||
IdString naming_attr;
|
||||
IdString base_name;
|
||||
bool apply_mode;
|
||||
for (argidx = 1; argidx < args.size(); argidx++) {
|
||||
if (args[argidx] == "-naming_attr" && argidx + 1 < args.size())
|
||||
naming_attr = RTLIL::escape_id(args[++argidx]);
|
||||
else if (args[argidx] == "-base" && argidx + 1 < args.size())
|
||||
base_name = RTLIL::escape_id(args[++argidx]);
|
||||
else if (args[argidx] == "-apply")
|
||||
apply_mode = true;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
@ -90,13 +96,14 @@ struct BoxDerivePass : Pass {
|
|||
|
||||
auto index = std::make_pair(base->name, cell->parameters);
|
||||
|
||||
if (cell->parameters.empty() || done.count(index))
|
||||
if (cell->parameters.empty())
|
||||
continue;
|
||||
|
||||
if (!done.count(index)) {
|
||||
IdString derived_type = base->derive(d, cell->parameters);
|
||||
Module *derived = d->module(derived_type);
|
||||
log_assert(derived && "Failed to derive module\n");
|
||||
log_debug("derived %s\n", derived_type);
|
||||
log("derived %s\n", derived_type);
|
||||
|
||||
if (!naming_attr.empty() && derived->has_attribute(naming_attr)) {
|
||||
IdString new_name = RTLIL::escape_id(derived->get_string_attribute(naming_attr));
|
||||
|
@ -109,6 +116,10 @@ struct BoxDerivePass : Pass {
|
|||
|
||||
done[index] = derived;
|
||||
}
|
||||
|
||||
if (apply_mode)
|
||||
cell->type = done[index]->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
} BoxDerivePass;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue