From 2f718b9ea04d813dd17ebc23d6a11207f7d49082 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 17 Nov 2020 21:10:29 -0500 Subject: [PATCH] Show IEEE reference in array port message, plus internal cleanups. --- src/V3Param.cpp | 6 +++--- src/V3Width.cpp | 17 +++++++---------- test_regress/t/t_inst_array_bad.out | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 2cb57c9f3..dae9078b8 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -532,7 +532,7 @@ private: } return newmodp; } - void visitCell(AstCell* nodep, const string& hierName); + void visitCellDeparam(AstCell* nodep, const string& hierName); void visitModules() { // Loop on all modules left to process // Hitting a cell adds to the appropriate level of this level-sorted list, @@ -558,7 +558,7 @@ private: if (string* genHierNamep = (string*)cellp->user5p()) { fullName += *genHierNamep; } - visitCell(cellp, fullName); + visitCellDeparam(cellp, fullName); } } } @@ -887,7 +887,7 @@ public: //---------------------------------------------------------------------- // VISITs -void ParamVisitor::visitCell(AstCell* nodep, const string& hierName) { +void ParamVisitor::visitCellDeparam(AstCell* nodep, const string& hierName) { // Cell: Check for parameters in the instantiation. iterateChildren(nodep); UASSERT_OBJ(nodep->modp(), nodep, "Not linked?"); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 5a01d586f..583d1df52 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -198,8 +198,7 @@ private: // STATE WidthVP* m_vup = nullptr; // Current node state bool m_paramsOnly; // Computing parameter value; limit operation - AstRange* m_cellRangep - = nullptr; // Range for arrayed instantiations, nullptr for normal instantiations + AstCell* m_cellp = nullptr; // Current cell for arrayed instantiations AstNodeFTask* m_ftaskp = nullptr; // Current function/task AstNodeProcedure* m_procedurep = nullptr; // Current final/always AstLambdaArgRef* m_lambdaArgRefp = nullptr; // Argument to above lambda @@ -4052,8 +4051,8 @@ private: if (conDTypep == pinDTypep // If match, we're golden || similarDTypeRecurse(conDTypep, pinDTypep)) { userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p()); - } else if (m_cellRangep) { - int numInsts = m_cellRangep->elementsConst(); + } else if (m_cellp->rangep()) { + int numInsts = m_cellp->rangep()->elementsConst(); if (conwidth == pinwidth) { // Arrayed instants: widths match so connect to each instance subDTypep = conDTypep; // = same expr dtype @@ -4069,7 +4068,7 @@ private: << " requires " << pinwidth << " or " << pinwidth * numInsts << " bits, but connection's " << nodep->exprp()->prettyTypeName() << " generates " << conwidth - << " bits."); + << " bits. (IEEE 1800-2017 23.3.3)"); subDTypep = conDTypep; // = same expr dtype } userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p()); @@ -4138,6 +4137,8 @@ private: // if (debug()) nodep->dumpTree(cout, "- PinOut: "); } virtual void visit(AstCell* nodep) override { + VL_RESTORER(m_cellp); + m_cellp = nodep; if (!m_paramsOnly) { if (VN_IS(nodep->modp(), NotFoundModule)) { // We've resolved parameters and hit a module that we couldn't resolve. It's @@ -4147,14 +4148,10 @@ private: << nodep->modName() << "'"); v3Global.opt.filePathLookedMsg(nodep->modNameFileline(), nodep->modName()); } - if (nodep->rangep()) { - m_cellRangep = nodep->rangep(); - userIterateAndNext(nodep->rangep(), WidthVP(SELF, BOTH).p()); - } + if (nodep->rangep()) userIterateAndNext(nodep->rangep(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->pinsp(), nullptr); } userIterateAndNext(nodep->paramsp(), nullptr); - m_cellRangep = nullptr; } virtual void visit(AstGatePin* nodep) override { if (m_vup->prelim()) { diff --git a/test_regress/t/t_inst_array_bad.out b/test_regress/t/t_inst_array_bad.out index 312b0b4c3..b438a2a0d 100644 --- a/test_regress/t/t_inst_array_bad.out +++ b/test_regress/t/t_inst_array_bad.out @@ -1,4 +1,4 @@ -%Error: t/t_inst_array_bad.v:19:28: Input port connection 'onebit' as part of a module instance array requires 1 or 8 bits, but connection's VARREF 'onebitbad' generates 9 bits. +%Error: t/t_inst_array_bad.v:19:28: Input port connection 'onebit' as part of a module instance array requires 1 or 8 bits, but connection's VARREF 'onebitbad' generates 9 bits. (IEEE 1800-2017 23.3.3) : ... In instance t 19 | sub sub [7:0] (allbits, onebitbad, bitout); | ^~~~~~~~~