From f0fb0b05ff3bf8940382db9303ef35be7c313188 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 20 Sep 2024 08:59:10 -0400 Subject: [PATCH] Internals: Misc V3Param cleanups. --- src/V3Param.cpp | 20 +++++++++++++------- test_regress/t/t_inst_recurse2_bad.out | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/V3Param.cpp b/src/V3Param.cpp index d5c5d87d9..41d50dc49 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -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; @@ -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()) { someInstanceName += *genHierNamep; cellp->user2p(nullptr); diff --git a/test_regress/t/t_inst_recurse2_bad.out b/test_regress/t/t_inst_recurse2_bad.out index 024193f31..9ff14a7f2 100644 --- a/test_regress/t/t_inst_recurse2_bad.out +++ b/test_regress/t/t_inst_recurse2_bad.out @@ -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