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

Merge pull request #1961 from whitequark/paramod-original-name

ast, rpc: record original name of $paramod\* as \hdlname attribute
This commit is contained in:
whitequark 2020-04-21 01:43:20 +00:00 committed by GitHub
commit abc8f1fcb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 11 deletions

View file

@ -306,17 +306,8 @@ struct FirrtlWorker
// If this is a parameterized module, its parent module is encoded in the cell type // If this is a parameterized module, its parent module is encoded in the cell type
if (cell->type.begins_with("$paramod")) if (cell->type.begins_with("$paramod"))
{ {
std::string::iterator it; log_assert(cell->has_attribute(ID::hdlname));
for (it = cell_type.begin(); it < cell_type.end(); it++) instanceOf = cell->get_string_attribute(ID::hdlname);
{
switch (*it) {
case '\\': /* FALL_THROUGH */
case '=': /* FALL_THROUGH */
case '\'': /* FALL_THROUGH */
case '$': instanceOf.append("_"); break;
default: instanceOf.append(1, *it); break;
}
}
} }
else else
{ {

View file

@ -1565,6 +1565,9 @@ std::string AstModule::derive_common(RTLIL::Design *design, const dict<RTLIL::Id
rewritten.reserve(GetSize(parameters)); rewritten.reserve(GetSize(parameters));
AstNode *new_ast = ast->clone(); AstNode *new_ast = ast->clone();
if (!new_ast->attributes.count(ID::hdlname))
new_ast->attributes[ID::hdlname] = AstNode::mkconst_str(stripped_name);
para_counter = 0; para_counter = 0;
for (auto child : new_ast->children) { for (auto child : new_ast->children) {
if (child->type != AST_PARAMETER) if (child->type != AST_PARAMETER)

View file

@ -217,6 +217,8 @@ struct RpcModule : RTLIL::Module {
module.second->name = mangled_name; module.second->name = mangled_name;
module.second->design = design; module.second->design = design;
module.second->attributes.erase(ID::top); module.second->attributes.erase(ID::top);
if (!module.second->has_attribute(ID::hdlname))
module.second->set_string_attribute(ID::hdlname, module.first.str());
design->modules_[mangled_name] = module.second; design->modules_[mangled_name] = module.second;
derived_design->modules_.erase(module.first); derived_design->modules_.erase(module.first);
} }