From 43b6876c88f442a9d7b37a72e41fca316792b9dc Mon Sep 17 00:00:00 2001 From: em2machine <92717390+em2machine@users.noreply.github.com> Date: Wed, 8 Apr 2026 16:03:02 +0200 Subject: [PATCH 1/2] promote downward instead of upward --- src/V3Param.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 0223f6bd6..b262f431f 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -1326,6 +1326,22 @@ class ParamProcessor final { } AstConst* const exprp = VN_CAST(pinp->exprp(), Const); AstConst* const origp = VN_CAST(modvarp->valuep(), Const); + // Normalize pin width to the port's declared type for naming only. + // A 32-bit literal and a 1-bit substituted value must produce the + // same specialization name. Use subDTypep() since dtypep() is not + // yet set (V3Width has not run). + AstConst* normedNamep = nullptr; + if (exprp && !exprp->num().isDouble() && !exprp->num().isString() + && !exprp->num().isFourState()) { + const AstNodeDType* const declTypep = modvarp->subDTypep(); + const int portWidth = declTypep ? declTypep->skipRefp()->width() : 0; + if (portWidth > 0 && exprp->num().width() != portWidth) { + V3Number normed{exprp, portWidth}; + normed.opAssign(exprp->num()); + normedNamep = new AstConst{exprp->fileline(), normed}; + } + } + AstConst* const namingExprp = normedNamep ? normedNamep : exprp; if (!exprp) { // With DepGraph architecture, all expressions should be constants // by the time V3Param runs. If not, it's an error. @@ -1346,16 +1362,17 @@ class ParamProcessor final { // This prevents making additional modules, and makes coverage more // obvious as it won't show up under a unique module page name. UINFO(9, "cellPinCleanup: same as default " << pinp); - } else if (exprp->num().isDouble() || exprp->num().isString() - || exprp->num().isFourState() || exprp->num().width() != 32) { + } else if (namingExprp->num().isDouble() || namingExprp->num().isString() + || namingExprp->num().isFourState() || namingExprp->num().width() != 32) { longnamer - += ("_" + paramSmallName(srcModp, modvarp) + paramValueNumber(exprp)); + += ("_" + paramSmallName(srcModp, modvarp) + paramValueNumber(namingExprp)); any_overridesr = true; } else { longnamer - += ("_" + paramSmallName(srcModp, modvarp) + exprp->num().ascii(false)); + += ("_" + paramSmallName(srcModp, modvarp) + namingExprp->num().ascii(false)); any_overridesr = true; } + if (normedNamep) VL_DO_DANGLING(normedNamep->deleteTree(), normedNamep); } } else if (AstParamTypeDType* const modvarp = pinp->modPTypep()) { // Handle DOT with ParseRef RHS (e.g., p_class#(8)::p_type) From 566e6513eb59d51e23f683efbe62d8c38ff2da48 Mon Sep 17 00:00:00 2001 From: github action Date: Wed, 8 Apr 2026 14:04:09 +0000 Subject: [PATCH 2/2] Apply 'make format' --- src/V3Param.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/V3Param.cpp b/src/V3Param.cpp index b262f431f..581b6f4c7 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -1363,13 +1363,14 @@ class ParamProcessor final { // obvious as it won't show up under a unique module page name. UINFO(9, "cellPinCleanup: same as default " << pinp); } else if (namingExprp->num().isDouble() || namingExprp->num().isString() - || namingExprp->num().isFourState() || namingExprp->num().width() != 32) { - longnamer - += ("_" + paramSmallName(srcModp, modvarp) + paramValueNumber(namingExprp)); + || namingExprp->num().isFourState() + || namingExprp->num().width() != 32) { + longnamer += ("_" + paramSmallName(srcModp, modvarp) + + paramValueNumber(namingExprp)); any_overridesr = true; } else { - longnamer - += ("_" + paramSmallName(srcModp, modvarp) + namingExprp->num().ascii(false)); + longnamer += ("_" + paramSmallName(srcModp, modvarp) + + namingExprp->num().ascii(false)); any_overridesr = true; } if (normedNamep) VL_DO_DANGLING(normedNamep->deleteTree(), normedNamep);