Internals: Misc V3Param cleanups.

This commit is contained in:
Wilson Snyder 2024-09-20 08:59:10 -04:00
parent 02e88e3848
commit f0fb0b05ff
2 changed files with 14 additions and 8 deletions

View File

@ -21,6 +21,7 @@
// (Interfaces also matter, as if a module is parameterized
// this effectively changes the width behavior of all that
// reference the iface.)
//
// Clone module cell calls, renaming with __{par1}_{par2}_...
// Substitute constants for cell's module's parameters.
// Relink pins and cell and ifacerefdtype to point to new module.
@ -65,7 +66,7 @@
VL_DEFINE_DEBUG_FUNCTIONS;
//######################################################################
// Hierarchical block and parameter db (modules without parameter is also handled)
// Hierarchical block and parameter db (modules without parameters are also handled)
class ParameterizedHierBlocks final {
using HierBlockOptsByOrigName = std::multimap<std::string, const V3HierarchicalBlockOption*>;
@ -231,10 +232,10 @@ class ParamProcessor final {
// // (0=not processed, 1=iterated, but no number,
// // 65+ parameter numbered)
// NODE STATE - Shared with ParamVisitor
// AstClass::user3p() // AstClass* Unchanged copy of the parameterized class node.
// The class node may be modified according to parameter
// values and an unchanged copy is needed to instantiate
// classes with different parameters.
// AstNodeModule::user3p() // AstNodeModule* Unaltered copy of the parameterized module.
// The module/class node may be modified according to parameter
// values and an unchanged copy is needed to instantiate
// modules/classes with different parameters.
// AstNodeModule::user2() // bool True if processed
// AstGenFor::user2() // bool True if processed
// AstVar::user2() // bool True if constant propagated
@ -962,7 +963,9 @@ public:
if (debug() >= 10) nodep->dumpTree("- cell: ");
// Evaluate all module constants
V3Const::constifyParamsEdit(nodep);
srcModpr->someInstanceName(someInstanceName + "." + nodep->name());
// Set name for warnings for when we param propagate the module
const string instanceName = someInstanceName + "." + nodep->name();
srcModpr->someInstanceName(instanceName);
if (auto* cellp = VN_CAST(nodep, Cell)) {
cellDeparam(cellp, srcModpr);
@ -976,6 +979,9 @@ public:
nodep->v3fatalSrc("Expected module parameterization");
}
// Set name for later warnings (if srcModpr changed value due to cloning)
srcModpr->someInstanceName(instanceName);
UINFO(8, " Done with " << nodep << endl);
// if (debug() >= 10)
// v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("param-out.tree"));
@ -1070,7 +1076,7 @@ class ParamVisitor final : public VNVisitor {
UASSERT_OBJ(srcModp, cellp, "Unlinked class ref");
// Update path
string someInstanceName(modp->someInstanceName());
string someInstanceName = modp->someInstanceName();
if (const string* const genHierNamep = cellp->user2u().to<string*>()) {
someInstanceName += *genHierNamep;
cellp->user2p(nullptr);

View File

@ -1,5 +1,5 @@
%Error-UNSUPPORTED: t/t_inst_recurse2_bad.v:18:8: Unsupported: Identically recursive module (module instantiates itself, without changing parameters): 'looped'
: ... note: In instance 't.looped.looped'
: ... note: In instance 't.looped.looped.looped'
18 | module looped ( );
| ^~~~~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest