From 00059987a122784bef8c554540555d17b409942b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 17 Oct 2021 14:47:19 -0400 Subject: [PATCH 01/79] devel release --- Changes | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index f1bc12cc2..983f69301 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,10 @@ The changes in each Verilator version are described below. The contributors that suggested a given feature are shown in []. Thanks! +Verilator 4.215 devel +========================== + + Verilator 4.214 2021-10-17 ========================== diff --git a/configure.ac b/configure.ac index 18d128901..75f9a35d3 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ #AC_INIT([Verilator],[#.### YYYY-MM-DD]) #AC_INIT([Verilator],[#.### devel]) -AC_INIT([Verilator],[4.214 2021-10-17], +AC_INIT([Verilator],[4.215 devel], [https://verilator.org], [verilator],[https://verilator.org]) # When releasing, also update header of Changes file From 0ef9087f895ea0f6622ec0f95f496b02d41e4ef6 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 17 Oct 2021 14:51:50 -0400 Subject: [PATCH 02/79] Commentary --- Changes | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Changes b/Changes index 983f69301..c8497c591 100644 --- a/Changes +++ b/Changes @@ -11,11 +11,19 @@ contributors that suggested a given feature are shown in []. Thanks! Verilator 4.215 devel ========================== +**Minor:** + + Verilator 4.214 2021-10-17 ========================== +**Major:** + * Add profile-guided optmization of mtasks (#3150). + +**Minor:** + * Verilator_gantt has removed the ASCII graphics, use the VCD output instead. * Verilator_gantt now shows the predicted mtask times, eval times, and additional statistics. * Verilator_gantt data files now include processor information, to allow later processing. From ef7759a5222a1dd0d58d571f40c24676bab2fd5b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 19 Oct 2021 20:33:53 -0400 Subject: [PATCH 03/79] Commentary re: WSL2 --- docs/guide/faq.rst | 6 ++++-- docs/guide/install.rst | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/guide/faq.rst b/docs/guide/faq.rst index c3ffd5b76..845830ae1 100644 --- a/docs/guide/faq.rst +++ b/docs/guide/faq.rst @@ -35,8 +35,10 @@ simulators. Does Verilator run under Windows? """"""""""""""""""""""""""""""""" -Yes, using Cygwin. Verilated output also compiles under Microsoft Visual -C++, but this is not tested every release. +Yes, ideally run Ubuntu under Windows Subsystem for Linux (WSL2). +Alternatively use Cygwin, though this tends to be slower and is not +regurally tested. Verilated output also compiles under Microsoft Visual +C++, but this is also not regurally tested. Can you provide binaries? diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 7b13ae677..b05547858 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -78,10 +78,10 @@ OS Requirements Verilator is developed and has primary testing on Ubuntu, with additional testing on FreeBSD and Apple OS-X. Versions have also built on Redhat -Linux, HPUX and Solaris. It should run with minor porting on any -GNU/Linux-ish platform. Verilator also works on Windows under Cygwin, and -Windows under MinGW (gcc -mno-cygwin). Verilated output (not Verilator -itself) compiles under all the options above, plus using MSVC++. +Linux, and other flavors of GNU/Linux-ish platforms. Verilator also works +on Windows Subsystem for Linux (WSL2), Windows under Cygwin, and Windows +under MinGW (gcc -mno-cygwin). Verilated output (not Verilator itself) +compiles under all the options above, plus using MSVC++. Install Prerequisites From 371bf019574b7930d009f8c11fb5d6fa68d4c6dd Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 19 Oct 2021 21:21:52 -0400 Subject: [PATCH 04/79] Tests: Fix numactl on WSL2 --- test_regress/t/t_bench_mux4k_onecpu.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test_regress/t/t_bench_mux4k_onecpu.pl b/test_regress/t/t_bench_mux4k_onecpu.pl index 832b8d6a4..c53837685 100755 --- a/test_regress/t/t_bench_mux4k_onecpu.pl +++ b/test_regress/t/t_bench_mux4k_onecpu.pl @@ -17,7 +17,10 @@ compile( $Self->wno_unopthreads_for_few_cores()] ); -if (`numactl --show` !~ /cpu/) { +# WSL2 gives a warning and we must skip the test: +# "physcpubind: 0 1 2 3 ...\n No NUMA support available on this system." +my $nout = `numactl --show`; +if ($nout !~ /cpu/ || $nout =~ /system does not support NUMA/i) { skip("No numactl available"); } else { execute( From aa1a0b0f13d517844f4df61b943f0a6da0ec0309 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 19 Oct 2021 21:24:22 -0400 Subject: [PATCH 05/79] Tests: Fix numactl on WSL2 --- test_regress/t/t_bench_mux4k_onecpu.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_regress/t/t_bench_mux4k_onecpu.pl b/test_regress/t/t_bench_mux4k_onecpu.pl index c53837685..4aa4cada7 100755 --- a/test_regress/t/t_bench_mux4k_onecpu.pl +++ b/test_regress/t/t_bench_mux4k_onecpu.pl @@ -20,7 +20,7 @@ compile( # WSL2 gives a warning and we must skip the test: # "physcpubind: 0 1 2 3 ...\n No NUMA support available on this system." my $nout = `numactl --show`; -if ($nout !~ /cpu/ || $nout =~ /system does not support NUMA/i) { +if ($nout !~ /cpu/ || $nout =~ /No NUMA support available/i) { skip("No numactl available"); } else { execute( From dae9fa50530e87216eaf8f7281b496c85f503c32 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 22 Oct 2021 13:56:48 +0100 Subject: [PATCH 06/79] Use VN_AS wherever possible and obvious. No functional change. --- src/V3Active.cpp | 4 +- src/V3ActiveTop.cpp | 2 +- src/V3Assert.cpp | 8 +- src/V3Ast.h | 24 ++-- src/V3AstInlines.h | 12 +- src/V3AstNodes.cpp | 57 ++++----- src/V3AstNodes.h | 141 +++++++++++---------- src/V3Broken.cpp | 2 +- src/V3CCtors.cpp | 2 +- src/V3CUse.cpp | 2 +- src/V3Case.cpp | 24 ++-- src/V3Cdc.cpp | 2 +- src/V3Changed.cpp | 2 +- src/V3Class.cpp | 2 +- src/V3Clock.cpp | 6 +- src/V3Combine.cpp | 6 +- src/V3Const.cpp | 273 ++++++++++++++++++++-------------------- src/V3Coverage.cpp | 4 +- src/V3CoverageJoin.cpp | 2 +- src/V3Dead.cpp | 4 +- src/V3Delayed.cpp | 26 ++-- src/V3EmitCBase.cpp | 2 +- src/V3EmitCBase.h | 2 +- src/V3EmitCConstInit.h | 2 +- src/V3EmitCFunc.cpp | 9 +- src/V3EmitCFunc.h | 16 +-- src/V3EmitCHeaders.cpp | 4 +- src/V3EmitCImp.cpp | 12 +- src/V3EmitCMake.cpp | 2 +- src/V3EmitCSyms.cpp | 8 +- src/V3EmitMk.cpp | 2 +- src/V3EmitV.cpp | 12 +- src/V3Expand.cpp | 17 ++- src/V3Gate.cpp | 22 ++-- src/V3GenClk.cpp | 2 +- src/V3Inline.cpp | 12 +- src/V3Inst.cpp | 29 +++-- src/V3Life.cpp | 4 +- src/V3LifePost.cpp | 4 +- src/V3LinkCells.cpp | 16 +-- src/V3LinkDot.cpp | 71 ++++++----- src/V3LinkInc.cpp | 6 +- src/V3LinkJump.cpp | 12 +- src/V3LinkLevel.cpp | 13 +- src/V3LinkParse.cpp | 2 +- src/V3LinkResolve.cpp | 6 +- src/V3MergeCond.cpp | 2 +- src/V3Name.cpp | 2 +- src/V3Order.cpp | 8 +- src/V3Param.cpp | 54 ++++---- src/V3ParseGrammar.cpp | 8 +- src/V3ParseImp.h | 6 +- src/V3Premit.cpp | 6 +- src/V3Randomize.cpp | 14 +-- src/V3Reloop.cpp | 2 +- src/V3Scope.cpp | 2 +- src/V3Simulate.h | 12 +- src/V3Slice.cpp | 12 +- src/V3SplitVar.cpp | 14 +-- src/V3Subst.cpp | 2 +- src/V3SymTable.h | 2 +- src/V3Task.cpp | 22 ++-- src/V3Trace.cpp | 2 +- src/V3TraceDecl.cpp | 4 +- src/V3Tristate.cpp | 22 ++-- src/V3Unknown.cpp | 16 +-- src/V3Unroll.cpp | 10 +- src/V3VariableOrder.cpp | 2 +- src/V3Width.cpp | 157 ++++++++++++----------- src/V3WidthCommit.h | 2 +- src/V3WidthSel.cpp | 18 +-- 71 files changed, 637 insertions(+), 656 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 76adf0e25..f7292f9e6 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -355,7 +355,7 @@ private: } else if (m_check == CT_LATCH) { // Suppress. Shouldn't matter that the interior of the latch races } else if (!(VN_IS(nodep->lhsp(), VarRef) - && VN_CAST(nodep->lhsp(), VarRef)->varp()->isLatched())) { + && VN_AS(nodep->lhsp(), VarRef)->varp()->isLatched())) { nodep->v3warn(COMBDLY, "Delayed assignments (<=) in non-clocked" " (non flop or latch) block\n" << nodep->warnMore() @@ -490,7 +490,7 @@ private: void visitAlways(AstNode* nodep, AstSenTree* oldsensesp, VAlwaysKwd kwd) { // Move always to appropriate ACTIVE based on its sense list if (oldsensesp && oldsensesp->sensesp() && VN_IS(oldsensesp->sensesp(), SenItem) - && VN_CAST(oldsensesp->sensesp(), SenItem)->isNever()) { + && VN_AS(oldsensesp->sensesp(), SenItem)->isNever()) { // Never executing. Kill it. UASSERT_OBJ(!oldsensesp->sensesp()->nextp(), nodep, "Never senitem should be alone, else the never should be eliminated."); diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 6706dc357..d76ebd6db 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -71,7 +71,7 @@ private: AstSenTree* sensesp = nodep->sensesp(); UASSERT_OBJ(sensesp, nodep, "nullptr"); if (sensesp->sensesp() && VN_IS(sensesp->sensesp(), SenItem) - && VN_CAST(sensesp->sensesp(), SenItem)->isNever()) { + && VN_AS(sensesp->sensesp(), SenItem)->isNever()) { // Never executing. Kill it. UASSERT_OBJ(!sensesp->sensesp()->nextp(), nodep, "Never senitem should be alone, else the never should be eliminated."); diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 40aa060da..1155631f0 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -147,7 +147,7 @@ private: selfDestruct = true; } else { // V3Coverage assigned us a bucket to increment. - AstCoverInc* covincp = VN_CAST(snodep->coverincp(), CoverInc); + AstCoverInc* covincp = VN_AS(snodep->coverincp(), CoverInc); UASSERT_OBJ(covincp, snodep, "Missing AstCoverInc under assertion"); covincp->unlinkFrBackWithNext(); // next() might have AstAssign for trace if (message != "") covincp->declp()->comment(message); @@ -258,7 +258,7 @@ private: if (!nodep->user1SetOnce()) { bool has_default = false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (itemp->isDefault()) has_default = true; } if (nodep->fullPragma() || nodep->priorityPragma()) { @@ -279,7 +279,7 @@ private: } else { AstNode* propp = nullptr; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) { AstNode* onep; if (AstInsideRange* rcondp = VN_CAST(icondp, InsideRange)) { @@ -329,7 +329,7 @@ private: if (nodep->ticksp()) { UASSERT_OBJ(VN_IS(nodep->ticksp(), Const), nodep, "Expected constant ticks, checked in V3Width"); - ticks = VN_CAST(nodep->ticksp(), Const)->toUInt(); + ticks = VN_AS(nodep->ticksp(), Const)->toUInt(); } UASSERT_OBJ(ticks >= 1, nodep, "0 tick should have been checked in V3Width"); AstNode* inp = nodep->exprp()->unlinkFrBack(); diff --git a/src/V3Ast.h b/src/V3Ast.h index 4fb190666..dbe75cde4 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2166,7 +2166,7 @@ public: AstNode* fromp() const { return op1p(); } AstNode* rhsp() const { return op2p(); } AstNode* thsp() const { return op3p(); } - AstAttrOf* attrp() const { return VN_CAST(op4p(), AttrOf); } + AstAttrOf* attrp() const { return VN_AS(op4p(), AttrOf); } void fromp(AstNode* nodep) { return setOp1p(nodep); } void rhsp(AstNode* nodep) { return setOp2p(nodep); } void thsp(AstNode* nodep) { return setOp3p(nodep); } @@ -2304,7 +2304,7 @@ public: virtual int instrCount() const override { return INSTR_COUNT_BRANCH; } AstNode* exprp() const { return op1p(); } // op1 = case condition AstCaseItem* itemsp() const { - return VN_CAST(op2p(), CaseItem); + return VN_AS(op2p(), CaseItem); } // op2 = list of case expressions AstNode* notParallelp() const { return op3p(); } // op3 = assertion code for non-full case's void addItemsp(AstNode* nodep) { addOp2p(nodep); } @@ -2518,10 +2518,10 @@ public: // For basicp() we reuse the size to indicate a "fake" basic type of same size virtual AstBasicDType* basicp() const override { return (isFourstate() - ? VN_CAST(findLogicRangeDType(VNumRange{width() - 1, 0}, width(), numeric()), - BasicDType) - : VN_CAST(findBitRangeDType(VNumRange{width() - 1, 0}, width(), numeric()), - BasicDType)); + ? VN_AS(findLogicRangeDType(VNumRange{width() - 1, 0}, width(), numeric()), + BasicDType) + : VN_AS(findBitRangeDType(VNumRange{width() - 1, 0}, width(), numeric()), + BasicDType)); } virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; } virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; } @@ -2537,7 +2537,7 @@ public: virtual string name() const override { return m_name; } virtual void name(const string& flag) override { m_name = flag; } AstMemberDType* membersp() const { - return VN_CAST(op1p(), MemberDType); + return VN_AS(op1p(), MemberDType); } // op1 = AstMember list void addMembersp(AstNode* nodep) { addNOp1p(nodep); } bool packed() const { return m_packed; } @@ -2591,7 +2591,7 @@ public: && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp())); } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -2599,7 +2599,7 @@ public: void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; } virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } - AstRange* rangep() const { return VN_CAST(op2p(), Range); } // op2 = Array(s) of variable + AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Array(s) of variable void rangep(AstRange* nodep); // METHODS virtual AstBasicDType* basicp() const override { @@ -2762,7 +2762,7 @@ public: AstNode* stmtsp() const { return op3p(); } // op3 = List of statements void addStmtsp(AstNode* nodep) { addNOp3p(nodep); } // op4 = scope name - AstScopeName* scopeNamep() const { return VN_CAST(op4p(), ScopeName); } + AstScopeName* scopeNamep() const { return VN_AS(op4p(), ScopeName); } // MORE ACCESSORS void dpiOpenParentInc() { ++m_dpiOpenParent; } void dpiOpenParentClear() { m_dpiOpenParent = 0; } @@ -2860,7 +2860,7 @@ public: AstNode* pinsp() const { return op3p(); } void addPinsp(AstNode* nodep) { addOp3p(nodep); } // op4 = scope tracking - AstScopeName* scopeNamep() const { return VN_CAST(op4p(), ScopeName); } + AstScopeName* scopeNamep() const { return VN_AS(op4p(), ScopeName); } void scopeNamep(AstNode* nodep) { setNOp4p(nodep); } }; @@ -2906,7 +2906,7 @@ public: virtual string name() const override { return m_name; } virtual bool timescaleMatters() const = 0; AstNode* stmtsp() const { return op2p(); } // op2 = List of statements - AstActive* activesp() const { return VN_CAST(op3p(), Active); } // op3 = List of i/sblocks + AstActive* activesp() const { return VN_AS(op3p(), Active); } // op3 = List of i/sblocks // METHODS void addInlinesp(AstNode* nodep) { addOp1p(nodep); } void addStmtp(AstNode* nodep) { addNOp2p(nodep); } diff --git a/src/V3AstInlines.h b/src/V3AstInlines.h index 2ee0ff9ae..49b84a061 100644 --- a/src/V3AstInlines.h +++ b/src/V3AstInlines.h @@ -34,7 +34,7 @@ inline int AstNode::widthInstrs() const { return (!dtypep() ? 1 : (dtypep()->isWide() ? dtypep()->widthWords() : 1)); } inline bool AstNode::isDouble() const { - return dtypep() && VN_IS(dtypep(), BasicDType) && VN_CAST(dtypep(), BasicDType)->isDouble(); + return dtypep() && VN_IS(dtypep(), BasicDType) && VN_AS(dtypep(), BasicDType)->isDouble(); } inline bool AstNode::isString() const { return dtypep() && dtypep()->basicp() && dtypep()->basicp()->isString(); @@ -42,19 +42,19 @@ inline bool AstNode::isString() const { inline bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); } inline bool AstNode::isZero() const { - return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->num().isEqZero()); + return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isEqZero()); } inline bool AstNode::isNeqZero() const { - return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->num().isNeqZero()); + return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isNeqZero()); } inline bool AstNode::isOne() const { - return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->num().isEqOne()); + return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isEqOne()); } inline bool AstNode::isAllOnes() const { - return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->isEqAllOnes()); + return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->isEqAllOnes()); } inline bool AstNode::isAllOnesV() const { - return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->isEqAllOnesV()); + return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->isEqAllOnesV()); } inline bool AstNode::sameTree(const AstNode* node2p) const { return sameTreeIter(this, node2p, true, false); diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index abc85275f..11b2c7252 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -44,7 +44,7 @@ const char* AstIfaceRefDType::broken() const { } AstIface* AstIfaceRefDType::ifaceViaCellp() const { - return ((m_cellp && m_cellp->modp()) ? VN_CAST(m_cellp->modp(), Iface) : m_ifacep); + return ((m_cellp && m_cellp->modp()) ? VN_AS(m_cellp->modp(), Iface) : m_ifacep); } const char* AstNodeVarRef::broken() const { @@ -73,13 +73,13 @@ const char* AstAddrOfCFunc::broken() const { } int AstNodeSel::bitConst() const { - AstConst* constp = VN_CAST(bitp(), Const); + AstConst* constp = VN_AS(bitp(), Const); return (constp ? constp->toSInt() : 0); } void AstNodeUOrStructDType::repairMemberCache() { clearCache(); - for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_CAST(itemp->nextp(), MemberDType)) { + for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_AS(itemp->nextp(), MemberDType)) { if (m_members.find(itemp->name()) != m_members.end()) { itemp->v3error("Duplicate declaration of member name: " << itemp->prettyNameQ()); } else { @@ -90,7 +90,7 @@ void AstNodeUOrStructDType::repairMemberCache() { const char* AstNodeUOrStructDType::broken() const { std::unordered_set exists; - for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_CAST(itemp->nextp(), MemberDType)) { + for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_AS(itemp->nextp(), MemberDType)) { exists.insert(itemp); } for (MemberNameMap::const_iterator it = m_members.begin(); it != m_members.end(); ++it) { @@ -614,8 +614,8 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) { return nullptr; } } else if (VN_IS(nodep, VarRef)) { - if (VN_CAST(nodep, VarRef)->varp()->isSc()) { - return VN_CAST(nodep, VarRef)->varp(); + if (VN_AS(nodep, VarRef)->varp()->isSc()) { + return VN_AS(nodep, VarRef)->varp(); } else { return nullptr; } @@ -795,25 +795,25 @@ AstNode* AstArraySel::baseFromp(AstNode* nodep, bool overMembers) { // Else AstArraySel etc; search for the base while (nodep) { if (VN_IS(nodep, ArraySel)) { - nodep = VN_CAST(nodep, ArraySel)->fromp(); + nodep = VN_AS(nodep, ArraySel)->fromp(); continue; } else if (VN_IS(nodep, Sel)) { - nodep = VN_CAST(nodep, Sel)->fromp(); + nodep = VN_AS(nodep, Sel)->fromp(); continue; } else if (overMembers && VN_IS(nodep, MemberSel)) { - nodep = VN_CAST(nodep, MemberSel)->fromp(); + nodep = VN_AS(nodep, MemberSel)->fromp(); continue; } // AstNodeSelPre stashes the associated variable under an ATTROF // of AstAttrType::VAR_BASE/MEMBER_BASE so it isn't constified else if (VN_IS(nodep, AttrOf)) { - nodep = VN_CAST(nodep, AttrOf)->fromp(); + nodep = VN_AS(nodep, AttrOf)->fromp(); continue; } else if (VN_IS(nodep, NodePreSel)) { - if (VN_CAST(nodep, NodePreSel)->attrp()) { - nodep = VN_CAST(nodep, NodePreSel)->attrp(); + if (VN_AS(nodep, NodePreSel)->attrp()) { + nodep = VN_AS(nodep, NodePreSel)->attrp(); } else { - nodep = VN_CAST(nodep, NodePreSel)->fromp(); + nodep = VN_AS(nodep, NodePreSel)->fromp(); } continue; } else { @@ -854,7 +854,7 @@ string AstScope::nameDotless() const { string AstScopeName::scopePrettyNameFormatter(AstText* scopeTextp) const { string out; - for (AstText* textp = scopeTextp; textp; textp = VN_CAST(textp->nextp(), Text)) { + for (AstText* textp = scopeTextp; textp; textp = VN_AS(textp->nextp(), Text)) { out += textp->text(); } // TOP will be replaced by top->name() @@ -865,7 +865,7 @@ string AstScopeName::scopePrettyNameFormatter(AstText* scopeTextp) const { } string AstScopeName::scopeNameFormatter(AstText* scopeTextp) const { string out; - for (AstText* textp = scopeTextp; textp; textp = VN_CAST(textp->nextp(), Text)) { + for (AstText* textp = scopeTextp; textp; textp = VN_AS(textp->nextp(), Text)) { out += textp->text(); } if (out.substr(0, 10) == "__DOT__TOP") out.replace(0, 10, ""); @@ -879,28 +879,28 @@ string AstScopeName::scopeNameFormatter(AstText* scopeTextp) const { bool AstSenTree::hasClocked() const { UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it"); - for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { if (senp->isClocked()) return true; } return false; } bool AstSenTree::hasSettle() const { UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it"); - for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { if (senp->isSettle()) return true; } return false; } bool AstSenTree::hasInitial() const { UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it"); - for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { if (senp->isInitial()) return true; } return false; } bool AstSenTree::hasCombo() const { UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it"); - for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { if (senp->isCombo()) return true; } return false; @@ -1041,10 +1041,8 @@ static bool sameInit(const AstInitArray* ap, const AstInitArray* bp) { // - the default/inititem children might be in different order yet still yield the same table // See note in AstInitArray::same about the same. This function instead compares by initializer // value, rather than by tree structure. - const AstUnpackArrayDType* const aDTypep = VN_CAST(ap->dtypep(), UnpackArrayDType); - const AstUnpackArrayDType* const bDTypep = VN_CAST(bp->dtypep(), UnpackArrayDType); - UASSERT_STATIC(aDTypep, "Bad type in array initializer"); - UASSERT_STATIC(bDTypep, "Bad type in array initializer"); + const AstUnpackArrayDType* const aDTypep = VN_AS(ap->dtypep(), UnpackArrayDType); + const AstUnpackArrayDType* const bDTypep = VN_AS(bp->dtypep(), UnpackArrayDType); if (!aDTypep->subDTypep()->sameTree(bDTypep->subDTypep())) { // Element types differ return false; } @@ -1070,7 +1068,7 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) { UASSERT_OBJ(!defaultp || VN_IS(defaultp, Const), initp, "Const pool table default must be Const"); for (AstNode* nodep = initp->initsp(); nodep; nodep = nodep->nextp()) { - AstNode* const valuep = VN_CAST(nodep, InitItem)->valuep(); + AstNode* const valuep = VN_AS(nodep, InitItem)->valuep(); UASSERT_OBJ(VN_IS(valuep, Const), valuep, "Const pool table entry must be Const"); } // Try to find an existing table with the same content @@ -1078,7 +1076,7 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) { const auto& er = m_tables.equal_range(hash.value()); for (auto it = er.first; it != er.second; ++it) { AstVarScope* const varScopep = it->second; - const AstInitArray* const init2p = VN_CAST(varScopep->varp()->valuep(), InitArray); + const AstInitArray* const init2p = VN_AS(varScopep->varp()->valuep(), InitArray); if (sameInit(initp, init2p)) { return varScopep; // Found identical table } @@ -1107,7 +1105,7 @@ AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) { const auto& er = m_consts.equal_range(hash.value()); for (auto it = er.first; it != er.second; ++it) { AstVarScope* const varScopep = it->second; - const AstConst* const init2p = VN_CAST(varScopep->varp()->valuep(), Const); + const AstConst* const init2p = VN_AS(varScopep->varp()->valuep(), Const); if (sameInit(initp, init2p) && (mergeDType || varScopep->dtypep()->sameTree(initp->dtypep()))) { return varScopep; // Found identical constant @@ -1284,9 +1282,8 @@ const char* AstClassPackage::broken() const { return nullptr; } void AstClass::insertCache(AstNode* nodep) { - const bool doit - = (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef) - || (VN_IS(nodep, NodeFTask) && !VN_CAST(nodep, NodeFTask)->isExternProto())); + const bool doit = (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef) + || (VN_IS(nodep, NodeFTask) && !VN_AS(nodep, NodeFTask)->isExternProto())); if (doit) { if (m_members.find(nodep->name()) != m_members.end()) { nodep->v3error("Duplicate declaration of member name: " << nodep->prettyNameQ()); @@ -1314,7 +1311,7 @@ void AstClass::dump(std::ostream& str) const { AstClass* AstClassExtends::classp() const { AstClassRefDType* refp = VN_CAST(dtypep(), ClassRefDType); if (VL_UNLIKELY(!refp)) { // LinkDot uses this for 'super.' - refp = VN_CAST(childDTypep(), ClassRefDType); + refp = VN_AS(childDTypep(), ClassRefDType); } UASSERT_OBJ(refp, this, "class extends non-ref"); return refp->classp(); diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index d9351f101..76d2c1a8f 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -282,7 +282,7 @@ public: virtual string emitC() override { V3ERROR_NA_RETURN(""); } virtual bool cleanOut() const override { return true; } AstNode* exprp() const { return op1p(); } // op1 = Pin expression - AstRange* rangep() const { return VN_CAST(op2p(), Range); } // op2 = Range of pin + AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Range of pin }; //###################################################################### @@ -334,7 +334,7 @@ public: insertCache(nodep); addStmtp(nodep); } - AstClassExtends* extendsp() const { return VN_CAST(op4p(), ClassExtends); } + AstClassExtends* extendsp() const { return VN_AS(op4p(), ClassExtends); } void extendsp(AstNode* nodep) { addNOp4p(nodep); } void clearCache() { m_members.clear(); } void repairCache(); @@ -362,7 +362,7 @@ public: ASTNODE_NODE_FUNCS(ClassExtends) virtual bool hasDType() const override { return true; } virtual string verilogKwd() const override { return "extends"; } - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } AstNode* classOrPkgsp() const { return op2p(); } void classOrPkgsp(AstNode* nodep) { setOp2p(nodep); } @@ -390,7 +390,7 @@ public: ASTNODE_NODE_FUNCS(ParamTypeDType) virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Type assigning to - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return dtypep() ? dtypep() : childDTypep(); @@ -441,7 +441,7 @@ public: virtual void dump(std::ostream& str) const override; virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Type assigning to - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); } void addAttrsp(AstNode* nodep) { addNOp4p(nodep); } @@ -503,7 +503,7 @@ public: } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return dtypep() ? dtypep() : childDTypep(); @@ -567,7 +567,7 @@ public: virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } virtual AstNodeDType* getChild2DTypep() const override { return keyChildDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -581,7 +581,7 @@ public: AstNodeDType* keyDTypep() const { return m_keyDTypep ? m_keyDTypep : keyChildDTypep(); } void keyDTypep(AstNodeDType* nodep) { m_keyDTypep = nodep; } // op1 = Range of variable - AstNodeDType* keyChildDTypep() const { return VN_CAST(op2p(), NodeDType); } + AstNodeDType* keyChildDTypep() const { return VN_AS(op2p(), NodeDType); } void keyChildDTypep(AstNodeDType* nodep) { setOp2p(nodep); } // METHODS virtual AstBasicDType* basicp() const override { return nullptr; } @@ -607,7 +607,7 @@ public: ASTNODE_NODE_FUNCS(BracketArrayDType) virtual bool similarDType(AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } virtual AstNodeDType* subDTypep() const override { return childDTypep(); } // op2 = Range of variable AstNode* elementsp() const { return op2p(); } @@ -664,7 +664,7 @@ public: virtual void dumpSmall(std::ostream& str) const override; virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -780,7 +780,7 @@ public: virtual void dumpSmall(std::ostream& str) const override; virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -889,7 +889,7 @@ public: BROKEN_RTN(dtypep() != this); return nullptr; } - AstRange* rangep() const { return VN_CAST(op1p(), Range); } // op1 = Range of variable + AstRange* rangep() const { return VN_AS(op1p(), Range); } // op1 = Range of variable void rangep(AstRange* nodep) { setNOp1p(nodep); } void setSignedState(const VSigning& signst) { // Note NOSIGN does NOT change the state; this is required by the parser @@ -983,7 +983,7 @@ public: } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -1049,7 +1049,7 @@ public: void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } AstClass* classp() const { return m_classp; } void classp(AstClass* nodep) { m_classp = nodep; } - AstPin* paramsp() const { return VN_CAST(op4p(), Pin); } + AstPin* paramsp() const { return VN_AS(op4p(), Pin); } virtual bool isCompound() const override { return true; } }; @@ -1150,7 +1150,7 @@ public: virtual string prettyDTypeName() const override; virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -1272,7 +1272,7 @@ public: void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; } AstNode* typeofp() const { return op2p(); } AstNode* classOrPackageOpp() const { return op3p(); } - AstPin* paramsp() const { return VN_CAST(op4p(), Pin); } + AstPin* paramsp() const { return VN_AS(op4p(), Pin); } virtual bool isCompound() const override { v3fatalSrc("call isCompound on subdata type, not reference"); return false; @@ -1329,7 +1329,7 @@ public: virtual bool maybePointedTo() const override { return true; } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } virtual AstNodeDType* subDTypep() const override { return m_refDTypep ? m_refDTypep : childDTypep(); @@ -1436,8 +1436,8 @@ public: virtual bool maybePointedTo() const override { return true; } virtual bool hasDType() const override { return true; } virtual void name(const string& flag) override { m_name = flag; } - AstRange* rangep() const { return VN_CAST(op1p(), Range); } // op1 = Range for name appending - void rangep(AstNode* nodep) { addOp1p(nodep); } + AstRange* rangep() const { return VN_AS(op1p(), Range); } // op1 = Range for name appending + void rangep(AstRange* nodep) { addOp1p(nodep); } AstNode* valuep() const { return op2p(); } // op2 = Value void valuep(AstNode* nodep) { addOp2p(nodep); } }; @@ -1462,7 +1462,7 @@ public: } virtual int instrCount() const override { return 0; } virtual void cloneRelink() override { - if (m_itemp->clonep()) m_itemp = VN_CAST(m_itemp->clonep(), EnumItem); + if (m_itemp->clonep()) m_itemp = VN_AS(m_itemp->clonep(), EnumItem); } virtual bool same(const AstNode* samep) const override { const AstEnumItemRef* sp = static_cast(samep); @@ -1510,7 +1510,7 @@ public: } virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } // op1 = Data type + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } // op1 = Data type void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } // op1 = Range of variable virtual AstNodeDType* subDTypep() const override { @@ -1521,8 +1521,7 @@ public: virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); } virtual string name() const override { return m_name; } virtual void name(const string& flag) override { m_name = flag; } - AstEnumItem* itemsp() const { return VN_CAST(op2p(), EnumItem); } // op2 = AstEnumItem's - void addValuesp(AstNode* nodep) { addOp2p(nodep); } + AstEnumItem* itemsp() const { return VN_AS(op2p(), EnumItem); } // op2 = AstEnumItem's // METHODS virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); } virtual AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); } @@ -1575,7 +1574,7 @@ private: void init(AstNode* fromp) { if (fromp && VN_IS(fromp->dtypep()->skipRefp(), NodeArrayDType)) { // Strip off array to find what array references - dtypeFrom(VN_CAST(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep()); + dtypeFrom(VN_AS(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep()); } } @@ -1620,7 +1619,7 @@ private: void init(AstNode* fromp) { if (fromp && VN_IS(fromp->dtypep()->skipRefp(), AssocArrayDType)) { // Strip off array to find what array references - dtypeFrom(VN_CAST(fromp->dtypep()->skipRefp(), AssocArrayDType)->subDTypep()); + dtypeFrom(VN_AS(fromp->dtypep()->skipRefp(), AssocArrayDType)->subDTypep()); } } @@ -1752,7 +1751,7 @@ public: : ASTGEN_SUPER_Sel(fl, fromp, lsbp, widthp) , m_declElWidth{1} { if (VN_IS(widthp, Const)) { - dtypeSetLogicSized(VN_CAST(widthp, Const)->toUInt(), VSigning::UNSIGNED); + dtypeSetLogicSized(VN_AS(widthp, Const)->toUInt(), VSigning::UNSIGNED); } } AstSel(FileLine* fl, AstNode* fromp, int lsb, int bitwidth) @@ -1787,8 +1786,8 @@ public: } // op1 = Extracting what (nullptr=TBD during parsing) AstNode* lsbp() const { return op2p(); } // op2 = Msb selection expression AstNode* widthp() const { return op3p(); } // op3 = Width - int widthConst() const { return VN_CAST(widthp(), Const)->toSInt(); } - int lsbConst() const { return VN_CAST(lsbp(), Const)->toSInt(); } + int widthConst() const { return VN_AS(widthp(), Const)->toSInt(); } + int lsbConst() const { return VN_AS(lsbp(), Const)->toSInt(); } int msbConst() const { return lsbConst() + widthConst() - 1; } VNumRange& declRange() { return m_declRange; } const VNumRange& declRange() const { return m_declRange; } @@ -2100,7 +2099,7 @@ public: void combineType(AstVarType type); virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } // op1 = Range of variable - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } AstNodeDType* dtypeSkipRefp() const { return subDTypep()->skipRefp(); } // (Slow) recurse down to find basic data type (Note don't need virtual - // AstVar isn't a NodeDType) @@ -2350,7 +2349,7 @@ public: ASTNODE_NODE_FUNCS(TopScope) AstNode* stmtsp() const { return op1p(); } void addStmtsp(AstNode* nodep) { addOp1p(nodep); } - AstScope* scopep() const { return VN_CAST(op2p(), Scope); } // op1 = AstVarScope's + AstScope* scopep() const { return VN_AS(op2p(), Scope); } // op1 = AstVarScope's }; class AstVarScope final : public AstNode { @@ -2860,13 +2859,13 @@ public: string modName() const { return m_modName; } // * = Instance name void modName(const string& name) { m_modName = name; } FileLine* modNameFileline() const { return m_modNameFileline; } - AstPin* pinsp() const { return VN_CAST(op1p(), Pin); } // op1 = List of cell ports + AstPin* pinsp() const { return VN_AS(op1p(), Pin); } // op1 = List of cell ports // op2 = List of parameter #(##) values - AstPin* paramsp() const { return VN_CAST(op2p(), Pin); } + AstPin* paramsp() const { return VN_AS(op2p(), Pin); } // op3 = Range of arrayed instants (nullptr=not ranged) - AstRange* rangep() const { return VN_CAST(op3p(), Range); } + AstRange* rangep() const { return VN_AS(op3p(), Range); } // op4 = List of interface references - AstIntfRef* intfRefp() const { return VN_CAST(op4p(), IntfRef); } + AstIntfRef* intfRefp() const { return VN_AS(op4p(), IntfRef); } AstNodeModule* modp() const { return m_modp; } // [AfterLink] = Pointer to module instantiated void addPinsp(AstPin* nodep) { addOp1p(nodep); } void addParamsp(AstPin* nodep) { addOp2p(nodep); } @@ -3070,10 +3069,10 @@ public: virtual string name() const override { return m_name; } // * = Var name AstNode* classOrPackageNodep() const { return m_classOrPackageNodep; } void classOrPackageNodep(AstNode* nodep) { m_classOrPackageNodep = nodep; } - AstNodeModule* classOrPackagep() const { return VN_CAST(m_classOrPackageNodep, NodeModule); } - AstPackage* packagep() const { return VN_CAST(classOrPackageNodep(), Package); } + AstNodeModule* classOrPackagep() const { return VN_AS(m_classOrPackageNodep, NodeModule); } + AstPackage* packagep() const { return VN_AS(classOrPackageNodep(), Package); } void classOrPackagep(AstNodeModule* nodep) { m_classOrPackageNodep = nodep; } - AstPin* paramsp() const { return VN_CAST(op4p(), Pin); } + AstPin* paramsp() const { return VN_AS(op4p(), Pin); } }; class AstDot final : public AstNode { @@ -3244,8 +3243,8 @@ public: return nullptr; } // - AstLambdaArgRef* indexArgRefp() const { return VN_CAST(op1p(), LambdaArgRef); } - AstLambdaArgRef* valueArgRefp() const { return VN_CAST(op2p(), LambdaArgRef); } + AstLambdaArgRef* indexArgRefp() const { return VN_AS(op1p(), LambdaArgRef); } + AstLambdaArgRef* valueArgRefp() const { return VN_AS(op2p(), LambdaArgRef); } AstNode* exprp() const { return op3p(); } }; @@ -3322,7 +3321,7 @@ public: virtual bool maybePointedTo() const override { return true; } bool isMulti() const { return m_multi; } // op1 = Sensitivity list - AstSenItem* sensesp() const { return VN_CAST(op1p(), SenItem); } + AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } void addSensesp(AstSenItem* nodep) { addOp1p(nodep); } void multi(bool flag) { m_multi = true; } // METHODS @@ -3358,7 +3357,7 @@ public: ASTNODE_NODE_FUNCS(Always) // virtual void dump(std::ostream& str) const override; - AstSenTree* sensesp() const { return VN_CAST(op1p(), SenTree); } // op1 = Sensitivity list + AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } // op1 = Sensitivity list void sensesp(AstSenTree* nodep) { setOp1p(nodep); } VAlwaysKwd keyword() const { return m_keyword; } }; @@ -3394,7 +3393,7 @@ public: ASTNODE_NODE_FUNCS(AlwaysPublic) virtual bool same(const AstNode* samep) const override { return true; } // - AstSenTree* sensesp() const { return VN_CAST(op1p(), SenTree); } // op1 = Sensitivity list + AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } // op1 = Sensitivity list AstNode* bodysp() const { return op2p(); } // op2 = Statements to evaluate void addStmtp(AstNode* nodep) { addOp2p(nodep); } // Special accessors @@ -3525,7 +3524,7 @@ public: addOp1p(new AstVarRef{fl, varScopep, VAccess::WRITE}); } ASTNODE_NODE_FUNCS(DpiExportUpdated) - AstVarScope* varScopep() const { return VN_CAST(op1p(), VarRef)->varScopep(); } + AstVarScope* varScopep() const { return VN_AS(op1p(), VarRef)->varScopep(); } }; class AstExprStmt final : public AstNodeMath { @@ -3707,7 +3706,7 @@ public: return false; // Though the AstCoverInc under this is an outputter } // but isPure() true - AstCoverInc* incp() const { return VN_CAST(op1p(), CoverInc); } + AstCoverInc* incp() const { return VN_AS(op1p(), CoverInc); } void incp(AstCoverInc* nodep) { setOp1p(nodep); } AstNode* origp() const { return op2p(); } AstNode* changep() const { return op3p(); } @@ -3846,7 +3845,7 @@ public: AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output string text() const { return m_text; } // * = Text to display void text(const string& text) { m_text = text; } - AstScopeName* scopeNamep() const { return VN_CAST(op2p(), ScopeName); } + AstScopeName* scopeNamep() const { return VN_AS(op2p(), ScopeName); } void scopeNamep(AstNode* nodep) { setNOp2p(nodep); } bool formatScopeTracking() const { // Track scopeNamep(); Ok if false positive return (name().find("%m") != string::npos || name().find("%M") != string::npos); @@ -3907,7 +3906,7 @@ public: // * = Add a newline for $display bool addNewline() const { return displayType().addNewline(); } void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter - AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); } + AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); } AstNode* filep() const { return op3p(); } void filep(AstNodeVarRef* nodep) { setNOp3p(nodep); } }; @@ -3969,7 +3968,7 @@ public: AstDisplayType displayType() const { return m_displayType; } void displayType(AstDisplayType type) { m_displayType = type; } void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter - AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); } + AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); } }; class AstSFormat final : public AstNodeStmt { @@ -4002,7 +4001,7 @@ public: virtual int instrCount() const override { return INSTR_COUNT_PLI; } virtual bool same(const AstNode* samep) const override { return true; } void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter - AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); } + AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); } AstNode* lhsp() const { return op3p(); } void lhsp(AstNode* nodep) { setOp3p(nodep); } }; @@ -5193,7 +5192,7 @@ public: virtual bool isPure() const override { return false; } virtual bool isOutputter() const override { return false; } virtual int instrCount() const override { return 0; } - AstSenTree* sensesp() const { return VN_CAST(op1p(), SenTree); } + AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } AstNode* stmtsp() const { return op2p(); } }; @@ -5355,7 +5354,7 @@ public: AstSenTree* sensesp() const { return m_sensesp; } // op1 = Sensitivity tree, if a clocked block in early stages void sensesStorep(AstSenTree* nodep) { addOp1p(nodep); } - AstSenTree* sensesStorep() const { return VN_CAST(op1p(), SenTree); } + AstSenTree* sensesStorep() const { return VN_AS(op1p(), SenTree); } // op2 = Combo logic AstNode* stmtsp() const { return op2p(); } void addStmtsp(AstNode* nodep) { addOp2p(nodep); } @@ -5405,9 +5404,9 @@ public: virtual string emitVerilog() override { return ""; } virtual string emitC() override { V3ERROR_NA_RETURN(""); } virtual bool cleanOut() const override { return true; } - AstText* scopeAttrp() const { return VN_CAST(op1p(), Text); } + AstText* scopeAttrp() const { return VN_AS(op1p(), Text); } void scopeAttrp(AstNode* nodep) { addOp1p(nodep); } - AstText* scopeEntrp() const { return VN_CAST(op2p(), Text); } + AstText* scopeEntrp() const { return VN_AS(op2p(), Text); } void scopeEntrp(AstNode* nodep) { addOp2p(nodep); } string scopeSymName() const { // Name for __Vscope variable including children return scopeNameFormatter(scopeAttrp()); @@ -5433,7 +5432,7 @@ public: } ASTNODE_NODE_FUNCS(UdpTable) // op1 = List of UdpTableLines - AstUdpTableLine* bodysp() const { return VN_CAST(op1p(), UdpTableLine); } + AstUdpTableLine* bodysp() const { return VN_AS(op1p(), UdpTableLine); } }; class AstUdpTableLine final : public AstNode { @@ -6041,7 +6040,7 @@ public: AstNode* fromp() const { return lhsp(); } void lhsp(AstNode* nodep) { setOp1p(nodep); } virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } - AstNodeDType* childDTypep() const { return VN_CAST(op2p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op2p(), NodeDType); } virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); } }; @@ -8316,7 +8315,7 @@ public: virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } virtual int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression - AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain + AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain virtual bool same(const AstNode* samep) const override { return true; } }; @@ -8339,7 +8338,7 @@ public: virtual int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression AstNode* ticksp() const { return op2p(); } // op2 = ticks or nullptr means 1 - AstSenTree* sentreep() const { return VN_CAST(op4p(), SenTree); } // op4 = clock domain + AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain void sentreep(AstSenTree* sentreep) { addOp4p(sentreep); } // op4 = clock domain virtual bool same(const AstNode* samep) const override { return true; } }; @@ -8360,7 +8359,7 @@ public: virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } virtual int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression - AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain + AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain virtual bool same(const AstNode* samep) const override { return true; } }; @@ -8400,7 +8399,7 @@ public: virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); } virtual int instrCount() const override { return widthInstrs(); } AstNode* exprp() const { return op1p(); } // op1 = expression - AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain + AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain virtual bool same(const AstNode* samep) const override { return true; } }; @@ -8423,7 +8422,7 @@ public: virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); } virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); } // op1 = Type assigning to - AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } + AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } AstNode* itemsp() const { return op2p(); } // op2 = AstPatReplicate, AstPatMember, etc }; @@ -8474,7 +8473,7 @@ public: AstNode* rhsp() const { return op2p(); } void lhsp(AstNode* nodep) { return setOp1p(nodep); } void rhsp(AstNode* nodep) { return setOp2p(nodep); } - AstSenTree* sentreep() const { return VN_CAST(op4p(), SenTree); } // op4 = clock domain + AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain void sentreep(AstSenTree* sentreep) { addOp4p(sentreep); } // op4 = clock domain virtual bool same(const AstNode* samep) const override { return true; } }; @@ -8494,7 +8493,7 @@ public: } ASTNODE_NODE_FUNCS(Clocking) // op1 = Sensitivity list - AstSenItem* sensesp() const { return VN_CAST(op1p(), SenItem); } + AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } AstNode* bodysp() const { return op2p(); } // op2 = Body }; @@ -8516,7 +8515,7 @@ public: virtual bool hasDType() const override { return true; } // Used under Cover, which expects a bool child - AstSenItem* sensesp() const { return VN_CAST(op1p(), SenItem); } // op1 = Sensitivity list + AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } // op1 = Sensitivity list AstNode* disablep() const { return op2p(); } // op2 = disable AstNode* propp() const { return op3p(); } // op3 = property }; @@ -8543,7 +8542,7 @@ public: virtual void name(const string& name) override { m_name = name; } virtual void dump(std::ostream& str = std::cout) const override; AstNode* propp() const { return op1p(); } // op1 = property - AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain + AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain AstNode* passsp() const { return op4p(); } // op4 = statements (assert/cover passes) bool immediate() const { return m_immediate; } @@ -8719,7 +8718,7 @@ public: virtual string name() const override { return m_name; } virtual bool same(const AstNode* samep) const override { return true; } void tblockp(AstTextBlock* tblockp) { setOp1p(tblockp); } - AstTextBlock* tblockp() { return VN_CAST(op1p(), TextBlock); } + AstTextBlock* tblockp() { return VN_AS(op1p(), TextBlock); } }; //====================================================================== @@ -9019,7 +9018,7 @@ public: class AstCReset final : public AstNodeStmt { // Reset variable at startup public: - AstCReset(FileLine* fl, AstNode* exprsp) + AstCReset(FileLine* fl, AstVarRef* exprsp) : ASTGEN_SUPER_CReset(fl) { addNOp1p(exprsp); } @@ -9027,7 +9026,7 @@ public: virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } virtual bool same(const AstNode* samep) const override { return true; } - AstVarRef* varrefp() const { return VN_CAST(op1p(), VarRef); } // op1 = varref to reset + AstVarRef* varrefp() const { return VN_AS(op1p(), VarRef); } // op1 = varref to reset }; class AstCStmt final : public AstNodeStmt { @@ -9138,7 +9137,7 @@ class AstTypeTable final : public AstNode { public: explicit AstTypeTable(FileLine* fl); ASTNODE_NODE_FUNCS(TypeTable) - AstNodeDType* typesp() const { return VN_CAST(op1p(), NodeDType); } // op1 = List of dtypes + AstNodeDType* typesp() const { return VN_AS(op1p(), NodeDType); } // op1 = List of dtypes void addTypesp(AstNodeDType* nodep) { addOp1p(nodep); } AstBasicDType* findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd); AstBasicDType* findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, int width, int widthMin, @@ -9212,13 +9211,13 @@ public: virtual string name() const override { return "$root"; } virtual void dump(std::ostream& str) const override; AstNodeModule* modulesp() const { // op1 = List of modules - return VN_CAST(op1p(), NodeModule); + return VN_AS(op1p(), NodeModule); } - AstNodeModule* topModulep() const { // * = Top module in hierarchy (first one added, for now) - return VN_CAST(op1p(), NodeModule); + AstNodeModule* topModulep() const { // Top module in hierarchy + return modulesp(); // First one in the list, for now } void addModulep(AstNodeModule* modulep) { addOp1p(modulep); } - AstNodeFile* filesp() const { return VN_CAST(op2p(), NodeFile); } // op2 = List of files + AstNodeFile* filesp() const { return VN_AS(op2p(), NodeFile); } // op2 = List of files void addFilesp(AstNodeFile* filep) { addOp2p(filep); } AstNode* miscsp() const { return op3p(); } // op3 = List of dtypes etc void addMiscsp(AstNode* nodep) { addOp3p(nodep); } diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index a1b081523..fb10a1972 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -242,7 +242,7 @@ private: processAndIterate(nodep); UASSERT_OBJ(!(v3Global.assertDTypesResolved() && nodep->brokeLhsMustBeLvalue() && VN_IS(nodep->lhsp(), NodeVarRef) - && !VN_CAST(nodep->lhsp(), NodeVarRef)->access().isWriteOrRW()), + && !VN_AS(nodep->lhsp(), NodeVarRef)->access().isWriteOrRW()), nodep, "Assignment LHS is not an lvalue"); } virtual void visit(AstScope* nodep) override { diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index 40b328966..fcee962dc 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -175,7 +175,7 @@ void V3CCtors::cctorsAll() { UINFO(2, __FUNCTION__ << ": " << endl); evalAsserts(); for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; - modp = VN_CAST(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { // Process each module in turn { V3CCtorsBuilder var_reset{modp, "_ctor_var_reset", diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 54c2a0566..5e35527df 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -100,7 +100,7 @@ void V3CUse::cUseAll() { UINFO(2, __FUNCTION__ << ": " << endl); // Call visitor separately for each module, so visitor state is cleared for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; - modp = VN_CAST(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { // Insert under this module; someday we should e.g. make Ast // for each output file and put under that CUseVisitor{modp}; diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 843f804d3..d9c2ce710 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -59,13 +59,13 @@ private: VL_DEBUG_FUNC; // Declare debug() virtual void visit(AstNodeCase* nodep) override { - if (VN_IS(nodep, Case) && VN_CAST(nodep, Case)->casex()) { + if (VN_IS(nodep, Case) && VN_AS(nodep, Case)->casex()) { nodep->v3warn(CASEX, "Suggest casez (with ?'s) in place of casex (with X's)"); } // Detect multiple defaults bool hitDefault = false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (itemp->isDefault()) { if (hitDefault) { itemp->v3error("Multiple default statements in case statement."); @@ -79,7 +79,7 @@ private: m_caseExprp = nodep; iterate(nodep->exprp()); for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { iterateAndNextNull(itemp->condsp()); } m_caseExprp = nullptr; @@ -91,11 +91,11 @@ private: if (VN_IS(m_caseExprp, GenCase)) { nodep->v3error("Use of x/? constant in generate case statement, " "(no such thing as 'generate casez')"); - } else if (VN_IS(m_caseExprp, Case) && VN_CAST(m_caseExprp, Case)->casex()) { + } else if (VN_IS(m_caseExprp, Case) && VN_AS(m_caseExprp, Case)->casex()) { // Don't sweat it, we already complained about casex in general } else if (VN_IS(m_caseExprp, Case) - && (VN_CAST(m_caseExprp, Case)->casez() - || VN_CAST(m_caseExprp, Case)->caseInside())) { + && (VN_AS(m_caseExprp, Case)->casez() + || VN_AS(m_caseExprp, Case)->caseInside())) { if (nodep->num().isAnyX()) { nodep->v3warn(CASEWITHX, "Use of x constant in casez statement, " "(perhaps intended ?/z in constant)"); @@ -145,7 +145,7 @@ private: m_caseItems = 0; m_caseNoOverlapsAllCovered = true; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) { if (icondp->width() > width) width = icondp->width(); if (icondp->isDouble()) opaque = true; @@ -167,10 +167,10 @@ private: bool reportedOverlap = false; bool reportedSubcase = false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) { // if (debug() >= 9) icondp->dumpTree(cout, " caseitem: "); - AstConst* iconstp = VN_CAST(icondp, Const); + AstConst* iconstp = VN_AS(icondp, Const); UASSERT_OBJ(iconstp, nodep, "above 'can't parse' should have caught this"); if (neverItem(nodep, iconstp)) { // X in casez can't ever be executed @@ -244,7 +244,7 @@ private: // Convert valueItem from AstCaseItem* to the expression // Not done earlier, as we may now have a nullptr because it's just a ";" NOP branch for (uint32_t i = 0; i < numCases; ++i) { - m_valueItem[i] = VN_CAST(m_valueItem[i], CaseItem)->bodysp(); + m_valueItem[i] = VN_AS(m_valueItem[i], CaseItem)->bodysp(); } return true; // All is fine } @@ -341,7 +341,7 @@ private: if (debug() >= 9) nodep->dumpTree(cout, " _comp_IN: "); bool hadDefault = false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (!itemp->condsp()) { // Default clause. Just make true, we'll optimize it away later itemp->condsp(new AstConst(itemp->fileline(), AstConst::BitTrue())); @@ -416,7 +416,7 @@ private: AstIf* groupnextp = nullptr; AstIf* itemnextp = nullptr; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { AstNode* istmtsp = itemp->bodysp(); // Maybe null -- no action. if (istmtsp) istmtsp->unlinkFrBackWithNext(); // Expressioned clause diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 98b9168c3..03e6aedab 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -599,7 +599,7 @@ private: } } // If multiple domains need to do complicated optimizations - if (senedited) senoutp = VN_CAST(V3Const::constifyExpensiveEdit(senoutp), SenTree); + if (senedited) senoutp = VN_AS(V3Const::constifyExpensiveEdit(senoutp), SenTree); if (traceDests) { vertexp->dstDomainSet(true); // Note it's set - domainp may be null, so can't use that vertexp->dstDomainp(senoutp); diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index aac14f59a..6c7111f5c 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -94,7 +94,7 @@ public: if (!m_tlChgFuncp->stmtsp()) { m_tlChgFuncp->addStmtsp(new AstCReturn{m_scopetopp->fileline(), callp}); } else { - AstCReturn* const returnp = VN_CAST(m_tlChgFuncp->stmtsp(), CReturn); + AstCReturn* const returnp = VN_AS(m_tlChgFuncp->stmtsp(), CReturn); UASSERT_OBJ(returnp, m_scopetopp, "Lost CReturn in top change function"); // This is currently using AstLogOr which will shortcut the // evaluation if any function returns true. This is likely what diff --git a/src/V3Class.cpp b/src/V3Class.cpp index da29a24c1..e317a3480 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -141,7 +141,7 @@ public: if (VN_IS(moved.first, NodeFTask)) { moved.second->addActivep(moved.first->unlinkFrBack()); } else if (VN_IS(moved.first, Var)) { - AstVarScope* scopep = VN_CAST(moved.first->user1p(), VarScope); + AstVarScope* scopep = VN_AS(moved.first->user1p(), VarScope); moved.second->addVarp(scopep->unlinkFrBack()); } } diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 07d8e2c81..4cad9d93d 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -172,7 +172,7 @@ private: AstNode* createSenseEquation(AstSenItem* nodesp) { // Nodep may be a list of elements; we need to walk it AstNode* senEqnp = nullptr; - for (AstSenItem* senp = nodesp; senp; senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = nodesp; senp; senp = VN_AS(senp->nextp(), SenItem)) { AstNode* const senOnep = createSenItemEquation(senp); if (senEqnp) { // Add new OR to the sensitivity list equation @@ -412,8 +412,8 @@ private: } } virtual void visit(AstExecGraph* nodep) override { - for (m_mtaskBodyp = VN_CAST(nodep->op1p(), MTaskBody); m_mtaskBodyp; - m_mtaskBodyp = VN_CAST(m_mtaskBodyp->nextp(), MTaskBody)) { + for (m_mtaskBodyp = VN_AS(nodep->op1p(), MTaskBody); m_mtaskBodyp; + m_mtaskBodyp = VN_AS(m_mtaskBodyp->nextp(), MTaskBody)) { clearLastSen(); iterate(m_mtaskBodyp); } diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index 71582a60f..5fbfd1f3a 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -132,7 +132,7 @@ private: // METHODS void walkEmptyFuncs() { for (const auto& itr : m_dupFinder) { - AstCFunc* const oldfuncp = VN_CAST(itr.second, CFunc); + AstCFunc* const oldfuncp = VN_AS(itr.second, CFunc); UASSERT_OBJ(oldfuncp, itr.second, "Not a CFunc in hash"); if (!oldfuncp->emptyBody()) continue; UASSERT_OBJ(!oldfuncp->dontCombine(), oldfuncp, @@ -152,14 +152,14 @@ private: // Do non-slow first as then favors naming functions based on fast name for (const bool slow : {false, true}) { for (auto newIt = m_dupFinder.begin(); newIt != m_dupFinder.end(); ++newIt) { - AstCFunc* const newfuncp = VN_CAST(newIt->second, CFunc); + AstCFunc* const newfuncp = VN_AS(newIt->second, CFunc); UASSERT_OBJ(newfuncp, newIt->second, "Not a CFunc in hash"); if (newfuncp->user3()) continue; // Already replaced if (newfuncp->slow() != slow) continue; auto oldIt = newIt; ++oldIt; // Skip over current position for (; oldIt != m_dupFinder.end(); ++oldIt) { - AstCFunc* const oldfuncp = VN_CAST(oldIt->second, CFunc); + AstCFunc* const oldfuncp = VN_AS(oldIt->second, CFunc); UASSERT_OBJ(oldfuncp, oldIt->second, "Not a CFunc in hash"); UASSERT_OBJ(newfuncp != oldfuncp, newfuncp, "Same function hashed multiple times"); diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 047b0810d..6b8187fe6 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -902,7 +902,7 @@ private: // Remove And with constant one inserted by V3Clean // 1 & (a == b) -> (IData)(a == b) // When bool is casted to int, the value is either 0 or 1 - AstConst* constp = VN_CAST(andp->lhsp(), Const); + AstConst* constp = VN_AS(andp->lhsp(), Const); UASSERT_OBJ(constp && constp->isOne(), andp->lhsp(), "TRREEOPC must meet this condition"); AstNode* rhsp = andp->rhsp(); AstCCast* ccastp = nullptr; @@ -945,20 +945,20 @@ private: AstNode* ap; AstNodeBiop* andp; if (VN_IS(nodep->lhsp(), And)) { - andp = VN_CAST(nodep->lhsp(), And); + andp = VN_AS(nodep->lhsp(), And); ap = nodep->rhsp(); } else if (VN_IS(nodep->rhsp(), And)) { - andp = VN_CAST(nodep->rhsp(), And); + andp = VN_AS(nodep->rhsp(), And); ap = nodep->lhsp(); } else return false; AstNodeUniop* notp; AstNode* cp; if (VN_IS(andp->lhsp(), Not)) { - notp = VN_CAST(andp->lhsp(), Not); + notp = VN_AS(andp->lhsp(), Not); cp = andp->rhsp(); } else if (VN_IS(andp->rhsp(), Not)) { - notp = VN_CAST(andp->rhsp(), Not); + notp = VN_AS(andp->rhsp(), Not); cp = andp->lhsp(); } else return false; @@ -1007,10 +1007,10 @@ private: // 0xff & (a << 8 | b >> 24) --> 0xff & (b >> 24) // Compute how many significant bits are in the mask - const AstConst* const constp = VN_CAST(nodep->lhsp(), Const); + const AstConst* const constp = VN_AS(nodep->lhsp(), Const); const uint32_t significantBits = constp->num().widthMin(); - AstOr* const orp = VN_CAST(nodep->rhsp(), Or); + AstOr* const orp = VN_AS(nodep->rhsp(), Or); // Predicate for checking whether the bottom 'significantBits' bits of the given expression // are all zeroes. @@ -1049,7 +1049,7 @@ private: // drop redundant masking of left shift result. E.g.: 0xff000000 & ((uint32_t)a << 24). const auto checkMask = [=](const V3Number& mask) -> bool { - const AstConst* const constp = VN_CAST(nodep->lhsp(), Const); + const AstConst* const constp = VN_AS(nodep->lhsp(), Const); if (constp->num().isCaseEq(mask)) { AstNode* const rhsp = nodep->rhsp(); rhsp->unlinkFrBack(); @@ -1121,7 +1121,7 @@ private: return newp; } static bool operandShiftSame(const AstNode* nodep) { - const AstNodeBiop* np = VN_CAST_CONST(nodep, NodeBiop); + const AstNodeBiop* np = VN_AS_CONST(nodep, NodeBiop); { const AstShiftL* lp = VN_CAST_CONST(np->lhsp(), ShiftL); const AstShiftL* rp = VN_CAST_CONST(np->rhsp(), ShiftL); @@ -1142,28 +1142,28 @@ private: } bool operandHugeShiftL(const AstNodeBiop* nodep) { return (VN_IS(nodep->rhsp(), Const) - && !VN_CAST_CONST(nodep->rhsp(), Const)->num().isFourState() - && (VN_CAST_CONST(nodep->rhsp(), Const)->toUInt() + && !VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState() + && (VN_AS_CONST(nodep->rhsp(), Const)->toUInt() >= static_cast(nodep->width())) && isTPure(nodep->lhsp())); } bool operandHugeShiftR(const AstNodeBiop* nodep) { return (VN_IS(nodep->rhsp(), Const) - && !VN_CAST_CONST(nodep->rhsp(), Const)->num().isFourState() - && (VN_CAST_CONST(nodep->rhsp(), Const)->toUInt() + && !VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState() + && (VN_AS_CONST(nodep->rhsp(), Const)->toUInt() >= static_cast(nodep->lhsp()->width())) && isTPure(nodep->lhsp())); } bool operandIsTwo(const AstNode* nodep) { - return (VN_IS(nodep, Const) && !VN_CAST_CONST(nodep, Const)->num().isFourState() - && nodep->width() <= VL_QUADSIZE && VN_CAST_CONST(nodep, Const)->toUQuad() == 2); + return (VN_IS(nodep, Const) && !VN_AS_CONST(nodep, Const)->num().isFourState() + && nodep->width() <= VL_QUADSIZE && VN_AS_CONST(nodep, Const)->toUQuad() == 2); } bool operandIsTwostate(const AstNode* nodep) { - return (VN_IS(nodep, Const) && !VN_CAST_CONST(nodep, Const)->num().isFourState()); + return (VN_IS(nodep, Const) && !VN_AS_CONST(nodep, Const)->num().isFourState()); } bool operandIsPowTwo(const AstNode* nodep) { if (!operandIsTwostate(nodep)) return false; - return (1 == VN_CAST_CONST(nodep, Const)->num().countOnes()); + return (1 == VN_AS_CONST(nodep, Const)->num().countOnes()); } bool operandShiftOp(const AstNodeBiop* nodep) { if (!VN_IS(nodep->rhsp(), Const)) return false; @@ -1181,8 +1181,8 @@ private: // We can only get rid of a<>c or a<rhsp(), Const) && VN_IS(lhsp->rhsp(), Const))) return false; - if (VN_CAST_CONST(nodep->rhsp(), Const)->num().isFourState() - || VN_CAST_CONST(lhsp->rhsp(), Const)->num().isFourState()) + if (VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState() + || VN_AS_CONST(lhsp->rhsp(), Const)->num().isFourState()) return false; if (nodep->width() != lhsp->width()) return false; if (nodep->width() != lhsp->lhsp()->width()) return false; @@ -1193,9 +1193,9 @@ private: // It was an expression, then got constified. In reality, the WordSel // must be wrapped in a Cond, that will be false. return (VN_IS(nodep->rhsp(), Const) && VN_IS(nodep->fromp(), NodeVarRef) - && VN_CAST_CONST(nodep->fromp(), NodeVarRef)->access().isReadOnly() - && (static_cast(VN_CAST_CONST(nodep->rhsp(), Const)->toUInt()) - >= VN_CAST(nodep->fromp(), NodeVarRef)->varp()->widthWords())); + && VN_AS_CONST(nodep->fromp(), NodeVarRef)->access().isReadOnly() + && (static_cast(VN_AS_CONST(nodep->rhsp(), Const)->toUInt()) + >= VN_AS(nodep->fromp(), NodeVarRef)->varp()->widthWords())); } bool operandSelFull(const AstSel* nodep) { return (VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) @@ -1240,8 +1240,8 @@ private: return false; } AstNode* ap = shiftp->lhsp(); - AstConst* bp = VN_CAST(shiftp->rhsp(), Const); - AstConst* lp = VN_CAST(nodep->lsbp(), Const); + AstConst* bp = VN_AS(shiftp->rhsp(), Const); + AstConst* lp = VN_AS(nodep->lsbp(), Const); if (bp->isWide() || bp->num().isFourState() || bp->num().isNegative() || lp->isWide() || lp->num().isFourState() || lp->num().isNegative()) { return false; @@ -1336,8 +1336,8 @@ private: if (m_warn && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && doit) { const int maxDeclBit = nodep->declRange().hiMaxSelect() * nodep->declElWidth() + (nodep->declElWidth() - 1); - if (VN_CAST(nodep->lsbp(), Const)->num().isFourState() - || VN_CAST(nodep->widthp(), Const)->num().isFourState()) { + if (VN_AS(nodep->lsbp(), Const)->num().isFourState() + || VN_AS(nodep->widthp(), Const)->num().isFourState()) { nodep->v3error("Selection index is constantly unknown or tristated: " "lsb=" << nodep->lsbp()->name() << " width=" << nodep->widthp()->name()); @@ -1491,7 +1491,7 @@ private: void replaceNum(AstNode* oldp, const V3Number& num) { // Replace oldp node with a constant set to specified value UASSERT(oldp, "Null old"); - UASSERT_OBJ(!(VN_IS(oldp, Const) && !VN_CAST(oldp, Const)->num().isFourState()), oldp, + UASSERT_OBJ(!(VN_IS(oldp, Const) && !VN_AS(oldp, Const)->num().isFourState()), oldp, "Already constant??"); AstNode* newp = new AstConst(oldp->fileline(), num); newp->dtypeFrom(oldp); @@ -1539,30 +1539,30 @@ private: } void replaceConst(AstNodeUniop* nodep) { V3Number num(nodep, nodep->width()); - nodep->numberOperate(num, VN_CAST(nodep->lhsp(), Const)->num()); + nodep->numberOperate(num, VN_AS(nodep->lhsp(), Const)->num()); UINFO(4, "UNICONST -> " << num << endl); VL_DO_DANGLING(replaceNum(nodep, num), nodep); } void replaceConst(AstNodeBiop* nodep) { V3Number num(nodep, nodep->width()); - nodep->numberOperate(num, VN_CAST(nodep->lhsp(), Const)->num(), - VN_CAST(nodep->rhsp(), Const)->num()); + nodep->numberOperate(num, VN_AS(nodep->lhsp(), Const)->num(), + VN_AS(nodep->rhsp(), Const)->num()); UINFO(4, "BICONST -> " << num << endl); VL_DO_DANGLING(replaceNum(nodep, num), nodep); } void replaceConst(AstNodeTriop* nodep) { V3Number num(nodep, nodep->width()); - nodep->numberOperate(num, VN_CAST(nodep->lhsp(), Const)->num(), - VN_CAST(nodep->rhsp(), Const)->num(), - VN_CAST(nodep->thsp(), Const)->num()); + nodep->numberOperate(num, VN_AS(nodep->lhsp(), Const)->num(), + VN_AS(nodep->rhsp(), Const)->num(), + VN_AS(nodep->thsp(), Const)->num()); UINFO(4, "TRICONST -> " << num << endl); VL_DO_DANGLING(replaceNum(nodep, num), nodep); } void replaceConst(AstNodeQuadop* nodep) { V3Number num(nodep, nodep->width()); nodep->numberOperate( - num, VN_CAST(nodep->lhsp(), Const)->num(), VN_CAST(nodep->rhsp(), Const)->num(), - VN_CAST(nodep->thsp(), Const)->num(), VN_CAST(nodep->fhsp(), Const)->num()); + num, VN_AS(nodep->lhsp(), Const)->num(), VN_AS(nodep->rhsp(), Const)->num(), + VN_AS(nodep->thsp(), Const)->num(), VN_AS(nodep->fhsp(), Const)->num()); UINFO(4, "QUADCONST -> " << num << endl); VL_DO_DANGLING(replaceNum(nodep, num), nodep); } @@ -1620,7 +1620,7 @@ private: // BIASV(SAMEa, BIASV(SAMEb, c)) -> BIASV( BIASV(SAMEa,SAMEb), c) // nodep->dumpTree(cout, " repAsvConst_old: "); AstNode* ap = nodep->lhsp(); - AstNodeBiop* rp = VN_CAST(nodep->rhsp(), NodeBiop); + AstNodeBiop* rp = VN_AS(nodep->rhsp(), NodeBiop); AstNode* bp = rp->lhsp(); AstNode* cp = rp->rhsp(); ap->unlinkFrBack(); @@ -1636,7 +1636,7 @@ private: } void replaceAsvLUp(AstNodeBiop* nodep) { // BIASV(BIASV(CONSTll,lr),r) -> BIASV(CONSTll,BIASV(lr,r)) - AstNodeBiop* lp = VN_CAST(nodep->lhsp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); AstNode* llp = lp->lhsp()->unlinkFrBack(); AstNode* lrp = lp->rhsp()->unlinkFrBack(); AstNode* rp = nodep->rhsp()->unlinkFrBack(); @@ -1649,7 +1649,7 @@ private: void replaceAsvRUp(AstNodeBiop* nodep) { // BIASV(l,BIASV(CONSTrl,rr)) -> BIASV(CONSTrl,BIASV(l,rr)) AstNode* lp = nodep->lhsp()->unlinkFrBack(); - AstNodeBiop* rp = VN_CAST(nodep->rhsp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); AstNode* rlp = rp->lhsp()->unlinkFrBack(); AstNode* rrp = rp->rhsp()->unlinkFrBack(); nodep->lhsp(rlp); @@ -1663,10 +1663,10 @@ private: // OR (AND (CONSTll,lr), AND(CONSTrl, rr=lr)) -> AND (OR(ll,rl), rr) // nodep ^lp ^llp ^lrp ^rp ^rlp ^rrp // (Or/And may also be reversed) - AstNodeBiop* lp = VN_CAST(nodep->lhsp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); AstNode* llp = lp->lhsp()->unlinkFrBack(); AstNode* lrp = lp->rhsp()->unlinkFrBack(); - AstNodeBiop* rp = VN_CAST(nodep->rhsp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); AstNode* rlp = rp->lhsp()->unlinkFrBack(); AstNode* rrp = rp->rhsp()->unlinkFrBack(); nodep->replaceWith(lp); @@ -1692,10 +1692,10 @@ private: void replaceShiftSame(AstNodeBiop* nodep) { // Or(Shift(ll,CONSTlr),Shift(rl,CONSTrr==lr)) -> Shift(Or(ll,rl),CONSTlr) // (Or/And may also be reversed) - AstNodeBiop* lp = VN_CAST(nodep->lhsp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); AstNode* llp = lp->lhsp()->unlinkFrBack(); AstNode* lrp = lp->rhsp()->unlinkFrBack(); - AstNodeBiop* rp = VN_CAST(nodep->rhsp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); AstNode* rlp = rp->lhsp()->unlinkFrBack(); AstNode* rrp = rp->rhsp()->unlinkFrBack(); nodep->replaceWith(lp); @@ -1709,8 +1709,8 @@ private: } void replaceConcatSel(AstConcat* nodep) { // {a[1], a[0]} -> a[1:0] - AstSel* lselp = VN_CAST(nodep->lhsp()->unlinkFrBack(), Sel); - AstSel* rselp = VN_CAST(nodep->rhsp()->unlinkFrBack(), Sel); + AstSel* lselp = VN_AS(nodep->lhsp()->unlinkFrBack(), Sel); + AstSel* rselp = VN_AS(nodep->rhsp()->unlinkFrBack(), Sel); const int lstart = lselp->lsbConst(); const int lwidth = lselp->widthConst(); const int rstart = rselp->lsbConst(); @@ -1729,8 +1729,8 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } void replaceConcatMerge(AstConcat* nodep) { - AstNodeBiop* lp = VN_CAST(nodep->lhsp(), NodeBiop); - AstNodeBiop* rp = VN_CAST(nodep->rhsp(), NodeBiop); + AstNodeBiop* lp = VN_AS(nodep->lhsp(), NodeBiop); + AstNodeBiop* rp = VN_AS(nodep->rhsp(), NodeBiop); AstNode* llp = lp->lhsp()->cloneTree(false); AstNode* lrp = lp->rhsp()->cloneTree(false); AstNode* rlp = rp->lhsp()->cloneTree(false); @@ -1776,7 +1776,7 @@ private: } void replaceMulShift(AstMul* nodep) { // Mul, but not MulS as not simple shift UINFO(5, "MUL(2^n,b)->SHIFTL(b,n) " << nodep << endl); - const int amount = VN_CAST(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 + const int amount = VN_AS(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 AstNode* opp = nodep->rhsp()->unlinkFrBack(); AstShiftL* newp = new AstShiftL(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount)); @@ -1786,7 +1786,7 @@ private: } void replaceDivShift(AstDiv* nodep) { // Mul, but not MulS as not simple shift UINFO(5, "DIV(b,2^n)->SHIFTR(b,n) " << nodep << endl); - const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 + const int amount = VN_AS(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 AstNode* opp = nodep->lhsp()->unlinkFrBack(); AstShiftR* newp = new AstShiftR(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount)); @@ -1796,7 +1796,7 @@ private: } void replaceModAnd(AstModDiv* nodep) { // Mod, but not ModS as not simple shift UINFO(5, "MOD(b,2^n)->AND(b,2^n-1) " << nodep << endl); - const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 + const int amount = VN_AS(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 V3Number mask(nodep, nodep->width()); mask.setMask(amount); AstNode* opp = nodep->lhsp()->unlinkFrBack(); @@ -1809,7 +1809,7 @@ private: UINFO(5, "SHIFT(AND(a,b),CONST)->AND(SHIFT(a,CONST),SHIFT(b,CONST)) " << nodep << endl); AstNRelinker handle; nodep->unlinkFrBack(&handle); - AstNodeBiop* lhsp = VN_CAST(nodep->lhsp(), NodeBiop); + AstNodeBiop* lhsp = VN_AS(nodep->lhsp(), NodeBiop); lhsp->unlinkFrBack(); AstNode* shiftp = nodep->rhsp()->unlinkFrBack(); AstNode* ap = lhsp->lhsp()->unlinkFrBack(); @@ -1829,7 +1829,7 @@ private: void replaceShiftShift(AstNodeBiop* nodep) { UINFO(4, "SHIFT(SHIFT(a,s1),s2)->SHIFT(a,ADD(s1,s2)) " << nodep << endl); if (debug() >= 9) nodep->dumpTree(cout, " repShiftShift_old: "); - AstNodeBiop* lhsp = VN_CAST(nodep->lhsp(), NodeBiop); + AstNodeBiop* lhsp = VN_AS(nodep->lhsp(), NodeBiop); lhsp->unlinkFrBack(); AstNode* ap = lhsp->lhsp()->unlinkFrBack(); AstNode* shift1p = lhsp->rhsp()->unlinkFrBack(); @@ -1837,8 +1837,8 @@ private: // Shift1p and shift2p may have different sizes, both are // self-determined so sum with infinite width if (nodep->type() == lhsp->type()) { - int shift1 = VN_CAST(shift1p, Const)->toUInt(); - int shift2 = VN_CAST(shift2p, Const)->toUInt(); + int shift1 = VN_AS(shift1p, Const)->toUInt(); + int shift2 = VN_AS(shift2p, Const)->toUInt(); const int newshift = shift1 + shift2; VL_DO_DANGLING(shift1p->deleteTree(), shift1p); VL_DO_DANGLING(shift2p->deleteTree(), shift2p); @@ -1847,9 +1847,9 @@ private: iterate(nodep); // Further reduce, either node may have more reductions. } else { // We know shift amounts are constant, but might be a mixed left/right shift - int shift1 = VN_CAST(shift1p, Const)->toUInt(); + int shift1 = VN_AS(shift1p, Const)->toUInt(); if (VN_IS(lhsp, ShiftR)) shift1 = -shift1; - int shift2 = VN_CAST(shift2p, Const)->toUInt(); + int shift2 = VN_AS(shift2p, Const)->toUInt(); if (VN_IS(nodep, ShiftR)) shift2 = -shift2; const int newshift = shift1 + shift2; VL_DO_DANGLING(shift1p->deleteTree(), shift1p); @@ -1949,7 +1949,7 @@ private: if (!nodep) return true; if (level > 2) return false; if (!nodep->isPure()) return false; // For example a $fgetc can't be reordered - if (VN_IS(nodep, NodeVarRef) && VN_CAST(nodep, NodeVarRef)->varp() == varp) return false; + if (VN_IS(nodep, NodeVarRef) && VN_AS(nodep, NodeVarRef)->varp() == varp) return false; return (varNotReferenced(nodep->nextp(), varp, level + 1) && varNotReferenced(nodep->op1p(), varp, level + 1) && varNotReferenced(nodep->op2p(), varp, level + 1) @@ -1959,7 +1959,7 @@ private: bool replaceNodeAssign(AstNodeAssign* nodep) { if (VN_IS(nodep->lhsp(), VarRef) && VN_IS(nodep->rhsp(), VarRef) - && VN_CAST(nodep->lhsp(), VarRef)->sameNoLvalue(VN_CAST(nodep->rhsp(), VarRef)) + && VN_AS(nodep->lhsp(), VarRef)->sameNoLvalue(VN_AS(nodep->rhsp(), VarRef)) && !VN_IS(nodep, AssignDly)) { // X = X. Quite pointless, though X <= X may override another earlier assignment if (VN_IS(nodep, AssignW)) { @@ -1994,9 +1994,9 @@ private: } if (debug() >= 9) nodep->dumpTree(cout, " Ass_old: "); // Unlink the stuff - AstNode* lc1p = VN_CAST(nodep->lhsp(), Concat)->lhsp()->unlinkFrBack(); - AstNode* lc2p = VN_CAST(nodep->lhsp(), Concat)->rhsp()->unlinkFrBack(); - AstNode* conp = VN_CAST(nodep->lhsp(), Concat)->unlinkFrBack(); + AstNode* lc1p = VN_AS(nodep->lhsp(), Concat)->lhsp()->unlinkFrBack(); + AstNode* lc2p = VN_AS(nodep->lhsp(), Concat)->rhsp()->unlinkFrBack(); + AstNode* conp = VN_AS(nodep->lhsp(), Concat)->unlinkFrBack(); AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* rhs2p = rhsp->cloneTree(false); // Calc widths @@ -2012,8 +2012,8 @@ private: //*** Not cloneTree; just one node. AstNode* newp = nullptr; if (!need_temp) { - AstNodeAssign* asn1ap = VN_CAST(nodep->cloneType(lc1p, sel1p), NodeAssign); - AstNodeAssign* asn2ap = VN_CAST(nodep->cloneType(lc2p, sel2p), NodeAssign); + AstNodeAssign* asn1ap = VN_AS(nodep->cloneType(lc1p, sel1p), NodeAssign); + AstNodeAssign* asn2ap = VN_AS(nodep->cloneType(lc2p, sel2p), NodeAssign); asn1ap->dtypeFrom(sel1p); asn2ap->dtypeFrom(sel2p); newp = AstNode::addNext(newp, asn1ap); @@ -2033,21 +2033,21 @@ private: m_modp->addStmtp(temp1p); m_modp->addStmtp(temp2p); AstNodeAssign* asn1ap - = VN_CAST(nodep->cloneType( - new AstVarRef(sel1p->fileline(), temp1p, VAccess::WRITE), sel1p), - NodeAssign); + = VN_AS(nodep->cloneType( + new AstVarRef(sel1p->fileline(), temp1p, VAccess::WRITE), sel1p), + NodeAssign); AstNodeAssign* asn2ap - = VN_CAST(nodep->cloneType( - new AstVarRef(sel2p->fileline(), temp2p, VAccess::WRITE), sel2p), - NodeAssign); + = VN_AS(nodep->cloneType( + new AstVarRef(sel2p->fileline(), temp2p, VAccess::WRITE), sel2p), + NodeAssign); AstNodeAssign* asn1bp - = VN_CAST(nodep->cloneType( - lc1p, new AstVarRef(sel1p->fileline(), temp1p, VAccess::READ)), - NodeAssign); + = VN_AS(nodep->cloneType( + lc1p, new AstVarRef(sel1p->fileline(), temp1p, VAccess::READ)), + NodeAssign); AstNodeAssign* asn2bp - = VN_CAST(nodep->cloneType( - lc2p, new AstVarRef(sel2p->fileline(), temp2p, VAccess::READ)), - NodeAssign); + = VN_AS(nodep->cloneType( + lc2p, new AstVarRef(sel2p->fileline(), temp2p, VAccess::READ)), + NodeAssign); asn1ap->dtypeFrom(temp1p); asn1bp->dtypeFrom(temp1p); asn2ap->dtypeFrom(temp2p); @@ -2069,9 +2069,9 @@ private: // The right-streaming operator on rhs of assignment does not // change the order of bits. Eliminate stream but keep its lhsp // Unlink the stuff - AstNode* srcp = VN_CAST(nodep->rhsp(), StreamR)->lhsp()->unlinkFrBack(); - AstNode* sizep = VN_CAST(nodep->rhsp(), StreamR)->rhsp()->unlinkFrBack(); - AstNode* streamp = VN_CAST(nodep->rhsp(), StreamR)->unlinkFrBack(); + AstNode* srcp = VN_AS(nodep->rhsp(), StreamR)->lhsp()->unlinkFrBack(); + AstNode* sizep = VN_AS(nodep->rhsp(), StreamR)->rhsp()->unlinkFrBack(); + AstNode* streamp = VN_AS(nodep->rhsp(), StreamR)->unlinkFrBack(); nodep->rhsp(srcp); // Cleanup VL_DO_DANGLING(sizep->deleteTree(), sizep); @@ -2080,14 +2080,14 @@ private: return true; } else if (m_doV && VN_IS(nodep->lhsp(), StreamL)) { // Push the stream operator to the rhs of the assignment statement - const int dWidth = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->width(); + const int dWidth = VN_AS(nodep->lhsp(), StreamL)->lhsp()->width(); const int sWidth = nodep->rhsp()->width(); // Unlink the stuff - AstNode* dstp = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack(); - AstNode* streamp = VN_CAST(nodep->lhsp(), StreamL)->unlinkFrBack(); + AstNode* dstp = VN_AS(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack(); + AstNode* streamp = VN_AS(nodep->lhsp(), StreamL)->unlinkFrBack(); AstNode* srcp = nodep->rhsp()->unlinkFrBack(); // Connect the rhs to the stream operator and update its width - VN_CAST(streamp, StreamL)->lhsp(srcp); + VN_AS(streamp, StreamL)->lhsp(srcp); streamp->dtypeSetLogicUnsized(srcp->width(), srcp->widthMin(), VSigning::UNSIGNED); // Shrink the RHS if necessary if (sWidth > dWidth) { @@ -2101,12 +2101,12 @@ private: // The right stream operator on lhs of assignment statement does // not reorder bits. However, if the rhs is wider than the lhs, // then we select bits from the left-most, not the right-most. - const int dWidth = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->width(); + const int dWidth = VN_AS(nodep->lhsp(), StreamR)->lhsp()->width(); const int sWidth = nodep->rhsp()->width(); // Unlink the stuff - AstNode* dstp = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack(); - AstNode* sizep = VN_CAST(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack(); - AstNode* streamp = VN_CAST(nodep->lhsp(), StreamR)->unlinkFrBack(); + AstNode* dstp = VN_AS(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack(); + AstNode* sizep = VN_AS(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack(); + AstNode* streamp = VN_AS(nodep->lhsp(), StreamR)->unlinkFrBack(); AstNode* srcp = nodep->rhsp()->unlinkFrBack(); if (sWidth > dWidth) { srcp = new AstSel(streamp->fileline(), srcp, sWidth - dWidth, dWidth); @@ -2128,22 +2128,21 @@ private: bool operandBoolShift(const AstNode* nodep) { // boolean test of AND(const,SHIFTR(x,const)) -> test of AND(SHIFTL(x,const), x) if (!VN_IS(nodep, And)) return false; - if (!VN_IS(VN_CAST_CONST(nodep, And)->lhsp(), Const)) return false; - if (!VN_IS(VN_CAST_CONST(nodep, And)->rhsp(), ShiftR)) return false; - const AstShiftR* shiftp = VN_CAST(VN_CAST_CONST(nodep, And)->rhsp(), ShiftR); + if (!VN_IS(VN_AS_CONST(nodep, And)->lhsp(), Const)) return false; + if (!VN_IS(VN_AS_CONST(nodep, And)->rhsp(), ShiftR)) return false; + const AstShiftR* shiftp = VN_AS(VN_AS_CONST(nodep, And)->rhsp(), ShiftR); if (!VN_IS(shiftp->rhsp(), Const)) return false; if (static_cast(nodep->width()) - <= VN_CAST_CONST(shiftp->rhsp(), Const)->toUInt()) { + <= VN_AS_CONST(shiftp->rhsp(), Const)->toUInt()) { return false; } return true; } void replaceBoolShift(AstNode* nodep) { if (debug() >= 9) nodep->dumpTree(cout, " bshft_old: "); - AstConst* andConstp = VN_CAST(VN_CAST(nodep, And)->lhsp(), Const); - AstNode* fromp = VN_CAST(VN_CAST(nodep, And)->rhsp(), ShiftR)->lhsp()->unlinkFrBack(); - AstConst* shiftConstp - = VN_CAST(VN_CAST(VN_CAST(nodep, And)->rhsp(), ShiftR)->rhsp(), Const); + AstConst* andConstp = VN_AS(VN_AS(nodep, And)->lhsp(), Const); + AstNode* fromp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->lhsp()->unlinkFrBack(); + AstConst* shiftConstp = VN_AS(VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->rhsp(), Const); V3Number val(andConstp, andConstp->width()); val.opShiftL(andConstp->num(), shiftConstp->num()); AstAnd* newp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), val), fromp); @@ -2252,7 +2251,7 @@ private: UINFO(4, "Move concat: " << nodep << endl); if (operandConcatMove(nodep) > 1) { AstNode* ap = nodep->lhsp()->unlinkFrBack(); - AstConcat* bcConcp = VN_CAST(nodep->rhsp(), Concat); + AstConcat* bcConcp = VN_AS(nodep->rhsp(), Concat); bcConcp->unlinkFrBack(); AstNode* bp = bcConcp->lhsp()->unlinkFrBack(); AstNode* cp = bcConcp->rhsp()->unlinkFrBack(); @@ -2264,7 +2263,7 @@ private: if (operandConcatMove(abConcp)) moveConcat(abConcp); VL_DO_DANGLING(bcConcp->deleteTree(), bcConcp); } else { - AstConcat* abConcp = VN_CAST(nodep->lhsp(), Concat); + AstConcat* abConcp = VN_AS(nodep->lhsp(), Concat); abConcp->unlinkFrBack(); AstNode* ap = abConcp->lhsp()->unlinkFrBack(); AstNode* bp = abConcp->rhsp()->unlinkFrBack(); @@ -2307,7 +2306,7 @@ private: void replaceSelSel(AstSel* nodep) { // SEL(SEL({x},a,b),c,d) => SEL({x},a+c,d) - AstSel* belowp = VN_CAST(nodep->fromp(), Sel); + AstSel* belowp = VN_AS(nodep->fromp(), Sel); AstNode* fromp = belowp->fromp()->unlinkFrBack(); AstNode* widthp = nodep->widthp()->unlinkFrBack(); AstNode* lsb1p = nodep->lsbp()->unlinkFrBack(); @@ -2316,8 +2315,8 @@ private: UINFO(4, "Elim Lower range: " << nodep << endl); AstNode* newlsbp; if (VN_IS(lsb1p, Const) && VN_IS(lsb2p, Const)) { - newlsbp = new AstConst(lsb1p->fileline(), VN_CAST(lsb1p, Const)->toUInt() - + VN_CAST(lsb2p, Const)->toUInt()); + newlsbp = new AstConst(lsb1p->fileline(), + VN_AS(lsb1p, Const)->toUInt() + VN_AS(lsb2p, Const)->toUInt()); VL_DO_DANGLING(lsb1p->deleteTree(), lsb1p); VL_DO_DANGLING(lsb2p->deleteTree(), lsb2p); } else { @@ -2326,7 +2325,7 @@ private: newlsbp = new AstAdd(lsb1p->fileline(), lsb2p, new AstExtend(lsb1p->fileline(), lsb1p)); newlsbp->dtypeFrom(lsb2p); // Unsigned - VN_CAST(newlsbp, Add)->rhsp()->dtypeFrom(lsb2p); + VN_AS(newlsbp, Add)->rhsp()->dtypeFrom(lsb2p); } AstSel* newp = new AstSel(nodep->fileline(), fromp, newlsbp, widthp); nodep->replaceWith(newp); @@ -2335,7 +2334,7 @@ private: void replaceSelConcat(AstSel* nodep) { // SEL(CONCAT(a,b),c,d) => SEL(a or b, . .) - AstConcat* conp = VN_CAST(nodep->fromp(), Concat); + AstConcat* conp = VN_AS(nodep->fromp(), Concat); AstNode* conLhsp = conp->lhsp(); AstNode* conRhsp = conp->rhsp(); if (static_cast(nodep->lsbConst()) >= conRhsp->width()) { @@ -2365,7 +2364,7 @@ private: bool operandSelReplicate(AstSel* nodep) { // SEL(REPLICATE(from,rep),lsb,width) => SEL(from,0,width) as long // as SEL's width <= b's width - AstReplicate* repp = VN_CAST(nodep->fromp(), Replicate); + AstReplicate* repp = VN_AS(nodep->fromp(), Replicate); AstNode* fromp = repp->lhsp(); AstConst* lsbp = VN_CAST(nodep->lsbp(), Const); if (!lsbp) return false; @@ -2389,7 +2388,7 @@ private: } bool operandRepRep(AstReplicate* nodep) { // REPLICATE(REPLICATE2(from2,cnt2),cnt1) => REPLICATE(from2,(cnt1+cnt2)) - AstReplicate* rep2p = VN_CAST(nodep->lhsp(), Replicate); + AstReplicate* rep2p = VN_AS(nodep->lhsp(), Replicate); AstNode* from2p = rep2p->lhsp(); AstConst* cnt1p = VN_CAST(nodep->rhsp(), Const); if (!cnt1p) return false; @@ -2418,13 +2417,13 @@ private: if (VN_IS(from1p, Replicate)) { AstConst* cnt1p = VN_CAST(VN_CAST(from1p, Replicate)->rhsp(), Const); if (!cnt1p) return false; - from1p = VN_CAST(from1p, Replicate)->lhsp(); + from1p = VN_AS(from1p, Replicate)->lhsp(); cnt1 = cnt1p->toUInt(); } if (VN_IS(from2p, Replicate)) { AstConst* cnt2p = VN_CAST(VN_CAST(from2p, Replicate)->rhsp(), Const); if (!cnt2p) return false; - from2p = VN_CAST(from2p, Replicate)->lhsp(); + from2p = VN_AS(from2p, Replicate)->lhsp(); cnt2 = cnt2p->toUInt(); } if (!operandsSame(from1p, from2p)) return false; @@ -2438,7 +2437,7 @@ private: } void replaceSelIntoBiop(AstSel* nodep) { // SEL(BUFIF1(a,b),1,bit) => BUFIF1(SEL(a,1,bit),SEL(b,1,bit)) - AstNodeBiop* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeBiop); UASSERT_OBJ(fromp, nodep, "Called on non biop"); AstNode* lsbp = nodep->lsbp()->unlinkFrBack(); AstNode* widthp = nodep->widthp()->unlinkFrBack(); @@ -2455,7 +2454,7 @@ private: } void replaceSelIntoUniop(AstSel* nodep) { // SEL(NOT(a),1,bit) => NOT(SEL(a,bit)) - AstNodeUniop* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), NodeUniop); + AstNodeUniop* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeUniop); UASSERT_OBJ(fromp, nodep, "Called on non biop"); AstNode* lsbp = nodep->lsbp()->unlinkFrBack(); AstNode* widthp = nodep->widthp()->unlinkFrBack(); @@ -2481,8 +2480,8 @@ private: if (VN_IS(nodep->bitp(), Const) && VN_IS(nodep->fromp(), VarRef) // Need to make sure it's an array object so don't mis-allow a constant (bug509.) - && VN_CAST(nodep->fromp(), VarRef)->varp() - && VN_IS(VN_CAST(nodep->fromp(), VarRef)->varp()->valuep(), InitArray)) { + && VN_AS(nodep->fromp(), VarRef)->varp() + && VN_IS(VN_AS(nodep->fromp(), VarRef)->varp()->valuep(), InitArray)) { m_selp = nodep; // Ask visit(AstVarRef) to replace varref with const } iterateAndNextNull(nodep->fromp()); @@ -2495,7 +2494,7 @@ private: if (VN_IS(fromp->dtypep()->skipRefp(), NodeArrayDType)) { // Strip off array to find what array references fromp->dtypeFrom( - VN_CAST(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep()); + VN_AS(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep()); } VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -2520,16 +2519,16 @@ private: && !nodep->varp()->noSubst() && !nodep->varp()->isSigPublic()) || nodep->varp()->isParam())) { if (operandConst(valuep)) { - const V3Number& num = VN_CAST(valuep, Const)->num(); + const V3Number& num = VN_AS(valuep, Const)->num(); // UINFO(2,"constVisit "<bitConst(); AstNode* itemp = initarp->getIndexDefaultedValuep(bit); if (VN_IS(itemp, Const)) { - const V3Number& num = VN_CAST(itemp, Const)->num(); + const V3Number& num = VN_AS(itemp, Const)->num(); // UINFO(2,"constVisit "<lhsp(); + lastSensp = VN_AS(lastSensp, Not)->lhsp(); invert = !invert; } UINFO(8, "senItem(NOT...) " << nodep << " " << invert << endl); if (invert) nodep->edgeType(nodep->edgeType().invert()); - AstNodeVarRef* senvarp = VN_CAST(lastSensp->unlinkFrBack(), NodeVarRef); + AstNodeVarRef* senvarp = VN_AS(lastSensp->unlinkFrBack(), NodeVarRef); UASSERT_OBJ(senvarp, sensp, "Non-varref sensitivity variable"); sensp->replaceWith(senvarp); VL_DO_DANGLING(sensp->deleteTree(), sensp); @@ -2672,8 +2671,8 @@ private: { AstUser4InUse m_inuse4; // Mark x in SENITEM(x) - for (AstSenItem* senp = VN_CAST(nodep->sensesp(), SenItem); senp; - senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = VN_AS(nodep->sensesp(), SenItem); senp; + senp = VN_AS(senp->nextp(), SenItem)) { if (senp->varrefp() && senp->varrefp()->varScopep()) { senp->varrefp()->varScopep()->user4(1); } @@ -2683,17 +2682,16 @@ private: // Sort the sensitivity names so "posedge a or b" and "posedge b or a" end up together. // Also, remove duplicate assignments, and fold POS&NEGs into ANYEDGEs // Make things a little faster; check first if we need a sort - for (AstSenItem *nextp, *senp = VN_CAST(nodep->sensesp(), SenItem); senp; - senp = nextp) { - nextp = VN_CAST(senp->nextp(), SenItem); + for (AstSenItem *nextp, *senp = VN_AS(nodep->sensesp(), SenItem); senp; senp = nextp) { + nextp = VN_AS(senp->nextp(), SenItem); // cppcheck-suppress unassignedVariable // cppcheck bug SenItemCmp cmp; if (nextp && !cmp(senp, nextp)) { // Something's out of order, sort it senp = nullptr; std::vector vec; - for (AstSenItem* senp = VN_CAST(nodep->sensesp(), SenItem); senp; - senp = VN_CAST(senp->nextp(), SenItem)) { + for (AstSenItem* senp = VN_AS(nodep->sensesp(), SenItem); senp; + senp = VN_AS(senp->nextp(), SenItem)) { vec.push_back(senp); } stable_sort(vec.begin(), vec.end(), SenItemCmp()); @@ -2704,9 +2702,8 @@ private: } // Pass2, remove dup edges - for (AstSenItem *nextp, *senp = VN_CAST(nodep->sensesp(), SenItem); senp; - senp = nextp) { - nextp = VN_CAST(senp->nextp(), SenItem); + for (AstSenItem *nextp, *senp = VN_AS(nodep->sensesp(), SenItem); senp; senp = nextp) { + nextp = VN_AS(senp->nextp(), SenItem); AstSenItem* const litemp = senp; AstSenItem* const ritemp = nextp; if (ritemp) { @@ -2759,7 +2756,7 @@ private: nodep->lhsp(), VarRef); // Not VarXRef, as different refs may set different values to each hierarchy if (m_wremove && !m_params && m_doNConst && m_modp && operandConst(nodep->rhsp()) - && !VN_CAST(nodep->rhsp(), Const)->num().isFourState() + && !VN_AS(nodep->rhsp(), Const)->num().isFourState() && varrefp // Don't do messes with BITREFs/ARRAYREFs && !varrefp->varp()->valuep() // Not already constified && !varrefp->varScopep()) { // Not scoped (or each scope may have different initial @@ -2825,8 +2822,7 @@ private: || VN_IS(nodep->condp(), LogNot)) && nodep->ifsp() && nodep->elsesp()) { UINFO(4, "IF(NOT {x}) => IF(x) swapped if/else" << nodep << endl); - AstNode* condp - = VN_CAST(nodep->condp(), NodeUniop)->lhsp()->unlinkFrBackWithNext(); + AstNode* condp = VN_AS(nodep->condp(), NodeUniop)->lhsp()->unlinkFrBackWithNext(); AstNode* ifsp = nodep->ifsp()->unlinkFrBackWithNext(); AstNode* elsesp = nodep->elsesp()->unlinkFrBackWithNext(); AstIf* ifp = new AstIf(nodep->fileline(), condp, elsesp, ifsp); @@ -2837,8 +2833,8 @@ private: UINFO( 4, "IF({a}) ASSIGN({b},{c}) else ASSIGN({b},{d}) => ASSIGN({b}, {a}?{c}:{d})\n"); - AstNodeAssign* ifp = VN_CAST(nodep->ifsp(), NodeAssign); - AstNodeAssign* elsep = VN_CAST(nodep->elsesp(), NodeAssign); + AstNodeAssign* ifp = VN_AS(nodep->ifsp(), NodeAssign); + AstNodeAssign* elsep = VN_AS(nodep->elsesp(), NodeAssign); ifp->unlinkFrBack(); AstNode* condp = nodep->condp()->unlinkFrBack(); AstNode* truep = ifp->rhsp()->unlinkFrBack(); @@ -2850,7 +2846,7 @@ private: // without due to short-circuiting && operandIfIf(nodep)) { UINFO(9, "IF({a}) IF({b}) => IF({a} && {b})" << endl); - AstNodeIf* lowerIfp = VN_CAST(nodep->ifsp(), NodeIf); + AstNodeIf* lowerIfp = VN_AS(nodep->ifsp(), NodeIf); AstNode* condp = nodep->condp()->unlinkFrBack(); AstNode* lowerIfsp = lowerIfp->ifsp()->unlinkFrBackWithNext(); AstNode* lowerCondp = lowerIfp->condp()->unlinkFrBackWithNext(); @@ -2957,8 +2953,7 @@ private: if (argp) { AstNode* nextp = argp->nextp(); if (VN_IS(argp, Const)) { // Convert it - const string out - = VN_CAST(argp, Const)->num().displayed(nodep, fmt); + const string out = VN_AS(argp, Const)->num().displayed(nodep, fmt); UINFO(9, " DispConst: " << fmt << " -> " << out << " for " << argp << endl); // fmt = out w/ replace % with %% as it must be literal. @@ -3237,7 +3232,7 @@ private: TREEOP1("AstLt {$lhsp.isAllOnes, $rhsp, $lhsp->width()==$rhsp->width()}", "replaceNumLimited(nodep,0)"); TREEOP1("AstGte {$lhsp.isAllOnes, $rhsp, $lhsp->width()==$rhsp->width()}", "replaceNumLimited(nodep,1)"); // Two level bubble pushing - TREEOP ("AstNot {$lhsp.castNot, $lhsp->width()==VN_CAST($lhsp,,Not)->lhsp()->width()}", "replaceWChild(nodep, $lhsp->op1p())"); // NOT(NOT(x))->x + TREEOP ("AstNot {$lhsp.castNot, $lhsp->width()==VN_AS($lhsp,,Not)->lhsp()->width()}", "replaceWChild(nodep, $lhsp->op1p())"); // NOT(NOT(x))->x TREEOP ("AstLogNot{$lhsp.castLogNot}", "replaceWChild(nodep, $lhsp->op1p())"); // LOGNOT(LOGNOT(x))->x TREEOPV("AstNot {$lhsp.castEqCase, $lhsp.width1}","AstNeqCase{$lhsp->op1p(),$lhsp->op2p()}"); TREEOP ("AstLogNot{$lhsp.castEqCase}", "AstNeqCase{$lhsp->op1p(),$lhsp->op2p()}"); @@ -3349,10 +3344,10 @@ private: TREEOPV("AstRedAnd{$lhsp.castConcat}", "AstAnd{AstRedAnd{$lhsp->castConcat()->lhsp()}, AstRedAnd{$lhsp->castConcat()->rhsp()}}"); // &{a,b} => {&a}&{&b} TREEOPV("AstRedOr {$lhsp.castConcat}", "AstOr {AstRedOr {$lhsp->castConcat()->lhsp()}, AstRedOr {$lhsp->castConcat()->rhsp()}}"); // |{a,b} => {|a}|{|b} TREEOPV("AstRedXor{$lhsp.castConcat}", "AstXor{AstRedXor{$lhsp->castConcat()->lhsp()}, AstRedXor{$lhsp->castConcat()->rhsp()}}"); // ^{a,b} => {^a}^{^b} - TREEOPV("AstRedAnd{$lhsp.castExtend, $lhsp->width() > VN_CAST($lhsp,,Extend)->lhsp()->width()}", "replaceZero(nodep)"); // &{0,...} => 0 Prevents compiler limited range error + TREEOPV("AstRedAnd{$lhsp.castExtend, $lhsp->width() > VN_AS($lhsp,,Extend)->lhsp()->width()}", "replaceZero(nodep)"); // &{0,...} => 0 Prevents compiler limited range error TREEOPV("AstRedOr {$lhsp.castExtend}", "AstRedOr {$lhsp->castExtend()->lhsp()}"); TREEOPV("AstRedXor{$lhsp.castExtend}", "AstRedXor{$lhsp->castExtend()->lhsp()}"); - TREEOP ("AstRedXor{$lhsp.castXor, VN_IS(VN_CAST($lhsp,,Xor)->lhsp(),,Const)}", "AstXor{AstRedXor{$lhsp->castXor()->lhsp()}, AstRedXor{$lhsp->castXor()->rhsp()}}"); // ^(const ^ a) => (^const)^(^a) + TREEOP ("AstRedXor{$lhsp.castXor, VN_IS(VN_AS($lhsp,,Xor)->lhsp(),,Const)}", "AstXor{AstRedXor{$lhsp->castXor()->lhsp()}, AstRedXor{$lhsp->castXor()->rhsp()}}"); // ^(const ^ a) => (^const)^(^a) TREEOPC("AstAnd {$lhsp.castConst, $rhsp.castRedXor, matchBitOpTree(nodep)}", "DONE"); TREEOPV("AstOneHot{$lhsp.width1}", "replaceWLhs(nodep)"); TREEOPV("AstOneHot0{$lhsp.width1}", "replaceNum(nodep,1)"); @@ -3365,7 +3360,7 @@ private: TREEOPV("AstConcat{operandConcatMove(nodep)}", "moveConcat(nodep)"); TREEOPV("AstConcat{$lhsp.isZero, $rhsp}", "replaceExtend(nodep, nodep->rhsp())"); // CONCAT(a[1],a[0]) -> a[1:0] - TREEOPV("AstConcat{$lhsp.castSel, $rhsp.castSel, ifAdjacentSel(VN_CAST($lhsp,,Sel),,VN_CAST($rhsp,,Sel))}", "replaceConcatSel(nodep)"); + TREEOPV("AstConcat{$lhsp.castSel, $rhsp.castSel, ifAdjacentSel(VN_AS($lhsp,,Sel),,VN_AS($rhsp,,Sel))}", "replaceConcatSel(nodep)"); TREEOPV("AstConcat{ifConcatMergeableBiop($lhsp), concatMergeable($lhsp,,$rhsp)}", "replaceConcatMerge(nodep)"); // Common two-level operations that can be simplified TREEOP ("AstAnd {$lhsp.castConst,matchAndCond(nodep)}", "DONE"); @@ -3382,8 +3377,8 @@ private: TREEOPC("AstXor {matchBitOpTree(nodep)}", "DONE"); // Note can't simplify a extend{extends}, extends{extend}, as the sign // bits end up in the wrong places - TREEOPV("AstExtend {$lhsp.castExtend}", "replaceExtend(nodep, VN_CAST(nodep->lhsp(), Extend)->lhsp())"); - TREEOPV("AstExtendS{$lhsp.castExtendS}", "replaceExtend(nodep, VN_CAST(nodep->lhsp(), ExtendS)->lhsp())"); + TREEOPV("AstExtend {$lhsp.castExtend}", "replaceExtend(nodep, VN_AS(nodep->lhsp(), Extend)->lhsp())"); + TREEOPV("AstExtendS{$lhsp.castExtendS}", "replaceExtend(nodep, VN_AS(nodep->lhsp(), ExtendS)->lhsp())"); TREEOPV("AstReplicate{$lhsp, $rhsp.isOne, $lhsp->width()==nodep->width()}", "replaceWLhs(nodep)"); // {1{lhs}}->lhs TREEOPV("AstReplicateN{$lhsp, $rhsp.isOne, $lhsp->width()==nodep->width()}", "replaceWLhs(nodep)"); // {1{lhs}}->lhs TREEOPV("AstReplicate{$lhsp.castReplicate, operandRepRep(nodep)}", "DONE"); // {2{3{lhs}}}->{6{lhs}} @@ -3417,7 +3412,7 @@ private: // Strings TREEOPA("AstPutcN{$lhsp.castConst, $rhsp.castConst, $thsp.castConst}", "replaceConst(nodep)"); TREEOPA("AstSubstrN{$lhsp.castConst, $rhsp.castConst, $thsp.castConst}", "replaceConst(nodep)"); - TREEOPA("AstCvtPackString{$lhsp.castConst}", "replaceConstString(nodep, VN_CAST(nodep->lhsp(), Const)->num().toString())"); + TREEOPA("AstCvtPackString{$lhsp.castConst}", "replaceConstString(nodep, VN_AS(nodep->lhsp(), Const)->num().toString())"); // Custom // Implied by AstIsUnbounded::numberOperate: V("AstIsUnbounded{$lhsp.castConst}", "replaceNum(nodep, 0)"); TREEOPV("AstIsUnbounded{$lhsp.castUnbounded}", "replaceNum(nodep, 1)"); diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 76dd38fd8..579931e38 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -352,7 +352,7 @@ private: } else if (AstStructDType* adtypep = VN_CAST(dtypep, StructDType)) { // For now it's packed, so similar to array for (AstMemberDType* itemp = adtypep->membersp(); itemp; - itemp = VN_CAST(itemp->nextp(), MemberDType)) { + itemp = VN_AS(itemp->nextp(), MemberDType)) { AstNodeDType* subtypep = itemp->subDTypep()->skipRefp(); const int index_code = itemp->lsb(); ToggleEnt newent(above.m_comment + string(".") + itemp->name(), @@ -387,7 +387,7 @@ private: // An else-if. When we iterate the if, use "elsif" marking const bool elsif = nodep->ifsp() && VN_IS(nodep->elsesp(), If) && !nodep->elsesp()->nextp(); - if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true); + if (elsif) VN_AS(nodep->elsesp(), If)->user1(true); const bool first_elsif = !nodep->user1() && elsif; const bool cont_elsif = nodep->user1() && elsif; const bool final_elsif = nodep->user1() && !elsif && nodep->elsesp(); diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index 8ceb3ccd5..0bab93685 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -64,7 +64,7 @@ private: // Note hashed will point to the original variable (what's // duplicated), not the covertoggle, but we need to get back to the // covertoggle which is immediately above, so: - AstCoverToggle* removep = VN_CAST(duporigp->backp(), CoverToggle); + AstCoverToggle* removep = VN_AS(duporigp->backp(), CoverToggle); UASSERT_OBJ(removep, nodep, "CoverageJoin duplicate of wrong type"); UINFO(8, " Orig " << nodep << " -->> " << nodep->incp()->declp() << endl); UINFO(8, " dup " << removep << " -->> " << removep->incp()->declp() << endl); diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index dafc1110c..78592c9ca 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -310,7 +310,7 @@ private: retry = false; AstNodeModule* nextmodp; for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp = nextmodp) { - nextmodp = VN_CAST(modp->nextp(), NodeModule); + nextmodp = VN_AS(modp->nextp(), NodeModule); if (modp->dead() || (modp->level() > 2 && modp->user1() == 0 && !modp->internal())) { // > 2 because L1 is the wrapper, L2 is the top user module @@ -418,7 +418,7 @@ private: if ((classp = VN_CAST((*it), NodeUOrStructDType))) { bool cont = true; for (AstMemberDType* memberp = classp->membersp(); memberp; - memberp = VN_CAST(memberp->nextp(), MemberDType)) { + memberp = VN_AS(memberp->nextp(), MemberDType)) { if (memberp->user1() != 0) { cont = false; break; diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 7b4c0f88b..d14010105 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -206,10 +206,10 @@ private: AstSel* bitselp = nullptr; AstArraySel* arrayselp = nullptr; if (VN_IS(lhsp, Sel)) { - bitselp = VN_CAST(lhsp, Sel); - arrayselp = VN_CAST(bitselp->fromp(), ArraySel); + bitselp = VN_AS(lhsp, Sel); + arrayselp = VN_AS(bitselp->fromp(), ArraySel); } else { - arrayselp = VN_CAST(lhsp, ArraySel); + arrayselp = VN_AS(lhsp, ArraySel); } UASSERT_OBJ(arrayselp, nodep, "No arraysel under bitsel?"); UASSERT_OBJ(!VN_IS(arrayselp->dtypep()->skipRefp(), UnpackArrayDType), nodep, @@ -219,11 +219,11 @@ private: //=== Dimensions: __Vdlyvdim__ std::deque dimvalp; // Assignment value for each dimension of assignment AstNode* dimselp = arrayselp; - for (; VN_IS(dimselp, ArraySel); dimselp = VN_CAST(dimselp, ArraySel)->fromp()) { - AstNode* valp = VN_CAST(dimselp, ArraySel)->bitp()->unlinkFrBack(); + for (; VN_IS(dimselp, ArraySel); dimselp = VN_AS(dimselp, ArraySel)->fromp()) { + AstNode* valp = VN_AS(dimselp, ArraySel)->bitp()->unlinkFrBack(); dimvalp.push_front(valp); } - AstVarRef* varrefp = VN_CAST(dimselp, VarRef); + AstVarRef* varrefp = VN_AS(dimselp, VarRef); UASSERT_OBJ(varrefp, nodep, "No var underneath arraysels"); UASSERT_OBJ(varrefp->varScopep(), varrefp, "Var didn't get varscoped in V3Scope.cpp"); varrefp->unlinkFrBack(); @@ -291,7 +291,7 @@ private: // then we told this nodep->user3 we can use its Vdlyvset rather than making a new one. // This is good for code like: // for (i=0; i<5; i++) vector[i] <= something; - setvscp = VN_CAST(nodep->user3p(), VarScope); + setvscp = VN_AS(nodep->user3p(), VarScope); ++m_statSharedSet; } else { // Create new one string setvarname @@ -325,9 +325,9 @@ private: // Build "IF (changeit) ... UINFO(9, " For " << setvscp << endl); UINFO(9, " & " << varrefp << endl); - AstAlwaysPost* finalp = VN_CAST(varrefp->varScopep()->user4p(), AlwaysPost); + AstAlwaysPost* finalp = VN_AS(varrefp->varScopep()->user4p(), AlwaysPost); if (finalp) { - AstActive* oldactivep = VN_CAST(finalp->user2p(), Active); + AstActive* oldactivep = VN_AS(finalp->user2p(), Active); checkActivePost(varrefp, oldactivep); if (setinitp) oldactivep->addStmtsp(setinitp); } else { // first time we've dealt with this memory @@ -343,7 +343,7 @@ private: if (finalp->user3p() == setvscp) { // Optimize as above; if sharing Vdlyvset *ON SAME VARIABLE*, // we can share the IF statement too - postLogicp = VN_CAST(finalp->user4p(), If); + postLogicp = VN_AS(finalp->user4p(), If); UASSERT_OBJ(postLogicp, nodep, "Delayed assignment misoptimized; prev var found w/o associated IF"); } else { @@ -397,7 +397,7 @@ private: } if (VN_IS(nodep->lhsp(), ArraySel) || (VN_IS(nodep->lhsp(), Sel) - && VN_IS(VN_CAST(nodep->lhsp(), Sel)->fromp(), ArraySel))) { + && VN_IS(VN_AS(nodep->lhsp(), Sel)->fromp(), ArraySel))) { AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); AstNode* newlhsp = createDlyArray(nodep, lhsp); if (m_inLoop) { @@ -434,9 +434,9 @@ private: } AstVarScope* oldvscp = nodep->varScopep(); UASSERT_OBJ(oldvscp, nodep, "Var didn't get varscoped in V3Scope.cpp"); - AstVarScope* dlyvscp = VN_CAST(oldvscp->user1p(), VarScope); + AstVarScope* dlyvscp = VN_AS(oldvscp->user1p(), VarScope); if (dlyvscp) { // Multiple use of delayed variable - AstActive* oldactivep = VN_CAST(dlyvscp->user2p(), Active); + AstActive* oldactivep = VN_AS(dlyvscp->user2p(), Active); checkActivePost(nodep, oldactivep); } if (!dlyvscp) { // First use of this delayed variable diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index 0632a32e3..4c56aee73 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -30,7 +30,7 @@ EmitCParentModule::EmitCParentModule() { } }; for (AstNode* modp = v3Global.rootp()->modulesp(); modp; modp = modp->nextp()) { - setAll(VN_CAST(modp, NodeModule)); + setAll(VN_AS(modp, NodeModule)); } setAll(v3Global.rootp()->constPoolp()->modp()); } diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index dcebb4484..564926899 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -41,7 +41,7 @@ public: VL_UNCOPYABLE(EmitCParentModule); static const AstNodeModule* get(const AstNode* nodep) { - return VN_CAST_CONST(nodep->user4p(), NodeModule); + return VN_AS_CONST(nodep->user4p(), NodeModule); } }; diff --git a/src/V3EmitCConstInit.h b/src/V3EmitCConstInit.h index 386926b63..40233ef37 100644 --- a/src/V3EmitCConstInit.h +++ b/src/V3EmitCConstInit.h @@ -38,7 +38,7 @@ protected: // VISITORS virtual void visit(AstInitArray* nodep) override { const AstUnpackArrayDType* const dtypep - = VN_CAST(nodep->dtypep()->skipRefp(), UnpackArrayDType); + = VN_AS(nodep->dtypep()->skipRefp(), UnpackArrayDType); UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype"); const uint32_t size = dtypep->elementsConst(); const uint32_t elemBytes = dtypep->subDTypep()->widthTotalBytes(); diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index ed130c578..429396bc0 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -629,15 +629,14 @@ void EmitCFunc::emitVarReset(AstVar* varp) { if (initarp->defaultp()) { puts("for (int __Vi=0; __Vi<" + cvtToStr(adtypep->elementsConst())); puts("; ++__Vi) {\n"); - emitSetVarConstant(varNameProtected + "[__Vi]", - VN_CAST(initarp->defaultp(), Const)); + emitSetVarConstant(varNameProtected + "[__Vi]", VN_AS(initarp->defaultp(), Const)); puts("}\n"); } const AstInitArray::KeyItemMap& mapr = initarp->map(); for (const auto& itr : mapr) { AstNode* valuep = itr.second->valuep(); emitSetVarConstant(varNameProtected + "[" + cvtToStr(itr.first) + "]", - VN_CAST(valuep, Const)); + VN_AS(valuep, Const)); } } else { varp->v3fatalSrc("InitArray under non-arrayed var"); @@ -692,7 +691,7 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, const string& varNameP if (dtypep->isWide()) { // Handle unpacked; not basicp->isWide string out; if (varp->valuep()) { - AstConst* const constp = VN_CAST(varp->valuep(), Const); + AstConst* const constp = VN_AS(varp->valuep(), Const); if (!constp) varp->v3fatalSrc("non-const initializer for variable"); for (int w = 0; w < varp->widthWords(); ++w) { out += varNameProtected + suffix + "[" + cvtToStr(w) + "] = "; @@ -792,7 +791,7 @@ void EmitCFunc::emitChangeDet() { doubleOrDetect(nodep, gotOneIgnore); string varname; if (VN_IS(nodep->lhsp(), VarRef)) { - varname = ": " + VN_CAST(nodep->lhsp(), VarRef)->varp()->prettyName(); + varname = ": " + VN_AS(nodep->lhsp(), VarRef)->varp()->prettyName(); } puts(")) VL_DBG_MSGF(\" CHANGE: "); puts(protect(nodep->fileline()->filename())); diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index fa9a3d157..0c0b85060 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -323,7 +323,7 @@ public: && !VN_IS(nodep->rhsp(), AssocSel) // && !VN_IS(nodep->rhsp(), ArraySel)) { // Wide functions assign into the array directly, don't need separate assign statement - m_wideTempRefp = VN_CAST(nodep->lhsp(), VarRef); + m_wideTempRefp = VN_AS(nodep->lhsp(), VarRef); paren = false; } else if (nodep->isWide()) { putbs("VL_ASSIGN_W("); @@ -348,7 +348,7 @@ public: virtual void visit(AstAssocSel* nodep) override { iterateAndNextNull(nodep->fromp()); putbs(".at("); - AstAssocArrayDType* adtypep = VN_CAST(nodep->fromp()->dtypep(), AssocArrayDType); + AstAssocArrayDType* adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType); UASSERT_OBJ(adtypep, nodep, "Associative select on non-associative type"); if (adtypep->keyDTypep()->isWide()) { emitCvtWideArray(nodep->bitp(), nodep->fromp()); @@ -898,7 +898,7 @@ public: } } virtual void visit(AstTextBlock* nodep) override { - visit(VN_CAST(nodep, NodeSimpleText)); + visit(VN_AS(nodep, NodeSimpleText)); for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) { iterate(childp); if (nodep->commas() && childp->nextp()) puts(", "); @@ -978,7 +978,7 @@ public: } virtual void visit(AstRedXor* nodep) override { if (nodep->lhsp()->isWide()) { - visit(VN_CAST(nodep, NodeUniop)); + visit(VN_AS(nodep, NodeUniop)); } else { AstVarRef* const vrefp = VN_CAST(nodep->lhsp(), VarRef); const int widthPow2 = vrefp ? vrefp->varp()->dtypep()->widthPow2() @@ -1042,7 +1042,7 @@ public: } virtual void visit(AstReplicate* nodep) override { if (nodep->lhsp()->widthMin() == 1 && !nodep->isWide()) { - UASSERT_OBJ((static_cast(VN_CAST(nodep->rhsp(), Const)->toUInt()) + UASSERT_OBJ((static_cast(VN_AS(nodep->rhsp(), Const)->toUInt()) * nodep->lhsp()->widthMin()) == nodep->widthMin(), nodep, "Replicate non-constant or width miscomputed"); @@ -1064,8 +1064,8 @@ public: virtual void visit(AstStreamL* nodep) override { // Attempt to use a "fast" stream function for slice size = power of 2 if (!nodep->isWide()) { - uint32_t isPow2 = VN_CAST(nodep->rhsp(), Const)->num().countOnes() == 1; - uint32_t sliceSize = VN_CAST(nodep->rhsp(), Const)->toUInt(); + uint32_t isPow2 = VN_AS(nodep->rhsp(), Const)->num().countOnes() == 1; + uint32_t sliceSize = VN_AS(nodep->rhsp(), Const)->toUInt(); if (isPow2 && sliceSize <= (nodep->isQuad() ? sizeof(uint64_t) : sizeof(uint32_t))) { puts("VL_STREAML_FAST_"); emitIQW(nodep); @@ -1077,7 +1077,7 @@ public: puts(","); iterateAndNextNull(nodep->lhsp()); puts(", "); - uint32_t rd_log2 = V3Number::log2b(VN_CAST(nodep->rhsp(), Const)->toUInt()); + uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt()); puts(cvtToStr(rd_log2) + ")"); return; } diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index 74dce02c8..46f2c5349 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -191,7 +191,7 @@ class EmitCHeader final : public EmitCConstInit { } else { puts("enum " + tdefp->name() + " {\n"); for (const AstEnumItem* itemp = edtypep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), EnumItem)) { + itemp = VN_AS(itemp->nextp(), EnumItem)) { puts(itemp->nameProtect()); puts(" = "); iterate(itemp->valuep()); @@ -335,6 +335,6 @@ void V3EmitC::emitcHeaders() { // Process each module in turn for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) { if (VN_IS(nodep, Class)) continue; // Declared with the ClassPackage - EmitCHeader::main(VN_CAST_CONST(nodep, NodeModule)); + EmitCHeader::main(VN_AS_CONST(nodep, NodeModule)); } } diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 03b84a273..3bf5b3ca5 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -446,7 +446,7 @@ class EmitCImp final : EmitCFunc { } void emitCommonImp(const AstNodeModule* modp) { const AstClass* const classp - = VN_IS(modp, ClassPackage) ? VN_CAST_CONST(modp, ClassPackage)->classp() : nullptr; + = VN_IS(modp, ClassPackage) ? VN_AS_CONST(modp, ClassPackage)->classp() : nullptr; if (hasCommonImp(modp) || hasCommonImp(classp)) { std::set headers; @@ -724,7 +724,7 @@ class EmitCTrace final : EmitCFunc { puts("const char* " + protect("__VenumItemNames") + "[]\n"); puts("= {"); for (AstEnumItem* itemp = enump->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), EnumItem)) { + itemp = VN_AS(itemp->nextp(), EnumItem)) { if (++nvals > 1) puts(", "); putbs("\"" + itemp->prettyName() + "\""); } @@ -733,8 +733,8 @@ class EmitCTrace final : EmitCFunc { puts("const char* " + protect("__VenumItemValues") + "[]\n"); puts("= {"); for (AstEnumItem* itemp = enump->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), EnumItem)) { - AstConst* constp = VN_CAST(itemp->valuep(), Const); + itemp = VN_AS(itemp->nextp(), EnumItem)) { + AstConst* constp = VN_AS(itemp->valuep(), Const); if (++nvals > 1) puts(", "); putbs("\"" + constp->num().displayed(nodep, "%0b") + "\""); } @@ -887,7 +887,7 @@ void V3EmitC::emitcImp() { // Process each module in turn for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) { if (VN_IS(nodep, Class)) continue; // Imped with ClassPackage - const AstNodeModule* const modp = VN_CAST_CONST(nodep, NodeModule); + const AstNodeModule* const modp = VN_AS_CONST(nodep, NodeModule); EmitCImp::main(modp, /* slow: */ true); EmitCImp::main(modp, /* slow: */ false); } @@ -902,7 +902,7 @@ void V3EmitC::emitcImp() { void V3EmitC::emitcFiles() { UINFO(2, __FUNCTION__ << ": " << endl); for (AstNodeFile* filep = v3Global.rootp()->filesp(); filep; - filep = VN_CAST(filep->nextp(), NodeFile)) { + filep = VN_AS(filep->nextp(), NodeFile)) { AstCFile* cfilep = VN_CAST(filep, CFile); if (cfilep && cfilep->tblockp()) { V3OutCFile of(cfilep->name()); diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index 890634a86..776d84ef8 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -135,7 +135,7 @@ class CMakeEmitter final { std::vector support_slow; std::vector global; for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep; - nodep = VN_CAST(nodep->nextp(), NodeFile)) { + nodep = VN_AS(nodep->nextp(), NodeFile)) { AstCFile* cfilep = VN_CAST(nodep, CFile); if (cfilep && cfilep->source()) { if (cfilep->support()) { diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 76e82adf0..a10f5a64c 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -124,8 +124,8 @@ class EmitCSyms final : EmitCBaseVisitor { // Prevent GCC compile time error; name check all things that reach C++ code if (nodep->name() != "" && !(VN_IS(nodep, CFunc) - && (VN_CAST(nodep, CFunc)->isConstructor() - || VN_CAST(nodep, CFunc)->isDestructor()))) { + && (VN_AS(nodep, CFunc)->isConstructor() + || VN_AS(nodep, CFunc)->isDestructor()))) { const string rsvd = V3LanguageWords::isKeyword(nodep->name()); if (rsvd != "") { // Generally V3Name should find all of these and throw SYMRSVDWORD. @@ -402,7 +402,7 @@ void EmitCSyms::emitSymHdr() { puts("\n// INCLUDE MODULE CLASSES\n"); for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; - nodep = VN_CAST(nodep->nextp(), NodeModule)) { + nodep = VN_AS(nodep->nextp(), NodeModule)) { if (VN_IS(nodep, Class)) continue; // Class included earlier puts("#include \"" + prefixNameProtect(nodep) + ".h\"\n"); } @@ -584,7 +584,7 @@ void EmitCSyms::emitSymImpPreamble() { puts("#include \"" + symClassName() + ".h\"\n"); puts("#include \"" + topClassName() + ".h\"\n"); for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; - nodep = VN_CAST(nodep->nextp(), NodeModule)) { + nodep = VN_AS(nodep->nextp(), NodeModule)) { if (VN_IS(nodep, Class)) continue; // Class included earlier puts("#include \"" + prefixNameProtect(nodep) + ".h\"\n"); } diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index b27ef2fbb..acff39cf0 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -115,7 +115,7 @@ public: } else if (support == 2 && slow) { } else { for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep; - nodep = VN_CAST(nodep->nextp(), NodeFile)) { + nodep = VN_AS(nodep->nextp(), NodeFile)) { AstCFile* cfilep = VN_CAST(nodep, CFile); if (cfilep && cfilep->source() && cfilep->slow() == (slow != 0) && cfilep->support() == (support != 0)) { diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 28d36222f..da749f237 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -382,7 +382,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } } virtual void visit(AstTextBlock* nodep) override { - visit(VN_CAST(nodep, NodeSimpleText)); + visit(VN_AS(nodep, NodeSimpleText)); { VL_RESTORER(m_suppressSemi); m_suppressVarSemi = nodep->commas(); @@ -538,15 +538,15 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { if (VN_IS(nodep->lsbp(), Const)) { if (nodep->widthp()->isOne()) { if (VN_IS(nodep->lsbp(), Const)) { - puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt())); + puts(cvtToStr(VN_AS(nodep->lsbp(), Const)->toSInt())); } else { iterateAndNextNull(nodep->lsbp()); } } else { - puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt() - + VN_CAST(nodep->widthp(), Const)->toSInt() - 1)); + puts(cvtToStr(VN_AS(nodep->lsbp(), Const)->toSInt() + + VN_AS(nodep->widthp(), Const)->toSInt() - 1)); puts(":"); - puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt())); + puts(cvtToStr(VN_AS(nodep->lsbp(), Const)->toSInt())); } } else { iterateAndNextNull(nodep->lsbp()); @@ -837,7 +837,7 @@ void V3EmitV::verilogPrefixedTree(AstNode* nodep, std::ostream& os, const string void V3EmitV::emitvFiles() { UINFO(2, __FUNCTION__ << ": " << endl); for (AstNodeFile* filep = v3Global.rootp()->filesp(); filep; - filep = VN_CAST(filep->nextp(), NodeFile)) { + filep = VN_AS(filep->nextp(), NodeFile)) { AstVFile* vfilep = VN_CAST(filep, VFile); if (vfilep && vfilep->tblockp()) { V3OutVFile of(vfilep->name()); diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index d62930a47..3afd020bd 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -109,7 +109,7 @@ private: static void fixCloneLvalue(AstNode* nodep) { // In AstSel transforms, we call clone() on VarRefs that were lvalues, // but are now being used on the RHS of the assignment - if (VN_IS(nodep, VarRef)) VN_CAST(nodep, VarRef)->access(VAccess::READ); + if (VN_IS(nodep, VarRef)) VN_AS(nodep, VarRef)->access(VAccess::READ); // Iterate if (nodep->op1p()) fixCloneLvalue(nodep->op1p()); if (nodep->op2p()) fixCloneLvalue(nodep->op2p()); @@ -183,8 +183,7 @@ private: AstNode* wordp; FileLine* const lfl = lsbp->fileline(); if (VN_IS(lsbp, Const)) { - wordp - = new AstConst{lfl, wordOffset + VL_BITWORD_E(VN_CAST(lsbp, Const)->toUInt())}; + wordp = new AstConst{lfl, wordOffset + VL_BITWORD_E(VN_AS(lsbp, Const)->toUInt())}; } else { wordp = new AstShiftR{lfl, lsbp->cloneTree(true), new AstConst{lfl, VL_EDATASIZE_LOG2}, VL_EDATASIZE}; @@ -202,8 +201,8 @@ private: // If there's a CONDBOUND safety to keep arrays in bounds, // we're going to AND it to a value that always fits inside a // word, so we don't need it. - // if (VN_IS(nodep, CondBound) && VN_IS(VN_CAST(nodep, CondBound)->lhsp(), Lte)) { - // nodep = VN_CAST(nodep, CondBound)->rhsp(); + // if (VN_IS(nodep, CondBound) && VN_IS(VN_AS(nodep, CondBound)->lhsp(), Lte)) { + // nodep = VN_AS(nodep, CondBound)->rhsp(); //} return nodep; } @@ -212,7 +211,7 @@ private: // Return equation to get the VL_BITBIT of a constant or non-constant FileLine* const fl = lsbp->fileline(); if (VN_IS(lsbp, Const)) { - return new AstConst{fl, VL_BITBIT_E(VN_CAST(lsbp, Const)->toUInt())}; + return new AstConst{fl, VL_BITBIT_E(VN_AS(lsbp, Const)->toUInt())}; } else { return new AstAnd{fl, new AstConst{fl, VL_EDATASIZE - 1}, dropCondBound(lsbp)->cloneTree(true)}; @@ -346,7 +345,7 @@ private: // Remember, Sel's may have non-integer rhs, so need to optimize for that! UASSERT_OBJ(nodep->widthMin() == nodep->widthConst(), nodep, "Width mismatch"); if (VN_IS(nodep->backp(), NodeAssign) - && nodep == VN_CAST(nodep->backp(), NodeAssign)->lhsp()) { + && nodep == VN_AS(nodep->backp(), NodeAssign)->lhsp()) { // Sel is an LHS assignment select } else if (nodep->isWide()) { // See under ASSIGN(WIDE) @@ -679,7 +678,7 @@ private: newp = new AstNegate{fl, lhsp}; } else { UINFO(8, " REPLICATE " << nodep << endl); - const AstConst* constp = VN_CAST(nodep->rhsp(), Const); + const AstConst* constp = VN_AS(nodep->rhsp(), Const); UASSERT_OBJ(constp, nodep, "Replication value isn't a constant. Checked earlier!"); uint32_t times = constp->toUInt(); @@ -707,7 +706,7 @@ private: FileLine* const fl = nodep->fileline(); AstNode* const lhsp = rhsp->lhsp(); const int lhswidth = lhsp->widthMin(); - const AstConst* const constp = VN_CAST(rhsp->rhsp(), Const); + const AstConst* const constp = VN_AS(rhsp->rhsp(), Const); UASSERT_OBJ(constp, rhsp, "Replication value isn't a constant. Checked earlier!"); const uint32_t times = constp->toUInt(); for (int w = 0; w < rhsp->widthWords(); ++w) { diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 9e36482a9..3c7b94755 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -249,14 +249,12 @@ private: // This avoids a mess in computing what exactly a POSEDGE is // V3Const cleans up any NOTs by flipping the edges for us if (m_buffersOnly - && !(VN_IS(nodep->rhsp(), VarRef) - // Avoid making non-clocked logic into clocked, - // as it slows down the verilator_sim_benchmark - || (VN_IS(nodep->rhsp(), Not) - && VN_IS(VN_CAST(nodep->rhsp(), Not)->lhsp(), VarRef) - && VN_CAST(VN_CAST(nodep->rhsp(), Not)->lhsp(), VarRef) - ->varp() - ->isUsedClock()))) { + && !( + VN_IS(nodep->rhsp(), VarRef) + // Avoid making non-clocked logic into clocked, + // as it slows down the verilator_sim_benchmark + || (VN_IS(nodep->rhsp(), Not) && VN_IS(VN_AS(nodep->rhsp(), Not)->lhsp(), VarRef) + && VN_AS(VN_AS(nodep->rhsp(), Not)->lhsp(), VarRef)->varp()->isUsedClock()))) { clearSimple("Not a buffer (goes to a clock)"); } } @@ -512,7 +510,7 @@ private: } virtual void visit(AstConcat* nodep) override { UASSERT_OBJ(!(VN_IS(nodep->backp(), NodeAssign) - && VN_CAST(nodep->backp(), NodeAssign)->lhsp() == nodep), + && VN_AS(nodep->backp(), NodeAssign)->lhsp() == nodep), nodep, "Concat on LHS of assignment; V3Const should have deleted it"); iterateChildren(nodep); } @@ -996,7 +994,7 @@ public: // So dupit is either a different, duplicate rhsp, or the end of the hash. if (dupit != m_dupFinder.end()) { m_dupFinder.erase(inserted); - return VN_CAST(dupit->second->user2p(), NodeAssign); + return VN_AS(dupit->second->user2p(), NodeAssign); } // Retain new inserted information return nullptr; @@ -1285,8 +1283,8 @@ private: if (AstNodeAssign* assignp = VN_CAST(lvertexp->nodep(), NodeAssign)) { // if (lvertexp->outSize1() && VN_IS(assignp->lhsp(), Sel)) { if (VN_IS(assignp->lhsp(), Sel) && lvertexp->outSize1()) { - UINFO(9, "assing to the nodep[" - << VN_CAST(assignp->lhsp(), Sel)->lsbConst() << "]" << endl); + UINFO(9, "assing to the nodep[" << VN_AS(assignp->lhsp(), Sel)->lsbConst() + << "]" << endl); // first assign with Sel-lhs if (!m_activep) m_activep = lvertexp->activep(); if (!m_logicvp) m_logicvp = lvertexp; diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index 1845a95b3..f766b7a4a 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -54,7 +54,7 @@ private: // METHODS AstVarScope* genInpClk(AstVarScope* vscp) { if (vscp->user2p()) { - return VN_CAST(vscp->user2p(), VarScope); + return VN_AS(vscp->user2p(), VarScope); } else { // In order to create a __VinpClk* for a signal, it needs to be marked circular. // The DPI export trigger is never marked circular by V3Order (see comments in diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 680eacfc6..f56933dd9 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -359,7 +359,7 @@ private: // Each inlined cell that contain an interface variable need to // copy the IfaceRefDType and point it to the newly cloned // interface cell. - AstIfaceRefDType* newdp = VN_CAST(ifacerefp->cloneTree(false), IfaceRefDType); + AstIfaceRefDType* newdp = VN_AS(ifacerefp->cloneTree(false), IfaceRefDType); nodep->dtypep(newdp); ifacerefp->addNextHere(newdp); // Relink to point to newly cloned cell @@ -536,7 +536,7 @@ private: // Better off before, as if module has multiple instantiations // we'll save work, and we can't call pinReconnectSimple in // this loop as it clone()s itself. - for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { V3Inst::pinReconnectSimple(pinp, nodep, false); } @@ -555,7 +555,7 @@ private: nodep->modp()->timeunit()); m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells // Create assignments to the pins - for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (!pinp->exprp()) continue; UINFO(6, " Pin change from " << pinp->modVarp() << endl); // Make new signal; even though we'll optimize the interconnect, we @@ -574,7 +574,7 @@ private: // Propagate any attributes across the interconnect pinNewVarp->propagateAttrFrom(pinOldVarp); if (VN_IS(connectRefp, VarRef)) { - VN_CAST(connectRefp, VarRef)->varp()->propagateAttrFrom(pinOldVarp); + VN_AS(connectRefp, VarRef)->varp()->propagateAttrFrom(pinOldVarp); } // One to one interconnect won't make a temporary variable. @@ -648,7 +648,7 @@ private: if (AstModule* modp = VN_CAST(nodep->modp(), Module)) { // Pass Cell pointers down to the next module - for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { AstVar* varp = pinp->modVarp(); AstVarRef* varrefp = VN_CAST(pinp->exprp(), VarRef); if (!varrefp) continue; @@ -720,7 +720,7 @@ void V3Inline::inlineAll(AstNetlist* nodep) { // idea to avoid dumping the hugely exploded tree. AstNodeModule* nextmodp; for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp = nextmodp) { - nextmodp = VN_CAST(modp->nextp(), NodeModule); + nextmodp = VN_AS(modp->nextp(), NodeModule); if (modp->user1()) { // Was inlined VL_DO_DANGLING(modp->unlinkFrBack()->deleteTree(), modp); } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 97508c9f3..92fdfb954 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -91,9 +91,9 @@ private: if (debug() >= 9) assp->dumpTree(cout, " _new: "); } else if (nodep->modVarp()->isIfaceRef() || (VN_IS(nodep->modVarp()->subDTypep(), UnpackArrayDType) - && VN_IS(VN_CAST(nodep->modVarp()->subDTypep(), UnpackArrayDType) - ->subDTypep(), - IfaceRefDType))) { + && VN_IS( + VN_AS(nodep->modVarp()->subDTypep(), UnpackArrayDType)->subDTypep(), + IfaceRefDType))) { // Create an AstAssignVarScope for Vars to Cells so we can // link with their scope later AstNode* lhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), @@ -202,16 +202,16 @@ private: // VISITORS virtual void visit(AstVar* nodep) override { if (VN_IS(nodep->dtypep(), UnpackArrayDType) - && VN_IS(VN_CAST(nodep->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType)) { + && VN_IS(VN_AS(nodep->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType)) { UINFO(8, " dv-vec-VAR " << nodep << endl); - AstUnpackArrayDType* arrdtype = VN_CAST(nodep->dtypep(), UnpackArrayDType); + AstUnpackArrayDType* arrdtype = VN_AS(nodep->dtypep(), UnpackArrayDType); AstNode* prevp = nullptr; for (int i = arrdtype->lo(); i <= arrdtype->hi(); ++i) { const string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__"; UINFO(8, "VAR name insert " << varNewName << " " << nodep << endl); if (!m_deModVars.find(varNewName)) { AstIfaceRefDType* ifaceRefp - = VN_CAST(arrdtype->subDTypep(), IfaceRefDType)->cloneTree(false); + = VN_AS(arrdtype->subDTypep(), IfaceRefDType)->cloneTree(false); arrdtype->addNextHere(ifaceRefp); ifaceRefp->cellp(nullptr); @@ -248,7 +248,7 @@ private: AstVar* ifaceVarp = VN_CAST(nodep->nextp(), Var); const bool isIface = ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType) - && VN_IS(VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(), + && VN_IS(VN_AS(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType); // Make all of the required clones @@ -271,9 +271,8 @@ private: // If this AstCell is actually an interface instantiation, also clone the IfaceRef // within the same parent module as the cell if (isIface) { - AstUnpackArrayDType* arrdtype = VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType); - AstIfaceRefDType* origIfaceRefp - = VN_CAST(arrdtype->subDTypep(), IfaceRefDType); + AstUnpackArrayDType* arrdtype = VN_AS(ifaceVarp->dtypep(), UnpackArrayDType); + AstIfaceRefDType* origIfaceRefp = VN_AS(arrdtype->subDTypep(), IfaceRefDType); origIfaceRefp->cellp(nullptr); AstVar* varNewp = ifaceVarp->cloneTree(false); AstIfaceRefDType* ifaceRefp = origIfaceRefp->cloneTree(false); @@ -328,7 +327,7 @@ private: << pinDim.second << endl); if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) { // Connection to array, where array dimensions match the instant dimension - AstRange* rangep = VN_CAST(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep(); + AstRange* rangep = VN_AS(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep(); const int arraySelNum = rangep->littleEndian() ? (rangep->elementsConst() - 1 - m_instSelNum) : m_instSelNum; @@ -405,7 +404,7 @@ private: if (!pinVarp->backp()) { varNewp = m_deModVars.find(varNewName); } else { - AstIfaceRefDType* ifaceRefp = VN_CAST(pinArrp->subDTypep(), IfaceRefDType); + AstIfaceRefDType* ifaceRefp = VN_AS(pinArrp->subDTypep(), IfaceRefDType); ifaceRefp->cellp(nullptr); varNewp = pinVarp->cloneTree(false); varNewp->name(varNewName); @@ -433,11 +432,11 @@ private: const AstVarRef* varrefp = VN_CAST(newp->exprp(), VarRef); // Maybe null int expr_i = i; if (AstSliceSel* slicep = VN_CAST(newp->exprp(), SliceSel)) { - varrefp = VN_CAST(slicep->fromp(), VarRef); + varrefp = VN_AS(slicep->fromp(), VarRef); UASSERT(VN_IS(slicep->rhsp(), Const), "Slices should be constant"); int slice_index = slicep->declRange().left() + in * slicep->declRange().leftToRightInc(); - auto* exprArrp = VN_CAST(varrefp->dtypep(), UnpackArrayDType); + auto* exprArrp = VN_AS(varrefp->dtypep(), UnpackArrayDType); UASSERT_OBJ(exprArrp, slicep, "Slice of non-array"); expr_i = slice_index + exprArrp->lo(); } else if (!varrefp) { @@ -597,7 +596,7 @@ void V3Inst::checkOutputShort(AstPin* nodep) { if (nodep->modVarp()->direction() == VDirection::OUTPUT) { if (VN_IS(nodep->exprp(), Const) || VN_IS(nodep->exprp(), Extend) || (VN_IS(nodep->exprp(), Concat) - && (VN_IS(VN_CAST(nodep->exprp(), Concat)->lhsp(), Const)))) { + && (VN_IS(VN_AS(nodep->exprp(), Concat)->lhsp(), Const)))) { // Uses v3warn for error, as might be found multiple times nodep->v3warn(E_PORTSHORT, "Output port is connected to a constant pin," " electrical short"); diff --git a/src/V3Life.cpp b/src/V3Life.cpp index af09be5ea..c0fcb0ed3 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -97,7 +97,7 @@ public: m_assignp = assp; m_constp = nullptr; m_everSet = true; - if (VN_IS(assp->rhsp(), Const)) m_constp = VN_CAST(assp->rhsp(), Const); + if (VN_IS(assp->rhsp(), Const)) m_constp = VN_AS(assp->rhsp(), Const); } inline void complexAssign() { // A[x]=... or some complicated assignment m_assignp = nullptr; @@ -313,7 +313,7 @@ private: } // Has to be direct assignment without any EXTRACTing. if (VN_IS(nodep->lhsp(), VarRef) && !m_sideEffect && !m_noopt) { - AstVarScope* vscp = VN_CAST(nodep->lhsp(), VarRef)->varScopep(); + AstVarScope* vscp = VN_AS(nodep->lhsp(), VarRef)->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope lost on variable"); m_lifep->simpleAssign(vscp, nodep); } else { diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index f8306c38f..7eee9d96d 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -187,8 +187,8 @@ private: void squashAssignposts() { for (auto& itr : m_assignposts) { LifePostLocation* app = &itr.second; - AstVarRef* lhsp = VN_CAST(app->nodep->lhsp(), VarRef); // original var - AstVarRef* rhsp = VN_CAST(app->nodep->rhsp(), VarRef); // dly var + AstVarRef* lhsp = VN_AS(app->nodep->lhsp(), VarRef); // original var + AstVarRef* rhsp = VN_AS(app->nodep->rhsp(), VarRef); // dly var AstVarScope* dlyVarp = rhsp->varScopep(); AstVarScope* origVarp = lhsp->varScopep(); diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index c6ee709b3..7e29a669c 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -131,7 +131,7 @@ private: if (!foundp) { return nullptr; } else { - return VN_CAST(foundp->nodep(), NodeModule); + return VN_AS(foundp->nodep(), NodeModule); } } @@ -233,7 +233,7 @@ private: if (VN_IS(modp, Iface)) { // Track module depths, so can sort list from parent down to children new V3GraphEdge(&m_graph, vertex(m_modp), vertex(modp), 1, false); - if (!nodep->cellp()) nodep->ifacep(VN_CAST(modp, Iface)); + if (!nodep->cellp()) nodep->ifacep(VN_AS(modp, Iface)); } else if (VN_IS(modp, NotFoundModule)) { // Will error out later } else { nodep->v3error("Non-interface used as an interface: " << nodep->prettyNameQ()); @@ -349,7 +349,7 @@ private: // Convert .* to list of pins bool pinStar = false; for (AstPin *nextp, *pinp = nodep->pinsp(); pinp; pinp = nextp) { - nextp = VN_CAST(pinp->nextp(), Pin); + nextp = VN_AS(pinp->nextp(), Pin); if (pinp->dotStar()) { if (pinStar) pinp->v3error("Duplicate .* in an instance"); pinStar = true; @@ -358,10 +358,10 @@ private: } } // Convert unnamed pins to pin number based assignments - for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (pinp->name() == "") pinp->name("__pinNumber" + cvtToStr(pinp->pinNum())); } - for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { pinp->param(true); if (pinp->name() == "") pinp->name("__paramNumber" + cvtToStr(pinp->pinNum())); } @@ -369,7 +369,7 @@ private: nodep->modName(nodep->modp()->name()); // Note what pins exist std::unordered_set ports; // Symbol table of all connected port names - for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (pinp->name() == "") pinp->v3error("Connect by position is illegal in .* connected instances"); if (!pinp->exprp()) { @@ -449,7 +449,7 @@ private: } virtual void visit(AstRefDType* nodep) override { - for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { pinp->param(true); if (pinp->name() == "") pinp->name("__paramNumber" + cvtToStr(pinp->pinNum())); } @@ -469,7 +469,7 @@ private: "information of the top module must exist if --hierarchical-child is set"); // Look at all modules, and store pointers to all module names for (AstNodeModule *nextp, *nodep = v3Global.rootp()->modulesp(); nodep; nodep = nextp) { - nextp = VN_CAST(nodep->nextp(), NodeModule); + nextp = VN_AS(nodep->nextp(), NodeModule); if (v3Global.opt.hierChild() && nodep->name() == hierIt->second.origName()) { nodep->name(hierIt->first); // Change name of this module to be mangled name // considering parameter diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index d8d13d9c5..3a119b0fa 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -259,7 +259,7 @@ public: // We don't throw VARHIDDEN as if the import is later the symbol // table's import wouldn't warn } else if (VN_IS(nodep, Begin) && VN_IS(fnodep, Begin) - && VN_CAST(nodep, Begin)->generate()) { + && VN_AS(nodep, Begin)->generate()) { // Begin: ... blocks often replicate under genif/genfor, so simply // suppress duplicate checks. See t_gen_forif.v for an example. } else { @@ -441,7 +441,7 @@ public: } void computeIfaceVarSyms() { for (VSymEnt* varSymp : m_ifaceVarSyms) { - AstVar* varp = varSymp ? VN_CAST(varSymp->nodep(), Var) : nullptr; + AstVar* varp = varSymp ? VN_AS(varSymp->nodep(), Var) : nullptr; UINFO(9, " insAllIface se" << cvtToHex(varSymp) << " " << varp << endl); AstIfaceRefDType* ifacerefp = ifaceRefFromArray(varp->subDTypep()); UASSERT_OBJ(ifacerefp, varp, "Non-ifacerefs on list!"); @@ -497,7 +497,7 @@ public: // Typically lhsp=VAR w/dtype IFACEREF, rhsp=IFACE cell UINFO(9, " insertScopeAlias se" << cvtToHex(lhsp) << " se" << cvtToHex(rhsp) << endl); UASSERT_OBJ( - !(VN_IS(rhsp->nodep(), Cell) && !VN_IS(VN_CAST(rhsp->nodep(), Cell)->modp(), Iface)), + !(VN_IS(rhsp->nodep(), Cell) && !VN_IS(VN_AS(rhsp->nodep(), Cell)->modp(), Iface)), rhsp->nodep(), "Got a non-IFACE alias RHS"); m_scopeAliasMap[samn].emplace(lhsp, rhsp); } @@ -742,7 +742,7 @@ class LinkDotFindVisitor final : public AstNVisitor { // Process $unit or other packages // Not needed - dotted references not allowed from inside packages // for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); - // nodep; nodep=VN_CAST(nodep->nextp(), NodeModule)) { + // nodep; nodep=VN_AS(nodep->nextp(), NodeModule)) { // if (VN_IS(nodep, Package)) {}} m_statep->insertDUnit(nodep); @@ -757,7 +757,7 @@ class LinkDotFindVisitor final : public AstNVisitor { // wrapTop may have not been created yet. if (!nodep->modulesp()) nodep->v3error("No top level module found"); for (AstNodeModule* modp = nodep->modulesp(); modp && modp->level() <= 2; - modp = VN_CAST(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { UINFO(8, "Top Module: " << modp << endl); m_scope = "TOP"; m_curSymp = m_modSymp = m_statep->insertTopCell(modp, m_scope); @@ -999,7 +999,7 @@ class LinkDotFindVisitor final : public AstNVisitor { } // Set the class as package for iteration if (VN_IS(m_curSymp->nodep(), Class)) { - m_classOrPackagep = VN_CAST(m_curSymp->nodep(), Class); + m_classOrPackagep = VN_AS(m_curSymp->nodep(), Class); } // Create symbol table for the task's vars const string name = string{nodep->isExternProto() ? "extern " : ""} + nodep->name(); @@ -1197,7 +1197,7 @@ class LinkDotFindVisitor final : public AstNVisitor { if (!foundp && m_modSymp && nodep->name() == m_modSymp->nodep()->name()) { foundp = m_modSymp; // Conflicts with modname? } - AstEnumItem* findvarp = foundp ? VN_CAST(foundp->nodep(), EnumItem) : nullptr; + AstEnumItem* findvarp = foundp ? VN_AS(foundp->nodep(), EnumItem) : nullptr; bool ins = false; if (!foundp) { ins = true; @@ -1267,7 +1267,7 @@ class LinkDotFindVisitor final : public AstNVisitor { } virtual void visit(AstWithParse* nodep) override { // Change WITHPARSE(FUNCREF, equation) to FUNCREF(WITH(equation)) - const auto funcrefp = VN_CAST(nodep->funcrefp(), NodeFTaskRef); + const auto funcrefp = VN_AS(nodep->funcrefp(), NodeFTaskRef); UASSERT_OBJ(funcrefp, nodep, "'with' only can operate on a function/task"); string name = "item"; FileLine* argFl = nodep->fileline(); @@ -1398,7 +1398,7 @@ private: << "... Suggest use instantiation with #(." << nodep->prettyName() << "(...etc...))"); VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->path()); - AstCell* cellp = foundp ? VN_CAST(foundp->nodep(), Cell) : nullptr; + AstCell* cellp = foundp ? VN_AS(foundp->nodep(), Cell) : nullptr; if (!cellp) { nodep->v3error("In defparam, instance " << nodep->path() << " never declared"); } else { @@ -1418,7 +1418,7 @@ private: // Need to set pin numbers after varnames are created // But before we do the final resolution based on names VSymEnt* foundp = m_statep->getNodeSym(m_modp)->findIdFlat(nodep->name()); - AstVar* refp = foundp ? VN_CAST(foundp->nodep(), Var) : nullptr; + AstVar* refp = foundp ? VN_AS(foundp->nodep(), Var) : nullptr; if (!refp) { nodep->v3error( "Input/output/inout declaration not found for port: " << nodep->prettyNameQ()); @@ -1472,10 +1472,10 @@ private: // Relink forward definitions to the "real" definition VSymEnt* foundp = m_statep->getNodeSym(fwdp)->findIdFallback(fwdp->name()); if (foundp && (VN_IS(foundp->nodep(), Class) || VN_IS(foundp->nodep(), Package))) { - nodep->classOrPackagep(VN_CAST(foundp->nodep(), NodeModule)); + nodep->classOrPackagep(VN_AS(foundp->nodep(), NodeModule)); } else if (foundp && VN_IS(foundp->nodep(), ParamTypeDType)) { UASSERT(m_statep->forPrimary(), "Param types should have been resolved"); - nodep->classOrPackageNodep(foundp->nodep()); + nodep->classOrPackageNodep(VN_AS(foundp->nodep(), ParamTypeDType)); } else { if (foundp) UINFO(1, "found nodep = " << foundp->nodep() << endl); nodep->v3error( @@ -1597,8 +1597,8 @@ class LinkDotScopeVisitor final : public AstNVisitor { // Track aliases created by V3Inline; if we get a VARXREF(aliased_from) // we'll need to replace it with a VARXREF(aliased_to) if (debug() >= 9) nodep->dumpTree(cout, "- alias: "); - AstVarScope* fromVscp = VN_CAST(nodep->lhsp(), VarRef)->varScopep(); - AstVarScope* toVscp = VN_CAST(nodep->rhsp(), VarRef)->varScopep(); + AstVarScope* fromVscp = VN_AS(nodep->lhsp(), VarRef)->varScopep(); + AstVarScope* toVscp = VN_AS(nodep->rhsp(), VarRef)->varScopep(); UASSERT_OBJ(fromVscp && toVscp, nodep, "Bad alias scopes"); fromVscp->user2p(toVscp); iterateChildren(nodep); @@ -1878,9 +1878,9 @@ private: if (!symp) { return nullptr; } else if (VN_IS(symp->nodep(), Var)) { - return VN_CAST(symp->nodep(), Var); + return VN_AS(symp->nodep(), Var); } else if (VN_IS(symp->nodep(), ModportVarRef)) { - AstModportVarRef* snodep = VN_CAST(symp->nodep(), ModportVarRef); + AstModportVarRef* snodep = VN_AS(symp->nodep(), ModportVarRef); AstVar* varp = snodep->varp(); if (access.isWriteOrRW() && snodep->direction().isReadOnly()) { nodep->v3error("Attempt to drive input-only modport: " << nodep->prettyNameQ()); @@ -1907,7 +1907,7 @@ private: AstVar* findIfaceTopVarp(AstNode* nodep, VSymEnt* parentEntp, const string& name) { const string findName = name + "__Viftop"; VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName); - AstVar* ifaceTopVarp = ifaceSymp ? VN_CAST(ifaceSymp->nodep(), Var) : nullptr; + AstVar* ifaceTopVarp = ifaceSymp ? VN_AS(ifaceSymp->nodep(), Var) : nullptr; UASSERT_OBJ(ifaceTopVarp, nodep, "Can't find interface var ref: " << findName); return ifaceTopVarp; } @@ -2088,12 +2088,12 @@ private: nodep->v3error("'super' used outside class (IEEE 1800-2017 8.15)"); m_ds.m_dotErr = true; } else { - const auto classp = VN_CAST(classSymp->nodep(), Class); + const auto classp = VN_AS(classSymp->nodep(), Class); if (!classp->extendsp()) { nodep->v3error("'super' used on non-extended class (IEEE 1800-2017 8.15)"); m_ds.m_dotErr = true; } else { - const auto cextp = VN_CAST(classp->extendsp(), ClassExtends); + const auto cextp = VN_AS(classp->extendsp(), ClassExtends); UASSERT_OBJ(cextp, nodep, "Bad super extends link"); const auto sclassp = cextp->classp(); UASSERT_OBJ(sclassp, nodep, "Bad superclass"); @@ -2204,8 +2204,7 @@ private: allowVar = true; UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(), "Bad package link"); - AstClassOrPackageRef* cpackagerefp - = VN_CAST(m_ds.m_dotp->lhsp(), ClassOrPackageRef); + AstClassOrPackageRef* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); classOrPackagep = cpackagerefp->classOrPackagep(); UASSERT_OBJ(classOrPackagep, m_ds.m_dotp->lhsp(), "Bad package link"); m_ds.m_dotSymp = m_statep->getNodeSym(classOrPackagep); @@ -2250,7 +2249,7 @@ private: m_ds.m_dotPos = DP_SCOPE; // Upper AstDot visitor will handle it from here } else if (VN_IS(foundp->nodep(), Cell) && allowVar && m_cellp) { - AstCell* cellp = VN_CAST(foundp->nodep(), Cell); + AstCell* cellp = VN_AS(foundp->nodep(), Cell); if (VN_IS(cellp->modp(), Iface)) { // Interfaces can be referenced like a variable for interconnect VSymEnt* cellEntp = m_statep->getNodeSym(cellp); @@ -2312,8 +2311,8 @@ private: refp->dotted(dotted.substr(0, pos)); newp = refp; } else { - newp = new AstUnlinkedRef(nodep->fileline(), - VN_CAST(refp, VarXRef), refp->name(), + newp = new AstUnlinkedRef(nodep->fileline(), VN_AS(refp, VarXRef), + refp->name(), m_ds.m_unlinkedScopep->unlinkFrBack()); m_ds.m_unlinkedScopep = nullptr; m_ds.m_unresolved = false; @@ -2342,16 +2341,16 @@ private: UINFO(9, "dotSymp " << m_ds.m_dotSymp << " " << m_ds.m_dotSymp->nodep() << endl); // Iface was the previously dotted component if (!m_ds.m_dotSymp || !VN_IS(m_ds.m_dotSymp->nodep(), Cell) - || !VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp() - || !VN_IS(VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) { + || !VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp() + || !VN_IS(VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) { nodep->v3error("Modport not referenced as ." << modportp->prettyNameQ()); - } else if (!VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp() - || !VN_IS(VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) { + } else if (!VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp() + || !VN_IS(VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) { nodep->v3error("Modport not referenced from underneath an interface: " << modportp->prettyNameQ()); } else { - AstCell* cellp = VN_CAST(m_ds.m_dotSymp->nodep(), Cell); + AstCell* cellp = VN_AS(m_ds.m_dotSymp->nodep(), Cell); UASSERT_OBJ(cellp, nodep, "Modport not referenced from an instance"); VSymEnt* cellEntp = m_statep->getNodeSym(cellp); UASSERT_OBJ(cellEntp, nodep, "No interface sym entry"); @@ -2519,7 +2518,7 @@ private: } } else { VSymEnt* foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); - AstVarScope* vscp = foundp ? VN_CAST(foundp->nodep(), VarScope) : nullptr; + AstVarScope* vscp = foundp ? VN_AS(foundp->nodep(), VarScope) : nullptr; if (!vscp) { nodep->v3error("Can't find varpin scope of " << AstNode::prettyNameQ(baddot) << " in dotted signal: '" @@ -2529,7 +2528,7 @@ private: while (vscp->user2p()) { // If V3Inline aliased it, pick up the new signal UINFO(7, " Resolved pre-alias " << vscp << endl); // Also prints taskp - vscp = VN_CAST(vscp->user2p(), VarScope); + vscp = VN_AS(vscp->user2p(), VarScope); } // Convert the VarXRef to a VarRef, so we don't need // later optimizations to deal with VarXRef. @@ -2578,7 +2577,7 @@ private: if (m_ds.m_dotp && m_ds.m_dotPos == DP_PACKAGE) { UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(), "Bad package link"); - AstClassOrPackageRef* cpackagerefp = VN_CAST(m_ds.m_dotp->lhsp(), ClassOrPackageRef); + AstClassOrPackageRef* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); if (cpackagerefp->name() == "process" || cpackagerefp->name() == "local") { nodep->v3warn(E_UNSUPPORTED, "Unsupported: " << AstNode::prettyNameQ(cpackagerefp->name())); @@ -2864,7 +2863,7 @@ private: cextp->v3error("Attempting to extend class " << nodep->prettyNameQ() << " from itself"); } else { - AstNode* paramsp = cpackagerefp->paramsp(); + AstPin* paramsp = cpackagerefp->paramsp(); if (paramsp) paramsp = paramsp->cloneTree(true); const auto newp = new AstClassRefDType{nodep->fileline(), classp, paramsp}; @@ -2933,7 +2932,7 @@ private: if (m_ds.m_dotp && m_ds.m_dotPos == DP_PACKAGE) { UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(), "Bad package link"); - auto* cpackagerefp = VN_CAST(m_ds.m_dotp->lhsp(), ClassOrPackageRef); + auto* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); UASSERT_OBJ(cpackagerefp->classOrPackagep(), m_ds.m_dotp->lhsp(), "Bad package link"); nodep->classOrPackagep(cpackagerefp->classOrPackagep()); m_ds.m_dotPos = DP_SCOPE; @@ -2956,7 +2955,7 @@ private: = foundp ? VN_CAST(foundp->nodep(), ParamTypeDType) : nullptr) { nodep->refDTypep(defp); nodep->classOrPackagep(foundp->classOrPackagep()); - } else if (AstClass* defp = foundp ? VN_CAST(foundp->nodep(), Class) : nullptr) { + } else if (AstClass* defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) { AstNode* paramsp = nodep->paramsp(); if (paramsp) paramsp->unlinkFrBackWithNext(); AstClassRefDType* newp = new AstClassRefDType{nodep->fileline(), defp, paramsp}; @@ -2976,7 +2975,7 @@ private: iterateChildren(nodep); checkNoDot(nodep); VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); - AstNodeFTask* taskp = foundp ? VN_CAST(foundp->nodep(), NodeFTask) : nullptr; + AstNodeFTask* taskp = foundp ? VN_AS(foundp->nodep(), NodeFTask) : nullptr; if (!taskp) { nodep->v3error( "Can't find definition of exported task/function: " << nodep->prettyNameQ()); diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index 2317218e7..248e47902 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -74,7 +74,7 @@ private: } else if (m_insMode == IM_AFTER) { m_insStmtp->addNextHere(newp); } else if (m_insMode == IM_WHILE_PRECOND) { - AstWhile* whilep = VN_CAST(m_insStmtp, While); + AstWhile* whilep = VN_AS(m_insStmtp, While); UASSERT_OBJ(whilep, nodep, "Insert should be under WHILE"); whilep->addPrecondsp(newp); } else { @@ -151,7 +151,7 @@ private: void prepost_non_stmt_visit(AstNodeTriop* nodep) { iterateChildren(nodep); - AstConst* constp = VN_CAST(nodep->lhsp(), Const); + AstConst* constp = VN_AS(nodep->lhsp(), Const); UASSERT_OBJ(nodep, constp, "Expecting CONST"); AstConst* newconstp = constp->cloneTree(true); @@ -181,7 +181,7 @@ private: return; } - AstConst* constp = VN_CAST(nodep->lhsp(), Const); + AstConst* constp = VN_AS(nodep->lhsp(), Const); UASSERT_OBJ(nodep, constp, "Expecting CONST"); AstNode* backp = nodep->backp(); AstConst* newconstp = constp->cloneTree(true); diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index 5d4a35425..46e60a544 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -58,19 +58,19 @@ private: AstJumpLabel* findAddLabel(AstNode* nodep, bool endOfIter) { // Put label under given node, and if WHILE optionally at end of iteration UINFO(4, "Create label for " << nodep << endl); - if (VN_IS(nodep, JumpLabel)) return VN_CAST(nodep, JumpLabel); // Done + if (VN_IS(nodep, JumpLabel)) return VN_AS(nodep, JumpLabel); // Done AstNode* underp = nullptr; bool under_and_next = true; if (VN_IS(nodep, NodeBlock)) { - underp = VN_CAST(nodep, NodeBlock)->stmtsp(); + underp = VN_AS(nodep, NodeBlock)->stmtsp(); } else if (VN_IS(nodep, NodeFTask)) { - underp = VN_CAST(nodep, NodeFTask)->stmtsp(); + underp = VN_AS(nodep, NodeFTask)->stmtsp(); } else if (VN_IS(nodep, While)) { if (endOfIter) { // Note we jump to end of bodysp; a FOR loop has its // increment under incsp() which we don't skip - underp = VN_CAST(nodep, While)->bodysp(); + underp = VN_AS(nodep, While)->bodysp(); } else { underp = nodep; under_and_next = false; // IE we skip the entire while @@ -87,7 +87,7 @@ private: UINFO(5, " Underpoint is " << underp << endl); if (VN_IS(underp, JumpLabel)) { - return VN_CAST(underp, JumpLabel); + return VN_AS(underp, JumpLabel); } else { // Move underp stuff to be under a new label AstJumpBlock* blockp = new AstJumpBlock(nodep->fileline(), nullptr); AstJumpLabel* labelp = new AstJumpLabel(nodep->fileline(), blockp); @@ -210,7 +210,7 @@ private: // Set output variable to return value nodep->addPrev(new AstAssign( nodep->fileline(), - new AstVarRef(nodep->fileline(), VN_CAST(funcp->fvarp(), Var), VAccess::WRITE), + new AstVarRef(nodep->fileline(), VN_AS(funcp->fvarp(), Var), VAccess::WRITE), nodep->lhsp()->unlinkFrBackWithNext())); } // Jump to the end of the function call diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index bbecddae1..3d8a9a266 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -49,7 +49,7 @@ void V3LinkLevel::modSortByLevel() { ModVec mods; // Modules ModVec tops; // Top level modules for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep; - nodep = VN_CAST(nodep->nextp(), NodeModule)) { + nodep = VN_AS(nodep->nextp(), NodeModule)) { if (nodep->level() <= 2) tops.push_back(nodep); mods.push_back(nodep); } @@ -165,8 +165,7 @@ void V3LinkLevel::wrapTop(AstNetlist* rootp) { // Instantiate all packages under the top wrapper // This way all later SCOPE based optimizations can ignore packages - for (AstNodeModule* modp = rootp->modulesp(); modp; - modp = VN_CAST(modp->nextp(), NodeModule)) { + for (AstNodeModule* modp = rootp->modulesp(); modp; modp = VN_AS(modp->nextp(), NodeModule)) { if (VN_IS(modp, Package)) { AstCell* cellp = new AstCell(modp->fileline(), modp->fileline(), // Could add __03a__03a="::" to prevent conflict @@ -189,8 +188,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { NameSet ioNames; NameSet dupNames; // For all modules, skipping over new top - for (AstNodeModule* oldmodp = VN_CAST(rootp->modulesp()->nextp(), NodeModule); - oldmodp && oldmodp->level() <= 2; oldmodp = VN_CAST(oldmodp->nextp(), NodeModule)) { + for (AstNodeModule* oldmodp = VN_AS(rootp->modulesp()->nextp(), NodeModule); + oldmodp && oldmodp->level() <= 2; oldmodp = VN_AS(oldmodp->nextp(), NodeModule)) { for (AstNode* subnodep = oldmodp->stmtsp(); subnodep; subnodep = subnodep->nextp()) { if (AstVar* oldvarp = VN_CAST(subnodep, Var)) { if (oldvarp->isIO()) { @@ -206,8 +205,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { } // For all modules, skipping over new top - for (AstNodeModule* oldmodp = VN_CAST(rootp->modulesp()->nextp(), NodeModule); - oldmodp && oldmodp->level() <= 2; oldmodp = VN_CAST(oldmodp->nextp(), NodeModule)) { + for (AstNodeModule* oldmodp = VN_AS(rootp->modulesp()->nextp(), NodeModule); + oldmodp && oldmodp->level() <= 2; oldmodp = VN_AS(oldmodp->nextp(), NodeModule)) { if (VN_IS(oldmodp, Package)) continue; // Add instance UINFO(5, "LOOP " << oldmodp << endl); diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 6dff6a029..49c0c3e9d 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -280,7 +280,7 @@ private: cleanFileline(nodep); iterateChildren(nodep); if (nodep->attrType() == AstAttrType::DT_PUBLIC) { - AstTypedef* typep = VN_CAST(nodep->backp(), Typedef); + AstTypedef* typep = VN_AS(nodep->backp(), Typedef); UASSERT_OBJ(typep, nodep, "Attribute not attached to typedef"); typep->attrPublic(true); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 70067cd79..d5582a101 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -449,8 +449,8 @@ private: UASSERT_OBJ(nodep->text() == "", nodep, "Non-format $sformatf should have \"\" format"); if (VN_IS(nodep->exprsp(), Const) - && VN_CAST(nodep->exprsp(), Const)->num().isFromString()) { - AstConst* fmtp = VN_CAST(nodep->exprsp()->unlinkFrBack(), Const); + && VN_AS(nodep->exprsp(), Const)->num().isFromString()) { + AstConst* fmtp = VN_AS(nodep->exprsp()->unlinkFrBack(), Const); nodep->text(fmtp->num().toString()); VL_DO_DANGLING(pushDeletep(fmtp), fmtp); } @@ -459,7 +459,7 @@ private: const string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false); nodep->text(newFormat); if ((VN_IS(nodep->backp(), Display) - && VN_CAST(nodep->backp(), Display)->displayType().needScopeTracking()) + && VN_AS(nodep->backp(), Display)->displayType().needScopeTracking()) || nodep->formatScopeTracking()) { nodep->scopeNamep(new AstScopeName(nodep->fileline())); } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 57b5dc511..0b05e6f0d 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -313,7 +313,7 @@ private: // Cleanup VL_DO_DANGLING(rhsp->deleteTree(), rhsp); } else { - AstNodeIf* const ifp = VN_CAST(currp, NodeIf); + AstNodeIf* const ifp = VN_AS(currp, NodeIf); UASSERT_OBJ(ifp, currp, "Must be AstNodeIf"); // Move branch contents under new if if (AstNode* const listp = ifp->ifsp()) { diff --git a/src/V3Name.cpp b/src/V3Name.cpp index d448ad0da..0583dc90c 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -51,7 +51,7 @@ private: const string newname = string("__PVT__") + nodep->name(); nodep->name(newname); nodep->editCountInc(); - } else if (VN_IS(nodep, CFunc) && VN_CAST(nodep, CFunc)->isConstructor()) { + } else if (VN_IS(nodep, CFunc) && VN_AS(nodep, CFunc)->isConstructor()) { } else { const string rsvd = V3LanguageWords::isKeyword(nodep->name()); if (rsvd != "") { diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 0cb9cf4d8..754a42cb4 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -327,7 +327,7 @@ private: if (m_inAss) { iterateChildren(nodep); if (VN_IS(nodep->rhsp(), Const)) { - m_childClkWidth = m_childClkWidth * VN_CAST(nodep->rhsp(), Const)->toUInt(); + m_childClkWidth = m_childClkWidth * VN_AS(nodep->rhsp(), Const)->toUInt(); } else { m_childClkWidth = nodep->width(); // can not check in this case. } @@ -1262,8 +1262,8 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) { const bool fromInitial = fromp->hasInitial() || fromp->hasSettle(); if (toInitial != fromInitial) return true; - const AstSenItem* fromSenListp = VN_CAST(fromp->sensesp(), SenItem); - const AstSenItem* toSenListp = VN_CAST(top->sensesp(), SenItem); + const AstSenItem* fromSenListp = VN_AS(fromp->sensesp(), SenItem); + const AstSenItem* toSenListp = VN_AS(top->sensesp(), SenItem); UASSERT_OBJ(fromSenListp, fromp, "sensitivity list item is not an AstSenItem"); UASSERT_OBJ(toSenListp, top, "sensitivity list item is not an AstSenItem"); @@ -1728,7 +1728,7 @@ AstActive* OrderVisitor::processMoveOneLogic(const OrderLogicVertex* lvertexp, AstScope* const scopep = lvertexp->scopep(); AstSenTree* const domainp = lvertexp->domainp(); AstNode* nodep = lvertexp->nodep(); - AstNodeModule* const modp = VN_CAST(scopep->user1p(), NodeModule); // Stashed by visitor func + AstNodeModule* const modp = VN_AS(scopep->user1p(), NodeModule); // Stashed by visitor func UASSERT(modp, "nullptr"); if (VN_IS(nodep, SenTree)) { // Just ignore sensitivities, we'll deal with them when we move statements that need them diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 56175a280..b0ba43339 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -107,7 +107,7 @@ public: m_modParams.insert({hierOpt.second.origName(), {}}); } for (AstNodeModule* modp = nodep->modulesp(); modp; - modp = VN_CAST(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { if (hierOpts.find(modp->prettyName()) != hierOpts.end()) { m_hierBlockMod.emplace(modp->name(), modp); } @@ -138,12 +138,12 @@ public: size_t paramIdx = 0; const ParamConstMap& params = m_hierParams[hierIt->second]; UASSERT(params.size() == hierIt->second->params().size(), "not match"); - for (AstPin* pinp = firstPinp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = firstPinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (!pinp->exprp()) continue; UASSERT_OBJ(!pinp->modPTypep(), pinp, "module with type parameter must not be a hierarchical block"); if (AstVar* modvarp = pinp->modVarp()) { - AstConst* constp = VN_CAST(pinp->exprp(), Const); + AstConst* constp = VN_AS(pinp->exprp(), Const); UASSERT_OBJ(constp, pinp, "parameter for a hierarchical block must have been constified"); const auto paramIt = paramsIt->second.find(modvarp->name()); @@ -402,19 +402,19 @@ class ParamProcessor final { } } void relinkPins(const CloneMap* clonemapp, AstPin* startpinp) { - for (AstPin* pinp = startpinp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = startpinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (pinp->modVarp()) { // Find it in the clone structure // UINFO(8,"Clone find 0x"<modVarp()<find(pinp->modVarp()); UASSERT_OBJ(cloneiter != clonemapp->end(), pinp, "Couldn't find pin in clone list"); - pinp->modVarp(VN_CAST(cloneiter->second, Var)); + pinp->modVarp(VN_AS(cloneiter->second, Var)); } else if (pinp->modPTypep()) { const auto cloneiter = clonemapp->find(pinp->modPTypep()); UASSERT_OBJ(cloneiter != clonemapp->end(), pinp, "Couldn't find pin in clone list"); - pinp->modPTypep(VN_CAST(cloneiter->second, ParamTypeDType)); + pinp->modPTypep(VN_AS(cloneiter->second, ParamTypeDType)); } else { pinp->v3fatalSrc("Not linked?"); } @@ -429,7 +429,7 @@ class ParamProcessor final { } } } - for (AstPin* pinp = startpinp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = startpinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (AstVar* varp = pinp->modVarp()) { const auto varIt = vlstd::as_const(nameToPin).find(varp->name()); UASSERT_OBJ(varIt != nameToPin.end(), varp, @@ -471,7 +471,7 @@ class ParamProcessor final { UASSERT_OBJ(modp->hierBlock(), modp, "should be used for hierarchical block"); std::map pins; - for (AstPin* pinp = paramPinsp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = paramPinsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { checkSupportedParam(modp, pinp); if (AstVar* varp = pinp->modVarp()) { if (!pinp->exprp()) continue; @@ -558,8 +558,8 @@ class ParamProcessor final { // Keep tree sorted by level AstNodeModule* insertp = srcModp; while (VN_IS(insertp->nextp(), NodeModule) - && VN_CAST(insertp->nextp(), NodeModule)->level() < newmodp->level()) { - insertp = VN_CAST(insertp->nextp(), NodeModule); + && VN_AS(insertp->nextp(), NodeModule)->level() < newmodp->level()) { + insertp = VN_AS(insertp->nextp(), NodeModule); } insertp->addNextHere(newmodp); @@ -588,7 +588,7 @@ class ParamProcessor final { } // Assign parameters to the constants specified // DOES clone() so must be finished with module clonep() before here - for (AstPin* pinp = paramsp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = paramsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (pinp->exprp()) { if (AstVar* modvarp = pinp->modVarp()) { AstNode* newp = pinp->exprp(); // Const or InitArray @@ -603,7 +603,7 @@ class ParamProcessor final { modvarp->valuep(newp->cloneTree(false)); modvarp->overriddenParam(overridden); } else if (AstParamTypeDType* modptp = pinp->modPTypep()) { - AstNodeDType* dtypep = VN_CAST(pinp->exprp(), NodeDType); + AstNodeDType* dtypep = VN_AS(pinp->exprp(), NodeDType); UASSERT_OBJ(dtypep, pinp, "unlinked param dtype"); if (modptp->childDTypep()) modptp->childDTypep()->unlinkFrBack()->deleteTree(); // Set this parameter to value requested by cell @@ -694,7 +694,7 @@ class ParamProcessor final { void cellInterfaceCleanup(AstCell* nodep, AstNodeModule* srcModp, string& longnamer, bool& any_overridesr, IfaceRefRefs& ifaceRefRefs) { - for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { AstVar* modvarp = pinp->modVarp(); if (modvarp->isIfaceRef()) { AstIfaceRefDType* portIrefp = VN_CAST(modvarp->subDTypep(), IfaceRefDType); @@ -704,9 +704,9 @@ class ParamProcessor final { AstIfaceRefDType* pinIrefp = nullptr; AstNode* exprp = pinp->exprp(); AstVar* varp - = (exprp && VN_IS(exprp, VarRef)) ? VN_CAST(exprp, VarRef)->varp() : nullptr; + = (exprp && VN_IS(exprp, VarRef)) ? VN_AS(exprp, VarRef)->varp() : nullptr; if (varp && varp->subDTypep() && VN_IS(varp->subDTypep(), IfaceRefDType)) { - pinIrefp = VN_CAST(varp->subDTypep(), IfaceRefDType); + pinIrefp = VN_AS(varp->subDTypep(), IfaceRefDType); } else if (varp && varp->subDTypep() && arraySubDTypep(varp->subDTypep()) && VN_CAST(arraySubDTypep(varp->subDTypep()), IfaceRefDType)) { pinIrefp = VN_CAST(arraySubDTypep(varp->subDTypep()), IfaceRefDType); @@ -717,9 +717,9 @@ class ParamProcessor final { && VN_CAST( arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()), IfaceRefDType)) { - pinIrefp = VN_CAST( - arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()), - IfaceRefDType); + pinIrefp + = VN_AS(arraySubDTypep(VN_AS(exprp->op1p(), VarRef)->varp()->subDTypep()), + IfaceRefDType); } UINFO(9, " portIfaceRef " << portIrefp << endl); @@ -781,7 +781,7 @@ public: longname = parameterizedHierBlockName(srcModp, nodep->paramsp()); any_overrides = longname != srcModp->name(); } else { - for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) { + for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { cellPinCleanup(nodep, pinp, srcModp, longname /*ref*/, any_overrides /*ref*/); } } @@ -824,7 +824,7 @@ public: explicit ParamProcessor(AstNetlist* nodep) : m_hierBlocks{v3Global.opt.hierBlocks(), nodep} { for (AstNodeModule* modp = nodep->modulesp(); modp; - modp = VN_CAST(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { m_allModuleNames.insert(modp->name()); } } @@ -995,8 +995,8 @@ class ParamVisitor final : public AstNVisitor { UINFO(9, "Hit module boundary, done looking for interface" << endl); break; } - if (VN_IS(backp, Var) && VN_CAST(backp, Var)->isIfaceRef() - && VN_CAST(backp, Var)->childDTypep() + if (VN_IS(backp, Var) && VN_AS(backp, Var)->isIfaceRef() + && VN_AS(backp, Var)->childDTypep() && (VN_CAST(VN_CAST(backp, Var)->childDTypep(), IfaceRefDType) || (VN_CAST(VN_CAST(backp, Var)->childDTypep(), UnpackArrayDType) && VN_CAST(VN_CAST(backp, Var)->childDTypep()->getChildDTypep(), @@ -1101,7 +1101,7 @@ class ParamVisitor final : public AstNVisitor { //! move to more generic constant expressions, such code will be needed here. virtual void visit(AstBegin* nodep) override { if (nodep->genforp()) { - AstGenFor* forp = VN_CAST(nodep->genforp(), GenFor); + AstGenFor* forp = VN_AS(nodep->genforp(), GenFor); UASSERT_OBJ(forp, nodep, "Non-GENFOR under generate-for BEGIN"); // We should have a GENFOR under here. We will be replacing the begin, // so process here rather than at the generate to avoid iteration problems @@ -1142,10 +1142,10 @@ class ParamVisitor final : public AstNVisitor { V3Width::widthParamsEdit(nodep); // Param typed widthing will NOT recurse the body, // don't trigger errors yet. V3Const::constifyParamsEdit(nodep->exprp()); // exprp may change - AstConst* exprp = VN_CAST(nodep->exprp(), Const); + AstConst* exprp = VN_AS(nodep->exprp(), Const); // Constify for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* ep = itemp->condsp(); ep;) { AstNode* nextp = ep->nextp(); // May edit list iterateAndNextNull(ep); @@ -1155,7 +1155,7 @@ class ParamVisitor final : public AstNVisitor { } // Item match for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (!itemp->isDefault()) { for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) { if (const AstConst* ccondp = VN_CAST(ep, Const)) { @@ -1170,7 +1170,7 @@ class ParamVisitor final : public AstNVisitor { } // Else default match for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (itemp->isDefault()) { if (!keepp) keepp = itemp->bodysp(); } diff --git a/src/V3ParseGrammar.cpp b/src/V3ParseGrammar.cpp index 8b617181a..4af73bab2 100644 --- a/src/V3ParseGrammar.cpp +++ b/src/V3ParseGrammar.cpp @@ -92,7 +92,7 @@ AstNode* V3ParseGrammar::createSupplyExpr(FileLine* fileline, const string& name AstRange* V3ParseGrammar::scrubRange(AstNodeRange* nrangep) { // Remove any UnsizedRange's from list for (AstNodeRange *nodep = nrangep, *nextp; nodep; nodep = nextp) { - nextp = VN_CAST(nodep->nextp(), NodeRange); + nextp = VN_AS(nodep->nextp(), NodeRange); if (!VN_IS(nodep, Range)) { nodep->v3error( "Unsupported or syntax error: Unsized range in instance or other declaration"); @@ -115,9 +115,9 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra // into ARRAYDTYPE0(ARRAYDTYPE1(ARRAYDTYPE2(BASICTYPE3), RANGE), RANGE) AstNodeDType* arrayp = basep; if (nrangep) { // Maybe no range - return unmodified base type - while (nrangep->nextp()) nrangep = VN_CAST(nrangep->nextp(), NodeRange); + while (nrangep->nextp()) nrangep = VN_AS(nrangep->nextp(), NodeRange); while (nrangep) { - AstNodeRange* prevp = VN_CAST(nrangep->backp(), NodeRange); + AstNodeRange* prevp = VN_AS(nrangep->backp(), NodeRange); if (prevp) nrangep->unlinkFrBack(); AstRange* rangep = VN_CAST(nrangep, Range); if (rangep && isPacked) { @@ -134,7 +134,7 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra } else if (VN_IS(nrangep, UnsizedRange)) { arrayp = new AstUnsizedArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp); } else if (VN_IS(nrangep, BracketRange)) { - AstBracketRange* arangep = VN_CAST(nrangep, BracketRange); + AstBracketRange* arangep = VN_AS(nrangep, BracketRange); AstNode* keyp = arangep->elementsp()->unlinkFrBack(); arrayp = new AstBracketArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp, keyp); diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index fd6422dce..d42e87b4c 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -69,7 +69,7 @@ struct VMemberQualifiers { return q; } void applyToNodes(AstNodeFTask* nodesp) const { - for (AstNodeFTask* nodep = nodesp; nodep; nodep = VN_CAST(nodep->nextp(), NodeFTask)) { + for (AstNodeFTask* nodep = nodesp; nodep; nodep = VN_AS(nodep->nextp(), NodeFTask)) { if (m_local) nodep->isHideLocal(true); if (m_protected) nodep->isHideProtected(true); if (m_virtual) nodep->isVirtual(true); @@ -82,7 +82,7 @@ struct VMemberQualifiers { } } void applyToNodes(AstVar* nodesp) const { - for (AstVar* nodep = nodesp; nodep; nodep = VN_CAST(nodep->nextp(), Var)) { + for (AstVar* nodep = nodesp; nodep; nodep = VN_AS(nodep->nextp(), Var)) { if (m_randc) { nodep->v3warn(RANDC, "Unsupported: Converting 'randc' to 'rand'"); nodep->isRand(true); @@ -309,7 +309,7 @@ public: pkgp = parsep()->rootp()->dollarUnitPkgAddp(); symp()->reinsert(pkgp, symp()->symRootp()); // Don't push/pop scope as they're global } else { - pkgp = VN_CAST(rootSymp->nodep(), Package); + pkgp = VN_AS(rootSymp->nodep(), Package); } return pkgp; } diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 1c680382d..9ffda7800 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -128,10 +128,10 @@ private: if (nodep->isWide()) { if (m_assignLhs) { } else if (nodep->firstAbovep() && VN_IS(nodep->firstAbovep(), NodeAssign) - && assignNoTemp(VN_CAST(nodep->firstAbovep(), NodeAssign))) { + && assignNoTemp(VN_AS(nodep->firstAbovep(), NodeAssign))) { // Not much point if it's just a direct assignment to a constant } else if (VN_IS(nodep->backp(), Sel) - && VN_CAST(nodep->backp(), Sel)->widthp() == nodep) { + && VN_AS(nodep->backp(), Sel)->widthp() == nodep) { // AstSel::width must remain a constant } else if ((nodep->firstAbovep() && VN_IS(nodep->firstAbovep(), ArraySel)) || ((VN_IS(m_stmtp, CCall) || VN_IS(m_stmtp, CStmt)) @@ -384,7 +384,7 @@ private: AstNode* searchp = nodep->nextp(); while (searchp && VN_IS(searchp, Comment)) searchp = searchp->nextp(); if (searchp && VN_IS(searchp, Display) - && nodep->filep()->sameGateTree(VN_CAST(searchp, Display)->filep())) { + && nodep->filep()->sameGateTree(VN_AS(searchp, Display)->filep())) { // There's another display next; we can just wait to flush } else { UINFO(4, "Autoflush " << nodep << endl); diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 6b6b1d8d4..c14ed2364 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -52,7 +52,7 @@ private: classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr) { for (auto* memberp = classp->stmtsp(); memberp; memberp = memberp->nextp()) { // If member is rand and of class type, mark its class - if (VN_IS(memberp, Var) && VN_CAST(memberp, Var)->isRand()) { + if (VN_IS(memberp, Var) && VN_AS(memberp, Var)->isRand()) { if (auto* classRefp = VN_CAST(memberp->dtypep(), ClassRefDType)) { auto* rclassp = classRefp->classp(); markMembers(rclassp); @@ -127,7 +127,7 @@ private: VL_DEBUG_FUNC; AstVar* enumValueTabp(AstEnumDType* nodep) { - if (nodep->user2p()) return VN_CAST(nodep->user2p(), Var); + if (nodep->user2p()) return VN_AS(nodep->user2p(), Var); UINFO(9, "Construct Venumvaltab " << nodep << endl); AstNodeArrayDType* vardtypep = new AstUnpackArrayDType(nodep->fileline(), nodep->dtypep(), @@ -143,8 +143,8 @@ private: v3Global.rootp()->dollarUnitPkgAddp()->addStmtp(varp); UASSERT_OBJ(nodep->itemsp(), nodep, "Enum without items"); for (AstEnumItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), EnumItem)) { - AstConst* vconstp = VN_CAST(itemp->valuep(), Const); + itemp = VN_AS(itemp->nextp(), EnumItem)) { + AstConst* vconstp = VN_AS(itemp->valuep(), Const); UASSERT_OBJ(vconstp, nodep, "Enum item without constified value"); initp->addValuep(vconstp->cloneTree(false)); } @@ -159,7 +159,7 @@ private: AstNodeStmt* stmtsp = nullptr; offset += memberp ? memberp->lsb() : 0; for (auto* smemberp = structDtp->membersp(); smemberp; - smemberp = VN_CAST(smemberp->nextp(), MemberDType)) { + smemberp = VN_AS(smemberp->nextp(), MemberDType)) { auto* randp = newRandStmtsp(fl, stmtsp ? varrefp->cloneTree(false) : varrefp, offset, smemberp); if (stmtsp) { @@ -198,7 +198,7 @@ private: if (!nodep->user1()) return; // Doesn't need randomize, or already processed UINFO(9, "Define randomize() for " << nodep << endl); auto* funcp = V3Randomize::newRandomizeFunc(nodep); - auto* fvarp = VN_CAST(funcp->fvarp(), Var); + auto* fvarp = VN_AS(funcp->fvarp(), Var); funcp->addStmtsp(new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), fvarp, VAccess::WRITE), new AstConst(nodep->fileline(), AstConst::WidthedValue(), 32, 1))); @@ -253,7 +253,7 @@ void V3Randomize::randomizeNetlist(AstNetlist* nodep) { } AstFunc* V3Randomize::newRandomizeFunc(AstClass* nodep) { - auto* funcp = VN_CAST(nodep->findMember("randomize"), Func); + auto* funcp = VN_AS(nodep->findMember("randomize"), Func); if (!funcp) { auto* dtypep = nodep->findBitDType(32, 32, VSigning::SIGNED); // IEEE says int return of 0/1 diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 646758819..219e203ca 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -68,7 +68,7 @@ private: VL_DEBUG_FUNC; // Declare debug() AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) { - AstVar* varp = VN_CAST(cfuncp->user1p(), Var); + AstVar* varp = VN_AS(cfuncp->user1p(), Var); if (!varp) { const string newvarname = string("__Vilp"); varp = new AstVar(fl, AstVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32); diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 5cafafd3b..d9ed9ce9f 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -370,7 +370,7 @@ private: if (nodep->classOrPackagep()) { // Point to the clone UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked"); - AstNodeFTask* newp = VN_CAST(nodep->taskp()->user2p(), NodeFTask); + AstNodeFTask* newp = VN_AS(nodep->taskp()->user2p(), NodeFTask); UASSERT_OBJ(newp, nodep, "No clone for package function"); nodep->taskp(newp); UINFO(9, " New pkg-taskref " << nodep << endl); diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 96967643a..3a41dae75 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -123,7 +123,7 @@ private: std::ostringstream out; out << "'{"; for (AstMemberDType* itemp = stp->membersp(); itemp; - itemp = VN_CAST(itemp->nextp(), MemberDType)) { + itemp = VN_AS(itemp->nextp(), MemberDType)) { const int width = itemp->width(); const int lsb = itemp->lsb(); const int msb = lsb + width - 1; @@ -661,7 +661,7 @@ private: clearOptimizable(nodep, "Array select LHS isn't simple variable"); return; } - AstUnpackArrayDType* arrayp = VN_CAST(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType); + AstUnpackArrayDType* arrayp = VN_AS(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType); UASSERT_OBJ(arrayp, nodep, "Array select of non-array dtype"); AstBasicDType* basicp = VN_CAST(arrayp->subDTypep()->skipRefp(), BasicDType); if (!basicp) { @@ -815,7 +815,7 @@ private: iterateAndNextNull(nodep->exprp()); bool hit = false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (!itemp->isDefault()) { for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) { if (hit) break; @@ -833,7 +833,7 @@ private: } // Else default match for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { if (hit) break; if (!hit && itemp->isDefault()) { iterateAndNextNull(itemp->bodysp()); @@ -966,11 +966,11 @@ private: badNodeType(nodep); return; } - AstNodeFTask* funcp = VN_CAST(nodep->taskp(), NodeFTask); + AstNodeFTask* funcp = VN_AS(nodep->taskp(), NodeFTask); UASSERT_OBJ(funcp, nodep, "Not linked"); if (m_params) V3Width::widthParamsEdit(funcp); VL_DANGLING(funcp); // Make sure we've sized the function - funcp = VN_CAST(nodep->taskp(), NodeFTask); + funcp = VN_AS(nodep->taskp(), NodeFTask); UASSERT_OBJ(funcp, nodep, "Not linked"); // Apply function call values to function V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index f2a809797..203f863fa 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -185,12 +185,12 @@ class SliceVisitor final : public AstNVisitor { for (int index = 0; index < adtypep->rangep()->elementsConst(); ++index) { // EQ(a,b) -> LOGAND(EQ(ARRAYSEL(a,0), ARRAYSEL(b,0)), ...[1]) AstNodeBiop* clonep - = VN_CAST(nodep->cloneType( - new AstArraySel(nodep->fileline(), - nodep->lhsp()->cloneTree(false), index), - new AstArraySel(nodep->fileline(), - nodep->rhsp()->cloneTree(false), index)), - NodeBiop); + = VN_AS(nodep->cloneType( + new AstArraySel(nodep->fileline(), + nodep->lhsp()->cloneTree(false), index), + new AstArraySel(nodep->fileline(), + nodep->rhsp()->cloneTree(false), index)), + NodeBiop); if (!logp) { logp = clonep; } else { diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 71818e975..9123df814 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -416,7 +416,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { } static int outerMostSizeOfUnpackedArray(const AstVar* nodep) { const AstUnpackArrayDType* const dtypep - = VN_CAST_CONST(nodep->dtypep()->skipRefp(), UnpackArrayDType); + = VN_AS_CONST(nodep->dtypep()->skipRefp(), UnpackArrayDType); UASSERT_OBJ(dtypep, nodep, "Must be unapcked array"); return dtypep->elementsConst(); } @@ -585,7 +585,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { virtual void visit(AstSliceSel* nodep) override { if (AstVarRef* const refp = isTargetVref(nodep->fromp())) { const AstUnpackArrayDType* const dtypep - = VN_CAST(refp->varp()->dtypep()->skipRefp(), UnpackArrayDType); + = VN_AS(refp->varp()->dtypep()->skipRefp(), UnpackArrayDType); // declRange() of AstSliceSel is shifted by dtypep->declRange().lo() in V3WidthSel.cpp // restore the original decl range here. const VNumRange selRange{nodep->declRange().hi() + dtypep->declRange().lo(), @@ -690,7 +690,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { AstVar* const varp = pair.first; AstNode* insertp = varp; const AstUnpackArrayDType* const dtypep - = VN_CAST(varp->dtypep()->skipRefp(), UnpackArrayDType); + = VN_AS(varp->dtypep()->skipRefp(), UnpackArrayDType); AstNodeDType* const subTypep = dtypep->subDTypep(); const bool needNext = VN_IS(subTypep, UnpackArrayDType); // Still unpacked array. std::vector vars; @@ -719,13 +719,13 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { AstUnpackArrayDType* adtypep; int lsb = 0; if (refp) { - adtypep = VN_CAST(refp->dtypep()->skipRefp(), UnpackArrayDType); + adtypep = VN_AS(refp->dtypep()->skipRefp(), UnpackArrayDType); } else { - AstSliceSel* selp = VN_CAST(ref.nodep(), SliceSel); + AstSliceSel* selp = VN_AS(ref.nodep(), SliceSel); UASSERT_OBJ(selp, ref.nodep(), "Unexpected op is registered"); - refp = VN_CAST(selp->fromp(), VarRef); + refp = VN_AS(selp->fromp(), VarRef); UASSERT_OBJ(refp, selp, "Unexpected op is registered"); - adtypep = VN_CAST(selp->dtypep()->skipRefp(), UnpackArrayDType); + adtypep = VN_AS(selp->dtypep()->skipRefp(), UnpackArrayDType); lsb = adtypep->lo(); } AstVarRef* const newrefp diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index a9d422344..9c0536ad8 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -276,7 +276,7 @@ private: } else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) { if (AstVarRef* varrefp = VN_CAST(wordp->lhsp(), VarRef)) { if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) { - const int word = VN_CAST(wordp->rhsp(), Const)->toUInt(); + const int word = VN_AS(wordp->rhsp(), Const)->toUInt(); SubstVarEntry* entryp = getEntryp(varrefp); hit = true; if (m_ops > SUBST_MAX_OPS_SUBST) { diff --git a/src/V3SymTable.h b/src/V3SymTable.h index e7ff1905f..653db2332 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -262,7 +262,7 @@ public: string scopes; for (IdNameMap::iterator it = m_idNameMap.begin(); it != m_idNameMap.end(); ++it) { AstNode* itemp = it->second->nodep(); - if (VN_IS(itemp, Cell) || (VN_IS(itemp, Module) && VN_CAST(itemp, Module)->isTop())) { + if (VN_IS(itemp, Cell) || (VN_IS(itemp, Module) && VN_AS(itemp, Module)->isTop())) { if (scopes != "") scopes += ", "; scopes += AstNode::prettyName(it->first); } diff --git a/src/V3Task.cpp b/src/V3Task.cpp index a4bcff21d..8db34120f 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -118,7 +118,7 @@ private: public: // METHODS AstScope* getScope(AstNodeFTask* nodep) { - AstScope* scopep = VN_CAST(nodep->user3p(), Scope); + AstScope* scopep = VN_AS(nodep->user3p(), Scope); UASSERT_OBJ(scopep, nodep, "No scope for function"); return scopep; } @@ -300,7 +300,7 @@ private: if (nodep->varp()->user2p()) { // It's being converted to an alias. UINFO(9, " relinkVar " << cvtToHex(nodep->varp()->user2p()) << " " << nodep << endl); - AstVarScope* newvscp = VN_CAST(nodep->varp()->user2p(), VarScope); + AstVarScope* newvscp = VN_AS(nodep->varp()->user2p(), VarScope); UASSERT_OBJ(newvscp, nodep, "not linked"); nodep->varScopep(newvscp); nodep->varp(nodep->varScopep()->varp()); @@ -454,7 +454,7 @@ private: AstVarScope* createVarScope(AstVar* invarp, const string& name) { if (invarp->isParam() && VN_IS(invarp->valuep(), InitArray)) { // Move array params in functions into constant pool - return v3Global.rootp()->constPoolp()->findTable(VN_CAST(invarp->valuep(), InitArray)); + return v3Global.rootp()->constPoolp()->findTable(VN_AS(invarp->valuep(), InitArray)); } else { // We could create under either the ref's scope or the ftask's scope. // It shouldn't matter, as they are only local variables. @@ -686,7 +686,7 @@ private: for (AstNode* pinp = refp->pinsp(); pinp; pinp = nextpinp) { nextpinp = pinp->nextp(); // Move pin to the CCall, removing all Arg's - AstNode* exprp = VN_CAST(pinp, Arg)->exprp(); + AstNode* exprp = VN_AS(pinp, Arg)->exprp(); exprp->unlinkFrBack(); ccallp->addArgsp(exprp); } @@ -1015,7 +1015,7 @@ private: for (AstNode* stmtp = cfuncp->argsp(); stmtp; stmtp = stmtp->nextp()) { if (AstVar* portp = VN_CAST(stmtp, Var)) { AstVarScope* portvscp - = VN_CAST(portp->user2p(), VarScope); // Remembered when we created it earlier + = VN_AS(portp->user2p(), VarScope); // Remembered when we created it earlier if (portp->isIO() && !portp->isFuncReturn() && portvscp != rtnvscp && portp->name() != "__Vscopep" // Passed to dpiContext, not callee && portp->name() != "__Vfilenamep" && portp->name() != "__Vlineno") { @@ -1088,7 +1088,7 @@ private: portp->protect(false); // No additional exposure - already part of shown proto if (portp->isIO() && (portp->isWritable() || portp->isFuncReturn()) && !portp->isDpiOpenArray()) { - AstVarScope* portvscp = VN_CAST( + AstVarScope* portvscp = VN_AS( portp->user2p(), VarScope); // Remembered when we created it earlier cfuncp->addStmtsp( createAssignDpiToInternal(portvscp, portp->name() + tmpSuffixp)); @@ -1120,7 +1120,7 @@ private: AstNode::user2ClearTree(); AstVar* rtnvarp = nullptr; if (nodep->isFunction()) { - AstVar* portp = VN_CAST(nodep->fvarp(), Var); + AstVar* portp = VN_AS(nodep->fvarp(), Var); UASSERT_OBJ(portp, nodep, "function without function output variable"); if (!portp->isFuncReturn()) nodep->v3error("Not marked as function return var"); if (nodep->dpiImport() || nodep->dpiExport()) { @@ -1254,7 +1254,7 @@ private: portp->unlinkFrBack(); pushDeletep(portp); AstNode* const tablep = v3Global.rootp()->constPoolp()->findTable( - VN_CAST(portp->valuep(), InitArray)); + VN_AS(portp->valuep(), InitArray)); portp->user2p(tablep); } else { if (portp->isIO()) { @@ -1369,7 +1369,7 @@ private: m_insStmtp->addNextHere(newp); } else if (m_insMode == IM_WHILE_PRECOND) { UINFO(5, " IM_While_Precond " << m_insStmtp << endl); - AstWhile* whilep = VN_CAST(m_insStmtp, While); + AstWhile* whilep = VN_AS(m_insStmtp, While); UASSERT_OBJ(whilep, nodep, "Insert should be under WHILE"); whilep->addPrecondsp(newp); visitp = newp; @@ -1416,7 +1416,7 @@ private: if (nodep->taskp()->isFunction()) { // Not that it's a FUNCREF, but that we're calling a function (perhaps as a task) outvscp - = createVarScope(VN_CAST(nodep->taskp()->fvarp(), Var), namePrefix + "__Vfuncout"); + = createVarScope(VN_AS(nodep->taskp()->fvarp(), Var), namePrefix + "__Vfuncout"); } // Create cloned statements AstNode* beginp; @@ -1605,7 +1605,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) bool reorganize = false; for (AstNode *nextp, *pinp = nodep->pinsp(); pinp; pinp = nextp) { nextp = pinp->nextp(); - AstArg* argp = VN_CAST(pinp, Arg); + AstArg* argp = VN_AS(pinp, Arg); UASSERT_OBJ(argp, pinp, "Non-arg under ftask reference"); if (argp->name() != "") { // By name diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 168ae24d4..0e2eeffb6 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -221,7 +221,7 @@ private: const auto dupit = dupFinder.findDuplicate(nodep->valuep()); if (dupit != dupFinder.end()) { const AstTraceDecl* const dupDeclp - = VN_CAST_CONST(dupit->second->backp(), TraceDecl); + = VN_AS_CONST(dupit->second->backp(), TraceDecl); UASSERT_OBJ(dupDeclp, nodep, "Trace duplicate of wrong type"); TraceTraceVertex* const dupvertexp = dynamic_cast(dupDeclp->user1u().toGraphVertex()); diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 066aa51ce..8019b41da 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -164,7 +164,7 @@ private: // be unlinked as we go while (nextIrp) { AstIntfRef* const irp = nextIrp; - nextIrp = VN_CAST(irp->nextp(), IntfRef); + nextIrp = VN_AS(irp->nextp(), IntfRef); const string irpName = irp->prettyName(); if (scopeLen > irpName.length()) continue; @@ -301,7 +301,7 @@ private: addIgnore("Unsupported: Unpacked struct/union"); } else { for (const AstMemberDType* itemp = nodep->membersp(); itemp; - itemp = VN_CAST_CONST(itemp->nextp(), MemberDType)) { + itemp = VN_AS_CONST(itemp->nextp(), MemberDType)) { AstNodeDType* const subtypep = itemp->subDTypep()->skipRefToEnump(); VL_RESTORER(m_traShowname); VL_RESTORER(m_traValuep); diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 6be7c1621..a48245c84 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -392,7 +392,7 @@ class TristateVisitor final : public TristateBaseVisitor { } invarp->user1p(newp); // find envar given invarp } - return VN_CAST(invarp->user1p(), Var); + return VN_AS(invarp->user1p(), Var); } AstVar* getCreateOutVarp(AstVar* invarp) { @@ -410,7 +410,7 @@ class TristateVisitor final : public TristateBaseVisitor { } invarp->user4p(newp); // find outvar given invarp } - return VN_CAST(invarp->user4p(), Var); + return VN_AS(invarp->user4p(), Var); } AstVar* getCreateUnconnVarp(AstNode* fromp, AstNodeDType* dtypep) { @@ -554,7 +554,7 @@ class TristateVisitor final : public TristateBaseVisitor { outvarp->user3p(invarp->user3p()); // AstPull* propagation if (invarp->user3p()) UINFO(9, "propagate pull to " << outvarp << endl); } else if (invarp->user1p()) { - envarp = VN_CAST(invarp->user1p(), Var); // From CASEEQ, foo === 1'bz + envarp = VN_AS(invarp->user1p(), Var); // From CASEEQ, foo === 1'bz } AstNode* orp = nullptr; @@ -948,7 +948,7 @@ class TristateVisitor final : public TristateBaseVisitor { // 3'b1z0 -> ((3'b101 == in__en) && (3'b100 == in)) varrefp->unlinkFrBack(); FileLine* fl = nodep->fileline(); - V3Number oneIfEn = VN_CAST(constp->user1p(), Const) + V3Number oneIfEn = VN_AS(constp->user1p(), Const) ->num(); // visit(AstConst) already split into en/ones const V3Number& oneIfEnOne = constp->num(); AstVar* envarp = getCreateEnVarp(varrefp->varp()); @@ -989,11 +989,11 @@ class TristateVisitor final : public TristateBaseVisitor { virtual void visit(AstCountBits* nodep) override { std::array dropop; - dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_CAST(nodep->rhsp(), Const)->num().isAnyZ(); - dropop[1] = VN_IS(nodep->thsp(), Const) && VN_CAST(nodep->thsp(), Const)->num().isAnyZ(); - dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_CAST(nodep->fhsp(), Const)->num().isAnyZ(); + dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_AS(nodep->rhsp(), Const)->num().isAnyZ(); + dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyZ(); + dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_AS(nodep->fhsp(), Const)->num().isAnyZ(); UINFO(4, " COUNTBITS(" << dropop[0] << dropop[1] << dropop[2] << " " << nodep << endl); - AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); // Input variable + AstVarRef* varrefp = VN_AS(nodep->lhsp(), VarRef); // Input variable if (m_graphing) { iterateAndNextNull(nodep->lhsp()); if (!dropop[0]) iterateAndNextNull(nodep->rhsp()); @@ -1050,10 +1050,10 @@ class TristateVisitor final : public TristateBaseVisitor { UINFO(9, dbgState() << nodep << endl); AstVarRef* varrefp = nullptr; if (VN_IS(nodep->lhsp(), VarRef)) { - varrefp = VN_CAST(nodep->lhsp(), VarRef); + varrefp = VN_AS(nodep->lhsp(), VarRef); } else if (VN_IS(nodep->lhsp(), Sel) - && VN_IS(VN_CAST(nodep->lhsp(), Sel)->fromp(), VarRef)) { - varrefp = VN_CAST(VN_CAST(nodep->lhsp(), Sel)->fromp(), VarRef); + && VN_IS(VN_AS(nodep->lhsp(), Sel)->fromp(), VarRef)) { + varrefp = VN_AS(VN_AS(nodep->lhsp(), Sel)->fromp(), VarRef); } if (!varrefp) { if (debug() >= 4) nodep->dumpTree(cout, "- "); diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 5ac9b5763..b8a259949 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -108,7 +108,7 @@ private: // Already exists; rather than IF(a,... IF(b... optimize to IF(a&&b, // Saves us teaching V3Const how to optimize, and it won't be needed again. - if (AstIf* ifp = VN_CAST(prep->user2p(), If)) { + if (AstIf* ifp = VN_AS(prep->user2p(), If)) { UASSERT_OBJ(!needDly, prep, "Should have already converted to non-delay"); AstNRelinker replaceHandle; AstNode* earliercondp = ifp->condp()->unlinkFrBack(&replaceHandle); @@ -192,8 +192,8 @@ private: AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* newp; // If we got ==1'bx it can never be true (but 1'bx==1'bx can be!) - if (((VN_IS(lhsp, Const) && VN_CAST(lhsp, Const)->num().isFourState()) - || (VN_IS(rhsp, Const) && VN_CAST(rhsp, Const)->num().isFourState()))) { + if (((VN_IS(lhsp, Const) && VN_AS(lhsp, Const)->num().isFourState()) + || (VN_IS(rhsp, Const) && VN_AS(rhsp, Const)->num().isFourState()))) { newp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), 1, (VN_IS(nodep, EqCase) ? 0 : 1)); VL_DO_DANGLING(lhsp->deleteTree(), lhsp); @@ -231,9 +231,9 @@ private: } else { // X or Z's become mask, ala case statements. V3Number nummask(rhsp, rhsp->width()); - nummask.opBitsNonX(VN_CAST(rhsp, Const)->num()); + nummask.opBitsNonX(VN_AS(rhsp, Const)->num()); V3Number numval(rhsp, rhsp->width()); - numval.opBitsOne(VN_CAST(rhsp, Const)->num()); + numval.opBitsOne(VN_AS(rhsp, Const)->num()); AstNode* and1p = new AstAnd(nodep->fileline(), lhsp, new AstConst(nodep->fileline(), nummask)); AstNode* and2p = new AstConst(nodep->fileline(), numval); @@ -266,9 +266,9 @@ private: virtual void visit(AstCountBits* nodep) override { // Ahh, we're two state, so this is easy std::array dropop; - dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_CAST(nodep->rhsp(), Const)->num().isAnyX(); - dropop[1] = VN_IS(nodep->thsp(), Const) && VN_CAST(nodep->thsp(), Const)->num().isAnyX(); - dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_CAST(nodep->fhsp(), Const)->num().isAnyX(); + dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_AS(nodep->rhsp(), Const)->num().isAnyX(); + dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyX(); + dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_AS(nodep->fhsp(), Const)->num().isAnyX(); UINFO(4, " COUNTBITS(" << dropop[0] << dropop[1] << dropop[2] << " " << nodep << endl); AstNode* nonXp = nullptr; diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index ae5640258..e3353c4c0 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -115,8 +115,8 @@ private: if (!incAssp) return cantUnroll(nodep, "no increment assignment"); if (incAssp->nextp()) return cantUnroll(nodep, "multiple increments"); - m_forVarp = VN_CAST(initAssp->lhsp(), VarRef)->varp(); - m_forVscp = VN_CAST(initAssp->lhsp(), VarRef)->varScopep(); + m_forVarp = VN_AS(initAssp->lhsp(), VarRef)->varp(); + m_forVscp = VN_AS(initAssp->lhsp(), VarRef)->varScopep(); if (VN_IS(nodep, GenFor) && !m_forVarp->isGenVar()) { nodep->v3error("Non-genvar used in generate for: " << m_forVarp->prettyNameQ()); } else if (!VN_IS(nodep, GenFor) && m_forVarp->isGenVar()) { @@ -155,7 +155,7 @@ private: if (debug() >= 9) nodep->dumpTree(cout, "- for: "); if (!m_generate) { - AstAssign* incpAssign = VN_CAST(incp, Assign); + AstAssign* incpAssign = VN_AS(incp, Assign); if (!canSimulate(incpAssign->rhsp())) { return cantUnroll(incp, "Unable to simulate increment"); } @@ -255,7 +255,7 @@ private: outLoopsr++; // Run inc - AstAssign* incpass = VN_CAST(incp, Assign); + AstAssign* incpass = VN_AS(incp, Assign); V3Number newLoopValue = V3Number(initp); if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) { return false; @@ -345,7 +345,7 @@ private: } // loopValue += valInc - AstAssign* incpass = VN_CAST(incp, Assign); + AstAssign* incpass = VN_AS(incp, Assign); V3Number newLoopValue = V3Number(nodep); if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) { nodep->v3error("Loop unrolling failed"); diff --git a/src/V3VariableOrder.cpp b/src/V3VariableOrder.cpp index ea88cd98f..e3df0d1d0 100644 --- a/src/V3VariableOrder.cpp +++ b/src/V3VariableOrder.cpp @@ -200,7 +200,7 @@ public: void V3VariableOrder::orderAll() { UINFO(2, __FUNCTION__ << ": " << endl); for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; - modp = VN_CAST(modp->nextp(), NodeModule)) { + modp = VN_AS(modp->nextp(), NodeModule)) { VariableOrder::processModule(modp); } V3Global::dumpCheckGlobalTree("variableorder", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); diff --git a/src/V3Width.cpp b/src/V3Width.cpp index a3b912670..f52145765 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -928,11 +928,11 @@ private: // Must check bounds before adding a select that truncates the bound // Note we've already subtracted off LSB if (VN_IS(nodep->bitp(), Const) - && (VN_CAST(nodep->bitp(), Const)->toSInt() > (frommsb - fromlsb) - || VN_CAST(nodep->bitp(), Const)->toSInt() < 0)) { + && (VN_AS(nodep->bitp(), Const)->toSInt() > (frommsb - fromlsb) + || VN_AS(nodep->bitp(), Const)->toSInt() < 0)) { nodep->v3warn(SELRANGE, "Selection index out of range: " - << (VN_CAST(nodep->bitp(), Const)->toSInt() + fromlsb) + << (VN_AS(nodep->bitp(), Const)->toSInt() + fromlsb) << " outside " << frommsb << ":" << fromlsb); UINFO(1, " Related node: " << nodep << endl); } @@ -1405,7 +1405,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (VN_IS(nodep->dimp(), Const)) { - const int dim = VN_CAST(nodep->dimp(), Const)->toSInt(); + const int dim = VN_AS(nodep->dimp(), Const)->toSInt(); AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(), nodep->attrType(), dim); nodep->replaceWith(newp); @@ -1657,7 +1657,7 @@ private: // elimination should do much the same // Form: "( ((v > size) ? false : enum_valid[v[N:0]]) // ? ExprStmt(ExprAssign(out, Cast(v, type)), 1) : 0)" - auto* enumDtp = VN_CAST(toDtp, EnumDType); + auto* enumDtp = VN_AS(toDtp, EnumDType); UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type"); uint64_t maxval = enumMaxValue(nodep, enumDtp); const int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit @@ -1817,7 +1817,7 @@ private: UASSERT_OBJ(VN_IS(nodep->rhsp(), Const), nodep, "Unsupported: Non-const cast of size"); // if (debug()) nodep->dumpTree(cout, " CastSizePre: "); if (m_vup->prelim()) { - int width = VN_CAST(nodep->rhsp(), Const)->toSInt(); + int width = VN_AS(nodep->rhsp(), Const)->toSInt(); if (width < 1) { nodep->v3error("Size-changing cast to zero or negative size"); width = 1; @@ -1839,7 +1839,7 @@ private: if (!underDtp) underDtp = underp->dtypep()->basicp(); if (!underDtp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Size-changing cast on non-basic data type"); - underDtp = VN_CAST(nodep->findBitDType(), BasicDType); + underDtp = VN_AS(nodep->findBitDType(), BasicDType); } UASSERT_OBJ(underp == nodep->op1p(), nodep, "Assuming op1 is cast value"); // A cast propagates its size to the lower expression and is included in the maximum @@ -2022,7 +2022,7 @@ private: V3Number one(nodep, nodep->width(), 1); std::map inits; for (AstEnumItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), EnumItem)) { + itemp = VN_AS(itemp->nextp(), EnumItem)) { if (itemp->valuep()) { if (debug() >= 9) { UINFO(0, "EnumInit " << itemp << endl); @@ -2052,7 +2052,7 @@ private: itemp->valuep(new AstConst(itemp->fileline(), num)); } - AstConst* constp = VN_CAST(itemp->valuep(), Const); + AstConst* constp = VN_AS(itemp->valuep(), Const); if (constp->num().isFourState() && nodep->dtypep()->basicp() && !nodep->dtypep()->basicp()->isFourstate()) { itemp->v3error("Enum value with X/Zs cannot be assigned to non-fourstate type " @@ -2102,7 +2102,7 @@ private: } virtual void visit(AstConsAssoc* nodep) override { // Type computed when constructed here - auto* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), AssocArrayDType); + auto* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsAssoc requires assoc upper parent data type"); if (m_vup->prelim()) { nodep->dtypeFrom(vdtypep); @@ -2114,7 +2114,7 @@ private: } virtual void visit(AstSetAssoc* nodep) override { // Type computed when constructed here - auto* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), AssocArrayDType); + auto* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); UASSERT_OBJ(vdtypep, nodep, "SetsAssoc requires assoc upper parent data type"); if (m_vup->prelim()) { nodep->dtypeFrom(vdtypep); @@ -2127,7 +2127,7 @@ private: } virtual void visit(AstConsDynArray* nodep) override { // Type computed when constructed here - AstDynArrayDType* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), DynArrayDType); + AstDynArrayDType* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), DynArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsDynArray requires queue upper parent data type"); if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, PRELIM).p()); @@ -2159,7 +2159,7 @@ private: } virtual void visit(AstConsQueue* nodep) override { // Type computed when constructed here - AstQueueDType* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), QueueDType); + AstQueueDType* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), QueueDType); UASSERT_OBJ(vdtypep, nodep, "ConsQueue requires queue upper parent data type"); if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, PRELIM).p()); @@ -2300,7 +2300,7 @@ private: // MSB is first, so go backwards AstMemberDType* itemp; for (itemp = nodep->membersp(); itemp && itemp->nextp(); - itemp = VN_CAST(itemp->nextp(), MemberDType)) {} + itemp = VN_AS(itemp->nextp(), MemberDType)) {} for (AstMemberDType* backip; itemp; itemp = backip) { if (itemp->isFourstate()) nodep->isFourstate(true); backip = VN_CAST(itemp->backp(), MemberDType); @@ -2456,8 +2456,7 @@ private: // Should check types the method requires, but at present we don't do much userIterate(nodep->fromp(), WidthVP(SELF, BOTH).p()); // Any AstWith is checked later when know types, in methodWithArgument - for (AstArg* argp = VN_CAST(nodep->pinsp(), Arg); argp; - argp = VN_CAST(argp->nextp(), Arg)) { + for (AstArg* argp = VN_CAST(nodep->pinsp(), Arg); argp; argp = VN_AS(argp->nextp(), Arg)) { if (argp->exprp()) userIterate(argp->exprp(), WidthVP(SELF, BOTH).p()); } // Find the fromp dtype - should be a class @@ -2557,16 +2556,16 @@ private: newp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); // Spec doesn't say what to do } else { - newp = VN_CAST(itemp->valuep()->cloneTree(false), Const); // A const + newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const } } else if (nodep->name() == "last") { AstEnumItem* itemp = adtypep->itemsp(); - while (itemp && itemp->nextp()) itemp = VN_CAST(itemp->nextp(), EnumItem); + while (itemp && itemp->nextp()) itemp = VN_AS(itemp->nextp(), EnumItem); if (!itemp) { newp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); // Spec doesn't say what to do } else { - newp = VN_CAST(itemp->valuep()->cloneTree(false), Const); // A const + newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const } } UASSERT_OBJ(newp, nodep, "Enum method (perhaps enum item) not const"); @@ -2588,17 +2587,16 @@ private: if (nodep->name() == "name") { methodOkArguments(nodep, 0, 0); - } else if (nodep->pinsp() && !(VN_IS(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const))) { + } else if (nodep->pinsp() && !(VN_IS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const))) { nodep->pinsp()->v3fatalSrc("Unsupported: enum next/prev with non-const argument"); } else if (nodep->pinsp() - && !(VN_IS(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const) - && VN_CAST(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const)->toUInt() == 1 + && !(VN_IS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const) + && VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt() == 1 && !nodep->pinsp()->nextp())) { // Unroll of enumVar.next(k) to enumVar.next(1).next(k - 1) AstMethodCall* clonep = nodep->cloneTree(false); - VN_CAST(VN_CAST(clonep->pinsp(), Arg)->exprp(), Const)->num().setLong(1); - uint32_t stepWidth - = VN_CAST(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const)->toUInt(); + VN_AS(VN_AS(clonep->pinsp(), Arg)->exprp(), Const)->num().setLong(1); + uint32_t stepWidth = VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt(); AstConst* constp = new AstConst(nodep->fileline(), stepWidth - 1); AstArg* argp = new AstArg(nodep->fileline(), "", constp); AstMethodCall* newp @@ -2727,7 +2725,7 @@ private: iterateCheck(nodep, "index", index_exprp, CONTEXT, FINAL, adtypep->keyDTypep(), EXTEND_EXP); VL_DANGLING(index_exprp); // May have been edited - return VN_CAST(nodep->pinsp(), Arg)->exprp(); + return VN_AS(nodep->pinsp(), Arg)->exprp(); } void methodCallLValueRecurse(AstMethodCall* nodep, AstNode* childp, const VAccess& access) { if (AstNodeVarRef* varrefp = VN_CAST(childp, NodeVarRef)) { @@ -2866,7 +2864,7 @@ private: methodOkArguments(nodep, 2, 2); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); AstNode* index_exprp = methodCallQueueIndexExpr(nodep); - AstArg* argp = VN_CAST(nodep->pinsp()->nextp(), Arg); + AstArg* argp = VN_AS(nodep->pinsp()->nextp(), Arg); iterateCheckTyped(nodep, "insert value", argp->exprp(), adtypep->subDTypep(), BOTH); if (index_exprp->isZero()) { // insert(0, ...) is a push_front newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2889,7 +2887,7 @@ private: } else if (nodep->name() == "push_back" || nodep->name() == "push_front") { methodOkArguments(nodep, 1, 1); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); - AstArg* argp = VN_CAST(nodep->pinsp(), Arg); + AstArg* argp = VN_AS(nodep->pinsp(), Arg); iterateCheckTyped(nodep, "push value", argp->exprp(), adtypep->subDTypep(), BOTH); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), nodep->name(), argp->exprp()->unlinkFrBack()); @@ -2961,10 +2959,10 @@ private: } } AstNode* methodCallQueueIndexExpr(AstMethodCall* nodep) { - AstNode* index_exprp = VN_CAST(nodep->pinsp(), Arg)->exprp(); + AstNode* index_exprp = VN_AS(nodep->pinsp(), Arg)->exprp(); iterateCheckSigned32(nodep, "index", index_exprp, BOTH); VL_DANGLING(index_exprp); // May have been edited - return VN_CAST(nodep->pinsp(), Arg)->exprp(); + return VN_AS(nodep->pinsp(), Arg)->exprp(); } void methodCallClass(AstMethodCall* nodep, AstClassRefDType* adtypep) { // No need to width-resolve the class, as it was done when we did the child @@ -3114,7 +3112,7 @@ private: } else if (nodep->name() == "compare" || nodep->name() == "icompare") { const bool ignoreCase = nodep->name()[0] == 'i'; methodOkArguments(nodep, 1, 1); - AstArg* argp = VN_CAST(nodep->pinsp(), Arg); + AstArg* argp = VN_AS(nodep->pinsp(), Arg); AstNode* lhs = nodep->fromp()->unlinkFrBack(); AstNode* rhs = argp->exprp()->unlinkFrBack(); AstNode* newp = new AstCompareNN(nodep->fileline(), lhs, rhs, ignoreCase); @@ -3122,9 +3120,9 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "putc") { methodOkArguments(nodep, 2, 2); - AstArg* arg0p = VN_CAST(nodep->pinsp(), Arg); - AstArg* arg1p = VN_CAST(arg0p->nextp(), Arg); - AstNodeVarRef* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), VarRef); + AstArg* arg0p = VN_AS(nodep->pinsp(), Arg); + AstArg* arg1p = VN_AS(arg0p->nextp(), Arg); + AstNodeVarRef* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef); AstNode* rhsp = arg0p->exprp()->unlinkFrBack(); AstNode* thsp = arg1p->exprp()->unlinkFrBack(); AstVarRef* varrefp = new AstVarRef(nodep->fileline(), fromp->varp(), VAccess::READ); @@ -3135,7 +3133,7 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "getc") { methodOkArguments(nodep, 1, 1); - AstArg* arg0p = VN_CAST(nodep->pinsp(), Arg); + AstArg* arg0p = VN_AS(nodep->pinsp(), Arg); AstNode* lhsp = nodep->fromp()->unlinkFrBack(); AstNode* rhsp = arg0p->exprp()->unlinkFrBack(); AstNode* newp = new AstGetcN(nodep->fileline(), lhsp, rhsp); @@ -3143,8 +3141,8 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "substr") { methodOkArguments(nodep, 2, 2); - AstArg* arg0p = VN_CAST(nodep->pinsp(), Arg); - AstArg* arg1p = VN_CAST(arg0p->nextp(), Arg); + AstArg* arg0p = VN_AS(nodep->pinsp(), Arg); + AstArg* arg1p = VN_AS(arg0p->nextp(), Arg); AstNode* lhsp = nodep->fromp()->unlinkFrBack(); AstNode* rhsp = arg0p->exprp()->unlinkFrBack(); AstNode* thsp = arg1p->exprp()->unlinkFrBack(); @@ -3278,8 +3276,8 @@ private: nodep->dtypep(dtypep); // Determine replication count, and replicate initial value as // widths need to be individually determined - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { const int times = visitPatMemberRep(patp); for (int i = 1; i < times; i++) { AstNode* newp = patp->cloneTree(false); @@ -3288,8 +3286,8 @@ private: } } // Convert any PatMember with multiple items to multiple PatMembers - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { if (patp->lhssp()->nextp()) { // Can't just addNext, as would add to end of all members. // So detach, add next and reattach @@ -3307,8 +3305,8 @@ private: } } AstPatMember* defaultp = nullptr; - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { if (patp->isDefault()) { if (defaultp) nodep->v3error("Multiple '{ default: } clauses"); defaultp = patp; @@ -3331,7 +3329,7 @@ private: VL_DO_DANGLING(patternDynArray(nodep, vdtypep, defaultp), nodep); } else if (auto* vdtypep = VN_CAST(dtypep, QueueDType)) { VL_DO_DANGLING(patternQueue(nodep, vdtypep, defaultp), nodep); - } else if (VN_IS(dtypep, BasicDType) && VN_CAST(dtypep, BasicDType)->isRanged()) { + } else if (VN_IS(dtypep, BasicDType) && VN_AS(dtypep, BasicDType)->isRanged()) { VL_DO_DANGLING(patternBasic(nodep, dtypep, defaultp), nodep); } else { nodep->v3warn( @@ -3385,18 +3383,18 @@ private: std::pair ret = patmap.emplace(memp, patp); if (!ret.second) { patp->v3error("Assignment pattern contains duplicate entry: " - << VN_CAST(patp->keyp(), Text)->text()); + << VN_AS(patp->keyp(), Text)->text()); } } } while (false); // Next - if (memp) memp = VN_CAST(memp->nextp(), MemberDType); - if (patp) patp = VN_CAST(patp->nextp(), PatMember); + if (memp) memp = VN_AS(memp->nextp(), MemberDType); + if (patp) patp = VN_AS(patp->nextp(), PatMember); } } AstNode* newp = nullptr; for (AstMemberDType* memp = vdtypep->membersp(); memp; - memp = VN_CAST(memp->nextp(), MemberDType)) { + memp = VN_AS(memp->nextp(), MemberDType)) { const auto it = patmap.find(memp); AstPatMember* newpatp = nullptr; AstPatMember* patp = nullptr; @@ -3467,7 +3465,7 @@ private: = new AstInitArray(nodep->fileline(), arrayDtp, nullptr); newp = newap; } - VN_CAST(newp, InitArray)->addIndexValuep(ent - range.lo(), valuep); + VN_AS(newp, InitArray)->addIndexValuep(ent - range.lo(), valuep); } else { // Packed. Convert to concat for now. if (!newp) { newp = valuep; @@ -3496,8 +3494,8 @@ private: if (defaultp) defaultValuep = defaultp->lhssp()->unlinkFrBack(); AstNode* newp = new AstConsAssoc(nodep->fileline(), defaultValuep); newp->dtypeFrom(arrayDtp); - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { patp->dtypep(arrayDtp->subDTypep()); AstNode* valuep = patternMemberValueIterate(patp); AstNode* keyp = patp->keyp(); @@ -3512,8 +3510,8 @@ private: void patternDynArray(AstPattern* nodep, AstDynArrayDType* arrayp, AstPatMember*) { AstNode* newp = new AstConsDynArray(nodep->fileline()); newp->dtypeFrom(arrayp); - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { patp->dtypep(arrayp->subDTypep()); AstNode* valuep = patternMemberValueIterate(patp); auto* newap = new AstConsDynArray(nodep->fileline(), valuep, newp); @@ -3527,8 +3525,8 @@ private: void patternQueue(AstPattern* nodep, AstQueueDType* arrayp, AstPatMember*) { AstNode* newp = new AstConsQueue(nodep->fileline()); newp->dtypeFrom(arrayp); - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { patp->dtypep(arrayp->subDTypep()); AstNode* valuep = patternMemberValueIterate(patp); auto* newap = new AstConsQueue(nodep->fileline(), valuep, newp); @@ -3540,7 +3538,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); // Deletes defaultp also, if present } void patternBasic(AstPattern* nodep, AstNodeDType* vdtypep, AstPatMember* defaultp) { - AstBasicDType* bdtypep = VN_CAST(vdtypep, BasicDType); + AstBasicDType* bdtypep = VN_AS(vdtypep, BasicDType); const VNumRange range = bdtypep->declRange(); PatVecMap patmap = patVectorMap(nodep, range); UINFO(9, "ent " << range.hi() << " to " << range.lo() << endl); @@ -3596,7 +3594,7 @@ private: if (VN_IS(valuep, Const)) { // Forming a AstConcat will cause problems with // unsized (uncommitted sized) constants - if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(VN_CAST(valuep, Const))) { + if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(VN_AS(valuep, Const))) { VL_DO_DANGLING(pushDeletep(valuep), valuep); valuep = newp; } @@ -3660,8 +3658,7 @@ private: assertAtStatement(nodep); userIterateAndNext(nodep->exprp(), WidthVP(CONTEXT, PRELIM).p()); for (AstCaseItem *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) { - nextip - = VN_CAST(itemp->nextp(), CaseItem); // Prelim may cause the node to get replaced + nextip = VN_AS(itemp->nextp(), CaseItem); // Prelim may cause the node to get replaced if (!VN_IS(nodep, GenCase)) userIterateAndNext(itemp->bodysp(), nullptr); for (AstNode *nextcp, *condp = itemp->condsp(); condp; condp = nextcp) { nextcp = condp->nextp(); // Prelim may cause the node to get replaced @@ -3672,7 +3669,7 @@ private: // Take width as maximum across all items, if any is real whole thing is real AstNodeDType* subDTypep = nodep->exprp()->dtypep(); for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* condp = itemp->condsp(); condp; condp = condp->nextp()) { if (condp->dtypep() != subDTypep) { if (condp->dtypep()->isDouble()) { @@ -3691,7 +3688,7 @@ private: iterateCheck(nodep, "Case expression", nodep->exprp(), CONTEXT, FINAL, subDTypep, EXTEND_LHS); for (AstCaseItem* itemp = nodep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), CaseItem)) { + itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode *nextcp, *condp = itemp->condsp(); condp; condp = nextcp) { nextcp = condp->nextp(); // Final may cause the node to get replaced iterateCheck(nodep, "Case Item", condp, CONTEXT, FINAL, subDTypep, EXTEND_LHS); @@ -4336,7 +4333,7 @@ private: // Pretend it's void so less special casing needed when look at dtypes nodep->dtypeSetVoid(); } else if (nodep->fvarp()) { - m_funcp = VN_CAST(nodep, Func); + m_funcp = VN_AS(nodep, Func); UASSERT_OBJ(m_funcp, nodep, "FTask with function variable, but isn't a function"); nodep->dtypeFrom(nodep->fvarp()); // Which will get it from fvarp()->dtypep() } @@ -4368,7 +4365,7 @@ private: } virtual void visit(AstFuncRef* nodep) override { - visit(VN_CAST(nodep, NodeFTaskRef)); + visit(VN_AS(nodep, NodeFTaskRef)); nodep->dtypeFrom(nodep->taskp()); // if (debug()) nodep->dumpTree(cout, " FuncOut: "); } @@ -4437,7 +4434,7 @@ private: AstNRelinker handle; argp->unlinkFrBackWithNext(&handle); // Format + additional args, if any AstNode* argsp = nullptr; - while (AstArg* nextargp = VN_CAST(argp->nextp(), Arg)) { + while (AstArg* nextargp = VN_AS(argp->nextp(), Arg)) { argsp = AstNode::addNext( argsp, nextargp->exprp() ->unlinkFrBackWithNext()); // Expression goes to SFormatF @@ -4445,7 +4442,7 @@ private: } string format; if (VN_IS(pinp, Const)) { - format = VN_CAST(pinp, Const)->num().toString(); + format = VN_AS(pinp, Const)->num().toString(); } else { pinp->v3error( "Format to $display-like function must have constant format string"); @@ -4464,7 +4461,7 @@ private: && !VN_IS(pinp, SFormatF) // Already generates a string && !VN_IS(portp->dtypep(), UnpackArrayDType) // Unpacked array must match && !(VN_IS(pinp, VarRef) - && VN_CAST(pinp, VarRef)->varp()->basicp()->keyword() + && VN_AS(pinp, VarRef)->varp()->basicp()->keyword() == AstBasicDTypeKwd::STRING)) { UINFO(4, " Add CvtPackString: " << pinp << endl); AstNRelinker handle; @@ -5275,7 +5272,7 @@ private: UASSERT_OBJ(stage == FINAL, nodep, "Bad width call"); // We iterate and size the RHS based on the result of RHS evaluation bool lhsStream - = (VN_IS(nodep, NodeAssign) && VN_IS(VN_CAST(nodep, NodeAssign)->lhsp(), NodeStream)); + = (VN_IS(nodep, NodeAssign) && VN_IS(VN_AS(nodep, NodeAssign)->lhsp(), NodeStream)); rhsp = iterateCheck(nodep, side, rhsp, ASSIGN, FINAL, lhsDTypep, lhsStream ? EXTEND_OFF : EXTEND_LHS); // if (debug()) nodep->dumpTree(cout, "-checkout: "); @@ -5305,7 +5302,7 @@ private: linker.relink(newp); } else if (VN_IS(underp->dtypep(), ClassRefDType) || (VN_IS(underp->dtypep(), BasicDType) - && VN_CAST(underp->dtypep(), BasicDType)->keyword() + && VN_AS(underp->dtypep(), BasicDType)->keyword() == AstBasicDTypeKwd::CHANDLE)) { // Allow warning-free "if (handle)" VL_DO_DANGLING(fixWidthReduce(underp), underp); // Changed @@ -5438,7 +5435,7 @@ private: underp = nullptr; // Changes underp return; } - if (VN_IS(underp, Const) && VN_CAST(underp, Const)->num().isFromString() + if (VN_IS(underp, Const) && VN_AS(underp, Const)->num().isFromString() && expWidth > underp->width() && (((expWidth - underp->width()) % 8) == 0)) { // At least it's character sized // reg [31:0] == "foo" we'll consider probably fine. @@ -5704,7 +5701,7 @@ private: nodep->v3error("Argument needed for string." + nodep->prettyName() + " method"); return; } - AstNodeVarRef* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), VarRef); + AstNodeVarRef* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef); AstNode* newp = new AstAssign( nodep->fileline(), fromp, new AstSFormatF(nodep->fileline(), format, false, argp->exprp()->unlinkFrBack())); @@ -5860,8 +5857,8 @@ private: // a map for when the value is many bits and sparse. uint64_t maxval = 0; for (const AstEnumItem* itemp = adtypep->itemsp(); itemp; - itemp = VN_CAST(itemp->nextp(), EnumItem)) { - const AstConst* vconstp = VN_CAST(itemp->valuep(), Const); + itemp = VN_AS(itemp->nextp(), EnumItem)) { + const AstConst* vconstp = VN_AS(itemp->valuep(), Const); UASSERT_OBJ(vconstp, errNodep, "Enum item without constified value"); if (vconstp->toUQuad() >= maxval) maxval = vconstp->toUQuad(); } @@ -5923,10 +5920,10 @@ private: { AstEnumItem* firstp = nodep->itemsp(); AstEnumItem* prevp = firstp; // Prev must start with last item - while (prevp->nextp()) prevp = VN_CAST(prevp->nextp(), EnumItem); + while (prevp->nextp()) prevp = VN_AS(prevp->nextp(), EnumItem); for (AstEnumItem* itemp = firstp; itemp;) { - AstEnumItem* nextp = VN_CAST(itemp->nextp(), EnumItem); - const AstConst* vconstp = VN_CAST(itemp->valuep(), Const); + AstEnumItem* nextp = VN_AS(itemp->nextp(), EnumItem); + const AstConst* vconstp = VN_AS(itemp->valuep(), Const); UASSERT_OBJ(vconstp, nodep, "Enum item without constified value"); uint32_t i = vconstp->toUInt(); if (attrType == AstAttrType::ENUM_NAME) { @@ -5956,8 +5953,8 @@ private: PatVecMap patVectorMap(AstPattern* nodep, const VNumRange& range) { PatVecMap patmap; int element = range.left(); - for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp; - patp = VN_CAST(patp->nextp(), PatMember)) { + for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; + patp = VN_AS(patp->nextp(), PatMember)) { if (patp->keyp()) { if (const AstConst* constp = VN_CAST(patp->keyp(), Const)) { element = constp->toSInt(); @@ -6052,11 +6049,11 @@ private: } else if (VN_IS(toDtp, EnumDType)) { if (fromNumericable) return DYNAMIC_ENUM; } else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromConstp, Const)) { - if (VN_IS(fromConstp, Const) && VN_CAST(fromConstp, Const)->num().isNull()) + if (VN_IS(fromConstp, Const) && VN_AS(fromConstp, Const)->num().isNull()) return COMPATIBLE; } else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromDtp, ClassRefDType)) { - const auto toClassp = VN_CAST(toDtp, ClassRefDType)->classp(); - const auto fromClassp = VN_CAST(fromDtp, ClassRefDType)->classp(); + const auto toClassp = VN_AS(toDtp, ClassRefDType)->classp(); + const auto fromClassp = VN_AS(fromDtp, ClassRefDType)->classp(); const bool downcast = AstClass::isClassExtendedFrom(toClassp, fromClassp); const bool upcast = AstClass::isClassExtendedFrom(fromClassp, toClassp); if (upcast) { diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index 7aeeeb416..77514ff3b 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -203,7 +203,7 @@ private: iterateChildren(nodep); editDType(nodep); if (nodep->classMethod() && nodep->pureVirtual() && VN_IS(m_modp, Class) - && !VN_CAST(m_modp, Class)->isVirtual()) { + && !VN_AS(m_modp, Class)->isVirtual()) { nodep->v3error( "Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2017 8.21)"); } diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index c1e77fd74..6a4ff4289 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -75,7 +75,7 @@ private: VNumRange fromRange; // constructs to isRanged(false) while (basefromp) { if (VN_IS(basefromp, AttrOf)) { - basefromp = VN_CAST(basefromp, AttrOf)->fromp(); + basefromp = VN_AS(basefromp, AttrOf)->fromp(); continue; } break; @@ -120,7 +120,7 @@ private: } else if (VN_IS(lhsp, Const)) { // Optional vs just making add/sub below, but saves constification some work V3Number num(lhsp, lhsp->width()); - num.opSub(VN_CAST(lhsp, Const)->num(), V3Number(lhsp, 32, rhs)); + num.opSub(VN_AS(lhsp, Const)->num(), V3Number(lhsp, 32, rhs)); num.isSigned(lhsp->isSigned()); AstNode* newp = new AstConst(lhsp->fileline(), num); return newp; @@ -189,7 +189,7 @@ private: } void warnTri(AstNode* nodep) { - if (VN_IS(nodep, Const) && VN_CAST(nodep, Const)->num().isFourState()) { + if (VN_IS(nodep, Const) && VN_AS(nodep, Const)->num().isFourState()) { nodep->v3error( "Selection index is constantly unknown or tristated: " << nodep->name()); } @@ -332,8 +332,8 @@ private: AstNode* fromp = nodep->fromp()->unlinkFrBack(); AstNode* msbp = nodep->rhsp()->unlinkFrBack(); AstNode* lsbp = nodep->thsp()->unlinkFrBack(); - vlsint32_t msb = VN_CAST(msbp, Const)->toSInt(); - vlsint32_t lsb = VN_CAST(lsbp, Const)->toSInt(); + vlsint32_t msb = VN_AS(msbp, Const)->toSInt(); + vlsint32_t lsb = VN_AS(lsbp, Const)->toSInt(); vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1); const FromData fromdata = fromDataForArray(nodep, fromp); AstNodeDType* ddtypep = fromdata.m_dtypep; @@ -479,7 +479,7 @@ private: AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* widthp = nodep->thsp()->unlinkFrBack(); warnTri(rhsp); - const int width = VN_CAST(widthp, Const)->toSInt(); + const int width = VN_AS(widthp, Const)->toSInt(); if (width > (1 << 28)) { nodep->v3error("Width of :+ or :- is huge; vector of over 1billion bits: " << widthp->prettyName()); @@ -491,7 +491,7 @@ private: if (VN_IS(ddtypep, UnpackArrayDType)) { // Slice +: and -: extraction if (fromRange.elements() == width && VN_IS(rhsp, Const) - && VN_CAST(rhsp, Const)->toSInt() + && VN_AS(rhsp, Const)->toSInt() == fromRange.lo()) { // Extracting whole of original array nodep->replaceWith(fromp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -500,7 +500,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(rhsp, Const)) { // Slice - vlsint32_t rhs = VN_CAST(rhsp, Const)->toSInt(); + vlsint32_t rhs = VN_AS(rhsp, Const)->toSInt(); // down array: lsb/lo +: width // down array: msb/hi -: width // up array: msb/lo +: width @@ -516,7 +516,7 @@ private: } } else if (VN_IS(ddtypep, BasicDType) || VN_IS(ddtypep, PackArrayDType) || (VN_IS(ddtypep, NodeUOrStructDType) - && VN_CAST(ddtypep, NodeUOrStructDType)->packedUnsup())) { + && VN_AS(ddtypep, NodeUOrStructDType)->packedUnsup())) { int elwidth = 1; AstNode* newwidthp = widthp; if (const AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) { From 7cb6dc664e8531fc11ef95dbcfcefc8be7fbcfec Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 22 Oct 2021 19:02:45 +0100 Subject: [PATCH 07/79] Generate YYSTYPE members with astgen In preparation for strengthening Ast type system. No functional change. --- src/V3ParseImp.h | 30 +----------- src/astgen | 7 +++ src/verilog.y | 120 +++++++++++++++++++++++------------------------ 3 files changed, 68 insertions(+), 89 deletions(-) diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index d42e87b4c..38949ddc5 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -122,35 +122,7 @@ struct V3ParseBisonYYSType { AstAttrType::en attrtypeen; VLifetime::en lifetime; - AstNode* nodep; - - AstBasicDType* bdtypep; - AstBegin* beginp; - AstCase* casep; - AstCaseItem* caseitemp; - AstCell* cellp; - AstClass* classp; - AstConst* constp; - AstFork* forkp; - AstFunc* funcp; - AstMemberDType* memberp; - AstNodeModule* modulep; - AstNodeUOrStructDType* uorstructp; - AstNodeDType* dtypep; - AstNodeFTask* ftaskp; - AstNodeFTaskRef* ftaskrefp; - AstNodeRange* rangep; - AstSenItem* senitemp; - AstNodeVarRef* varnodep; - AstPackage* packagep; - AstParseRef* parserefp; - AstPatMember* patmemberp; - AstPattern* patternp; - AstPin* pinp; - AstRefDType* refdtypep; - AstSenTree* sentreep; - AstVar* varp; - AstVarRef* varrefp; +#include "V3Ast__gen_yystype.h" }; }; std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs); diff --git a/src/astgen b/src/astgen index 6328e4adc..0c4bb5cab 100755 --- a/src/astgen +++ b/src/astgen @@ -592,6 +592,12 @@ def write_types(filename): fh.write(" }\n") +def write_yystype(filename): + with open_file(filename) as fh: + for typen in sorted(Classes.keys()): + fh.write("Ast{t}* {m}p;\n".format(t=typen, m=typen[0].lower() + typen[1:])) + + def write_macros(filename): with open_file(filename) as fh: typen = "None" @@ -683,6 +689,7 @@ if Args.classes: write_visitor("V3Ast__gen_visitor.h") write_impl("V3Ast__gen_impl.h") write_types("V3Ast__gen_types.h") + write_yystype("V3Ast__gen_yystype.h") write_macros("V3AstNodes__gen_macros.h") for cpt in Args.infiles: diff --git a/src/verilog.y b/src/verilog.y index 39f45bb57..8cca67a2c 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1055,7 +1055,7 @@ package_declaration: // ==IEEE: package_declaration GRAMMARP->endLabel($4,$1,$4); } ; -packageFront: +packageFront: yPACKAGE lifetimeE idAny ';' { $$ = new AstPackage($3, *$3); $$->inLibrary(true); // packages are always libraries; don't want to make them a "top" @@ -1178,7 +1178,7 @@ module_declaration: // ==IEEE: module_declaration { BBUNSUP($1, "Unsupported: extern module"); } ; -modFront: +modFront: // // General note: all *Front functions must call symPushNew before // // any formal arguments, as the arguments must land in the new scope. yMODULE lifetimeE idAny @@ -1199,7 +1199,7 @@ importsAndParametersE: // IEEE: common part of module_declaration, interf | package_import_declarationList parameter_port_listE { $$ = $1->addNextNull($2); } ; -udpFront: +udpFront: yPRIMITIVE lifetimeE idAny { $$ = new AstPrimitive($3, *$3); $$->inLibrary(true); $$->lifetime($2); @@ -1413,7 +1413,7 @@ interface_declaration: // IEEE: interface_declaration + interface_nonansi_heade { BBUNSUP($1, "Unsupported: extern interface"); } ; -intFront: +intFront: yINTERFACE lifetimeE idAny/*new_interface*/ { $$ = new AstIface($3, *$3); $$->inLibrary(true); @@ -1505,7 +1505,7 @@ program_declaration: // IEEE: program_declaration + program_nonansi_header + pr SYMP->popScope($2); } ; -pgmFront: +pgmFront: yPROGRAM lifetimeE idAny/*new_program*/ { $$ = new AstModule($3, *$3, true); $$->lifetime($2); @@ -1686,7 +1686,7 @@ net_scalaredE: | yVECTORED { } ; -net_dataTypeE: +net_dataTypeE: // // If there's a SV data type there shouldn't be a delay on this wire // // Otherwise #(...) can't be determined to be a delay or parameters // // Submit this as a footnote to the committee @@ -1777,7 +1777,7 @@ tf_port_declaration: // ==IEEE: tf_port_declaration | port_directionReset yVAR implicit_typeE { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; } ; -integer_atom_type: // ==IEEE: integer_atom_type +integer_atom_type: // ==IEEE: integer_atom_type yBYTE { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BYTE); } | ySHORTINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::SHORTINT); } | yINT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::INT); } @@ -1786,13 +1786,13 @@ integer_atom_type: // ==IEEE: integer_atom_type | yTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::TIME); } ; -integer_vector_type: // ==IEEE: integer_atom_type +integer_vector_type: // ==IEEE: integer_atom_type yBIT { $$ = new AstBasicDType($1,AstBasicDTypeKwd::BIT); } | yLOGIC { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LOGIC); } | yREG { $$ = new AstBasicDType($1,AstBasicDTypeKwd::LOGIC); } // logic==reg ; -non_integer_type: // ==IEEE: non_integer_type +non_integer_type: // ==IEEE: non_integer_type yREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); } | yREALTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); } | ySHORTREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); UNSUPREAL($1); } @@ -1811,7 +1811,7 @@ signing: // ==IEEE: signing //************************************************ // Data Types -simple_type: // ==IEEE: simple_type +simple_type: // ==IEEE: simple_type // // IEEE: integer_type integer_atom_type { $$ = $1; } | integer_vector_type { $$ = $1; } @@ -1828,7 +1828,7 @@ simple_type: // ==IEEE: simple_type // // Need to determine if generate_block_identifier can be lex-detected ; -data_type: // ==IEEE: data_type +data_type: // ==IEEE: data_type // // This expansion also replicated elsewhere, IE data_type__AndID data_typeNoRef { $$ = $1; } // @@ -1846,13 +1846,13 @@ data_type: // ==IEEE: data_type $$ = GRAMMARP->createArray(refp, $4, true); } ; -data_typeBasic: // IEEE: part of data_type +data_typeBasic: // IEEE: part of data_type integer_vector_type signingE rangeListE { $1->setSignedState($2); $$ = GRAMMARP->addRange($1,$3,true); } | integer_atom_type signingE { $1->setSignedState($2); $$ = $1; } | non_integer_type { $$ = $1; } ; -data_typeNoRef: // ==IEEE: data_type, excluding class_type etc references +data_typeNoRef: // ==IEEE: data_type, excluding class_type etc references data_typeBasic { $$ = $1; } | struct_unionDecl packed_dimensionListE { $$ = GRAMMARP->createArray(new AstDefImplicitDType($1->fileline(),"__typeimpsu"+cvtToStr(GRAMMARP->s_modTypeImpNum++), SYMP,VFlagChildDType(),$1),$2,true); } @@ -1878,32 +1878,32 @@ data_typeNoRef: // ==IEEE: data_type, excluding class_type etc referenc // // IEEE: ps_covergroup: see data_type above ; -data_type_or_void: // ==IEEE: data_type_or_void +data_type_or_void: // ==IEEE: data_type_or_void data_type { $$ = $1; } //UNSUP yVOID { UNSUP } // No yTAGGED structures ; -var_data_type: // ==IEEE: var_data_type +var_data_type: // ==IEEE: var_data_type data_type { $$ = $1; } | yVAR data_type { $$ = $2; } | yVAR implicit_typeE { $$ = $2; } ; -type_reference: // ==IEEE: type_reference +type_reference: // ==IEEE: type_reference yTYPE '(' exprOrDataType ')' { $$ = new AstRefDType($1, AstRefDType::FlagTypeOfExpr(), $3); } ; -struct_unionDecl: // IEEE: part of data_type +struct_unionDecl: // IEEE: part of data_type // // packedSigningE is NOP for unpacked ySTRUCT packedSigningE '{' - /*mid*/ { $$ = new AstStructDType($1, $2); SYMP->pushNew($$); } + /*mid*/ { $$ = new AstStructDType($1, $2); SYMP->pushNew($$); } /*cont*/ struct_union_memberList '}' - { $$ = $4; $$->addMembersp($5); SYMP->popScope($$); } + { $$ = $4; $$->addMembersp($5); SYMP->popScope($$); } | yUNION taggedE packedSigningE '{' - /*mid*/ { $$ = new AstUnionDType($1, $3); SYMP->pushNew($$); } + /*mid*/ { $$ = new AstUnionDType($1, $3); SYMP->pushNew($$); } /*cont*/ struct_union_memberList '}' - { $$ = $5; $$->addMembersp($6); SYMP->popScope($$); } + { $$ = $5; $$->addMembersp($6); SYMP->popScope($$); } ; struct_union_memberList: // IEEE: { struct_union_member } @@ -1924,7 +1924,7 @@ list_of_member_decl_assignments: // Derived from IEEE: list_of_variable_d | list_of_member_decl_assignments ',' member_decl_assignment { $$ = $1->addNextNull($3); } ; -member_decl_assignment: // Derived from IEEE: variable_decl_assignment +member_decl_assignment: // Derived from IEEE: variable_decl_assignment // // At present we allow only packed structures/unions. So this is different from variable_decl_assignment id variable_dimensionListE { if ($2) $2->v3warn(UNPACKED, "Unsupported: Unpacked array in packed struct/union (struct/union converted to unpacked)"); @@ -1991,17 +1991,17 @@ variable_declExpr: // IEEE: part of variable_decl_assignment - rhs of ex | class_new { $$ = $1; } ; -variable_dimensionListE: // IEEE: variable_dimension + empty +variable_dimensionListE: // IEEE: variable_dimension + empty /*empty*/ { $$ = nullptr; } | variable_dimensionList { $$ = $1; } ; -variable_dimensionList: // IEEE: variable_dimension + empty +variable_dimensionList: // IEEE: variable_dimension + empty variable_dimension { $$ = $1; } | variable_dimensionList variable_dimension { $$ = VN_CAST($1->addNext($2), NodeRange); } ; -variable_dimension: // ==IEEE: variable_dimension +variable_dimension: // ==IEEE: variable_dimension // // IEEE: unsized_dimension '[' ']' { $$ = new AstUnsizedRange($1); } // // IEEE: unpacked_dimension @@ -2044,11 +2044,11 @@ packedSigningE: // enum // IEEE: part of data_type -enumDecl: +enumDecl: yENUM enum_base_typeE '{' enum_nameList '}' { $$ = new AstEnumDType($1,VFlagChildDType(),$2,$4); } ; -enum_base_typeE: // IEEE: enum_base_type +enum_base_typeE: // IEEE: enum_base_type /* empty */ { $$ = new AstBasicDType(CRELINE(), AstBasicDTypeKwd::INT); } // // Not in spec, but obviously "enum [1:0]" should work // // implicit_type expanded, without empty @@ -2190,7 +2190,7 @@ data_declarationVarFrontClass: // IEEE: part of data_declaration (for class_prop //UNSUP | yNETTYPE packageClassScope id/*net_type_identifier*/ idAny/*net_type_identifier*/ ';' { } //UNSUP ; -implicit_typeE: // IEEE: part of *data_type_or_implicit +implicit_typeE: // IEEE: part of *data_type_or_implicit // // Also expanded in data_declaration /* empty */ { $$ = nullptr; } | signingE rangeList { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1),$2,true); } @@ -2661,12 +2661,12 @@ sigAttr: | yVL_SPLIT_VAR { $$ = new AstAttrOf($1,AstAttrType::VAR_SPLIT_VAR); } ; -rangeListE: // IEEE: [{packed_dimension}] +rangeListE: // IEEE: [{packed_dimension}] /* empty */ { $$ = nullptr; } | rangeList { $$ = $1; } ; -rangeList: // IEEE: {packed_dimension} +rangeList: // IEEE: {packed_dimension} anyrange { $$ = $1; } | rangeList anyrange { $$ = $1; $1->addNext($2); } ; @@ -2679,21 +2679,21 @@ rangeList: // IEEE: {packed_dimension} // IEEE: select // Merged into more general idArray -anyrange: +anyrange: '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); } ; -packed_dimensionListE: // IEEE: [{ packed_dimension }] +packed_dimensionListE: // IEEE: [{ packed_dimension }] /* empty */ { $$ = nullptr; } | packed_dimensionList { $$ = $1; } ; -packed_dimensionList: // IEEE: { packed_dimension } +packed_dimensionList: // IEEE: { packed_dimension } packed_dimension { $$ = $1; } | packed_dimensionList packed_dimension { $$ = VN_CAST($1->addNext($2), NodeRange); } ; -packed_dimension: // ==IEEE: packed_dimension +packed_dimension: // ==IEEE: packed_dimension anyrange { $$ = $1; } | '[' ']' { $$ = nullptr; BBUNSUP($1, "Unsupported: [] dimensions"); } @@ -2810,17 +2810,17 @@ instnameParen: // // It also breaks allowing "id foo;" instantiation syntax. ; -instRangeListE: +instRangeListE: /* empty */ { $$ = nullptr; } | instRangeList { $$ = $1; } ; -instRangeList: +instRangeList: instRange { $$ = $1; } | instRangeList instRange { $$ = VN_CAST($1->addNextNull($2), Range); } ; -instRange: +instRange: '[' constExpr ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstSub($1, $2, new AstConst($1, 1))); } | '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); } ; @@ -2886,18 +2886,18 @@ cellpinItemE: // IEEE: named_port_connection + empty //************************************************ // EventControl lists -attr_event_controlE: +attr_event_controlE: /* empty */ { $$ = nullptr; } | attr_event_control { $$ = $1; } ; -attr_event_control: // ==IEEE: event_control +attr_event_control: // ==IEEE: event_control '@' '(' event_expression ')' { $$ = new AstSenTree($1,$3); } | '@' '(' '*' ')' { $$ = nullptr; } | '@' '*' { $$ = nullptr; } ; -event_control: // ==IEEE: event_control +event_control: // ==IEEE: event_control '@' '(' event_expression ')' { $$ = new AstSenTree($1,$3); } | '@' '(' '*' ')' { $$ = nullptr; } | '@' '*' { $$ = nullptr; } @@ -2914,7 +2914,7 @@ event_control: // ==IEEE: event_control //UNSUP '@' idClassSel '(' list_of_argumentsE ')' { } ; -event_expression: // IEEE: event_expression - split over several +event_expression: // IEEE: event_expression - split over several //UNSUP // Below are all removed senitem { $$ = $1; } | event_expression yOR senitem { $$ = VN_CAST($1->addNextNull($3), SenItem); } @@ -2924,7 +2924,7 @@ event_expression: // IEEE: event_expression - split over several //UNSUP event_expression ',' ev_expr %prec yOR { $$ = VN_CAST($1->addNextNull($3), SenItem); } ; -senitem: // IEEE: part of event_expression, non-'OR' ',' terms +senitem: // IEEE: part of event_expression, non-'OR' ',' terms senitemEdge { $$ = $1; } | senitemVar { $$ = $1; } | '(' senitem ')' { $$ = $2; } @@ -2937,11 +2937,11 @@ senitem: // IEEE: part of event_expression, non-'OR' ',' terms | yaFLOATNUM { $$ = nullptr; } ; -senitemVar: +senitemVar: idClassSel { $$ = new AstSenItem($1->fileline(), VEdgeType::ET_ANYEDGE, $1); } ; -senitemEdge: // IEEE: part of event_expression +senitemEdge: // IEEE: part of event_expression //UNSUP // Below are all removed yPOSEDGE idClassSel { $$ = new AstSenItem($1, VEdgeType::ET_POSEDGE, $2); } | yNEGEDGE idClassSel { $$ = new AstSenItem($1, VEdgeType::ET_NEGEDGE, $2); } @@ -3344,17 +3344,17 @@ caseAttrE: //UNSUP case_itemListE { $$ = $1; } //UNSUP ; -case_itemListE: // IEEE: [ { case_item } ] +case_itemListE: // IEEE: [ { case_item } ] /* empty */ { $$ = nullptr; } | case_itemList { $$ = $1; } ; -case_insideListE: // IEEE: [ { case_inside_item } ] +case_insideListE: // IEEE: [ { case_inside_item } ] /* empty */ { $$ = nullptr; } | case_inside_itemList { $$ = $1; } ; -case_itemList: // IEEE: { case_item + ... } +case_itemList: // IEEE: { case_item + ... } caseCondList colon stmtBlock { $$ = new AstCaseItem{$2, $1, $3}; } | yDEFAULT colon stmtBlock { $$ = new AstCaseItem{$1, nullptr, $3}; } | yDEFAULT stmtBlock { $$ = new AstCaseItem{$1, nullptr, $2}; } @@ -3363,7 +3363,7 @@ case_itemList: // IEEE: { case_item + ... } | case_itemList yDEFAULT colon stmtBlock { $$ = $1; $1->addNext(new AstCaseItem{$2, nullptr, $4}); } ; -case_inside_itemList: // IEEE: { case_inside_item + open_range_list ... } +case_inside_itemList: // IEEE: { case_inside_item + open_range_list ... } open_range_list colon stmtBlock { $$ = new AstCaseItem{$2, $1, $3}; } | yDEFAULT colon stmtBlock { $$ = new AstCaseItem{$1, nullptr, $3}; } | yDEFAULT stmtBlock { $$ = new AstCaseItem{$1, nullptr, $2}; } @@ -3425,7 +3425,7 @@ patternMemberList: // IEEE: part of pattern and assignment_pattern | patternMemberList ',' patternMemberOne { $$ = $1->addNextNull($3); } ; -patternMemberOne: // IEEE: part of pattern and assignment_pattern +patternMemberOne: // IEEE: part of pattern and assignment_pattern patternKey ':' expr { $$ = new AstPatMember($1->fileline(),$3,$1,nullptr); } | patternKey ':' patternNoExpr { $$ = nullptr; BBUNSUP($2, "Unsupported: '{} .* patterns"); } // // From assignment_pattern_key @@ -3888,21 +3888,21 @@ list_of_argumentsE: // IEEE: [list_of_arguments] | argsExprListE ',' argsDottedList { $$ = $1->addNextNull($3); } ; -task_declaration: // ==IEEE: task_declaration +task_declaration: // ==IEEE: task_declaration yTASK lifetimeE taskId tfGuts yENDTASK endLabelE { $$ = $3; $$->addStmtsp($4); SYMP->popScope($$); $$->lifetime($2); GRAMMARP->endLabel($6,$$,$6); } ; -task_prototype: // ==IEEE: task_prototype +task_prototype: // ==IEEE: task_prototype yTASK taskId '(' tf_port_listE ')' { $$ = $2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); } | yTASK taskId { $$ = $2; $$->prototype(true); SYMP->popScope($$); } ; -function_declaration: // IEEE: function_declaration + function_body_declaration +function_declaration: // IEEE: function_declaration + function_body_declaration yFUNCTION lifetimeE funcId funcIsolateE tfGuts yENDFUNCTION endLabelE { $$ = $3; $3->attrIsolateAssign($4); $$->addStmtsp($5); $$->lifetime($2); @@ -3915,14 +3915,14 @@ function_declaration: // IEEE: function_declaration + function_body_decl GRAMMARP->endLabel($7,$$,$7); } ; -function_prototype: // IEEE: function_prototype +function_prototype: // IEEE: function_prototype yFUNCTION funcId '(' tf_port_listE ')' { $$ = $2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); } | yFUNCTION funcId { $$ = $2; $$->prototype(true); SYMP->popScope($$); } ; -class_constructor_prototype: // ==IEEE: class_constructor_prototype +class_constructor_prototype: // ==IEEE: class_constructor_prototype yFUNCTION funcIdNew '(' tf_port_listE ')' ';' { $$ = $2; $$->addStmtsp($4); $$->prototype(true); SYMP->popScope($$); } | yFUNCTION funcIdNew ';' @@ -3934,7 +3934,7 @@ funcIsolateE: | yVL_ISOLATE_ASSIGNMENTS { $$ = 1; } ; -method_prototype: +method_prototype: task_prototype { $$ = $1; } | function_prototype { $$ = $1; } ; @@ -3950,7 +3950,7 @@ lifetime: // ==IEEE: lifetime | yAUTOMATIC { $$ = VLifetime::AUTOMATIC; } ; -taskId: +taskId: id { $$ = new AstTask($$, *$1, nullptr); SYMP->pushNewUnderNodeOrCurrent($$, nullptr); } @@ -3966,7 +3966,7 @@ taskId: SYMP->pushNewUnderNodeOrCurrent($$, $1); } ; -funcId: // IEEE: function_data_type_or_implicit + part of function_body_declaration +funcId: // IEEE: function_data_type_or_implicit + part of function_body_declaration // // IEEE: function_data_type_or_implicit must be expanded here to prevent conflict // // function_data_type expanded here to prevent conflicts with implicit_type:empty vs data_type:ID /**/ fIdScoped @@ -3990,7 +3990,7 @@ funcId: // IEEE: function_data_type_or_implicit + part of function_bod { $$ = $2; } ; -funcIdNew: // IEEE: from class_constructor_declaration +funcIdNew: // IEEE: from class_constructor_declaration yNEW__ETC { $$ = new AstFunc($1, "new", nullptr, nullptr); $$->isConstructor(true); @@ -4109,7 +4109,7 @@ parenE: // // IEEE: built_in_method_call // // method_call_root not needed, part of expr resolution // // What's left is below array_methodNoRoot -array_methodNoRoot: +array_methodNoRoot: yOR { $$ = new AstFuncRef($1, "or", nullptr); } | yAND { $$ = new AstFuncRef($1, "and", nullptr); } | yXOR { $$ = new AstFuncRef($1, "xor", nullptr); } @@ -4995,7 +4995,7 @@ idArrayedForeach: // IEEE: id + select (under foreach expression) ; // VarRef without any dots or vectorizaion -varRefBase: +varRefBase: id { $$ = new AstVarRef($1, *$1, VAccess::READ); } ; From 70603bb752870ea4fe34acc2125320e1e8deeec3 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 22 Oct 2021 17:36:58 +0100 Subject: [PATCH 08/79] Add static assertions for unnecessary VN_IS/VN_AS/VN_CAST Fail at compile time if the result of these macros can be statically determined (i.e.: they aways succeed or always fail). Remove unnecessary casts discovered. No functional change. --- src/V3Active.cpp | 3 +-- src/V3ActiveTop.cpp | 3 +-- src/V3Ast.h | 57 +++++++++++++++++++++++++++++++++++---------- src/V3AstNodes.h | 8 ++----- src/V3Broken.cpp | 2 +- src/V3Const.cpp | 8 +++---- src/V3EmitCFunc.cpp | 8 ++----- src/V3EmitCFunc.h | 4 ++-- src/V3EmitV.cpp | 2 +- src/V3Gate.cpp | 7 +++--- src/V3Inline.cpp | 2 +- src/V3LinkDot.cpp | 5 ++-- src/V3Order.cpp | 8 +++---- src/V3Param.cpp | 2 +- src/V3Simulate.h | 4 ++-- src/V3TraceDecl.cpp | 2 +- src/V3Width.cpp | 2 +- src/astgen | 15 +++++++----- 18 files changed, 83 insertions(+), 59 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index f7292f9e6..d7501522f 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -489,8 +489,7 @@ private: // METHODS void visitAlways(AstNode* nodep, AstSenTree* oldsensesp, VAlwaysKwd kwd) { // Move always to appropriate ACTIVE based on its sense list - if (oldsensesp && oldsensesp->sensesp() && VN_IS(oldsensesp->sensesp(), SenItem) - && VN_AS(oldsensesp->sensesp(), SenItem)->isNever()) { + if (oldsensesp && oldsensesp->sensesp() && oldsensesp->sensesp()->isNever()) { // Never executing. Kill it. UASSERT_OBJ(!oldsensesp->sensesp()->nextp(), nodep, "Never senitem should be alone, else the never should be eliminated."); diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index d76ebd6db..3fe652d58 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -70,8 +70,7 @@ private: V3Const::constifyExpensiveEdit(nodep); AstSenTree* sensesp = nodep->sensesp(); UASSERT_OBJ(sensesp, nodep, "nullptr"); - if (sensesp->sensesp() && VN_IS(sensesp->sensesp(), SenItem) - && VN_AS(sensesp->sensesp(), SenItem)->isNever()) { + if (sensesp->sensesp() && sensesp->sensesp()->isNever()) { // Never executing. Kill it. UASSERT_OBJ(!sensesp->sensesp()->nextp(), nodep, "Never senitem should be alone, else the never should be eliminated."); diff --git a/src/V3Ast.h b/src/V3Ast.h index dbe75cde4..b5d8262a0 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -62,17 +62,20 @@ using MTaskIdSet = std::set; // Set of mtaskIds for Var sorting // (V)erilator (N)ode is: Returns true iff AstNode is of the given AstNode subtype, and not // nullptr. -#define VN_IS(nodep, nodetypename) (AstNode::privateIs(nodep)) +#define VN_IS(nodep, nodetypename) (AstNode::privateIs(nodep)) // (V)erilator (N)ode cast: More efficient but otherwise same as dynamic_cast, use this instead. // Cast to given type if node is of such type, otherwise returns nullptr. -#define VN_CAST(nodep, nodetypename) (AstNode::privateCast(nodep)) -#define VN_CAST_CONST(nodep, nodetypename) (AstNode::privateCastConst(nodep)) +#define VN_CAST(nodep, nodetypename) \ + (AstNode::privateCast(nodep)) +#define VN_CAST_CONST(nodep, nodetypename) \ + (AstNode::privateCastConst(nodep)) // (V)erilator (N)ode as: Assert node is of given type then cast to that type. Node can be nullptr. // Use this to downcast instead of VN_CAST when you know the true type of the node. -#define VN_AS(nodep, nodetypename) (AstNode::privateAs(nodep)) -#define VN_AS_CONST(nodep, nodetypename) (AstNode::privateAsConst(nodep)) +#define VN_AS(nodep, nodetypename) (AstNode::privateAs(nodep)) +#define VN_AS_CONST(nodep, nodetypename) \ + (AstNode::privateAsConst(nodep)) // (V)erilator (N)ode deleted: Pointer to deleted AstNode (for assertions only) #define VN_DELETED(nodep) VL_UNLIKELY((vluint64_t)(nodep) == 0x1) @@ -1847,28 +1850,58 @@ private: // For internal use only. template inline static bool privateTypeTest(const AstNode* nodep); + template constexpr static bool uselessCast() { + using NonRef = typename std::remove_reference::type; + using NonPtr = typename std::remove_pointer::type; + using NonCV = typename std::remove_cv::type; + return std::is_base_of::value; + } + + template constexpr static bool impossibleCast() { + using NonRef = typename std::remove_reference::type; + using NonPtr = typename std::remove_pointer::type; + using NonCV = typename std::remove_cv::type; + return !std::is_base_of::value; + } + public: // For use via the VN_IS macro only - template inline static bool privateIs(const AstNode* nodep) { + template inline static bool privateIs(const AstNode* nodep) { + static_assert(!uselessCast(), "Unnecessary VN_IS, node known to have target type."); + static_assert(!impossibleCast(), "Unnecessary VN_IS, node cannot be this type."); return nodep && privateTypeTest(nodep); } // For use via the VN_CAST macro only - template inline static T* privateCast(AstNode* nodep) { - return privateIs(nodep) ? reinterpret_cast(nodep) : nullptr; + template inline static T* privateCast(AstNode* nodep) { + static_assert(!uselessCast(), + "Unnecessary VN_CAST, node known to have target type."); + static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); + return nodep && privateTypeTest(nodep) ? reinterpret_cast(nodep) : nullptr; } // For use via the VN_CAST_CONST macro only - template inline static const T* privateCastConst(const AstNode* nodep) { - return privateIs(nodep) ? reinterpret_cast(nodep) : nullptr; + template + inline static const T* privateCastConst(const AstNode* nodep) { + static_assert(!uselessCast(), + "Unnecessary VN_CAST_CONST, node known to have target type."); + static_assert(!impossibleCast(), + "Unnecessary VN_CAST_CONST, node cannot be this type."); + return nodep && privateTypeTest(nodep) ? reinterpret_cast(nodep) : nullptr; } // For use via the VN_AS macro only - template inline static T* privateAs(AstNode* nodep) { + template inline static T* privateAs(AstNode* nodep) { + static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); + static_assert(!impossibleCast(), "Unnecessary VN_AS, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, "AstNode is not of expected type, but instead has type '" << nodep->typeName() << "'"); return reinterpret_cast(nodep); } // For use via the VN_AS_CONST macro only - template inline static const T* privateAsConst(const AstNode* nodep) { + template inline static const T* privateAsConst(const AstNode* nodep) { + static_assert(!uselessCast(), + "Unnecessary VN_AS_CONST, node known to have target type."); + static_assert(!impossibleCast(), + "Unnecessary VN_AS_CONST, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, "AstNode is not of expected type, but instead has type '" << nodep->typeName() << "'"); diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 76d2c1a8f..303bf7894 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -1456,13 +1456,9 @@ public: ASTNODE_NODE_FUNCS(EnumItemRef) virtual void dump(std::ostream& str) const override; virtual string name() const override { return itemp()->name(); } - virtual const char* broken() const override { - BROKEN_RTN(!VN_IS(itemp(), EnumItem)); - return nullptr; - } virtual int instrCount() const override { return 0; } virtual void cloneRelink() override { - if (m_itemp->clonep()) m_itemp = VN_AS(m_itemp->clonep(), EnumItem); + if (m_itemp->clonep()) m_itemp = m_itemp->clonep(); } virtual bool same(const AstNode* samep) const override { const AstEnumItemRef* sp = static_cast(samep); @@ -4976,7 +4972,7 @@ public: virtual void dump(std::ostream& str) const override; virtual const char* broken() const override { for (KeyItemMap::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { - BROKEN_RTN(!VN_IS(it->second, InitItem)); + BROKEN_RTN(!it->second); BROKEN_RTN(!it->second->brokeExists()); } return nullptr; diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index fb10a1972..66beaeb2a 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -197,7 +197,7 @@ private: if (nodep->dtypep()) { UASSERT_OBJ(nodep->dtypep()->brokeExists(), nodep, "Broken link in node->dtypep() to " << cvtToHex(nodep->dtypep())); - UASSERT_OBJ(VN_IS(nodep->dtypep(), NodeDType), nodep, + UASSERT_OBJ(nodep->dtypep(), nodep, "Non-dtype link in node->dtypep() to " << cvtToHex(nodep->dtypep())); } if (v3Global.assertDTypesResolved()) { diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 6b8187fe6..48b4a2822 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -2671,7 +2671,7 @@ private: { AstUser4InUse m_inuse4; // Mark x in SENITEM(x) - for (AstSenItem* senp = VN_AS(nodep->sensesp(), SenItem); senp; + for (AstSenItem* senp = nodep->sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { if (senp->varrefp() && senp->varrefp()->varScopep()) { senp->varrefp()->varScopep()->user4(1); @@ -2682,7 +2682,7 @@ private: // Sort the sensitivity names so "posedge a or b" and "posedge b or a" end up together. // Also, remove duplicate assignments, and fold POS&NEGs into ANYEDGEs // Make things a little faster; check first if we need a sort - for (AstSenItem *nextp, *senp = VN_AS(nodep->sensesp(), SenItem); senp; senp = nextp) { + for (AstSenItem *nextp, *senp = nodep->sensesp(); senp; senp = nextp) { nextp = VN_AS(senp->nextp(), SenItem); // cppcheck-suppress unassignedVariable // cppcheck bug SenItemCmp cmp; @@ -2690,7 +2690,7 @@ private: // Something's out of order, sort it senp = nullptr; std::vector vec; - for (AstSenItem* senp = VN_AS(nodep->sensesp(), SenItem); senp; + for (AstSenItem* senp = nodep->sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { vec.push_back(senp); } @@ -2702,7 +2702,7 @@ private: } // Pass2, remove dup edges - for (AstSenItem *nextp, *senp = VN_AS(nodep->sensesp(), SenItem); senp; senp = nextp) { + for (AstSenItem *nextp, *senp = nodep->sensesp(); senp; senp = nextp) { nextp = VN_AS(senp->nextp(), SenItem); AstSenItem* const litemp = senp; AstSenItem* const ritemp = nextp; diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 429396bc0..0910c6cfb 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -533,13 +533,11 @@ void EmitCFunc::emitConstant(AstConst* nodep, AstVarRef* assigntop, const string puts(","); if (!assigntop) { puts(assignString); - } else if (VN_IS(assigntop, VarRef)) { + } else { if (!assigntop->selfPointer().empty()) { emitDereference(assigntop->selfPointerProtect(m_useSelfForThis)); } puts(assigntop->varp()->nameProtect()); - } else { - iterateAndNextNull(assigntop); } for (int word = VL_WORDS_I(upWidth) - 1; word >= 0; word--) { // Only 32 bits - llx + long long here just to appease CPP format warning @@ -558,13 +556,11 @@ void EmitCFunc::emitConstant(AstConst* nodep, AstVarRef* assigntop, const string puts(","); if (!assigntop) { puts(assignString); - } else if (VN_IS(assigntop, VarRef)) { + } else { if (!assigntop->selfPointer().empty()) { emitDereference(assigntop->selfPointerProtect(m_useSelfForThis)); } puts(assigntop->varp()->nameProtect()); - } else { - iterateAndNextNull(assigntop); } for (int word = EMITC_NUM_CONSTW - 1; word >= 0; word--) { // Only 32 bits - llx + long long here just to appease CPP format warning diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 0c0b85060..55d3a8151 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -898,7 +898,7 @@ public: } } virtual void visit(AstTextBlock* nodep) override { - visit(VN_AS(nodep, NodeSimpleText)); + visit(static_cast(nodep)); for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) { iterate(childp); if (nodep->commas() && childp->nextp()) puts(", "); @@ -978,7 +978,7 @@ public: } virtual void visit(AstRedXor* nodep) override { if (nodep->lhsp()->isWide()) { - visit(VN_AS(nodep, NodeUniop)); + visit(static_cast(nodep)); } else { AstVarRef* const vrefp = VN_CAST(nodep->lhsp(), VarRef); const int widthPow2 = vrefp ? vrefp->varp()->dtypep()->widthPow2() diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index da749f237..8c21a17b3 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -382,7 +382,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } } virtual void visit(AstTextBlock* nodep) override { - visit(VN_AS(nodep, NodeSimpleText)); + visit(static_cast(nodep)); { VL_RESTORER(m_suppressSemi); m_suppressVarSemi = nodep->commas(); diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 3c7b94755..9c88263bb 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -843,10 +843,9 @@ private: UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Can't replace lvalue assignments with const var"); AstNode* substp = m_replaceTreep->cloneTree(false); - UASSERT_OBJ( - !(VN_IS(nodep, NodeVarRef) && VN_IS(substp, NodeVarRef) && nodep->same(substp)), - // Prevent an infinite loop... - substp, "Replacing node with itself; perhaps circular logic?"); + UASSERT_OBJ(!(VN_IS(substp, NodeVarRef) && nodep->same(substp)), + // Prevent an infinite loop... + substp, "Replacing node with itself; perhaps circular logic?"); // Which fileline() to use? // If replacing with logic, an error/warning is likely to want to point to the logic // IE what we're replacing with. diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index f56933dd9..539728e1b 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -359,7 +359,7 @@ private: // Each inlined cell that contain an interface variable need to // copy the IfaceRefDType and point it to the newly cloned // interface cell. - AstIfaceRefDType* newdp = VN_AS(ifacerefp->cloneTree(false), IfaceRefDType); + AstIfaceRefDType* newdp = ifacerefp->cloneTree(false); nodep->dtypep(newdp); ifacerefp->addNextHere(newdp); // Relink to point to newly cloned cell diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 3a119b0fa..e0948ffb7 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2093,7 +2093,7 @@ private: nodep->v3error("'super' used on non-extended class (IEEE 1800-2017 8.15)"); m_ds.m_dotErr = true; } else { - const auto cextp = VN_AS(classp->extendsp(), ClassExtends); + const auto cextp = classp->extendsp(); UASSERT_OBJ(cextp, nodep, "Bad super extends link"); const auto sclassp = cextp->classp(); UASSERT_OBJ(sclassp, nodep, "Bad superclass"); @@ -2311,8 +2311,7 @@ private: refp->dotted(dotted.substr(0, pos)); newp = refp; } else { - newp = new AstUnlinkedRef(nodep->fileline(), VN_AS(refp, VarXRef), - refp->name(), + newp = new AstUnlinkedRef(nodep->fileline(), refp, refp->name(), m_ds.m_unlinkedScopep->unlinkFrBack()); m_ds.m_unlinkedScopep = nullptr; m_ds.m_unresolved = false; diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 754a42cb4..0c1994fa3 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -1262,11 +1262,11 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) { const bool fromInitial = fromp->hasInitial() || fromp->hasSettle(); if (toInitial != fromInitial) return true; - const AstSenItem* fromSenListp = VN_AS(fromp->sensesp(), SenItem); - const AstSenItem* toSenListp = VN_AS(top->sensesp(), SenItem); + const AstSenItem* fromSenListp = fromp->sensesp(); + const AstSenItem* toSenListp = top->sensesp(); - UASSERT_OBJ(fromSenListp, fromp, "sensitivity list item is not an AstSenItem"); - UASSERT_OBJ(toSenListp, top, "sensitivity list item is not an AstSenItem"); + UASSERT_OBJ(fromSenListp, fromp, "sensitivity list empty"); + UASSERT_OBJ(toSenListp, top, "sensitivity list empty"); if (fromSenListp->nextp()) return false; if (toSenListp->nextp()) return false; diff --git a/src/V3Param.cpp b/src/V3Param.cpp index b0ba43339..d59863661 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -452,7 +452,7 @@ class ParamProcessor final { << " has hier_block metacomment, hierarchical verilation" << " supports only integer/floating point/string parameters"); } - } else if (VN_IS(pinp->modPTypep(), ParamTypeDType)) { + } else { pinp->v3error(AstNode::prettyNameQ(modp->origName()) << " has hier_block metacomment, but 'parameter type' is not supported"); } diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 3a41dae75..35e601a87 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -966,11 +966,11 @@ private: badNodeType(nodep); return; } - AstNodeFTask* funcp = VN_AS(nodep->taskp(), NodeFTask); + AstNodeFTask* funcp = nodep->taskp(); UASSERT_OBJ(funcp, nodep, "Not linked"); if (m_params) V3Width::widthParamsEdit(funcp); VL_DANGLING(funcp); // Make sure we've sized the function - funcp = VN_AS(nodep->taskp(), NodeFTask); + funcp = nodep->taskp(); UASSERT_OBJ(funcp, nodep, "Not linked"); // Apply function call values to function V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 8019b41da..c6c335f57 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -145,7 +145,7 @@ private: iterateChildren(nodep); } virtual void visit(AstScope* nodep) override { - AstCell* const cellp = VN_CAST(nodep->aboveCellp(), Cell); + AstCell* const cellp = nodep->aboveCellp(); if (cellp && VN_IS(cellp->modp(), Iface)) { AstCFunc* const origSubFunc = m_initSubFuncp; int origSubStmts = m_initSubStmts; diff --git a/src/V3Width.cpp b/src/V3Width.cpp index f52145765..5f6647ab6 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -4365,7 +4365,7 @@ private: } virtual void visit(AstFuncRef* nodep) override { - visit(VN_AS(nodep, NodeFTaskRef)); + visit(static_cast(nodep)); nodep->dtypeFrom(nodep->taskp()); // if (debug()) nodep->dumpTree(cout, " FuncOut: "); } diff --git a/src/astgen b/src/astgen index 0c4bb5cab..f04126587 100755 --- a/src/astgen +++ b/src/astgen @@ -333,12 +333,11 @@ class Cpt: " iterateAndNextNull(nodep->lhsp());\n" + "".join(out_for_type_sc)) if out_for_type[0]: - self.print( - " iterateAndNextNull(nodep->rhsp());\n" + - " AstNodeTriop *tnp = VN_CAST(nodep, NodeTriop);\n" - + - " if (tnp && tnp->thsp()) iterateAndNextNull(tnp->thsp());\n" - + "".join(out_for_type) + " }\n") + self.print(" iterateAndNextNull(nodep->rhsp());\n") + if is_subclass_of(typen, "NodeTriop"): + self.print( + " iterateAndNextNull(nodep->thsp());\n") + self.print("".join(out_for_type) + " }\n") elif len(out_for_type) > 0: # Other types with something to print skip = typen in self.tree_skip_visit gen = "Gen" if skip else "" @@ -450,6 +449,10 @@ def children_of(typen): return cllist +def is_subclass_of(typen, what): + return typen == what or (typen in children_of(what)) + + # --------------------------------------------------------------------- From 20e896ec21f64a3e9176bea5cfb4ed12e850f36b Mon Sep 17 00:00:00 2001 From: github action Date: Fri, 22 Oct 2021 18:51:57 +0000 Subject: [PATCH 09/79] Apply 'make format' --- src/astgen | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/astgen b/src/astgen index f04126587..97534f102 100755 --- a/src/astgen +++ b/src/astgen @@ -598,7 +598,8 @@ def write_types(filename): def write_yystype(filename): with open_file(filename) as fh: for typen in sorted(Classes.keys()): - fh.write("Ast{t}* {m}p;\n".format(t=typen, m=typen[0].lower() + typen[1:])) + fh.write("Ast{t}* {m}p;\n".format(t=typen, + m=typen[0].lower() + typen[1:])) def write_macros(filename): From 381c87a1eb18f0b54729046e12fe8b7621eddcbf Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Fri, 22 Oct 2021 15:15:42 +0100 Subject: [PATCH 10/79] Remove VN_CAST_CONST and VN_AS_CONST. The _CONST suffix on these macros is only lexical notation, pointer constness can be preserved by overloading the underlying implementations appropriately. Given that the compiler will catch invalid const usage (trying to assign a non-const pointer to a const pointer variable, etc.), and that the declarations of symbols should make their constness obvious, I see no reason to keep the _CONST flavours. --- src/V3Ast.cpp | 6 +-- src/V3Ast.h | 40 +++++++-------- src/V3AstInlines.h | 10 ++-- src/V3AstNodes.cpp | 20 ++++---- src/V3Const.cpp | 104 +++++++++++++++++++-------------------- src/V3EmitCBase.cpp | 7 ++- src/V3EmitCBase.h | 2 +- src/V3EmitCConstPool.cpp | 2 +- src/V3EmitCHeaders.cpp | 16 +++--- src/V3EmitCImp.cpp | 16 +++--- src/V3EmitCModel.cpp | 8 +-- src/V3LinkDot.cpp | 4 +- src/V3MergeCond.cpp | 16 +++--- src/V3Param.cpp | 12 ++--- src/V3Simulate.h | 4 +- src/V3SplitVar.cpp | 2 +- src/V3Trace.cpp | 2 +- src/V3TraceDecl.cpp | 2 +- 18 files changed, 131 insertions(+), 142 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index e0bbe975b..0fecb49a5 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1164,7 +1164,7 @@ string AstNode::locationStr() const { return ""; // LCOV_EXCL_LINE } const AstScope* scopep; - if ((scopep = VN_CAST_CONST(backp, Scope))) { + if ((scopep = VN_CAST(backp, Scope))) { // The design is flattened and there are no useful scopes // This is probably because of inlining if (scopep->isTop()) break; @@ -1178,10 +1178,10 @@ string AstNode::locationStr() const { while (backp) { const AstModule* modp; const AstNodeVarRef* nvrp; - if ((modp = VN_CAST_CONST(backp, Module)) && !modp->hierName().empty()) { + if ((modp = VN_CAST(backp, Module)) && !modp->hierName().empty()) { str += modp->hierName(); return str; - } else if ((nvrp = VN_CAST_CONST(backp, NodeVarRef))) { + } else if ((nvrp = VN_CAST(backp, NodeVarRef))) { const string prettyName = nvrp->prettyName(); // VarRefs have not been flattened yet and do not contain location information if (prettyName != nvrp->name()) { diff --git a/src/V3Ast.h b/src/V3Ast.h index b5d8262a0..a65b1656f 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -60,22 +60,22 @@ using MTaskIdSet = std::set; // Set of mtaskIds for Var sorting if (VL_UNCOVERABLE(reasonp)) return reasonp; \ } while (false) -// (V)erilator (N)ode is: Returns true iff AstNode is of the given AstNode subtype, and not -// nullptr. +// (V)erilator (N)ode is: Returns true if and only if AstNode is of the given AstNode subtype, +// and not nullptr. #define VN_IS(nodep, nodetypename) (AstNode::privateIs(nodep)) -// (V)erilator (N)ode cast: More efficient but otherwise same as dynamic_cast, use this instead. -// Cast to given type if node is of such type, otherwise returns nullptr. +// (V)erilator (N)ode cast: Similar to dynamic_cast, but more efficient, use this instead. +// Cast to given type if node is of such type, otherwise returns nullptr. If 'nodep' is nullptr, +// return nullptr. Pointer constness is preserved, i.e.: given a 'const AstNode*', +// a 'const Ast*' is returned. #define VN_CAST(nodep, nodetypename) \ (AstNode::privateCast(nodep)) -#define VN_CAST_CONST(nodep, nodetypename) \ - (AstNode::privateCastConst(nodep)) -// (V)erilator (N)ode as: Assert node is of given type then cast to that type. Node can be nullptr. -// Use this to downcast instead of VN_CAST when you know the true type of the node. +// (V)erilator (N)ode as: Assert node is of given type then cast to that type. Use this to +// downcast instead of VN_CAST when you know the true type of the node. If 'nodep' is nullptr, +// return nullptr. Pointer constness is preserved, i.e.: given a 'const AstNode*', a 'const +// Ast*' is returned. #define VN_AS(nodep, nodetypename) (AstNode::privateAs(nodep)) -#define VN_AS_CONST(nodep, nodetypename) \ - (AstNode::privateAsConst(nodep)) // (V)erilator (N)ode deleted: Pointer to deleted AstNode (for assertions only) #define VN_DELETED(nodep) VL_UNLIKELY((vluint64_t)(nodep) == 0x1) @@ -1871,6 +1871,7 @@ public: static_assert(!impossibleCast(), "Unnecessary VN_IS, node cannot be this type."); return nodep && privateTypeTest(nodep); } + // For use via the VN_CAST macro only template inline static T* privateCast(AstNode* nodep) { static_assert(!uselessCast(), @@ -1878,15 +1879,13 @@ public: static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); return nodep && privateTypeTest(nodep) ? reinterpret_cast(nodep) : nullptr; } - // For use via the VN_CAST_CONST macro only - template - inline static const T* privateCastConst(const AstNode* nodep) { + template inline static const T* privateCast(const AstNode* nodep) { static_assert(!uselessCast(), - "Unnecessary VN_CAST_CONST, node known to have target type."); - static_assert(!impossibleCast(), - "Unnecessary VN_CAST_CONST, node cannot be this type."); + "Unnecessary VN_CAST, node known to have target type."); + static_assert(!impossibleCast(), "Unnecessary VN_CAST, node cannot be this type."); return nodep && privateTypeTest(nodep) ? reinterpret_cast(nodep) : nullptr; } + // For use via the VN_AS macro only template inline static T* privateAs(AstNode* nodep) { static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); @@ -1896,12 +1895,9 @@ public: << "'"); return reinterpret_cast(nodep); } - // For use via the VN_AS_CONST macro only - template inline static const T* privateAsConst(const AstNode* nodep) { - static_assert(!uselessCast(), - "Unnecessary VN_AS_CONST, node known to have target type."); - static_assert(!impossibleCast(), - "Unnecessary VN_AS_CONST, node cannot be this type."); + template inline static const T* privateAs(const AstNode* nodep) { + static_assert(!uselessCast(), "Unnecessary VN_AS, node known to have target type."); + static_assert(!impossibleCast(), "Unnecessary VN_AS, node cannot be this type."); UASSERT_OBJ(!nodep || privateTypeTest(nodep), nodep, "AstNode is not of expected type, but instead has type '" << nodep->typeName() << "'"); diff --git a/src/V3AstInlines.h b/src/V3AstInlines.h index 49b84a061..6058da776 100644 --- a/src/V3AstInlines.h +++ b/src/V3AstInlines.h @@ -42,19 +42,19 @@ inline bool AstNode::isString() const { inline bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); } inline bool AstNode::isZero() const { - return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isEqZero()); + return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqZero()); } inline bool AstNode::isNeqZero() const { - return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isNeqZero()); + return (VN_IS(this, Const) && VN_AS(this, Const)->num().isNeqZero()); } inline bool AstNode::isOne() const { - return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isEqOne()); + return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqOne()); } inline bool AstNode::isAllOnes() const { - return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->isEqAllOnes()); + return (VN_IS(this, Const) && VN_AS(this, Const)->isEqAllOnes()); } inline bool AstNode::isAllOnesV() const { - return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->isEqAllOnesV()); + return (VN_IS(this, Const) && VN_AS(this, Const)->isEqAllOnesV()); } inline bool AstNode::sameTree(const AstNode* node2p) const { return sameTreeIter(this, node2p, true, false); diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 11b2c7252..456f25e81 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -413,7 +413,7 @@ string AstVar::vlPropDecl(const string& propName) const { std::vector ulims; // Unpacked dimension limits for (const AstNodeDType* dtp = dtypep(); dtp;) { dtp = dtp->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node - if (const AstNodeArrayDType* const adtypep = VN_CAST_CONST(dtp, NodeArrayDType)) { + if (const AstNodeArrayDType* const adtypep = VN_CAST(dtp, NodeArrayDType)) { ulims.push_back(adtypep->declRange().left()); ulims.push_back(adtypep->declRange().right()); dtp = adtypep->subDTypep(); @@ -667,22 +667,22 @@ AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound) const { CTypeRecursed info; const AstNodeDType* dtypep = this->skipRefp(); - if (const auto* adtypep = VN_CAST_CONST(dtypep, AssocArrayDType)) { + if (const auto* adtypep = VN_CAST(dtypep, AssocArrayDType)) { const CTypeRecursed key = adtypep->keyDTypep()->cTypeRecurse(true); const CTypeRecursed val = adtypep->subDTypep()->cTypeRecurse(true); info.m_type = "VlAssocArray<" + key.m_type + ", " + val.m_type + ">"; - } else if (const auto* adtypep = VN_CAST_CONST(dtypep, DynArrayDType)) { + } else if (const auto* adtypep = VN_CAST(dtypep, DynArrayDType)) { const CTypeRecursed sub = adtypep->subDTypep()->cTypeRecurse(true); info.m_type = "VlQueue<" + sub.m_type + ">"; - } else if (const auto* adtypep = VN_CAST_CONST(dtypep, QueueDType)) { + } else if (const auto* adtypep = VN_CAST(dtypep, QueueDType)) { const CTypeRecursed sub = adtypep->subDTypep()->cTypeRecurse(true); info.m_type = "VlQueue<" + sub.m_type; // + 1 below as VlQueue uses 0 to mean unlimited, 1 to mean size() max is 1 if (adtypep->boundp()) info.m_type += ", " + cvtToStr(adtypep->boundConst() + 1); info.m_type += ">"; - } else if (const auto* adtypep = VN_CAST_CONST(dtypep, ClassRefDType)) { + } else if (const auto* adtypep = VN_CAST(dtypep, ClassRefDType)) { info.m_type = "VlClassRef<" + EmitCBaseVisitor::prefixNameProtect(adtypep) + ">"; - } else if (const auto* adtypep = VN_CAST_CONST(dtypep, UnpackArrayDType)) { + } else if (const auto* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { if (adtypep->isCompound()) compound = true; const CTypeRecursed sub = adtypep->subDTypep()->cTypeRecurse(compound); info.m_type = "VlUnpacked<" + sub.m_type; @@ -777,11 +777,11 @@ int AstNodeDType::widthPow2() const { } bool AstNodeDType::isLiteralType() const { - if (auto* const dtypep = VN_CAST_CONST(skipRefp(), BasicDType)) { + if (auto* const dtypep = VN_CAST(skipRefp(), BasicDType)) { return dtypep->keyword().isLiteralType(); - } else if (auto* const dtypep = VN_CAST_CONST(skipRefp(), UnpackArrayDType)) { + } else if (auto* const dtypep = VN_CAST(skipRefp(), UnpackArrayDType)) { return dtypep->basicp()->isLiteralType(); - } else if (auto* const dtypep = VN_CAST_CONST(skipRefp(), StructDType)) { + } else if (auto* const dtypep = VN_CAST(skipRefp(), StructDType)) { // Currently all structs are packed, later this can be expanded to // 'forall members _.isLiteralType()' return dtypep->packed(); @@ -1512,7 +1512,7 @@ void AstNodeDType::dumpSmall(std::ostream& str) const { } void AstNodeArrayDType::dumpSmall(std::ostream& str) const { this->AstNodeDType::dumpSmall(str); - if (auto* adtypep = VN_CAST_CONST(this, UnpackArrayDType)) { + if (auto* adtypep = VN_CAST(this, UnpackArrayDType)) { // uc = packed compound object, u = unpacked POD str << (adtypep->isCompound() ? "uc" : "u"); } else { diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 48b4a2822..1ffc1b32d 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -79,7 +79,7 @@ public: }; static bool isConst(const AstNode* nodep, uint64_t v) { - const AstConst* const constp = VN_CAST_CONST(nodep, Const); + const AstConst* const constp = VN_CAST(nodep, Const); return constp && constp->toUQuad() == v; } @@ -841,10 +841,10 @@ private: bool operandConst(AstNode* nodep) { return VN_IS(nodep, Const); } bool operandAsvConst(const AstNode* nodep) { // BIASV(CONST, BIASV(CONST,...)) -> BIASV( BIASV_CONSTED(a,b), ...) - const AstNodeBiComAsv* bnodep = VN_CAST_CONST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; if (!VN_IS(bnodep->lhsp(), Const)) return false; - const AstNodeBiComAsv* rnodep = VN_CAST_CONST(bnodep->rhsp(), NodeBiComAsv); + const AstNodeBiComAsv* rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); if (!rnodep) return false; if (rnodep->type() != bnodep->type()) return false; if (rnodep->width() != bnodep->width()) return false; @@ -854,9 +854,9 @@ private: } bool operandAsvSame(const AstNode* nodep) { // BIASV(SAMEa, BIASV(SAMEb,...)) -> BIASV( BIASV(SAMEa,SAMEb), ...) - const AstNodeBiComAsv* bnodep = VN_CAST_CONST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; - const AstNodeBiComAsv* rnodep = VN_CAST_CONST(bnodep->rhsp(), NodeBiComAsv); + const AstNodeBiComAsv* rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); if (!rnodep) return false; if (rnodep->type() != bnodep->type()) return false; if (rnodep->width() != bnodep->width()) return false; @@ -873,9 +873,9 @@ private: // BIASV(CONST_a_c,BIASV(c...,d...))) // // Idea for the future: All BiComAsvs could be lists, sorted by if they're constant - const AstNodeBiComAsv* bnodep = VN_CAST_CONST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; - const AstNodeBiComAsv* lnodep = VN_CAST_CONST(bnodep->lhsp(), NodeBiComAsv); + const AstNodeBiComAsv* lnodep = VN_CAST(bnodep->lhsp(), NodeBiComAsv); if (!lnodep) return false; if (lnodep->type() != bnodep->type()) return false; if (lnodep->width() != bnodep->width()) return false; @@ -883,9 +883,9 @@ private: } bool operandAsvRUp(const AstNode* nodep) { // BIASV(l,BIASV(CONSTrl,rr)) -> BIASV(CONSTrl,BIASV(l,rr)) ? - const AstNodeBiComAsv* bnodep = VN_CAST_CONST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; - const AstNodeBiComAsv* rnodep = VN_CAST_CONST(bnodep->rhsp(), NodeBiComAsv); + const AstNodeBiComAsv* rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); if (!rnodep) return false; if (rnodep->type() != bnodep->type()) return false; if (rnodep->width() != bnodep->width()) return false; @@ -893,8 +893,8 @@ private: } static bool operandSubAdd(const AstNode* nodep) { // SUB( ADD(CONSTx,y), CONSTz) -> ADD(SUB(CONSTx,CONSTz), y) - const AstNodeBiop* np = VN_CAST_CONST(nodep, NodeBiop); - const AstNodeBiop* lp = VN_CAST_CONST(np->lhsp(), NodeBiop); + const AstNodeBiop* np = VN_CAST(nodep, NodeBiop); + const AstNodeBiop* lp = VN_CAST(np->lhsp(), NodeBiop); return (lp && VN_IS(lp->lhsp(), Const) && VN_IS(np->rhsp(), Const) && lp->width() == np->width()); } @@ -931,9 +931,9 @@ private: static bool operandAndOrSame(const AstNode* nodep) { // OR( AND(VAL,x), AND(VAL,y)) -> AND(VAL,OR(x,y)) // OR( AND(x,VAL), AND(y,VAL)) -> AND(OR(x,y),VAL) - const AstNodeBiop* np = VN_CAST_CONST(nodep, NodeBiop); - const AstNodeBiop* lp = VN_CAST_CONST(np->lhsp(), NodeBiop); - const AstNodeBiop* rp = VN_CAST_CONST(np->rhsp(), NodeBiop); + const AstNodeBiop* np = VN_CAST(nodep, NodeBiop); + const AstNodeBiop* lp = VN_CAST(np->lhsp(), NodeBiop); + const AstNodeBiop* rp = VN_CAST(np->rhsp(), NodeBiop); return (lp && rp && lp->width() == rp->width() && lp->type() == rp->type() && (operandsSame(lp->lhsp(), rp->lhsp()) || operandsSame(lp->rhsp(), rp->rhsp()))); } @@ -1015,8 +1015,8 @@ private: // Predicate for checking whether the bottom 'significantBits' bits of the given expression // are all zeroes. const auto checkBottomClear = [=](const AstNode* nodep) -> bool { - if (const AstShiftL* const shiftp = VN_CAST_CONST(nodep, ShiftL)) { - if (const AstConst* const scp = VN_CAST_CONST(shiftp->rhsp(), Const)) { + if (const AstShiftL* const shiftp = VN_CAST(nodep, ShiftL)) { + if (const AstConst* const scp = VN_CAST(shiftp->rhsp(), Const)) { return scp->num().toUInt() >= significantBits; } } @@ -1063,14 +1063,14 @@ private: // Check if masking is redundant if (AstShiftR* const shiftp = VN_CAST(nodep->rhsp(), ShiftR)) { - if (const AstConst* scp = VN_CAST_CONST(shiftp->rhsp(), Const)) { + if (const AstConst* scp = VN_CAST(shiftp->rhsp(), Const)) { // Check if mask is full over the non-zero bits V3Number maskLo(nodep, nodep->width()); maskLo.setMask(nodep->width() - scp->num().toUInt()); return checkMask(maskLo); } } else if (AstShiftL* const shiftp = VN_CAST(nodep->rhsp(), ShiftL)) { - if (const AstConst* scp = VN_CAST_CONST(shiftp->rhsp(), Const)) { + if (const AstConst* scp = VN_CAST(shiftp->rhsp(), Const)) { // Check if mask is full over the non-zero bits V3Number maskLo(nodep, nodep->width()); V3Number maskHi(nodep, nodep->width()); @@ -1121,18 +1121,18 @@ private: return newp; } static bool operandShiftSame(const AstNode* nodep) { - const AstNodeBiop* np = VN_AS_CONST(nodep, NodeBiop); + const AstNodeBiop* np = VN_AS(nodep, NodeBiop); { - const AstShiftL* lp = VN_CAST_CONST(np->lhsp(), ShiftL); - const AstShiftL* rp = VN_CAST_CONST(np->rhsp(), ShiftL); + const AstShiftL* lp = VN_CAST(np->lhsp(), ShiftL); + const AstShiftL* rp = VN_CAST(np->rhsp(), ShiftL); if (lp && rp) { return (lp->width() == rp->width() && lp->lhsp()->width() == rp->lhsp()->width() && operandsSame(lp->rhsp(), rp->rhsp())); } } { - const AstShiftR* lp = VN_CAST_CONST(np->lhsp(), ShiftR); - const AstShiftR* rp = VN_CAST_CONST(np->rhsp(), ShiftR); + const AstShiftR* lp = VN_CAST(np->lhsp(), ShiftR); + const AstShiftR* rp = VN_CAST(np->rhsp(), ShiftR); if (lp && rp) { return (lp->width() == rp->width() && lp->lhsp()->width() == rp->lhsp()->width() && operandsSame(lp->rhsp(), rp->rhsp())); @@ -1141,29 +1141,26 @@ private: return false; } bool operandHugeShiftL(const AstNodeBiop* nodep) { - return (VN_IS(nodep->rhsp(), Const) - && !VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState() - && (VN_AS_CONST(nodep->rhsp(), Const)->toUInt() - >= static_cast(nodep->width())) + return (VN_IS(nodep->rhsp(), Const) && !VN_AS(nodep->rhsp(), Const)->num().isFourState() + && (VN_AS(nodep->rhsp(), Const)->toUInt() >= static_cast(nodep->width())) && isTPure(nodep->lhsp())); } bool operandHugeShiftR(const AstNodeBiop* nodep) { - return (VN_IS(nodep->rhsp(), Const) - && !VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState() - && (VN_AS_CONST(nodep->rhsp(), Const)->toUInt() + return (VN_IS(nodep->rhsp(), Const) && !VN_AS(nodep->rhsp(), Const)->num().isFourState() + && (VN_AS(nodep->rhsp(), Const)->toUInt() >= static_cast(nodep->lhsp()->width())) && isTPure(nodep->lhsp())); } bool operandIsTwo(const AstNode* nodep) { - return (VN_IS(nodep, Const) && !VN_AS_CONST(nodep, Const)->num().isFourState() - && nodep->width() <= VL_QUADSIZE && VN_AS_CONST(nodep, Const)->toUQuad() == 2); + return (VN_IS(nodep, Const) && !VN_AS(nodep, Const)->num().isFourState() + && nodep->width() <= VL_QUADSIZE && VN_AS(nodep, Const)->toUQuad() == 2); } bool operandIsTwostate(const AstNode* nodep) { - return (VN_IS(nodep, Const) && !VN_AS_CONST(nodep, Const)->num().isFourState()); + return (VN_IS(nodep, Const) && !VN_AS(nodep, Const)->num().isFourState()); } bool operandIsPowTwo(const AstNode* nodep) { if (!operandIsTwostate(nodep)) return false; - return (1 == VN_AS_CONST(nodep, Const)->num().countOnes()); + return (1 == VN_AS(nodep, Const)->num().countOnes()); } bool operandShiftOp(const AstNodeBiop* nodep) { if (!VN_IS(nodep->rhsp(), Const)) return false; @@ -1181,8 +1178,8 @@ private: // We can only get rid of a<>c or a<rhsp(), Const) && VN_IS(lhsp->rhsp(), Const))) return false; - if (VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState() - || VN_AS_CONST(lhsp->rhsp(), Const)->num().isFourState()) + if (VN_AS(nodep->rhsp(), Const)->num().isFourState() + || VN_AS(lhsp->rhsp(), Const)->num().isFourState()) return false; if (nodep->width() != lhsp->width()) return false; if (nodep->width() != lhsp->lhsp()->width()) return false; @@ -1193,8 +1190,8 @@ private: // It was an expression, then got constified. In reality, the WordSel // must be wrapped in a Cond, that will be false. return (VN_IS(nodep->rhsp(), Const) && VN_IS(nodep->fromp(), NodeVarRef) - && VN_AS_CONST(nodep->fromp(), NodeVarRef)->access().isReadOnly() - && (static_cast(VN_AS_CONST(nodep->rhsp(), Const)->toUInt()) + && VN_AS(nodep->fromp(), NodeVarRef)->access().isReadOnly() + && (static_cast(VN_AS(nodep->rhsp(), Const)->toUInt()) >= VN_AS(nodep->fromp(), NodeVarRef)->varp()->widthWords())); } bool operandSelFull(const AstSel* nodep) { @@ -1289,11 +1286,11 @@ private: // EQ(const{width32}, EXTEND(xx{width3})) -> constant // When the constant has non-zero bits above the extend it's a constant. // Avoids compiler warning - const AstExtend* extendp = VN_CAST_CONST(nodep->rhsp(), Extend); + const AstExtend* extendp = VN_CAST(nodep->rhsp(), Extend); if (!extendp) return false; AstNode* smallerp = extendp->lhsp(); const int subsize = smallerp->width(); - const AstConst* constp = VN_CAST_CONST(nodep->lhsp(), Const); + const AstConst* constp = VN_CAST(nodep->lhsp(), Const); if (!constp) return false; if (constp->num().isBitsZero(constp->width() - 1, subsize)) return false; return true; @@ -1387,8 +1384,8 @@ private: } } bool ifSameAssign(const AstNodeIf* nodep) { - const AstNodeAssign* ifp = VN_CAST_CONST(nodep->ifsp(), NodeAssign); - const AstNodeAssign* elsep = VN_CAST_CONST(nodep->elsesp(), NodeAssign); + const AstNodeAssign* ifp = VN_CAST(nodep->ifsp(), NodeAssign); + const AstNodeAssign* elsep = VN_CAST(nodep->elsesp(), NodeAssign); if (!ifp || ifp->nextp()) return false; // Must be SINGLE statement if (!elsep || elsep->nextp()) return false; if (ifp->type() != elsep->type()) return false; // Can't mix an assigndly and an assign @@ -1399,7 +1396,7 @@ private: } bool operandIfIf(const AstNodeIf* nodep) { if (nodep->elsesp()) return false; - const AstNodeIf* lowerIfp = VN_CAST_CONST(nodep->ifsp(), NodeIf); + const AstNodeIf* lowerIfp = VN_CAST(nodep->ifsp(), NodeIf); if (!lowerIfp || lowerIfp->nextp()) return false; if (nodep->type() != lowerIfp->type()) return false; if (afterComment(lowerIfp->elsesp())) return false; @@ -1414,10 +1411,10 @@ private: const AstNode* lfromp = lhsp->fromp(); const AstNode* rfromp = rhsp->fromp(); if (!lfromp || !rfromp || !lfromp->sameGateTree(rfromp)) return false; - const AstConst* lstart = VN_CAST_CONST(lhsp->lsbp(), Const); - const AstConst* rstart = VN_CAST_CONST(rhsp->lsbp(), Const); - const AstConst* lwidth = VN_CAST_CONST(lhsp->widthp(), Const); - const AstConst* rwidth = VN_CAST_CONST(rhsp->widthp(), Const); + const AstConst* lstart = VN_CAST(lhsp->lsbp(), Const); + const AstConst* rstart = VN_CAST(rhsp->lsbp(), Const); + const AstConst* lwidth = VN_CAST(lhsp->widthp(), Const); + const AstConst* rwidth = VN_CAST(rhsp->widthp(), Const); if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated const int rend = (rstart->toSInt() + rwidth->toSInt()); return (rend == lstart->toSInt()); @@ -1465,8 +1462,8 @@ private: if (lhsp->type() != rhsp->type()) return false; if (!ifConcatMergeableBiop(lhsp)) return false; - const AstNodeBiop* lp = VN_CAST_CONST(lhsp, NodeBiop); - const AstNodeBiop* rp = VN_CAST_CONST(rhsp, NodeBiop); + const AstNodeBiop* lp = VN_CAST(lhsp, NodeBiop); + const AstNodeBiop* rp = VN_CAST(rhsp, NodeBiop); if (!lp || !rp) return false; // {a[]&b[], a[]&b[]} const bool lad = ifMergeAdjacent(lp->lhsp(), rp->lhsp()); @@ -2128,12 +2125,11 @@ private: bool operandBoolShift(const AstNode* nodep) { // boolean test of AND(const,SHIFTR(x,const)) -> test of AND(SHIFTL(x,const), x) if (!VN_IS(nodep, And)) return false; - if (!VN_IS(VN_AS_CONST(nodep, And)->lhsp(), Const)) return false; - if (!VN_IS(VN_AS_CONST(nodep, And)->rhsp(), ShiftR)) return false; - const AstShiftR* shiftp = VN_AS(VN_AS_CONST(nodep, And)->rhsp(), ShiftR); + if (!VN_IS(VN_AS(nodep, And)->lhsp(), Const)) return false; + if (!VN_IS(VN_AS(nodep, And)->rhsp(), ShiftR)) return false; + const AstShiftR* shiftp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR); if (!VN_IS(shiftp->rhsp(), Const)) return false; - if (static_cast(nodep->width()) - <= VN_AS_CONST(shiftp->rhsp(), Const)->toUInt()) { + if (static_cast(nodep->width()) <= VN_AS(shiftp->rhsp(), Const)->toUInt()) { return false; } return true; diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index 4c56aee73..f9e85f5be 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -78,7 +78,7 @@ string EmitCBaseVisitor::cFuncArgs(const AstCFunc* nodep) { } // Might be a user function with argument list. for (const AstNode* stmtp = nodep->argsp(); stmtp; stmtp = stmtp->nextp()) { - if (const AstVar* portp = VN_CAST_CONST(stmtp, Var)) { + if (const AstVar* portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn()) { if (args != "") args += ", "; if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) { @@ -134,9 +134,8 @@ void EmitCBaseVisitor::emitVarDecl(const AstVar* nodep, bool asRef) { const auto emitDeclArrayBrackets = [this](const AstVar* nodep) -> void { // This isn't very robust and may need cleanup for other data types - for (const AstUnpackArrayDType* arrayp - = VN_CAST_CONST(nodep->dtypeSkipRefp(), UnpackArrayDType); - arrayp; arrayp = VN_CAST_CONST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) { + for (const AstUnpackArrayDType* arrayp = VN_CAST(nodep->dtypeSkipRefp(), UnpackArrayDType); + arrayp; arrayp = VN_CAST(arrayp->subDTypep()->skipRefp(), UnpackArrayDType)) { puts("[" + cvtToStr(arrayp->elementsConst()) + "]"); } }; diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 564926899..5843c80bc 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -41,7 +41,7 @@ public: VL_UNCOPYABLE(EmitCParentModule); static const AstNodeModule* get(const AstNode* nodep) { - return VN_AS_CONST(nodep->user4p(), NodeModule); + return VN_AS(nodep->user4p(), NodeModule); } }; diff --git a/src/V3EmitCConstPool.cpp b/src/V3EmitCConstPool.cpp index abd50bd41..0aee902c4 100644 --- a/src/V3EmitCConstPool.cpp +++ b/src/V3EmitCConstPool.cpp @@ -68,7 +68,7 @@ class EmitCConstPool final : public EmitCConstInit { void emitVars(const AstConstPool* poolp) { std::vector varps; for (AstNode* nodep = poolp->modp()->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { varps.push_back(varp); } + if (const AstVar* const varp = VN_CAST(nodep, Var)) { varps.push_back(varp); } } if (varps.empty()) return; // Constant pool is empty, so we are done diff --git a/src/V3EmitCHeaders.cpp b/src/V3EmitCHeaders.cpp index 46f2c5349..f4b9a18de 100644 --- a/src/V3EmitCHeaders.cpp +++ b/src/V3EmitCHeaders.cpp @@ -40,7 +40,7 @@ class EmitCHeader final : public EmitCConstInit { void emitCellDecls(const AstNodeModule* modp) { bool first = true; for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstCell* const cellp = VN_CAST_CONST(nodep, Cell)) { + if (const AstCell* const cellp = VN_CAST(nodep, Cell)) { decorateFirst(first, "// CELLS\n"); puts(prefixNameProtect(cellp->modp()) + "* " + cellp->nameProtect() + ";\n"); } @@ -102,7 +102,7 @@ class EmitCHeader final : public EmitCConstInit { // Emit variables in consecutive anon and non-anon batches for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (varp->isIO() || varp->isSignal() || varp->isClassMember() || varp->isTemp()) { const bool anon = isAnonOk(varp); if (anon != lastAnon) emitCurrentList(); @@ -179,7 +179,7 @@ class EmitCHeader final : public EmitCConstInit { void emitEnums(const AstNodeModule* modp) { bool first = true; for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - const AstTypedef* const tdefp = VN_CAST_CONST(nodep, Typedef); + const AstTypedef* const tdefp = VN_CAST(nodep, Typedef); if (!tdefp) continue; if (!tdefp->attrPublic()) continue; const AstEnumDType* const edtypep @@ -206,7 +206,7 @@ class EmitCHeader final : public EmitCConstInit { std::vector funcsp; for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstCFunc* const funcp = VN_CAST_CONST(nodep, CFunc)) { + if (const AstCFunc* const funcp = VN_CAST(nodep, CFunc)) { if (funcp->dpiImportPrototype()) // Declared in __Dpi.h continue; if (funcp->dpiExportDispatcher()) // Declared in __Dpi.h @@ -230,7 +230,7 @@ class EmitCHeader final : public EmitCConstInit { } void emitAll(const AstNodeModule* modp) { // Include files required by this AstNodeModule - if (const AstClass* const classp = VN_CAST_CONST(modp, Class)) { + if (const AstClass* const classp = VN_CAST(modp, Class)) { if (classp->extendsp()) puts("#include \"" + prefixNameProtect(classp->extendsp()->classp()->classOrPackagep()) @@ -246,7 +246,7 @@ class EmitCHeader final : public EmitCConstInit { emitTextSection(modp, AstType::atScHdr); // Open class body {{{ - if (const AstClass* const classp = VN_CAST_CONST(modp, Class)) { + if (const AstClass* const classp = VN_CAST(modp, Class)) { puts("class "); puts(prefixNameProtect(modp)); if (classp->extendsp()) { @@ -310,7 +310,7 @@ class EmitCHeader final : public EmitCConstInit { emitAll(modp); - if (const AstClassPackage* const packagep = VN_CAST_CONST(modp, ClassPackage)) { + if (const AstClassPackage* const packagep = VN_CAST(modp, ClassPackage)) { // Put the non-static class implementation in same h file for speed emitAll(packagep->classp()); } @@ -335,6 +335,6 @@ void V3EmitC::emitcHeaders() { // Process each module in turn for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) { if (VN_IS(nodep, Class)) continue; // Declared with the ClassPackage - EmitCHeader::main(VN_AS_CONST(nodep, NodeModule)); + EmitCHeader::main(VN_AS(nodep, NodeModule)); } } diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 3bf5b3ca5..73aff137d 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -38,14 +38,14 @@ class EmitCGatherDependencies final : AstNVisitor { // METHODS void addSymsDependency() { m_dependencies.insert(EmitCBaseVisitor::symClassName()); } void addModDependency(const AstNodeModule* modp) { - if (const AstClass* const classp = VN_CAST_CONST(modp, Class)) { + if (const AstClass* const classp = VN_CAST(modp, Class)) { m_dependencies.insert(EmitCBaseVisitor::prefixNameProtect(classp->classOrPackagep())); } else { m_dependencies.insert(EmitCBaseVisitor::prefixNameProtect(modp)); } } void addDTypeDependency(const AstNodeDType* nodep) { - if (const AstClassRefDType* const dtypep = VN_CAST_CONST(nodep, ClassRefDType)) { + if (const AstClassRefDType* const dtypep = VN_CAST(nodep, ClassRefDType)) { m_dependencies.insert( EmitCBaseVisitor::prefixNameProtect(dtypep->classp()->classOrPackagep())); } @@ -193,7 +193,7 @@ class EmitCImp final : EmitCFunc { // Emit static variable definitions const string modName = prefixNameProtect(modp); for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (varp->isStatic()) { puts(varp->vlArgType(true, false, false, modName)); puts(";\n"); @@ -205,7 +205,7 @@ class EmitCImp final : EmitCFunc { const string modName = prefixNameProtect(modp); bool first = true; for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (varp->isParam()) { if (first) { puts("\n"); @@ -241,7 +241,7 @@ class EmitCImp final : EmitCFunc { ofp()->indentInc(); for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (const AstBasicDType* const dtypep = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { if (dtypep->keyword().isMTaskState()) { @@ -446,7 +446,7 @@ class EmitCImp final : EmitCFunc { } void emitCommonImp(const AstNodeModule* modp) { const AstClass* const classp - = VN_IS(modp, ClassPackage) ? VN_AS_CONST(modp, ClassPackage)->classp() : nullptr; + = VN_IS(modp, ClassPackage) ? VN_AS(modp, ClassPackage)->classp() : nullptr; if (hasCommonImp(modp) || hasCommonImp(classp)) { std::set headers; @@ -486,7 +486,7 @@ class EmitCImp final : EmitCFunc { }; gather(modp); - if (const AstClassPackage* const packagep = VN_CAST_CONST(modp, ClassPackage)) { + if (const AstClassPackage* const packagep = VN_CAST(modp, ClassPackage)) { gather(packagep->classp()); } @@ -887,7 +887,7 @@ void V3EmitC::emitcImp() { // Process each module in turn for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) { if (VN_IS(nodep, Class)) continue; // Imped with ClassPackage - const AstNodeModule* const modp = VN_AS_CONST(nodep, NodeModule); + const AstNodeModule* const modp = VN_AS(nodep, NodeModule); EmitCImp::main(modp, /* slow: */ true); EmitCImp::main(modp, /* slow: */ false); } diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 2a7c087bd..10688305d 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -90,7 +90,7 @@ class EmitCModel final : public EmitCFunc { "// The application code writes and reads these signals to\n" "// propagate new values into/out from the Verilated model.\n"); for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (varp->isPrimaryIO()) { // emitVarDecl(varp, /* asRef: */ true); } @@ -102,7 +102,7 @@ class EmitCModel final : public EmitCFunc { "// Public to allow access to /* verilator public */ items.\n" "// Otherwise the application code can consider these internals.\n"); for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstCell* const cellp = VN_CAST_CONST(nodep, Cell)) { + if (const AstCell* const cellp = VN_CAST(nodep, Cell)) { puts(prefixNameProtect(cellp->modp()) + "* const " + cellp->nameProtect() + ";\n"); } } @@ -237,7 +237,7 @@ class EmitCModel final : public EmitCFunc { // Set up IO references for (const AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* const varp = VN_CAST_CONST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (varp->isPrimaryIO()) { const string protName = varp->nameProtect(); puts(" , " + protName + "{vlSymsp->TOP." + protName + "}\n"); @@ -247,7 +247,7 @@ class EmitCModel final : public EmitCFunc { // Setup cell pointers for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstCell* const cellp = VN_CAST_CONST(nodep, Cell)) { + if (const AstCell* const cellp = VN_CAST(nodep, Cell)) { const string protName = cellp->nameProtect(); puts(" , " + protName + "{vlSymsp->TOP." + protName + "}\n"); } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index e0948ffb7..d2388e2d5 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -99,7 +99,7 @@ public: class LinkNodeMatcherVarIO final : public VNodeMatcher { public: virtual bool nodeMatch(const AstNode* nodep) const override { - const AstVar* varp = VN_CAST_CONST(nodep, Var); + const AstVar* varp = VN_CAST(nodep, Var); if (!varp) return false; return varp->isIO(); } @@ -107,7 +107,7 @@ public: class LinkNodeMatcherVarParam final : public VNodeMatcher { public: virtual bool nodeMatch(const AstNode* nodep) const override { - const AstVar* varp = VN_CAST_CONST(nodep, Var); + const AstVar* varp = VN_CAST(nodep, Var); if (!varp) return false; return varp->isParam(); } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 0b05e6f0d..f8bbf8bcb 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -169,17 +169,17 @@ private: // Predicate to check if an expression yields only 0 or 1 (i.e.: a 1-bit value) static bool yieldsOneOrZero(const AstNode* nodep) { UASSERT_OBJ(!nodep->isWide(), nodep, "Cannot handle wide nodes"); - if (const AstConst* const constp = VN_CAST_CONST(nodep, Const)) { + if (const AstConst* const constp = VN_CAST(nodep, Const)) { return constp->num().toUQuad() <= 1; } - if (const AstVarRef* const vrefp = VN_CAST_CONST(nodep, VarRef)) { + if (const AstVarRef* const vrefp = VN_CAST(nodep, VarRef)) { AstVar* const varp = vrefp->varp(); return varp->widthMin() == 1 && !varp->dtypep()->isSigned(); } - if (const AstShiftR* const shiftp = VN_CAST_CONST(nodep, ShiftR)) { + if (const AstShiftR* const shiftp = VN_CAST(nodep, ShiftR)) { // Shift right by width - 1 or more - if (const AstConst* const constp = VN_CAST_CONST(shiftp->rhsp(), Const)) { - const AstVarRef* const vrefp = VN_CAST_CONST(shiftp->lhsp(), VarRef); + if (const AstConst* const constp = VN_CAST(shiftp->rhsp(), Const)) { + const AstVarRef* const vrefp = VN_CAST(shiftp->lhsp(), VarRef); const int width = vrefp && !vrefp->varp()->dtypep()->isSigned() ? vrefp->varp()->widthMin() : shiftp->width(); @@ -191,17 +191,17 @@ private: || VN_IS(nodep, Gt) || VN_IS(nodep, Gte)) { return true; } - if (const AstNodeBiop* const biopp = VN_CAST_CONST(nodep, NodeBiop)) { + if (const AstNodeBiop* const biopp = VN_CAST(nodep, NodeBiop)) { if (VN_IS(nodep, And)) return yieldsOneOrZero(biopp->lhsp()) || yieldsOneOrZero(biopp->rhsp()); if (VN_IS(nodep, Or) || VN_IS(nodep, Xor)) return yieldsOneOrZero(biopp->lhsp()) && yieldsOneOrZero(biopp->rhsp()); return false; } - if (const AstNodeCond* const condp = VN_CAST_CONST(nodep, NodeCond)) { + if (const AstNodeCond* const condp = VN_CAST(nodep, NodeCond)) { return yieldsOneOrZero(condp->expr1p()) && yieldsOneOrZero(condp->expr2p()); } - if (const AstCCast* const castp = VN_CAST_CONST(nodep, CCast)) { + if (const AstCCast* const castp = VN_CAST(nodep, CCast)) { // Cast never sign extends return yieldsOneOrZero(castp->lhsp()); } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index d59863661..78be0c482 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -301,11 +301,9 @@ class ParamProcessor final { } static string paramValueKey(const AstNode* nodep) { - if (const AstRefDType* const refp = VN_CAST_CONST(nodep, RefDType)) { - nodep = refp->skipRefp(); - } + if (const AstRefDType* const refp = VN_CAST(nodep, RefDType)) { nodep = refp->skipRefp(); } string key = nodep->name(); - if (const AstIfaceRefDType* const ifrtp = VN_CAST_CONST(nodep, IfaceRefDType)) { + if (const AstIfaceRefDType* const ifrtp = VN_CAST(nodep, IfaceRefDType)) { if (ifrtp->cellp() && ifrtp->cellp()->modp()) { key = ifrtp->cellp()->modp()->name(); } else if (ifrtp->ifacep()) { @@ -314,7 +312,7 @@ class ParamProcessor final { nodep->v3fatalSrc("Can't parameterize interface without module name"); } } else if (const AstNodeUOrStructDType* const dtypep - = VN_CAST_CONST(nodep, NodeUOrStructDType)) { + = VN_CAST(nodep, NodeUOrStructDType)) { key += " "; key += dtypep->verilogKwd(); key += " {"; @@ -324,10 +322,10 @@ class ParamProcessor final { key += ";"; } key += "}"; - } else if (const AstMemberDType* const dtypep = VN_CAST_CONST(nodep, MemberDType)) { + } else if (const AstMemberDType* const dtypep = VN_CAST(nodep, MemberDType)) { key += " "; key += paramValueKey(dtypep->subDTypep()); - } else if (const AstBasicDType* const dtypep = VN_CAST_CONST(nodep, BasicDType)) { + } else if (const AstBasicDType* const dtypep = VN_CAST(nodep, BasicDType)) { if (dtypep->isRanged()) { key += "[" + cvtToStr(dtypep->left()) + ":" + cvtToStr(dtypep->right()) + "]"; } diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 35e601a87..727538ada 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -245,7 +245,7 @@ private: public: void newValue(AstNode* nodep, const AstNode* valuep) { - if (const AstConst* constp = VN_CAST_CONST(valuep, Const)) { + if (const AstConst* constp = VN_CAST(valuep, Const)) { newConst(nodep)->num().opAssign(constp->num()); } else if (fetchValueNull(nodep) != valuep) { // const_cast, as clonep() is set on valuep, but nothing should care @@ -253,7 +253,7 @@ public: } } void newOutValue(AstNode* nodep, const AstNode* valuep) { - if (const AstConst* constp = VN_CAST_CONST(valuep, Const)) { + if (const AstConst* constp = VN_CAST(valuep, Const)) { newOutConst(nodep)->num().opAssign(constp->num()); } else if (fetchOutValueNull(nodep) != valuep) { // const_cast, as clonep() is set on valuep, but nothing should care diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 9123df814..3541c63de 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -416,7 +416,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { } static int outerMostSizeOfUnpackedArray(const AstVar* nodep) { const AstUnpackArrayDType* const dtypep - = VN_AS_CONST(nodep->dtypep()->skipRefp(), UnpackArrayDType); + = VN_AS(nodep->dtypep()->skipRefp(), UnpackArrayDType); UASSERT_OBJ(dtypep, nodep, "Must be unapcked array"); return dtypep->elementsConst(); } diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 0e2eeffb6..bf878eb18 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -221,7 +221,7 @@ private: const auto dupit = dupFinder.findDuplicate(nodep->valuep()); if (dupit != dupFinder.end()) { const AstTraceDecl* const dupDeclp - = VN_AS_CONST(dupit->second->backp(), TraceDecl); + = VN_AS(dupit->second->backp(), TraceDecl); UASSERT_OBJ(dupDeclp, nodep, "Trace duplicate of wrong type"); TraceTraceVertex* const dupvertexp = dynamic_cast(dupDeclp->user1u().toGraphVertex()); diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index c6c335f57..d1bcbb66e 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -301,7 +301,7 @@ private: addIgnore("Unsupported: Unpacked struct/union"); } else { for (const AstMemberDType* itemp = nodep->membersp(); itemp; - itemp = VN_AS_CONST(itemp->nextp(), MemberDType)) { + itemp = VN_AS(itemp->nextp(), MemberDType)) { AstNodeDType* const subtypep = itemp->subDTypep()->skipRefToEnump(); VL_RESTORER(m_traShowname); VL_RESTORER(m_traValuep); From 5515eed0b67422a3219027a98fed9aea203c0e7a Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sun, 17 Oct 2021 10:29:17 +0100 Subject: [PATCH 11/79] Make AstTopScope accessible from AstNetlist AstTopScope is a singleton node and making it accessible without a traversal simplifies some code and decouple some other. --- src/V3ActiveTop.cpp | 9 +-------- src/V3AstNodes.h | 30 +++++++++++++++++++++--------- src/V3GenClk.cpp | 7 +------ src/V3Order.cpp | 2 -- src/V3Scope.cpp | 3 +-- src/V3SenTree.h | 23 ++++++++++------------- src/V3Task.cpp | 6 +----- src/V3Trace.cpp | 8 +------- src/V3TraceDecl.cpp | 3 +-- 9 files changed, 37 insertions(+), 54 deletions(-) diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 3fe652d58..52556d5ba 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -45,19 +45,12 @@ private: AstUser1InUse m_inuser1; // STATE - AstTopScope* m_topscopep = nullptr; // Top scope for adding sentrees under - SenTreeFinder m_finder; // Find global sentree's and add them + SenTreeFinder m_finder; // Find global sentree's / add them under the AstTopScope // METHODS VL_DEBUG_FUNC; // Declare debug() // VISITORS - virtual void visit(AstTopScope* nodep) override { - m_topscopep = nodep; - m_finder.init(m_topscopep); - iterateChildren(nodep); - m_topscopep = nullptr; - } virtual void visit(AstNodeModule* nodep) override { // Create required actives and add to module // We can start ordering at a module, or a scope diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 303bf7894..b109c4928 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2333,19 +2333,22 @@ public: }; class AstTopScope final : public AstNode { - // In the top level netlist, a complete scope tree - // There may be two of these, when we support "rare" and "usual" splitting - // Parents: topMODULE - // Children: SCOPEs -public: + // A singleton, held under the top level AstModule. Holds the top level AstScope, + // and after V3ActiveTop, the global list of AstSenTrees (list of unique sensitivity lists). + // Parent: Top level AstModule + // Children: AstSenTree, AstScope + friend class AstNetlist; // Only the AstNetlist can create one AstTopScope(FileLine* fl, AstScope* ascopep) : ASTGEN_SUPER_TopScope(fl) { - addNOp2p(ascopep); + addOp2p(ascopep); } + +public: ASTNODE_NODE_FUNCS(TopScope) - AstNode* stmtsp() const { return op1p(); } - void addStmtsp(AstNode* nodep) { addOp1p(nodep); } - AstScope* scopep() const { return VN_AS(op2p(), Scope); } // op1 = AstVarScope's + virtual bool maybePointedTo() const override { return true; } + AstSenTree* senTreesp() const { return VN_AS(op1p(), SenTree); } + void addSenTreep(AstSenTree* nodep) { addOp1p((AstNode*)nodep); } + AstScope* scopep() const { return VN_AS(op2p(), Scope); } }; class AstVarScope final : public AstNode { @@ -9191,6 +9194,7 @@ private: AstCFunc* m_evalp = nullptr; // The '_eval' function AstExecGraph* m_execGraphp = nullptr; // Execution MTask graph for threads>1 mode AstVarScope* m_dpiExportTriggerp = nullptr; // The DPI export trigger variable + AstTopScope* m_topScopep = nullptr; // The singleton AstTopScope under the top module VTimescale m_timeunit; // Global time unit VTimescale m_timeprecision; // Global time precision bool m_changeRequest = false; // Have _change_request method @@ -9202,6 +9206,7 @@ public: BROKEN_RTN(m_dollarUnitPkgp && !m_dollarUnitPkgp->brokeExists()); BROKEN_RTN(m_evalp && !m_evalp->brokeExists()); BROKEN_RTN(m_dpiExportTriggerp && !m_dpiExportTriggerp->brokeExists()); + BROKEN_RTN(m_topScopep && !m_topScopep->brokeExists()); return nullptr; } virtual string name() const override { return "$root"; } @@ -9239,6 +9244,13 @@ public: void execGraphp(AstExecGraph* graphp) { m_execGraphp = graphp; } AstVarScope* dpiExportTriggerp() const { return m_dpiExportTriggerp; } void dpiExportTriggerp(AstVarScope* varScopep) { m_dpiExportTriggerp = varScopep; } + AstTopScope* topScopep() const { return m_topScopep; } + void createTopScope(AstScope* scopep) { + UASSERT(scopep, "Must not be nullptr"); + UASSERT_OBJ(!m_topScopep, scopep, "TopScope already exits"); + m_topScopep = new AstTopScope{scopep->modp()->fileline(), scopep}; + scopep->modp()->addStmtp(v3Global.rootp()->topScopep()); + } VTimescale timeunit() const { return m_timeunit; } void timeunit(const VTimescale& value) { m_timeunit = value; } VTimescale timeprecision() const { return m_timeprecision; } diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index f766b7a4a..cf7c4fc54 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -49,7 +49,7 @@ private: // STATE AstActive* m_activep = nullptr; // Inside activate statement AstNodeModule* m_topModp; // Top module - AstScope* m_scopetopp = nullptr; // Scope under TOPSCOPE + AstScope* const m_scopetopp = v3Global.rootp()->topScopep()->scopep(); // The top AstScope // METHODS AstVarScope* genInpClk(AstVarScope* vscp) { @@ -93,11 +93,6 @@ private: // VISITORS virtual void visit(AstTopScope* nodep) override { AstNode::user2ClearTree(); // user2p() used on entire tree - - AstScope* scopep = nodep->scopep(); - UASSERT_OBJ(scopep, nodep, "No scope found on top level"); - m_scopetopp = scopep; - iterateChildren(nodep); } //---- diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 0c1994fa3..98cb21f7e 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -941,8 +941,6 @@ private: m_activep = nullptr; m_topScopep = nodep; m_scopetopp = nodep->scopep(); - // Find global SenTrees - m_finder.init(m_topScopep); // ProcessDomainsIterate will use these when it needs to move // something to a combodomain. This saves a ton of find() operations. AstSenTree* combp diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index d9ed9ce9f..d9b73b4de 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -132,8 +132,7 @@ private: AstNode::user1ClearTree(); m_modp = nodep; if (m_modp->isTop()) { - AstTopScope* topscp = new AstTopScope(nodep->fileline(), m_scopep); - m_modp->addStmtp(topscp); + v3Global.rootp()->createTopScope(m_scopep); } else { m_modp->addStmtp(m_scopep); } diff --git a/src/V3SenTree.h b/src/V3SenTree.h index 5abca02f6..243d493fa 100644 --- a/src/V3SenTree.h +++ b/src/V3SenTree.h @@ -74,14 +74,21 @@ private: class SenTreeFinder final { private: // STATE - AstTopScope* m_topScopep = nullptr; // Top scope to add global SenTrees to + AstTopScope* const m_topScopep; // Top scope to add global SenTrees to SenTreeSet m_trees; // Set of global SenTrees VL_UNCOPYABLE(SenTreeFinder); public: // CONSTRUCTORS - SenTreeFinder() = default; + SenTreeFinder() + : m_topScopep{v3Global.rootp()->topScopep()} { + // Gather existing global SenTrees + for (AstSenTree* nodep = m_topScopep->senTreesp(); nodep; + nodep = VN_AS(nodep->nextp(), SenTree)) { + m_trees.add(nodep); + } + } // METHODS AstSenTree* getSenTree(AstSenTree* senTreep) { @@ -90,23 +97,13 @@ public: AstSenTree* treep = m_trees.find(senTreep); // Not found, form a new one if (!treep) { - UASSERT(m_topScopep, "Never called init()"); treep = senTreep->cloneTree(false); - m_topScopep->addStmtsp(treep); + m_topScopep->addSenTreep(treep); UINFO(8, " New SENTREE " << treep << endl); m_trees.add(treep); } return treep; } - - void init(AstTopScope* topScopep) { - // Keep hold of top scope so we can add global SenTrees later - m_topScopep = topScopep; - // Gather existing global SenTrees - for (AstNode* nodep = topScopep->stmtsp(); nodep; nodep = nodep->nextp()) { - if (AstSenTree* senTreep = VN_CAST(nodep, SenTree)) m_trees.add(senTreep); - } - } }; #endif // Guard diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 8db34120f..73042fe34 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -423,7 +423,7 @@ private: // STATE TaskStateVisitor* m_statep; // Common state between visitors AstNodeModule* m_modp = nullptr; // Current module - AstTopScope* m_topScopep = nullptr; // Current top scope + AstTopScope* const m_topScopep = v3Global.rootp()->topScopep(); // The AstTopScope AstScope* m_scopep = nullptr; // Current scope InsertMode m_insMode = IM_BEFORE; // How to insert AstNode* m_insStmtp = nullptr; // Where to insert statement @@ -1392,10 +1392,6 @@ private: iterateChildren(nodep); } } - virtual void visit(AstTopScope* nodep) override { - m_topScopep = nodep; - iterateChildren(nodep); - } virtual void visit(AstScope* nodep) override { m_scopep = nodep; m_insStmtp = nullptr; diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index bf878eb18..a2b3553da 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -169,7 +169,7 @@ private: // STATE AstNodeModule* m_topModp = nullptr; // Module to add variables to - AstScope* m_topScopep = nullptr; // Scope to add variables to + AstScope* const m_topScopep = v3Global.rootp()->topScopep()->scopep(); // The top AstScope AstCFunc* m_cfuncp = nullptr; // C function adding to graph AstCFunc* m_regFuncp = nullptr; // Trace registration function AstTraceDecl* m_tracep = nullptr; // Trace function adding to graph @@ -808,12 +808,6 @@ private: if (nodep->isTop()) m_topModp = nodep; iterateChildren(nodep); } - virtual void visit(AstTopScope* nodep) override { - AstScope* const scopep = nodep->scopep(); - UASSERT_OBJ(scopep, nodep, "No scope found on top level"); - m_topScopep = scopep; - iterateChildren(nodep); - } virtual void visit(AstCCall* nodep) override { UINFO(8, " CCALL " << nodep << endl); if (!m_finding && !nodep->user2()) { diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index d1bcbb66e..a37ddb8c8 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -37,7 +37,7 @@ private: // NODE STATE // STATE - AstScope* m_topScopep = nullptr; // Current top scope + AstScope* const m_topScopep = v3Global.rootp()->topScopep()->scopep(); // The top AstScope AstCFunc* m_initFuncp = nullptr; // Trace function being built AstCFunc* m_initSubFuncp = nullptr; // Trace function being built (under m_init) int m_initSubStmts = 0; // Number of statements in function @@ -136,7 +136,6 @@ private: // VISITORS virtual void visit(AstTopScope* nodep) override { - m_topScopep = nodep->scopep(); // Create the trace init function m_initFuncp = newCFunc("trace_init_top"); // Create initial sub function From f5a226a183da220c7034b3e71519c12ec8ec87b3 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sun, 17 Oct 2021 11:40:44 +0100 Subject: [PATCH 12/79] Partial clean up of V3Order. No functional change intended. This is a partial cleanup of V3Order with the aim of increasing clarity: - Split the initial OrderGraph building and the actual ordering process into separate classes (OrderVisitor -> OrderBuildVisitor + OrderProcess) - Remove all the historical cruft from the graph building phase (now in OrderBuildVisitor), and add more assertions for assumptions. - Change the dot styling of OrderGraph to use shapes and more easily distinguishable colors. - Expand vague comments, remove incorrect comments, and add more. - Replace some old code with cleaner C++11 constructs. - Move code about a bit so logically connected sections are closer to each other, scope some definitions where they are used rather than file scope. - The actual ordering process (now in OrderProcess) is still largely unchanged. The generated code is identical to before (within the limits of the exiting non-determinism). --- src/V3Ast.cpp | 6 +- src/V3Ast.h | 34 +- src/V3AstNodes.h | 12 +- src/V3Class.cpp | 5 +- src/V3Order.cpp | 1286 +++++++++++++++++++++++--------------------- src/V3OrderGraph.h | 16 +- src/V3SenTree.h | 27 +- src/astgen | 24 +- 8 files changed, 742 insertions(+), 668 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 0fecb49a5..d1e1123c6 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1276,9 +1276,9 @@ AstNodeDType* AstNode::findVoidDType() const { } //###################################################################### -// AstNVisitor +// AstNDeleter -void AstNVisitor::doDeletes() { - for (AstNode* nodep : m_deleteps) nodep->deleteTree(); +void AstNDeleter::doDeletes() { + for (AstNode* const nodep : m_deleteps) nodep->deleteTree(); m_deleteps.clear(); } diff --git a/src/V3Ast.h b/src/V3Ast.h index a65b1656f..cec0f4a26 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1251,31 +1251,39 @@ public: // clang-format on //###################################################################### -// AstNVisitor -- Allows new functions to be called on each node -// type without changing the base classes. See "Modern C++ Design". +// Node deleter, deletes all enqueued AstNode* on destruction, or when +// explicitly told to do so. This is useful when the deletion of removed +// nodes needs to be deferred to a later time, because pointers to the +// removed nodes might still exist. -class AstNVisitor VL_NOT_FINAL { -private: +class AstNDeleter VL_NOT_FINAL { // MEMBERS - std::vector m_deleteps; // Nodes to delete when doDeletes() called -protected: - friend class AstNode; + std::vector m_deleteps; // Nodes to delete public: // METHODS - /// At the end of the visitor (or doDeletes()), delete this pushed node - /// along with all children and next(s). This is often better to use - /// than an immediate deleteTree, as any pointers into this node will - /// persist for the lifetime of the visitor + + // Enqueue node for deletion on next 'doDelete' (or destruction) void pushDeletep(AstNode* nodep) { UASSERT_STATIC(nodep, "Cannot delete nullptr node"); m_deleteps.push_back(nodep); } - /// Call deleteTree on all previously pushDeletep()'ed nodes + + // Delete all previously pushed nodes (by callint deleteTree) void doDeletes(); + // Do the deletions on destruction + virtual ~AstNDeleter() { doDeletes(); } +}; + +//###################################################################### +// AstNVisitor -- Allows new functions to be called on each node +// type without changing the base classes. See "Modern C++ Design". + +class AstNVisitor VL_NOT_FINAL : public AstNDeleter { + friend class AstNode; + public: - virtual ~AstNVisitor() { doDeletes(); } /// Call visit()s on nodep void iterate(AstNode* nodep); /// Call visit()s on nodep diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index b109c4928..9a409fd92 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2300,9 +2300,9 @@ class AstScope final : public AstNode { private: // An AstScope->name() is special: . indicates an uninlined scope, __DOT__ an inlined scope string m_name; // Name - AstScope* m_aboveScopep; // Scope above this one in the hierarchy (nullptr if top) - AstCell* m_aboveCellp; // Cell above this in the hierarchy (nullptr if top) - AstNodeModule* m_modp; // Module scope corresponds to + AstScope* const m_aboveScopep; // Scope above this one in the hierarchy (nullptr if top) + AstCell* const m_aboveCellp; // Cell above this in the hierarchy (nullptr if top) + AstNodeModule* const m_modp; // Module scope corresponds to public: AstScope(FileLine* fl, AstNodeModule* modp, const string& name, AstScope* aboveScopep, AstCell* aboveCellp) @@ -2321,8 +2321,8 @@ public: string nameDotless() const; string nameVlSym() const { return ((string("vlSymsp->")) + nameDotless()); } AstNodeModule* modp() const { return m_modp; } - void addVarp(AstNode* nodep) { addOp1p(nodep); } - AstNode* varsp() const { return op1p(); } // op1 = AstVarScope's + void addVarp(AstVarScope* nodep) { addOp1p((AstNode*)nodep); } + AstVarScope* varsp() const { return VN_AS(op1p(), VarScope); } // op1 = AstVarScope's void addActivep(AstNode* nodep) { addOp2p(nodep); } AstNode* blocksp() const { return op2p(); } // op2 = Block names void addFinalClkp(AstNode* nodep) { addOp3p(nodep); } @@ -2367,6 +2367,8 @@ public: : ASTGEN_SUPER_VarScope(fl) , m_scopep{scopep} , m_varp{varp} { + UASSERT_OBJ(scopep, fl, "Scope must be non-null"); + UASSERT_OBJ(varp, fl, "Var must be non-null"); m_circular = false; m_trace = true; dtypeFrom(varp); diff --git a/src/V3Class.cpp b/src/V3Class.cpp index e317a3480..cd7fdb6f7 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -141,8 +141,9 @@ public: if (VN_IS(moved.first, NodeFTask)) { moved.second->addActivep(moved.first->unlinkFrBack()); } else if (VN_IS(moved.first, Var)) { - AstVarScope* scopep = VN_AS(moved.first->user1p(), VarScope); - moved.second->addVarp(scopep->unlinkFrBack()); + AstVarScope* const scopep = VN_AS(moved.first->user1p(), VarScope); + scopep->unlinkFrBack(); + moved.second->addVarp(scopep); } } } diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 98cb21f7e..d4e4db5b4 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -108,7 +108,71 @@ #include #include -static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top); +//###################################################################### +// Utilities + +static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) { + // Return 'true' if we can prove that both 'from' and 'to' cannot both + // be active on the same eval pass, or false if we can't prove this. + // + // This detects the case of 'always @(posedge clk)' + // and 'always @(negedge clk)' being exclusive. It also detects + // that initial/settle blocks and post-initial blocks are exclusive. + // + // Are there any other cases we need to handle? Maybe not, + // because these are not exclusive: + // always @(posedge A or posedge B) + // always @(negedge A) + // + // ... unless you know more about A and B, which sounds hard. + + const bool toInitial = top->hasInitial() || top->hasSettle(); + const bool fromInitial = fromp->hasInitial() || fromp->hasSettle(); + if (toInitial != fromInitial) return true; + + const AstSenItem* fromSenListp = fromp->sensesp(); + const AstSenItem* toSenListp = top->sensesp(); + + UASSERT_OBJ(fromSenListp, fromp, "sensitivity list empty"); + UASSERT_OBJ(toSenListp, top, "sensitivity list empty"); + + if (fromSenListp->nextp()) return false; + if (toSenListp->nextp()) return false; + + const AstNodeVarRef* fromVarrefp = fromSenListp->varrefp(); + const AstNodeVarRef* toVarrefp = toSenListp->varrefp(); + if (!fromVarrefp || !toVarrefp) return false; + + // We know nothing about the relationship between different clocks here, + // so give up on proving anything. + if (fromVarrefp->varScopep() != toVarrefp->varScopep()) return false; + + return fromSenListp->edgeType().exclusiveEdge(toSenListp->edgeType()); +} + +// Predicate returning true if the LHS of the given assignment is a signal marked as clocker +static bool isClockerAssignment(AstNodeAssign* nodep) { + class Visitor final : public AstNVisitor { + public: + bool m_clkAss = false; // There is signals marked as clocker in the assignment + private: + // METHODS + VL_DEBUG_FUNC; // Declare debug() + virtual void visit(AstNodeAssign* nodep) override { + if (const AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef)) { + if (varrefp->varp()->attrClocker() == VVarAttrClocker::CLOCKER_YES) { + m_clkAss = true; + UINFO(6, "node was marked as clocker " << varrefp << endl); + } + } + iterateChildren(nodep->rhsp()); + } + virtual void visit(AstNodeMath*) override {} // Accelerate + virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + } visitor; + visitor.iterate(nodep); + return visitor.m_clkAss; +} //###################################################################### // Functions for above graph classes @@ -125,120 +189,6 @@ void OrderGraph::loopsVertexCb(V3GraphVertex* vertexp) { } } -//###################################################################### - -class OrderMoveDomScope final { - // Information stored for each unique loop, domain & scope trifecta -public: - V3ListEnt m_readyDomScopeE; // List of next ready dom scope - V3List m_readyVertices; // Ready vertices with same domain & scope -private: - bool m_onReadyList = false; // True if DomScope is already on list of ready dom/scopes - const AstSenTree* m_domainp; // Domain all vertices belong to - const AstScope* m_scopep; // Scope all vertices belong to - - using DomScopeKey = std::pair; - using DomScopeMap = std::map; - static DomScopeMap s_dsMap; // Structure registered for each dom/scope pairing - -public: - OrderMoveDomScope(const AstSenTree* domainp, const AstScope* scopep) - : m_domainp{domainp} - , m_scopep{scopep} {} - OrderMoveDomScope* readyDomScopeNextp() const { return m_readyDomScopeE.nextp(); } - const AstSenTree* domainp() const { return m_domainp; } - const AstScope* scopep() const { return m_scopep; } - void ready(OrderVisitor* ovp); // Check the domScope is on ready list, add if not - void movedVertex( - OrderVisitor* ovp, - OrderMoveVertex* vertexp); // Mark one vertex as finished, remove from ready list if done - // STATIC MEMBERS (for lookup) - static void clear() { - for (const auto& itr : s_dsMap) delete itr.second; - s_dsMap.clear(); - } - V3List& readyVertices() { return m_readyVertices; } - static OrderMoveDomScope* findCreate(const AstSenTree* domainp, const AstScope* scopep) { - const DomScopeKey key = std::make_pair(domainp, scopep); - const auto iter = s_dsMap.find(key); - if (iter != s_dsMap.end()) { - return iter->second; - } else { - OrderMoveDomScope* domScopep = new OrderMoveDomScope(domainp, scopep); - s_dsMap.emplace(key, domScopep); - return domScopep; - } - } - string name() const { - return (string("MDS:") + " d=" + cvtToHex(domainp()) + " s=" + cvtToHex(scopep())); - } -}; - -OrderMoveDomScope::DomScopeMap OrderMoveDomScope::s_dsMap; - -inline std::ostream& operator<<(std::ostream& lhs, const OrderMoveDomScope& rhs) { - lhs << rhs.name(); - return lhs; -} - -//###################################################################### -// Order information stored under each AstNode::user1p()... - -// Types of vertex we can create -enum WhichVertex : uint8_t { WV_STD, WV_PRE, WV_PORD, WV_POST, WV_MAX }; - -class OrderUser final { - // Stored in AstVarScope::user1p, a list of all the various vertices - // that can exist for one given variable -private: - std::array m_vertexp; // Vertex of each type (if non nullptr) -public: - // METHODS - OrderVarVertex* newVarUserVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varscp, - WhichVertex type, bool* createdp = nullptr) { - UASSERT_OBJ(type < WV_MAX, varscp, "Bad case"); - OrderVarVertex* vertexp = m_vertexp[type]; - if (!vertexp) { - UINFO(6, "New vertex " << varscp << endl); - if (createdp) *createdp = true; - switch (type) { - case WV_STD: vertexp = new OrderVarStdVertex(graphp, scopep, varscp); break; - case WV_PRE: vertexp = new OrderVarPreVertex(graphp, scopep, varscp); break; - case WV_PORD: vertexp = new OrderVarPordVertex(graphp, scopep, varscp); break; - case WV_POST: vertexp = new OrderVarPostVertex(graphp, scopep, varscp); break; - default: varscp->v3fatalSrc("Bad case"); - } - m_vertexp[type] = vertexp; - } else { - if (createdp) *createdp = false; - } - return vertexp; - } - - // CONSTRUCTORS - OrderUser() { - for (auto& vertexp : m_vertexp) vertexp = nullptr; - } - ~OrderUser() = default; -}; - -//###################################################################### -// Comparator classes - -//! Comparator for width of associated variable -struct OrderVarWidthCmp { - bool operator()(OrderVarStdVertex* vsv1p, OrderVarStdVertex* vsv2p) { - return vsv1p->varScp()->varp()->width() > vsv2p->varScp()->varp()->width(); - } -}; - -//! Comparator for fanout of vertex -struct OrderVarFanoutCmp { - bool operator()(OrderVarStdVertex* vsv1p, OrderVarStdVertex* vsv2p) { - return vsv1p->fanout() > vsv2p->fanout(); - } -}; - //###################################################################### // The class is used for propagating the clocker attribute for further // avoiding marking clock signals as circular. @@ -252,8 +202,8 @@ struct OrderVarFanoutCmp { // In addition it also check whether clock and data signals are mixed, and // produce a CLKDATA warning if so. // + class OrderClkMarkVisitor final : public AstNVisitor { -private: bool m_hasClk = false; // flag indicating whether there is clock signal on rhs bool m_inClocked = false; // Currently inside a sequential block bool m_newClkMarked; // Flag for deciding whether a new run is needed @@ -287,7 +237,6 @@ private: } } } - virtual void visit(AstVarRef* nodep) override { if (m_inAss && nodep->varp()->attrClocker() == VVarAttrClocker::CLOCKER_YES) { if (m_inClocked) { @@ -340,7 +289,6 @@ private: } virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } -public: // CONSTRUCTORS explicit OrderClkMarkVisitor(AstNode* nodep) { do { @@ -349,41 +297,509 @@ public: } while (m_newClkMarked); } virtual ~OrderClkMarkVisitor() override = default; + +public: + static void process(AstNetlist* nodep) { OrderClkMarkVisitor{nodep}; } }; //###################################################################### -// The class checks if the assignment generates a clock. +// Order information stored under each AstNode::user1p()... + +class OrderUser final { + // Stored in AstVarScope::user1p, a list of all the various vertices + // that can exist for one given scoped variable +public: + // TYPES + enum class VarVertexType : uint8_t { // Types of vertices we can create + STD = 0, + PRE = 1, + PORD = 2, + POST = 3 + }; -class OrderClkAssVisitor final : public AstNVisitor { private: - bool m_clkAss = false; // There is signals marked as clocker in the assignment - // METHODS - VL_DEBUG_FUNC; // Declare debug() - virtual void visit(AstNodeAssign* nodep) override { - if (const AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef)) { - if (varrefp->varp()->attrClocker() == VVarAttrClocker::CLOCKER_YES) { - m_clkAss = true; - UINFO(6, "node was marked as clocker " << varrefp << endl); - } - } - iterateChildren(nodep->rhsp()); - } - virtual void visit(AstVarRef*) override { - // Previous versions checked attrClocker() here, but this breaks - // the updated t_clocker VCD test. - // If reenable this visitor note AstNodeMath short circuit below - } - virtual void visit(AstNodeMath*) override {} // Accelerate - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + // Vertex of each type (if non nullptr) + std::array(VarVertexType::POST) + 1> m_vertexps; public: - // CONSTRUCTORS - explicit OrderClkAssVisitor(AstNode* nodep) { iterate(nodep); } - virtual ~OrderClkAssVisitor() override = default; // METHODS - bool isClkAss() const { return m_clkAss; } + OrderVarVertex* getVarVertex(V3Graph* graphp, AstScope* scopep, AstVarScope* varscp, + VarVertexType type) { + const unsigned idx = static_cast(type); + OrderVarVertex* vertexp = m_vertexps[idx]; + if (!vertexp) { + switch (type) { + case VarVertexType::STD: + vertexp = new OrderVarStdVertex(graphp, scopep, varscp); + break; + case VarVertexType::PRE: + vertexp = new OrderVarPreVertex(graphp, scopep, varscp); + break; + case VarVertexType::PORD: + vertexp = new OrderVarPordVertex(graphp, scopep, varscp); + break; + case VarVertexType::POST: + vertexp = new OrderVarPostVertex(graphp, scopep, varscp); + break; + } + m_vertexps[idx] = vertexp; + } + return vertexp; + } + + // CONSTRUCTORS + OrderUser() { m_vertexps.fill(nullptr); } + ~OrderUser() = default; }; +//###################################################################### +// OrderBuildVisitor builds the ordering graph of the entire netlist, and +// removes any nodes that are no longer required once the graph is built + +class OrderBuildVisitor final : public AstNVisitor { + // TYPES + enum VarUsage : uint8_t { VU_CON = 0x1, VU_GEN = 0x2 }; + using VarVertexType = OrderUser::VarVertexType; + + // NODE STATE + // AstVarScope::user1 -> OrderUser instance for variable (via m_orderUser) + // AstVarScope::user2 -> VarUsage within logic blocks + AstUser1InUse user1InUse; + AstUser2InUse user2InUse; + AstUser1Allocator m_orderUser; + + // STATE + // The ordering graph built by this visitor + OrderGraph* const m_graphp = new OrderGraph; + // Singleton vertex that all top level inputs depend on + OrderInputsVertex* const m_inputsVxp = new OrderInputsVertex{m_graphp, nullptr}; + // Singleton DPI Export trigger event vertex + OrderVarVertex* const m_dpiExportTriggerVxp + = v3Global.rootp()->dpiExportTriggerp() + ? getVarVertex(v3Global.rootp()->dpiExportTriggerp(), VarVertexType::STD) + : nullptr; + + OrderLogicVertex* m_activeSenVxp = nullptr; // Sensitivity vertex for clocked logic + OrderLogicVertex* m_logicVxp = nullptr; // Current loic block being analyzed + + // Current AstScope being processed + AstScope* m_scopep = nullptr; + // Sensitivity list for non-combinational logic (incl. initial and settle), + // nullptr for combinational logic + AstSenTree* m_domainp = nullptr; + + bool m_inClocked = false; // Underneath clocked AstActive + bool m_inClkAss = false; // Underneath AstNodeAssign to clock + bool m_inPre = false; // Underneath AstAssignPre + bool m_inPost = false; // Underneath AstAssignPost/AstAlwaysPost + bool m_inPostponed = false; // Underneath AstAlwaysPostponed + + // METHODS + VL_DEBUG_FUNC; // Declare debug() + + void iterateLogic(AstNode* nodep) { + UASSERT_OBJ(!m_logicVxp, nodep, "Should not nest"); + // Reset VarUsage + AstNode::user2ClearTree(); + // Create LogicVertex for this logic node + m_logicVxp = new OrderLogicVertex(m_graphp, m_scopep, m_domainp, nodep); + // If this logic has a clocked activation, add a link from the sensitivity list LogicVertex + // to this LogicVertex. + if (m_activeSenVxp) new OrderEdge(m_graphp, m_activeSenVxp, m_logicVxp, WEIGHT_NORMAL); + // Gather variable dependencies based on usage + iterateChildren(nodep); + // Finished with this logic + m_logicVxp = nullptr; + } + + OrderVarVertex* getVarVertex(AstVarScope* varscp, VarVertexType type) { + return m_orderUser(varscp).getVarVertex(m_graphp, m_scopep, varscp, type); + } + + // VISITORS + virtual void visit(AstSenTree* nodep) override { + // This should only find the global AstSenTrees under the AstTopScope, which we ignore + // here. We visit AstSenTrees separately when encountering the AstActive that references + // them. + UASSERT_OBJ(!m_scopep, nodep, "AstSenTrees should have been made global in V3ActiveTop"); + } + virtual void visit(AstScope* nodep) override { + UASSERT_OBJ(!m_scopep, nodep, "Should not nest"); + m_scopep = nodep; + iterateChildren(nodep); + m_scopep = nullptr; + } + virtual void visit(AstActive* nodep) override { + UASSERT_OBJ(!nodep->sensesStorep(), nodep, + "AstSenTrees should have been made global in V3ActiveTop"); + UASSERT_OBJ(m_scopep, nodep, "AstActive not under AstScope"); + UASSERT_OBJ(!m_logicVxp, nodep, "AstActive under logic"); + UASSERT_OBJ(!m_inClocked && !m_activeSenVxp && !m_domainp, nodep, "Should not nest"); + + m_inClocked = nodep->sensesp()->hasClocked(); + + // Analyze variable references in sensitivity list. Note that non-clocked sensitivity lists + // don't reference any variables (have no clocks), so the sensitivity list vertex would + // have no incoming dependencies and is hence redundant, therefore we only do this for + // clocked sensitivity lists. + if (m_inClocked) { + // Add LogicVertex for the sensitivity list of this AstActive. + m_activeSenVxp = new OrderLogicVertex(m_graphp, m_scopep, nodep->sensesp(), nodep); + // Analyze variables in the sensitivity list + iterateChildren(nodep->sensesp()); + } + + // Ignore the sensitivity domain for combinational logic. We will assign combinational + // logic to a domain later, based on the domains of incoming variables. + if (!nodep->sensesp()->hasCombo()) m_domainp = nodep->sensesp(); + + // Analyze logic underneath + iterateChildren(nodep); + + // + m_inClocked = false; + m_activeSenVxp = nullptr; + m_domainp = nullptr; + } + virtual void visit(AstNodeVarRef* nodep) override { + // As we explicitly not visit (see ignored nodes below) any subtree that is not relevant + // for ordering, we should be able to assert this: + UASSERT_OBJ(m_scopep, nodep, "AstVarRef not under scope"); + UASSERT_OBJ(m_logicVxp || m_activeSenVxp, nodep, + "AstVarRef not under logic nor sensitivity list"); + AstVarScope* const varscp = nodep->varScopep(); + UASSERT_OBJ(varscp, nodep, "Var didn't get varscoped in V3Scope.cpp"); + if (!m_logicVxp) { + // Variable reference in sensitivity list. Add clock dependency. + + UASSERT_OBJ(!nodep->access().isWriteOrRW(), nodep, + "How can a sensitivity list be writing a variable?"); + // Add edge from sensed VarStdVertex -> to sensitivity list LogicVertex + OrderVarVertex* const varVxp = getVarVertex(varscp, VarVertexType::STD); + varVxp->isClock(true); + new OrderEdge(m_graphp, varVxp, m_activeSenVxp, WEIGHT_MEDIUM); + } else { + // Variable reference in logic. Add data dependency. + + // Check whether this variable was already generated/consumed in the same logic. We + // don't want to add extra edges if the logic has many usages of the same variable, + // so only proceed on first encounter. + const bool prevGen = varscp->user2() & VU_GEN; + const bool prevCon = varscp->user2() & VU_CON; + + // Compute whether the variable is produced (written) here + bool gen = false; + if (!prevGen && nodep->access().isWriteOrRW()) { + gen = true; + if (m_inPostponed) { + // IEE 1800-2017 (4.2.9) forbids any value updates in the postponed region, but + // Verilator generated trigger signals for $strobe are cleared after the + // display is executed. This is both safe to ignore (because their single read + // is in the same AstAlwaysPostponed, just prior to the clear), and is + // necessary to ignore to avoid a circular logic (UNOPTFLAT) warning. + UASSERT_OBJ(prevCon, nodep, "Should have been consumed in same process"); + gen = false; + } + } + + // Compute whether the value is consumed (read) here + bool con = false; + if (!prevCon && nodep->access().isReadOrRW()) { + con = true; + if (prevGen && !m_inClocked) { + // Dangerous assumption: + // If a variable is consumed in the same combinational process that produced it + // earlier, consider it something like: + // foo = 1 + // foo = foo + 1 + // and still optimize. Note this will break though: + // if (sometimes) foo = 1 + // foo = foo + 1 + // TODO: Do this properly with liveness analysis (i.e.: if live, it's consumed) + // Note however that this construct is not nicely synthesizable (yields + // latch?). + con = false; + } + + // TODO: Explain how the following two exclusions are useful + if (varscp->varp()->attrClockEn() && !m_inPre && !m_inPost && !m_inClocked) { + // 'clock_enable' attribute on this signal: user's worrying about it for us + con = false; + } + if (m_inClkAss + && (varscp->varp()->attrClocker() != VVarAttrClocker::CLOCKER_YES)) { + // 'clocker' attribute on some other signal in same logic: same as + // 'clock_enable' attribute above + con = false; + UINFO(4, "nodep used as clock_enable " << varscp << " in " + << m_logicVxp->nodep() << endl); + } + } + + // Variable is produced + if (gen) { + // Update VarUsage + varscp->user2(varscp->user2() | VU_GEN); + // Add edges for produced variables + if (!m_inClocked || m_inPost) { + // Combinational logic + OrderVarVertex* const varVxp = getVarVertex(varscp, VarVertexType::STD); + // Add edge from producing LogicVertex -> produced VarStdVertex + if (m_inPost) { + new OrderPostCutEdge(m_graphp, m_logicVxp, varVxp); + // Mark the VarVertex as being produced by a delayed (non-blocking) + // assignment. This is used to control marking internal clocks + // circular, which must only happen if they are generated by delayed + // assignment. + varVxp->isDelayed(true); + UINFO(5, " Found delayed assignment (post) " << varVxp << endl); + } else if (varscp->varp()->attrClocker() == VVarAttrClocker::CLOCKER_YES) { + // If the variable has the 'clocker' attribute, avoid making it + // circular by adding a hard edge instead of normal cuttable edge. + new OrderEdge(m_graphp, m_logicVxp, varVxp, WEIGHT_NORMAL); + } else { + new OrderComboCutEdge(m_graphp, m_logicVxp, varVxp); + } + + // Add edge from produced VarPostVertex -> to producing LogicVertex + + // For m_inPost: + // Add edge consumed_var_POST->logic_vertex + // This prevents a consumer of the "early" value to be scheduled + // after we've changed to the next-cycle value + // ALWAYS do it: + // There maybe a wire a=b; between the two blocks + OrderVarVertex* const postVxp = getVarVertex(varscp, VarVertexType::POST); + new OrderEdge(m_graphp, postVxp, m_logicVxp, WEIGHT_POST); + } else if (m_inPre) { // AstAssignPre + // Add edge from producing LogicVertex -> produced VarPordVertex + OrderVarVertex* const ordVxp = getVarVertex(varscp, VarVertexType::PORD); + new OrderEdge(m_graphp, m_logicVxp, ordVxp, WEIGHT_NORMAL); + // Add edge from producing LogicVertex -> produced VarStdVertex + OrderVarVertex* const varVxp = getVarVertex(varscp, VarVertexType::STD); + new OrderEdge(m_graphp, m_logicVxp, varVxp, WEIGHT_NORMAL); + } else { + // Sequential (clocked) logic + // Add edge from produced VarPordVertex -> to producing LogicVertex + OrderVarVertex* const ordVxp = getVarVertex(varscp, VarVertexType::PORD); + new OrderEdge(m_graphp, ordVxp, m_logicVxp, WEIGHT_NORMAL); + // Add edge from producing LogicVertex-> to produced VarStdVertex + OrderVarVertex* const varVxp = getVarVertex(varscp, VarVertexType::STD); + new OrderEdge(m_graphp, m_logicVxp, varVxp, WEIGHT_NORMAL); + } + } + + // Variable is consumed + if (con) { + // Update VarUsage + varscp->user2(varscp->user2() | VU_CON); + // Add edges + if (!m_inClocked || m_inPost) { + // Combinational logic + OrderVarVertex* const varVxp = getVarVertex(varscp, VarVertexType::STD); + // Add edge from consumed VarStdVertex -> to consuming LogicVertex + new OrderEdge(m_graphp, varVxp, m_logicVxp, WEIGHT_MEDIUM); + } else if (m_inPre) { + // AstAssignPre logic + // Add edge from consumed VarPreVertex -> to consuming LogicVertex + // This one is cutable (vs the producer) as there's only one such consumer, + // but may be many producers + OrderVarVertex* const preVxp = getVarVertex(varscp, VarVertexType::PRE); + new OrderPreCutEdge(m_graphp, preVxp, m_logicVxp); + } else { + // Sequential (clocked) logic + // Add edge from consuming LogicVertex -> to consumed VarPreVertex + // Generation of 'pre' because we want to indicate it should be before + // AstAssignPre + OrderVarVertex* const preVxp = getVarVertex(varscp, VarVertexType::PRE); + new OrderEdge(m_graphp, m_logicVxp, preVxp, WEIGHT_NORMAL); + // Add edge from consuming LogicVertex -> to consumed VarPostVertex + OrderVarVertex* const postVxp = getVarVertex(varscp, VarVertexType::POST); + new OrderEdge(m_graphp, m_logicVxp, postVxp, WEIGHT_POST); + } + } + } + } + virtual void visit(AstDpiExportUpdated* nodep) override { + // This is under a logic block (AstAlways) sensitive to a change in the DPI export trigger. + // We just need to add an edge to the enclosing logic vertex (the vertex for the + // AstAlways). + OrderVarVertex* const varVxp = getVarVertex(nodep->varScopep(), VarVertexType::STD); + new OrderComboCutEdge(m_graphp, m_logicVxp, varVxp); + // Only used for ordering, so we can get rid of it here + nodep->unlinkFrBack(); + VL_DO_DANGLING(pushDeletep(nodep), nodep); + } + virtual void visit(AstCCall* nodep) override { + // Calls to 'context' imported DPI function may call DPI exported functions + if (m_dpiExportTriggerVxp && nodep->funcp()->dpiImportWrapper() + && nodep->funcp()->dpiContext()) { + UASSERT_OBJ(m_logicVxp, nodep, "Call not under logic"); + new OrderEdge(m_graphp, m_logicVxp, m_dpiExportTriggerVxp, WEIGHT_NORMAL); + } + iterateChildren(nodep); + } + + //--- Logic akin to SystemVerilog Processes (AstNodeProcedure) + virtual void visit(AstInitial* nodep) override { // + iterateLogic(nodep); + } + virtual void visit(AstAlways* nodep) override { // + iterateLogic(nodep); + } + virtual void visit(AstAlwaysPost* nodep) override { + UASSERT_OBJ(!m_inPost, nodep, "Should not nest"); + m_inPost = true; + iterateLogic(nodep); + m_inPost = false; + } + virtual void visit(AstAlwaysPostponed* nodep) override { + UASSERT_OBJ(!m_inPostponed, nodep, "Should not nest"); + m_inPostponed = true; + iterateLogic(nodep); + m_inPostponed = false; + } + virtual void visit(AstFinal* nodep) override { // LCOV_EXCL_START + nodep->v3fatalSrc("AstFinal should have been removed already"); + } // LCOV_EXCL_STOP + + //--- Logic akin go SystemVerilog continuous assignments + virtual void visit(AstAssignAlias* nodep) override { // + iterateLogic(nodep); + } + virtual void visit(AstAssignW* nodep) override { + UASSERT_OBJ(!m_inClkAss, nodep, "Should not nest"); + m_inClkAss = isClockerAssignment(nodep); + iterateLogic(nodep); + m_inClkAss = false; + } + virtual void visit(AstAssignPre* nodep) override { + UASSERT_OBJ(!m_inClkAss && !m_inPre, nodep, "Should not nest"); + m_inClkAss = isClockerAssignment(nodep); + m_inPre = true; + iterateLogic(nodep); + m_inPre = false; + m_inClkAss = false; + } + virtual void visit(AstAssignPost* nodep) override { + UASSERT_OBJ(!m_inClkAss && !m_inPost, nodep, "Should not nest"); + m_inClkAss = isClockerAssignment(nodep); + m_inPost = true; + iterateLogic(nodep); + m_inPost = false; + m_inClkAss = false; + } + + //--- Verilator concoctions + virtual void visit(AstAlwaysPublic* nodep) override { // + iterateLogic(nodep); + } + virtual void visit(AstCoverToggle* nodep) override { // + iterateLogic(nodep); + } + + //--- Ignored nodes + virtual void visit(AstVar*) override {} + virtual void visit(AstVarScope* nodep) override {} + virtual void visit(AstCell*) override {} // Only interested in the respective AstScope + virtual void visit(AstTypeTable*) override {} + virtual void visit(AstConstPool*) override {} + virtual void visit(AstClass*) override {} + virtual void visit(AstCFunc*) override { + // Calls to DPI exports handled with AstCCall. /* verilator public */ functions are + // ignored for now (and hence potentially mis-ordered), but could use the same or + // similar mechanism as DPI exports. Every other impure function (including those + // that may set a non-local variable) must have been inlined in V3Task. + } + + //--- + virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } + + // CONSTRUCTOR + OrderBuildVisitor(AstNetlist* nodep) { + // Enable debugging (3 is default if global debug; we want acyc debugging) + if (debug()) m_graphp->debug(5); + + // Add edges from the InputVertex to all top level input signal VarStdVertex + for (AstVarScope* vscp = nodep->topScopep()->scopep()->varsp(); vscp; + vscp = VN_AS(vscp->nextp(), VarScope)) { + if (vscp->varp()->isNonOutput()) { + OrderVarVertex* varVxp = getVarVertex(vscp, VarVertexType::STD); + new OrderEdge(m_graphp, m_inputsVxp, varVxp, WEIGHT_INPUT); + } + } + + // Build the rest of the graph + iterate(nodep); + } + virtual ~OrderBuildVisitor() = default; + +public: + // Process the netlist and return the constructed ordering graph. It's 'process' because + // this visitor does change the tree (removes some nodes related to DPI export trigger). + static std::unique_ptr process(AstNetlist* nodep) { + return std::unique_ptr{OrderBuildVisitor{nodep}.m_graphp}; + } +}; + +//###################################################################### + +class OrderProcess; + +class OrderMoveDomScope final { + // Information stored for each unique loop, domain & scope trifecta +public: + V3ListEnt m_readyDomScopeE; // List of next ready dom scope + V3List m_readyVertices; // Ready vertices with same domain & scope +private: + bool m_onReadyList = false; // True if DomScope is already on list of ready dom/scopes + const AstSenTree* m_domainp; // Domain all vertices belong to + const AstScope* m_scopep; // Scope all vertices belong to + + using DomScopeKey = std::pair; + using DomScopeMap = std::map; + static DomScopeMap s_dsMap; // Structure registered for each dom/scope pairing + +public: + OrderMoveDomScope(const AstSenTree* domainp, const AstScope* scopep) + : m_domainp{domainp} + , m_scopep{scopep} {} + OrderMoveDomScope* readyDomScopeNextp() const { return m_readyDomScopeE.nextp(); } + const AstSenTree* domainp() const { return m_domainp; } + const AstScope* scopep() const { return m_scopep; } + // Check the domScope is on ready list, add if not + void ready(OrderProcess* opp); + // Mark one vertex as finished, remove from ready list if done + void movedVertex(OrderProcess* opp, OrderMoveVertex* vertexp); + // STATIC MEMBERS (for lookup) + static void clear() { + for (const auto& itr : s_dsMap) delete itr.second; + s_dsMap.clear(); + } + V3List& readyVertices() { return m_readyVertices; } + static OrderMoveDomScope* findCreate(const AstSenTree* domainp, const AstScope* scopep) { + const DomScopeKey key = std::make_pair(domainp, scopep); + const auto iter = s_dsMap.find(key); + if (iter != s_dsMap.end()) { + return iter->second; + } else { + OrderMoveDomScope* domScopep = new OrderMoveDomScope(domainp, scopep); + s_dsMap.emplace(key, domScopep); + return domScopep; + } + } + string name() const { + return (string("MDS:") + " d=" + cvtToHex(domainp()) + " s=" + cvtToHex(scopep())); + } +}; + +OrderMoveDomScope::DomScopeMap OrderMoveDomScope::s_dsMap; + +inline std::ostream& operator<<(std::ostream& lhs, const OrderMoveDomScope& rhs) { + lhs << rhs.name(); + return lhs; +} + //###################################################################### // ProcessMoveBuildGraph @@ -616,95 +1032,36 @@ public: }; //###################################################################### -// Order class functions +// OrderProcess class -class OrderVisitor final : public AstNVisitor { -private: +class OrderProcess final : AstNDeleter { // NODE STATE - // Forming graph: - // Entire Netlist: - // AstVarScope::user1u -> OrderUser* for usage var (via m_orderUser) - // {statement}Node::user1p-> AstModule* statement is under - // USER4 Cleared on each Logic stmt - // AstVarScope::user4() -> VarUsage(gen/con/both). Where already encountered signal - // Ordering (user3/4/5 cleared between forming and ordering) - // AstScope::user1p() -> AstNodeModule*. Module this scope is under - // AstNodeModule::user3() -> Number of routines created - // Each call to V3Const::constify - // AstNode::user4() Used by V3Const::constify, called below - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - // AstUser4InUse m_inuser4; // Used only when building tree, so below - - AstUser1Allocator m_orderUser; + // AstNodeModule::user3 -> int: Number of AstCFuncs created under this module + // AstNode::user4 -> Used by V3Const::constifyExpensiveEdit + AstUser3InUse user3InUse; // STATE - OrderGraph m_graph; // Scoreboard of var usages/dependencies - SenTreeFinder m_finder; // Find global sentree's and add them - AstSenTree* m_comboDomainp = nullptr; // Combo activation tree - AstSenTree* m_deleteDomainp = nullptr; // Delete this from tree - OrderInputsVertex* m_inputsVxp = nullptr; // Top level vertex all inputs point from - OrderVarVertex* m_dpiExportTriggerVxp = nullptr; // DPI Export trigger condition vertex - OrderLogicVertex* m_logicVxp = nullptr; // Current statement being tracked, nullptr=ignored - AstTopScope* m_topScopep = nullptr; // Current top scope being processed - AstScope* m_scopetopp = nullptr; // Scope under TOPSCOPE - AstNodeModule* m_modp = nullptr; // Current module - AstScope* m_scopep = nullptr; // Current scope being processed - AstActive* m_activep = nullptr; // Current activation block - bool m_inSenTree = false; // Underneath AstSenItem; any varrefs are clocks - bool m_inClocked = false; // Underneath clocked block - bool m_inClkAss = false; // Underneath AstAssign - bool m_inPre = false; // Underneath AstAssignPre - bool m_inPost = false; // Underneath AstAssignPost - bool m_inPostponed = false; // Underneath AstAssignPostponed - OrderLogicVertex* m_activeSenVxp = nullptr; // Sensitivity vertex - // STATE... for inside process + OrderGraph& m_graph; // The ordering graph + OrderInputsVertex& m_inputsVtx; // The singleton OrderInputsVertex + SenTreeFinder m_finder; // Global AstSenTree manager + AstSenTree* const m_comboDomainp; // The combinational domain AstSenTree + AstSenTree* const m_deleteDomainp; // Dummy AstSenTree indicating needs deletion + AstScope& m_scopetop; // The top level AstScope + AstCFunc* m_pomNewFuncp = nullptr; // Current function being created int m_pomNewStmts = 0; // Statements in function being created V3Graph m_pomGraph; // Graph of logic elements to move V3List m_pomWaiting; // List of nodes needing inputs to become ready -protected: friend class OrderMoveDomScope; V3List m_pomReadyDomScope; // List of ready domain/scope pairs, by loopId std::vector m_unoptflatVars; // Vector of variables in UNOPTFLAT loop -private: // STATS std::array m_statCut; // Count of each edge type cut - // TYPES - enum VarUsage : uint8_t { VU_NONE = 0, VU_CON = 1, VU_GEN = 2 }; - // METHODS VL_DEBUG_FUNC; // Declare debug() - void iterateNewStmt(AstNode* nodep) { - if (m_scopep) { - UINFO(4, " STMT " << nodep << endl); - // VV***** We reset user4p() - AstNode::user4ClearTree(); - UASSERT_OBJ(m_activep && m_activep->sensesp(), nodep, "nullptr"); - // If inside combo logic, ignore the domain, we'll assign one based on interconnect - AstSenTree* startDomainp = m_activep->sensesp(); - if (startDomainp->hasCombo()) startDomainp = nullptr; - m_logicVxp = new OrderLogicVertex(&m_graph, m_scopep, startDomainp, nodep); - if (m_activeSenVxp) { - // If in a clocked activation, add a link from the sensitivity to this block - // Add edge logic_sensitive_vertex->logic_vertex - new OrderEdge(&m_graph, m_activeSenVxp, m_logicVxp, WEIGHT_NORMAL); - } - nodep->user1p(m_modp); - iterateChildren(nodep); - m_logicVxp = nullptr; - } - } - - OrderVarVertex* newVarUserVertex(AstVarScope* varscp, WhichVertex type, - bool* createdp = nullptr) { - return m_orderUser(varscp).newVarUserVertex(&m_graph, m_scopep, varscp, type, createdp); - } - void process(); void processCircular(); using VertexVec = std::deque; @@ -759,9 +1116,9 @@ private: void nodeMarkCircular(OrderVarVertex* vertexp, OrderEdge* edgep) { // To be marked circular requires being a clock assigned in a delayed assignment, or // having a cutable in or out edge, none of which is true for the DPI export trigger. - UASSERT(vertexp != m_dpiExportTriggerVxp, - "DPI expor trigger should not be marked circular"); - AstVarScope* nodep = vertexp->varScp(); + AstVarScope* const nodep = vertexp->varScp(); + UASSERT(nodep != v3Global.rootp()->dpiExportTriggerp(), + "DPI export trigger should not be marked circular"); OrderLogicVertex* fromLVtxp = nullptr; OrderLogicVertex* toLVtxp = nullptr; if (edgep) { @@ -831,17 +1188,17 @@ private: } } - //! Find all variables in an UNOPTFLAT loop - //! - //! Ignore vars that are 1-bit wide and don't worry about generated - //! variables (PRE and POST vars, __Vdly__, __Vcellin__ and __VCellout). - //! What remains are candidates for splitting to break loops. - //! - //! node->user3 is used to mark if we have done a particular variable. - //! vertex->user is used to mark if we have seen this vertex before. - //! - //! @todo We could be cleverer in the future and consider just - //! the width that is generated/consumed. + // Find all variables in an UNOPTFLAT loop + // + // Ignore vars that are 1-bit wide and don't worry about generated + // variables (PRE and POST vars, __Vdly__, __Vcellin__ and __VCellout). + // What remains are candidates for splitting to break loops. + // + // node->user3 is used to mark if we have done a particular variable. + // vertex->user is used to mark if we have seen this vertex before. + // + // @todo We could be cleverer in the future and consider just + // the width that is generated/consumed. void reportLoopVars(OrderVarVertex* vertexp) { m_graph.userClearVertices(); AstNode::user3ClearTree(); @@ -852,7 +1209,11 @@ private: // May be very large vector, so only report the "most important" // elements. Up to 10 of the widest std::cerr << V3Error::warnMore() << "... Widest candidate vars to split:\n"; - std::stable_sort(m_unoptflatVars.begin(), m_unoptflatVars.end(), OrderVarWidthCmp()); + std::stable_sort(m_unoptflatVars.begin(), m_unoptflatVars.end(), + [](OrderVarStdVertex* vsv1p, OrderVarStdVertex* vsv2p) -> bool { + return vsv1p->varScp()->varp()->width() + > vsv2p->varScp()->varp()->width(); + }); std::unordered_set canSplitList; int lim = m_unoptflatVars.size() < 10 ? m_unoptflatVars.size() : 10; for (int i = 0; i < lim; i++) { @@ -870,7 +1231,10 @@ private: } // Up to 10 of the most fanned out std::cerr << V3Error::warnMore() << "... Most fanned out candidate vars to split:\n"; - std::stable_sort(m_unoptflatVars.begin(), m_unoptflatVars.end(), OrderVarFanoutCmp()); + std::stable_sort(m_unoptflatVars.begin(), m_unoptflatVars.end(), + [](OrderVarStdVertex* vsv1p, OrderVarStdVertex* vsv2p) -> bool { + return vsv1p->fanout() > vsv2p->fanout(); + }); lim = m_unoptflatVars.size() < 10 ? m_unoptflatVars.size() : 10; for (int i = 0; i < lim; i++) { OrderVarStdVertex* vsvertexp = m_unoptflatVars[i]; @@ -918,313 +1282,33 @@ private: if (edgep->fromp()->color() == color) reportLoopVarsIterate(edgep->fromp(), color); } } - // VISITORS - virtual void visit(AstNetlist* nodep) override { - { - AstUser4InUse m_inuser4; // Used only when building tree, so below - iterateChildren(nodep); - } - // We're finished, complete the topscopes - if (m_topScopep) { - process(); - m_topScopep = nullptr; - } - } - virtual void visit(AstTopScope* nodep) override { - // Process the last thing we're finishing - UASSERT_OBJ(!m_topScopep, nodep, "Only one topscope should ever be created"); - UINFO(2, " Loading tree...\n"); - // VV***** We reset userp() - AstNode::user1ClearTree(); - AstNode::user3ClearTree(); - m_graph.clear(); - m_activep = nullptr; - m_topScopep = nodep; - m_scopetopp = nodep->scopep(); - // ProcessDomainsIterate will use these when it needs to move - // something to a combodomain. This saves a ton of find() operations. - AstSenTree* combp - = new AstSenTree(nodep->fileline(), // Gets cloned() so ok if goes out of scope - new AstSenItem(nodep->fileline(), AstSenItem::Combo())); - m_comboDomainp = m_finder.getSenTree(combp); - pushDeletep(combp); // Cleanup when done - // Fake AstSenTree we set domainp to indicate needs deletion - m_deleteDomainp = new AstSenTree(nodep->fileline(), - new AstSenItem(nodep->fileline(), AstSenItem::Settle())); - pushDeletep(m_deleteDomainp); // Cleanup when done - UINFO(5, " DeleteDomain = " << m_deleteDomainp << endl); - // Base vertices - m_activeSenVxp = nullptr; - m_inputsVxp = new OrderInputsVertex(&m_graph, nullptr); - if (AstVarScope* const dpiExportTrigger = v3Global.rootp()->dpiExportTriggerp()) { - m_dpiExportTriggerVxp = newVarUserVertex(dpiExportTrigger, WV_STD); - } - // - iterateChildren(nodep); - // Done topscope, erase extra user information - // user1p passed to next process() operation - AstNode::user3ClearTree(); - AstNode::user4ClearTree(); - } - virtual void visit(AstNodeModule* nodep) override { - VL_RESTORER(m_modp); - { - m_modp = nodep; - iterateChildren(nodep); - } - } - virtual void visit(AstClass*) override {} - virtual void visit(AstScope* nodep) override { - UINFO(4, " SCOPE " << nodep << endl); - m_scopep = nodep; - m_logicVxp = nullptr; - m_activeSenVxp = nullptr; - nodep->user1p(m_modp); - // Iterate - iterateChildren(nodep); - m_scopep = nullptr; - } - virtual void visit(AstActive* nodep) override { - // Create required activation blocks and add to module - UINFO(4, " ACTIVE " << nodep << endl); - m_activep = nodep; - m_activeSenVxp = nullptr; - m_inClocked = nodep->hasClocked(); - // Grab the sensitivity list - UASSERT_OBJ(!nodep->sensesStorep(), nodep, - "Senses should have been activeTop'ed to be global!"); - iterate(nodep->sensesp()); - // Collect statements under it - iterateChildren(nodep); - m_activep = nullptr; - m_activeSenVxp = nullptr; - m_inClocked = false; - } - virtual void visit(AstVarScope* nodep) override { - // Create links to all input signals - UASSERT_OBJ(m_modp, nodep, "Scope not under module"); - if (m_modp->isTop() && nodep->varp()->isNonOutput()) { - OrderVarVertex* varVxp = newVarUserVertex(nodep, WV_STD); - new OrderEdge(&m_graph, m_inputsVxp, varVxp, WEIGHT_INPUT); - } - } - virtual void visit(AstNodeVarRef* nodep) override { - if (m_scopep) { - AstVarScope* varscp = nodep->varScopep(); - UASSERT_OBJ(varscp, nodep, "Var didn't get varscoped in V3Scope.cpp"); - if (m_inSenTree) { - // Add CLOCK dependency... This is a root of the tree we'll trace - UASSERT_OBJ(!nodep->access().isWriteOrRW(), nodep, - "How can a sensitivity be setting a var?"); - OrderVarVertex* varVxp = newVarUserVertex(varscp, WV_STD); - varVxp->isClock(true); - new OrderEdge(&m_graph, varVxp, m_activeSenVxp, WEIGHT_MEDIUM); - } else { - UASSERT_OBJ(m_logicVxp, nodep, "Var ref not under a logic block"); - // What new directions is this used - // We don't want to add extra edges if the logic block has many usages of same var - bool gen = false; - bool con = false; - if (nodep->access().isWriteOrRW() && !m_inPostponed) - gen = !(varscp->user4() & VU_GEN); - if (nodep->access().isReadOrRW()) { - con = !(varscp->user4() & VU_CON); - if ((varscp->user4() & VU_GEN) && !m_inClocked) { - // Dangerous assumption: - // If a variable is used in the same activation which defines it first, - // consider it something like: - // foo = 1 - // foo = foo + 1 - // and still optimize. This is the rule verilog-mode assumes for /*AS*/ - // Note this will break though: - // if (sometimes) foo = 1 - // foo = foo + 1 - con = false; - } - if (varscp->varp()->attrClockEn() && !m_inPre && !m_inPost && !m_inClocked) { - // clock_enable attribute: user's worrying about it for us - con = false; - } - if (m_inClkAss - && (varscp->varp()->attrClocker() != VVarAttrClocker::CLOCKER_YES)) { - con = false; - UINFO(4, "nodep used as clock_enable " << varscp << " in " - << m_logicVxp->nodep() << endl); - } - } - if (gen) varscp->user4(varscp->user4() | VU_GEN); - if (con) varscp->user4(varscp->user4() | VU_CON); - // Add edges - if (!m_inClocked || m_inPost) { - // Combo logic - { // not settle and (combo or inPost) - if (gen) { - // Add edge logic_vertex->logic_generated_var - OrderVarVertex* varVxp = newVarUserVertex(varscp, WV_STD); - if (m_inPost) { - new OrderPostCutEdge(&m_graph, m_logicVxp, varVxp); - // Mark the vertex. Used to control marking - // internal clocks circular, which must only - // happen if they are generated by delayed - // assignment. - UINFO(5, - " Found delayed assignment (post) " << varVxp << endl); - varVxp->isDelayed(true); - } else { - // If the lhs is a clocker, avoid marking that as circular by - // putting a hard edge instead of normal cuttable - if (varscp->varp()->attrClocker() - == VVarAttrClocker::CLOCKER_YES) { - new OrderEdge(&m_graph, m_logicVxp, varVxp, WEIGHT_NORMAL); - } else { - new OrderComboCutEdge(&m_graph, m_logicVxp, varVxp); - } - } - // For m_inPost: - // Add edge consumed_var_POST->logic_vertex - // This prevents a consumer of the "early" value to be scheduled - // after we've changed to the next-cycle value - // ALWAYS do it: - // There maybe a wire a=b; between the two blocks - OrderVarVertex* postVxp = newVarUserVertex(varscp, WV_POST); - new OrderEdge(&m_graph, postVxp, m_logicVxp, WEIGHT_POST); - } - if (con) { - // Add edge logic_consumed_var->logic_vertex - OrderVarVertex* varVxp = newVarUserVertex(varscp, WV_STD); - new OrderEdge(&m_graph, varVxp, m_logicVxp, WEIGHT_MEDIUM); - } - } - } else if (m_inPre) { - // AstAssignPre logic - if (gen) { - // Add edge logic_vertex->generated_var_PREORDER - OrderVarVertex* ordVxp = newVarUserVertex(varscp, WV_PORD); - new OrderEdge(&m_graph, m_logicVxp, ordVxp, WEIGHT_NORMAL); - // Add edge logic_vertex->logic_generated_var (same as if comb) - OrderVarVertex* varVxp = newVarUserVertex(varscp, WV_STD); - new OrderEdge(&m_graph, m_logicVxp, varVxp, WEIGHT_NORMAL); - } - if (con) { - // Add edge logic_consumed_var_PREVAR->logic_vertex - // This one is cutable (vs the producer) as there's - // only one of these, but many producers - OrderVarVertex* preVxp = newVarUserVertex(varscp, WV_PRE); - new OrderPreCutEdge(&m_graph, preVxp, m_logicVxp); - } - } else { - // Seq logic - if (gen) { - // Add edge logic_generated_var_PREORDER->logic_vertex - OrderVarVertex* ordVxp = newVarUserVertex(varscp, WV_PORD); - new OrderEdge(&m_graph, ordVxp, m_logicVxp, WEIGHT_NORMAL); - // Add edge logic_vertex->logic_generated_var (same as if comb) - OrderVarVertex* varVxp = newVarUserVertex(varscp, WV_STD); - new OrderEdge(&m_graph, m_logicVxp, varVxp, WEIGHT_NORMAL); - } - if (con) { - // Add edge logic_vertex->consumed_var_PREVAR - // Generation of 'pre' because we want to indicate - // it should be before AstAssignPre - OrderVarVertex* preVxp = newVarUserVertex(varscp, WV_PRE); - new OrderEdge(&m_graph, m_logicVxp, preVxp, WEIGHT_NORMAL); - // Add edge logic_vertex->consumed_var_POST - OrderVarVertex* postVxp = newVarUserVertex(varscp, WV_POST); - new OrderEdge(&m_graph, m_logicVxp, postVxp, WEIGHT_POST); - } - } - } - } - } - virtual void visit(AstDpiExportUpdated* nodep) override { - // This is under an AstAlways, sensitive to a change in the DPI export trigger. We just - // need to add an edge to the enclosing logic vertex (the vertex for the AstAlways). - OrderVarVertex* const varVxp = newVarUserVertex(nodep->varScopep(), WV_STD); - new OrderComboCutEdge(&m_graph, m_logicVxp, varVxp); - // Only used for ordering, so we can get rid of it here - nodep->unlinkFrBack(); - VL_DO_DANGLING(pushDeletep(nodep), nodep); - } - virtual void visit(AstCCall* nodep) override { - // Calls to 'context' imported DPI function may call DPI exported functions - if (m_dpiExportTriggerVxp && nodep->funcp()->dpiImportWrapper() - && nodep->funcp()->dpiContext()) { - UASSERT_OBJ(m_logicVxp, nodep, "Call not under logic"); - new OrderEdge(&m_graph, m_logicVxp, m_dpiExportTriggerVxp, WEIGHT_NORMAL); - } - iterateChildren(nodep); - } - virtual void visit(AstSenTree* nodep) override { - // Having a node derived from the sentree isn't required for - // correctness, it merely makes the graph better connected - // and improves graph algorithmic performance - if (m_scopep) { // Else TOPSCOPE's SENTREE list - m_inSenTree = true; - if (nodep->hasClocked()) { - if (!m_activeSenVxp) { - m_activeSenVxp = new OrderLogicVertex(&m_graph, m_scopep, nodep, m_activep); - } - iterateChildren(nodep); - } - m_inSenTree = false; - } - } - virtual void visit(AstAlwaysPost* nodep) override { - m_inPost = true; - iterateNewStmt(nodep); - m_inPost = false; - } - virtual void visit(AstAlwaysPostponed* nodep) override { - VL_RESTORER(m_inPostponed); - m_inPostponed = true; - iterateNewStmt(nodep); - } - virtual void visit(AstAlways* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstAlwaysPublic* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstAssignAlias* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstAssignW* nodep) override { - OrderClkAssVisitor visitor{nodep}; - m_inClkAss = visitor.isClkAss(); - iterateNewStmt(nodep); - m_inClkAss = false; - } - virtual void visit(AstAssignPre* nodep) override { - OrderClkAssVisitor visitor{nodep}; - m_inClkAss = visitor.isClkAss(); - m_inPre = true; - iterateNewStmt(nodep); - m_inPre = false; - m_inClkAss = false; - } - virtual void visit(AstAssignPost* nodep) override { - OrderClkAssVisitor visitor{nodep}; - m_inClkAss = visitor.isClkAss(); - m_inPost = true; - iterateNewStmt(nodep); - m_inPost = false; - m_inClkAss = false; - } - virtual void visit(AstCoverToggle* nodep) override { iterateNewStmt(nodep); } - virtual void visit(AstInitial* nodep) override { - // We use initials to setup parameters and static consts's which may be referenced - // in user initial blocks. So use ordering to sort them all out. - iterateNewStmt(nodep); - } - virtual void visit(AstCFunc*) override { - // Calls to DPI exports handled with AstCCall. /* verlator public */ functions are - // ignored for now (and hence potentially mis-ordered), but could use the same or - // similar mechanism as DPI exports. Every other impure function (including those - // that may set a non-local variable) must have been inlined in V3Task. - } - //-------------------- - virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } -public: - // CONSTRUCTORS - OrderVisitor() { - if (debug()) m_graph.debug(5); // 3 is default if global debug; we want acyc debugging + // Only for member initialization in constructor + static OrderInputsVertex& findInputVertex(OrderGraph& graph) { + for (V3GraphVertex* vtxp = graph.verticesBeginp(); vtxp; vtxp = vtxp->verticesNextp()) { + if (auto* ivtxp = dynamic_cast(vtxp)) return *ivtxp; + } + VL_UNREACHABLE } - virtual ~OrderVisitor() override { + + // Only for member initialization in constructor + static AstSenTree* makeDeleteDomainSenTree(FileLine* fl) { + // TODO: Using "Never" instead of "Settle" causes a test failure, it probably shouldn't ... + return new AstSenTree{fl, new AstSenItem{fl, AstSenItem::Settle{}}}; + } + + // CONSTRUCTOR + OrderProcess(AstNetlist* netlistp, OrderGraph& graph) + : m_graph{graph} + , m_inputsVtx{findInputVertex(graph)} + , m_finder{netlistp} + , m_comboDomainp{m_finder.getComb()} + , m_deleteDomainp{makeDeleteDomainSenTree(netlistp->fileline())} + , m_scopetop{*netlistp->topScopep()->scopep()} { + pushDeletep(m_deleteDomainp); + } + + ~OrderProcess() { // Stats for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) { const double count = double(m_statCut[type]); @@ -1232,85 +1316,46 @@ public: V3Stats::addStat(string("Order, cut, ") + OrderVEdgeType(type).ascii(), count); } } - // Destruction - m_graph.debug(V3Error::debugDefault()); } - void main(AstNode* nodep) { iterate(nodep); } + +public: + // Order the logic + static void main(AstNetlist* netlistp, OrderGraph& graph) { + OrderProcess{netlistp, graph}.process(); + } }; -//###################################################################### -// General utilities - -static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) { - // Return 'true' if we can prove that both 'from' and 'to' cannot both - // be active on the same eval pass, or false if we can't prove this. - // - // This detects the case of 'always @(posedge clk)' - // and 'always @(negedge clk)' being exclusive. It also detects - // that initial/settle blocks and post-initial blocks are exclusive. - // - // Are there any other cases we need to handle? Maybe not, - // because these are not exclusive: - // always @(posedge A or posedge B) - // always @(negedge A) - // - // ... unless you know more about A and B, which sounds hard. - - const bool toInitial = top->hasInitial() || top->hasSettle(); - const bool fromInitial = fromp->hasInitial() || fromp->hasSettle(); - if (toInitial != fromInitial) return true; - - const AstSenItem* fromSenListp = fromp->sensesp(); - const AstSenItem* toSenListp = top->sensesp(); - - UASSERT_OBJ(fromSenListp, fromp, "sensitivity list empty"); - UASSERT_OBJ(toSenListp, top, "sensitivity list empty"); - - if (fromSenListp->nextp()) return false; - if (toSenListp->nextp()) return false; - - const AstNodeVarRef* fromVarrefp = fromSenListp->varrefp(); - const AstNodeVarRef* toVarrefp = toSenListp->varrefp(); - if (!fromVarrefp || !toVarrefp) return false; - - // We know nothing about the relationship between different clocks here, - // so give up on proving anything. - if (fromVarrefp->varScopep() != toVarrefp->varScopep()) return false; - - return fromSenListp->edgeType().exclusiveEdge(toSenListp->edgeType()); -} - //###################################################################### // OrderMoveDomScope methods // Check the domScope is on ready list, add if not -inline void OrderMoveDomScope::ready(OrderVisitor* ovp) { +inline void OrderMoveDomScope::ready(OrderProcess* opp) { if (!m_onReadyList) { m_onReadyList = true; - m_readyDomScopeE.pushBack(ovp->m_pomReadyDomScope, this); + m_readyDomScopeE.pushBack(opp->m_pomReadyDomScope, this); } } // Mark one vertex as finished, remove from ready list if done -inline void OrderMoveDomScope::movedVertex(OrderVisitor* ovp, OrderMoveVertex* vertexp) { +inline void OrderMoveDomScope::movedVertex(OrderProcess* opp, OrderMoveVertex* vertexp) { UASSERT_OBJ(m_onReadyList, vertexp, "Moving vertex from ready when nothing was on que as ready."); if (m_readyVertices.empty()) { // Else more work to get to later m_onReadyList = false; - m_readyDomScopeE.unlink(ovp->m_pomReadyDomScope, this); + m_readyDomScopeE.unlink(opp->m_pomReadyDomScope, this); } } //###################################################################### -// OrderVisitor - Clock propagation +// OrderProcess methods -void OrderVisitor::processInputs() { +void OrderProcess::processInputs() { m_graph.userClearVertices(); // Vertex::user() // 1 if input recursed, 2 if marked as input, // 3 if out-edges recursed // Start at input vertex, process from input-to-output order VertexVec todoVec; // List of newly-input marked vectors we need to process - todoVec.push_front(m_inputsVxp); - m_inputsVxp->isFromInput(true); // By definition + todoVec.push_front(&m_inputsVtx); + m_inputsVtx.isFromInput(true); // By definition while (!todoVec.empty()) { OrderEitherVertex* vertexp = todoVec.back(); todoVec.pop_back(); @@ -1318,7 +1363,7 @@ void OrderVisitor::processInputs() { } } -void OrderVisitor::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& todoVec) { +void OrderProcess::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& todoVec) { // Propagate PrimaryIn through simple assignments if (vertexp->user()) return; // Already processed if (false && debug() >= 9) { @@ -1358,7 +1403,7 @@ void OrderVisitor::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& // UINFO(9, " InIdone " << vertexp << endl); } -void OrderVisitor::processInputsOutIterate(OrderEitherVertex* vertexp, VertexVec& todoVec) { +void OrderProcess::processInputsOutIterate(OrderEitherVertex* vertexp, VertexVec& todoVec) { if (vertexp->user() == 3) return; // Already out processed // UINFO(9, " InOIter " << vertexp << endl); // First make sure input path is fully recursed @@ -1387,7 +1432,7 @@ void OrderVisitor::processInputsOutIterate(OrderEitherVertex* vertexp, VertexVec //###################################################################### // OrderVisitor - Circular detection -void OrderVisitor::processCircular() { +void OrderProcess::processCircular() { // Take broken edges and add circular flags // The change detect code will use this to force changedets for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { @@ -1432,7 +1477,7 @@ void OrderVisitor::processCircular() { } } -void OrderVisitor::processSensitive() { +void OrderProcess::processSensitive() { // Sc sensitives are required on all inputs that go to a combo // block. (Not inputs that go only to clocked blocks.) for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { @@ -1456,7 +1501,7 @@ void OrderVisitor::processSensitive() { } } -void OrderVisitor::processDomains() { +void OrderProcess::processDomains() { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { OrderEitherVertex* vertexp = dynamic_cast(itp); UASSERT(vertexp, "Null or vertex not derived from EitherVertex"); @@ -1464,7 +1509,7 @@ void OrderVisitor::processDomains() { } } -void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) { +void OrderProcess::processDomainsIterate(OrderEitherVertex* vertexp) { // The graph routines have already sorted the vertexes and edges into best->worst order // Assign clock domains to each signal. // Sequential logic is forced into the same sequential domain. @@ -1475,7 +1520,6 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) { UINFO(5, " pdi: " << vertexp << endl); OrderVarVertex* vvertexp = dynamic_cast(vertexp); AstSenTree* domainp = nullptr; - UASSERT(m_comboDomainp, "not preset"); if (vvertexp && vvertexp->varScp()->varp()->isNonOutput()) domainp = m_comboDomainp; if (vvertexp && vvertexp->varScp()->isCircular()) domainp = m_comboDomainp; if (!domainp) { @@ -1548,7 +1592,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) { //###################################################################### // OrderVisitor - Move graph construction -void OrderVisitor::processEdgeReport() { +void OrderProcess::processEdgeReport() { // Make report of all signal names and what clock edges they have const string filename = v3Global.debugFilename("order_edges.txt"); const std::unique_ptr logp{V3File::new_ofstream(filename)}; @@ -1581,19 +1625,19 @@ void OrderVisitor::processEdgeReport() { for (const string& i : report) *logp << i << '\n'; } -void OrderVisitor::processMoveClear() { +void OrderProcess::processMoveClear() { OrderMoveDomScope::clear(); m_pomWaiting.reset(); m_pomReadyDomScope.reset(); m_pomGraph.clear(); } -void OrderVisitor::processMoveBuildGraph() { +void OrderProcess::processMoveBuildGraph() { // Build graph of only vertices UINFO(5, " MoveBuildGraph\n"); processMoveClear(); - m_pomGraph - .userClearVertices(); // Vertex::user->OrderMoveVertex*, last edge added or nullptr=none + // Vertex::user->OrderMoveVertex*, last edge added or nullptr=none + m_pomGraph.userClearVertices(); OrderMoveVertexMaker createOrderMoveVertex(&m_pomGraph, &m_pomWaiting); ProcessMoveBuildGraph serialPMBG(&m_graph, &m_pomGraph, @@ -1604,7 +1648,7 @@ void OrderVisitor::processMoveBuildGraph() { //###################################################################### // OrderVisitor - Moving -void OrderVisitor::processMove() { +void OrderProcess::processMove() { // The graph routines have already sorted the vertexes and edges into best->worst order // Make a new waiting graph with only OrderLogicVertex's // (Order is preserved in the recreation so the sorting is preserved) @@ -1654,7 +1698,7 @@ void OrderVisitor::processMove() { processMoveClear(); } -void OrderVisitor::processMovePrepReady() { +void OrderProcess::processMovePrepReady() { // Make list of ready nodes UINFO(5, " MovePrepReady\n"); for (OrderMoveVertex* vertexp = m_pomWaiting.begin(); vertexp;) { @@ -1664,7 +1708,7 @@ void OrderVisitor::processMovePrepReady() { } } -void OrderVisitor::processMoveReadyOne(OrderMoveVertex* vertexp) { +void OrderProcess::processMoveReadyOne(OrderMoveVertex* vertexp) { // Recursive! // Move one node from waiting to ready list vertexp->setReady(); @@ -1681,7 +1725,7 @@ void OrderVisitor::processMoveReadyOne(OrderMoveVertex* vertexp) { } } -void OrderVisitor::processMoveDoneOne(OrderMoveVertex* vertexp) { +void OrderProcess::processMoveDoneOne(OrderMoveVertex* vertexp) { // Move one node from ready to completion vertexp->setMoved(); // Unlink from ready lists @@ -1707,7 +1751,7 @@ void OrderVisitor::processMoveDoneOne(OrderMoveVertex* vertexp) { } } -void OrderVisitor::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, +void OrderProcess::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, int level) { UASSERT_OBJ(vertexp->domScopep() == domScopep, vertexp, "Domain mismatch; list misbuilt?"); const OrderLogicVertex* lvertexp = vertexp->logicp(); @@ -1716,17 +1760,17 @@ void OrderVisitor::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* d << " s=" << cvtToHex(scopep) << " " << lvertexp << endl); AstActive* newActivep = processMoveOneLogic(lvertexp, m_pomNewFuncp /*ref*/, m_pomNewStmts /*ref*/); - if (newActivep) m_scopetopp->addActivep(newActivep); + if (newActivep) m_scopetop.addActivep(newActivep); processMoveDoneOne(vertexp); } -AstActive* OrderVisitor::processMoveOneLogic(const OrderLogicVertex* lvertexp, +AstActive* OrderProcess::processMoveOneLogic(const OrderLogicVertex* lvertexp, AstCFunc*& newFuncpr, int& newStmtsr) { AstActive* activep = nullptr; AstScope* const scopep = lvertexp->scopep(); AstSenTree* const domainp = lvertexp->domainp(); AstNode* nodep = lvertexp->nodep(); - AstNodeModule* const modp = VN_AS(scopep->user1p(), NodeModule); // Stashed by visitor func + AstNodeModule* const modp = scopep->modp(); UASSERT(modp, "nullptr"); if (VN_IS(nodep, SenTree)) { // Just ignore sensitivities, we'll deal with them when we move statements that need them @@ -1794,7 +1838,7 @@ AstActive* OrderVisitor::processMoveOneLogic(const OrderLogicVertex* lvertexp, return activep; } -void OrderVisitor::processMTasksInitial(InitialLogicE logic_type) { +void OrderProcess::processMTasksInitial(InitialLogicE logic_type) { // Emit initial/settle logic. Initial blocks won't be part of the // mtask partition, aren't eligible for parallelism. // @@ -1813,11 +1857,11 @@ void OrderVisitor::processMTasksInitial(InitialLogicE logic_type) { lastScopep = initp->scopep(); } AstActive* newActivep = processMoveOneLogic(initp, initCFunc /*ref*/, initStmts /*ref*/); - if (newActivep) m_scopetopp->addActivep(newActivep); + if (newActivep) m_scopetop.addActivep(newActivep); } } -void OrderVisitor::processMTasks() { +void OrderProcess::processMTasks() { // For nondeterminism debug: V3Partition::hashGraphDebug(&m_graph, "V3Order's m_graph"); @@ -1893,7 +1937,7 @@ void OrderVisitor::processMTasks() { // of the MTask graph. FileLine* rootFlp = v3Global.rootp()->fileline(); AstExecGraph* execGraphp = new AstExecGraph(rootFlp); - m_scopetopp->addActivep(execGraphp); + m_scopetop.addActivep(execGraphp); v3Global.rootp()->execGraphp(execGraphp); // Create CFuncs and bodies for each MTask. @@ -1952,7 +1996,7 @@ void OrderVisitor::processMTasks() { //###################################################################### // OrderVisitor - Top processing -void OrderVisitor::process() { +void OrderProcess::process() { // Dump data m_graph.dumpDotFilePrefixed("orderg_pre"); @@ -2020,12 +2064,16 @@ void OrderVisitor::process() { //###################################################################### // Order class functions -void V3Order::orderAll(AstNetlist* nodep) { +void V3Order::orderAll(AstNetlist* netlistp) { UINFO(2, __FUNCTION__ << ": " << endl); - { - OrderClkMarkVisitor markVisitor{nodep}; - OrderVisitor visitor; - visitor.main(nodep); - } // Destruct before checking + // Propagate 'clocker' attribute through logic + OrderClkMarkVisitor::process(netlistp); + // Build ordering graph + std::unique_ptr orderGraph = OrderBuildVisitor::process(netlistp); + // Order the netlist + OrderProcess::main(netlistp, *orderGraph.get()); + // Reset debug level + orderGraph.get()->debug(V3Error::debugDefault()); + // Dump tree V3Global::dumpCheckGlobalTree("order", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index 56e44bc99..963aa0415 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -167,6 +167,7 @@ public: virtual string name() const override { return "*INPUTS*"; } virtual string dotColor() const override { return "green"; } virtual string dotName() const override { return ""; } + virtual string dotShape() const override { return "invhouse"; } virtual bool domainMatters() override { return false; } }; @@ -193,7 +194,9 @@ public: return (cvtToHex(m_nodep) + "\\n " + cvtToStr(nodep()->typeName())); } AstNode* nodep() const { return m_nodep; } - virtual string dotColor() const override { return "yellow"; } + virtual string dotShape() const override { + return VN_IS(m_nodep, Active) ? "doubleoctagon" : "rect"; + } }; class OrderVarVertex VL_NOT_FINAL : public OrderEitherVertex { @@ -221,6 +224,7 @@ public: bool isClock() const { return m_isClock; } void isDelayed(bool flag) { m_isDelayed = flag; } bool isDelayed() const { return m_isDelayed; } + virtual string dotShape() const override { return "ellipse"; } }; class OrderVarStdVertex final : public OrderVarVertex { @@ -238,7 +242,7 @@ public: virtual string name() const override { return (cvtToHex(varScp()) + "\\n " + varScp()->name()); } - virtual string dotColor() const override { return "skyblue"; } + virtual string dotColor() const override { return "grey"; } virtual bool domainMatters() override { return true; } }; class OrderVarPreVertex final : public OrderVarVertex { @@ -256,7 +260,7 @@ public: virtual string name() const override { return (cvtToHex(varScp()) + " PRE\\n " + varScp()->name()); } - virtual string dotColor() const override { return "lightblue"; } + virtual string dotColor() const override { return "green"; } virtual bool domainMatters() override { return false; } }; class OrderVarPostVertex final : public OrderVarVertex { @@ -274,7 +278,7 @@ public: virtual string name() const override { return (cvtToHex(varScp()) + " POST\\n " + varScp()->name()); } - virtual string dotColor() const override { return "CadetBlue"; } + virtual string dotColor() const override { return "red"; } virtual bool domainMatters() override { return false; } }; class OrderVarPordVertex final : public OrderVarVertex { @@ -292,7 +296,7 @@ public: virtual string name() const override { return (cvtToHex(varScp()) + " PORD\\n " + varScp()->name()); } - virtual string dotColor() const override { return "NavyBlue"; } + virtual string dotColor() const override { return "blue"; } virtual bool domainMatters() override { return false; } }; @@ -307,7 +311,7 @@ class OrderMoveVertex final : public V3GraphVertex { OrderMoveDomScope* m_domScopep; // Domain/scope list information protected: - friend class OrderVisitor; + friend class OrderProcess; friend class OrderMoveVertexMaker; // These only contain the "next" item, // for the head of the list, see the same var name under OrderVisitor diff --git a/src/V3SenTree.h b/src/V3SenTree.h index 243d493fa..2cc62d06b 100644 --- a/src/V3SenTree.h +++ b/src/V3SenTree.h @@ -82,21 +82,24 @@ private: public: // CONSTRUCTORS SenTreeFinder() - : m_topScopep{v3Global.rootp()->topScopep()} { + : SenTreeFinder(v3Global.rootp()) {} + + explicit SenTreeFinder(AstNetlist* netlistp) + : m_topScopep{netlistp->topScopep()} { // Gather existing global SenTrees - for (AstSenTree* nodep = m_topScopep->senTreesp(); nodep; - nodep = VN_AS(nodep->nextp(), SenTree)) { - m_trees.add(nodep); + for (AstNode* nodep = m_topScopep->senTreesp(); nodep; nodep = nodep->nextp()) { + m_trees.add(VN_AS(nodep, SenTree)); } } // METHODS + + // Return a global AstSenTree that matches given SenTree. + // If no such global AstSenTree exists create one and add it to the stored AstTopScope. AstSenTree* getSenTree(AstSenTree* senTreep) { - // Return a global SenTree that matches given SenTree. If no such global - // SenTree exists, create one and add it to the stored TopScope. AstSenTree* treep = m_trees.find(senTreep); - // Not found, form a new one if (!treep) { + // Not found, form a new one treep = senTreep->cloneTree(false); m_topScopep->addSenTreep(treep); UINFO(8, " New SENTREE " << treep << endl); @@ -104,6 +107,16 @@ public: } return treep; } + + // Return the global combinational AstSenTree. + // If no such global SenTree exists create one and add it to the stored AstTopScope. + AstSenTree* getComb() { + FileLine* const fl = m_topScopep->fileline(); + AstSenTree* const combp = new AstSenTree{fl, new AstSenItem{fl, AstSenItem::Combo()}}; + AstSenTree* const resultp = getSenTree(combp); + VL_DO_DANGLING(combp->deleteTree(), combp); // getSenTree clones, so can delete + return resultp; + } }; #endif // Guard diff --git a/src/astgen b/src/astgen index 97534f102..579a7f014 100755 --- a/src/astgen +++ b/src/astgen @@ -362,21 +362,19 @@ def read_types(filename): match = re.search(r'^\s*(class|struct)\s*(\S+)', line) if match: classn = match.group(2) - inh = "" match = re.search(r':\s*public\s+(\S+)', line) - if match: - inh = match.group(1) - # print("class "+classn+" : "+inh) - if classn == "AstNode": - inh = "" - if re.search(r'Ast', inh) or classn == "AstNode": + supern = match.group(1) if match else "" + assert classn != "AstNode" or supern == "", "AstNode can't have a superclass" + if re.search(r'Ast', supern) or classn == "AstNode": + if supern == "AstNDeleter": + continue classn = re.sub(r'^Ast', '', classn) - inh = re.sub(r'^Ast', '', inh) - Classes[classn] = inh - if inh != '': - if inh not in Children: - Children[inh] = {} - Children[inh][classn] = 1 + supern = re.sub(r'^Ast', '', supern) + Classes[classn] = supern + if supern != '': + if supern not in Children: + Children[supern] = {} + Children[supern][classn] = 1 def read_stages(filename): From f3b10df454335504fe318813fbd8c6ad284f1893 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Mon, 25 Oct 2021 20:56:59 +0900 Subject: [PATCH 13/79] Skip merging assign statements if a variable is marked split_var to fix #3177 (#3179) * add tests to reproduce #3177. Any random test circuits can be added to t_split_var_4.v later because it uses CRC to check the result while t_split_var_0.v has just barrel shifters. * Fix #3177. Don't merge assign statements if a variable is marked split_var. --- src/V3Const.cpp | 2 + test_regress/t/t_split_var_0.pl | 2 +- test_regress/t/t_split_var_2_trace.pl | 2 +- test_regress/t/t_split_var_4.pl | 24 +++++++ test_regress/t/t_split_var_4.v | 99 +++++++++++++++++++++++++++ test_regress/t/t_split_var_5.pl | 26 +++++++ 6 files changed, 153 insertions(+), 2 deletions(-) create mode 100755 test_regress/t/t_split_var_4.pl create mode 100644 test_regress/t/t_split_var_4.v create mode 100755 test_regress/t/t_split_var_5.pl diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 1ffc1b32d..259cc7417 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1911,6 +1911,8 @@ private: // assignment. For speed, we only look 3 deep, then give up. if (!varNotReferenced(nodep->rhsp(), varref1p->varp())) return false; if (!varNotReferenced(nextp->rhsp(), varref2p->varp())) return false; + // If a variable is marked split_var, access to the variable should not be merged. + if (varref1p->varp()->attrSplitVar() || varref2p->varp()->attrSplitVar()) return false; // Swap? if ((con1p->toSInt() != con2p->toSInt() + sel2p->width()) && (con2p->toSInt() != con1p->toSInt() + sel1p->width())) { diff --git a/test_regress/t/t_split_var_0.pl b/test_regress/t/t_split_var_0.pl index f04359527..5f07afe64 100755 --- a/test_regress/t/t_split_var_0.pl +++ b/test_regress/t/t_split_var_0.pl @@ -22,7 +22,7 @@ execute( check_finished => 1, ); -file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 11); +file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 13); file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 27); ok(1); 1; diff --git a/test_regress/t/t_split_var_2_trace.pl b/test_regress/t/t_split_var_2_trace.pl index 76513de86..c79ed778a 100755 --- a/test_regress/t/t_split_var_2_trace.pl +++ b/test_regress/t/t_split_var_2_trace.pl @@ -24,7 +24,7 @@ execute( ); vcd_identical("$Self->{obj_dir}/simx.vcd", $Self->{golden_filename}); -file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 10); +file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 12); file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 27); ok(1); diff --git a/test_regress/t/t_split_var_4.pl b/test_regress/t/t_split_var_4.pl new file mode 100755 index 000000000..9030a83e0 --- /dev/null +++ b/test_regress/t/t_split_var_4.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); + +compile( + verilator_flags2 => ['--stats', '-DENABLE_SPLIT_VAR=1'], + ); + +execute( + check_finished => 1, + ); + +file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 1); +file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 0); +ok(1); +1; diff --git a/test_regress/t/t_split_var_4.v b/test_regress/t/t_split_var_4.v new file mode 100644 index 000000000..f8557f479 --- /dev/null +++ b/test_regress/t/t_split_var_4.v @@ -0,0 +1,99 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 Yutetsu TAKATSUKASA. +// SPDX-License-Identifier: CC0-1.0 + +`ifdef ENABLE_SPLIT_VAR +`define SPLIT_VAR_COMMENT /* verilator split_var */ +`else +`define SPLIT_VAR_COMMENT +/* verilator lint_off UNOPTFLAT */ +`endif + +module t(/*AUTOARG*/ + // Inputs + clk + ); + input clk; + + integer cyc=0; + reg [63:0] crc; + reg [63:0] sum; + + // Take CRC data and apply to testblock inputs + wire [31:0] in = crc[31:0]; + wire o0; + + wire [15:0] vec_i = crc[15:0]; + wire [31:0] i = crc[31:0]; + + Test test(/*AUTOINST*/ + // Outputs + .o0 (o0), + // Inputs + .clk (clk), + .i (i[1:0])); + + // Aggregate outputs into a single result vector + // verilator lint_off WIDTH + wire [63:0] result = {o0}; + // verilator lint_on WIDTH + + // Test loop + always @ (posedge clk) begin +`ifdef TEST_VERBOSE + $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $display("o %b", o0); +`endif + cyc <= cyc + 1; + crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + if (cyc == 0) begin + // Setup + crc <= 64'h5aef0c8d_d70a4497; + sum <= '0; + end + else if (cyc == 99) begin + $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + if (crc !== 64'hc77bb9b3784ea091) $stop; + // What checksum will we end up with (above print should match) +`define EXPECTED_SUM 64'hb58b16c592557b30 + if (sum !== `EXPECTED_SUM) $stop; + $write("*-* All Finished *-*\n"); + $finish; + end + end + +endmodule + +module Test(/*AUTOARG*/ + // Outputs + o0, + // Inputs + clk, i + ); + + input wire clk; + input wire [1:0] i; + output reg o0; + + typedef struct packed { + logic v0, v1; + } packed_type0; + packed_type0 value0 `SPLIT_VAR_COMMENT; + wire value0_v0; + + assign value0.v0 = i[0]; + assign value0.v1 = i[1] & !value0_v0; + assign value0_v0 = value0.v0; + + always_ff @(posedge clk) begin + o0 <= |value0; + end +endmodule + + +`ifdef ENABLE_SPLIT_VAR +/* verilator lint_on UNOPTFLAT */ +`endif diff --git a/test_regress/t/t_split_var_5.pl b/test_regress/t/t_split_var_5.pl new file mode 100755 index 000000000..0fc4cc23a --- /dev/null +++ b/test_regress/t/t_split_var_5.pl @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); +top_filename("t/t_split_var_4.v"); + +compile( + verilator_flags2 => ['--stats'] + ); + +execute( + check_finished => 1, + ); + +file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 0); +file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 0); +ok(1); +1; + From 4ef37d9411cf78545e6babd09c9a578b9947513a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 25 Oct 2021 19:53:29 -0400 Subject: [PATCH 14/79] Commentary --- docs/guide/exe_verilator.rst | 40 +++++++++++++++++------------------- docs/guide/extensions.rst | 7 +++---- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 8ed959e21..7e38489e5 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -158,28 +158,26 @@ Summary: .. option:: --clk - Sometimes it is quite difficult for Verilator to distinguish clock - signals from other data signals. Occasionally the clock signals can end - up in the checking list of signals which determines if further - evaluation is needed. This will heavily degrade the performance of a - Verilated model. - With :vlopt:`--clk`, the specified signal-name is taken as a root clock - into the model, then Verilator will mark the signal as clocker and - propagate the clocker attribute automatically to other signals derived - from that. In this way, Verilator will try to avoid taking the clocker - signal into checking list. + into the model; Verilator will mark the signal as clocker and + propagate the clocker attribute automatically to other signals downstream in + that clock tree. - Note signal-name is specified by the RTL hierarchy path. For example, - v.foo.bar. If the signal is the input to top-module, the directly the - signal name. If you find it difficult to find the exact name, try to use - a :option:`/*verilator&32;clocker*/` metacomment in RTL file to mark the + The provided signal-name is specified using a RTL hierarchy path. For + example, v.foo.bar. If the signal is the input to top-module, then + directly provide the signal name. Alternatively, use a + :option:`/*verilator&32;clocker*/` metacomment in RTL file to mark the signal directly. - If clock signals are assigned to vectors and then later used - individually, Verilator will attempt to decompose the vector and connect - the single-bit clock signals directly. This should be transparent to - the user. + If clock signals are assigned to vectors and then later used as + individual bits, Verilator will attempt to decompose the vector and + connect the single-bit clock signals. + + The clocker attribute is useful in cases where Verilator does not + properly distinguish clock signals from other data signals. Using + clocker will cause the signal indicated to be considered a clock, and + remove it from the combinatorial logic reevaluation checking code. This + may greatly improve performance. .. option:: --make @@ -1506,9 +1504,9 @@ The grammar of configuration commands is as follows: .. option:: no_clocker -module "" [-function ""] -var "" - Indicate the signal is used as clock or not. This information is used by - Verilator to mark the signal as clocker and propagate the clocker - attribute automatically to derived signals. See :vlopt:`--clk`. + Indicates that the signal is used as clock or not. This information is + used by Verilator to mark the signal and any derrived signals as + clocker. See :vlopt:`--clk`. Same as :option:`/*verilator&32;clocker*/` metacomment. diff --git a/docs/guide/extensions.rst b/docs/guide/extensions.rst index c82c89adb..6e2d26495 100644 --- a/docs/guide/extensions.rst +++ b/docs/guide/extensions.rst @@ -176,10 +176,9 @@ or "`ifdef`"'s may break other tools. .. option:: /*verilator&32;no_clocker*/ - Used after a signal declaration to indicate the signal is used as clock - or not. This information is used by Verilator to mark the signal as - clocker and propagate the clocker attribute automatically to derived - signals. See :vlopt:`--clk`. + Specifies that the signal is used as clock or not. This information is + used by Verilator to mark the signal and any derrived signals as + clocker. See :vlopt:`--clk`. Same as :option:`clocker` and :option:`no_clocker` in configuration files. From a1bb471acaab857c8754cbfe301294fda9ee9de0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 25 Oct 2021 20:19:49 -0400 Subject: [PATCH 15/79] Internals: Iterate sentree in clocker to avoid confusing iterateChildren. No functional change intended. --- src/V3GenClk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index cf7c4fc54..498d6fe08 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -115,7 +115,7 @@ private: virtual void visit(AstActive* nodep) override { m_activep = nodep; UASSERT_OBJ(nodep->sensesp(), nodep, "Unlinked"); - iterateChildren(nodep->sensesp()); // iterateAndNext? + iterate(nodep->sensesp()); m_activep = nullptr; iterateChildren(nodep); } @@ -210,7 +210,7 @@ private: UINFO(8, "ACTIVE " << nodep << endl); m_activep = nodep; UASSERT_OBJ(nodep->sensesp(), nodep, "Unlinked"); - iterateChildren(nodep->sensesp()); // iterateAndNext? + iterate(nodep->sensesp()); m_activep = nullptr; iterateChildren(nodep); } From 90102d98673daf53d9dd7745ed8b5bd29d65ce73 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 25 Oct 2021 21:02:02 -0400 Subject: [PATCH 16/79] Commentary --- include/verilated_trace_imp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/verilated_trace_imp.cpp b/include/verilated_trace_imp.cpp index ba8e43110..84225ed98 100644 --- a/include/verilated_trace_imp.cpp +++ b/include/verilated_trace_imp.cpp @@ -267,7 +267,7 @@ template <> void VerilatedTrace::flushBase() { // Callbacks to run on global events template <> void VerilatedTrace::onFlush(void* selfp) { - // This calls 'flush' on the derived classo (which must then get any mutex) + // This calls 'flush' on the derived class (which must then get any mutex) reinterpret_cast(selfp)->flush(); } From fdbf465edae84e7b4f907a45c2473f066fd2fd89 Mon Sep 17 00:00:00 2001 From: Teng Huang Date: Wed, 27 Oct 2021 00:20:45 +0800 Subject: [PATCH 17/79] Fix array method names with parens (#3181) (#3183) --- docs/CONTRIBUTORS | 1 + src/verilog.y | 2 +- test_regress/t/t_assoc_method.v | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 1a86f4570..898bd3ba7 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -88,6 +88,7 @@ Sergi Granell Stefan Wallentowitz Stephen Henry Steven Hugg +Teng Huang Tim Snyder Tobias Rosenkranz Tobias Wölfel diff --git a/src/verilog.y b/src/verilog.y index 8cca67a2c..7d6e44d16 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -4117,7 +4117,7 @@ array_methodNoRoot: ; array_methodWith: - array_methodNoRoot { $$ = $1; } + array_methodNoRoot parenE { $$ = $1; } | array_methodNoRoot parenE yWITH__PAREN '(' expr ')' { $$ = new AstWithParse($3, false, $1, $5); } | array_methodNoRoot '(' expr ')' yWITH__PAREN '(' expr ')' diff --git a/test_regress/t/t_assoc_method.v b/test_regress/t/t_assoc_method.v index 684e90c68..e4d87f611 100644 --- a/test_regress/t/t_assoc_method.v +++ b/test_regress/t/t_assoc_method.v @@ -119,6 +119,26 @@ module t (/*AUTOARG*/); i = qe.xor; `checkh(i, 32'b0); + i = q.and(); + `checkh(i, 32'b1000); + i = q.and() with (item + 1); + `checkh(i, 32'b1001); + i = q.or(); + `checkh(i, 32'b1110); + i = q.or() with (item + 1); + `checkh(i, 32'b1111); + i = q.xor(); + `checkh(i, 32'b0110); + i = q.xor() with (item + 1); + `checkh(i, 32'b0110); + + i = qe.and(); + `checkh(i, 32'b0); + i = qe.or(); + `checkh(i, 32'b0); + i = qe.xor(); + `checkh(i, 32'b0); + $write("*-* All Finished *-*\n"); $finish; end From 304697d1337cf76b6e894dceeec8f602e0100b94 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 1 Nov 2021 08:57:43 -0400 Subject: [PATCH 18/79] Commentary --- Changes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changes b/Changes index c8497c591..8f6484fc0 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,9 @@ Verilator 4.215 devel **Minor:** +* Internal code cleanups and improvements. [Geza Lore] +* Fix array method names with parens (#3181) (#3183). [Teng Huang] +* Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] Verilator 4.214 2021-10-17 From 758264dc7729e7e270e38b34548f7a80acd10600 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 1 Nov 2021 08:59:00 -0400 Subject: [PATCH 19/79] Fix nested generate if genblk naming (#3189). --- Changes | 1 + src/V3LinkParse.cpp | 31 +++++++++++++++++++++++------- test_regress/t/t_gen_ifelse.pl | 21 ++++++++++++++++++++ test_regress/t/t_gen_ifelse.v | 35 ++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 7 deletions(-) create mode 100755 test_regress/t/t_gen_ifelse.pl create mode 100644 test_regress/t/t_gen_ifelse.v diff --git a/Changes b/Changes index 8f6484fc0..809d45d07 100644 --- a/Changes +++ b/Changes @@ -16,6 +16,7 @@ Verilator 4.215 devel * Internal code cleanups and improvements. [Geza Lore] * Fix array method names with parens (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] +* Fix nested generate if genblk naming (#3189). [yanx21] Verilator 4.214 2021-10-17 diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 49c0c3e9d..be349ee45 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -105,6 +105,21 @@ private: } } + bool nestedIfBegin(AstBegin* nodep) { // Point at begin inside the GenIf + // IEEE says directly nested item is not a new block + // The genblk name will get attached to the if true/false LOWER begin block(s) + // 1: GENIF + // -> 1:3: BEGIN [GEN] [IMPLIED] // nodep passed to this function + // 1:3:1: GENIF + // 1:3:1:2: BEGIN genblk1 [GEN] [IMPLIED] + AstNode* const backp = nodep->backp(); + return (nodep->implied() // User didn't provide begin/end + && VN_IS(backp, GenIf) && VN_CAST(backp, GenIf)->elsesp() == nodep + && !nodep->nextp() // No other statements under upper genif else + && (VN_IS(nodep->stmtsp(), GenIf)) // Begin has if underneath + && !nodep->stmtsp()->nextp()); // Has only one item + } + // VISITs virtual void visit(AstNodeFTask* nodep) override { if (!nodep->user1SetOnce()) { // Process only once. @@ -539,12 +554,10 @@ private: virtual void visit(AstBegin* nodep) override { V3Config::applyCoverageBlock(m_modp, nodep); cleanFileline(nodep); - AstNode* backp = nodep->backp(); + AstNode* const backp = nodep->backp(); // IEEE says directly nested item is not a new block - const bool nestedIf = (nodep->implied() // User didn't provide begin/end - && (VN_IS(nodep->stmtsp(), GenIf) - || VN_IS(nodep->stmtsp(), GenCase)) // Has an if/case - && !nodep->stmtsp()->nextp()); // Has only one item + // The genblk name will get attached to the if true/false LOWER begin block(s) + const bool nestedIf = nestedIfBegin(nodep); // It's not FOR(BEGIN(...)) but we earlier changed it to BEGIN(FOR(...)) if (nodep->genforp()) { ++m_genblkNum; @@ -576,9 +589,13 @@ private: } } virtual void visit(AstGenIf* nodep) override { - ++m_genblkNum; cleanFileline(nodep); - { + bool nestedIf + = (VN_IS(nodep->backp(), Begin) && nestedIfBegin(VN_CAST(nodep->backp(), Begin))); + if (nestedIf) { + iterateChildren(nodep); + } else { + ++m_genblkNum; VL_RESTORER(m_genblkAbove); VL_RESTORER(m_genblkNum); m_genblkAbove = m_genblkNum; diff --git a/test_regress/t/t_gen_ifelse.pl b/test_regress/t/t_gen_ifelse.pl new file mode 100755 index 000000000..2cb5eeaff --- /dev/null +++ b/test_regress/t/t_gen_ifelse.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2021 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); + +compile( + ); + +execute( + check_finished => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_gen_ifelse.v b/test_regress/t/t_gen_ifelse.v new file mode 100644 index 000000000..c23565d85 --- /dev/null +++ b/test_regress/t/t_gen_ifelse.v @@ -0,0 +1,35 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module s; + parameter A = 0; + generate + if (A == 1) + int i; + else if (A == 2) + int i; + else + int i; + endgenerate + generate + if (A == 1) + int i; + else if (A == 2) + int i; + else + int i; + endgenerate +endmodule + +module t; + s #(0) s0(); + s #(1) s1(); + s #(2) s2(); + initial begin + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule From c26ce25ceaddbeaa876292770c9f026e78c3f520 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 3 Nov 2021 17:49:19 -0400 Subject: [PATCH 20/79] Internals: Add more const. No functional change. --- src/V3GraphStream.h | 8 +- src/V3Partition.cpp | 245 ++++++++++++++++++++++---------------------- src/V3Scoreboard.h | 4 +- 3 files changed, 131 insertions(+), 126 deletions(-) diff --git a/src/V3GraphStream.h b/src/V3GraphStream.h index 196aa60ef..85d6ea32c 100644 --- a/src/V3GraphStream.h +++ b/src/V3GraphStream.h @@ -111,7 +111,7 @@ public: } else { uint32_t depCount = 0; for (V3GraphEdge* depp = vxp->inBeginp(); depp; depp = depp->inNextp()) { - depCount++; + ++depCount; } VxHolder newVx(vxp, pos++, depCount); m_waitingVertices.emplace(vxp, newVx); @@ -123,7 +123,7 @@ public: } else { uint32_t depCount = 0; for (V3GraphEdge* depp = vxp->outBeginp(); depp; depp = depp->outNextp()) { - depCount++; + ++depCount; } VxHolder newVx(vxp, pos++, depCount); m_waitingVertices.emplace(vxp, newVx); @@ -194,7 +194,7 @@ private: void unblockDeps(const V3GraphVertex* vertexp) { if (m_way == GraphWay::FORWARD) { for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - V3GraphVertex* toVertexp = edgep->top(); + V3GraphVertex* const toVertexp = edgep->top(); const auto it = m_waitingVertices.find(toVertexp); UASSERT_OBJ(it != m_waitingVertices.end(), toVertexp, @@ -206,7 +206,7 @@ private: } } else { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - V3GraphVertex* fromVertexp = edgep->fromp(); + V3GraphVertex* const fromVertexp = edgep->fromp(); const auto it = m_waitingVertices.find(fromVertexp); UASSERT_OBJ(it != m_waitingVertices.end(), fromVertexp, diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index d9fc5f1d1..fc6d8d999 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -187,13 +187,13 @@ public: // of each, and add each to m_pending if its overall CP has grown. for (V3GraphEdge* edgep = vxp->beginp(m_way); edgep; edgep = edgep->nextp(m_way)) { if (!m_edgeFuncp(edgep)) continue; - V3GraphVertex* relativep = edgep->furtherp(m_way); + V3GraphVertex* const relativep = edgep->furtherp(m_way); m_accessp->notifyEdgeCp(relativep, m_way, vxp, newInclusiveCp); if (m_accessp->critPathCost(relativep, m_way) < newInclusiveCp) { // relativep's critPathCost() is out of step with its // longest !wayward edge. Schedule that to be resolved. - uint32_t newPendingVal + const uint32_t newPendingVal = newInclusiveCp - m_accessp->critPathCost(relativep, m_way); if (m_pending.has(relativep)) { if (newPendingVal > m_pending.at(relativep)) { @@ -225,14 +225,14 @@ public: // This generalizes to multiple seed nodes also. while (!m_pending.empty()) { const auto it = m_pending.rbegin(); - V3GraphVertex* updateMep = (*it).key(); - uint32_t cpGrowBy = (*it).value(); + V3GraphVertex* const updateMep = (*it).key(); + const uint32_t cpGrowBy = (*it).value(); m_pending.erase(it); // For *updateMep, whose critPathCost was out-of-date with respect // to its edges, update the critPathCost. - uint32_t startCp = m_accessp->critPathCost(updateMep, m_way); - uint32_t newCp = startCp + cpGrowBy; + const uint32_t startCp = m_accessp->critPathCost(updateMep, m_way); + const uint32_t newCp = startCp + cpGrowBy; if (m_slowAsserts) m_accessp->checkNewCpVersusEdges(updateMep, m_way, newCp); m_accessp->setCritPathCost(updateMep, m_way, newCp); @@ -263,7 +263,7 @@ protected: friend class PartPropagateCp; void notifyEdgeCp(V3GraphVertex* vxp, GraphWay way, V3GraphVertex* throughp, uint32_t cp) const { - uint32_t throughCost = critPathCost(throughp, way); + const uint32_t throughCost = critPathCost(throughp, way); UASSERT_SELFTEST(uint32_t, cp, (1 + throughCost)); } @@ -293,10 +293,10 @@ private: // redundant to test. GraphStreamUnordered order(&m_graph); while (const V3GraphVertex* cvxp = order.nextp()) { - V3GraphVertex* vxp = const_cast(cvxp); + V3GraphVertex* const vxp = const_cast(cvxp); uint32_t cpCost = 0; for (V3GraphEdge* edgep = vxp->inBeginp(); edgep; edgep = edgep->inNextp()) { - V3GraphVertex* parentp = edgep->fromp(); + V3GraphVertex* const parentp = edgep->fromp(); cpCost = std::max(cpCost, critPathCost(parentp, GraphWay::FORWARD) + 1); } if (checkOnly) { @@ -315,8 +315,8 @@ private: // Create 250 edges at random. Edges must go from // lower-to-higher index vertices, so we get a DAG. for (unsigned i = 0; i < 250; ++i) { - unsigned idx1 = V3Os::rand64(rngState) % 50; - unsigned idx2 = V3Os::rand64(rngState) % 50; + const unsigned idx1 = V3Os::rand64(rngState) % 50; + const unsigned idx2 = V3Os::rand64(rngState) % 50; if (idx1 > idx2) { new V3GraphEdge(&m_graph, m_vx[idx2], m_vx[idx1], 1); } else if (idx2 > idx1) { @@ -375,17 +375,17 @@ public: ~CpCostAccessor() = default; // Return cost of this node uint32_t cost(const V3GraphVertex* vxp) const { - const LogicMTask* mtaskp = dynamic_cast(vxp); + const LogicMTask* const mtaskp = dynamic_cast(vxp); return mtaskp->stepCost(); } // Return stored CP to this node uint32_t critPathCost(const V3GraphVertex* vxp, GraphWay way) const { - const LogicMTask* mtaskp = dynamic_cast(vxp); + const LogicMTask* const mtaskp = dynamic_cast(vxp); return mtaskp->critPathCost(way); } // Store a new CP to this node void setCritPathCost(V3GraphVertex* vxp, GraphWay way, uint32_t cost) const { - LogicMTask* mtaskp = dynamic_cast(vxp); + LogicMTask* const mtaskp = dynamic_cast(vxp); mtaskp->setCritPathCost(way, cost); } // Notify vxp that the wayward CP at the throughp-->vxp edge @@ -393,19 +393,19 @@ public: // This is our cue to update vxp's m_edges[!way][throughp]. void notifyEdgeCp(V3GraphVertex* vxp, GraphWay way, V3GraphVertex* throuvhVxp, uint32_t cp) const { - LogicMTask* updateVxp = dynamic_cast(vxp); - LogicMTask* lthrouvhVxp = dynamic_cast(throuvhVxp); + LogicMTask* const updateVxp = dynamic_cast(vxp); + LogicMTask* const lthrouvhVxp = dynamic_cast(throuvhVxp); EdgeSet& edges = updateVxp->m_edges[way.invert()]; - uint32_t edgeCp = edges.at(lthrouvhVxp); + const uint32_t edgeCp = edges.at(lthrouvhVxp); if (cp > edgeCp) edges.set(lthrouvhVxp, cp); } // Check that CP matches that of the longest edge wayward of vxp. void checkNewCpVersusEdges(V3GraphVertex* vxp, GraphWay way, uint32_t cp) const { - LogicMTask* mtaskp = dynamic_cast(vxp); + LogicMTask* const mtaskp = dynamic_cast(vxp); EdgeSet& edges = mtaskp->m_edges[way.invert()]; // This is mtaskp's relative with longest !wayward inclusive CP: const auto edgeIt = edges.rbegin(); - uint32_t edgeCp = (*edgeIt).value(); + const uint32_t edgeCp = (*edgeIt).value(); UASSERT_OBJ(edgeCp == cp, vxp, "CP doesn't match longest wayward edge"); } @@ -455,7 +455,7 @@ public: for (unsigned int& i : m_critPathCost) i = 0; if (mtmvVxp) { // Else null for test m_vertices.push_back(mtmvVxp); - if (OrderLogicVertex* olvp = mtmvVxp->logicp()) { + if (OrderLogicVertex* const olvp = mtmvVxp->logicp()) { m_cost += V3InstrCount::count(olvp->nodep(), true); } } @@ -502,7 +502,7 @@ public: logcost = ceil(logcost); logcost = logcost / 20.0; - uint32_t stepCost = static_cast(exp(logcost)); + const uint32_t stepCost = static_cast(exp(logcost)); UASSERT_STATIC(stepCost >= cost, "stepped cost error exceeded"); UASSERT_STATIC(stepCost <= ((cost * 11 / 10)), "stepped cost error exceeded"); return stepCost; @@ -528,8 +528,8 @@ public: void checkRelativesCp(GraphWay way) const { const EdgeSet& edges = m_edges[way]; for (EdgeSet::const_reverse_iterator it = edges.rbegin(); it != edges.rend(); ++it) { - LogicMTask* relativep = (*it).key(); - uint32_t cachedCp = (*it).value(); + LogicMTask* const relativep = (*it).key(); + const uint32_t cachedCp = (*it).value(); partCheckCachedScoreVsActual(cachedCp, relativep->critPathCost(way.invert()) + relativep->stepCost()); } @@ -603,7 +603,7 @@ private: for (const V3GraphEdge* followp = fromp->outBeginp(); followp; followp = followp->outNextp()) { if (followp == excludedEdgep) continue; - LogicMTask* nextp = dynamic_cast(followp->top()); + LogicMTask* const nextp = dynamic_cast(followp->top()); if (pathExistsFromInternal(nextp, top, nullptr, generation)) return true; } return false; @@ -634,7 +634,7 @@ public: const LogicMTask* startp = nullptr; for (const V3GraphVertex* vxp = graphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - const LogicMTask* mtaskp = dynamic_cast(vxp); + const LogicMTask* const mtaskp = dynamic_cast(vxp); if (!startp) { startp = mtaskp; continue; @@ -669,7 +669,7 @@ public: *osp << "begin mtask with cost " << mtaskp->cost() << '\n'; for (VxList::const_iterator lit = mtaskp->vertexListp()->begin(); lit != mtaskp->vertexListp()->end(); ++lit) { - const OrderLogicVertex* logicp = (*lit)->logicp(); + const OrderLogicVertex* const logicp = (*lit)->logicp(); if (!logicp) continue; if (false) { // Show nodes only @@ -781,7 +781,7 @@ public: } static MTaskEdge* cast(V3GraphEdge* edgep) { if (!edgep) return nullptr; - MTaskEdge* resultp = dynamic_cast(edgep); + MTaskEdge* const resultp = dynamic_cast(edgep); UASSERT(resultp, "Failed to cast in MTaskEdge::cast"); return resultp; } @@ -789,8 +789,8 @@ public: // out of the edge-map for each node and reinsert at a new location // with updated critical path. void resetCriticalPaths() { - LogicMTask* fromp = fromMTaskp(); - LogicMTask* top = toMTaskp(); + LogicMTask* const fromp = fromMTaskp(); + LogicMTask* const top = toMTaskp(); fromp->removeRelative(GraphWay::FORWARD, top); top->removeRelative(GraphWay::REVERSE, fromp); fromp->addRelative(GraphWay::FORWARD, top); @@ -809,8 +809,8 @@ class OrderByPtrId final { public: virtual bool operator()(const OrderVarStdVertex* lhsp, const OrderVarStdVertex* rhsp) const { - vluint64_t l_id = m_ids.findId(lhsp); - vluint64_t r_id = m_ids.findId(rhsp); + const vluint64_t l_id = m_ids.findId(lhsp); + const vluint64_t r_id = m_ids.findId(rhsp); return l_id < r_id; } }; @@ -905,8 +905,8 @@ static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool check GraphStreamUnordered order(mtasksp, way); const GraphWay rev = way.invert(); for (const V3GraphVertex* vertexp; (vertexp = order.nextp());) { - const LogicMTask* mtaskcp = dynamic_cast(vertexp); - LogicMTask* mtaskp = const_cast(mtaskcp); + const LogicMTask* const mtaskcp = dynamic_cast(vertexp); + LogicMTask* const mtaskp = const_cast(mtaskcp); uint32_t cpCost = 0; std::unordered_set relatives; for (V3GraphEdge* edgep = vertexp->beginp(rev); edgep; edgep = edgep->nextp(rev)) { @@ -917,7 +917,7 @@ static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool check "Should be no redundant edges in mtasks graph"); relatives.insert(edgep->furtherp(rev)); - LogicMTask* relativep = dynamic_cast(edgep->furtherp(rev)); + LogicMTask* const relativep = dynamic_cast(edgep->furtherp(rev)); cpCost = std::max(cpCost, (relativep->critPathCost(way) + static_cast(relativep->stepCost()))); } @@ -938,7 +938,7 @@ static void partInitCriticalPaths(V3Graph* mtasksp) { // They would have been all zeroes on initial creation of the MTaskEdges. for (V3GraphVertex* vxp = mtasksp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { for (V3GraphEdge* edgep = vxp->outBeginp(); edgep; edgep = edgep->outNextp()) { - MTaskEdge* mtedgep = dynamic_cast(edgep); + MTaskEdge* const mtedgep = dynamic_cast(edgep); mtedgep->resetCriticalPaths(); } } @@ -950,7 +950,7 @@ static void partCheckCriticalPaths(V3Graph* mtasksp) { partInitHalfCriticalPaths(GraphWay::FORWARD, mtasksp, true); partInitHalfCriticalPaths(GraphWay::REVERSE, mtasksp, true); for (V3GraphVertex* vxp = mtasksp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - LogicMTask* mtaskp = dynamic_cast(vxp); + LogicMTask* const mtaskp = dynamic_cast(vxp); mtaskp->checkRelativesCp(GraphWay::FORWARD); mtaskp->checkRelativesCp(GraphWay::REVERSE); } @@ -958,7 +958,7 @@ static void partCheckCriticalPaths(V3Graph* mtasksp) { // Advance to nextp(way) and delete edge static V3GraphEdge* partBlastEdgep(GraphWay way, V3GraphEdge* edgep) { - V3GraphEdge* nextp = edgep->nextp(way); + V3GraphEdge* const nextp = edgep->nextp(way); VL_DO_DANGLING(edgep->unlinkDelete(), edgep); return nextp; } @@ -1000,12 +1000,12 @@ static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMT V3Scoreboard* sbp) { for (const auto& way : {GraphWay::FORWARD, GraphWay::REVERSE}) { for (V3GraphEdge* edgep = donorp->beginp(way); edgep; edgep = partBlastEdgep(way, edgep)) { - MTaskEdge* tedgep = MTaskEdge::cast(edgep); + MTaskEdge* const tedgep = MTaskEdge::cast(edgep); if (sbp && !tedgep->removedFromSb()) sbp->removeElem(tedgep); // Existing edge; mark it in need of a rescore if (recipientp->hasRelative(way, tedgep->furtherMTaskp(way))) { if (sbp) { - MTaskEdge* existMTaskEdgep = MTaskEdge::cast( + MTaskEdge* const existMTaskEdgep = MTaskEdge::cast( recipientp->findConnectingEdgep(way, tedgep->furtherMTaskp(way))); UASSERT(existMTaskEdgep, "findConnectingEdge didn't find edge"); if (!existMTaskEdgep->removedFromSb()) { @@ -1104,7 +1104,7 @@ public: while (true) { // This is the best edge to merge, with the lowest // score (shortest local critical path) - MergeCandidate* mergeCanp = const_cast(m_sb.bestp()); + MergeCandidate* const mergeCanp = const_cast(m_sb.bestp()); if (!mergeCanp) { // Scoreboard found no eligible merges. Maybe a rescore // will produce some merge-able pairs? @@ -1119,8 +1119,8 @@ public: UASSERT(!m_sb.needsRescore(mergeCanp), "Need-rescore items should not be returned by bestp"); } - uint32_t cachedScore = m_sb.cachedScore(mergeCanp); - uint32_t actualScore = mergeCandidateScore(mergeCanp); + const uint32_t cachedScore = m_sb.cachedScore(mergeCanp); + const uint32_t actualScore = mergeCandidateScore(mergeCanp); if (actualScore > cachedScore) { // Cached score is out-of-date. @@ -1232,8 +1232,9 @@ private: newCp = std::max(otherp->critPathCost(way), mtaskp->critPathCost(way)); } - uint32_t origRelativesCp = mtaskp->critPathCost(way) + mtaskp->stepCost(); - uint32_t newRelativesCp = newCp + LogicMTask::stepCost(mtaskp->cost() + otherp->cost()); + const uint32_t origRelativesCp = mtaskp->critPathCost(way) + mtaskp->stepCost(); + const uint32_t newRelativesCp + = newCp + LogicMTask::stepCost(mtaskp->cost() + otherp->cost()); NewCp result; result.cp = newCp; @@ -1245,9 +1246,9 @@ private: void removeSiblingMCsWith(LogicMTask* mtaskp) { for (SibpSet::iterator it = m_mtask2sibs[mtaskp].begin(); it != m_mtask2sibs[mtaskp].end(); ++it) { - const SiblingMC* pairp = *it; + const SiblingMC* const pairp = *it; if (!pairp->removedFromSb()) m_sb.removeElem(pairp); - LogicMTask* otherp = (pairp->bp() == mtaskp) ? pairp->ap() : pairp->bp(); + LogicMTask* const otherp = (pairp->bp() == mtaskp) ? pairp->ap() : pairp->bp(); size_t erased = m_mtask2sibs[otherp].erase(pairp); UASSERT_OBJ(erased > 0, otherp, "Expected existing mtask"); erased = m_pairs.erase(*pairp); @@ -1374,14 +1375,14 @@ private: siblingPairFromRelatives(GraphWay::FORWARD, recipientp, true); unsigned edges = 0; for (V3GraphEdge* edgep = recipientp->outBeginp(); edgep; edgep = edgep->outNextp()) { - LogicMTask* postreqp = dynamic_cast(edgep->top()); + LogicMTask* const postreqp = dynamic_cast(edgep->top()); siblingPairFromRelatives(GraphWay::REVERSE, postreqp, false); edges++; if (edges > PART_SIBLING_EDGE_LIMIT) break; } edges = 0; for (V3GraphEdge* edgep = recipientp->inBeginp(); edgep; edgep = edgep->inNextp()) { - LogicMTask* prereqp = dynamic_cast(edgep->fromp()); + LogicMTask* const prereqp = dynamic_cast(edgep->fromp()); siblingPairFromRelatives(GraphWay::FORWARD, prereqp, false); edges++; if (edges > PART_SIBLING_EDGE_LIMIT) break; @@ -1416,11 +1417,11 @@ private: } static uint32_t siblingScore(const SiblingMC* sibsp) { - LogicMTask* ap = sibsp->ap(); - LogicMTask* bp = sibsp->bp(); - uint32_t mergedCpCostFwd + const LogicMTask* const ap = sibsp->ap(); + const LogicMTask* const bp = sibsp->bp(); + const uint32_t mergedCpCostFwd = std::max(ap->critPathCost(GraphWay::FORWARD), bp->critPathCost(GraphWay::FORWARD)); - uint32_t mergedCpCostRev + const uint32_t mergedCpCostRev = std::max(ap->critPathCost(GraphWay::REVERSE), bp->critPathCost(GraphWay::REVERSE)); return mergedCpCostRev + mergedCpCostFwd + LogicMTask::stepCost(ap->cost() + bp->cost()); } @@ -1429,12 +1430,14 @@ private: // Score this edge. Lower is better. The score is the new local CP // length if we merge these mtasks. ("Local" means the longest // critical path running through the merged node.) - LogicMTask* top = dynamic_cast(edgep->top()); - LogicMTask* fromp = dynamic_cast(edgep->fromp()); - uint32_t mergedCpCostFwd = std::max(fromp->critPathCost(GraphWay::FORWARD), - top->critPathCostWithout(GraphWay::FORWARD, edgep)); - uint32_t mergedCpCostRev = std::max(fromp->critPathCostWithout(GraphWay::REVERSE, edgep), - top->critPathCost(GraphWay::REVERSE)); + LogicMTask* const top = dynamic_cast(edgep->top()); + LogicMTask* const fromp = dynamic_cast(edgep->fromp()); + const uint32_t mergedCpCostFwd + = std::max(fromp->critPathCost(GraphWay::FORWARD), + top->critPathCostWithout(GraphWay::FORWARD, edgep)); + const uint32_t mergedCpCostRev + = std::max(fromp->critPathCostWithout(GraphWay::REVERSE, edgep), + top->critPathCost(GraphWay::REVERSE)); return mergedCpCostRev + mergedCpCostFwd + LogicMTask::stepCost(fromp->cost() + top->cost()); } @@ -1443,7 +1446,7 @@ private: SiblingMC newSibs(ap, bp); std::pair insertResult = m_pairs.insert(newSibs); if (insertResult.second) { - const SiblingMC* newSibsp = &(*insertResult.first); + const SiblingMC* const newSibsp = &(*insertResult.first); m_mtask2sibs[ap].insert(newSibsp); m_mtask2sibs[bp].insert(newSibsp); m_sb.addElem(newSibsp); @@ -1455,7 +1458,7 @@ private: bool found = false; for (SibpSet::iterator it = m_mtask2sibs[ap].begin(); it != m_mtask2sibs[ap].end(); ++it) { - const SiblingMC* sibsp = *it; + const SiblingMC* const sibsp = *it; UASSERT_OBJ(!(!sibsp->removedFromSb() && !m_sb.contains(sibsp)), ap, "One sibling must be the one we collided with"); if ((sibsp->ap() == ap && sibsp->bp() == bp) @@ -1468,11 +1471,11 @@ private: static const GraphWay* s_shortestWaywardCpInclusiveWay; static int shortestWaywardCpInclusive(const void* vap, const void* vbp) { - const GraphWay* wp = s_shortestWaywardCpInclusiveWay; - const LogicMTask* ap = *reinterpret_cast(vap); - const LogicMTask* bp = *reinterpret_cast(vbp); - uint32_t aCp = ap->critPathCost(*wp) + ap->stepCost(); - uint32_t bCp = bp->critPathCost(*wp) + bp->stepCost(); + const GraphWay* const wp = s_shortestWaywardCpInclusiveWay; + const LogicMTask* const ap = *reinterpret_cast(vap); + const LogicMTask* const bp = *reinterpret_cast(vbp); + const uint32_t aCp = ap->critPathCost(*wp) + ap->stepCost(); + const uint32_t bCp = bp->critPathCost(*wp) + bp->stepCost(); if (aCp < bCp) return -1; if (aCp > bCp) return 1; if (ap->id() < bp->id()) return -1; @@ -1484,7 +1487,7 @@ private: std::vector shortestPrereqs; for (V3GraphEdge* edgep = mtaskp->beginp(way); edgep; edgep = edgep->nextp(way)) { - LogicMTask* prereqp = dynamic_cast(edgep->furtherp(way)); + LogicMTask* const prereqp = dynamic_cast(edgep->furtherp(way)); shortestPrereqs.push_back(prereqp); // Prevent nodes with huge numbers of edges from massively // slowing down the partitioner: @@ -1503,9 +1506,9 @@ private: auto it = shortestPrereqs.cbegin(); for (unsigned i = 0; exhaustive || (i < 3); ++i) { if (it == shortestPrereqs.cend()) break; - LogicMTask* ap = *(it++); + LogicMTask* const ap = *(it++); if (it == shortestPrereqs.cend()) break; - LogicMTask* bp = *(it++); + LogicMTask* const bp = *(it++); makeSiblingMC(ap, bp); } } @@ -1517,8 +1520,8 @@ private: // runtime should be N*log(N) for a chain-shaped graph. // static void selfTestChain() { - vluint64_t usecsSmall = partitionChainUsecs(5); - vluint64_t usecsLarge = partitionChainUsecs(500); + const vluint64_t usecsSmall = partitionChainUsecs(5); + const vluint64_t usecsLarge = partitionChainUsecs(500); // Large input is 50x bigger than small input. // Its runtime should be about 10x longer -- not about 2500x longer // or worse which would suggest N^2 scaling or worse. @@ -1533,7 +1536,7 @@ private: V3Graph mtasks; LogicMTask* lastp = nullptr; for (unsigned i = 0; i < chain_len; ++i) { - LogicMTask* mtp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const mtp = new LogicMTask(&mtasks, nullptr); mtp->setCost(1); if (lastp) new MTaskEdge(&mtasks, lastp, mtp, 1); lastp = mtp; @@ -1551,8 +1554,8 @@ private: PartParallelismEst check(&mtasks); check.traverse(); - vluint64_t endUsecs = V3Os::timeUsecs(); - vluint64_t elapsedUsecs = endUsecs - startUsecs; + const vluint64_t endUsecs = V3Os::timeUsecs(); + const vluint64_t elapsedUsecs = endUsecs - startUsecs; if (debug() >= 6) { UINFO(0, "Chain self test stats:\n"); @@ -1582,20 +1585,20 @@ private: static void selfTestX() { // NOTE: To get a dot file run with --debugi-V3Partition 4 or more. V3Graph mtasks; - LogicMTask* center = new LogicMTask(&mtasks, nullptr); - center->setCost(1); + LogicMTask* const centerp = new LogicMTask(&mtasks, nullptr); + centerp->setCost(1); unsigned i; for (i = 0; i < 50; ++i) { - LogicMTask* mtp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const mtp = new LogicMTask(&mtasks, nullptr); mtp->setCost(1); - // Edge from every input -> center - new MTaskEdge(&mtasks, mtp, center, 1); + // Edge from every input -> centerp + new MTaskEdge(&mtasks, mtp, centerp, 1); } for (i = 0; i < 50; ++i) { - LogicMTask* mtp = new LogicMTask(&mtasks, nullptr); + LogicMTask* const mtp = new LogicMTask(&mtasks, nullptr); mtp->setCost(1); - // Edge from center -> every output - new MTaskEdge(&mtasks, center, mtp, 1); + // Edge from centerp -> every output + new MTaskEdge(&mtasks, centerp, mtp, 1); } partInitCriticalPaths(&mtasks); @@ -1776,18 +1779,18 @@ private: void findAdjacentTasks(OvvSet::iterator ovvIt, TasksByRank* tasksByRankp) { // Find all writer tasks for this variable, group by rank. for (V3GraphEdge* edgep = (*ovvIt)->inBeginp(); edgep; edgep = edgep->inNextp()) { - OrderLogicVertex* logicp = dynamic_cast(edgep->fromp()); + OrderLogicVertex* const logicp = dynamic_cast(edgep->fromp()); if (!logicp) continue; if (logicp->domainp()->hasInitial() || logicp->domainp()->hasSettle()) continue; - LogicMTask* writerMtaskp = m_olv2mtask.at(logicp); + LogicMTask* const writerMtaskp = m_olv2mtask.at(logicp); (*tasksByRankp)[writerMtaskp->rank()].insert(writerMtaskp); } // Find all reader tasks for this variable, group by rank. for (V3GraphEdge* edgep = (*ovvIt)->outBeginp(); edgep; edgep = edgep->outNextp()) { - OrderLogicVertex* logicp = dynamic_cast(edgep->fromp()); + OrderLogicVertex* const logicp = dynamic_cast(edgep->fromp()); if (!logicp) continue; if (logicp->domainp()->hasInitial() || logicp->domainp()->hasSettle()) continue; - LogicMTask* readerMtaskp = m_olv2mtask.at(logicp); + LogicMTask* const readerMtaskp = m_olv2mtask.at(logicp); (*tasksByRankp)[readerMtaskp->rank()].insert(readerMtaskp); } } @@ -1801,7 +1804,7 @@ private: LogicMTask* mergedp = nullptr; for (LogicMTaskSet::iterator it = rankIt->second.begin(); it != rankIt->second.end(); ++it) { - LogicMTask* mtaskp = *it; + LogicMTask* const mtaskp = *it; if (mergedp) { if (mergedp->cost() < mtaskp->cost()) mergedp = mtaskp; } else { @@ -1812,15 +1815,15 @@ private: while (!rankIt->second.empty()) { const auto begin = rankIt->second.cbegin(); - LogicMTask* donorp = *begin; + LogicMTask* const donorp = *begin; UASSERT_OBJ(donorp != mergedp, donorp, "Donor can't be merged edge"); rankIt->second.erase(begin); // Merge donorp into mergedp. // Fix up the map, so donor's OLVs map to mergedp for (LogicMTask::VxList::const_iterator tmvit = donorp->vertexListp()->begin(); tmvit != donorp->vertexListp()->end(); ++tmvit) { - MTaskMoveVertex* tmvp = *tmvit; - OrderLogicVertex* logicp = tmvp->logicp(); + MTaskMoveVertex* const tmvp = *tmvit; + OrderLogicVertex* const logicp = tmvp->logicp(); if (logicp) m_olv2mtask[logicp] = mergedp; } // Move all vertices from donorp to mergedp @@ -1846,7 +1849,7 @@ private: for (LogicMTask::VxList::const_iterator it = mtaskp->vertexListp()->begin(); it != mtaskp->vertexListp()->end(); ++it) { if (!(*it)->logicp()) continue; - AstNode* nodep = (*it)->logicp()->nodep(); + AstNode* const nodep = (*it)->logicp()->nodep(); // NOTE: We don't handle DPI exports. If testbench code calls a // DPI-exported function at any time during eval() we may have // a data hazard. (Likewise in non-threaded mode if an export @@ -1874,20 +1877,21 @@ public: OvvSet ovvSetSystemC(ovvOrder); for (V3GraphVertex* vxp = m_mtasksp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - LogicMTask* mtaskp = dynamic_cast(vxp); + LogicMTask* const mtaskp = dynamic_cast(vxp); // Should be only one MTaskMoveVertex in each mtask at this // stage, but whatever, write it as a loop: for (LogicMTask::VxList::const_iterator it = mtaskp->vertexListp()->begin(); it != mtaskp->vertexListp()->end(); ++it) { - MTaskMoveVertex* tmvp = *it; - if (OrderLogicVertex* logicp = tmvp->logicp()) { + MTaskMoveVertex* const tmvp = *it; + if (OrderLogicVertex* const logicp = tmvp->logicp()) { m_olv2mtask[logicp] = mtaskp; // Look at downstream vars. for (V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) { // Only consider OrderVarStdVertex which reflects // an actual lvalue assignment; the others do not. - OrderVarStdVertex* ovvp = dynamic_cast(edgep->top()); + OrderVarStdVertex* const ovvp + = dynamic_cast(edgep->top()); if (!ovvp) continue; if (ovvp->varScp()->varp()->isSc()) { ovvSetSystemC.insert(ovvp); @@ -1983,7 +1987,7 @@ public: TasksByRank tasksByRank; for (V3GraphVertex* vxp = m_mtasksp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - LogicMTask* mtaskp = dynamic_cast(vxp); + LogicMTask* const mtaskp = dynamic_cast(vxp); if (hasDpiHazard(mtaskp)) tasksByRank[vxp->rank()].insert(mtaskp); } mergeSameRankTasks(&tasksByRank); @@ -2103,7 +2107,7 @@ void ThreadSchedule::dumpDotFile(const string& filename) const { // Find minimum cost MTask for scaling MTask node widths uint32_t minCost = UINT32_MAX; for (const V3GraphVertex* vxp = depGraph->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - if (const ExecMTask* mtaskp = dynamic_cast(vxp)) { + if (const ExecMTask* const mtaskp = dynamic_cast(vxp)) { minCost = minCost > mtaskp->cost() ? mtaskp->cost() : minCost; } } @@ -2126,15 +2130,15 @@ void ThreadSchedule::dumpDotFile(const string& filename) const { // Emit MTasks for (const V3GraphVertex* vxp = depGraph->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - if (const ExecMTask* mtaskp = dynamic_cast(vxp)) { emitMTask(mtaskp); } + if (const ExecMTask* const mtaskp = dynamic_cast(vxp)) emitMTask(mtaskp); } // Emit MTask dependency edges *logp << "\n // MTask dependencies\n"; for (const V3GraphVertex* vxp = depGraph->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - if (const ExecMTask* mtaskp = dynamic_cast(vxp)) { + if (const ExecMTask* const mtaskp = dynamic_cast(vxp)) { for (V3GraphEdge* edgep = mtaskp->outBeginp(); edgep; edgep = edgep->outNextp()) { - const V3GraphVertex* top = edgep->top(); + const V3GraphVertex* const top = edgep->top(); *logp << " " << vxp->name() << " -> " << top->name() << "\n"; } } @@ -2452,7 +2456,7 @@ void V3Partition::hashGraphDebug(const V3Graph* graphp, const char* debugName) { unsigned hash = 0; for (const V3GraphVertex* vxp = graphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { for (const V3GraphEdge* edgep = vxp->outBeginp(); edgep; edgep = edgep->outNextp()) { - const V3GraphVertex* top = edgep->top(); + const V3GraphVertex* const top = edgep->top(); hash = vx2Id[top] + 31U * hash; // The K&R hash function } } @@ -2462,7 +2466,7 @@ void V3Partition::hashGraphDebug(const V3Graph* graphp, const char* debugName) { void V3Partition::setupMTaskDeps(V3Graph* mtasksp, const Vx2MTaskMap* vx2mtaskp) { // Look at each mtask for (V3GraphVertex* itp = mtasksp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - LogicMTask* mtaskp = dynamic_cast(itp); + LogicMTask* const mtaskp = dynamic_cast(itp); const LogicMTask::VxList* vertexListp = mtaskp->vertexListp(); // For each logic vertex in this mtask, create an mtask-to-mtask @@ -2471,11 +2475,11 @@ void V3Partition::setupMTaskDeps(V3Graph* mtasksp, const Vx2MTaskMap* vx2mtaskp) vit != vertexListp->end(); ++vit) { for (V3GraphEdge* outp = (*vit)->outBeginp(); outp; outp = outp->outNextp()) { UASSERT(outp->weight() > 0, "Mtask not assigned weight"); - const MTaskMoveVertex* top = dynamic_cast(outp->top()); + const MTaskMoveVertex* const top = dynamic_cast(outp->top()); UASSERT(top, "MoveVertex not associated to mtask"); const auto it = vlstd::as_const(vx2mtaskp)->find(top); UASSERT(it != vx2mtaskp->end(), "MTask map can't find id"); - LogicMTask* otherMTaskp = it->second; + LogicMTask* const otherMTaskp = it->second; UASSERT(otherMTaskp, "nullptr other Mtask"); UASSERT_OBJ(otherMTaskp != mtaskp, mtaskp, "Would create a cycle edge"); @@ -2505,10 +2509,10 @@ void V3Partition::go(V3Graph* mtasksp) { Vx2MTaskMap vx2mtask; for (V3GraphVertex* vxp = m_fineDepsGraphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - MTaskMoveVertex* mtmvVxp = dynamic_cast(vxp); + MTaskMoveVertex* const mtmvVxp = dynamic_cast(vxp); UASSERT_OBJ(mtmvVxp, vxp, "Every vertex here should be an MTaskMoveVertex"); - LogicMTask* mtaskp = new LogicMTask(mtasksp, mtmvVxp); + LogicMTask* const mtaskp = new LogicMTask(mtasksp, mtmvVxp); vx2mtask[mtmvVxp] = mtaskp; totalGraphCost += mtaskp->cost(); @@ -2591,7 +2595,7 @@ void V3Partition::go(V3Graph* mtasksp) { using SortedMTaskSet = std::set; SortedMTaskSet sorted; for (V3GraphVertex* itp = mtasksp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - LogicMTask* mtaskp = dynamic_cast(itp); + LogicMTask* const mtaskp = dynamic_cast(itp); sorted.insert(mtaskp); } uint32_t nextId = 1; @@ -2602,16 +2606,16 @@ void V3Partition::go(V3Graph* mtasksp) { UASSERT(nextId <= (*it)->id(), "Should only shrink MTaskIDs here"); UINFO(4, "Reassigning MTask id " << (*it)->id() << " to id " << nextId << "\n"); (*it)->id(nextId); - nextId++; + ++nextId; } } // Set color to indicate an mtaskId on every underlying MTaskMoveVertex. for (V3GraphVertex* itp = mtasksp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - LogicMTask* mtaskp = dynamic_cast(itp); + LogicMTask* const mtaskp = dynamic_cast(itp); for (LogicMTask::VxList::const_iterator it = mtaskp->vertexListp()->begin(); it != mtaskp->vertexListp()->end(); ++it) { - MTaskMoveVertex* mvertexp = *it; + MTaskMoveVertex* const mvertexp = *it; mvertexp->color(mtaskp->id()); } } @@ -2643,7 +2647,7 @@ static void normalizeCosts(Costs& costs) { // For data where we don't have profiled data, compute how much to // scale up/down the estimate to make on same relative scale as // profiled data. (Improves results if only a few profiles missing.) - double estToProfile + const double estToProfile = static_cast(sumCostProfiled) / static_cast(sumCostEstimate); UINFO(5, "Estimated data needs scaling by " << estToProfile << ", sumCostProfiled=" << sumCostProfiled @@ -2713,13 +2717,14 @@ static void fillinCosts(V3Graph* execMTaskGraphp) { for (const V3GraphVertex* vxp = execMTaskGraphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - ExecMTask* mtp = dynamic_cast(const_cast(vxp)); + ExecMTask* const mtp = dynamic_cast(const_cast(vxp)); // Compute name of mtask, for hash lookup mtp->hashName(m_uniqueNames.get(mtp->bodyp())); // This estimate is 64 bits, but the final mtask graph algorithm needs 32 bits - vluint64_t costEstimate = V3InstrCount::count(mtp->bodyp(), false); - vluint64_t costProfiled = V3Config::getProfileData(v3Global.opt.prefix(), mtp->hashName()); + const vluint64_t costEstimate = V3InstrCount::count(mtp->bodyp(), false); + const vluint64_t costProfiled + = V3Config::getProfileData(v3Global.opt.prefix(), mtp->hashName()); if (costProfiled) { UINFO(5, "Profile data for mtask " << mtp->id() << " " << mtp->hashName() << " cost override " << costProfiled << endl); @@ -2733,7 +2738,7 @@ static void fillinCosts(V3Graph* execMTaskGraphp) { int missingProfiles = 0; for (const V3GraphVertex* vxp = execMTaskGraphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - ExecMTask* mtp = dynamic_cast(const_cast(vxp)); + ExecMTask* const mtp = dynamic_cast(const_cast(vxp)); const uint32_t costEstimate = costs[mtp->id()].first; const uint64_t costProfiled = costs[mtp->id()].second; UINFO(9, "ce = " << costEstimate << " cp=" << costProfiled << endl); @@ -2751,7 +2756,7 @@ static void fillinCosts(V3Graph* execMTaskGraphp) { } if (missingProfiles) { - if (FileLine* fl = V3Config::getProfileDataFileLine()) { + if (FileLine* const fl = V3Config::getProfileDataFileLine()) { fl->v3warn(PROFOUTOFDATE, "Profile data for mtasks may be out of date. " << missingProfiles << " of " << totalEstimates << " mtasks had no data"); @@ -2762,14 +2767,14 @@ static void fillinCosts(V3Graph* execMTaskGraphp) { static void finalizeCosts(V3Graph* execMTaskGraphp) { GraphStreamUnordered ser(execMTaskGraphp, GraphWay::REVERSE); while (const V3GraphVertex* vxp = ser.nextp()) { - ExecMTask* mtp = dynamic_cast(const_cast(vxp)); + ExecMTask* const mtp = dynamic_cast(const_cast(vxp)); // "Priority" is the critical path from the start of the mtask, to // the end of the graph reachable from this mtask. Given the // choice among several ready mtasks, we'll want to start the // highest priority one first, so we're always working on the "long // pole" for (V3GraphEdge* edgep = mtp->outBeginp(); edgep; edgep = edgep->outNextp()) { - ExecMTask* followp = dynamic_cast(edgep->top()); + ExecMTask* const followp = dynamic_cast(edgep->top()); if ((followp->priority() + mtp->cost()) > mtp->priority()) { mtp->priority(followp->priority() + mtp->cost()); } @@ -2780,13 +2785,13 @@ static void finalizeCosts(V3Graph* execMTaskGraphp) { // (It's common for tasks to shrink to nothing when V3LifePost // removes dly assignments.) for (V3GraphVertex* vxp = execMTaskGraphp->verticesBeginp(); vxp;) { - ExecMTask* mtp = dynamic_cast(vxp); + ExecMTask* const mtp = dynamic_cast(vxp); vxp = vxp->verticesNextp(); // Advance before delete // Don't rely on checking mtp->cost() == 0 to detect an empty task. // Our cost-estimating logic is just an estimate. Instead, check // the MTaskBody to see if it's empty. That's the source of truth. - AstMTaskBody* bodyp = mtp->bodyp(); + AstMTaskBody* const bodyp = mtp->bodyp(); if (!bodyp->stmtsp()) { // Kill this empty mtask UINFO(6, "Removing zero-cost " << mtp->name() << endl); for (V3GraphEdge* inp = mtp->inBeginp(); inp; inp = inp->inNextp()) { @@ -2805,7 +2810,7 @@ static void finalizeCosts(V3Graph* execMTaskGraphp) { vluint64_t profilerId = 0; for (const V3GraphVertex* vxp = execMTaskGraphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - ExecMTask* mtp = dynamic_cast(const_cast(vxp)); + ExecMTask* const mtp = dynamic_cast(const_cast(vxp)); mtp->profilerId(profilerId++); } diff --git a/src/V3Scoreboard.h b/src/V3Scoreboard.h index e4ac0761b..bfd267c85 100644 --- a/src/V3Scoreboard.h +++ b/src/V3Scoreboard.h @@ -252,7 +252,7 @@ public: return iterator(valIt, keyIt, this); } const_iterator begin() const { - SortByValueMap* mutp = const_cast(this); + SortByValueMap* const mutp = const_cast(this); const auto valIt = mutp->m_vals.begin(); if (valIt == mutp->m_vals.end()) return end(); const auto keyIt = valIt->second.begin(); @@ -278,7 +278,7 @@ public: return iterator(valIt, keyIt, this); } const_iterator find(const T_Key& k) const { - SortByValueMap* mutp = const_cast(this); + SortByValueMap* const mutp = const_cast(this); const auto kvit = mutp->m_keys.find(k); if (kvit == mutp->m_keys.end()) return end(); From c1d7bfa6173a03e1c92e99844eeacbb565f45539 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 3 Nov 2021 19:19:23 -0400 Subject: [PATCH 21/79] Internals: Skip some asserts in fastpath partitioning. --- src/V3Partition.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index fc6d8d999..d7290319a 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -714,6 +714,7 @@ public: ++serial; m_id = serial; } + virtual ~MergeCandidate() = default; virtual bool mergeWouldCreateCycle() const = 0; // METHODS bool removedFromSb() const { return m_removedFromSb; } @@ -908,15 +909,18 @@ static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool check const LogicMTask* const mtaskcp = dynamic_cast(vertexp); LogicMTask* const mtaskp = const_cast(mtaskcp); uint32_t cpCost = 0; +#if VL_DEBUG std::unordered_set relatives; +#endif for (V3GraphEdge* edgep = vertexp->beginp(rev); edgep; edgep = edgep->nextp(rev)) { +#if VL_DEBUG // Run a few asserts on the initial mtask graph, // while we're iterating through... UASSERT_OBJ(edgep->weight() != 0, mtaskp, "Should be no cut edges in mtasks graph"); UASSERT_OBJ(relatives.find(edgep->furtherp(rev)) == relatives.end(), mtaskp, "Should be no redundant edges in mtasks graph"); relatives.insert(edgep->furtherp(rev)); - +#endif LogicMTask* const relativep = dynamic_cast(edgep->furtherp(rev)); cpCost = std::max(cpCost, (relativep->critPathCost(way) + static_cast(relativep->stepCost()))); @@ -1091,8 +1095,10 @@ public: std::unordered_set neighbors; for (V3GraphEdge* edgep = itp->outBeginp(); edgep; edgep = edgep->outNextp()) { m_sb.addElem(MTaskEdge::cast(edgep)); - UASSERT_OBJ(neighbors.find(edgep->top()) == neighbors.end(), itp, - "Redundant edge found in input to PartContraction()"); + if (m_slowAsserts) { + UASSERT_OBJ(neighbors.find(edgep->top()) == neighbors.end(), itp, + "Redundant edge found in input to PartContraction()"); + } neighbors.insert(edgep->top()); } siblingPairFromRelatives(GraphWay::REVERSE, itp, true); @@ -1403,15 +1409,15 @@ private: } static uint32_t mergeCandidateScore(const MergeCandidate* pairp) { - const MTaskEdge* edgep = dynamic_cast(pairp); - if (edgep) { + if (const MTaskEdge* const edgep = dynamic_cast(pairp)) { // The '1 +' favors merging a SiblingMC over an otherwise- // equal-scoring MTaskEdge. The comment on selfTest() talks // about why. return 1 + edgeScore(edgep); } - const SiblingMC* sibsp = dynamic_cast(pairp); - if (sibsp) return siblingScore(sibsp); + if (const SiblingMC* const sibsp = dynamic_cast(pairp)) { + return siblingScore(sibsp); + } v3fatalSrc("Failed to cast pairp to either MTaskEdge or SiblingMC in mergeCandidateScore"); return 0; } From da5644211fe0f2a52220075337596a4489a34334 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 3 Nov 2021 22:01:27 -0400 Subject: [PATCH 22/79] Improve memory usage of V3Partition. Only performance change intended. --- src/V3Partition.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index d7290319a..5d67b2fb0 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -705,8 +705,11 @@ public: // Information associated with scoreboarding an MTask class MergeCandidate VL_NOT_FINAL { private: - bool m_removedFromSb = false; // Not on scoreboard, generally ignore - vluint64_t m_id; // Serial number for ordering + // This structure is extremely hot. To save 8 bytes we pack + // one bit indicating removedFromSb with the id. + vluint64_t m_id; // <63> removed, <62:0> Serial number for ordering + static constexpr vluint64_t REMOVED_MASK = 1ULL << 63; + public: // CONSTRUCTORS MergeCandidate() { @@ -717,9 +720,11 @@ public: virtual ~MergeCandidate() = default; virtual bool mergeWouldCreateCycle() const = 0; // METHODS - bool removedFromSb() const { return m_removedFromSb; } - void removedFromSb(bool removed) { m_removedFromSb = removed; } - bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; } + bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; } + void removedFromSb(bool removed) { m_id |= REMOVED_MASK; } + bool operator<(const MergeCandidate& other) const { + return (m_id & ~REMOVED_MASK) < (other.m_id & ~REMOVED_MASK); + } }; // A pair of associated LogicMTask's that are merge candidates for sibling From 8b00939f0cd0c9e832ceaae55a956e343bfb2320 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 3 Nov 2021 22:16:18 -0400 Subject: [PATCH 23/79] Improve performance of V3Scoreboard. Only performance change intended. --- Changes | 1 + src/V3Scoreboard.h | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 809d45d07..830293acf 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,7 @@ Verilator 4.215 devel **Minor:** * Internal code cleanups and improvements. [Geza Lore] +* Improve --thread verilation-time performance. * Fix array method names with parens (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] diff --git a/src/V3Scoreboard.h b/src/V3Scoreboard.h index bfd267c85..edb2165de 100644 --- a/src/V3Scoreboard.h +++ b/src/V3Scoreboard.h @@ -29,9 +29,9 @@ #include "V3Error.h" +#include #include #include -#include //###################################################################### // SortByValueMap @@ -363,7 +363,11 @@ private: using UserScoreFnp = T_Score (*)(const T_Elem*); // MEMBERS - std::unordered_set m_unknown; // Elements with unknown scores + // Below uses set<> not an unordered_set<>. unordered_set::clear() and + // construction results in a 491KB clear operation to zero all the + // buckets. Since the set size is generally small, and we iterate the + // set members, set is better performant. + std::set m_unknown; // Elements with unknown scores SortedMap m_sorted; // Set of elements with known scores UserScoreFnp m_scoreFnp; // Scoring function bool m_slowAsserts; // Do some asserts that require extra lookups From 61612582e6517a5cd5d98ac996f976949a39ae7b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 4 Nov 2021 07:39:28 -0400 Subject: [PATCH 24/79] Improve memory usage of V3Partition. Only performance change intended. --- src/V3Partition.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 5d67b2fb0..6984f7e66 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -707,14 +707,15 @@ class MergeCandidate VL_NOT_FINAL { private: // This structure is extremely hot. To save 8 bytes we pack // one bit indicating removedFromSb with the id. + // By using bit zero, we can still use < to compare IDs without masking. vluint64_t m_id; // <63> removed, <62:0> Serial number for ordering - static constexpr vluint64_t REMOVED_MASK = 1ULL << 63; + static constexpr vluint64_t REMOVED_MASK = 1ULL; public: // CONSTRUCTORS MergeCandidate() { static vluint64_t serial = 0; - ++serial; + serial += 2; // +2 so doesn't set REMOVED_MASK bit m_id = serial; } virtual ~MergeCandidate() = default; @@ -722,9 +723,7 @@ public: // METHODS bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; } void removedFromSb(bool removed) { m_id |= REMOVED_MASK; } - bool operator<(const MergeCandidate& other) const { - return (m_id & ~REMOVED_MASK) < (other.m_id & ~REMOVED_MASK); - } + bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; } }; // A pair of associated LogicMTask's that are merge candidates for sibling @@ -860,7 +859,7 @@ public: std::unordered_map critPaths; GraphStreamUnordered serialize(m_graphp); for (const V3GraphVertex* vertexp; (vertexp = serialize.nextp());) { - m_vertexCount++; + ++m_vertexCount; uint32_t cpCostToHere = 0; for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { ++m_edgeCount; @@ -1371,7 +1370,7 @@ private: // Delete the donorp mtask from the graph VL_DO_CLEAR(donorp->unlinkDelete(m_mtasksp), donorp = nullptr); - m_mergesSinceRescore++; + ++m_mergesSinceRescore; // Do an expensive check, confirm we haven't botched the CP // updates. @@ -1388,14 +1387,14 @@ private: for (V3GraphEdge* edgep = recipientp->outBeginp(); edgep; edgep = edgep->outNextp()) { LogicMTask* const postreqp = dynamic_cast(edgep->top()); siblingPairFromRelatives(GraphWay::REVERSE, postreqp, false); - edges++; + ++edges; if (edges > PART_SIBLING_EDGE_LIMIT) break; } edges = 0; for (V3GraphEdge* edgep = recipientp->inBeginp(); edgep; edgep = edgep->inNextp()) { LogicMTask* const prereqp = dynamic_cast(edgep->fromp()); siblingPairFromRelatives(GraphWay::FORWARD, prereqp, false); - edges++; + ++edges; if (edges > PART_SIBLING_EDGE_LIMIT) break; } } @@ -1843,7 +1842,7 @@ private: partMergeEdgesFrom(m_mtasksp, mergedp, donorp, nullptr); // Remove donorp from the graph VL_DO_DANGLING(donorp->unlinkDelete(m_mtasksp), donorp); - m_mergesDone++; + ++m_mergesDone; } if (lastMergedp) { From e69a8e838dccf046dff06cb003123dc7e65d6944 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sat, 6 Nov 2021 02:08:54 +0000 Subject: [PATCH 25/79] Improve memory usage of V3Partition. Only performance change intended. (#3192) --- src/V3Partition.cpp | 97 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 23 deletions(-) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 6984f7e66..9b6f5982e 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -702,30 +702,53 @@ public: } }; +class SiblingMC; +class MTaskEdge; + // Information associated with scoreboarding an MTask class MergeCandidate VL_NOT_FINAL { private: + // Only the known subclasses can create or delete one of these + friend class SiblingMC; + friend class MTaskEdge; + // This structure is extremely hot. To save 8 bytes we pack - // one bit indicating removedFromSb with the id. - // By using bit zero, we can still use < to compare IDs without masking. - vluint64_t m_id; // <63> removed, <62:0> Serial number for ordering - static constexpr vluint64_t REMOVED_MASK = 1ULL; + // one bit indicating removedFromSb with the id. To save another + // 8 bytes by not having a virtual function table, we implement the + // few polymorphic methods over the two known subclasses explicitly, + // using another bit of the id to denote the actual subtype. + + // By using the bottom bits for flags, we can still use < to compare IDs without masking. + vluint64_t m_id; // <63:2> Serial number for ordering, <1> subtype (SiblingMC), <0> removed + static constexpr vluint64_t REMOVED_MASK = 1ULL << 0; + static constexpr vluint64_t IS_SIBLING_MASK = 1ULL << 1; + static constexpr vluint64_t ID_INCREMENT = 1ULL << 2; + + bool isSiblingMC() const { return m_id & IS_SIBLING_MASK; } + + // CONSTRUCTORS + explicit MergeCandidate(bool isSiblingMC) { + static vluint64_t serial = 0; + serial += ID_INCREMENT; // +ID_INCREMENT so doesn't set the special bottom bits + m_id = serial | (isSiblingMC * IS_SIBLING_MASK); + } + ~MergeCandidate() = default; public: - // CONSTRUCTORS - MergeCandidate() { - static vluint64_t serial = 0; - serial += 2; // +2 so doesn't set REMOVED_MASK bit - m_id = serial; - } - virtual ~MergeCandidate() = default; - virtual bool mergeWouldCreateCycle() const = 0; // METHODS + SiblingMC* toSiblingMC(); // Instead of dynamic_cast + const SiblingMC* toSiblingMC() const; // Instead of dynamic_cast + MTaskEdge* toMTaskEdge(); // Instead of dynamic_cast + const MTaskEdge* toMTaskEdge() const; // Instead of dynamic_cast + bool mergeWouldCreateCycle() const; // Instead of virtual method + bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; } void removedFromSb(bool removed) { m_id |= REMOVED_MASK; } bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; } }; +static_assert(sizeof(MergeCandidate) == sizeof(vluint64_t), "Should not have a vtable"); + // A pair of associated LogicMTask's that are merge candidates for sibling // contraction class SiblingMC final : public MergeCandidate { @@ -736,7 +759,8 @@ private: public: // CONSTRUCTORS SiblingMC() = delete; - SiblingMC(LogicMTask* ap, LogicMTask* bp) { + SiblingMC(LogicMTask* ap, LogicMTask* bp) + : MergeCandidate{/* isSiblingMC: */ true} { // Assign 'ap' and 'bp' in a canonical order, so we can more easily // compare pairs of SiblingMCs if (ap->id() > bp->id()) { @@ -747,11 +771,11 @@ public: m_bp = ap; } } - virtual ~SiblingMC() = default; + ~SiblingMC() = default; // METHODS LogicMTask* ap() const { return m_ap; } LogicMTask* bp() const { return m_bp; } - bool mergeWouldCreateCycle() const override { + bool mergeWouldCreateCycle() const { return (LogicMTask::pathExistsFrom(m_ap, m_bp, nullptr) || LogicMTask::pathExistsFrom(m_bp, m_ap, nullptr)); } @@ -762,12 +786,16 @@ public: } }; +static_assert(sizeof(SiblingMC) == sizeof(MergeCandidate) + 2 * sizeof(LogicMTask*), + "Should not have a vtable"); + // GraphEdge for the MTask graph class MTaskEdge final : public V3GraphEdge, public MergeCandidate { public: // CONSTRUCTORS MTaskEdge(V3Graph* graphp, LogicMTask* fromp, LogicMTask* top, int weight) - : V3GraphEdge{graphp, fromp, top, weight} { + : V3GraphEdge{graphp, fromp, top, weight} + , MergeCandidate{/* isSiblingMC: */ false} { fromp->addRelative(GraphWay::FORWARD, top); top->addRelative(GraphWay::REVERSE, fromp); } @@ -781,7 +809,7 @@ public: } LogicMTask* fromMTaskp() const { return dynamic_cast(fromp()); } LogicMTask* toMTaskp() const { return dynamic_cast(top()); } - virtual bool mergeWouldCreateCycle() const override { + bool mergeWouldCreateCycle() const { return LogicMTask::pathExistsFrom(fromMTaskp(), toMTaskp(), this); } static MTaskEdge* cast(V3GraphEdge* edgep) { @@ -806,6 +834,30 @@ private: VL_UNCOPYABLE(MTaskEdge); }; +// Instead of dynamic cast +SiblingMC* MergeCandidate::toSiblingMC() { + return isSiblingMC() ? static_cast(this) : nullptr; +} + +MTaskEdge* MergeCandidate::toMTaskEdge() { + return isSiblingMC() ? nullptr : static_cast(this); +} + +const SiblingMC* MergeCandidate::toSiblingMC() const { + return isSiblingMC() ? static_cast(this) : nullptr; +} + +const MTaskEdge* MergeCandidate::toMTaskEdge() const { + return isSiblingMC() ? nullptr : static_cast(this); +} + +// Normally this would be a virtual function, but we save space by not having a vtable, +// and we know we only have 2 possible subclasses. +bool MergeCandidate::mergeWouldCreateCycle() const { + return isSiblingMC() ? static_cast(this)->mergeWouldCreateCycle() + : static_cast(this)->mergeWouldCreateCycle(); +} + //###################################################################### // Vertex utility classes @@ -1271,13 +1323,13 @@ private: void contract(MergeCandidate* mergeCanp) { LogicMTask* top = nullptr; LogicMTask* fromp = nullptr; - MTaskEdge* mergeEdgep = dynamic_cast(mergeCanp); + MTaskEdge* mergeEdgep = mergeCanp->toMTaskEdge(); SiblingMC* mergeSibsp = nullptr; if (mergeEdgep) { top = dynamic_cast(mergeEdgep->top()); fromp = dynamic_cast(mergeEdgep->fromp()); } else { - mergeSibsp = dynamic_cast(mergeCanp); + mergeSibsp = mergeCanp->toSiblingMC(); UASSERT(mergeSibsp, "Failed to cast mergeCanp to either MTaskEdge or SiblingMC"); top = mergeSibsp->ap(); fromp = mergeSibsp->bp(); @@ -1413,14 +1465,13 @@ private: } static uint32_t mergeCandidateScore(const MergeCandidate* pairp) { - if (const MTaskEdge* const edgep = dynamic_cast(pairp)) { + if (const MTaskEdge* const edgep = pairp->toMTaskEdge()) { // The '1 +' favors merging a SiblingMC over an otherwise- // equal-scoring MTaskEdge. The comment on selfTest() talks // about why. return 1 + edgeScore(edgep); - } - if (const SiblingMC* const sibsp = dynamic_cast(pairp)) { - return siblingScore(sibsp); + } else { + return siblingScore(pairp->toSiblingMC()); } v3fatalSrc("Failed to cast pairp to either MTaskEdge or SiblingMC in mergeCandidateScore"); return 0; From b08c694cd626e349f4bad8048ab946485c5ba6b0 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Sat, 6 Nov 2021 12:31:50 +0900 Subject: [PATCH 26/79] Fix wrong bit op tree optimization (#3185) * Add a test to reproduce bug3182. Run the same HDL with -Oo to confirm the result is same. * Hopefully fix #3182. The result can be 0 only when polarity is true (no AstNot is found during traversal). --- src/V3Const.cpp | 2 +- test_regress/t/t_const_no_opt.pl | 24 ++++++++++++++++++++++++ test_regress/t/t_const_opt.cpp | 13 +++++++++++++ test_regress/t/t_const_opt.pl | 2 +- test_regress/t/t_const_opt.v | 28 ++++++++++++++++++++++++++-- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100755 test_regress/t/t_const_no_opt.pl create mode 100644 test_regress/t/t_const_opt.cpp diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 259cc7417..a1277871e 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -537,7 +537,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { if (leafInfo.m_lsb < leafInfo.width()) { m_bitPolarities.emplace_back(leafInfo, isXorTree() || leafInfo.m_polarity, leafInfo.m_lsb); - } else if (isAndTree()) { + } else if (isAndTree() && leafInfo.m_polarity) { // If there is a constant 0 term in an And tree, we must include it. Fudge // this by adding a bit with both polarities, which will simplify to zero m_bitPolarities.emplace_back(leafInfo, true, 0); diff --git a/test_regress/t/t_const_no_opt.pl b/test_regress/t/t_const_no_opt.pl new file mode 100755 index 000000000..33be39810 --- /dev/null +++ b/test_regress/t/t_const_no_opt.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); +top_filename("t/t_const_opt.v"); + +# Run the same design as t_const_opt.pl without bitopt tree optimization to make sure that the result is same. +compile( + verilator_flags2 => ["-Wno-UNOPTTHREADS", "--stats", "-Oo", "$Self->{t_dir}/t_const_opt.cpp"], + ); + +execute( + check_finished => 1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_const_opt.cpp b/test_regress/t/t_const_opt.cpp new file mode 100644 index 000000000..116148dfb --- /dev/null +++ b/test_regress/t/t_const_opt.cpp @@ -0,0 +1,13 @@ +// -*- mode: C++; c-file-style: "cc-mode" -*- +//************************************************************************* +// +// Copyright 2021 by Yutetsu TAKATSUKASA. This program is free software; you can +// redistribute it and/or modify it under the terms of either the GNU +// Lesser General Public License Version 3 or the Perl Artistic License +// Version 2.0. +// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 +// +//************************************************************************* + +// This function is used to introduce dependency and disturb optimization +extern "C" int fake_dependency() { return 0; } diff --git a/test_regress/t/t_const_opt.pl b/test_regress/t/t_const_opt.pl index ee51e8030..26143eb57 100755 --- a/test_regress/t/t_const_opt.pl +++ b/test_regress/t/t_const_opt.pl @@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di scenarios(simulator => 1); compile( - verilator_flags2 => ["-Wno-UNOPTTHREADS", "--stats"], + verilator_flags2 => ["-Wno-UNOPTTHREADS", "--stats", "$Self->{t_dir}/$Self->{name}.cpp"], ); execute( diff --git a/test_regress/t/t_const_opt.v b/test_regress/t/t_const_opt.v index e8f31dfe1..2b953aa8d 100644 --- a/test_regress/t/t_const_opt.v +++ b/test_regress/t/t_const_opt.v @@ -57,7 +57,7 @@ module t(/*AUTOARG*/ $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) -`define EXPECTED_SUM 64'he78be35df15ae0ab +`define EXPECTED_SUM 64'ha916d9291821c6e0 if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; @@ -77,10 +77,11 @@ module Test(/*AUTOARG*/ input [31:0] i; logic [31:0] d; logic d0, d1, d2, d3, d4, d5, d6, d7; + logic bug3182_out; output logic o; - logic [4:0] tmp; + logic [5:0] tmp; assign o = ^tmp; always_ff @(posedge clk) begin @@ -101,6 +102,29 @@ module Test(/*AUTOARG*/ tmp[2] <= ((d0 & d1) | (d0 & d2))^ ((d3 & d4) | (d5 & d4)); // replaceAndOr() tmp[3] <= d0 <-> d1; // replaceLogEq() tmp[4] <= i[0] & (i[1] & (i[2] & (i[3] | d[4]))); // ConstBitOpTreeVisitor::m_frozenNodes + tmp[5] <= bug3182_out; end + bug3182 i_bug3182(.in(d[4:0]), .out(bug3182_out)); + +endmodule + +module bug3182(in, out); + input wire [4:0] in; + output wire out; + + // This function always returns 0, so safe to take bitwise OR with any value. + // Calling this function stops constant folding as Verialtor does not know + // what this function returns. + import "DPI-C" context function int fake_dependency(); + + logic [4:0] bit_source; + + /* verilator lint_off WIDTH */ + always @(in) + bit_source = fake_dependency() | in; + + wire [5:0] tmp = bit_source; // V3Gate should inline this + wire out = ~(tmp >> 5) & (bit_source == 5'd10); + /* verilator lint_on WIDTH */ endmodule From 987ce927eb584426bd4da735e3ef2b4887455252 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Sun, 7 Nov 2021 14:09:36 +0000 Subject: [PATCH 27/79] Remove unused code. No functional change. --- src/V3Ast.h | 9 --------- src/V3AstNodes.cpp | 24 ------------------------ src/V3AstNodes.h | 19 +------------------ src/V3Case.cpp | 2 +- src/V3Changed.cpp | 4 ++-- src/V3Graph.h | 4 ---- src/V3LinkInc.h | 3 --- src/V3Number.h | 4 ---- 8 files changed, 4 insertions(+), 65 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index cec0f4a26..be0a03321 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -517,9 +517,6 @@ public: return (m_e == BIT || m_e == BYTE || m_e == INT || m_e == INTEGER || m_e == LOGIC || m_e == LONGINT || m_e == SHORTINT || m_e == UINT32 || m_e == UINT64); } - bool isSloppy() const { // Don't be as anal about width warnings - return !(m_e == LOGIC || m_e == BIT); - } bool isBitLogic() const { // Bit/logic vector types; can form a packed array return (m_e == LOGIC || m_e == BIT); } @@ -1029,9 +1026,6 @@ public: int hiMaxSelect() const { return (lo() < 0 ? hi() - lo() : hi()); } // Maximum value a [] select may index - bool representableByWidth() const { // Could be represented by just width=1, or [width-1:0] - return (!m_ranged || (m_right == 0 && m_left >= 1)); - } void dump(std::ostream& str) const { if (ranged()) { str << "[" << left() << ":" << right() << "]"; @@ -2879,7 +2873,6 @@ public: return m_taskp && m_taskp->isGateOptimizable(); } string dotted() const { return m_dotted; } // * = Scope name or "" - string prettyDotted() const { return prettyName(dotted()); } string inlinedDots() const { return m_inlinedDots; } void inlinedDots(const string& flag) { m_inlinedDots = flag; } AstNodeFTask* taskp() const { return m_taskp; } // [After Link] Pointer to variable @@ -2918,7 +2911,6 @@ private: bool m_recursive : 1; // Recursive module bool m_recursiveClone : 1; // If recursive, what module it clones, otherwise nullptr int m_level = 0; // 1=top module, 2=cell off top module, ... - int m_typeNum = 0; // Incrementing implicit type number VLifetime m_lifetime; // Lifetime VTimescale m_timeunit; // Global time unit VOptionBool m_unconnectedDrive; // State of `unconnected_drive @@ -2958,7 +2950,6 @@ public: void level(int level) { m_level = level; } int level() const { return m_level; } bool isTop() const { return level() == 1; } - int typeNumGetInc() { return ++m_typeNum; } void modPublic(bool flag) { m_modPublic = flag; } bool modPublic() const { return m_modPublic; } void modTrace(bool flag) { m_modTrace = flag; } diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 456f25e81..970bc86ca 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -197,30 +197,6 @@ AstNodeBiop* AstEq::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) { } } -AstNodeBiop* AstGte::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) { - if (lhsp->isString() && rhsp->isString()) { - return new AstGteN(fl, lhsp, rhsp); - } else if (lhsp->isDouble() && rhsp->isDouble()) { - return new AstGteD(fl, lhsp, rhsp); - } else if (lhsp->isSigned() && rhsp->isSigned()) { - return new AstGteS(fl, lhsp, rhsp); - } else { - return new AstGte(fl, lhsp, rhsp); - } -} - -AstNodeBiop* AstLte::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) { - if (lhsp->isString() && rhsp->isString()) { - return new AstLteN(fl, lhsp, rhsp); - } else if (lhsp->isDouble() && rhsp->isDouble()) { - return new AstLteD(fl, lhsp, rhsp); - } else if (lhsp->isSigned() && rhsp->isSigned()) { - return new AstLteS(fl, lhsp, rhsp); - } else { - return new AstLte(fl, lhsp, rhsp); - } -} - AstNodeBiop* AstEqWild::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) { if (lhsp->isString() && rhsp->isString()) { return new AstEqN(fl, lhsp, rhsp); diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 9a409fd92..5c60f657c 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -365,7 +365,6 @@ public: AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); } AstNode* classOrPkgsp() const { return op2p(); } - void classOrPkgsp(AstNode* nodep) { setOp2p(nodep); } AstClass* classp() const; // Class being extended (after link) }; @@ -917,7 +916,6 @@ public: bool isEventValue() const { return keyword().isEventValue(); } bool isOpaque() const { return keyword().isOpaque(); } bool isString() const { return keyword().isString(); } - bool isSloppy() const { return keyword().isSloppy(); } bool isZeroInit() const { return keyword().isZeroInit(); } bool isRanged() const { return rangep() || m.m_nrange.ranged(); } bool isDpiBitVec() const { // DPI uses svBitVecVal @@ -1096,7 +1094,6 @@ public: string ifaceName() const { return m_ifaceName; } void ifaceName(const string& name) { m_ifaceName = name; } string modportName() const { return m_modportName; } - void modportName(const string& name) { m_modportName = name; } AstIface* ifaceViaCellp() const; // Use cellp or ifacep AstIface* ifacep() const { return m_ifacep; } void ifacep(AstIface* nodep) { m_ifacep = nodep; } @@ -2464,7 +2461,6 @@ public: virtual void dump(std::ostream& str) const override; string dotted() const { return m_dotted; } void dotted(const string& dotted) { m_dotted = dotted; } - string prettyDotted() const { return prettyName(dotted()); } string inlinedDots() const { return m_inlinedDots; } void inlinedDots(const string& flag) { m_inlinedDots = flag; } virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } @@ -3783,8 +3779,6 @@ class AstCaseItem final : public AstNode { // Parents: CASE // condsp Children: MATH (Null condition used for default block) // bodysp Children: Statements -private: - bool m_ignoreOverlap = false; // Default created by assertions; ignore overlaps public: AstCaseItem(FileLine* fl, AstNode* condsp, AstNode* bodysp) : ASTGEN_SUPER_CaseItem(fl) { @@ -3798,8 +3792,6 @@ public: void condsp(AstNode* nodep) { setOp1p(nodep); } void addBodysp(AstNode* newp) { addOp2p(newp); } bool isDefault() const { return condsp() == nullptr; } - bool ignoreOverlap() const { return m_ignoreOverlap; } - void ignoreOverlap(bool flag) { m_ignoreOverlap = flag; } }; class AstSFormatF final : public AstNode { @@ -4760,20 +4752,16 @@ public: class AstChangeDet final : public AstNodeStmt { // A comparison to determine change detection, common & must be fast. -private: - bool m_clockReq; // Type of detection public: // Null lhs+rhs used to indicate change needed with no spec vars - AstChangeDet(FileLine* fl, AstNode* lhsp, AstNode* rhsp, bool clockReq) + AstChangeDet(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_ChangeDet(fl) { setNOp1p(lhsp); setNOp2p(rhsp); - m_clockReq = clockReq; } ASTNODE_NODE_FUNCS(ChangeDet) AstNode* lhsp() const { return op1p(); } AstNode* rhsp() const { return op2p(); } - bool isClockReq() const { return m_clockReq; } virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } virtual int instrCount() const override { return widthInstrs() * 2; } // xor, or/logor @@ -7076,8 +7064,6 @@ public: virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstGte(this->fileline(), lhsp, rhsp); } - static AstNodeBiop* newTyped(FileLine* fl, AstNode* lhsp, - AstNode* rhsp); // Return AstGte/AstGteS/AstGteD virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opGte(lhs, rhs); } @@ -7171,8 +7157,6 @@ public: virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) override { return new AstLte(this->fileline(), lhsp, rhsp); } - static AstNodeBiop* newTyped(FileLine* fl, AstNode* lhsp, - AstNode* rhsp); // Return AstLte/AstLteS/AstLteD virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opLte(lhs, rhs); } @@ -9222,7 +9206,6 @@ public: void addModulep(AstNodeModule* modulep) { addOp1p(modulep); } AstNodeFile* filesp() const { return VN_AS(op2p(), NodeFile); } // op2 = List of files void addFilesp(AstNodeFile* filep) { addOp2p(filep); } - AstNode* miscsp() const { return op3p(); } // op3 = List of dtypes etc void addMiscsp(AstNode* nodep) { addOp3p(nodep); } AstTypeTable* typeTablep() { return m_typeTablep; } void changeRequest(bool specified) { m_changeRequest = specified; } diff --git a/src/V3Case.cpp b/src/V3Case.cpp index d9c2ce710..b966dedb5 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -190,7 +190,7 @@ private: if (!m_valueItem[i]) { m_valueItem[i] = itemp; foundHit = true; - } else if (!foundOverlap && !itemp->ignoreOverlap()) { + } else if (!foundOverlap) { firstOverlap = i; foundOverlap = true; m_caseNoOverlapsAllCovered = false; diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 6c7111f5c..daef2b0f1 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -71,7 +71,7 @@ public: // Each change detection function needs at least one AstChangeDet // to ensure that V3EmitC outputs the necessary code. maybeCreateMidChg(); - m_chgFuncp->addStmtsp(new AstChangeDet{m_scopetopp->fileline(), nullptr, nullptr, false}); + m_chgFuncp->addStmtsp(new AstChangeDet{m_scopetopp->fileline(), nullptr, nullptr}); } void maybeCreateMidChg() { // Don't create an extra function call if splitting is disabled @@ -146,7 +146,7 @@ private: m_statep->maybeCreateChgFuncp(); AstChangeDet* const changep = new AstChangeDet{ - m_vscp->fileline(), m_varEqnp->cloneTree(true), m_newRvEqnp->cloneTree(true), false}; + m_vscp->fileline(), m_varEqnp->cloneTree(true), m_newRvEqnp->cloneTree(true)}; m_statep->m_chgFuncp->addStmtsp(changep); AstAssign* const initp = new AstAssign{m_vscp->fileline(), m_newLvEqnp->cloneTree(true), m_varEqnp->cloneTree(true)}; diff --git a/src/V3Graph.h b/src/V3Graph.h index 1b03c8a7e..5d160dce7 100644 --- a/src/V3Graph.h +++ b/src/V3Graph.h @@ -88,10 +88,6 @@ protected: friend class V3GraphEdge; friend class GraphAcyc; // METHODS - void acyclicDFS(); - void acyclicDFSIterate(V3GraphVertex* vertexp, int depth, uint32_t currentRank); - void acyclicCut(); - void acyclicLoop(V3GraphVertex* vertexp, int depth); double orderDFSIterate(V3GraphVertex* vertexp); void dumpEdge(std::ostream& os, V3GraphVertex* vertexp, V3GraphEdge* edgep); void verticesUnlink() { m_vertices.reset(); } diff --git a/src/V3LinkInc.h b/src/V3LinkInc.h index 5fc9f41a1..3348e9961 100644 --- a/src/V3LinkInc.h +++ b/src/V3LinkInc.h @@ -28,9 +28,6 @@ class V3LinkInc final { public: static void linkIncrements(AstNetlist* nodep); - -private: - void prepost_visit(AstNode* nodep); }; #endif // Guard diff --git a/src/V3Number.h b/src/V3Number.h index 9a33a6b7a..f43fd6619 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -359,12 +359,8 @@ public: // STATICS static int log2b(uint32_t num); - using UniopFuncp = V3Number& (*)(V3Number&); - using BiopFuncp = V3Number& (*)(V3Number&, V3Number&); - // MATH // "this" is the output, as we need the output width before some computations - V3Number& isTrue(const V3Number& lhs); V3Number& opBitsNonX(const V3Number& lhs); // 0/1->1, X/Z->0 V3Number& opBitsOne(const V3Number& lhs); // 1->1, 0/X/Z->0 V3Number& opBitsXZ(const V3Number& lhs); // 0/1->0, X/Z->1 From 185e5d8f428d203bfda8650c21f613c0205fb2fc Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Tue, 9 Nov 2021 21:29:28 +0000 Subject: [PATCH 28/79] Make 'bit', 'logic' and 'time' types unsigned by default IEEE 1800-2017 6.11.3 says these types are unsigned. Until now these types were treated as not having a signedness (NOSIGN), and nodes having these types were later resolved by V3Width to be unsigned. This is a bit problematic when creating nodes of these types after V3Width. Treating these types as unsigned from the get go is fine, and actually improves generated code slightly. --- src/V3Ast.h | 3 +- test_regress/t/t_xml_debugcheck.out | 257 ++++++++++++------------- test_regress/t/t_xml_flat_vlvbound.out | 67 ++++--- 3 files changed, 163 insertions(+), 164 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index be0a03321..ac027182c 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -504,7 +504,8 @@ public: } bool isUnsigned() const { return m_e == CHANDLE || m_e == EVENTVALUE || m_e == STRING || m_e == SCOPEPTR - || m_e == CHARPTR || m_e == UINT32 || m_e == UINT64; + || m_e == CHARPTR || m_e == UINT32 || m_e == UINT64 || m_e == BIT || m_e == LOGIC + || m_e == TIME; } bool isFourstate() const { return m_e == INTEGER || m_e == LOGIC || m_e == LOGIC_IMPLICIT || m_e == TIME; diff --git a/test_regress/t/t_xml_debugcheck.out b/test_regress/t/t_xml_debugcheck.out index 3b62af357..791baf602 100644 --- a/test_regress/t/t_xml_debugcheck.out +++ b/test_regress/t/t_xml_debugcheck.out @@ -104,10 +104,10 @@ - + - + @@ -120,7 +120,7 @@ - + @@ -134,10 +134,10 @@ - + - + @@ -150,7 +150,7 @@ - + @@ -164,14 +164,14 @@ - + - + - + @@ -186,11 +186,11 @@ - + - + @@ -206,10 +206,10 @@ - + - + @@ -222,7 +222,7 @@ - + @@ -236,10 +236,10 @@ - + - + @@ -252,7 +252,7 @@ - + @@ -266,14 +266,14 @@ - + - + - + @@ -288,11 +288,11 @@ - + - + @@ -354,10 +354,10 @@ - + - + @@ -370,7 +370,7 @@ - + @@ -384,10 +384,10 @@ - + - + @@ -400,7 +400,7 @@ - + @@ -414,14 +414,14 @@ - + - + - + @@ -436,11 +436,11 @@ - + - + @@ -456,10 +456,10 @@ - + - + @@ -472,7 +472,7 @@ - + @@ -486,10 +486,10 @@ - + - + @@ -502,7 +502,7 @@ - + @@ -516,14 +516,14 @@ - + - + - + @@ -538,11 +538,11 @@ - + - + @@ -604,10 +604,10 @@ - + - + @@ -620,7 +620,7 @@ - + @@ -634,10 +634,10 @@ - + - + @@ -650,7 +650,7 @@ - + @@ -664,14 +664,14 @@ - + - + - + @@ -686,11 +686,11 @@ - + - + @@ -706,10 +706,10 @@ - + - + @@ -722,7 +722,7 @@ - + @@ -736,10 +736,10 @@ - + - + @@ -752,7 +752,7 @@ - + @@ -766,14 +766,14 @@ - + - + - + @@ -788,11 +788,11 @@ - + - + @@ -855,10 +855,10 @@ - + - + @@ -871,7 +871,7 @@ - + @@ -885,14 +885,14 @@ - + - + - + @@ -907,11 +907,11 @@ - + - + @@ -927,14 +927,14 @@ - + - + - + @@ -949,11 +949,11 @@ - + - + @@ -969,18 +969,18 @@ - + - + - + - + @@ -997,15 +997,15 @@ - + - + - + @@ -1023,18 +1023,18 @@ - + - + - + - + @@ -1051,15 +1051,15 @@ - + - + - + @@ -1077,18 +1077,18 @@ - + - + - + - + @@ -1105,15 +1105,15 @@ - + - + - + @@ -1131,10 +1131,10 @@ - + - + @@ -1147,7 +1147,7 @@ - + @@ -1161,10 +1161,10 @@ - + - + @@ -1177,7 +1177,7 @@ - + @@ -1191,14 +1191,14 @@ - + - + - + @@ -1213,11 +1213,11 @@ - + - + @@ -1233,14 +1233,14 @@ - + - + - + @@ -1255,11 +1255,11 @@ - + - + @@ -1347,7 +1347,7 @@ - + @@ -1419,7 +1419,7 @@ - + @@ -1442,7 +1442,7 @@ - + @@ -1455,7 +1455,7 @@ - + @@ -1484,10 +1484,10 @@ - + - + @@ -1511,7 +1511,7 @@ - + @@ -1523,15 +1523,15 @@ - + - + - + @@ -1543,13 +1543,12 @@ - + - - + diff --git a/test_regress/t/t_xml_flat_vlvbound.out b/test_regress/t/t_xml_flat_vlvbound.out index aafd3bcf6..0ccd4afa3 100644 --- a/test_regress/t/t_xml_flat_vlvbound.out +++ b/test_regress/t/t_xml_flat_vlvbound.out @@ -77,37 +77,37 @@ - - - - + + + + - + - - + + - + - + - - + + - + - - + + @@ -143,37 +143,37 @@ - - - - + + + + - + - - + + - + - + - - + + - + - - + + @@ -201,16 +201,15 @@ - - + + - - - + + + - From b95ee84343266d2b73b0709b38186d06abcd2a86 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 7 Nov 2021 12:49:44 -0500 Subject: [PATCH 29/79] Commentary --- docs/guide/exe_verilator.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 7e38489e5..508492d16 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -1165,9 +1165,9 @@ Summary: .. option:: --trace-underscore - Enable tracing of signals that start with an underscore. Normally, these - signals are not output during tracing. See also - :vlopt:`--coverage-underscore` option. + Enable tracing of signals or modules that start with an + underscore. Normally, these signals are not output during tracing. See + also :vlopt:`--coverage-underscore` option. .. option:: -U From 27883b52d661cb0c6ecdc79c89ca97f90425e2ea Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 10:42:26 -0500 Subject: [PATCH 30/79] Internals: Add const --- src/V3Cast.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index de912c72e..d8db3abe1 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -155,7 +155,7 @@ private: } } virtual void visit(AstVarRef* nodep) override { - AstNode* const backp = nodep->backp(); + const AstNode* const backp = nodep->backp(); if (nodep->access().isReadOnly() && !VN_IS(backp, CCast) && VN_IS(backp, NodeMath) && !VN_IS(backp, ArraySel) && !VN_IS(backp, RedXor) && backp->width() && castSize(nodep) != castSize(nodep->varp())) { From 3a5cbd5b67465b50d81374734c1b32e2653d5f68 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 10:46:25 -0500 Subject: [PATCH 31/79] Internals: Untabify some embedded tabs. --- test_regress/t/t_EXAMPLE.v | 10 +++++----- test_regress/t/t_alw_split_rst.v | 10 +++++----- test_regress/t/t_array_mda.v | 10 +++++----- test_regress/t/t_array_rev.v | 2 +- test_regress/t/t_assign_slice_overflow.v | 2 +- test_regress/t/t_assoc.v | 2 +- test_regress/t/t_assoc2.v | 2 +- test_regress/t/t_assoc_wildcard_unsup.v | 2 +- test_regress/t/t_bitsel_slice.v | 10 +++++----- test_regress/t/t_case_deep.v | 10 +++++----- test_regress/t/t_case_dupitems.v | 10 +++++----- test_regress/t/t_case_inside.v | 8 ++++---- test_regress/t/t_case_nest.v | 6 +++--- test_regress/t/t_case_onehot.v | 10 +++++----- test_regress/t/t_case_reducer.v | 10 +++++----- test_regress/t/t_case_wild.v | 6 +++--- test_regress/t/t_case_write1.v | 6 +++--- test_regress/t/t_case_write2.v | 6 +++--- test_regress/t/t_castdyn_enum.v | 2 +- test_regress/t/t_chg_first.v | 2 +- test_regress/t/t_clk_2in.v | 4 ++-- test_regress/t/t_clk_dpulse.v | 2 +- test_regress/t/t_clk_dsp.v | 2 +- test_regress/t/t_clk_first.v | 2 +- test_regress/t/t_clk_gater.v | 10 +++++----- test_regress/t/t_clk_latch.v | 2 +- test_regress/t/t_clk_latchgate.v | 8 ++++---- test_regress/t/t_clk_powerdn.v | 4 ++-- test_regress/t/t_clk_vecgen1.v | 10 +++++----- test_regress/t/t_concat_sel.v | 10 +++++----- test_regress/t/t_const_op_red_scope.v | 10 +++++----- test_regress/t/t_const_opt.v | 10 +++++----- test_regress/t/t_const_opt_cov.v | 10 +++++----- test_regress/t/t_const_opt_or.v | 10 +++++----- test_regress/t/t_const_opt_red.v | 12 ++++++------ test_regress/t/t_const_opt_shortcut.v | 10 +++++----- test_regress/t/t_display_merge.v | 24 ++++++++++++------------ test_regress/t/t_display_realtime.v | 2 +- test_regress/t/t_display_wide.v | 10 +++++----- test_regress/t/t_dpi_var.v | 8 ++++---- test_regress/t/t_dynarray.v | 2 +- test_regress/t/t_embed1.v | 8 ++++---- test_regress/t/t_emit_constw.v | 10 +++++----- test_regress/t/t_enum_large_methods.v | 2 +- test_regress/t/t_enum_type_methods.v | 2 +- test_regress/t/t_extend.v | 6 +++--- test_regress/t/t_extend_class.v | 6 +++--- test_regress/t/t_flag_compiler.v | 4 ++-- test_regress/t/t_flag_csplit.v | 4 ++-- test_regress/t/t_for_break.v | 10 +++++----- test_regress/t/t_for_funcbound.v | 2 +- test_regress/t/t_for_local.v | 4 ++-- test_regress/t/t_for_loop.v | 4 ++-- test_regress/t/t_func_check.v | 4 ++-- test_regress/t/t_func_endian.v | 10 +++++----- test_regress/t/t_func_first.v | 2 +- test_regress/t/t_func_graphcirc.v | 2 +- test_regress/t/t_func_noinl.v | 10 +++++----- test_regress/t/t_func_outfirst.v | 10 +++++----- test_regress/t/t_func_plog.v | 10 +++++----- test_regress/t/t_func_rand.v | 2 +- test_regress/t/t_func_return.v | 10 +++++----- test_regress/t/t_func_sum.v | 10 +++++----- test_regress/t/t_gate_array.v | 10 +++++----- test_regress/t/t_gate_implicit.v | 10 +++++----- test_regress/t/t_gate_ormux.v | 12 ++++++------ test_regress/t/t_gen_alw.v | 10 +++++----- test_regress/t/t_gen_assign.v | 6 +++--- test_regress/t/t_gen_for.v | 4 ++-- test_regress/t/t_gen_for0.v | 2 +- test_regress/t/t_gen_for1.v | 2 +- test_regress/t/t_gen_for_shuffle.v | 10 +++++----- test_regress/t/t_gen_forif.v | 10 +++++----- test_regress/t/t_gen_inc.v | 2 +- test_regress/t/t_gen_intdot.v | 4 ++-- test_regress/t/t_gen_intdot2.v | 4 ++-- test_regress/t/t_gen_local.v | 2 +- test_regress/t/t_gen_lsb.v | 10 +++++----- test_regress/t/t_gen_upscope.v | 2 +- test_regress/t/t_if_deep.v | 10 +++++----- test_regress/t/t_iff.v | 10 +++++----- test_regress/t/t_inside_unpacked.v | 2 +- test_regress/t/t_inside_wild.v | 10 +++++----- test_regress/t/t_inst_aport.v | 10 +++++----- test_regress/t/t_inst_array_partial.v | 10 +++++----- test_regress/t/t_inst_ccall.v | 4 ++-- test_regress/t/t_inst_dff.v | 10 +++++----- test_regress/t/t_inst_mnpipe.v | 4 ++-- test_regress/t/t_inst_notunsized.v | 10 +++++----- test_regress/t/t_inst_signed.v | 2 +- test_regress/t/t_inst_signed1.v | 2 +- test_regress/t/t_inst_slice.v | 10 +++++----- test_regress/t/t_interface_bind_public.v | 2 +- test_regress/t/t_interface_dups.v | 10 +++++----- test_regress/t/t_interface_gen2.v | 2 +- test_regress/t/t_interface_gen3.v | 2 +- test_regress/t/t_interface_ref_trace.v | 2 +- test_regress/t/t_math_clog2.v | 10 +++++----- test_regress/t/t_math_cmp.v | 4 ++-- test_regress/t/t_math_concat0.v | 10 +++++----- test_regress/t/t_math_cond_clean.v | 10 +++++----- test_regress/t/t_math_cond_huge.v | 10 +++++----- test_regress/t/t_math_const.v | 2 +- test_regress/t/t_math_countbits.v | 2 +- test_regress/t/t_math_eq.v | 10 +++++----- test_regress/t/t_math_imm.v | 6 +++--- test_regress/t/t_math_mul.v | 6 +++--- test_regress/t/t_math_pick.v | 10 +++++----- test_regress/t/t_math_pow2.v | 10 +++++----- test_regress/t/t_math_pow4.v | 4 ++-- test_regress/t/t_math_precedence.v | 10 +++++----- test_regress/t/t_math_real.v | 4 ++-- test_regress/t/t_math_real_random.v | 6 +++--- test_regress/t/t_math_real_round.v | 2 +- test_regress/t/t_math_red.v | 2 +- test_regress/t/t_math_shift_rep.v | 10 +++++----- test_regress/t/t_math_shift_sel.v | 10 +++++----- test_regress/t/t_math_shortreal.v | 4 ++-- test_regress/t/t_math_signed.v | 4 ++-- test_regress/t/t_math_signed_wire.v | 2 +- test_regress/t/t_math_swap.v | 10 +++++----- test_regress/t/t_math_trig.v | 4 ++-- test_regress/t/t_math_vliw.v | 6 +++--- test_regress/t/t_math_yosys.v | 2 +- test_regress/t/t_mem_fifo.v | 6 +++--- test_regress/t/t_mem_file.v | 10 +++++----- test_regress/t/t_mem_func.v | 10 +++++----- test_regress/t/t_mem_iforder.v | 6 +++--- test_regress/t/t_mem_multidim.v | 6 +++--- test_regress/t/t_mem_multiwire.v | 2 +- test_regress/t/t_mem_packed.v | 2 +- test_regress/t/t_mem_shift.v | 6 +++--- test_regress/t/t_mem_slice_conc_bad.v | 10 +++++----- test_regress/t/t_mem_twoedge.v | 12 ++++++------ test_regress/t/t_merge_cond.v | 4 ++-- test_regress/t/t_mod_recurse.v | 10 +++++----- test_regress/t/t_optm_redor.v | 10 +++++----- test_regress/t/t_order.v | 4 ++-- test_regress/t/t_order_2d.v | 10 +++++----- test_regress/t/t_order_clkinst.v | 4 ++-- test_regress/t/t_order_comboclkloop.v | 6 +++--- test_regress/t/t_order_doubleloop.v | 4 ++-- test_regress/t/t_param_array6.v | 2 +- test_regress/t/t_param_if_blk.v | 10 +++++----- test_regress/t/t_param_sel.v | 10 +++++----- test_regress/t/t_past.v | 4 ++-- test_regress/t/t_pgo_profoutofdate_bad.v | 2 +- test_regress/t/t_prof.v | 8 ++++---- test_regress/t/t_prot_lib.v | 2 +- test_regress/t/t_queue.v | 2 +- test_regress/t/t_reloop_cam.v | 10 +++++----- test_regress/t/t_savable.v | 4 ++-- test_regress/t/t_select_2d.v | 10 +++++----- test_regress/t/t_select_bad_range2.v | 2 +- test_regress/t/t_select_bound1.v | 10 +++++----- test_regress/t/t_select_bound2.v | 10 +++++----- test_regress/t/t_select_lhs_oob.v | 4 ++-- test_regress/t/t_select_lhs_oob2.v | 10 +++++----- test_regress/t/t_select_little.v | 12 ++++++------ test_regress/t/t_select_negative.v | 12 ++++++------ test_regress/t/t_select_plus.v | 4 ++-- test_regress/t/t_select_plus_mul_pow2.v | 2 +- test_regress/t/t_select_plusloop.v | 6 +++--- test_regress/t/t_select_runtime_range.v | 6 +++--- test_regress/t/t_split_var_0.v | 2 +- test_regress/t/t_split_var_3_wreal.v | 2 +- test_regress/t/t_split_var_4.v | 10 +++++----- test_regress/t/t_stream2.v | 8 ++++---- test_regress/t/t_stream3.v | 6 +++--- test_regress/t/t_string.v | 2 +- test_regress/t/t_string_type_methods.v | 2 +- test_regress/t/t_struct_port.v | 10 +++++----- test_regress/t/t_struct_portsel.v | 10 +++++----- test_regress/t/t_struct_unaligned.v | 2 +- test_regress/t/t_sys_time.v | 2 +- test_regress/t/t_table_fsm.v | 10 +++++----- test_regress/t/t_time_sc.v | 2 +- test_regress/t/t_time_stamp64.v | 2 +- test_regress/t/t_trace_array.v | 2 +- test_regress/t/t_trace_complex.v | 2 +- test_regress/t/t_tri_array.v | 10 +++++----- test_regress/t/t_tri_array_bufif.v | 10 +++++----- test_regress/t/t_tri_eqcase.v | 10 +++++----- test_regress/t/t_tri_pull01.v | 10 +++++----- test_regress/t/t_tri_unconn.v | 2 +- test_regress/t/t_typedef_param.v | 10 +++++----- test_regress/t/t_typedef_port.v | 10 +++++----- test_regress/t/t_typedef_signed.v | 10 +++++----- test_regress/t/t_udp.v | 10 +++++----- test_regress/t/t_udp_noname.v | 2 +- test_regress/t/t_unopt_array.v | 10 +++++----- test_regress/t/t_unopt_combo.v | 10 +++++----- test_regress/t/t_unroll_signed.v | 2 +- test_regress/t/t_vams_wreal.v | 4 ++-- test_regress/t/t_var_assign_landr.v | 8 ++++---- test_regress/t/t_var_in_assign.v | 4 ++-- test_regress/t/t_verilated_debug.v | 2 +- test_regress/t/t_xml_debugcheck.out | 12 ++++++------ 198 files changed, 638 insertions(+), 638 deletions(-) diff --git a/test_regress/t/t_EXAMPLE.v b/test_regress/t/t_EXAMPLE.v index 032785ac5..3cc26f133 100644 --- a/test_regress/t/t_EXAMPLE.v +++ b/test_regress/t/t_EXAMPLE.v @@ -22,7 +22,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -47,11 +47,11 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -63,7 +63,7 @@ module t(/*AUTOARG*/ else if (cyc < 90) begin end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h4afe43fb79d7b71e diff --git a/test_regress/t/t_alw_split_rst.v b/test_regress/t/t_alw_split_rst.v index b0f411f53..5e39edbcb 100644 --- a/test_regress/t/t_alw_split_rst.v +++ b/test_regress/t/t_alw_split_rst.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -44,11 +44,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -60,7 +60,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h77979747fd1b3a5a diff --git a/test_regress/t/t_array_mda.v b/test_regress/t/t_array_mda.v index 2c4cd8350..c6105c7b4 100644 --- a/test_regress/t/t_array_mda.v +++ b/test_regress/t/t_array_mda.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -26,11 +26,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -57,7 +57,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h619f75c3a6d948bd diff --git a/test_regress/t/t_array_rev.v b/test_regress/t/t_array_rev.v index b46935b34..79dbb15e0 100644 --- a/test_regress/t/t_array_rev.v +++ b/test_regress/t/t_array_rev.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc=0; + integer cyc = 0; // verilator lint_off LITENDIAN logic arrd [0:1] = '{ 1'b1, 1'b0 }; // verilator lint_on LITENDIAN diff --git a/test_regress/t/t_assign_slice_overflow.v b/test_regress/t/t_assign_slice_overflow.v index 8cee5b0d3..816aa6b98 100644 --- a/test_regress/t/t_assign_slice_overflow.v +++ b/test_regress/t/t_assign_slice_overflow.v @@ -29,7 +29,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; // Non-constant offsets reg varoffset1; reg [6:0] varoffset2; diff --git a/test_regress/t/t_assoc.v b/test_regress/t/t_assoc.v index 6c474516a..278003ca4 100644 --- a/test_regress/t/t_assoc.v +++ b/test_regress/t/t_assoc.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; integer i; diff --git a/test_regress/t/t_assoc2.v b/test_regress/t/t_assoc2.v index 4c938a35a..8cea07e6b 100644 --- a/test_regress/t/t_assoc2.v +++ b/test_regress/t/t_assoc2.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; // associative array of an associative array logic [31:0] a [logic [31:0]][logic [63:0]]; diff --git a/test_regress/t/t_assoc_wildcard_unsup.v b/test_regress/t/t_assoc_wildcard_unsup.v index d29a50bf8..d17eaf3c1 100644 --- a/test_regress/t/t_assoc_wildcard_unsup.v +++ b/test_regress/t/t_assoc_wildcard_unsup.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; integer i; diff --git a/test_regress/t/t_bitsel_slice.v b/test_regress/t/t_bitsel_slice.v index f943829c2..d8f9d9ad8 100644 --- a/test_regress/t/t_bitsel_slice.v +++ b/test_regress/t/t_bitsel_slice.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -35,11 +35,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -51,7 +51,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hdc21e42d85441511 diff --git a/test_regress/t/t_case_deep.v b/test_regress/t/t_case_deep.v index 12335f6ac..1041a0281 100644 --- a/test_regress/t/t_case_deep.v +++ b/test_regress/t/t_case_deep.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -42,11 +42,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -57,7 +57,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_case_dupitems.v b/test_regress/t/t_case_dupitems.v index 8f38669e8..74d91c740 100644 --- a/test_regress/t/t_case_dupitems.v +++ b/test_regress/t/t_case_dupitems.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_case_inside.v b/test_regress/t/t_case_inside.v index 59879dd2e..49a70997b 100644 --- a/test_regress/t/t_case_inside.v +++ b/test_regress/t/t_case_inside.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -21,10 +21,10 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x sum=%x in[3:0]=%x out=%x,%x\n",$time, cyc, crc, sum, crc[3:0], out1,out2); + $write("[%0t] cyc==%0d crc=%x sum=%x in[3:0]=%x out=%x,%x\n", $time, cyc, crc, sum, crc[3:0], out1,out2); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {sum[62:0], sum[63]^sum[2]^sum[0]} ^ {58'h0,out1,out2}; if (cyc==0) begin // Setup @@ -32,7 +32,7 @@ module t (/*AUTOARG*/ sum <= 64'h0; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); `define EXPECTED_SUM 64'h10204fa5567c8a4b if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_case_nest.v b/test_regress/t/t_case_nest.v index 8ba5b85d8..024d1ebca 100644 --- a/test_regress/t/t_case_nest.v +++ b/test_regress/t/t_case_nest.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -20,10 +20,10 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x sum=%x out=%x\n",$time, cyc, crc, sum, out1); + $write("[%0t] cyc==%0d crc=%x sum=%x out=%x\n", $time, cyc, crc, sum, out1); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {sum[62:0], sum[63]^sum[2]^sum[0]} ^ {63'h0,out1}; if (cyc==1) begin // Setup diff --git a/test_regress/t/t_case_onehot.v b/test_regress/t/t_case_onehot.v index 2f71d68e9..35288267a 100644 --- a/test_regress/t/t_case_onehot.v +++ b/test_regress/t/t_case_onehot.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h704ca23e2a83e1c5 diff --git a/test_regress/t/t_case_reducer.v b/test_regress/t/t_case_reducer.v index 44e0a11bc..ab8f6eabe 100644 --- a/test_regress/t/t_case_reducer.v +++ b/test_regress/t/t_case_reducer.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h8a78c2ec4946ac38 diff --git a/test_regress/t/t_case_wild.v b/test_regress/t/t_case_wild.v index c6daa0688..171236ad5 100644 --- a/test_regress/t/t_case_wild.v +++ b/test_regress/t/t_case_wild.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -20,9 +20,9 @@ module t (/*AUTOARG*/ sub sub (.in(crc[23:0]), .out1(out1), .out2(out2)); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%x sum=%x out=%x,%x\n",$time, cyc, crc, sum, out1,out2); + //$write("[%0t] cyc==%0d crc=%x sum=%x out=%x,%x\n", $time, cyc, crc, sum, out1,out2); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {sum[62:0], sum[63]^sum[2]^sum[0]} ^ {58'h0,out1,out2}; if (cyc==0) begin // Setup diff --git a/test_regress/t/t_case_write1.v b/test_regress/t/t_case_write1.v index 7c3c8edf7..2b469f7cd 100644 --- a/test_regress/t/t_case_write1.v +++ b/test_regress/t/t_case_write1.v @@ -21,7 +21,7 @@ module t (/*AUTOARG*/ t_case_write1_tasks tasks (); - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; always @ (posedge clk) begin $fwrite(fd, "[%0d] crc=%x ", cyc, crc); @@ -30,9 +30,9 @@ module t (/*AUTOARG*/ end always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%x\n",$time, cyc, crc); + //$write("[%0t] cyc==%0d crc=%x\n", $time, cyc, crc); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==1) begin crc <= 64'h00000000_00000097; $write("%s", {"Open ", `STRINGIFY(`TEST_OBJ_DIR), "/t_case_write1_logger.log\n"}); diff --git a/test_regress/t/t_case_write2.v b/test_regress/t/t_case_write2.v index 98d50c2b5..7027ee9d9 100644 --- a/test_regress/t/t_case_write2.v +++ b/test_regress/t/t_case_write2.v @@ -21,7 +21,7 @@ module t (/*AUTOARG*/ t_case_write2_tasks tasks (); - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; always @ (posedge clk) begin $fwrite(fd, "[%0d] crc=%x ", cyc, crc); @@ -30,9 +30,9 @@ module t (/*AUTOARG*/ end always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%x\n",$time, cyc, crc); + //$write("[%0t] cyc==%0d crc=%x\n", $time, cyc, crc); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==1) begin crc <= 64'h00000000_00000097; $write("%s", {"Open ", `STRINGIFY(`TEST_OBJ_DIR), "/t_case_write2_logger.log\n"}); diff --git a/test_regress/t/t_castdyn_enum.v b/test_regress/t/t_castdyn_enum.v index 47e61cf98..2a68c93bf 100644 --- a/test_regress/t/t_castdyn_enum.v +++ b/test_regress/t/t_castdyn_enum.v @@ -36,7 +36,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin i = $cast(en, cyc); `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d i=%0d en=%0d\n",$time, cyc, i, en); + $write("[%0t] cyc==%0d i=%0d en=%0d\n", $time, cyc, i, en); `endif cyc <= cyc + 1; if (cyc == 10) begin diff --git a/test_regress/t/t_chg_first.v b/test_regress/t/t_chg_first.v index 77015defd..41cde7a1a 100644 --- a/test_regress/t/t_chg_first.v +++ b/test_regress/t/t_chg_first.v @@ -38,7 +38,7 @@ module t (/*AUTOARG*/ always @ (fastclk) begin // surefire lint_off_line ALWLTR ALWMTR if (_mode==1) begin - //$write("[%0t] t_chg: %d: Values: %x %x %x %x %x %x %x\n",$time,fastclk,ord1,ord2,ord3,ord4,ord5,ord6,ord7); + //$write("[%0t] t_chg: %d: Values: %x %x %x %x %x %x %x\n", $time,fastclk,ord1,ord2,ord3,ord4,ord5,ord6,ord7); //if (ord2 == 2 && ord7 != 7) $stop; end end diff --git a/test_regress/t/t_clk_2in.v b/test_regress/t/t_clk_2in.v index 25bd369ae..21bc8b253 100644 --- a/test_regress/t/t_clk_2in.v +++ b/test_regress/t/t_clk_2in.v @@ -85,7 +85,7 @@ module `t2 ( integer vn = 0; integer vpn = 0; task clear; -`ifdef TEST_VERBOSE $display("[%0t] clear\n",$time); `endif +`ifdef TEST_VERBOSE $display("[%0t] clear\n", $time); `endif p0 = 0; p1 = 0; p01 = 0; @@ -98,7 +98,7 @@ module `t2 ( endtask `define display_counts(text) begin \ - $write("[%0t] ",$time); \ + $write("[%0t] ", $time); \ `ifdef T_CLK_2IN_VEC $write(" 2v "); `endif \ $write(text); \ $write(": %0d %0d %0d %0d %0d %0d %0d %0d %0d\n", p0, p1, p01, n0, n1, n01, vp, vn, vpn); \ diff --git a/test_regress/t/t_clk_dpulse.v b/test_regress/t/t_clk_dpulse.v index 0c7877790..9cedf8e33 100644 --- a/test_regress/t/t_clk_dpulse.v +++ b/test_regress/t/t_clk_dpulse.v @@ -13,7 +13,7 @@ module t (/*AUTOARG*/ // verilator lint_off GENCLK - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg genclk; // verilator lint_off MULTIDRIVEN reg [7:0] set_both; diff --git a/test_regress/t/t_clk_dsp.v b/test_regress/t/t_clk_dsp.v index 9572c35e6..f991e87eb 100644 --- a/test_regress/t/t_clk_dsp.v +++ b/test_regress/t/t_clk_dsp.v @@ -13,7 +13,7 @@ module t (/*AUTOARG*/ // verilator lint_off GENCLK - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg [7:0] padd; reg dsp_ph1, dsp_ph2, dsp_reset; diff --git a/test_regress/t/t_clk_first.v b/test_regress/t/t_clk_first.v index 84b6f050b..92285011c 100644 --- a/test_regress/t/t_clk_first.v +++ b/test_regress/t/t_clk_first.v @@ -72,7 +72,7 @@ module t_clk (/*AUTOARG*/ if (!_ranit) begin _ranit <= 1; `ifdef TEST_VERBOSE - $write("[%0t] t_clk: Running\n",$time); + $write("[%0t] t_clk: Running\n", $time); `endif reset_int_ <= 1; end diff --git a/test_regress/t/t_clk_gater.v b/test_regress/t/t_clk_gater.v index b676228ae..4c2d253de 100644 --- a/test_regress/t/t_clk_gater.v +++ b/test_regress/t/t_clk_gater.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; reg reset; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; reset <= (cyc < 5); enable <= cyc[4] || (cyc < 2); if (cyc==0) begin @@ -55,7 +55,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h01e1553da1dcf3af if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_clk_latch.v b/test_regress/t/t_clk_latch.v index caf25288c..487920783 100644 --- a/test_regress/t/t_clk_latch.v +++ b/test_regress/t/t_clk_latch.v @@ -80,7 +80,7 @@ module t (/*AUTOARG*/ end end - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; always @ (posedge fastclk) begin cyc <= cyc+1; diff --git a/test_regress/t/t_clk_latchgate.v b/test_regress/t/t_clk_latchgate.v index 120db757f..b18af26c5 100644 --- a/test_regress/t/t_clk_latchgate.v +++ b/test_regress/t/t_clk_latchgate.v @@ -28,7 +28,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; // Take CRC data and apply to testblock inputs @@ -69,18 +69,18 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x ",$time, cyc, crc); + $write("[%0t] cyc==%0d crc=%x ", $time, cyc, crc); $display(" en=%b fen=%b d=%b ev=%b", test.flop_en_vld[0], test.ff_en_vld[0], test.dvld[0], test.entry_vld[0]); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc<3) begin crc <= 64'h5aef0c8d_d70a4497; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x\n",$time, cyc, crc); + $write("[%0t] cyc==%0d crc=%x\n", $time, cyc, crc); if (ffq_clk_active == 0) begin $display ("----"); $display ("%%Error: TESTCASE FAILED with no Clock arriving at FFQs"); diff --git a/test_regress/t/t_clk_powerdn.v b/test_regress/t/t_clk_powerdn.v index 55173b573..bb496db57 100644 --- a/test_regress/t/t_clk_powerdn.v +++ b/test_regress/t/t_clk_powerdn.v @@ -58,10 +58,10 @@ module t (/*AUTOARG*/ end end - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] rs %x cyc %d cg1f %x cnt %x cg %x\n",$time,reset_l,cyc,clkgate_e1f,count,countgated); + $write("[%0t] rs %x cyc %d cg1f %x cnt %x cg %x\n", $time,reset_l,cyc,clkgate_e1f,count,countgated); `endif cyc <= cyc + 8'd1; case (cyc) diff --git a/test_regress/t/t_clk_vecgen1.v b/test_regress/t/t_clk_vecgen1.v index fd4cd4bad..8c7535c07 100644 --- a/test_regress/t/t_clk_vecgen1.v +++ b/test_regress/t/t_clk_vecgen1.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -33,11 +33,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -48,7 +48,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'hfe8bac0bb1a0e53b if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_concat_sel.v b/test_regress/t/t_concat_sel.v index 33dc12a99..605794d85 100644 --- a/test_regress/t/t_concat_sel.v +++ b/test_regress/t/t_concat_sel.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -45,11 +45,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -61,7 +61,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h4afe43fb79d7b71e diff --git a/test_regress/t/t_const_op_red_scope.v b/test_regress/t/t_const_op_red_scope.v index e36cd4d8a..7ac8d9699 100644 --- a/test_regress/t/t_const_op_red_scope.v +++ b/test_regress/t/t_const_op_red_scope.v @@ -22,7 +22,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -81,11 +81,11 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -97,7 +97,7 @@ module t(/*AUTOARG*/ else if (cyc < 90) begin end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h118c5809c7856d78 diff --git a/test_regress/t/t_const_opt.v b/test_regress/t/t_const_opt.v index 2b953aa8d..eb6097355 100644 --- a/test_regress/t/t_const_opt.v +++ b/test_regress/t/t_const_opt.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,12 +37,12 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); $display("o %b", o); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -54,7 +54,7 @@ module t(/*AUTOARG*/ else if (cyc < 99) begin end else begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'ha916d9291821c6e0 diff --git a/test_regress/t/t_const_opt_cov.v b/test_regress/t/t_const_opt_cov.v index c939ad806..0d3790fed 100644 --- a/test_regress/t/t_const_opt_cov.v +++ b/test_regress/t/t_const_opt_cov.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t(/*AUTOARG*/ sum <= '0; end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'ha2601675a6ae4972 diff --git a/test_regress/t/t_const_opt_or.v b/test_regress/t/t_const_opt_or.v index 0f9077960..7ed622dc7 100644 --- a/test_regress/t/t_const_opt_or.v +++ b/test_regress/t/t_const_opt_or.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -45,11 +45,11 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -59,7 +59,7 @@ module t(/*AUTOARG*/ sum <= '0; end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hdc97b141ac5d6d7d diff --git a/test_regress/t/t_const_opt_red.v b/test_regress/t/t_const_opt_red.v index b8d2725ac..6405e0c92 100644 --- a/test_regress/t/t_const_opt_red.v +++ b/test_regress/t/t_const_opt_red.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -129,14 +129,14 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); $display("a %b %b %b %b %b %b %b %b %b %b %b", a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); $display("o %b %b %b %b %b %b %b %b %b %b %b", o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11); $display("x %b %b %b %b %b %b %b %b %b", x1, x2, x3, x4, x5, x6, x7, x8, x9); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -174,12 +174,12 @@ module t(/*AUTOARG*/ if (z6 != '1) $stop; if (z7 != '0) $stop; if (match1_o != match2_o) begin - $write("[%0t] cyc==%0d m1=%d != m2=%d\n",$time, cyc, match1_o, match2_o); + $write("[%0t] cyc==%0d m1=%d != m2=%d\n", $time, cyc, match1_o, match2_o); $stop; end end else begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h727fb78d09c1981e diff --git a/test_regress/t/t_const_opt_shortcut.v b/test_regress/t/t_const_opt_shortcut.v index 5690188f7..5ad27558e 100644 --- a/test_regress/t/t_const_opt_shortcut.v +++ b/test_regress/t/t_const_opt_shortcut.v @@ -16,7 +16,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t(/*AUTOARG*/ sum <= '0; end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (import_func1() != 1) $stop; // this must be the first call if (import_func3() != 1) $stop; // this must be the first call diff --git a/test_regress/t/t_display_merge.v b/test_regress/t/t_display_merge.v index 9d5b1e3ec..0704e7728 100644 --- a/test_regress/t/t_display_merge.v +++ b/test_regress/t/t_display_merge.v @@ -23,14 +23,14 @@ module t (/*AUTOARG*/); $write(" 1=%0d a=%m 1=%0d", one, one); $display(" 1=%0d b=%m 1=%0d", one, one); $display(" pre"); - $display(" t=%0d",$time); - $display(" t2=%0d",$time); + $display(" t=%0d", $time); + $display(" t2=%0d", $time); $display(" post"); - $display(" t3=%0d",$time); - $display(" t4=%0d t5=%0d",$time,$time,$time); + $display(" t3=%0d", $time); + $display(" t4=%0d t5=%0d", $time,$time,$time); $display("m"); - $display(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d",$time,$time,$time,$time,$time); - $display(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d",$time,$time,$time,$time,$time); + $display(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d", $time,$time,$time,$time,$time); + $display(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d", $time,$time,$time,$time,$time); $display("mm"); $display(""); @@ -38,14 +38,14 @@ module t (/*AUTOARG*/); $write(" a=%m"); $write(" b=%m"); $write(" pre"); - $write(" t=%0d",$time); - $write(" t2=%0d",$time); + $write(" t=%0d", $time); + $write(" t2=%0d", $time); $write(" post"); - $write(" t3=%0d",$time); - $write(" t4=%0d t5=%0d",$time,$time,$time); + $write(" t3=%0d", $time); + $write(" t4=%0d t5=%0d", $time,$time,$time); $write("m"); - $write(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d",$time,$time,$time,$time,$time); - $write(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d",$time,$time,$time,$time,$time); + $write(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d", $time,$time,$time,$time,$time); + $write(" t=%0d t2=%0d t3=%0d t4=%0d t5=%0d", $time,$time,$time,$time,$time); $display("mm"); $display("very very very very very very very very very very very very very very very very very very very very very very"); diff --git a/test_regress/t/t_display_realtime.v b/test_regress/t/t_display_realtime.v index 9dbcff308..ec16d2e91 100644 --- a/test_regress/t/t_display_realtime.v +++ b/test_regress/t/t_display_realtime.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; always @ (posedge clk) begin cyc <= cyc + 1; diff --git a/test_regress/t/t_display_wide.v b/test_regress/t/t_display_wide.v index 026ebecf2..c356ab0e4 100644 --- a/test_regress/t/t_display_wide.v +++ b/test_regress/t/t_display_wide.v @@ -10,21 +10,21 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [4095:0] crc; // Test loop always @ (posedge clk) begin cyc <= cyc + 1; - crc <= {crc[4094:0], crc[63]^crc[2]^crc[0]}; // not a good crc :) + crc <= {crc[4094:0], crc[63] ^ crc[2] ^ crc[0]}; // not a good crc :) if (cyc==0) begin // Setup crc <= 4096'h9f51804b5275c7b6ab9907144a58649bb778f9718062fa5c336fcc9edcad7cf17aad0a656244017bb21d9f97f7c0c147b6fa7488bb9d5bb8d3635b20fba1deab597121c502b21f49b18da998852d29a6b2b649315a3323a31e7e5f41e9bbb7e44046467438f37694857b963250bdb137a922cfce2af1defd1f93db5aa167f316d751bb274bda96fdee5e2c6eb21886633246b165341f0594c27697b06b62b1ad05ebe3c08909a54272de651296dcdd3d1774fc432d22210d8f6afa50b02cf23336f8cc3a0a2ebfd1a3a60366a1b66ef346e0379116d68caa01279ac2772d1f3cd76d2cbbc68ada6f83ec2441b2679b405486df8aa734ea1729b40c3f82210e8e42823eb3fd6ca77ee19f285741c4e8bac1ab7855c3138e84b6da1d897bbe37faf2d0256ad2f7ff9e704a63d824c1e97bddce990cae1578f9537ae2328d0afd69ffb317cbcf859696736e45e5c628b44727557c535a7d02c07907f2dccd6a21ca9ae9e1dbb1a135a8ebc2e0aa8c7329b898d02896273defe21beaa348e11165b71c48cf1c09714942a5a2ddc2adcb6e42c0f630117ee21205677d5128e8efc18c9a6f82a8475541fd722cca2dd829b7e78fef89dbeab63ab7b849910eb4fe675656c4b42b9452c81a4ca6296190a81dc63e6adfaa31995d7dfe3438ee9df66488d6cf569380569ffe6e5ea313d23af6ff08d979af29374ee9aff1fa143df238a1; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x%x%x%x\n",$time, cyc, crc[4095:3072], crc[2071:2048], crc[2047:1024], crc[1023:0]); - $write("[%0t] cyc==%0d crc=%b%b%b%b\n",$time, cyc, crc[4095:3072], crc[2071:2048], crc[2047:1024], crc[1023:0]); - //Unsupported: $write("[%0t] cyc==%0d crc=%x\n",$time, cyc, crc); + $write("[%0t] cyc==%0d crc=%x%x%x%x\n", $time, cyc, crc[4095:3072], crc[2071:2048], crc[2047:1024], crc[1023:0]); + $write("[%0t] cyc==%0d crc=%b%b%b%b\n", $time, cyc, crc[4095:3072], crc[2071:2048], crc[2047:1024], crc[1023:0]); + //Unsupported: $write("[%0t] cyc==%0d crc=%x\n", $time, cyc, crc); if (crc != 4096'h2961926edde3e5c6018be970cdbf327b72b5f3c5eab42995891005eec8767e5fdf03051edbe9d222ee756ee34d8d6c83ee877aad65c487140ac87d26c636a66214b4a69acad924c568cc8e8c79f97d07a6eedf91011919d0e3cdda5215ee58c942f6c4dea48b3f38abc77bf47e4f6d6a859fcc5b5d46ec9d2f6a5bf7b978b1bac862198cc91ac594d07c165309da5ec1ad8ac6b417af8f0224269509cb79944a5b7374f45dd3f10cb48884363dabe942c0b3c8ccdbe330e828baff468e980d9a86d9bbcd1b80de445b5a32a8049e6b09dcb47cf35db4b2ef1a2b69be0fb09106c99e6d01521b7e2a9cd3a85ca6d030fe08843a390a08facff5b29dfb867ca15d0713a2eb06ade1570c4e3a12db687625eef8dfebcb4095ab4bdffe79c1298f609307a5ef773a6432b855e3e54deb88ca342bf5a7fecc5f2f3e165a59cdb9179718a2d11c9d55f14d69f40b01e41fcb7335a8872a6ba7876ec684d6a3af0b82aa31cca6e26340a2589cf7bf886faa8d23844596dc71233c7025c5250a968b770ab72db90b03d8c045fb8848159df544a3a3bf063269be0aa11d5507f5c8b328b760a6df9e3fbe276faad8eadee126443ad3f99d595b12d0ae514b20693298a58642a07718f9ab7ea8c66575f7f8d0e3ba77d992235b3d5a4e015a7ff9b97a8c4f48ebdbfc2365e6bca4dd3ba6bfc7e850f7c8e2842c717a1d85a977a033f564fc ) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_dpi_var.v b/test_regress/t/t_dpi_var.v index a5fc89111..7909867bc 100644 --- a/test_regress/t/t_dpi_var.v +++ b/test_regress/t/t_dpi_var.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; wire monclk = ~clk; @@ -25,7 +25,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d in=%x fr_a=%x b=%x fr_chk=%x\n",$time, cyc, in, fr_a, fr_b, fr_chk); + $write("[%0t] cyc==%0d in=%x fr_a=%x b=%x fr_chk=%x\n", $time, cyc, in, fr_a, fr_b, fr_chk); `endif cyc <= cyc + 1; in <= {in[30:0], in[31]^in[2]^in[0]}; @@ -91,8 +91,8 @@ module sub (/*AUTOARG*/ $c("mon_class_name(this->name());"); mon_scope_name("%m"); // Scheme A - pass pointer directly - $c("mon_register_a(\"in\",&",in,",false);"); - $c("mon_register_a(\"fr_a\",&",fr_a,",true);"); + $c("mon_register_a(\"in\", &", in, ", false);"); + $c("mon_register_a(\"fr_a\", &", fr_a, ", true);"); // Scheme B - use VPIish callbacks to see what signals exist mon_register_b("in", 0); mon_register_b("fr_b", 1); diff --git a/test_regress/t/t_dynarray.v b/test_regress/t/t_dynarray.v index a24a83453..68fe7fb25 100644 --- a/test_regress/t/t_dynarray.v +++ b/test_regress/t/t_dynarray.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; integer i; string v; diff --git a/test_regress/t/t_embed1.v b/test_regress/t/t_embed1.v index c65452f7d..0ba86f13c 100644 --- a/test_regress/t/t_embed1.v +++ b/test_regress/t/t_embed1.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -82,11 +82,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x gv=%x ev=%x\n",$time, cyc, crc, result, + $write("[%0t] cyc==%0d crc=%x result=%x gv=%x ev=%x\n", $time, cyc, crc, result, got_vec_out, exp_vec_out); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -100,7 +100,7 @@ module t (/*AUTOARG*/ end end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; //Child prints this: $write("*-* All Finished *-*\n"); $finish; diff --git a/test_regress/t/t_emit_constw.v b/test_regress/t/t_emit_constw.v index ae9774734..20fa8a9ed 100644 --- a/test_regress/t/t_emit_constw.v +++ b/test_regress/t/t_emit_constw.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -67,11 +67,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -147,7 +147,7 @@ module t (/*AUTOARG*/ w17 = w17 >>> 1; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_enum_large_methods.v b/test_regress/t/t_enum_large_methods.v index a8b75326b..bd9eb5da5 100644 --- a/test_regress/t/t_enum_large_methods.v +++ b/test_regress/t/t_enum_large_methods.v @@ -18,7 +18,7 @@ module t (/*AUTOARG*/ ELARGE = 'hf00d } my_t; - integer cyc=0; + integer cyc = 0; my_t e; string all; diff --git a/test_regress/t/t_enum_type_methods.v b/test_regress/t/t_enum_type_methods.v index 37697ddf7..5d30a0534 100644 --- a/test_regress/t/t_enum_type_methods.v +++ b/test_regress/t/t_enum_type_methods.v @@ -19,7 +19,7 @@ module t (/*AUTOARG*/ E04 = 4 } my_t; - integer cyc=0; + integer cyc = 0; my_t e; int arrayfits [e.num]; // Check can use as constant diff --git a/test_regress/t/t_extend.v b/test_regress/t/t_extend.v index 1ed24e25d..f4a8e362c 100644 --- a/test_regress/t/t_extend.v +++ b/test_regress/t/t_extend.v @@ -13,14 +13,14 @@ module t (/*AUTOARG*/ input clk; // No verilator_public needed, because it's outside the "" in the $c statement - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg c_worked; reg [8:0] c_wider; wire one = 1'b1; always @ (posedge clk) begin - cyc <= cyc+8'd1; + cyc <= cyc + 8'd1; // coverage testing if (one) begin end @@ -33,7 +33,7 @@ module t (/*AUTOARG*/ if (cyc == 8'd2) begin `ifdef VERILATOR $c("VL_PRINTF(\"Calling $c, calling $c...\\n\");"); - $c("VL_PRINTF(\"Cyc=%d\\n\",",cyc,");"); + $c("VL_PRINTF(\"Cyc=%d\\n\",", cyc, ");"); c_worked <= $c("this->my_function()"); c_wider <= $c9("0x10"); `else diff --git a/test_regress/t/t_extend_class.v b/test_regress/t/t_extend_class.v index fb6d400c1..a12826fc6 100644 --- a/test_regress/t/t_extend_class.v +++ b/test_regress/t/t_extend_class.v @@ -10,14 +10,14 @@ module t (/*AUTOARG*/ ); input clk; - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg [31:0] in; wire [31:0] out; t_extend_class_v sub (.in(in), .out(out)); always @ (posedge clk) begin - cyc <= cyc+8'd1; + cyc <= cyc + 8'd1; if (cyc == 8'd1) begin in <= 32'h10; end @@ -43,7 +43,7 @@ module t_extend_class_v (/*AUTOARG*/ always @* begin // When "in" changes, call my method - out = $c("this->m_myobjp->my_math(",in,")"); + out = $c("this->m_myobjp->my_math(", in, ")"); end `systemc_header diff --git a/test_regress/t/t_flag_compiler.v b/test_regress/t/t_flag_compiler.v index 27d49b279..df8446ba5 100644 --- a/test_regress/t/t_flag_compiler.v +++ b/test_regress/t/t_flag_compiler.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [89:0] in; @@ -33,7 +33,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d in=%x out=%x\n",$time, cyc, in, out); + $write("[%0t] cyc==%0d in=%x out=%x\n", $time, cyc, in, out); `endif cyc <= cyc + 1; if (cyc==0) begin diff --git a/test_regress/t/t_flag_csplit.v b/test_regress/t/t_flag_csplit.v index b1ad77045..e25102a36 100644 --- a/test_regress/t/t_flag_csplit.v +++ b/test_regress/t/t_flag_csplit.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; parameter CNT = 5; @@ -36,7 +36,7 @@ module t (/*AUTOARG*/ else if (cyc==99) begin `define EXPECTED_SUM 32'h1239 `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d sum=%x\n",$time, cyc, w[CNT]); + $write("[%0t] cyc==%0d sum=%x\n", $time, cyc, w[CNT]); `endif if (w[CNT] !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_for_break.v b/test_regress/t/t_for_break.v index 0e2084e9d..fabb7b3b9 100644 --- a/test_regress/t/t_for_break.v +++ b/test_regress/t/t_for_break.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -32,11 +32,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -51,7 +51,7 @@ module t (/*AUTOARG*/ if (out0!==out3) $stop; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h293e9f9798e97da0 diff --git a/test_regress/t/t_for_funcbound.v b/test_regress/t/t_for_funcbound.v index b2eba60c3..b217dd246 100644 --- a/test_regress/t/t_for_funcbound.v +++ b/test_regress/t/t_for_funcbound.v @@ -22,7 +22,7 @@ module t (/*AUTOARG*/ reg [7:0] char; integer loc; begin - $write("[%0t] ",$time); + $write("[%0t] ", $time); strings.stringStart(8*8-1); for (char = strings.stringByte(str); !strings.isNull(char); char = strings.stringByte(str)) begin $write("%c",char); diff --git a/test_regress/t/t_for_local.v b/test_regress/t/t_for_local.v index 94a2eb99d..f7deaa4eb 100644 --- a/test_regress/t/t_for_local.v +++ b/test_regress/t/t_for_local.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg [31:0] loops; reg [31:0] loops2; @@ -18,7 +18,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin cyc <= cyc+8'd1; if (cyc == 8'd1) begin - $write("[%0t] t_loop: Running\n",$time); + $write("[%0t] t_loop: Running\n", $time); // Unwind < loops = 0; loops2 = 0; diff --git a/test_regress/t/t_for_loop.v b/test_regress/t/t_for_loop.v index 24cd98a0c..23912a81f 100644 --- a/test_regress/t/t_for_loop.v +++ b/test_regress/t/t_for_loop.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg [31:0] loops; reg [31:0] loops2; @@ -19,7 +19,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin cyc <= cyc+8'd1; if (cyc == 8'd1) begin - $write("[%0t] t_loop: Running\n",$time); + $write("[%0t] t_loop: Running\n", $time); // Unwind < loops = 0; loops2 = 0; diff --git a/test_regress/t/t_func_check.v b/test_regress/t/t_func_check.v index 05b1ac9f8..4fb6c33c9 100644 --- a/test_regress/t/t_func_check.v +++ b/test_regress/t/t_func_check.v @@ -10,7 +10,7 @@ module t ( clk ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; initial crc = 64'h1; chk chk (.clk (clk), @@ -20,7 +20,7 @@ module t ( always @ (posedge clk) begin cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin crc <= 64'h5aef0c8d_d70a4497; end diff --git a/test_regress/t/t_func_endian.v b/test_regress/t/t_func_endian.v index 30d4ecc04..85cccec96 100644 --- a/test_regress/t/t_func_endian.v +++ b/test_regress/t/t_func_endian.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -39,11 +39,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -55,7 +55,7 @@ module t (/*AUTOARG*/ end else if (cyc==99) begin $write("*-* All Finished *-*\n"); - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== 64'h89522c3f5e5ca324) $stop; $finish; diff --git a/test_regress/t/t_func_first.v b/test_regress/t/t_func_first.v index 6aedc2fcf..f882fac13 100644 --- a/test_regress/t/t_func_first.v +++ b/test_regress/t/t_func_first.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; reg set_in_task; always @ (posedge clk) begin diff --git a/test_regress/t/t_func_graphcirc.v b/test_regress/t/t_func_graphcirc.v index d5464771c..6a9a00dc9 100644 --- a/test_regress/t/t_func_graphcirc.v +++ b/test_regress/t/t_func_graphcirc.v @@ -7,7 +7,7 @@ module t (clk); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; always @(posedge clk) begin cyc <= cyc + 1; diff --git a/test_regress/t/t_func_noinl.v b/test_regress/t/t_func_noinl.v index cae0da0a5..1f08b9af1 100644 --- a/test_regress/t/t_func_noinl.v +++ b/test_regress/t/t_func_noinl.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -39,11 +39,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -54,7 +54,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_func_outfirst.v b/test_regress/t/t_func_outfirst.v index 589435311..68f6ee7a8 100644 --- a/test_regress/t/t_func_outfirst.v +++ b/test_regress/t/t_func_outfirst.v @@ -16,7 +16,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -43,11 +43,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -59,7 +59,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3a74e9d34771ad93 diff --git a/test_regress/t/t_func_plog.v b/test_regress/t/t_func_plog.v index 59b210b4b..db13bd781 100644 --- a/test_regress/t/t_func_plog.v +++ b/test_regress/t/t_func_plog.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; reg rst_n; @@ -41,11 +41,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; rst_n <= ~1'b0; if (cyc==0) begin // Setup @@ -60,7 +60,7 @@ module t (/*AUTOARG*/ if (pos1 !== pos2) $stop; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_func_rand.v b/test_regress/t/t_func_rand.v index a60f1fbd7..5da1f012a 100644 --- a/test_regress/t/t_func_rand.v +++ b/test_regress/t/t_func_rand.v @@ -20,7 +20,7 @@ module t (clk, Rand); input [7:0] idx; begin `ifdef verilator - QxRand32 = $c("this->QxRandTbl(",tbl,",",idx,")"); + QxRand32 = $c("this->QxRandTbl(", tbl, ",", idx, ")"); `else QxRand32 = 32'hfeed0fad; `endif diff --git a/test_regress/t/t_func_return.v b/test_regress/t/t_func_return.v index 5c6c54e69..6732caf7b 100644 --- a/test_regress/t/t_func_return.v +++ b/test_regress/t/t_func_return.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -31,11 +31,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -47,7 +47,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hc918fa0aa882a206 diff --git a/test_regress/t/t_func_sum.v b/test_regress/t/t_func_sum.v index ccbab0594..cf5c8b644 100644 --- a/test_regress/t/t_func_sum.v +++ b/test_regress/t/t_func_sum.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -36,11 +36,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -51,7 +51,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_gate_array.v b/test_regress/t/t_gate_array.v index 0ea797e6b..f9673c861 100644 --- a/test_regress/t/t_gate_array.v +++ b/test_regress/t/t_gate_array.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h0908a1f2194d24ee diff --git a/test_regress/t/t_gate_implicit.v b/test_regress/t/t_gate_implicit.v index 6b68b548a..3e485ce34 100644 --- a/test_regress/t/t_gate_implicit.v +++ b/test_regress/t/t_gate_implicit.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -35,11 +35,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -51,7 +51,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hb6d6b86aa20a882a diff --git a/test_regress/t/t_gate_ormux.v b/test_regress/t/t_gate_ormux.v index 7033c45fa..26d254632 100755 --- a/test_regress/t/t_gate_ormux.v +++ b/test_regress/t/t_gate_ormux.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (rdata2 != rdata) $stop; if (cyc==0) begin // Setup @@ -52,13 +52,13 @@ module t (/*AUTOARG*/ sum <= '0; end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h8977713eb467bc86 if (sum !== `EXPECTED_SUM) $stop; end else if (cyc == `SIM_CYCLES) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); $write("*-* All Finished *-*\n"); $finish; end diff --git a/test_regress/t/t_gen_alw.v b/test_regress/t/t_gen_alw.v index b30c20a03..8bd091b7f 100644 --- a/test_regress/t/t_gen_alw.v +++ b/test_regress/t/t_gen_alw.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -29,11 +29,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -44,7 +44,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h0 diff --git a/test_regress/t/t_gen_assign.v b/test_regress/t/t_gen_assign.v index 8bf840544..4528eebab 100644 --- a/test_regress/t/t_gen_assign.v +++ b/test_regress/t/t_gen_assign.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [31:0] sum; @@ -27,10 +27,10 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x q=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x q=%x\n", $time, cyc, crc, sum); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; diff --git a/test_regress/t/t_gen_for.v b/test_regress/t/t_gen_for.v index 4ca2596d7..5ea4631ff 100644 --- a/test_regress/t/t_gen_for.v +++ b/test_regress/t/t_gen_for.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; reg [7:0] crc; genvar g; @@ -28,7 +28,7 @@ module t (/*AUTOARG*/ enflop #(.WIDTH(8)) enf (.a(crc), .q(out_ef), .oe_e1(1'b1), .clk(clk)); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%b %x %x %x %x %x\n",$time, cyc, crc, out_p1, out_p2, out_p3, out_p4, out_ef); + //$write("[%0t] cyc==%0d crc=%b %x %x %x %x %x\n", $time, cyc, crc, out_p1, out_p2, out_p3, out_p4, out_ef); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin diff --git a/test_regress/t/t_gen_for0.v b/test_regress/t/t_gen_for0.v index 08427d063..b822d60ee 100644 --- a/test_regress/t/t_gen_for0.v +++ b/test_regress/t/t_gen_for0.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; Testit testit (/*AUTOINST*/ // Inputs diff --git a/test_regress/t/t_gen_for1.v b/test_regress/t/t_gen_for1.v index a7dc72e62..628213f38 100644 --- a/test_regress/t/t_gen_for1.v +++ b/test_regress/t/t_gen_for1.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ wire b; reg reset; - integer cyc=0; + integer cyc = 0; Testit testit (/*AUTOINST*/ // Outputs diff --git a/test_regress/t/t_gen_for_shuffle.v b/test_regress/t/t_gen_for_shuffle.v index b71f4ffac..ad93479ff 100644 --- a/test_regress/t/t_gen_for_shuffle.v +++ b/test_regress/t/t_gen_for_shuffle.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -33,11 +33,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -49,7 +49,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3e3a62edb61f8c7f diff --git a/test_regress/t/t_gen_forif.v b/test_regress/t/t_gen_forif.v index 91e3a913f..3ffaa7085 100644 --- a/test_regress/t/t_gen_forif.v +++ b/test_regress/t/t_gen_forif.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -29,12 +29,12 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x %x %x %x\n",$time, cyc, crc, Result, Result2); + $write("[%0t] cyc==%0d crc=%x %x %x %x\n", $time, cyc, crc, Result, Result2); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {56'h0, Result, Result2} - ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -46,7 +46,7 @@ module t (/*AUTOARG*/ end else if (cyc==99) begin $write("*-* All Finished *-*\n"); - $write("[%0t] cyc==%0d crc=%x %x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x %x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== 64'h4af37965592f64f9) $stop; $finish; diff --git a/test_regress/t/t_gen_inc.v b/test_regress/t/t_gen_inc.v index e2fbbce2d..dbe517bc6 100644 --- a/test_regress/t/t_gen_inc.v +++ b/test_regress/t/t_gen_inc.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; genvar g; integer i; diff --git a/test_regress/t/t_gen_intdot.v b/test_regress/t/t_gen_intdot.v index a4ffab809..16c509e8d 100644 --- a/test_regress/t/t_gen_intdot.v +++ b/test_regress/t/t_gen_intdot.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; wire out; reg in; @@ -19,7 +19,7 @@ module t (/*AUTOARG*/ Genit g (.clk(clk), .value(in), .result(out)); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d %x %x\n",$time, cyc, in, out); + //$write("[%0t] cyc==%0d %x %x\n", $time, cyc, in, out); cyc <= cyc + 1; if (cyc==0) begin // Setup diff --git a/test_regress/t/t_gen_intdot2.v b/test_regress/t/t_gen_intdot2.v index a2f3886ca..917b6223c 100644 --- a/test_regress/t/t_gen_intdot2.v +++ b/test_regress/t/t_gen_intdot2.v @@ -11,14 +11,14 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; reg check; initial check = 1'b0; Genit g (.clk(clk), .check(check)); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d %x %x\n",$time, cyc, check, out); + //$write("[%0t] cyc==%0d %x %x\n", $time, cyc, check, out); cyc <= cyc + 1; if (cyc==0) begin // Setup diff --git a/test_regress/t/t_gen_local.v b/test_regress/t/t_gen_local.v index f9adfd461..3e42ecf26 100644 --- a/test_regress/t/t_gen_local.v +++ b/test_regress/t/t_gen_local.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; localparam N = 31; diff --git a/test_regress/t/t_gen_lsb.v b/test_regress/t/t_gen_lsb.v index b442483e6..d5d24fa90 100644 --- a/test_regress/t/t_gen_lsb.v +++ b/test_regress/t/t_gen_lsb.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -35,11 +35,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -51,7 +51,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3db7bc8bfe61f983 diff --git a/test_regress/t/t_gen_upscope.v b/test_regress/t/t_gen_upscope.v index b9479e540..f765423d8 100644 --- a/test_regress/t/t_gen_upscope.v +++ b/test_regress/t/t_gen_upscope.v @@ -36,7 +36,7 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; tag tag (); b b (); diff --git a/test_regress/t/t_if_deep.v b/test_regress/t/t_if_deep.v index e8217c4a9..db7a37c0c 100644 --- a/test_regress/t/t_if_deep.v +++ b/test_regress/t/t_if_deep.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_iff.v b/test_regress/t/t_iff.v index 963257cc4..e41a2f746 100644 --- a/test_regress/t/t_iff.v +++ b/test_regress/t/t_iff.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -23,11 +23,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -39,7 +39,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'he58508de5310b541 diff --git a/test_regress/t/t_inside_unpacked.v b/test_regress/t/t_inside_unpacked.v index f15184aa5..0b0760fd8 100644 --- a/test_regress/t/t_inside_unpacked.v +++ b/test_regress/t/t_inside_unpacked.v @@ -22,7 +22,7 @@ module t(/*AUTOARG*/ if (MISS_INSIDE != 0) $stop; end - integer cyc=0; + integer cyc = 0; int array [10]; logic l; diff --git a/test_regress/t/t_inside_wild.v b/test_regress/t/t_inside_wild.v index 7b377ffc6..f8b3e5f37 100644 --- a/test_regress/t/t_inside_wild.v +++ b/test_regress/t/t_inside_wild.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h7a7bd4ee927e7cc3 diff --git a/test_regress/t/t_inst_aport.v b/test_regress/t/t_inst_aport.v index 4773acb8b..1268ea960 100644 --- a/test_regress/t/t_inst_aport.v +++ b/test_regress/t/t_inst_aport.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h4afe43fb79d7b71e diff --git a/test_regress/t/t_inst_array_partial.v b/test_regress/t/t_inst_array_partial.v index a216bbe87..52cdfb4be 100644 --- a/test_regress/t/t_inst_array_partial.v +++ b/test_regress/t/t_inst_array_partial.v @@ -43,7 +43,7 @@ module t (/*AUTOARG*/ .twobits (twobits[15:8]), .bitout ({bitout[18+:2],short_bitout[28+:2]})); - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -55,11 +55,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -71,7 +71,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'ha1da9ff8082a4ff6 diff --git a/test_regress/t/t_inst_ccall.v b/test_regress/t/t_inst_ccall.v index 3416a5915..31ae056ba 100644 --- a/test_regress/t/t_inst_ccall.v +++ b/test_regress/t/t_inst_ccall.v @@ -46,8 +46,8 @@ endmodule module sub (input [7:0] narrow, input [63:0] quad, output [31:0] longout, output [63:0] quadout); // verilator public_module `ifdef verilator - assign longout = $c32("(",narrow,"+1)"); - assign quadout = $c64("(",quad,"+1)"); + assign longout = $c32("(", narrow, "+1)"); + assign quadout = $c64("(", quad, "+1)"); `else assign longout = narrow + 8'd1; assign quadout = quad + 64'd1; diff --git a/test_regress/t/t_inst_dff.v b/test_regress/t/t_inst_dff.v index 0e7214233..00df717ed 100644 --- a/test_regress/t/t_inst_dff.v +++ b/test_regress/t/t_inst_dff.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -42,11 +42,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -64,7 +64,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hbcfcebdb75ec9d32 diff --git a/test_regress/t/t_inst_mnpipe.v b/test_regress/t/t_inst_mnpipe.v index a96141c51..1663dc88f 100644 --- a/test_regress/t/t_inst_mnpipe.v +++ b/test_regress/t/t_inst_mnpipe.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [7:0] crc; reg [2:0] sum; @@ -20,7 +20,7 @@ module t (/*AUTOARG*/ MxN_pipeline pipe (in, out, clk); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%b sum=%x\n",$time, cyc, crc, sum); + //$write("[%0t] cyc==%0d crc=%b sum=%x\n", $time, cyc, crc, sum); cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; if (cyc==0) begin diff --git a/test_regress/t/t_inst_notunsized.v b/test_regress/t/t_inst_notunsized.v index 07d68a38f..d2fa6ff41 100644 --- a/test_regress/t/t_inst_notunsized.v +++ b/test_regress/t/t_inst_notunsized.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h20050a66e7b253d1 diff --git a/test_regress/t/t_inst_signed.v b/test_regress/t/t_inst_signed.v index 7529608ae..39bdafa0d 100644 --- a/test_regress/t/t_inst_signed.v +++ b/test_regress/t/t_inst_signed.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; wire signed [7:0] sgn_wide; wire [7:0] unsgn_wide; diff --git a/test_regress/t/t_inst_signed1.v b/test_regress/t/t_inst_signed1.v index a1b1e4d5d..34cdaf2fc 100644 --- a/test_regress/t/t_inst_signed1.v +++ b/test_regress/t/t_inst_signed1.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ wire signed o1; wire signed o2; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; sub1 sub1 (.i(i), .o(o1)); sub2 sub2 (.i(o1), .o(o2)); diff --git a/test_regress/t/t_inst_slice.v b/test_regress/t/t_inst_slice.v index 1a56b6260..f05524451 100644 --- a/test_regress/t/t_inst_slice.v +++ b/test_regress/t/t_inst_slice.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -31,11 +31,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x sum=%x\n",$time, cyc, crc, result, sum); + $write("[%0t] cyc==%0d crc=%x result=%x sum=%x\n", $time, cyc, crc, result, sum); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -47,7 +47,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hb42b2f48a0a9375a diff --git a/test_regress/t/t_interface_bind_public.v b/test_regress/t/t_interface_bind_public.v index a95c01dfe..f20d70187 100644 --- a/test_regress/t/t_interface_bind_public.v +++ b/test_regress/t/t_interface_bind_public.v @@ -44,7 +44,7 @@ module t .io_success(success) ); - integer cyc=0; + integer cyc = 0; always @ (posedge clk) begin cyc = cyc + 1; diff --git a/test_regress/t/t_interface_dups.v b/test_regress/t/t_interface_dups.v index d434618f5..70de3f0c3 100644 --- a/test_regress/t/t_interface_dups.v +++ b/test_regress/t/t_interface_dups.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -57,11 +57,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -73,7 +73,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h6fd1bead9df31b07 diff --git a/test_regress/t/t_interface_gen2.v b/test_regress/t/t_interface_gen2.v index 83d5643db..703a31a83 100644 --- a/test_regress/t/t_interface_gen2.v +++ b/test_regress/t/t_interface_gen2.v @@ -24,7 +24,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d result=%b %b\n",$time, cyc, itopa.valueo, itopb.valueo); + $write("[%0t] cyc==%0d result=%b %b\n", $time, cyc, itopa.valueo, itopb.valueo); `endif cyc <= cyc + 1; itopa.valuei <= cyc[1:0]; diff --git a/test_regress/t/t_interface_gen3.v b/test_regress/t/t_interface_gen3.v index 59833d42c..7e8c92141 100644 --- a/test_regress/t/t_interface_gen3.v +++ b/test_regress/t/t_interface_gen3.v @@ -24,7 +24,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d result=%b %b\n",$time, cyc, itopa.valueo, itopb.valueo); + $write("[%0t] cyc==%0d result=%b %b\n", $time, cyc, itopa.valueo, itopb.valueo); `endif cyc <= cyc + 1; itopa.valuei <= cyc[1:0]; diff --git a/test_regress/t/t_interface_ref_trace.v b/test_regress/t/t_interface_ref_trace.v index 4de2cd2c2..a3fabda04 100644 --- a/test_regress/t/t_interface_ref_trace.v +++ b/test_regress/t/t_interface_ref_trace.v @@ -23,7 +23,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; ifc intf_1(.*); ifc intf_2(.*); diff --git a/test_regress/t/t_math_clog2.v b/test_regress/t/t_math_clog2.v index 713cb15f5..fdf68602e 100644 --- a/test_regress/t/t_math_clog2.v +++ b/test_regress/t/t_math_clog2.v @@ -16,7 +16,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -37,11 +37,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin crc <= 64'h0; if (`CLOG2(32'h0) != 0) $stop; @@ -82,7 +82,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hcbc77bb9b3784ea0) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_cmp.v b/test_regress/t/t_math_cmp.v index bf5dc80e4..203c39416 100644 --- a/test_regress/t/t_math_cmp.v +++ b/test_regress/t/t_math_cmp.v @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ .index_a (index_a), .index_b (index_b)); - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; initial index_a = 3'b0; initial index_b = 3'b0; always @* begin @@ -117,7 +117,7 @@ module prover ( reg [7:0] exp; reg [7:0] got; - integer cyc=0; + integer cyc = 0; always @ (posedge clk) begin cyc <= cyc + 1; if (cyc>2) begin diff --git a/test_regress/t/t_math_concat0.v b/test_regress/t/t_math_concat0.v index fd18e18aa..3ba29abb7 100644 --- a/test_regress/t/t_math_concat0.v +++ b/test_regress/t/t_math_concat0.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -54,7 +54,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h09be74b1b0f8c35d diff --git a/test_regress/t/t_math_cond_clean.v b/test_regress/t/t_math_cond_clean.v index ca804c671..3c05b9dbf 100644 --- a/test_regress/t/t_math_cond_clean.v +++ b/test_regress/t/t_math_cond_clean.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -36,11 +36,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h7cd85c944415d2ef diff --git a/test_regress/t/t_math_cond_huge.v b/test_regress/t/t_math_cond_huge.v index 22b9e65dd..f0e72273a 100644 --- a/test_regress/t/t_math_cond_huge.v +++ b/test_regress/t/t_math_cond_huge.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -298,11 +298,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -313,7 +313,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_const.v b/test_regress/t/t_math_const.v index 11bd286eb..8580a714c 100644 --- a/test_regress/t/t_math_const.v +++ b/test_regress/t/t_math_const.v @@ -41,7 +41,7 @@ module t (/*AUTOARG*/ if (cyc!=0) begin cyc <= cyc + 1; if (cyc==1) begin - $write("[%0t] t_const: Running\n",$time); + $write("[%0t] t_const: Running\n", $time); con1 = 4_0'h1000_0010; // Odd but legal _ in width con2 = 40'h10_0000_0010; diff --git a/test_regress/t/t_math_countbits.v b/test_regress/t/t_math_countbits.v index 547263faa..33890f07a 100644 --- a/test_regress/t/t_math_countbits.v +++ b/test_regress/t/t_math_countbits.v @@ -70,7 +70,7 @@ module t(/*AUTOARG*/ logic [31:0] val = 32'h70008421; - integer cyc=0; + integer cyc = 0; // Test loop always @ (posedge clk) begin cyc <= cyc + 1; diff --git a/test_regress/t/t_math_eq.v b/test_regress/t/t_math_eq.v index 13f0f866f..1ab0e9495 100644 --- a/test_regress/t/t_math_eq.v +++ b/test_regress/t/t_math_eq.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_imm.v b/test_regress/t/t_math_imm.v index 6ef2eb10a..e5019a4b0 100644 --- a/test_regress/t/t_math_imm.v +++ b/test_regress/t/t_math_imm.v @@ -17,7 +17,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [7:0] crc; reg [63:0] sum; @@ -48,7 +48,7 @@ module t (/*AUTOARG*/ cyc <= cyc + 1; crc <= {crc[6:0], ~^ {crc[7],crc[5],crc[4],crc[3]}}; `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%b %d.%d,%d.%d -> %x.%x -> %x\n",$time, cyc, crc, + $write("[%0t] cyc==%0d crc=%b %d.%d,%d.%d -> %x.%x -> %x\n", $time, cyc, crc, LowMaskSel_Top, HighMaskSel_Top, LowMaskSel_Bot, HighMaskSel_Bot, LowLogicImm, HighLogicImm, LogicImm); `endif @@ -66,7 +66,7 @@ module t (/*AUTOARG*/ sum <= {sum[62:0],sum[63]} ^ LogicImm; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%b %x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%b %x\n", $time, cyc, crc, sum); if (crc !== 8'b00111000) $stop; if (sum !== 64'h58743ffa61e41075) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_mul.v b/test_regress/t/t_math_mul.v index f83c751e0..a63ceb249 100644 --- a/test_regress/t/t_math_mul.v +++ b/test_regress/t/t_math_mul.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -21,10 +21,10 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x sum=%x out=%x %x\n",$time, cyc, crc, sum, out1, out2); + $write("[%0t] cyc==%0d crc=%x sum=%x out=%x %x\n", $time, cyc, crc, sum, out1, out2); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {sum[62:0], sum[63]^sum[2]^sum[0]} ^ {out2,out1}; if (cyc==1) begin // Setup diff --git a/test_regress/t/t_math_pick.v b/test_regress/t/t_math_pick.v index 03ccdb90d..9f8aa5c17 100644 --- a/test_regress/t/t_math_pick.v +++ b/test_regress/t/t_math_pick.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -54,7 +54,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h3ff4bf0e6407b281 diff --git a/test_regress/t/t_math_pow2.v b/test_regress/t/t_math_pow2.v index f181f6d21..9ecc6fd91 100644 --- a/test_regress/t/t_math_pow2.v +++ b/test_regress/t/t_math_pow2.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -23,11 +23,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -39,7 +39,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h056ea1c5a63aff6a if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_math_pow4.v b/test_regress/t/t_math_pow4.v index 092bcbc0f..a7488e610 100644 --- a/test_regress/t/t_math_pow4.v +++ b/test_regress/t/t_math_pow4.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; wire [31:0] y; reg a; @@ -23,7 +23,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d a=%x y=%x\n",$time, cyc, a, y); + $write("[%0t] cyc==%0d a=%x y=%x\n", $time, cyc, a, y); `endif cyc <= cyc + 1; if (cyc==0) begin diff --git a/test_regress/t/t_math_precedence.v b/test_regress/t/t_math_precedence.v index bae1119c9..46a6b8d3a 100644 --- a/test_regress/t/t_math_precedence.v +++ b/test_regress/t/t_math_precedence.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -105,7 +105,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x ",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x ", $time, cyc, crc, result); $write(" %b",o1); $write(" %b",o2); $write(" %b",o3); @@ -136,8 +136,8 @@ module t (/*AUTOARG*/ $write("\n"); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -149,7 +149,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h2756ea365ec7520e diff --git a/test_regress/t/t_math_real.v b/test_regress/t/t_math_real.v index dc94b5aa3..856547a66 100644 --- a/test_regress/t/t_math_real.v +++ b/test_regress/t/t_math_real.v @@ -28,7 +28,7 @@ module t (/*AUTOARG*/ reg [95:0] ci96; reg signed [95:0] cis96; real r, r2; - integer cyc=0; + integer cyc = 0; realtime uninit; initial if (uninit != 0.0) $stop; @@ -139,7 +139,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; if (cyc==0) begin diff --git a/test_regress/t/t_math_real_random.v b/test_regress/t/t_math_real_random.v index 02c86774f..f17e2ddaf 100644 --- a/test_regress/t/t_math_real_random.v +++ b/test_regress/t/t_math_real_random.v @@ -12,7 +12,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -47,10 +47,10 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d in=%x\n",$time, cyc, in); + $write("[%0t] cyc==%0d in=%x\n", $time, cyc, in); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; diff --git a/test_regress/t/t_math_real_round.v b/test_regress/t/t_math_real_round.v index 5c6a56870..50ca98a95 100644 --- a/test_regress/t/t_math_real_round.v +++ b/test_regress/t/t_math_real_round.v @@ -15,7 +15,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; real r; reg [31:0] v32; diff --git a/test_regress/t/t_math_red.v b/test_regress/t/t_math_red.v index 10cb292b8..fbd156940 100644 --- a/test_regress/t/t_math_red.v +++ b/test_regress/t/t_math_red.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [67:0] r; diff --git a/test_regress/t/t_math_shift_rep.v b/test_regress/t/t_math_shift_rep.v index cd0011fe1..d7e1ad0ec 100644 --- a/test_regress/t/t_math_shift_rep.v +++ b/test_regress/t/t_math_shift_rep.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -36,11 +36,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h0 diff --git a/test_regress/t/t_math_shift_sel.v b/test_regress/t/t_math_shift_sel.v index e0b20211c..3a78512b4 100644 --- a/test_regress/t/t_math_shift_sel.v +++ b/test_regress/t/t_math_shift_sel.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -36,11 +36,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hc746017202a24ecc diff --git a/test_regress/t/t_math_shortreal.v b/test_regress/t/t_math_shortreal.v index 2d62cef84..554297b44 100644 --- a/test_regress/t/t_math_shortreal.v +++ b/test_regress/t/t_math_shortreal.v @@ -18,7 +18,7 @@ module t (/*AUTOARG*/ integer i; reg [63:0] b; shortreal r, r2; - integer cyc=0; + integer cyc = 0; realtime uninit; initial if (uninit != 0.0) $stop; @@ -86,7 +86,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; if (cyc==0) begin diff --git a/test_regress/t/t_math_signed.v b/test_regress/t/t_math_signed.v index fc92d0d35..9bdc5d362 100644 --- a/test_regress/t/t_math_signed.v +++ b/test_regress/t/t_math_signed.v @@ -98,7 +98,7 @@ module t (/*AUTOARG*/ copy_signed = ai; endfunction - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; wire [31:0] ucyc = cyc; always @ (posedge clk) begin cyc <= cyc + 1; @@ -181,7 +181,7 @@ module by_width ( wire signed [WIDTH-1:0] i65ext = i65; // verilator lint_on WIDTH - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; always @ (posedge clk) begin cyc <= cyc + 1; i1 <= cyc[0]; diff --git a/test_regress/t/t_math_signed_wire.v b/test_regress/t/t_math_signed_wire.v index 0ddd9fa97..0f0d3fc62 100644 --- a/test_regress/t/t_math_signed_wire.v +++ b/test_regress/t/t_math_signed_wire.v @@ -20,7 +20,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] result=%x %x\n",$time, au, as); + $write("[%0t] result=%x %x\n", $time, au, as); `endif if (au != 'h12) $stop; if (as != 'h02) $stop; diff --git a/test_regress/t/t_math_swap.v b/test_regress/t/t_math_swap.v index f5a78c2f3..e59e1c5d8 100644 --- a/test_regress/t/t_math_swap.v +++ b/test_regress/t/t_math_swap.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -48,13 +48,13 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x it=%x\n",$time, cyc, crc, result, test.Iteration); + $write("[%0t] cyc==%0d crc=%x result=%x it=%x\n", $time, cyc, crc, result, test.Iteration); `endif cyc <= cyc + 1; if (cyc < 20 || test.Iteration==4'd15) begin - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; end - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -67,7 +67,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'h8dd70a44972ad809) $stop; if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_trig.v b/test_regress/t/t_math_trig.v index a87816e80..61204358c 100644 --- a/test_regress/t/t_math_trig.v +++ b/test_regress/t/t_math_trig.v @@ -13,7 +13,7 @@ module t (/*AUTOARG*/ input clk; real r, r2; - integer cyc=0; + integer cyc = 0; task check(integer line, real got, real ex); if (got != ex) begin @@ -90,7 +90,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin r = $itor(cyc)/10.0 - 5.0; // Crosses 0 `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d r=%g s_ln=%0.12g\n",$time, cyc, r, sum_ln); + $write("[%0t] cyc==%0d r=%g s_ln=%0.12g\n", $time, cyc, r, sum_ln); `endif cyc <= cyc + 1; if (cyc==0) begin diff --git a/test_regress/t/t_math_vliw.v b/test_regress/t/t_math_vliw.v index bf6ab7291..42ba7ff86 100644 --- a/test_regress/t/t_math_vliw.v +++ b/test_regress/t/t_math_vliw.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [7:0] crc; reg [223:0] sum; @@ -42,11 +42,11 @@ module t (/*AUTOARG*/ sum <= 224'h0; end else if (cyc<90) begin - //$write("[%0t] cyc==%0d BXI=%x\n",$time, cyc, bxiouf); + //$write("[%0t] cyc==%0d BXI=%x\n", $time, cyc, bxiouf); sum <= {sum[222:0],sum[223]} ^ bxiouf; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%b %x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%b %x\n", $time, cyc, crc, sum); if (crc !== 8'b01110000) $stop; if (sum !== 224'h1fdff998855c3c38d467e28124847831f9ad6d4a09f2801098f032a8) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_math_yosys.v b/test_regress/t/t_math_yosys.v index 9fe06d075..e72ac511d 100644 --- a/test_regress/t/t_math_yosys.v +++ b/test_regress/t/t_math_yosys.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; /*AUTOWIRE*/ // Beginning of automatic wires (for undeclared instantiated-module outputs) diff --git a/test_regress/t/t_mem_fifo.v b/test_regress/t/t_mem_fifo.v index 8702c4969..d4bdc2425 100644 --- a/test_regress/t/t_mem_fifo.v +++ b/test_regress/t/t_mem_fifo.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; wire [65:0] outData; // From fifo of fifo.v @@ -33,9 +33,9 @@ module t (/*AUTOARG*/ .wrEn (wrEn)); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%b q=%x\n",$time, cyc, crc, outData); + //$write("[%0t] cyc==%0d crc=%b q=%x\n", $time, cyc, crc, outData); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; diff --git a/test_regress/t/t_mem_file.v b/test_regress/t/t_mem_file.v index e1a7574ed..9284d9fba 100644 --- a/test_regress/t/t_mem_file.v +++ b/test_regress/t/t_mem_file.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -49,10 +49,10 @@ module t (/*AUTOARG*/ .w2_d (w2_d[63:0])); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d EN=%b%b%b%b R0=%x R1=%x\n",$time, cyc, r1_en,r2_en,w1_en,w2_en, r1_d_d2r, r2_d_d2r); + //$write("[%0t] cyc==%0d EN=%b%b%b%b R0=%x R1=%x\n", $time, cyc, r1_en,r2_en,w1_en,w2_en, r1_d_d2r, r2_d_d2r); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= {r1_d_d2r ^ r2_d_d2r} ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= {r1_d_d2r ^ r2_d_d2r} ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -65,7 +65,7 @@ module t (/*AUTOARG*/ end else if (cyc==99) begin $write("*-* All Finished *-*\n"); - $write("[%0t] cyc==%0d crc=%x %x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x %x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== 64'h5e9ea8c33a97f81e) $stop; $finish; diff --git a/test_regress/t/t_mem_func.v b/test_regress/t/t_mem_func.v index 22ca9e223..c9c1077a9 100644 --- a/test_regress/t/t_mem_func.v +++ b/test_regress/t/t_mem_func.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h58b162c58d6e35ba if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_mem_iforder.v b/test_regress/t/t_mem_iforder.v index 1c044fc6f..93e35744a 100644 --- a/test_regress/t/t_mem_iforder.v +++ b/test_regress/t/t_mem_iforder.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [31:0] sum; @@ -36,9 +36,9 @@ module t (/*AUTOARG*/ .inData (inData[15:0])); always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%x q=%x\n",$time, cyc, crc, sum); + //$write("[%0t] cyc==%0d crc=%x q=%x\n", $time, cyc, crc, sum); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; diff --git a/test_regress/t/t_mem_multidim.v b/test_regress/t/t_mem_multidim.v index cee7bcd29..3d09878cc 100644 --- a/test_regress/t/t_mem_multidim.v +++ b/test_regress/t/t_mem_multidim.v @@ -18,7 +18,7 @@ module t (/*AUTOARG*/ reg [7:0] memn [2:0][1:3][5:2]; // verilator lint_on BLKANDNBLK - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [71:0] wide; reg [7:0] narrow; @@ -62,7 +62,7 @@ module t (/*AUTOARG*/ index0 <= crc[1:0]; index1 <= crc[3:2]; index2 <= crc[6:4]; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; // We never read past bounds, or get unspecific results // We also never read lowest indexes, as writing outside of range may corrupt them @@ -88,7 +88,7 @@ module t (/*AUTOARG*/ else if (cyc==91) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x nar=%x wide=%x\n",$time, cyc, crc, narrow, wide); + $write("[%0t] cyc==%0d crc=%x nar=%x wide=%x\n", $time, cyc, crc, narrow, wide); if (crc != 64'h65e3bddcd9bc2750) $stop; if (narrow != 8'hca) $stop; if (wide != 72'h4edafed31ba6873f73) $stop; diff --git a/test_regress/t/t_mem_multiwire.v b/test_regress/t/t_mem_multiwire.v index 663df9be3..c031b44ce 100644 --- a/test_regress/t/t_mem_multiwire.v +++ b/test_regress/t/t_mem_multiwire.v @@ -16,7 +16,7 @@ module t (/*AUTOARG*/ wire [7:0] arrayNoColon [2][3]; // verilator lint_on LITENDIAN - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; integer i0,i1,i2; genvar g0,g1,g2; diff --git a/test_regress/t/t_mem_packed.v b/test_regress/t/t_mem_packed.v index 52a38bf9d..2a90a7462 100644 --- a/test_regress/t/t_mem_packed.v +++ b/test_regress/t/t_mem_packed.v @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ sum_w <= sum_w + arr_w[cyc-10]; end else if (cyc==99) begin - $write("[%0t] cyc==%0d sum=%x\n",$time, cyc, sum); + $write("[%0t] cyc==%0d sum=%x\n", $time, cyc, sum); if (sum != 8'h55) $stop; if (sum != sum_w) $stop; $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_mem_shift.v b/test_regress/t/t_mem_shift.v index 9302f09e1..a2e84d6cf 100644 --- a/test_regress/t/t_mem_shift.v +++ b/test_regress/t/t_mem_shift.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; integer i; @@ -34,9 +34,9 @@ module t (/*AUTOARG*/ wire [63:0] outData = mem[7]; always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%b q=%x\n",$time, cyc, crc, outData); + //$write("[%0t] cyc==%0d crc=%b q=%x\n", $time, cyc, crc, outData); cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; diff --git a/test_regress/t/t_mem_slice_conc_bad.v b/test_regress/t/t_mem_slice_conc_bad.v index 2f7118f1f..cca91bb24 100644 --- a/test_regress/t/t_mem_slice_conc_bad.v +++ b/test_regress/t/t_mem_slice_conc_bad.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ rst <= 1'b0; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h4afe43fb79d7b71e diff --git a/test_regress/t/t_mem_twoedge.v b/test_regress/t/t_mem_twoedge.v index 9c241853c..8d4f48303 100644 --- a/test_regress/t/t_mem_twoedge.v +++ b/test_regress/t/t_mem_twoedge.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -41,16 +41,16 @@ module t (/*AUTOARG*/ // Test loop `ifdef TEST_VERBOSE always @ (negedge clk) begin - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); end `endif always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -64,7 +64,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hc68a94a34ec970aa diff --git a/test_regress/t/t_merge_cond.v b/test_regress/t/t_merge_cond.v index 2484c11cc..110ebcc43 100644 --- a/test_regress/t/t_merge_cond.v +++ b/test_regress/t/t_merge_cond.v @@ -12,13 +12,13 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc= 64'h5aef0c8d_d70a4497; reg [63:0] prev_crc; always @ (posedge clk) begin cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; prev_crc <= crc; if (cyc==99) begin diff --git a/test_regress/t/t_mod_recurse.v b/test_regress/t/t_mod_recurse.v index 096843aad..370900e77 100644 --- a/test_regress/t/t_mod_recurse.v +++ b/test_regress/t/t_mod_recurse.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -31,11 +31,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -47,7 +47,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hc5fc632f816568fb diff --git a/test_regress/t/t_optm_redor.v b/test_regress/t/t_optm_redor.v index 11df0a68f..b902bcdca 100644 --- a/test_regress/t/t_optm_redor.v +++ b/test_regress/t/t_optm_redor.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h162c58b1635b8d6e diff --git a/test_regress/t/t_order.v b/test_regress/t/t_order.v index 3613c85c9..6ec373cbe 100644 --- a/test_regress/t/t_order.v +++ b/test_regress/t/t_order.v @@ -29,7 +29,7 @@ module t (/*AUTOARG*/ wire [7:0] o_subfrom_clk_lev2; // From b of t_order_b.v // End of automatics - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; t_order_a a ( .one (8'h1), @@ -89,7 +89,7 @@ module t (/*AUTOARG*/ end if (cyc == 8'd3) begin - $display("%d %d %d %d",m_from_clk_lev1_r, + $display("%d %d %d %d", m_from_clk_lev1_r, n_from_clk_lev2, o_from_com_levs11, o_from_comandclk_levs12); diff --git a/test_regress/t/t_order_2d.v b/test_regress/t/t_order_2d.v index 84e45021b..32132d1b1 100644 --- a/test_regress/t/t_order_2d.v +++ b/test_regress/t/t_order_2d.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h765b2e12b25ec97b diff --git a/test_regress/t/t_order_clkinst.v b/test_regress/t/t_order_clkinst.v index 859224e98..048f5851b 100644 --- a/test_regress/t/t_order_clkinst.v +++ b/test_regress/t/t_order_clkinst.v @@ -28,9 +28,9 @@ module t (/*AUTOARG*/ wire [31:0] c3_count; comb_loop c3 (.count(c3_count), .start(c3_start)); - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; always @ (posedge clk) begin - //$write("[%0t] %x counts %x %x %x\n",$time,cyc,c1_count,s2_count,c3_count); + //$write("[%0t] %x counts %x %x %x\n", $time,cyc,c1_count,s2_count,c3_count); cyc <= cyc + 8'd1; case (cyc) 8'd00: begin diff --git a/test_regress/t/t_order_comboclkloop.v b/test_regress/t/t_order_comboclkloop.v index 373c510bd..a4360e2f1 100644 --- a/test_regress/t/t_order_comboclkloop.v +++ b/test_regress/t/t_order_comboclkloop.v @@ -29,7 +29,7 @@ module t (/*AUTOARG*/ if ((runner & 32'hf)!=0) begin runcount = runcount + 1; runner = runnerm1; - $write (" seq runcount=%0d runner =%0x\n",runcount, runnerm1); + $write(" seq runcount=%0d runner =%0x\n", runcount, runnerm1); end run0 = (runner[8:4]!=0 && runner[3:0]==0); end @@ -42,9 +42,9 @@ module t (/*AUTOARG*/ $write ("[%0t] posedge runner=%0x\n", $time, runner); end - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; always @ (posedge clk) begin - $write("[%0t] %x counts %0x %0x\n",$time,cyc,runcount,clkcount); + $write("[%0t] %x counts %0x %0x\n", $time, cyc, runcount, clkcount); cyc <= cyc + 8'd1; case (cyc) 8'd00: begin diff --git a/test_regress/t/t_order_doubleloop.v b/test_regress/t/t_order_doubleloop.v index c0a32f4d9..8607ccc96 100644 --- a/test_regress/t/t_order_doubleloop.v +++ b/test_regress/t/t_order_doubleloop.v @@ -26,7 +26,7 @@ module t (/*AUTOARG*/ reg [31:0] dlyrun; initial dlyrun = 0; reg [31:0] dlyrunm1; always @ (posedge clk) begin - $write("[%0t] cyc %d\n",$time,cyc); + $write("[%0t] cyc %d\n", $time,cyc); cyc <= cyc + 1; if (cyc==2) begin // Test # of iters @@ -74,7 +74,7 @@ module t (/*AUTOARG*/ if (comrun!=0) begin comrunm1 = comrun - 32'd1; comcnt = comcnt + 32'd1; - $write("[%0t] comcnt=%0d\n",$time,comcnt); + $write("[%0t] comcnt=%0d\n", $time,comcnt); end end diff --git a/test_regress/t/t_param_array6.v b/test_regress/t/t_param_array6.v index 34766e731..708935749 100644 --- a/test_regress/t/t_param_array6.v +++ b/test_regress/t/t_param_array6.v @@ -49,7 +49,7 @@ module t import test_pkg::*; (clk); $display("rand: %h / Values -> val_1: %d / val_2: %d", random, temp.val_1, temp.val_2); `endif if (cyc > 10 && cyc < 90) begin - sum <= {48'h0, temp} ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + sum <= {48'h0, temp} ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; end else if (cyc == 99) begin $displayh(sum); diff --git a/test_regress/t/t_param_if_blk.v b/test_regress/t/t_param_if_blk.v index b2a71800d..b3a24bfdf 100644 --- a/test_regress/t/t_param_if_blk.v +++ b/test_regress/t/t_param_if_blk.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -39,11 +39,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -55,7 +55,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h9d550d82d38926fa diff --git a/test_regress/t/t_param_sel.v b/test_regress/t/t_param_sel.v index 3c91fef16..d79ed9d18 100644 --- a/test_regress/t/t_param_sel.v +++ b/test_regress/t/t_param_sel.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hf9b3a5000165ed38 diff --git a/test_regress/t/t_past.v b/test_regress/t/t_past.v index 6f5a353b0..250810185 100644 --- a/test_regress/t/t_past.v +++ b/test_regress/t/t_past.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -30,7 +30,7 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; diff --git a/test_regress/t/t_pgo_profoutofdate_bad.v b/test_regress/t/t_pgo_profoutofdate_bad.v index cba43da97..43a2b1b8d 100755 --- a/test_regress/t/t_pgo_profoutofdate_bad.v +++ b/test_regress/t/t_pgo_profoutofdate_bad.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; // Test loop always @ (posedge clk) begin diff --git a/test_regress/t/t_prof.v b/test_regress/t/t_prof.v index ae605781c..ee63a2f6b 100644 --- a/test_regress/t/t_prof.v +++ b/test_regress/t/t_prof.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; wire [63:0] result; Test test(/*AUTOINST*/ @@ -25,10 +25,10 @@ module t(/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d result=%x\n",$time, cyc, result); + $write("[%0t] cyc==%0d result=%x\n", $time, cyc, result); `endif cyc <= cyc + 1; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup sum <= '0; @@ -39,7 +39,7 @@ module t(/*AUTOARG*/ else if (cyc < 90) begin end else if (cyc == 99) begin - $write("[%0t] cyc==%0d sum=%x\n",$time, cyc, sum); + $write("[%0t] cyc==%0d sum=%x\n", $time, cyc, sum); // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hfefad16f06ba6b1f if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_prot_lib.v b/test_regress/t/t_prot_lib.v index b0195a940..d3dad3679 100644 --- a/test_regress/t/t_prot_lib.v +++ b/test_regress/t/t_prot_lib.v @@ -107,7 +107,7 @@ module t #(parameter GATED_CLK = 0) (/*AUTOARG*/ $time, x, cyc, accum_in, accum_out, accum_bypass_out); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; accum_in <= accum_in + 5; `DRIVE(s1) `DRIVE(s2) diff --git a/test_regress/t/t_queue.v b/test_regress/t/t_queue.v index 0d3ded455..3c5db893c 100644 --- a/test_regress/t/t_queue.v +++ b/test_regress/t/t_queue.v @@ -15,7 +15,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; integer i; diff --git a/test_regress/t/t_reloop_cam.v b/test_regress/t/t_reloop_cam.v index 4333577ec..5c568524f 100644 --- a/test_regress/t/t_reloop_cam.v +++ b/test_regress/t/t_reloop_cam.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; reg rst; @@ -59,11 +59,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -81,7 +81,7 @@ module t (/*AUTOARG*/ inval <= 1'b0; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h5182640870b07199 if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_savable.v b/test_regress/t/t_savable.v index 1fc854566..3edc34885 100644 --- a/test_regress/t/t_savable.v +++ b/test_regress/t/t_savable.v @@ -30,7 +30,7 @@ module sub (/*AUTOARG*/ input clk; /*verilator no_inline_module*/ // So we'll get hiearachy we can test - integer cyc=0; + integer cyc = 0; reg [127:0] save128; reg [47:0] save48; @@ -48,7 +48,7 @@ module sub (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d\n",$time, cyc); + $write("[%0t] cyc==%0d\n", $time, cyc); `endif si = "siimmed"; cyc <= cyc + 1; diff --git a/test_regress/t/t_select_2d.v b/test_regress/t/t_select_2d.v index bbe492e52..4de9b5f01 100644 --- a/test_regress/t/t_select_2d.v +++ b/test_regress/t/t_select_2d.v @@ -10,7 +10,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t(/*AUTOARG*/ else if (cyc < 90) begin end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h1f324087bbba0bfa diff --git a/test_regress/t/t_select_bad_range2.v b/test_regress/t/t_select_bad_range2.v index ae1ab47d9..0efb7ce2d 100644 --- a/test_regress/t/t_select_bad_range2.v +++ b/test_regress/t/t_select_bad_range2.v @@ -29,7 +29,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin in <= in + 1; `ifdef TEST_VERBOSE - $write("[%0t] in=%d out32=%d out10=%d\n",$time, in, out32, out10); + $write("[%0t] in=%d out32=%d out10=%d\n", $time, in, out32, out10); `endif if (in==3) begin $write("*-* All Finished *-*\n"); diff --git a/test_regress/t/t_select_bound1.v b/test_regress/t/t_select_bound1.v index af2861c60..07f38acbf 100644 --- a/test_regress/t/t_select_bound1.v +++ b/test_regress/t/t_select_bound1.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x out=%b mask=%b\n",$time, cyc, crc, out, mask); + $write("[%0t] cyc==%0d crc=%x out=%b mask=%b\n", $time, cyc, crc, out, mask); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -54,7 +54,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'ha9d3a7a69d2bea75 diff --git a/test_regress/t/t_select_bound2.v b/test_regress/t/t_select_bound2.v index 681a92457..c414fbfc0 100644 --- a/test_regress/t/t_select_bound2.v +++ b/test_regress/t/t_select_bound2.v @@ -11,7 +11,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -38,11 +38,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x out=%b mask=%b\n",$time, cyc, crc, out, mask); + $write("[%0t] cyc==%0d crc=%x out=%b mask=%b\n", $time, cyc, crc, out, mask); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -54,7 +54,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h4e9d3a74e9d3f656 diff --git a/test_regress/t/t_select_lhs_oob.v b/test_regress/t/t_select_lhs_oob.v index b34470849..826d794a9 100644 --- a/test_regress/t/t_select_lhs_oob.v +++ b/test_regress/t/t_select_lhs_oob.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ clk ); input clk; - integer cyc=0; + integer cyc = 0; reg [6:0] mem1d; reg [6:0] mem2d [5:0]; @@ -57,7 +57,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d reg2d[%0d]=%0x wd=%0x\n",$time, cyc, wi[2:0], reg2d[wi[2:0]], wd); + $write("[%0t] cyc==%0d reg2d[%0d]=%0x wd=%0x\n", $time, cyc, wi[2:0], reg2d[wi[2:0]], wd); `endif cyc <= cyc + 1; if (cyc<10) begin diff --git a/test_regress/t/t_select_lhs_oob2.v b/test_regress/t/t_select_lhs_oob2.v index 10cff1cf9..81d634caf 100644 --- a/test_regress/t/t_select_lhs_oob2.v +++ b/test_regress/t/t_select_lhs_oob2.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -43,11 +43,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -59,7 +59,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h421a41d1541ea652 diff --git a/test_regress/t/t_select_little.v b/test_regress/t/t_select_little.v index 2b7b9e93c..b33d7a137 100644 --- a/test_regress/t/t_select_little.v +++ b/test_regress/t/t_select_little.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -47,12 +47,12 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] sels=%x,%x,%x,%x %x,%x,%x,%x\n",$time, out20,out21,out22,out23, out30,out31,out32,out33); - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] sels=%x,%x,%x,%x %x,%x,%x,%x\n", $time, out20,out21,out22,out23, out30,out31,out32,out33); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -63,7 +63,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'h28bf65439eb12c00 if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_select_negative.v b/test_regress/t/t_select_negative.v index bd0e66687..e62df8185 100644 --- a/test_regress/t/t_select_negative.v +++ b/test_regress/t/t_select_negative.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -42,12 +42,12 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] sels=%x,%x,%x %x,%x,%x\n",$time, out21,out22,out23, out31,out32,out33); - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] sels=%x,%x,%x %x,%x,%x\n", $time, out21,out22,out23, out31,out32,out33); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -58,7 +58,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; `define EXPECTED_SUM 64'hba7fe1e7ac128362 if (sum !== `EXPECTED_SUM) $stop; diff --git a/test_regress/t/t_select_plus.v b/test_regress/t/t_select_plus.v index 247f166f8..11ed4a9bc 100644 --- a/test_regress/t/t_select_plus.v +++ b/test_regress/t/t_select_plus.v @@ -17,7 +17,7 @@ module t (/*AUTOARG*/ reg [3:0] nibblep; reg [3:0] nibblem; - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; always @* begin nibblep = from[bitn +: 4]; @@ -28,7 +28,7 @@ module t (/*AUTOARG*/ end always @ (posedge clk) begin - //$write("[%0t] cyc==%d nibblep==%b nibblem==%b to^from==%x\n",$time, cyc, nibblep, nibblem, from^to); + //$write("[%0t] cyc==%d nibblep==%b nibblem==%b to^from==%x\n", $time, cyc, nibblep, nibblem, from^to); cyc <= cyc + 8'd1; case (cyc) 8'd00: begin from<=80'h7bea9d779b67e48f67da; bitn<=7'd7; end diff --git a/test_regress/t/t_select_plus_mul_pow2.v b/test_regress/t/t_select_plus_mul_pow2.v index d533b88ab..6126383a5 100644 --- a/test_regress/t/t_select_plus_mul_pow2.v +++ b/test_regress/t/t_select_plus_mul_pow2.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ reg [63:0] from = 64'h0706050403020100; reg [7:0] to; reg [2:0] bitn; - reg [7:0] cyc; initial cyc=0; + reg [7:0] cyc; initial cyc = 0; always @* begin to = from[bitn * 8 +: 8]; diff --git a/test_regress/t/t_select_plusloop.v b/test_regress/t/t_select_plusloop.v index 58249e4ee..7a5ee64f0 100644 --- a/test_regress/t/t_select_plusloop.v +++ b/test_regress/t/t_select_plusloop.v @@ -15,12 +15,12 @@ module t (/*AUTOARG*/ reg [63:0] quad; reg [127:0] wide; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [7:0] crc; reg [6:0] index; always @ (posedge clk) begin - //$write("[%0t] cyc==%0d crc=%b n=%x\n",$time, cyc, crc, narrow); + //$write("[%0t] cyc==%0d crc=%b n=%x\n", $time, cyc, crc, narrow); cyc <= cyc + 1; if (cyc==0) begin // Setup @@ -54,7 +54,7 @@ module t (/*AUTOARG*/ wide[81] <=1'b1; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%b n=%x q=%x w=%x\n",$time, cyc, crc, narrow, quad, wide); + $write("[%0t] cyc==%0d crc=%b n=%x q=%x w=%x\n", $time, cyc, crc, narrow, quad, wide); if (crc != 8'b01111001) $stop; if (narrow != 32'h001661c7) $stop; if (quad != 64'h16d49b6f64266039) $stop; diff --git a/test_regress/t/t_select_runtime_range.v b/test_regress/t/t_select_runtime_range.v index b43330e11..40a57b989 100644 --- a/test_regress/t/t_select_runtime_range.v +++ b/test_regress/t/t_select_runtime_range.v @@ -53,10 +53,10 @@ module t (clk); end if (cyc==5) begin read = mi[index]; - $display("-Illegal read value: %x",read); + $display("-Illegal read value: %x", read); //if (read!==1'b1 && read!==1'bx) $stop; read = mi[indexi]; - $display("-Illegal read value: %x",read); + $display("-Illegal read value: %x", read); //if (read!==1'b1 && read!==1'bx) $stop; end if (cyc==6) begin @@ -64,7 +64,7 @@ module t (clk); end if (cyc==7) begin read = mi[indexi]; - $display("-Illegal read value: %x",read); + $display("-Illegal read value: %x", read); //if (read!==1'b1 && read!==1'bx) $stop; end if (cyc==10) begin diff --git a/test_regress/t/t_split_var_0.v b/test_regress/t/t_split_var_0.v index c317d5f9e..ee3db8562 100644 --- a/test_regress/t/t_split_var_0.v +++ b/test_regress/t/t_split_var_0.v @@ -289,7 +289,7 @@ module t_array_rev(clk); // from t_array_rev.v input clk; - integer cyc=0; + integer cyc = 0; // verilator lint_off LITENDIAN logic arrd [0:1] /*verilator split_var*/ = '{ 1'b1, 1'b0 }; // verilator lint_on LITENDIAN diff --git a/test_regress/t/t_split_var_3_wreal.v b/test_regress/t/t_split_var_3_wreal.v index 068fe0c7b..46cca2e2a 100644 --- a/test_regress/t/t_split_var_3_wreal.v +++ b/test_regress/t/t_split_var_3_wreal.v @@ -13,7 +13,7 @@ module t (/*autoarg*/ input clk; - integer cyc=0; + integer cyc = 0; real vin[0:1] /*verilator split_var*/; wreal vout[0:1] /*verilator split_var*/; diff --git a/test_regress/t/t_split_var_4.v b/test_regress/t/t_split_var_4.v index f8557f479..7b8a475bc 100644 --- a/test_regress/t/t_split_var_4.v +++ b/test_regress/t/t_split_var_4.v @@ -17,7 +17,7 @@ module t(/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -43,19 +43,19 @@ module t(/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); $display("o %b", o0); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc == 0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; sum <= '0; end else if (cyc == 99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hb58b16c592557b30 diff --git a/test_regress/t/t_stream2.v b/test_regress/t/t_stream2.v index 65d07ffe8..0fadf93ae 100644 --- a/test_regress/t/t_stream2.v +++ b/test_regress/t/t_stream2.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; /*AUTOWIRE*/ @@ -40,8 +40,8 @@ module t (/*AUTOARG*/ $time, cyc, crc, result, amt, left, right); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h0da01049b480c38a diff --git a/test_regress/t/t_stream3.v b/test_regress/t/t_stream3.v index 76e40a5fc..24b740bf3 100644 --- a/test_regress/t/t_stream3.v +++ b/test_regress/t/t_stream3.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; /*AUTOWIRE*/ @@ -34,7 +34,7 @@ module t (/*AUTOARG*/ $time, cyc, crc); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -46,7 +46,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h0 diff --git a/test_regress/t/t_string.v b/test_regress/t/t_string.v index 758d5744e..9e5327f37 100644 --- a/test_regress/t/t_string.v +++ b/test_regress/t/t_string.v @@ -13,7 +13,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [1*8:1] vstr1; reg [2*8:1] vstr2; diff --git a/test_regress/t/t_string_type_methods.v b/test_regress/t/t_string_type_methods.v index 85e410d71..db9597dbe 100644 --- a/test_regress/t/t_string_type_methods.v +++ b/test_regress/t/t_string_type_methods.v @@ -16,7 +16,7 @@ module t (/*AUTOARG*/ string s; - integer cyc=0; + integer cyc = 0; // Check constification initial begin diff --git a/test_regress/t/t_struct_port.v b/test_regress/t/t_struct_port.v index 58cf5beeb..45a75b527 100644 --- a/test_regress/t/t_struct_port.v +++ b/test_regress/t/t_struct_port.v @@ -16,7 +16,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -41,11 +41,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x in=%x result=%x\n",$time, cyc, crc, in, result); + $write("[%0t] cyc==%0d crc=%x in=%x result=%x\n", $time, cyc, crc, in, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -57,7 +57,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h99c434d9b08c2a8a diff --git a/test_regress/t/t_struct_portsel.v b/test_regress/t/t_struct_portsel.v index 3146a3eab..18f8133d0 100644 --- a/test_regress/t/t_struct_portsel.v +++ b/test_regress/t/t_struct_portsel.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -34,11 +34,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hdb7bc61592f31b99 diff --git a/test_regress/t/t_struct_unaligned.v b/test_regress/t/t_struct_unaligned.v index 8fdb06cb1..81c64f001 100644 --- a/test_regress/t/t_struct_unaligned.v +++ b/test_regress/t/t_struct_unaligned.v @@ -17,7 +17,7 @@ module t (/*AUTOARG*/ logic [130:0] data; } foo[1]; - integer cyc=0; + integer cyc = 0; // Test loop always @ (posedge clk) begin diff --git a/test_regress/t/t_sys_time.v b/test_regress/t/t_sys_time.v index 0a05a6cdb..81f0b1422 100644 --- a/test_regress/t/t_sys_time.v +++ b/test_regress/t/t_sys_time.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] time64; diff --git a/test_regress/t/t_table_fsm.v b/test_regress/t/t_table_fsm.v index f4d574288..4eab60786 100644 --- a/test_regress/t/t_table_fsm.v +++ b/test_regress/t/t_table_fsm.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; reg reset; @@ -36,11 +36,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x me=%0x mep=%x\n",$time, cyc, crc, result, myevent, myevent_pending); + $write("[%0t] cyc==%0d crc=%x result=%x me=%0x mep=%x\n", $time, cyc, crc, result, myevent, myevent_pending); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; reset <= (cyc<2); if (cyc==0) begin // Setup @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h4e93a74bd97b25ef diff --git a/test_regress/t/t_time_sc.v b/test_regress/t/t_time_sc.v index 50f48f359..fa799a00d 100644 --- a/test_regress/t/t_time_sc.v +++ b/test_regress/t/t_time_sc.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; time texpect = `TEST_EXPECT; diff --git a/test_regress/t/t_time_stamp64.v b/test_regress/t/t_time_stamp64.v index 2c965a83c..cd6c0aa27 100644 --- a/test_regress/t/t_time_stamp64.v +++ b/test_regress/t/t_time_stamp64.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; always @ (posedge clk) begin cyc <= cyc + 1; diff --git a/test_regress/t/t_trace_array.v b/test_regress/t/t_trace_array.v index 9622f78ff..e98e1de1a 100644 --- a/test_regress/t/t_trace_array.v +++ b/test_regress/t/t_trace_array.v @@ -6,7 +6,7 @@ module t (clk); input clk; - integer cyc=0; + integer cyc = 0; // Trace would overflow at 256KB which is 256 kb dump, 16 kb in a chunk diff --git a/test_regress/t/t_trace_complex.v b/test_regress/t/t_trace_complex.v index baae75453..9572e92dc 100644 --- a/test_regress/t/t_trace_complex.v +++ b/test_regress/t/t_trace_complex.v @@ -8,7 +8,7 @@ bit global_bit; module t (clk); input clk; - integer cyc=0; + integer cyc = 0; typedef struct packed { bit b1; diff --git a/test_regress/t/t_tri_array.v b/test_regress/t/t_tri_array.v index 7601f94f2..e79ba3d6d 100644 --- a/test_regress/t/t_tri_array.v +++ b/test_regress/t/t_tri_array.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -33,12 +33,12 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {60'h0, pad[3], pad[2], pad[1], pad[0]} - ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -50,7 +50,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'he09fe6f2dfd7a302 diff --git a/test_regress/t/t_tri_array_bufif.v b/test_regress/t/t_tri_array_bufif.v index 44489b7f6..1d0cb1d17 100644 --- a/test_regress/t/t_tri_array_bufif.v +++ b/test_regress/t/t_tri_array_bufif.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -46,11 +46,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x drv=%x %x (%b??%b:%b)\n",$time, cyc, crc, drv, drv2, drv_e,drv_a,drv_b); + $write("[%0t] cyc==%0d crc=%x drv=%x %x (%b??%b:%b)\n", $time, cyc, crc, drv, drv2, drv_e,drv_a,drv_b); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -63,7 +63,7 @@ module t (/*AUTOARG*/ if (drv2 != drv) $stop; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hd95d216c5a2945d0 diff --git a/test_regress/t/t_tri_eqcase.v b/test_regress/t/t_tri_eqcase.v index a922a4b94..7644426c9 100644 --- a/test_regress/t/t_tri_eqcase.v +++ b/test_regress/t/t_tri_eqcase.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -43,11 +43,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x m1=%x m2=%x (%b??%b:%b)\n",$time, cyc, crc, match1, match2, drv_e,drv_a,drv_b); + $write("[%0t] cyc==%0d crc=%x m1=%x m2=%x (%b??%b:%b)\n", $time, cyc, crc, match1, match2, drv_e,drv_a,drv_b); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -59,7 +59,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'hc0c4a2b9aea7c4b4 diff --git a/test_regress/t/t_tri_pull01.v b/test_regress/t/t_tri_pull01.v index 2d1248a9b..54d4b41e0 100644 --- a/test_regress/t/t_tri_pull01.v +++ b/test_regress/t/t_tri_pull01.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -40,11 +40,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -56,7 +56,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h04f91df71371e950 diff --git a/test_regress/t/t_tri_unconn.v b/test_regress/t/t_tri_unconn.v index 368c2638f..2cdf59228 100644 --- a/test_regress/t/t_tri_unconn.v +++ b/test_regress/t/t_tri_unconn.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; wire one = '1; wire z0 = 'z; diff --git a/test_regress/t/t_typedef_param.v b/test_regress/t/t_typedef_param.v index c9c98202f..8375d7a90 100644 --- a/test_regress/t/t_typedef_param.v +++ b/test_regress/t/t_typedef_param.v @@ -12,7 +12,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -46,11 +46,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -62,7 +62,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h018decfea0a8828a diff --git a/test_regress/t/t_typedef_port.v b/test_regress/t/t_typedef_port.v index 44d24d05d..2f0370710 100644 --- a/test_regress/t/t_typedef_port.v +++ b/test_regress/t/t_typedef_port.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ typedef reg [2:0] three_t; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -47,11 +47,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -63,7 +63,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h018decfea0a8828a diff --git a/test_regress/t/t_typedef_signed.v b/test_regress/t/t_typedef_signed.v index 0f7bf55ee..1f3d78b67 100644 --- a/test_regress/t/t_typedef_signed.v +++ b/test_regress/t/t_typedef_signed.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -39,11 +39,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -53,7 +53,7 @@ module t (/*AUTOARG*/ sum <= 64'h0; end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h7211d24a17b25ec9 diff --git a/test_regress/t/t_udp.v b/test_regress/t/t_udp.v index a40afa70e..26eb1104d 100644 --- a/test_regress/t/t_udp.v +++ b/test_regress/t/t_udp.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -69,11 +69,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -85,7 +85,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) // Note not all simulators agree about the latch result. Maybe have a race? diff --git a/test_regress/t/t_udp_noname.v b/test_regress/t/t_udp_noname.v index 258f6f42e..484dbb03a 100644 --- a/test_regress/t/t_udp_noname.v +++ b/test_regress/t/t_udp_noname.v @@ -14,7 +14,7 @@ module t (/*AUTOARG*/ wire o; udp (o, a); - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; // Test loop always @ (posedge clk) begin diff --git a/test_regress/t/t_unopt_array.v b/test_regress/t/t_unopt_array.v index 1158c8bb4..1ca4db785 100644 --- a/test_regress/t/t_unopt_array.v +++ b/test_regress/t/t_unopt_array.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -35,11 +35,11 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result); + $write("[%0t] cyc==%0d crc=%x result=%x\n", $time, cyc, crc, result); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; - sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; + sum <= result ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -51,7 +51,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 64'h458c2de282e30f8b diff --git a/test_regress/t/t_unopt_combo.v b/test_regress/t/t_unopt_combo.v index c4d7e6d14..6620e7459 100644 --- a/test_regress/t/t_unopt_combo.v +++ b/test_regress/t/t_unopt_combo.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; reg [63:0] crc; reg [63:0] sum; @@ -35,12 +35,12 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc=%0d crc=%x sum=%x b=%x d=%x\n",$time,cyc,crc,sum, b, d); + $write("[%0t] cyc=%0d crc=%x sum=%x b=%x d=%x\n", $time, cyc, crc, sum, b, d); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {b, d} - ^ {sum[62:0],sum[63]^sum[2]^sum[0]}; + ^ {sum[62:0], sum[63] ^ sum[2] ^ sum[0]}; if (cyc==0) begin // Setup crc <= 64'h5aef0c8d_d70a4497; @@ -52,7 +52,7 @@ module t (/*AUTOARG*/ end else if (cyc==99) begin $write("*-* All Finished *-*\n"); - $write("[%0t] cyc==%0d crc=%x %x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x %x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; if (sum !== 64'h649ee1713d624dd9) $stop; $finish; diff --git a/test_regress/t/t_unroll_signed.v b/test_regress/t/t_unroll_signed.v index 5be7038bf..e565137b7 100644 --- a/test_regress/t/t_unroll_signed.v +++ b/test_regress/t/t_unroll_signed.v @@ -31,7 +31,7 @@ module t (/*AUTOARG*/ reg [31:0] dly_to_ensure_was_unrolled [1:0]; reg [2:0] i3; - integer cyc; initial cyc=0; + integer cyc; initial cyc = 0; always @ (posedge clk) begin cyc <= cyc + 1; case (cyc) diff --git a/test_regress/t/t_vams_wreal.v b/test_regress/t/t_vams_wreal.v index d2c453b9b..6fe807df3 100644 --- a/test_regress/t/t_vams_wreal.v +++ b/test_regress/t/t_vams_wreal.v @@ -16,7 +16,7 @@ module t (/*autoarg*/ input [15:0] in; wreal aout; - integer cyc=0; + integer cyc = 0; real vin; wreal vpass; @@ -59,7 +59,7 @@ module t (/*autoarg*/ always @ (posedge clk) begin cyc <= cyc + 1; `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d aout=%d (%f-%f=%f)\n",$time, cyc, out, vin, gnd, within_range.in_int); + $write("[%0t] cyc==%0d aout=%d (%f-%f=%f)\n", $time, cyc, out, vin, gnd, within_range.in_int); `endif if (cyc==0) begin // Setup diff --git a/test_regress/t/t_var_assign_landr.v b/test_regress/t/t_var_assign_landr.v index 4713eea8f..dabaa0cef 100644 --- a/test_regress/t/t_var_assign_landr.v +++ b/test_regress/t/t_var_assign_landr.v @@ -10,7 +10,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; reg [63:0] crc; reg [255:0] sum; @@ -33,10 +33,10 @@ module t (/*AUTOARG*/ // Test loop always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d crc=%x result=%x %x\n",$time, cyc, crc, o1, o2); + $write("[%0t] cyc==%0d crc=%x result=%x %x\n", $time, cyc, crc, o1, o2); `endif cyc <= cyc + 1; - crc <= {crc[62:0], crc[63]^crc[2]^crc[0]}; + crc <= {crc[62:0], crc[63] ^ crc[2] ^ crc[0]}; sum <= {o1,o2} ^ {sum[254:0],sum[255]^sum[2]^sum[0]}; if (cyc==0) begin // Setup @@ -49,7 +49,7 @@ module t (/*AUTOARG*/ else if (cyc<90) begin end else if (cyc==99) begin - $write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum); + $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) `define EXPECTED_SUM 256'h008a080aaa000000140550404115dc7b008a080aaae7c8cd897bc1ca49c9350a diff --git a/test_regress/t/t_var_in_assign.v b/test_regress/t/t_var_in_assign.v index 263775599..aa41a3d03 100644 --- a/test_regress/t/t_var_in_assign.v +++ b/test_regress/t/t_var_in_assign.v @@ -9,7 +9,7 @@ module t (/*AUTOARG*/ ); input clk; - integer cyc=0; + integer cyc = 0; integer v; reg i; @@ -24,7 +24,7 @@ module t (/*AUTOARG*/ always @ (posedge clk) begin `ifdef TEST_VERBOSE - $write("[%0t] cyc==%0d i=%x oa=%x oz=%x\n",$time, cyc, i, oa, oz); + $write("[%0t] cyc==%0d i=%x oa=%x oz=%x\n", $time, cyc, i, oa, oz); `endif cyc <= cyc + 1; i <= cyc[0]; diff --git a/test_regress/t/t_verilated_debug.v b/test_regress/t/t_verilated_debug.v index 9cd229c4f..3f4e000eb 100644 --- a/test_regress/t/t_verilated_debug.v +++ b/test_regress/t/t_verilated_debug.v @@ -16,7 +16,7 @@ module t (/*AUTOARG*/ initial begin // internal code coverage for _vl_debug_print_w wide = {32'haa, 32'hbb, 32'hcc}; - $c("_vl_debug_print_w(",$bits(wide),",",wide,");"); + $c("_vl_debug_print_w(", $bits(wide), ", ", wide, ");"); end // Test loop diff --git a/test_regress/t/t_xml_debugcheck.out b/test_regress/t/t_xml_debugcheck.out index 791baf602..bbe26868f 100644 --- a/test_regress/t/t_xml_debugcheck.out +++ b/test_regress/t/t_xml_debugcheck.out @@ -842,13 +842,13 @@ - + - - - + + + @@ -1411,7 +1411,7 @@ - + @@ -1544,7 +1544,7 @@ - + From b7a7504ba5056e99cf5e0cd5b8fc34828a6be23b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 11:35:03 -0500 Subject: [PATCH 32/79] Internals: More obvious debug filename. --- src/V3LinkDot.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/V3LinkDot.h b/src/V3LinkDot.h index 6b650384a..98656689e 100644 --- a/src/V3LinkDot.h +++ b/src/V3LinkDot.h @@ -41,7 +41,8 @@ public: static void linkDotParamed(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); linkDotGuts(nodep, LDS_PARAMED); - V3Global::dumpCheckGlobalTree("paramlink", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); + V3Global::dumpCheckGlobalTree("linkdotparam", 0, + v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } static void linkDotArrayed(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); From 4cb5c1e1db74e1eb62d0f95b55274ffe1435eb09 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 11:38:12 -0500 Subject: [PATCH 33/79] Internals: More const. No functional change. --- src/V3Ast.h | 2 +- src/V3Param.cpp | 122 ++++++++++++++++++++++++------------------------ 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index ac027182c..0ff353e77 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1954,7 +1954,7 @@ public: virtual bool cleanOut() const = 0; // True if output has extra upper bits zero // Someday we will generically support data types on every math node // Until then isOpaque indicates we shouldn't constant optimize this node type - bool isOpaque() { return VN_IS(this, CvtPackString); } + bool isOpaque() const { return VN_IS(this, CvtPackString); } }; class AstNodeTermop VL_NOT_FINAL : public AstNodeMath { diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 78be0c482..7a63456a2 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -115,7 +115,7 @@ public: if (defParamIt != m_modParams.end()) { // modp is the original of parameterized hierarchical block for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isGParam()) defParamIt->second.emplace(varp->name(), varp); } } @@ -143,12 +143,12 @@ public: UASSERT_OBJ(!pinp->modPTypep(), pinp, "module with type parameter must not be a hierarchical block"); if (AstVar* modvarp = pinp->modVarp()) { - AstConst* constp = VN_AS(pinp->exprp(), Const); + AstConst* const constp = VN_AS(pinp->exprp(), Const); UASSERT_OBJ(constp, pinp, "parameter for a hierarchical block must have been constified"); const auto paramIt = paramsIt->second.find(modvarp->name()); UASSERT_OBJ(paramIt != paramsIt->second.end(), modvarp, "must be registered"); - AstConst* defValuep = VN_CAST(paramIt->second->valuep(), Const); + AstConst* const defValuep = VN_CAST(paramIt->second->valuep(), Const); if (defValuep && areSame(constp, defValuep)) { UINFO(5, "Setting default value of " << constp << " to " << modvarp << std::endl); @@ -273,7 +273,7 @@ class ParamProcessor final { usedLetter.resize(256); // Pass 1, assign first letter to each gparam's name for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isGParam() || varp->isIfaceRef()) { char ch = varp->name()[0]; ch = std::toupper(ch); @@ -281,7 +281,7 @@ class ParamProcessor final { varp->user4(usedLetter[static_cast(ch)] * 256 + ch); usedLetter[static_cast(ch)]++; } - } else if (AstParamTypeDType* typep = VN_CAST(stmtp, ParamTypeDType)) { + } else if (AstParamTypeDType* const typep = VN_CAST(stmtp, ParamTypeDType)) { const char ch = 'T'; typep->user4(usedLetter[static_cast(ch)] * 256 + ch); usedLetter[static_cast(ch)]++; @@ -369,13 +369,13 @@ class ParamProcessor final { } AstNodeDType* arraySubDTypep(AstNodeDType* nodep) { // If an unpacked array, return the subDTypep under it - if (AstUnpackArrayDType* adtypep = VN_CAST(nodep, UnpackArrayDType)) { + if (const AstUnpackArrayDType* const adtypep = VN_CAST(nodep, UnpackArrayDType)) { return adtypep->subDTypep(); } // We have not resolved parameter of the child yet, so still // have BracketArrayDType's. We'll presume it'll end up as assignment // compatible (or V3Width will complain). - if (AstBracketArrayDType* adtypep = VN_CAST(nodep, BracketArrayDType)) { + if (const AstBracketArrayDType* const adtypep = VN_CAST(nodep, BracketArrayDType)) { return adtypep->subDTypep(); } return nullptr; @@ -383,17 +383,17 @@ class ParamProcessor final { void collectPins(CloneMap* clonemapp, AstNodeModule* modp) { // Grab all I/O so we can remap our pins later for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isIO() || varp->isGParam() || varp->isIfaceRef()) { // Cloning saved a pointer to the new node for us, so just follow that link. - AstVar* oldvarp = varp->clonep(); + AstVar* const oldvarp = varp->clonep(); // UINFO(8,"Clone list 0x"< 0x"<<(uint32_t)varp<emplace(oldvarp, varp); } } else if (AstParamTypeDType* ptp = VN_CAST(stmtp, ParamTypeDType)) { if (ptp->isGParam()) { - AstParamTypeDType* oldptp = ptp->clonep(); + AstParamTypeDType* const oldptp = ptp->clonep(); clonemapp->emplace(oldptp, ptp); } } @@ -421,14 +421,14 @@ class ParamProcessor final { void relinkPinsByName(AstPin* startpinp, AstNodeModule* modp) { std::map nameToPin; for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isIO() || varp->isGParam() || varp->isIfaceRef()) { nameToPin.emplace(varp->name(), varp); } } } for (AstPin* pinp = startpinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { - if (AstVar* varp = pinp->modVarp()) { + if (AstVar* const varp = pinp->modVarp()) { const auto varIt = vlstd::as_const(nameToPin).find(varp->name()); UASSERT_OBJ(varIt != nameToPin.end(), varp, "Not found in " << modp->prettyNameQ()); @@ -442,7 +442,7 @@ class ParamProcessor final { // option. if (pinp->modVarp()) { bool supported = false; - if (AstConst* constp = VN_CAST(pinp->exprp(), Const)) { + if (const AstConst* const constp = VN_CAST(pinp->exprp(), Const)) { supported = !constp->isOpaque(); } if (!supported) { @@ -471,7 +471,7 @@ class ParamProcessor final { std::map pins; for (AstPin* pinp = paramPinsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { checkSupportedParam(modp, pinp); - if (AstVar* varp = pinp->modVarp()) { + if (AstVar* const varp = pinp->modVarp()) { if (!pinp->exprp()) continue; if (varp->isGParam()) { AstConst* constp = VN_CAST(pinp->exprp(), Const); @@ -485,9 +485,9 @@ class ParamProcessor final { // Using map with key=string so that we can scan it in deterministic order DefaultValueMap params; for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (const AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isGParam()) { - AstConst* constp = VN_CAST(varp->valuep(), Const); + AstConst* const constp = VN_CAST(varp->valuep(), Const); // constp can be nullptr if the parameter is not used to instantiate sub // module. varp->valuep() is not contified yet in the case. // nullptr means that the parameter is using some default value. @@ -502,7 +502,8 @@ class ParamProcessor final { string longname = modp->name(); for (auto&& defaultValue : paramsIt->second) { const auto pinIt = pins.find(defaultValue.first); - AstConst* constp = pinIt == pins.end() ? defaultValue.second : pinIt->second; + const AstConst* const constp + = pinIt == pins.end() ? defaultValue.second : pinIt->second; // This longname is not valid as verilog symbol, but ok, because it will be hashed longname += "_" + defaultValue.first + "="; // constp can be nullptr @@ -540,7 +541,7 @@ class ParamProcessor final { // Deep clone of new module // Note all module internal variables will be re-linked to the new modules by clone // However links outside the module (like on the upper cells) will not. - AstNodeModule* newmodp = srcModp->cloneTree(false); + AstNodeModule* const newmodp = srcModp->cloneTree(false); newmodp->name(newname); newmodp->user5(false); // We need to re-recurse this module once changed newmodp->recursive(false); @@ -563,7 +564,7 @@ class ParamProcessor final { m_modNameMap.emplace(newmodp->name(), ModInfo(newmodp)); const auto iter = m_modNameMap.find(newname); - CloneMap* clonemapp = &(iter->second.m_cloneMap); + CloneMap* const clonemapp = &(iter->second.m_cloneMap); UINFO(4, " De-parameterize to new: " << newmodp << endl); // Grab all I/O so we can remap our pins later @@ -574,9 +575,9 @@ class ParamProcessor final { relinkPins(clonemapp, paramsp); // Fix any interface references for (auto it = ifaceRefRefs.cbegin(); it != ifaceRefRefs.cend(); ++it) { - AstIfaceRefDType* portIrefp = it->first; - AstIfaceRefDType* pinIrefp = it->second; - AstIfaceRefDType* cloneIrefp = portIrefp->clonep(); + AstIfaceRefDType* const portIrefp = it->first; + AstIfaceRefDType* const pinIrefp = it->second; + AstIfaceRefDType* const cloneIrefp = portIrefp->clonep(); UINFO(8, " IfaceOld " << portIrefp << endl); UINFO(8, " IfaceTo " << pinIrefp << endl); UASSERT_OBJ(cloneIrefp, portIrefp, "parameter clone didn't hit AstIfaceRefDType"); @@ -589,9 +590,9 @@ class ParamProcessor final { for (AstPin* pinp = paramsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (pinp->exprp()) { if (AstVar* modvarp = pinp->modVarp()) { - AstNode* newp = pinp->exprp(); // Const or InitArray - AstConst* exprp = VN_CAST(newp, Const); - AstConst* origp = VN_CAST(modvarp->valuep(), Const); + AstNode* const newp = pinp->exprp(); // Const or InitArray + AstConst* const exprp = VN_CAST(newp, Const); + AstConst* const origp = VN_CAST(modvarp->valuep(), Const); const bool overridden = !(origp && ParameterizedHierBlocks::areSame(exprp, origp)); // Remove any existing parameter @@ -600,8 +601,8 @@ class ParamProcessor final { UINFO(9, " set param " << modvarp << " = " << newp << endl); modvarp->valuep(newp->cloneTree(false)); modvarp->overriddenParam(overridden); - } else if (AstParamTypeDType* modptp = pinp->modPTypep()) { - AstNodeDType* dtypep = VN_AS(pinp->exprp(), NodeDType); + } else if (AstParamTypeDType* const modptp = pinp->modPTypep()) { + AstNodeDType* const dtypep = VN_AS(pinp->exprp(), NodeDType); UASSERT_OBJ(dtypep, pinp, "unlinked param dtype"); if (modptp->childDTypep()) modptp->childDTypep()->unlinkFrBack()->deleteTree(); // Set this parameter to value requested by cell @@ -623,25 +624,25 @@ class ParamProcessor final { it = m_modNameMap.find(newname); UASSERT(it != m_modNameMap.end(), "should find just-made module"); } - const ModInfo* modInfop = &(it->second); + const ModInfo* const modInfop = &(it->second); return modInfop; } void cellPinCleanup(AstNode* nodep, AstPin* pinp, AstNodeModule* srcModp, string& longnamer, bool& any_overridesr) { if (!pinp->exprp()) return; // No-connect - if (AstVar* modvarp = pinp->modVarp()) { + if (AstVar* const modvarp = pinp->modVarp()) { if (!modvarp->isGParam()) { pinp->v3error("Attempted parameter setting of non-parameter: Param " << pinp->prettyNameQ() << " of " << nodep->prettyNameQ()); } else if (VN_IS(pinp->exprp(), InitArray) && arraySubDTypep(modvarp->subDTypep())) { // Array assigned to array - AstNode* exprp = pinp->exprp(); + AstNode* const exprp = pinp->exprp(); longnamer += "_" + paramSmallName(srcModp, modvarp) + paramValueNumber(exprp); any_overridesr = true; } else { - AstConst* exprp = VN_CAST(pinp->exprp(), Const); - AstConst* origp = VN_CAST(modvarp->valuep(), Const); + AstConst* const exprp = VN_CAST(pinp->exprp(), Const); + const AstConst* const origp = VN_CAST(modvarp->valuep(), Const); if (!exprp) { // if (debug()) pinp->dumpTree(cout, "error:"); pinp->v3error("Can't convert defparam value to constant: Param " @@ -663,9 +664,9 @@ class ParamProcessor final { any_overridesr = true; } } - } else if (AstParamTypeDType* modvarp = pinp->modPTypep()) { - AstNodeDType* exprp = VN_CAST(pinp->exprp(), NodeDType); - AstNodeDType* origp = modvarp->subDTypep(); + } else if (AstParamTypeDType* const modvarp = pinp->modPTypep()) { + AstNodeDType* const exprp = VN_CAST(pinp->exprp(), NodeDType); + const AstNodeDType* const origp = modvarp->subDTypep(); if (!exprp) { pinp->v3error("Parameter type pin value isn't a type: Param " << pinp->prettyNameQ() << " of " << nodep->prettyNameQ()); @@ -693,15 +694,15 @@ class ParamProcessor final { void cellInterfaceCleanup(AstCell* nodep, AstNodeModule* srcModp, string& longnamer, bool& any_overridesr, IfaceRefRefs& ifaceRefRefs) { for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { - AstVar* modvarp = pinp->modVarp(); + AstVar* const modvarp = pinp->modVarp(); if (modvarp->isIfaceRef()) { AstIfaceRefDType* portIrefp = VN_CAST(modvarp->subDTypep(), IfaceRefDType); if (!portIrefp && arraySubDTypep(modvarp->subDTypep())) { portIrefp = VN_CAST(arraySubDTypep(modvarp->subDTypep()), IfaceRefDType); } AstIfaceRefDType* pinIrefp = nullptr; - AstNode* exprp = pinp->exprp(); - AstVar* varp + AstNode* const exprp = pinp->exprp(); + AstVar* const varp = (exprp && VN_IS(exprp, VarRef)) ? VN_AS(exprp, VarRef)->varp() : nullptr; if (varp && varp->subDTypep() && VN_IS(varp->subDTypep(), IfaceRefDType)) { pinIrefp = VN_AS(varp->subDTypep(), IfaceRefDType); @@ -763,7 +764,7 @@ public: if (debug() >= 10) nodep->dumpTree(cout, "-cell: "); // Evaluate all module constants V3Const::constifyParamsEdit(nodep); - AstNodeModule* srcModp = nodep->modp(); + AstNodeModule* const srcModp = nodep->modp(); srcModp->hierName(hierName + "." + nodep->name()); // Make sure constification worked @@ -789,7 +790,7 @@ public: if (!any_overrides) { UINFO(8, "Cell parameters all match original values, skipping expansion.\n"); - } else if (AstNodeModule* paramedModp + } else if (AstNodeModule* const paramedModp = m_hierBlocks.findByParams(srcModp->name(), nodep->paramsp(), m_modp)) { nodep->modp(paramedModp); nodep->modName(paramedModp->name()); @@ -799,7 +800,7 @@ public: } else { const string newname = srcModp->hierBlock() ? longname : moduleCalcName(srcModp, longname); - const ModInfo* modInfop + const ModInfo* const modInfop = moduleFindOrClone(srcModp, nodep, nodep->paramsp(), newname, ifaceRefRefs); // Have child use this module instead. nodep->modp(modInfop->m_modp); @@ -862,7 +863,7 @@ class ParamVisitor final : public AstNVisitor { // so since cells originally exist top->bottom we process in top->bottom order too. while (!m_todoModps.empty()) { const auto itm = m_todoModps.cbegin(); - AstNodeModule* nodep = itm->second; + AstNodeModule* const nodep = itm->second; m_todoModps.erase(itm); if (!nodep->user5SetOnce()) { // Process once; note clone() must clear so we do it // again @@ -874,11 +875,11 @@ class ParamVisitor final : public AstNVisitor { // // Process interface cells, then non-interface which may ref an interface cell for (int nonIf = 0; nonIf < 2; ++nonIf) { - for (AstCell* cellp : m_cellps) { + for (AstCell* const cellp : m_cellps) { if ((nonIf == 0 && VN_IS(cellp->modp(), Iface)) || (nonIf == 1 && !VN_IS(cellp->modp(), Iface))) { string fullName(m_modp->hierName()); - if (const string* genHierNamep = (string*)cellp->user5p()) { + if (const string* const genHierNamep = (string*)cellp->user5p()) { fullName += *genHierNamep; cellp->user5p(nullptr); VL_DO_DANGLING(delete genHierNamep, genHierNamep); @@ -908,7 +909,7 @@ class ParamVisitor final : public AstNVisitor { // if (!nodep->dead() && VN_IS(nodep, Class)) { for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (const AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isParam()) { varp->v3warn(E_UNSUPPORTED, "Unsupported: class parameters"); } @@ -935,7 +936,7 @@ class ParamVisitor final : public AstNVisitor { } virtual void visit(AstCell* nodep) override { // Must do ifaces first, so push to list and do in proper order - string* genHierNamep = new string(m_generateHierName); + string* const genHierNamep = new string(m_generateHierName); nodep->user5p(genHierNamep); m_cellps.push_back(nodep); } @@ -969,11 +970,11 @@ class ParamVisitor final : public AstNVisitor { bool ifaceParamReplace(AstVarXRef* nodep, AstNode* candp) { for (; candp; candp = candp->nextp()) { if (nodep->name() == candp->name()) { - if (AstVar* varp = VN_CAST(candp, Var)) { + if (AstVar* const varp = VN_CAST(candp, Var)) { UINFO(9, "Found interface parameter: " << varp << endl); nodep->varp(varp); return true; - } else if (AstPin* pinp = VN_CAST(candp, Pin)) { + } else if (AstPin* const pinp = VN_CAST(candp, Pin)) { UINFO(9, "Found interface parameter: " << pinp << endl); UASSERT_OBJ(pinp->exprp(), pinp, "Interface parameter pin missing expression"); VL_DO_DANGLING(nodep->replaceWith(pinp->exprp()->cloneTree(false)), nodep); @@ -1006,7 +1007,7 @@ class ParamVisitor final : public AstNVisitor { IfaceRefDType); } // Interfaces passed in on the port map have ifaces - if (AstIface* ifacep = ifacerefp->ifacep()) { + if (AstIface* const ifacep = ifacerefp->ifacep()) { if (dotted == backp->name()) { UINFO(9, "Iface matching scope: " << ifacep << endl); if (ifaceParamReplace(nodep, ifacep->stmtsp())) { // @@ -1015,7 +1016,7 @@ class ParamVisitor final : public AstNVisitor { } } // Interfaces declared in this module have cells - else if (AstCell* cellp = ifacerefp->cellp()) { + else if (AstCell* const cellp = ifacerefp->cellp()) { if (dotted == cellp->name()) { UINFO(9, "Iface matching scope: " << cellp << endl); if (ifaceParamReplace(nodep, cellp->paramsp())) { // @@ -1030,8 +1031,8 @@ class ParamVisitor final : public AstNVisitor { } virtual void visit(AstUnlinkedRef* nodep) override { - AstVarXRef* varxrefp = VN_CAST(nodep->op1p(), VarXRef); - AstNodeFTaskRef* taskrefp = VN_CAST(nodep->op1p(), NodeFTaskRef); + AstVarXRef* const varxrefp = VN_CAST(nodep->op1p(), VarXRef); + AstNodeFTaskRef* const taskrefp = VN_CAST(nodep->op1p(), NodeFTaskRef); if (varxrefp) { m_unlinkedTxt = varxrefp->dotted(); } else if (taskrefp) { @@ -1052,7 +1053,7 @@ class ParamVisitor final : public AstNVisitor { } virtual void visit(AstCellArrayRef* nodep) override { V3Const::constifyParamsEdit(nodep->selp()); - if (const AstConst* constp = VN_CAST(nodep->selp(), Const)) { + if (const AstConst* const constp = VN_CAST(nodep->selp(), Const)) { const string index = AstNode::encodeNumber(constp->toSInt()); const string replacestr = nodep->name() + "__BRA__??__KET__"; const size_t pos = m_unlinkedTxt.find(replacestr); @@ -1078,9 +1079,8 @@ class ParamVisitor final : public AstNVisitor { V3Width::widthGenerateParamsEdit(nodep); // Param typed widthing will // NOT recurse the body. V3Const::constifyGenerateParamsEdit(nodep->condp()); // condp may change - if (const AstConst* constp = VN_CAST(nodep->condp(), Const)) { - AstNode* keepp = (constp->isZero() ? nodep->elsesp() : nodep->ifsp()); - if (keepp) { + if (const AstConst* const constp = VN_CAST(nodep->condp(), Const)) { + if (AstNode* const keepp = (constp->isZero() ? nodep->elsesp() : nodep->ifsp())) { keepp->unlinkFrBackWithNext(); nodep->replaceWith(keepp); } else { @@ -1099,7 +1099,7 @@ class ParamVisitor final : public AstNVisitor { //! move to more generic constant expressions, such code will be needed here. virtual void visit(AstBegin* nodep) override { if (nodep->genforp()) { - AstGenFor* forp = VN_AS(nodep->genforp(), GenFor); + AstGenFor* const forp = VN_AS(nodep->genforp(), GenFor); UASSERT_OBJ(forp, nodep, "Non-GENFOR under generate-for BEGIN"); // We should have a GENFOR under here. We will be replacing the begin, // so process here rather than at the generate to avoid iteration problems @@ -1118,7 +1118,7 @@ class ParamVisitor final : public AstNVisitor { VL_DO_DANGLING(m_unroller.unrollGen(forp, beginName), forp); // Blocks were constructed under the special begin, move them up // Note forp is null, so grab statements again - if (AstNode* stmtsp = nodep->genforp()) { + if (AstNode* const stmtsp = nodep->genforp()) { stmtsp->unlinkFrBackWithNext(); nodep->addNextHere(stmtsp); // Note this clears nodep->genforp(), so begin is no longer special @@ -1140,12 +1140,12 @@ class ParamVisitor final : public AstNVisitor { V3Width::widthParamsEdit(nodep); // Param typed widthing will NOT recurse the body, // don't trigger errors yet. V3Const::constifyParamsEdit(nodep->exprp()); // exprp may change - AstConst* exprp = VN_AS(nodep->exprp(), Const); + AstConst* const exprp = VN_AS(nodep->exprp(), Const); // Constify for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* ep = itemp->condsp(); ep;) { - AstNode* nextp = ep->nextp(); // May edit list + AstNode* const nextp = ep->nextp(); // May edit list iterateAndNextNull(ep); VL_DO_DANGLING(V3Const::constifyParamsEdit(ep), ep); // ep may change ep = nextp; @@ -1156,7 +1156,7 @@ class ParamVisitor final : public AstNVisitor { itemp = VN_AS(itemp->nextp(), CaseItem)) { if (!itemp->isDefault()) { for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) { - if (const AstConst* ccondp = VN_CAST(ep, Const)) { + if (const AstConst* const ccondp = VN_CAST(ep, Const)) { V3Number match(nodep, 1); match.opEq(ccondp->num(), exprp->num()); if (!keepp && match.isNeqZero()) keepp = itemp->bodysp(); From 37e3c6da7032550427abff12fa03684005ccb9da Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 13:50:44 -0500 Subject: [PATCH 34/79] Internals: Add more const. No functional change intended. --- src/V3Active.cpp | 41 ++++---- src/V3ActiveTop.cpp | 8 +- src/V3Assert.cpp | 70 ++++++------- src/V3AssertPre.cpp | 20 ++-- src/V3Ast.cpp | 48 ++++----- src/V3Ast.h | 2 +- src/V3AstNodes.cpp | 12 +-- src/V3Begin.cpp | 2 +- src/V3Broken.cpp | 5 +- src/V3CCtors.cpp | 4 +- src/V3Case.cpp | 44 +++++---- src/V3Cdc.cpp | 55 ++++++----- src/V3Class.cpp | 13 ++- src/V3Clean.cpp | 10 +- src/V3Clock.cpp | 24 ++--- src/V3Common.cpp | 2 +- src/V3Config.cpp | 6 +- src/V3Coverage.cpp | 32 +++--- src/V3CoverageJoin.cpp | 6 +- src/V3Dead.cpp | 22 ++--- src/V3Delayed.cpp | 70 ++++++------- src/V3DepthBlock.cpp | 2 +- src/V3Descope.cpp | 18 ++-- src/V3EmitCBase.cpp | 4 +- src/V3EmitCFunc.cpp | 8 +- src/V3EmitCMake.cpp | 2 +- src/V3EmitCSyms.cpp | 31 +++--- src/V3EmitMk.cpp | 2 +- src/V3EmitV.cpp | 14 +-- src/V3EmitXml.cpp | 2 +- src/V3Error.cpp | 2 +- src/V3File.cpp | 2 +- src/V3FileLine.cpp | 10 +- src/V3Gate.cpp | 183 +++++++++++++++++----------------- src/V3GenClk.cpp | 19 ++-- src/V3GraphAcyc.cpp | 27 ++--- src/V3GraphDfa.cpp | 60 ++++++------ src/V3GraphPathChecker.cpp | 10 +- src/V3GraphTest.cpp | 18 ++-- src/V3Hasher.cpp | 2 +- src/V3HierBlock.cpp | 2 +- src/V3Inline.cpp | 58 +++++------ src/V3Inst.cpp | 92 +++++++++-------- src/V3InstrCount.cpp | 6 +- src/V3Life.cpp | 34 +++---- src/V3LifePost.cpp | 24 ++--- src/V3LinkCells.cpp | 30 +++--- src/V3LinkDot.cpp | 62 ++++++------ src/V3LinkInc.cpp | 24 ++--- src/V3LinkJump.cpp | 32 +++--- src/V3LinkLValue.cpp | 4 +- src/V3LinkLevel.cpp | 4 +- src/V3LinkParse.cpp | 6 +- src/V3LinkResolve.cpp | 36 +++---- src/V3Localize.cpp | 2 +- src/V3OptionParser.cpp | 2 +- src/V3Options.cpp | 10 +- src/V3Order.cpp | 8 +- src/V3Os.cpp | 4 +- src/V3Param.cpp | 2 +- src/V3ParseGrammar.cpp | 20 ++-- src/V3ParseImp.cpp | 10 +- src/V3Partition.cpp | 2 +- src/V3PreProc.cpp | 14 +-- src/V3PreShell.cpp | 8 +- src/V3ProtectLib.cpp | 16 +-- src/V3Randomize.cpp | 67 +++++++------ src/V3Reloop.cpp | 4 +- src/V3Scope.cpp | 32 +++--- src/V3Slice.cpp | 21 ++-- src/V3Split.cpp | 86 ++++++++-------- src/V3SplitAs.cpp | 6 +- src/V3String.cpp | 2 +- src/V3Subst.cpp | 31 +++--- src/V3TSP.cpp | 38 ++++---- src/V3Table.cpp | 2 +- src/V3Task.cpp | 18 ++-- src/V3Trace.cpp | 4 +- src/V3Tristate.cpp | 188 ++++++++++++++++++----------------- src/V3Undriven.cpp | 4 +- src/V3Unknown.cpp | 16 +-- src/V3Unroll.cpp | 28 +++--- src/V3Width.cpp | 195 +++++++++++++++++++------------------ src/V3WidthSel.cpp | 119 +++++++++++----------- src/VlcTop.cpp | 2 +- 85 files changed, 1172 insertions(+), 1115 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index d7501522f..e2e3ddd0e 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -108,9 +108,10 @@ protected: } break; case LatchDetectGraphVertex::VT_BRANCH: // (AND of both sibling) - // A BRANCH vertex always has exactly 2 siblings - LatchDetectGraphVertex* ifp = castVertexp(vertexp->outBeginp()->top()); - LatchDetectGraphVertex* elsp = castVertexp(vertexp->outBeginp()->outNextp()->top()); + // A BRANCH vertex always has exactly 2 siblings + LatchDetectGraphVertex* const ifp = castVertexp(vertexp->outBeginp()->top()); + LatchDetectGraphVertex* const elsp + = castVertexp(vertexp->outBeginp()->outNextp()->top()); result = latchCheckInternal(ifp) && latchCheckInternal(elsp); break; } @@ -151,7 +152,7 @@ public: // Add a new output variable vertex and store a pointer to it in the user1 field of the // variables AstNode LatchDetectGraphVertex* addOutputVertex(AstVarRef* nodep) { - LatchDetectGraphVertex* outVertexp + LatchDetectGraphVertex* const outVertexp = new LatchDetectGraphVertex{this, nodep->name(), LatchDetectGraphVertex::VT_OUTPUT}; nodep->varp()->user1p(outVertexp); m_outputs.push_back(nodep); @@ -172,7 +173,7 @@ public: void latchCheck(AstNode* nodep, bool latch_expected) { bool latch_detected = false; for (const auto& vrp : m_outputs) { - LatchDetectGraphVertex* vertp = castVertexp(vrp->varp()->user1p()); + LatchDetectGraphVertex* const vertp = castVertexp(vrp->varp()->user1p()); vertp->user(true); // Identify the output vertex we are checking paths _to_ if (!latchCheckInternal(castVertexp(verticesBeginp()))) latch_detected = true; if (latch_detected && !latch_expected) { @@ -262,7 +263,7 @@ public: // Return a sentree in this scope that matches given sense list. AstActive* activep = nullptr; - AstSenTree* activeSenp = m_activeSens.find(sensesp); + AstSenTree* const activeSenp = m_activeSens.find(sensesp); if (activeSenp) { const auto it = m_activeMap.find(activeSenp); UASSERT(it != m_activeMap.end(), "Corrupt active map"); @@ -271,7 +272,7 @@ public: // Not found, form a new one if (!activep) { - AstSenTree* newsenp = sensesp->cloneTree(false); + AstSenTree* const newsenp = sensesp->cloneTree(false); activep = new AstActive(fl, "sequent", newsenp); activep->sensesStorep(activep->sensesp()); UINFO(8, " New ACTIVE " << activep << endl); @@ -303,15 +304,15 @@ private: LatchDetectGraph m_graph; // Graph used to detect latches in combo always // VISITORS virtual void visit(AstVarRef* nodep) { - AstVar* varp = nodep->varp(); + const AstVar* const varp = nodep->varp(); if (nodep->access().isWriteOrRW() && varp->isSignal() && !varp->isUsedLoopIdx()) { m_graph.addAssignment(nodep); } } virtual void visit(AstNodeIf* nodep) { if (!nodep->isBoundsCheck()) { - LatchDetectGraphVertex* parentp = m_graph.currentp(); - LatchDetectGraphVertex* branchp = m_graph.addPathVertex(parentp, "BRANCH", true); + LatchDetectGraphVertex* const parentp = m_graph.currentp(); + LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true); m_graph.addPathVertex(branchp, "IF"); iterateAndNextNull(nodep->ifsp()); m_graph.addPathVertex(branchp, "ELSE"); @@ -340,8 +341,8 @@ public: enum CheckType : uint8_t { CT_SEQ, CT_COMBO, CT_INITIAL, CT_LATCH }; private: - CheckType m_check; // Combo logic or other - AstNode* m_alwaysp; // Always we're under + const CheckType m_check; // Combo logic or other + AstNode* const m_alwaysp; // Always we're under AstNode* m_assignp = nullptr; // In assign // VISITORS virtual void visit(AstAssignDly* nodep) override { @@ -363,8 +364,8 @@ private: // Conversely, we could also suggest latches use delayed assignments, as // recommended by Cliff Cummings? } - AstNode* newp = new AstAssign(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), - nodep->rhsp()->unlinkFrBack()); + AstNode* const newp = new AstAssign(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), + nodep->rhsp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -377,7 +378,7 @@ private: } } virtual void visit(AstVarRef* nodep) override { - AstVar* varp = nodep->varp(); + const AstVar* const varp = nodep->varp(); if (m_check == CT_SEQ && m_assignp && !varp->isUsedLoopIdx() // Ignore loop indices && !varp->isTemp()) { // Allow turning off warnings on the always, or the variable also @@ -438,28 +439,28 @@ private: // Relink to IACTIVE, unless already under it UINFO(4, " INITIAL " << nodep << endl); ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; - AstActive* wantactivep = m_namer.getIActive(nodep->fileline()); + AstActive* const wantactivep = m_namer.getIActive(nodep->fileline()); nodep->unlinkFrBack(); wantactivep->addStmtsp(nodep); } virtual void visit(AstAssignAlias* nodep) override { // Relink to CACTIVE, unless already under it UINFO(4, " ASSIGNW " << nodep << endl); - AstActive* wantactivep = m_namer.getCActive(nodep->fileline()); + AstActive* const wantactivep = m_namer.getCActive(nodep->fileline()); nodep->unlinkFrBack(); wantactivep->addStmtsp(nodep); } virtual void visit(AstAssignW* nodep) override { // Relink to CACTIVE, unless already under it UINFO(4, " ASSIGNW " << nodep << endl); - AstActive* wantactivep = m_namer.getCActive(nodep->fileline()); + AstActive* const wantactivep = m_namer.getCActive(nodep->fileline()); nodep->unlinkFrBack(); wantactivep->addStmtsp(nodep); } virtual void visit(AstCoverToggle* nodep) override { // Relink to CACTIVE, unless already under it UINFO(4, " COVERTOGGLE " << nodep << endl); - AstActive* wantactivep = m_namer.getCActive(nodep->fileline()); + AstActive* const wantactivep = m_namer.getCActive(nodep->fileline()); nodep->unlinkFrBack(); wantactivep->addStmtsp(nodep); } @@ -577,7 +578,7 @@ private: } virtual void visit(AstSenItem* nodep) override { if (nodep->varrefp()) { - if (AstBasicDType* basicp = nodep->varrefp()->dtypep()->basicp()) { + if (const AstBasicDType* const basicp = nodep->varrefp()->dtypep()->basicp()) { if (basicp->isEventValue()) { // Events need to be treated as active high so we only activate on event being // 1 diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index 52556d5ba..cf786c44a 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -61,7 +61,7 @@ private: UINFO(4, " ACTIVE " << nodep << endl); // Remove duplicate clocks and such; sensesp() may change! V3Const::constifyExpensiveEdit(nodep); - AstSenTree* sensesp = nodep->sensesp(); + AstSenTree* const sensesp = nodep->sensesp(); UASSERT_OBJ(sensesp, nodep, "nullptr"); if (sensesp->sensesp() && sensesp->sensesp()->isNever()) { // Never executing. Kill it. @@ -72,16 +72,16 @@ private: } // Copy combo tree to settlement tree with duplicated statements if (sensesp->hasCombo()) { - AstSenTree* newsentreep = new AstSenTree( + AstSenTree* const newsentreep = new AstSenTree( nodep->fileline(), new AstSenItem(nodep->fileline(), AstSenItem::Settle())); - AstActive* newp = new AstActive(nodep->fileline(), "settle", newsentreep); + AstActive* const newp = new AstActive(nodep->fileline(), "settle", newsentreep); newp->sensesStorep(newsentreep); if (nodep->stmtsp()) newp->addStmtsp(nodep->stmtsp()->cloneTree(true)); nodep->addNextHere(newp); } // Move the SENTREE for each active up to the global level. // This way we'll easily see what clock domains are identical - AstSenTree* wantp = m_finder.getSenTree(sensesp); + AstSenTree* const wantp = m_finder.getSenTree(sensesp); UINFO(4, " lookdone\n"); if (wantp != sensesp) { // Move the active's contents to the other active diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 1155631f0..196113a02 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -56,8 +56,8 @@ private: nodep->displayType(AstDisplayType::DT_WRITE); nodep->fmtp()->text(assertDisplayMessage(nodep, prefix, nodep->fmtp()->text())); // cppcheck-suppress nullPointer - AstNode* timenewp = new AstTime(nodep->fileline(), m_modp->timeunit()); - if (AstNode* timesp = nodep->fmtp()->exprsp()) { + AstNode* const timenewp = new AstTime(nodep->fileline(), m_modp->timeunit()); + if (AstNode* const timesp = nodep->fmtp()->exprsp()) { timesp->unlinkFrBackWithNext(); timenewp->addNext(timesp); } @@ -89,8 +89,8 @@ private: AstNode* newIfAssertOn(AstNode* nodep, bool force) { // Add a internal if to check assertions are on. // Don't make this a AND term, as it's unlikely to need to test this. - FileLine* fl = nodep->fileline(); - AstNode* newp = new AstIf( + FileLine* const fl = nodep->fileline(); + AstNode* const newp = new AstIf( fl, (force ? new AstConst(fl, AstConst::BitTrue()) : // If assertions are off, have constant propagation rip them out later @@ -106,10 +106,10 @@ private: AstNode* newFireAssertUnchecked(AstNode* nodep, const string& message) { // Like newFireAssert() but omits the asserts-on check - AstDisplay* dispp = new AstDisplay(nodep->fileline(), AstDisplayType::DT_ERROR, message, - nullptr, nullptr); + AstDisplay* const dispp = new AstDisplay(nodep->fileline(), AstDisplayType::DT_ERROR, + message, nullptr, nullptr); dispp->fmtp()->timeunit(m_modp->timeunit()); - AstNode* bodysp = dispp; + AstNode* const bodysp = dispp; replaceDisplay(dispp, "%%Error"); // Convert to standard DISPLAY format bodysp->addNext(new AstStop(nodep->fileline(), true)); return bodysp; @@ -124,8 +124,8 @@ private: void newPslAssertion(AstNodeCoverOrAssert* nodep, AstNode* failsp) { if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name()); - AstNode* propp = nodep->propp()->unlinkFrBackWithNext(); - AstSenTree* sentreep = nodep->sentreep(); + AstNode* const propp = nodep->propp()->unlinkFrBackWithNext(); + AstSenTree* const sentreep = nodep->sentreep(); const string& message = nodep->name(); AstNode* passsp = nodep->passsp(); if (passsp) passsp->unlinkFrBackWithNext(); @@ -141,13 +141,13 @@ private: AstNode* bodysp = nullptr; bool selfDestruct = false; AstIf* ifp = nullptr; - if (AstCover* snodep = VN_CAST(nodep, Cover)) { + if (const AstCover* const snodep = VN_CAST(nodep, Cover)) { ++m_statCover; if (!v3Global.opt.coverageUser()) { selfDestruct = true; } else { // V3Coverage assigned us a bucket to increment. - AstCoverInc* covincp = VN_AS(snodep->coverincp(), CoverInc); + AstCoverInc* const covincp = VN_AS(snodep->coverincp(), CoverInc); UASSERT_OBJ(covincp, snodep, "Missing AstCoverInc under assertion"); covincp->unlinkFrBackWithNext(); // next() might have AstAssign for trace if (message != "") covincp->declp()->comment(message); @@ -199,13 +199,13 @@ private: virtual void visit(AstIf* nodep) override { if (nodep->user1SetOnce()) return; if (nodep->uniquePragma() || nodep->unique0Pragma()) { - AstNodeIf* ifp = nodep; + const AstNodeIf* ifp = nodep; AstNode* propp = nullptr; bool hasDefaultElse = false; do { // If this statement ends with 'else if', then nextIf will point to the // nextIf statement. Otherwise it will be null. - AstNodeIf* nextifp = dynamic_cast(ifp->elsesp()); + const AstNodeIf* const nextifp = dynamic_cast(ifp->elsesp()); iterateAndNextNull(ifp->condp()); // Recurse into the true case. @@ -217,7 +217,7 @@ private: } // Build a bitmask of the true predicates - AstNode* predp = ifp->condp()->cloneTree(false); + AstNode* const predp = ifp->condp()->cloneTree(false); if (propp) { propp = new AstConcat(nodep->fileline(), predp, propp); } else { @@ -230,7 +230,7 @@ private: ifp = nextifp; } while (ifp); - AstNode* newifp = nodep->cloneTree(false); + AstNode* const newifp = nodep->cloneTree(false); const bool allow_none = nodep->unique0Pragma(); // Empty case means no property @@ -238,10 +238,11 @@ private: // Note: if this ends with an 'else', then we don't need to validate that one of the // predicates evaluates to true. - AstNode* ohot = ((allow_none || hasDefaultElse) - ? static_cast(new AstOneHot0(nodep->fileline(), propp)) - : static_cast(new AstOneHot(nodep->fileline(), propp))); - AstIf* checkifp + AstNode* const ohot + = ((allow_none || hasDefaultElse) + ? static_cast(new AstOneHot0(nodep->fileline(), propp)) + : static_cast(new AstOneHot(nodep->fileline(), propp))); + AstIf* const checkifp = new AstIf(nodep->fileline(), new AstLogNot(nodep->fileline(), ohot), newFireAssert(nodep, "'unique if' statement violated"), newifp); checkifp->branchPred(VBranchPred::BP_UNLIKELY); @@ -282,7 +283,7 @@ private: itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) { AstNode* onep; - if (AstInsideRange* rcondp = VN_CAST(icondp, InsideRange)) { + if (AstInsideRange* const rcondp = VN_CAST(icondp, InsideRange)) { onep = rcondp->newAndFromInside(nodep->exprp(), rcondp->lhsp()->cloneTree(true), rcondp->rhsp()->cloneTree(true)); @@ -306,11 +307,11 @@ private: if (!propp) propp = new AstConst(nodep->fileline(), AstConst::BitFalse()); const bool allow_none = has_default || nodep->unique0Pragma(); - AstNode* ohot + AstNode* const ohot = (allow_none ? static_cast(new AstOneHot0(nodep->fileline(), propp)) : static_cast(new AstOneHot(nodep->fileline(), propp))); - AstIf* ifp = new AstIf( + AstIf* const ifp = new AstIf( nodep->fileline(), new AstLogNot(nodep->fileline(), ohot), newFireAssert(nodep, "synthesis parallel_case, but multiple matches found"), @@ -334,17 +335,17 @@ private: UASSERT_OBJ(ticks >= 1, nodep, "0 tick should have been checked in V3Width"); AstNode* inp = nodep->exprp()->unlinkFrBack(); AstVar* invarp = nullptr; - AstSenTree* sentreep = nodep->sentreep(); + AstSenTree* const sentreep = nodep->sentreep(); sentreep->unlinkFrBack(); - AstAlways* alwaysp + AstAlways* const alwaysp = new AstAlways(nodep->fileline(), VAlwaysKwd::ALWAYS, sentreep, nullptr); m_modp->addStmtp(alwaysp); for (uint32_t i = 0; i < ticks; ++i) { - AstVar* outvarp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, - "_Vpast_" + cvtToStr(m_modPastNum++) + "_" + cvtToStr(i), - inp->dtypep()); + AstVar* const outvarp = new AstVar( + nodep->fileline(), AstVarType::MODULETEMP, + "_Vpast_" + cvtToStr(m_modPastNum++) + "_" + cvtToStr(i), inp->dtypep()); m_modp->addStmtp(outvarp); - AstNode* assp = new AstAssignDly( + AstNode* const assp = new AstAssignDly( nodep->fileline(), new AstVarRef(nodep->fileline(), outvarp, VAccess::WRITE), inp); alwaysp->addStmtp(assp); // if (debug() >= 9) assp->dumpTree(cout, "-ass: "); @@ -378,15 +379,15 @@ private: new AstConst{fl, monNum}}; nodep->replaceWith(newsetp); // Add "always_comb if (__VmonitorOn && __VmonitorNum==N) $display(...);" - AstNode* stmtsp = nodep; - AstIf* ifp = new AstIf{ + AstNode* const stmtsp = nodep; + AstIf* const ifp = new AstIf{ fl, new AstLogAnd{fl, new AstLogNot{fl, newMonitorOffVarRefp(nodep, VAccess::READ)}, new AstEq{fl, new AstConst{fl, monNum}, newMonitorNumVarRefp(nodep, VAccess::READ)}}, stmtsp, nullptr}; ifp->branchPred(VBranchPred::BP_UNLIKELY); - AstNode* newp = new AstAlwaysPostponed{fl, ifp}; + AstNode* const newp = new AstAlwaysPostponed{fl, ifp}; m_modp->addStmtp(newp); } else if (nodep->displayType() == AstDisplayType::DT_STROBE) { nodep->displayType(AstDisplayType::DT_DISPLAY); @@ -401,10 +402,11 @@ private: new AstConst{fl, AstConst::BitTrue{}}}; nodep->replaceWith(newsetp); // Add "always_comb if (__Vstrobe) begin $display(...); __Vstrobe = '0; end" - AstNode* stmtsp = nodep; - AstIf* ifp = new AstIf{fl, new AstVarRef{fl, varp, VAccess::READ}, stmtsp, nullptr}; + AstNode* const stmtsp = nodep; + AstIf* const ifp + = new AstIf{fl, new AstVarRef{fl, varp, VAccess::READ}, stmtsp, nullptr}; ifp->branchPred(VBranchPred::BP_UNLIKELY); - AstNode* newp = new AstAlwaysPostponed{fl, ifp}; + AstNode* const newp = new AstAlwaysPostponed{fl, ifp}; stmtsp->addNext(new AstAssign{fl, new AstVarRef{fl, varp, VAccess::WRITE}, new AstConst{fl, AstConst::BitFalse{}}}); m_modp->addStmtp(newp); diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index 12bd7fddc..d4754597c 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -97,10 +97,10 @@ private: virtual void visit(AstFell* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); AstNode* exprp = nodep->exprp()->unlinkFrBack(); if (exprp->width() > 1) exprp = new AstSel(fl, exprp, 0, 1); - AstNode* past = new AstPast(fl, exprp, nullptr); + AstNode* const past = new AstPast(fl, exprp, nullptr); past->dtypeFrom(exprp); exprp = new AstAnd(fl, past, new AstNot(fl, exprp->cloneTree(false))); exprp->dtypeSetBit(); @@ -116,10 +116,10 @@ private: virtual void visit(AstRose* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); AstNode* exprp = nodep->exprp()->unlinkFrBack(); if (exprp->width() > 1) exprp = new AstSel(fl, exprp, 0, 1); - AstNode* past = new AstPast(fl, exprp, nullptr); + AstNode* const past = new AstPast(fl, exprp, nullptr); past->dtypeFrom(exprp); exprp = new AstAnd(fl, new AstNot(fl, past), exprp->cloneTree(false)); exprp->dtypeSetBit(); @@ -130,9 +130,9 @@ private: virtual void visit(AstStable* nodep) override { if (nodep->sentreep()) return; // Already processed iterateChildren(nodep); - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); AstNode* exprp = nodep->exprp()->unlinkFrBack(); - AstNode* past = new AstPast(fl, exprp, nullptr); + AstNode* const past = new AstPast(fl, exprp, nullptr); past->dtypeFrom(exprp); exprp = new AstEq(fl, past, exprp->cloneTree(false)); exprp->dtypeSetBit(); @@ -144,15 +144,15 @@ private: virtual void visit(AstImplication* nodep) override { if (nodep->sentreep()) return; // Already processed - FileLine* fl = nodep->fileline(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + FileLine* const fl = nodep->fileline(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); if (m_disablep) lhsp = new AstAnd(fl, new AstNot(fl, m_disablep), lhsp); - AstNode* past = new AstPast(fl, lhsp, nullptr); + AstNode* const past = new AstPast(fl, lhsp, nullptr); past->dtypeFrom(lhsp); - AstNode* exprp = new AstOr(fl, new AstNot(fl, past), rhsp); + AstNode* const exprp = new AstOr(fl, new AstNot(fl, past), rhsp); exprp->dtypeSetBit(); nodep->replaceWith(exprp); nodep->sentreep(newSenTree(nodep)); diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index d1e1123c6..56e9740a2 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -95,7 +95,7 @@ AstNode* AstNode::abovep() const { // Avoid supporting at other locations as would require walking // list which is likely to cause performance issues. UASSERT_OBJ(!m_nextp || firstAbovep(), this, "abovep() not allowed when in midlist"); - const AstNode* firstp = firstAbovep() ? this : m_headtailp; + const AstNode* const firstp = firstAbovep() ? this : m_headtailp; return firstp->backp(); } @@ -277,8 +277,8 @@ AstNode* AstNode::addNext(AstNode* nodep, AstNode* newp) { oldtailp->m_nextp = newp; newp->m_backp = oldtailp; // New tail needs the head - AstNode* newtailp = newp->m_headtailp; - AstNode* headp = oldtailp->m_headtailp; + AstNode* const newtailp = newp->m_headtailp; + AstNode* const headp = oldtailp->m_headtailp; oldtailp->m_headtailp = nullptr; // May be written again as new head newp->m_headtailp = nullptr; // May be written again as new tail newtailp->m_headtailp = headp; @@ -305,11 +305,11 @@ void AstNode::addNextHere(AstNode* newp) { debugTreeChange(newp, "-addHereNew: ", __LINE__, true); newp->editCountInc(); - AstNode* addlastp = newp->m_headtailp; // Last node in list to be added + AstNode* const addlastp = newp->m_headtailp; // Last node in list to be added UASSERT(!addlastp->m_nextp, "Headtailp tail isn't at the tail"); // Forward links - AstNode* oldnextp = this->m_nextp; + AstNode* const oldnextp = this->m_nextp; this->m_nextp = newp; addlastp->m_nextp = oldnextp; // Perhaps null if 'this' is not list @@ -318,7 +318,7 @@ void AstNode::addNextHere(AstNode* newp) { newp->m_backp = this; // Head/tail - AstNode* oldheadtailp = this->m_headtailp; + AstNode* const oldheadtailp = this->m_headtailp; // (!oldheadtailp) // this was&is middle of list // (oldheadtailp==this && !oldnext)// this was head AND tail (one node long list) // (oldheadtailp && oldnextp) // this was&is head of list of not just one node, not @@ -455,10 +455,10 @@ void AstNRelinker::dump(std::ostream& str) const { AstNode* AstNode::unlinkFrBackWithNext(AstNRelinker* linkerp) { debugTreeChange(this, "-unlinkWNextThs: ", __LINE__, true); - AstNode* oldp = this; + AstNode* const oldp = this; UASSERT(oldp->m_backp, "Node has no back, already unlinked?"); oldp->editCountInc(); - AstNode* backp = oldp->m_backp; + AstNode* const backp = oldp->m_backp; if (linkerp) { linkerp->m_oldp = oldp; linkerp->m_backp = backp; @@ -487,7 +487,7 @@ AstNode* AstNode::unlinkFrBackWithNext(AstNRelinker* linkerp) { AstNode* oldtailp = oldp; while (oldtailp->m_nextp) oldtailp = oldtailp->m_nextp; // Create new head/tail of old list - AstNode* oldheadp = oldtailp->m_headtailp; + AstNode* const oldheadp = oldtailp->m_headtailp; oldheadp->m_headtailp = oldp->m_backp; oldheadp->m_headtailp->m_headtailp = oldheadp; // Create new head/tail of extracted list @@ -515,10 +515,10 @@ AstNode* AstNode::unlinkFrBackWithNext(AstNRelinker* linkerp) { AstNode* AstNode::unlinkFrBack(AstNRelinker* linkerp) { debugTreeChange(this, "-unlinkFrBkThs: ", __LINE__, true); - AstNode* oldp = this; + AstNode* const oldp = this; UASSERT(oldp->m_backp, "Node has no back, already unlinked?"); oldp->editCountInc(); - AstNode* backp = oldp->m_backp; + AstNode* const backp = oldp->m_backp; if (linkerp) { linkerp->m_oldp = oldp; linkerp->m_backp = backp; @@ -560,7 +560,7 @@ AstNode* AstNode::unlinkFrBack(AstNRelinker* linkerp) { this->v3fatalSrc("Unlink of node with back not pointing to it."); } if (oldp->m_nextp) { - AstNode* newheadp = oldp->m_nextp; + AstNode* const newheadp = oldp->m_nextp; newheadp->m_backp = backp; newheadp->m_headtailp = oldp->m_headtailp; newheadp->m_headtailp->m_headtailp = newheadp; @@ -582,7 +582,7 @@ void AstNode::relink(AstNRelinker* linkerp) { UINFO(0, " EDIT: relink: "); dumpPtrs(); } - AstNode* newp = this; + AstNode* const newp = this; UASSERT(linkerp && linkerp->m_backp, "Need non-empty linker"); UASSERT(!newp->backp(), "New node already linked?"); newp->editCountInc(); @@ -592,7 +592,7 @@ void AstNode::relink(AstNRelinker* linkerp) { cout << endl; } - AstNode* backp = linkerp->m_backp; + AstNode* const backp = linkerp->m_backp; debugTreeChange(this, "-relinkNew: ", __LINE__, true); debugTreeChange(backp, "-relinkTre: ", __LINE__, true); @@ -631,10 +631,10 @@ void AstNode::relinkOneLink(AstNode*& pointpr, // Ref to pointer that gets set // Likewise there may be a old list. // Insert the whole old list following the new node's list. // Thus a unlink without next, followed by relink, gives the same list. - AstNode* newlistlastp = newp->m_headtailp; + AstNode* const newlistlastp = newp->m_headtailp; UASSERT_OBJ(!(newlistlastp->m_nextp && newlistlastp != newp), newp, "Headtailp tail isn't at the tail"); - AstNode* oldlistlastp = pointpr->m_headtailp; + AstNode* const oldlistlastp = pointpr->m_headtailp; UASSERT_OBJ(!(oldlistlastp->m_nextp && oldlistlastp != pointpr), newp, "Old headtailp tail isn't at the tail"); // Next links @@ -671,7 +671,7 @@ void AstNode::swapWith(AstNode* bp) { AstNode* AstNode::cloneTreeIter() { // private: Clone single node and children - AstNode* newp = this->clone(); + AstNode* const newp = this->clone(); if (this->m_op1p) newp->op1p(this->m_op1p->cloneTreeIterList()); if (this->m_op2p) newp->op2p(this->m_op2p->cloneTreeIterList()); if (this->m_op3p) newp->op3p(this->m_op3p->cloneTreeIterList()); @@ -688,7 +688,7 @@ AstNode* AstNode::cloneTreeIterList() { AstNode* newtailp = nullptr; // Audited to make sure this is never nullptr for (AstNode* oldp = this; oldp; oldp = oldp->m_nextp) { - AstNode* newp = oldp->cloneTreeIter(); + AstNode* const newp = oldp->cloneTreeIter(); newp->m_headtailp = nullptr; newp->m_backp = newtailp; if (newtailp) newtailp->m_nextp = newp; @@ -777,14 +777,14 @@ void AstNode::deleteTree() { #ifdef VL_LEAK_CHECKS void* AstNode::operator new(size_t size) { // Optimization note: Aligning to cache line is a loss, due to lost packing - AstNode* objp = static_cast(::operator new(size)); + AstNode* const objp = static_cast(::operator new(size)); V3Broken::addNewed(objp); return objp; } void AstNode::operator delete(void* objp, size_t size) { if (!objp) return; - AstNode* nodep = static_cast(objp); + AstNode* const nodep = static_cast(objp); V3Broken::deleted(nodep); ::operator delete(objp); } @@ -877,7 +877,7 @@ void AstNode::iterateAndNextConst(AstNVisitor& v) { // Keep following the current list even if edits change it AstNode* nodep = this; do { - AstNode* nnextp = nodep->m_nextp; + AstNode* const nnextp = nodep->m_nextp; ASTNODE_PREFETCH(nnextp); nodep->accept(v); nodep = nnextp; @@ -898,7 +898,7 @@ AstNode* AstNode::iterateSubtreeReturnEdits(AstNVisitor& v) { } else if (!nodep->backp()) { // Calling on standalone tree; insert a shim node so we can keep // track, then delete it on completion - AstBegin* tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", nodep); + AstBegin* const tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", nodep); { VL_DO_DANGLING(tempp->stmtsp()->accept(v), nodep); // nodep to null as may be replaced @@ -994,7 +994,7 @@ void AstNode::checkTreeIter(AstNode* backp) { void AstNode::checkTreeIterList(AstNode* backp) { // private: Check a (possible) list of nodes, this is always the head of the list // Audited to make sure this is never nullptr - AstNode* headp = this; + AstNode* const headp = this; AstNode* tailp = this; for (AstNode* nodep = headp; nodep; nodep = nodep->nextp()) { nodep->checkTreeIter(backp); @@ -1143,7 +1143,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump, boo checkTree(); // Broken isn't part of check tree because it can munge iterp's // set by other steps if it is called in the middle of other operations - if (AstNetlist* netp = VN_CAST(this, Netlist)) V3Broken::brokenAll(netp); + if (AstNetlist* const netp = VN_CAST(this, Netlist)) V3Broken::brokenAll(netp); } } diff --git a/src/V3Ast.h b/src/V3Ast.h index 0ff353e77..25807aecf 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -56,7 +56,7 @@ using MTaskIdSet = std::set; // Set of mtaskIds for Var sorting // For broken() function, return error string if a base of this class has a match #define BROKEN_BASE_RTN(test) \ do { \ - const char* reasonp = (test); \ + const char* const reasonp = (test); \ if (VL_UNCOVERABLE(reasonp)) return reasonp; \ } while (false) diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 970bc86ca..ddcaead8a 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -73,7 +73,7 @@ const char* AstAddrOfCFunc::broken() const { } int AstNodeSel::bitConst() const { - AstConst* constp = VN_AS(bitp(), Const); + const AstConst* const constp = VN_AS(bitp(), Const); return (constp ? constp->toSInt() : 0); } @@ -214,11 +214,11 @@ AstExecGraph::AstExecGraph(FileLine* fileline) AstExecGraph::~AstExecGraph() { VL_DO_DANGLING(delete m_depGraphp, m_depGraphp); } AstNode* AstInsideRange::newAndFromInside(AstNode* exprp, AstNode* lhsp, AstNode* rhsp) { - AstNode* ap = new AstGte(fileline(), exprp->cloneTree(true), lhsp); - AstNode* bp = new AstLte(fileline(), exprp->cloneTree(true), rhsp); + AstNode* const ap = new AstGte(fileline(), exprp->cloneTree(true), lhsp); + AstNode* const bp = new AstLte(fileline(), exprp->cloneTree(true), rhsp); ap->fileline()->modifyWarnOff(V3ErrorCode::UNSIGNED, true); bp->fileline()->modifyWarnOff(V3ErrorCode::CMPCONST, true); - AstNode* newp = new AstAnd(fileline(), ap, bp); + AstNode* const newp = new AstAnd(fileline(), ap, bp); return newp; } @@ -336,7 +336,7 @@ string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string& string AstVar::vlEnumType() const { string arg; - AstBasicDType* bdtypep = basicp(); + const AstBasicDType* const bdtypep = basicp(); const bool strtype = bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::STRING; if (bdtypep && bdtypep->keyword() == AstBasicDTypeKwd::CHARPTR) { return "VLVT_PTR"; @@ -377,7 +377,7 @@ string AstVar::vlEnumDir() const { out += "|VLVF_PUB_RD"; } // - if (AstBasicDType* bdtypep = basicp()) { + if (const AstBasicDType* const bdtypep = basicp()) { if (bdtypep->keyword().isDpiCLayout()) out += "|VLVF_DPI_CLAY"; } return out; diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 404b96803..d8797ce62 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -59,7 +59,7 @@ public: class BeginVisitor final : public AstNVisitor { private: // STATE - BeginState* m_statep; // Current global state + BeginState* const m_statep; // Current global state AstNodeModule* m_modp = nullptr; // Current module AstNodeFTask* m_ftaskp = nullptr; // Current function/task AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index 66beaeb2a..a1f1e1613 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -191,7 +191,7 @@ private: void processEnter(AstNode* nodep) { nodep->brokenState(m_brokenCntCurrentUnder); - const char* whyp = nodep->broken(); + const char* const whyp = nodep->broken(); UASSERT_OBJ(!whyp, nodep, "Broken link in node (or something without maybePointedTo): " << whyp); if (nodep->dtypep()) { @@ -210,7 +210,8 @@ private: } UASSERT_OBJ(!nodep->getChildDTypep(), nodep, "childDTypep() non-null on node after should have removed"); - if (const AstNodeDType* dnodep = VN_CAST(nodep, NodeDType)) checkWidthMin(dnodep); + if (const AstNodeDType* const dnodep = VN_CAST(nodep, NodeDType)) + checkWidthMin(dnodep); } checkWidthMin(nodep); } diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index fcee962dc..aebf6ceed 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -139,7 +139,7 @@ void V3CCtors::evalAsserts() { for (AstNode* np = modp->stmtsp(); np; np = np->nextp()) { if (AstVar* const varp = VN_CAST(np, Var)) { if (varp->isPrimaryInish() && !varp->isSc()) { - if (AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { + if (const AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { const int storedWidth = basicp->widthAlignBytes() * 8; const int lastWordWidth = varp->width() % storedWidth; if (lastWordWidth != 0) { @@ -200,7 +200,7 @@ void V3CCtors::cctorsAll() { } } } - if (AstClass* const classp = VN_CAST(modp, Class)) { + if (const AstClass* const classp = VN_CAST(modp, Class)) { AstCFunc* const funcp = new AstCFunc{modp->fileline(), "~", nullptr, ""}; funcp->isDestructor(true); funcp->isStatic(false); diff --git a/src/V3Case.cpp b/src/V3Case.cpp index b966dedb5..7e3502d99 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -170,7 +170,7 @@ private: itemp = VN_AS(itemp->nextp(), CaseItem)) { for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) { // if (debug() >= 9) icondp->dumpTree(cout, " caseitem: "); - AstConst* iconstp = VN_AS(icondp, Const); + AstConst* const iconstp = VN_AS(icondp, Const); UASSERT_OBJ(iconstp, nodep, "above 'can't parse' should have caught this"); if (neverItem(nodep, iconstp)) { // X in casez can't ever be executed @@ -289,10 +289,11 @@ private: // V3Number nummask (cexprp, cexprp->width(), (1UL<fileline(), cexprp->cloneTree(false), // new AstConst(cexprp->fileline(), nummask)); - AstNode* and1p = new AstSel(cexprp->fileline(), cexprp->cloneTree(false), msb, 1); - AstNode* eqp + AstNode* const and1p + = new AstSel(cexprp->fileline(), cexprp->cloneTree(false), msb, 1); + AstNode* const eqp = new AstNeq(cexprp->fileline(), new AstConst(cexprp->fileline(), 0), and1p); - AstIf* ifp = new AstIf(cexprp->fileline(), eqp, tree1p, tree0p); + AstIf* const ifp = new AstIf(cexprp->fileline(), eqp, tree1p, tree0p); ifp->user3(1); // So we don't bother to clone it return ifp; } @@ -302,11 +303,11 @@ private: // CASEx(cexpr,.... // -> tree of IF(msb, IF(msb-1, 11, 10) // IF(msb-1, 01, 00)) - AstNode* cexprp = nodep->exprp()->unlinkFrBack(); + AstNode* const cexprp = nodep->exprp()->unlinkFrBack(); if (debug() >= 9) { // LCOV_EXCL_START for (uint32_t i = 0; i < (1UL << m_caseWidth); ++i) { - if (AstNode* itemp = m_valueItem[i]) { + if (const AstNode* const itemp = m_valueItem[i]) { UINFO(9, "Value " << std::hex << i << " " << itemp << endl); } } @@ -335,7 +336,7 @@ private: // -> IF((cexpr==icond1),istmts1, // IF((EQ (AND MASK cexpr) (AND MASK icond1) // ,istmts2, istmts3 - AstNode* cexprp = nodep->exprp()->unlinkFrBack(); + AstNode* const cexprp = nodep->exprp()->unlinkFrBack(); // We'll do this in two stages. First stage, convert the conditions to // the appropriate IF AND terms. if (debug() >= 9) nodep->dumpTree(cout, " _comp_IN: "); @@ -355,7 +356,7 @@ private: icondp->unlinkFrBack(); AstNode* condp = nullptr; // Default is to use and1p/and2p - AstConst* iconstp = VN_CAST(icondp, Const); + AstConst* const iconstp = VN_CAST(icondp, Const); if (iconstp && neverItem(nodep, iconstp)) { // X in casez can't ever be executed VL_DO_DANGLING(icondp->deleteTree(), icondp); @@ -373,18 +374,19 @@ private: nummask.opBitsNonX(iconstp->num()); V3Number numval(itemp, iconstp->width()); numval.opBitsOne(iconstp->num()); - AstNode* and1p = new AstAnd(itemp->fileline(), cexprp->cloneTree(false), - new AstConst(itemp->fileline(), nummask)); - AstNode* and2p = new AstAnd(itemp->fileline(), - new AstConst(itemp->fileline(), numval), - new AstConst(itemp->fileline(), nummask)); + AstNode* const and1p + = new AstAnd(itemp->fileline(), cexprp->cloneTree(false), + new AstConst(itemp->fileline(), nummask)); + AstNode* const and2p = new AstAnd( + itemp->fileline(), new AstConst(itemp->fileline(), numval), + new AstConst(itemp->fileline(), nummask)); VL_DO_DANGLING(icondp->deleteTree(), icondp); VL_DANGLING(iconstp); condp = AstEq::newTyped(itemp->fileline(), and1p, and2p); } else { // Not a caseX mask, we can simply build CASEEQ(cexpr icond) - AstNode* and1p = cexprp->cloneTree(false); - AstNode* and2p = icondp; + AstNode* const and1p = cexprp->cloneTree(false); + AstNode* const and2p = icondp; condp = AstEq::newTyped(itemp->fileline(), and1p, and2p); } if (!ifexprp) { @@ -417,15 +419,15 @@ private: AstIf* itemnextp = nullptr; for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), CaseItem)) { - AstNode* istmtsp = itemp->bodysp(); // Maybe null -- no action. + AstNode* const istmtsp = itemp->bodysp(); // Maybe null -- no action. if (istmtsp) istmtsp->unlinkFrBackWithNext(); // Expressioned clause - AstNode* ifexprp = itemp->condsp()->unlinkFrBack(); + AstNode* const ifexprp = itemp->condsp()->unlinkFrBack(); { // Prepare for next group if (++depth > CASE_ENCODER_GROUP_DEPTH) depth = 1; if (depth == 1) { // First group or starting new group itemnextp = nullptr; - AstIf* newp + AstIf* const newp = new AstIf(itemp->fileline(), ifexprp->cloneTree(true), nullptr, nullptr); if (groupnextp) { groupnextp->addElsesp(newp); @@ -434,7 +436,7 @@ private: } groupnextp = newp; } else { // Continue group, modify if condition to OR in this new condition - AstNode* condp = groupnextp->condp()->unlinkFrBack(); + AstNode* const condp = groupnextp->condp()->unlinkFrBack(); groupnextp->condp( new AstOr(ifexprp->fileline(), condp, ifexprp->cloneTree(true))); } @@ -446,7 +448,7 @@ private: VL_DO_DANGLING(itemexprp->deleteTree(), itemexprp); itemexprp = new AstConst(itemp->fileline(), AstConst::BitTrue()); } - AstIf* newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, nullptr); + AstIf* const newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, nullptr); if (itemnextp) { itemnextp->addElsesp(newp); } else { @@ -474,7 +476,7 @@ private: // covered, we're done with it. // Else, convert to a normal statement parallel with the case statement. if (nodep->notParallelp() && !noOverlapsAllCovered) { - AstNode* parp = nodep->notParallelp()->unlinkFrBackWithNext(); + AstNode* const parp = nodep->notParallelp()->unlinkFrBackWithNext(); nodep->addNextHere(parp); } } diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 03e6aedab..2bd9da2cb 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -50,8 +50,8 @@ public: // Graph support classes class CdcEitherVertex VL_NOT_FINAL : public V3GraphVertex { - AstScope* m_scopep; - AstNode* m_nodep; + AstScope* const m_scopep; + AstNode* const m_nodep; AstSenTree* m_srcDomainp = nullptr; AstSenTree* m_dstDomainp = nullptr; bool m_srcDomainSet : 1; @@ -84,7 +84,7 @@ public: }; class CdcVarVertex final : public CdcEitherVertex { - AstVarScope* m_varScp; + AstVarScope* const m_varScp; int m_cntAsyncRst = 0; bool m_fromFlop = false; @@ -266,7 +266,7 @@ private: if (varscp->varp()->isPrimaryIO()) { // Create IO vertex - note it's relative to the pointed to var, not where we are // now This allows reporting to easily print the input statement - CdcLogicVertex* ioVertexp + CdcLogicVertex* const ioVertexp = new CdcLogicVertex(&m_graph, varscp->scopep(), varscp->varp(), nullptr); if (varscp->varp()->isWritable()) { new V3GraphEdge(&m_graph, vertexp, ioVertexp, 1); @@ -351,12 +351,12 @@ private: // userClearVertices is very slow, so we use a generation count instead m_graph.userClearVertices(); // user1: uint32_t - was analyzed generation for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (CdcVarVertex* vvertexp = dynamic_cast(itp)) { + if (CdcVarVertex* const vvertexp = dynamic_cast(itp)) { if (vvertexp->cntAsyncRst()) { m_userGeneration++; // Effectively a userClearVertices() UINFO(8, " Trace One async: " << vvertexp << endl); // Twice, as we need to detect, then propagate - CdcEitherVertex* markp = traceAsyncRecurse(vvertexp, false); + CdcEitherVertex* const markp = traceAsyncRecurse(vvertexp, false); if (markp) { // Mark is non-nullptr if something bad on this path UINFO(9, " Trace One bad! " << vvertexp << endl); m_userGeneration++; // Effectively a userClearVertices() @@ -381,7 +381,7 @@ private: // Clear out in prep for marking next path if (!mark) vertexp->asyncPath(false); - if (CdcLogicVertex* vvertexp = dynamic_cast(vertexp)) { + if (CdcLogicVertex* const vvertexp = dynamic_cast(vertexp)) { // Any logic considered bad, at the moment, anyhow if (vvertexp->hazard() && !mark_outp) mark_outp = vvertexp; // And keep tracing back so the user can understand what's up @@ -391,7 +391,8 @@ private: if (vvertexp->varScp()->varp()->isPrimaryInish()) { // Show the source "input" statement if it exists for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - CdcEitherVertex* eFromVertexp = static_cast(edgep->fromp()); + CdcEitherVertex* const eFromVertexp + = static_cast(edgep->fromp()); eFromVertexp->asyncPath(true); } return nullptr; @@ -399,7 +400,8 @@ private: // Also ok if from flop, but partially trace the flop so more obvious to users if (vvertexp->fromFlop()) { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - CdcEitherVertex* eFromVertexp = static_cast(edgep->fromp()); + CdcEitherVertex* const eFromVertexp + = static_cast(edgep->fromp()); eFromVertexp->asyncPath(true); } return nullptr; @@ -407,8 +409,8 @@ private: } for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - CdcEitherVertex* eFromVertexp = static_cast(edgep->fromp()); - CdcEitherVertex* submarkp = traceAsyncRecurse(eFromVertexp, mark); + CdcEitherVertex* const eFromVertexp = static_cast(edgep->fromp()); + CdcEitherVertex* const submarkp = traceAsyncRecurse(eFromVertexp, mark); if (submarkp && !mark_outp) mark_outp = submarkp; } @@ -417,14 +419,14 @@ private: } void dumpAsync(CdcVarVertex* vertexp, CdcEitherVertex* markp) { - AstNode* nodep = vertexp->varScp(); + const AstNode* const nodep = vertexp->varScp(); *m_ofp << "\n"; *m_ofp << "\n"; CdcEitherVertex* targetp = vertexp; // One example destination flop (of possibly many) for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - CdcEitherVertex* eToVertexp = static_cast(edgep->top()); + CdcEitherVertex* const eToVertexp = static_cast(edgep->top()); if (!eToVertexp) targetp = eToVertexp; - if (CdcLogicVertex* vvertexp = dynamic_cast(eToVertexp)) { + if (const CdcLogicVertex* const vvertexp = dynamic_cast(eToVertexp)) { if (vvertexp->isFlop() // IE the target flop that is upsetting us && edgep->weight() >= CDC_WEIGHT_ASYNC) { // And var feeds an async reset line targetp = eToVertexp; @@ -452,13 +454,13 @@ private: const string cont = prefix + sep; string nextsep = " "; for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - CdcEitherVertex* eFromVertexp = static_cast(edgep->fromp()); + CdcEitherVertex* const eFromVertexp = static_cast(edgep->fromp()); if (dumpAsyncRecurse(eFromVertexp, cont, nextsep, level + 1)) nextsep = " | "; } // Dump single variable/logic block // See also OrderGraph::loopsVertexCb(V3GraphVertex* vertexp) - AstNode* nodep = vertexp->nodep(); + AstNode* const nodep = vertexp->nodep(); string front = pad(filelineWidth(), nodep->fileline()->ascii() + ":") + " " + prefix + " +- "; if (VN_IS(nodep, VarScope)) { @@ -473,7 +475,7 @@ private: if (level) *m_ofp << V3OutFile::indentSpaces(filelineWidth()) << " " << prefix << nextsep << "\n"; - if (CdcLogicVertex* vvertexp = dynamic_cast(vertexp)) { + if (CdcLogicVertex* const vvertexp = dynamic_cast(vertexp)) { // Now that we've printed a path with this hazard, don't bother to print any more // Otherwise, we'd get a path for almost every destination flop vvertexp->clearHazard(); @@ -499,7 +501,7 @@ private: UINFO(9, " Trace Direction " << (traceDests ? "dst" : "src") << endl); m_graph.userClearVertices(); // user1: bool - was analyzed for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (CdcVarVertex* vvertexp = dynamic_cast(itp)) { + if (CdcVarVertex* const vvertexp = dynamic_cast(itp)) { UINFO(9, " Trace One edge: " << vvertexp << endl); edgeDomainRecurse(vvertexp, traceDests, 0); } @@ -514,8 +516,8 @@ private: std::deque report; // Sort output by name for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (CdcVarVertex* vvertexp = dynamic_cast(itp)) { - AstVar* varp = vvertexp->varScp()->varp(); + if (const CdcVarVertex* const vvertexp = dynamic_cast(itp)) { + const AstVar* const varp = vvertexp->varScp()->varp(); { string what = "wire"; if (varp->isPrimaryIO()) what = varp->direction().prettyName(); @@ -558,11 +560,11 @@ private: } // Fully computed std::set senouts; // List of all sensitivities for new signal - if (CdcLogicVertex* vvertexp = dynamic_cast(vertexp)) { + if (const CdcLogicVertex* const vvertexp = dynamic_cast(vertexp)) { if (vvertexp) {} // Unused } else if (CdcVarVertex* vvertexp = dynamic_cast(vertexp)) { // If primary I/O, give it domain of the input - AstVar* varp = vvertexp->varScp()->varp(); + const AstVar* const varp = vvertexp->varScp()->varp(); if (varp->isPrimaryIO() && varp->isNonOutput() && !traceDests) { senouts.insert(new AstSenTree( varp->fileline(), new AstSenItem(varp->fileline(), AstSenItem::Combo()))); @@ -572,13 +574,14 @@ private: // Now combine domains of sources/dests if (traceDests) { for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - CdcEitherVertex* eToVertexp = static_cast(edgep->top()); + CdcEitherVertex* const eToVertexp = static_cast(edgep->top()); edgeDomainRecurse(eToVertexp, traceDests, level + 1); if (eToVertexp->dstDomainp()) senouts.insert(eToVertexp->dstDomainp()); } } else { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - CdcEitherVertex* eFromVertexp = static_cast(edgep->fromp()); + CdcEitherVertex* const eFromVertexp + = static_cast(edgep->fromp()); edgeDomainRecurse(eFromVertexp, traceDests, level + 1); if (eFromVertexp->srcDomainp()) senouts.insert(eFromVertexp->srcDomainp()); } @@ -653,9 +656,9 @@ private: virtual void visit(AstNodeVarRef* nodep) override { if (m_scopep) { UASSERT_OBJ(m_logicVertexp, nodep, "Var ref not under a logic block"); - AstVarScope* varscp = nodep->varScopep(); + AstVarScope* const varscp = nodep->varScopep(); UASSERT_OBJ(varscp, nodep, "Var didn't get varscoped in V3Scope.cpp"); - CdcVarVertex* varvertexp = makeVarVertex(varscp); + CdcVarVertex* const varvertexp = makeVarVertex(varscp); UINFO(5, " VARREF to " << varscp << endl); // We use weight of one for normal edges, // Weight of CDC_WEIGHT_ASYNC to indicate feeds async (for reporting) diff --git a/src/V3Class.cpp b/src/V3Class.cpp index cd7fdb6f7..7d1393f9e 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -53,14 +53,16 @@ private: v3Global.rootp()->addModulep(nodep); // Make containing package // Note origName is the same as the class origName so errors look correct - AstClassPackage* packagep = new AstClassPackage(nodep->fileline(), nodep->origName()); + AstClassPackage* const packagep + = new AstClassPackage(nodep->fileline(), nodep->origName()); packagep->name(nodep->name() + "__Vclpkg"); nodep->classOrPackagep(packagep); packagep->classp(nodep); v3Global.rootp()->addModulep(packagep); // Add package to hierarchy - AstCell* cellp = new AstCell(packagep->fileline(), packagep->fileline(), packagep->name(), - packagep->name(), nullptr, nullptr, nullptr); + AstCell* const cellp + = new AstCell(packagep->fileline(), packagep->fileline(), packagep->name(), + packagep->name(), nullptr, nullptr, nullptr); cellp->modp(packagep); v3Global.rootp()->topModulep()->addStmtp(cellp); // Find class's scope @@ -72,8 +74,9 @@ private: UASSERT_OBJ(classScopep, nodep, "No scope under class"); // Add scope - AstScope* scopep = new AstScope(nodep->fileline(), packagep, classScopep->name(), - classScopep->aboveScopep(), classScopep->aboveCellp()); + AstScope* const scopep + = new AstScope(nodep->fileline(), packagep, classScopep->name(), + classScopep->aboveScopep(), classScopep->aboveCellp()); packagep->addStmtp(scopep); // Iterate VL_RESTORER(m_prefix); diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 5afa46e57..4d0295a43 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -67,16 +67,16 @@ private: } void setCppWidth(AstNode* nodep) { nodep->user2(true); // Don't resize it again - AstNodeDType* old_dtypep = nodep->dtypep(); + AstNodeDType* const old_dtypep = nodep->dtypep(); const int width = cppWidth(nodep); // widthMin is unchanged if (old_dtypep->width() != width) { // Since any given dtype's cppWidth() is the same, we can just // remember one conversion for each, and reuse it - if (AstNodeDType* new_dtypep = VN_CAST(old_dtypep->user3p(), NodeDType)) { + if (AstNodeDType* const new_dtypep = VN_CAST(old_dtypep->user3p(), NodeDType)) { nodep->dtypep(new_dtypep); } else { nodep->dtypeChgWidth(width, nodep->widthMin()); - AstNodeDType* new_dtypep2 = nodep->dtypep(); + AstNodeDType* const new_dtypep2 = nodep->dtypep(); UASSERT_OBJ(new_dtypep2 != old_dtypep, nodep, "Dtype didn't change when width changed"); old_dtypep->user3p(new_dtypep2); // Remember for next time @@ -126,7 +126,7 @@ private: computeCppWidth(nodep); V3Number mask(nodep, cppWidth(nodep)); mask.setMask(nodep->widthMin()); - AstNode* cleanp + AstNode* const cleanp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), mask), nodep); cleanp->dtypeFrom(nodep); // Otherwise the AND normally picks LHS relinkHandle.relink(cleanp); @@ -138,7 +138,7 @@ private: void ensureCleanAndNext(AstNode* nodep) { // Editing list, careful looping! for (AstNode* exprp = nodep; exprp;) { - AstNode* nextp = exprp->nextp(); + AstNode* const nextp = exprp->nextp(); ensureClean(exprp); exprp = nextp; } diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 4cad9d93d..c16316a3e 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -92,30 +92,30 @@ private: AstVarScope* getCreateLastClk(AstVarScope* vscp) { if (vscp->user1p()) return static_cast(vscp->user1p()); - AstVar* varp = vscp->varp(); + const AstVar* const varp = vscp->varp(); if (!varp->width1()) { varp->v3warn(E_UNSUPPORTED, "Unsupported: Clock edge on non-single bit signal: " << varp->prettyNameQ()); } string newvarname = (string("__Vclklast__") + vscp->scopep()->nameDotless() + "__" + varp->name()); - AstVar* newvarp = new AstVar(vscp->fileline(), AstVarType::MODULETEMP, newvarname, - VFlagLogicPacked(), 1); + AstVar* const newvarp = new AstVar(vscp->fileline(), AstVarType::MODULETEMP, newvarname, + VFlagLogicPacked(), 1); newvarp->noReset(true); // Reset by below assign m_modp->addStmtp(newvarp); - AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopep, newvarp); + AstVarScope* const newvscp = new AstVarScope(vscp->fileline(), m_scopep, newvarp); vscp->user1p(newvscp); m_scopep->addVarp(newvscp); // Add init AstNode* fromp = new AstVarRef(newvarp->fileline(), vscp, VAccess::READ); if (v3Global.opt.xInitialEdge()) fromp = new AstNot(fromp->fileline(), fromp); - AstNode* newinitp = new AstAssign( + AstNode* const newinitp = new AstAssign( vscp->fileline(), new AstVarRef(newvarp->fileline(), newvscp, VAccess::WRITE), fromp); addToInitial(newinitp); // At bottom, assign them - AstAssign* finalp = new AstAssign(vscp->fileline(), - new AstVarRef(vscp->fileline(), newvscp, VAccess::WRITE), - new AstVarRef(vscp->fileline(), vscp, VAccess::READ)); + AstAssign* const finalp = new AstAssign( + vscp->fileline(), new AstVarRef(vscp->fileline(), newvscp, VAccess::WRITE), + new AstVarRef(vscp->fileline(), vscp, VAccess::READ)); m_evalFuncp->addFinalsp(finalp); // UINFO(4, "New Last: " << newvscp << endl); @@ -137,16 +137,16 @@ private: return nullptr; } UASSERT_OBJ(nodep->varrefp(), nodep, "No clock found on sense item"); - AstVarScope* clkvscp = nodep->varrefp()->varScopep(); + AstVarScope* const clkvscp = nodep->varrefp()->varScopep(); if (nodep->edgeType() == VEdgeType::ET_POSEDGE) { - AstVarScope* lastVscp = getCreateLastClk(clkvscp); + AstVarScope* const lastVscp = getCreateLastClk(clkvscp); newp = new AstAnd( nodep->fileline(), new AstVarRef(nodep->fileline(), nodep->varrefp()->varScopep(), VAccess::READ), new AstNot(nodep->fileline(), new AstVarRef(nodep->fileline(), lastVscp, VAccess::READ))); } else if (nodep->edgeType() == VEdgeType::ET_NEGEDGE) { - AstVarScope* lastVscp = getCreateLastClk(clkvscp); + AstVarScope* const lastVscp = getCreateLastClk(clkvscp); newp = new AstAnd( nodep->fileline(), new AstNot(nodep->fileline(), @@ -154,7 +154,7 @@ private: VAccess::READ)), new AstVarRef(nodep->fileline(), lastVscp, VAccess::READ)); } else if (nodep->edgeType() == VEdgeType::ET_BOTHEDGE) { - AstVarScope* lastVscp = getCreateLastClk(clkvscp); + AstVarScope* const lastVscp = getCreateLastClk(clkvscp); newp = new AstXor( nodep->fileline(), new AstVarRef(nodep->fileline(), nodep->varrefp()->varScopep(), VAccess::READ), diff --git a/src/V3Common.cpp b/src/V3Common.cpp index 0cb564a5d..7dcf3f8b7 100644 --- a/src/V3Common.cpp +++ b/src/V3Common.cpp @@ -64,7 +64,7 @@ static void makeToStringMiddle(AstClass* nodep) { funcp->addStmtsp(new AstCStmt{nodep->fileline(), "std::string out;\n"}); std::string comma; for (AstNode* itemp = nodep->membersp(); itemp; itemp = itemp->nextp()) { - if (auto* const varp = VN_CAST(itemp, Var)) { + if (const auto* const varp = VN_CAST(itemp, Var)) { if (!varp->isParam()) { string stmt = "out += \""; stmt += comma; diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 93dd8a81f..32609217e 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -103,7 +103,7 @@ public: // Apply all attributes to the variable void apply(AstVar* varp) { for (const_iterator it = begin(); it != end(); ++it) { - AstNode* newp = new AstAttrOf(varp->fileline(), it->m_type); + AstNode* const newp = new AstAttrOf(varp->fileline(), it->m_type); varp->addAttrsp(newp); if (it->m_type == AstAttrType::VAR_PUBLIC_FLAT_RW && it->m_sentreep) { newp->addNext(new AstAlwaysPublic(varp->fileline(), it->m_sentreep, nullptr)); @@ -192,11 +192,11 @@ public: if (m_inline) { AstPragmaType type = m_inlineValue ? AstPragmaType::INLINE_MODULE : AstPragmaType::NO_INLINE_MODULE; - AstNode* nodep = new AstPragma(modp->fileline(), type); + AstNode* const nodep = new AstPragma(modp->fileline(), type); modp->addStmtp(nodep); } for (auto it = m_modPragmas.cbegin(); it != m_modPragmas.cend(); ++it) { - AstNode* nodep = new AstPragma(modp->fileline(), *it); + AstNode* const nodep = new AstPragma(modp->fileline(), *it); modp->addStmtp(nodep); } } diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 579931e38..e32a395e5 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -116,20 +116,20 @@ private: // Someday the user might be allowed to specify a different page suffix const string page = page_prefix + "/" + m_modp->prettyName(); - AstCoverDecl* declp = new AstCoverDecl(fl, page, comment, linescov, offset); + AstCoverDecl* const declp = new AstCoverDecl(fl, page, comment, linescov, offset); declp->hier(hier); m_modp->addStmtp(declp); UINFO(9, "new " << declp << endl); - AstCoverInc* incp = new AstCoverInc(fl, declp); + AstCoverInc* const incp = new AstCoverInc(fl, declp); if (!trace_var_name.empty() && v3Global.opt.traceCoverage()) { - AstVar* varp = new AstVar(incp->fileline(), AstVarType::MODULETEMP, trace_var_name, - incp->findUInt32DType()); + AstVar* const varp = new AstVar(incp->fileline(), AstVarType::MODULETEMP, + trace_var_name, incp->findUInt32DType()); varp->trace(true); varp->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true); m_modp->addStmtp(varp); UINFO(5, "New coverage trace: " << varp << endl); - AstAssign* assp = new AstAssign( + AstAssign* const assp = new AstAssign( incp->fileline(), new AstVarRef(incp->fileline(), varp, VAccess::WRITE), new AstAdd(incp->fileline(), new AstVarRef(incp->fileline(), varp, VAccess::READ), new AstConst(incp->fileline(), AstConst::WidthedValue(), 32, 1))); @@ -209,7 +209,7 @@ private: // VISITORS - BOTH virtual void visit(AstNodeModule* nodep) override { - AstNodeModule* origModp = m_modp; + AstNodeModule* const origModp = m_modp; VL_RESTORER(m_modp); VL_RESTORER(m_state); { @@ -240,10 +240,10 @@ private: iterateChildren(nodep); if (m_state.lineCoverageOn(nodep)) { lineTrack(nodep); - AstNode* newp + AstNode* const newp = newCoverInc(nodep->fileline(), "", "v_line", "block", linesCov(m_state, nodep), 0, traceNameForLine(nodep, "block")); - if (AstNodeProcedure* itemp = VN_CAST(nodep, NodeProcedure)) { + if (AstNodeProcedure* const itemp = VN_CAST(nodep, NodeProcedure)) { itemp->addStmtp(newp); } else if (AstNodeFTask* itemp = VN_CAST(nodep, NodeFTask)) { itemp->addStmtsp(newp); @@ -261,7 +261,7 @@ private: iterateChildren(nodep); if (m_modp && !m_inToggleOff && !m_state.m_inModOff && nodep->fileline()->coverageOn() && v3Global.opt.coverageToggle()) { - const char* disablep = varIgnoreToggle(nodep); + const char* const disablep = varIgnoreToggle(nodep); if (disablep) { UINFO(4, " Disable Toggle: " << disablep << " " << nodep << endl); } else { @@ -279,7 +279,7 @@ private: // Add signal to hold the old value const string newvarname = string("__Vtogcov__") + nodep->shortName(); - AstVar* chgVarp + AstVar* const chgVarp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, newvarname, nodep); chgVarp->fileline()->modifyWarnOff(V3ErrorCode::UNUSED, true); m_modp->addStmtp(chgVarp); @@ -298,7 +298,7 @@ private: } void toggleVarBottom(const ToggleEnt& above, const AstVar* varp) { - AstCoverToggle* newp = new AstCoverToggle( + AstCoverToggle* const newp = new AstCoverToggle( varp->fileline(), newCoverInc(varp->fileline(), "", "v_toggle", varp->name() + above.m_comment, "", 0, ""), @@ -308,7 +308,7 @@ private: void toggleVarRecurse(AstNodeDType* dtypep, int depth, // per-iteration const ToggleEnt& above, AstVar* varp, AstVar* chgVarp) { // Constant - if (const AstBasicDType* bdtypep = VN_CAST(dtypep, BasicDType)) { + if (const AstBasicDType* const bdtypep = VN_CAST(dtypep, BasicDType)) { if (bdtypep->isRanged()) { for (int index_docs = bdtypep->lo(); index_docs < bdtypep->hi() + 1; ++index_docs) { @@ -338,7 +338,7 @@ private: } } else if (AstPackArrayDType* adtypep = VN_CAST(dtypep, PackArrayDType)) { for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) { - AstNodeDType* subtypep = adtypep->subDTypep()->skipRefp(); + AstNodeDType* const subtypep = adtypep->subDTypep()->skipRefp(); const int index_code = index_docs - adtypep->lo(); ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]", new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true), @@ -353,7 +353,7 @@ private: // For now it's packed, so similar to array for (AstMemberDType* itemp = adtypep->membersp(); itemp; itemp = VN_AS(itemp->nextp(), MemberDType)) { - AstNodeDType* subtypep = itemp->subDTypep()->skipRefp(); + AstNodeDType* const subtypep = itemp->subDTypep()->skipRefp(); const int index_code = itemp->lsb(); ToggleEnt newent(above.m_comment + string(".") + itemp->name(), new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true), @@ -365,8 +365,8 @@ private: } } else if (AstUnionDType* adtypep = VN_CAST(dtypep, UnionDType)) { // Arbitrarily handle only the first member of the union - if (AstMemberDType* itemp = adtypep->membersp()) { - AstNodeDType* subtypep = itemp->subDTypep()->skipRefp(); + if (AstMemberDType* const itemp = adtypep->membersp()) { + AstNodeDType* const subtypep = itemp->subDTypep()->skipRefp(); ToggleEnt newent(above.m_comment + string(".") + itemp->name(), above.m_varRefp->cloneTree(true), above.m_chgRefp->cloneTree(true)); diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index 0bab93685..905b52969 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -60,18 +60,18 @@ private: const auto dupit = dupFinder.findDuplicate(nodep->origp()); if (dupit == dupFinder.end()) break; // - AstNode* duporigp = dupit->second; + const AstNode* const duporigp = dupit->second; // Note hashed will point to the original variable (what's // duplicated), not the covertoggle, but we need to get back to the // covertoggle which is immediately above, so: - AstCoverToggle* removep = VN_AS(duporigp->backp(), CoverToggle); + AstCoverToggle* const removep = VN_AS(duporigp->backp(), CoverToggle); UASSERT_OBJ(removep, nodep, "CoverageJoin duplicate of wrong type"); UINFO(8, " Orig " << nodep << " -->> " << nodep->incp()->declp() << endl); UINFO(8, " dup " << removep << " -->> " << removep->incp()->declp() << endl); // The CoverDecl the duplicate pointed to now needs to point to the // original's data. I.e. the duplicate will get the coverage number // from the non-duplicate - AstCoverDecl* datadeclp = nodep->incp()->declp()->dataDeclThisp(); + AstCoverDecl* const datadeclp = nodep->incp()->declp()->dataDeclThisp(); removep->incp()->declp()->dataDeclp(datadeclp); UINFO(8, " new " << removep->incp()->declp() << endl); // Mark the found node as a duplicate of the first node diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 78592c9ca..bbdcad753 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -102,9 +102,9 @@ private: void checkAll(AstNode* nodep) { if (nodep != nodep->dtypep()) { // NodeDTypes reference themselves - if (AstNode* subnodep = nodep->dtypep()) subnodep->user1Inc(); + if (AstNode* const subnodep = nodep->dtypep()) subnodep->user1Inc(); } - if (AstNode* subnodep = nodep->getChildDTypep()) subnodep->user1Inc(); + if (AstNode* const subnodep = nodep->getChildDTypep()) subnodep->user1Inc(); } void checkVarRef(AstNodeVarRef* nodep) { if (nodep->classOrPackagep() && m_elimCells) nodep->classOrPackagep(nullptr); @@ -116,8 +116,8 @@ private: ) { m_dtypesp.push_back(nodep); } - if (AstNode* subnodep = nodep->virtRefDTypep()) subnodep->user1Inc(); - if (AstNode* subnodep = nodep->virtRefDType2p()) subnodep->user1Inc(); + if (AstNode* const subnodep = nodep->virtRefDTypep()) subnodep->user1Inc(); + if (AstNode* const subnodep = nodep->virtRefDType2p()) subnodep->user1Inc(); } // VISITORS @@ -129,7 +129,7 @@ private: if (!nodep->dead()) { iterateChildren(nodep); checkAll(nodep); - if (AstClass* classp = VN_CAST(nodep, Class)) { + if (AstClass* const classp = VN_CAST(nodep, Class)) { if (classp->extendsp()) classp->extendsp()->user1Inc(); if (classp->classOrPackagep()) classp->classOrPackagep()->user1Inc(); m_classesp.push_back(classp); @@ -282,7 +282,7 @@ private: iterateAndNextNull(nodep->rhsp()); checkAll(nodep); // Has to be direct assignment without any EXTRACTing. - AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); + AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef); if (varrefp && !m_sideEffect && varrefp->varScopep()) { // For simplicity, we only remove post-scoping m_assignMap.emplace(varrefp->varScopep(), nodep); @@ -338,7 +338,7 @@ private: retry = false; for (std::vector::iterator it = m_scopesp.begin(); it != m_scopesp.end(); ++it) { - AstScope* scp = *it; + AstScope* const scp = *it; if (!scp) continue; if (scp->user1() == 0) { UINFO(4, " Dead AstScope " << scp << endl); @@ -364,7 +364,7 @@ private: for (bool retry = true; retry;) { retry = false; for (auto& itr : m_classesp) { - if (AstClass* nodep = itr) { // nullptr if deleted earlier + if (AstClass* const nodep = itr) { // nullptr if deleted earlier if (nodep->user1() == 0) { if (nodep->extendsp()) nodep->extendsp()->user1Inc(-1); if (nodep->classOrPackagep()) nodep->classOrPackagep()->user1Inc(-1); @@ -385,7 +385,7 @@ private: std::pair eqrange = m_assignMap.equal_range(vscp); for (AssignMap::iterator itr = eqrange.first; itr != eqrange.second; ++itr) { - AstNodeAssign* assp = itr->second; + AstNodeAssign* const assp = itr->second; UINFO(4, " Dead assign " << assp << endl); assp->dtypep()->user1Inc(-1); VL_DO_DANGLING(assp->unlinkFrBack()->deleteTree(), assp); @@ -398,7 +398,7 @@ private: for (bool retry = true; retry;) { retry = false; for (std::vector::iterator it = m_varsp.begin(); it != m_varsp.end(); ++it) { - AstVar* varp = *it; + AstVar* const varp = *it; if (!varp) continue; if (varp->user1() == 0) { UINFO(4, " Dead " << varp << endl); @@ -411,7 +411,7 @@ private: } for (std::vector::iterator it = m_dtypesp.begin(); it != m_dtypesp.end(); ++it) { if ((*it)->user1() == 0) { - AstNodeUOrStructDType* classp; + const AstNodeUOrStructDType* classp; // It's possible that there if a reference to each individual member, but // not to the dtype itself. Check and don't remove the parent dtype if // members are still alive. diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index d14010105..4b7d444de 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -104,16 +104,16 @@ private: void markVarUsage(AstNodeVarRef* nodep, bool blocking) { if (blocking) nodep->user5(true); - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); // UINFO(4, " MVU " << blocking << " " << nodep << endl); - AstNode* lastrefp = vscp->user5p(); + AstNode* const lastrefp = vscp->user5p(); if (!lastrefp) { vscp->user5p(nodep); } else { const bool last_was_blocking = lastrefp->user5(); if (last_was_blocking != blocking) { - AstNode* nonblockingp = blocking ? nodep : lastrefp; - AstNode* blockingp = blocking ? lastrefp : nodep; + const AstNode* const nonblockingp = blocking ? nodep : lastrefp; + const AstNode* const blockingp = blocking ? lastrefp : nodep; vscp->v3warn( BLKANDNBLK, "Unsupported: Blocked and non-blocking assignments to same variable: " @@ -131,7 +131,7 @@ private: // Because we've already scoped it, we may need to add both the AstVar and the AstVarScope UASSERT_OBJ(oldvarscp->scopep(), oldvarscp, "Var unscoped"); AstVar* varp; - AstNodeModule* addmodp = oldvarscp->scopep()->modp(); + AstNodeModule* const addmodp = oldvarscp->scopep()->modp(); // We need a new AstVar, but only one for all scopes, to match the new AstVarScope const auto it = m_modVarMap.find(std::make_pair(addmodp, name)); if (it != m_modVarMap.end()) { @@ -152,13 +152,14 @@ private: m_modVarMap.emplace(std::make_pair(addmodp, name), varp); } - AstVarScope* varscp = new AstVarScope(oldvarscp->fileline(), oldvarscp->scopep(), varp); + AstVarScope* const varscp + = new AstVarScope(oldvarscp->fileline(), oldvarscp->scopep(), varp); oldvarscp->scopep()->addVarp(varscp); return varscp; } AstActive* createActivePost(AstVarRef* varrefp) { - AstActive* newactp + AstActive* const newactp = new AstActive(varrefp->fileline(), "sequentdly", m_activep->sensesp()); // Was addNext(), but addNextHere() avoids a linear search. m_activep->addNextHere(newactp); @@ -184,11 +185,11 @@ private: UINFO(4, " Act: " << m_activep << endl); UINFO(4, " Act: " << oldactivep << endl); // Make a new sensitivity list, which is the combination of both blocks - AstSenItem* sena = m_activep->sensesp()->sensesp()->cloneTree(true); - AstSenItem* senb = oldactivep->sensesp()->sensesp()->cloneTree(true); - AstSenTree* treep = new AstSenTree(m_activep->fileline(), sena); + AstSenItem* const sena = m_activep->sensesp()->sensesp()->cloneTree(true); + AstSenItem* const senb = oldactivep->sensesp()->sensesp()->cloneTree(true); + AstSenTree* const treep = new AstSenTree(m_activep->fileline(), sena); if (senb) treep->addSensesp(senb); - if (AstSenTree* storep = oldactivep->sensesStorep()) { + if (AstSenTree* const storep = oldactivep->sensesStorep()) { storep->unlinkFrBack(); pushDeletep(storep); } @@ -203,7 +204,7 @@ private: // Return the new LHS for the assignment, Null = unlink // Find selects AstNode* newlhsp = nullptr; // nullptr = unlink old assign - AstSel* bitselp = nullptr; + const AstSel* bitselp = nullptr; AstArraySel* arrayselp = nullptr; if (VN_IS(lhsp, Sel)) { bitselp = VN_AS(lhsp, Sel); @@ -220,27 +221,27 @@ private: std::deque dimvalp; // Assignment value for each dimension of assignment AstNode* dimselp = arrayselp; for (; VN_IS(dimselp, ArraySel); dimselp = VN_AS(dimselp, ArraySel)->fromp()) { - AstNode* valp = VN_AS(dimselp, ArraySel)->bitp()->unlinkFrBack(); + AstNode* const valp = VN_AS(dimselp, ArraySel)->bitp()->unlinkFrBack(); dimvalp.push_front(valp); } - AstVarRef* varrefp = VN_AS(dimselp, VarRef); + AstVarRef* const varrefp = VN_AS(dimselp, VarRef); UASSERT_OBJ(varrefp, nodep, "No var underneath arraysels"); UASSERT_OBJ(varrefp->varScopep(), varrefp, "Var didn't get varscoped in V3Scope.cpp"); varrefp->unlinkFrBack(); - AstVar* oldvarp = varrefp->varp(); + const AstVar* const oldvarp = varrefp->varp(); const int modVecNum = m_scopeVecMap[varrefp->varScopep()]++; // std::deque dimreadps; // Read value for each dimension of assignment for (unsigned dimension = 0; dimension < dimvalp.size(); dimension++) { - AstNode* dimp = dimvalp[dimension]; + AstNode* const dimp = dimvalp[dimension]; if (VN_IS(dimp, Const)) { // bit = const, can just use it dimreadps.push_front(dimp); } else { const string bitvarname = (string("__Vdlyvdim") + cvtToStr(dimension) + "__" + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); - AstVarScope* bitvscp + AstVarScope* const bitvscp = createVarSc(varrefp->varScopep(), bitvarname, dimp->width(), nullptr); - AstAssign* bitassignp = new AstAssign( + AstAssign* const bitassignp = new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), bitvscp, VAccess::WRITE), dimp); nodep->addNextHere(bitassignp); @@ -251,16 +252,16 @@ private: //=== Bitselect: __Vdlyvlsb__ AstNode* bitreadp = nullptr; // Code to read Vdlyvlsb if (bitselp) { - AstNode* lsbvaluep = bitselp->lsbp()->unlinkFrBack(); + AstNode* const lsbvaluep = bitselp->lsbp()->unlinkFrBack(); if (VN_IS(bitselp->fromp(), Const)) { // vlsb = constant, can just push constant into where we use it bitreadp = lsbvaluep; } else { const string bitvarname = (string("__Vdlyvlsb__") + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); - AstVarScope* bitvscp + AstVarScope* const bitvscp = createVarSc(varrefp->varScopep(), bitvarname, lsbvaluep->width(), nullptr); - AstAssign* bitassignp = new AstAssign( + AstAssign* const bitassignp = new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), bitvscp, VAccess::WRITE), lsbvaluep); nodep->addNextHere(bitassignp); @@ -276,7 +277,7 @@ private: } else { string valvarname = (string("__Vdlyvval__") + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); - AstVarScope* valvscp + AstVarScope* const valvscp = createVarSc(varrefp->varScopep(), valvarname, 0, nodep->rhsp()->dtypep()); newlhsp = new AstVarRef(nodep->fileline(), valvscp, VAccess::WRITE); valreadp = new AstVarRef(nodep->fileline(), valvscp, VAccess::READ); @@ -300,7 +301,7 @@ private: setinitp = new AstAssignPre(nodep->fileline(), new AstVarRef(nodep->fileline(), setvscp, VAccess::WRITE), new AstConst(nodep->fileline(), 0)); - AstAssign* setassignp = new AstAssign( + AstAssign* const setassignp = new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), setvscp, VAccess::WRITE), new AstConst(nodep->fileline(), AstConst::BitTrue())); nodep->addNextHere(setassignp); @@ -327,13 +328,13 @@ private: UINFO(9, " & " << varrefp << endl); AstAlwaysPost* finalp = VN_AS(varrefp->varScopep()->user4p(), AlwaysPost); if (finalp) { - AstActive* oldactivep = VN_AS(finalp->user2p(), Active); + AstActive* const oldactivep = VN_AS(finalp->user2p(), Active); checkActivePost(varrefp, oldactivep); if (setinitp) oldactivep->addStmtsp(setinitp); } else { // first time we've dealt with this memory finalp = new AstAlwaysPost(nodep->fileline(), nullptr /*sens*/, nullptr /*body*/); UINFO(9, " Created " << finalp << endl); - AstActive* newactp = createActivePost(varrefp); + AstActive* const newactp = createActivePost(varrefp); newactp->addStmtsp(finalp); varrefp->varScopep()->user4p(finalp); finalp->user2p(newactp); @@ -398,13 +399,13 @@ private: if (VN_IS(nodep->lhsp(), ArraySel) || (VN_IS(nodep->lhsp(), Sel) && VN_IS(VN_AS(nodep->lhsp(), Sel)->fromp(), ArraySel))) { - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* newlhsp = createDlyArray(nodep, lhsp); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const newlhsp = createDlyArray(nodep, lhsp); if (m_inLoop) { nodep->v3warn(BLKLOOPINIT, "Unsupported: Delayed assignment to array inside for " "loops (non-delayed is ok - see docs)"); } - AstBasicDType* basicp = lhsp->dtypep()->basicp(); + const AstBasicDType* const basicp = lhsp->dtypep()->basicp(); if (basicp && basicp->isEventValue()) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: event arrays"); } @@ -432,18 +433,18 @@ private: nodep->v3error("Internal: Blocking <= assignment in non-clocked block, should " "have converted in V3Active"); } - AstVarScope* oldvscp = nodep->varScopep(); + AstVarScope* const oldvscp = nodep->varScopep(); UASSERT_OBJ(oldvscp, nodep, "Var didn't get varscoped in V3Scope.cpp"); AstVarScope* dlyvscp = VN_AS(oldvscp->user1p(), VarScope); if (dlyvscp) { // Multiple use of delayed variable - AstActive* oldactivep = VN_AS(dlyvscp->user2p(), Active); + AstActive* const oldactivep = VN_AS(dlyvscp->user2p(), Active); checkActivePost(nodep, oldactivep); } if (!dlyvscp) { // First use of this delayed variable const string newvarname = (string("__Vdly__") + nodep->varp()->shortName()); dlyvscp = createVarSc(oldvscp, newvarname, 0, nullptr); AstNodeAssign* prep; - AstBasicDType* basicp = oldvscp->dtypep()->basicp(); + const AstBasicDType* const basicp = oldvscp->dtypep()->basicp(); if (basicp && basicp->isEventValue()) { // Events go to zero on next timestep unless reactivated prep = new AstAssignPre( @@ -456,19 +457,20 @@ private: new AstVarRef(nodep->fileline(), dlyvscp, VAccess::WRITE), new AstVarRef(nodep->fileline(), oldvscp, VAccess::READ)); } - AstNodeAssign* postp = new AstAssignPost( + AstNodeAssign* const postp = new AstAssignPost( nodep->fileline(), new AstVarRef(nodep->fileline(), oldvscp, VAccess::WRITE), new AstVarRef(nodep->fileline(), dlyvscp, VAccess::READ)); postp->lhsp()->user2(true); // Don't detect this assignment oldvscp->user1p(dlyvscp); // So we can find it later // Make new ACTIVE with identical sensitivity tree - AstActive* newactp = createActivePost(nodep); + AstActive* const newactp = createActivePost(nodep); dlyvscp->user2p(newactp); newactp->addStmtsp(prep); // Add to FRONT of statements newactp->addStmtsp(postp); } - AstVarRef* newrefp = new AstVarRef(nodep->fileline(), dlyvscp, VAccess::WRITE); + AstVarRef* const newrefp + = new AstVarRef(nodep->fileline(), dlyvscp, VAccess::WRITE); newrefp->user2(true); // No reason to do it again nodep->replaceWith(newrefp); VL_DO_DANGLING(pushDeletep(nodep), nodep); diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 5fa2c3804..99bfb8ca5 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -94,7 +94,7 @@ private: if (m_depth > v3Global.opt.compLimitBlocks() && !VN_IS(nodep, NodeCCall)) { // Already done UINFO(4, "DeepBlocks " << m_depth << " " << nodep << endl); - AstNode* backp = nodep->backp(); // Only for debug + const AstNode* backp = nodep->backp(); // Only for debug if (debug() >= 9) backp->dumpTree(cout, "- pre : "); AstCFunc* funcp = createDeepFunc(nodep); iterate(funcp); diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 8ab4dccf5..05633fec0 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -107,14 +107,14 @@ private: // If multiple functions exist, we need to select the appropriate scope. for (FuncMmap::iterator it = m_modFuncs.begin(); it != m_modFuncs.end(); ++it) { const string name = it->first; - AstCFunc* topFuncp = it->second; + AstCFunc* const topFuncp = it->second; auto nextIt1 = it; ++nextIt1; bool moreOfSame1 = (nextIt1 != m_modFuncs.end() && nextIt1->first == name); if (moreOfSame1) { // Multiple functions under this name, need a wrapper function UINFO(6, " Wrapping " << name << " multifuncs\n"); - AstCFunc* newfuncp = topFuncp->cloneTree(false); + AstCFunc* const newfuncp = topFuncp->cloneTree(false); if (newfuncp->initsp()) newfuncp->initsp()->unlinkFrBackWithNext()->deleteTree(); if (newfuncp->stmtsp()) newfuncp->stmtsp()->unlinkFrBackWithNext()->deleteTree(); if (newfuncp->finalsp()) newfuncp->finalsp()->unlinkFrBackWithNext()->deleteTree(); @@ -125,7 +125,7 @@ private: for (FuncMmap::iterator eachIt = it; eachIt != m_modFuncs.end() && eachIt->first == name; ++eachIt) { it = eachIt; - AstCFunc* funcp = eachIt->second; + AstCFunc* const funcp = eachIt->second; auto nextIt2 = eachIt; ++nextIt2; const bool moreOfSame @@ -138,21 +138,21 @@ private: funcp->declPrivate(true); AstNode* argsp = nullptr; for (AstNode* stmtp = newfuncp->argsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn()) { - AstNode* newp = new AstVarRef(portp->fileline(), portp, - portp->isWritable() ? VAccess::WRITE - : VAccess::READ); + AstNode* const newp = new AstVarRef( + portp->fileline(), portp, + portp->isWritable() ? VAccess::WRITE : VAccess::READ); argsp = argsp ? argsp->addNextNull(newp) : newp; } } } - AstNode* returnp = new AstCReturn( + AstNode* const returnp = new AstCReturn( funcp->fileline(), new AstCCall(funcp->fileline(), funcp, argsp)); if (moreOfSame) { - AstIf* ifp = new AstIf( + AstIf* const ifp = new AstIf( funcp->fileline(), new AstEq( funcp->fileline(), new AstCMath(funcp->fileline(), "this", 64), diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index f9e85f5be..2dc5f5ea7 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -57,7 +57,7 @@ string EmitCBaseVisitor::funcNameProtect(const AstCFunc* nodep, const AstNodeMod } AstCFile* EmitCBaseVisitor::newCFile(const string& filename, bool slow, bool source) { - AstCFile* cfilep = new AstCFile(v3Global.rootp()->fileline(), filename); + AstCFile* const cfilep = new AstCFile(v3Global.rootp()->fileline(), filename); cfilep->slow(slow); cfilep->source(source); v3Global.rootp()->addFilesp(cfilep); @@ -78,7 +78,7 @@ string EmitCBaseVisitor::cFuncArgs(const AstCFunc* nodep) { } // Might be a user function with argument list. for (const AstNode* stmtp = nodep->argsp(); stmtp; stmtp = stmtp->nextp()) { - if (const AstVar* portp = VN_CAST(stmtp, Var)) { + if (const AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn()) { if (args != "") args += ", "; if (nodep->dpiImportPrototype() || nodep->dpiExportDispatcher()) { diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 0910c6cfb..89d6b47db 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -197,7 +197,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) { } else { // Format bool isStmt = false; - if (const AstFScanF* dispp = VN_CAST(nodep, FScanF)) { + if (const AstFScanF* const dispp = VN_CAST(nodep, FScanF)) { isStmt = false; puts("VL_FSCANF_IX("); iterate(dispp->filep()); @@ -238,7 +238,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) { // Arguments for (unsigned i = 0; i < emitDispState.m_argsp.size(); i++) { const char fmt = emitDispState.m_argsChar[i]; - AstNode* argp = emitDispState.m_argsp[i]; + AstNode* const argp = emitDispState.m_argsp[i]; const string func = emitDispState.m_argsFunc[i]; if (func != "" || argp) { puts(","); @@ -316,7 +316,7 @@ void EmitCFunc::displayArg(AstNode* dispp, AstNode** elistp, bool isScan, const emitDispState.pushArg(fmtLetter, argp, ""); if (fmtLetter == 't' || fmtLetter == '^') { AstSFormatF* fmtp = nullptr; - if (AstDisplay* nodep = VN_CAST(dispp, Display)) + if (AstDisplay* const nodep = VN_CAST(dispp, Display)) fmtp = nodep->fmtp(); else if (AstSFormat* nodep = VN_CAST(dispp, SFormat)) fmtp = nodep->fmtp(); @@ -472,7 +472,7 @@ void EmitCFunc::emitDereference(const string& pointer) { } void EmitCFunc::emitCvtPackStr(AstNode* nodep) { - if (const AstConst* constp = VN_CAST(nodep, Const)) { + if (const AstConst* const constp = VN_CAST(nodep, Const)) { putbs("std::string("); putsQuoted(constp->num().toString()); puts(")"); diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index 776d84ef8..b9c875e41 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -136,7 +136,7 @@ class CMakeEmitter final { std::vector global; for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep; nodep = VN_AS(nodep->nextp(), NodeFile)) { - AstCFile* cfilep = VN_CAST(nodep, CFile); + const AstCFile* const cfilep = VN_CAST(nodep, CFile); if (cfilep && cfilep->source()) { if (cfilep->support()) { if (cfilep->slow()) { diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index a10f5a64c..024972b4d 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -50,9 +50,9 @@ class EmitCSyms final : EmitCBaseVisitor { , m_type{type} {} }; struct ScopeFuncData { - AstScopeName* m_scopep; - AstCFunc* m_cfuncp; - AstNodeModule* m_modp; + AstScopeName* const m_scopep; + AstCFunc* const m_cfuncp; + AstNodeModule* const m_modp; ScopeFuncData(AstScopeName* scopep, AstCFunc* funcp, AstNodeModule* modp) : m_scopep{scopep} , m_cfuncp{funcp} @@ -61,9 +61,9 @@ class EmitCSyms final : EmitCBaseVisitor { struct ScopeVarData { string m_scopeName; string m_varBasePretty; - AstVar* m_varp; - AstNodeModule* m_modp; - AstScope* m_scopep; + AstVar* const m_varp; + AstNodeModule* const m_modp; + AstScope* const m_scopep; ScopeVarData(const string& scopeName, const string& varBasePretty, AstVar* varp, AstNodeModule* modp, AstScope* scopep) : m_scopeName{scopeName} @@ -193,12 +193,12 @@ class EmitCSyms final : EmitCBaseVisitor { // Someday. For now public isn't common. for (std::vector::iterator itsc = m_scopes.begin(); itsc != m_scopes.end(); ++itsc) { - AstScope* scopep = itsc->first; - AstNodeModule* smodp = itsc->second; + AstScope* const scopep = itsc->first; + const AstNodeModule* const smodp = itsc->second; for (std::vector::iterator it = m_modVars.begin(); it != m_modVars.end(); ++it) { - AstNodeModule* modp = it->first; - AstVar* varp = it->second; + AstNodeModule* const modp = it->first; + AstVar* const varp = it->second; if (modp == smodp) { // Need to split the module + var name into the // original-ish full scope and variable name under that scope. @@ -411,7 +411,7 @@ void EmitCSyms::emitSymHdr() { puts("\n// DPI TYPES for DPI Export callbacks (Internal use)\n"); std::map types; // Remove duplicates and sort for (const auto& itr : m_scopeFuncs) { - AstCFunc* funcp = itr.second.m_cfuncp; + const AstCFunc* const funcp = itr.second.m_cfuncp; if (funcp->dpiExportImpl()) { const string cbtype = protect(v3Global.opt.prefix() + "__Vcb_" + funcp->cname() + "_t"); @@ -461,8 +461,8 @@ void EmitCSyms::emitSymHdr() { puts("\n// MODULE INSTANCE STATE\n"); for (const auto& i : m_scopes) { - AstScope* scopep = i.first; - AstNodeModule* modp = i.second; + const AstScope* const scopep = i.first; + const AstNodeModule* const modp = i.second; if (VN_IS(modp, Class)) continue; const string name = prefixNameProtect(modp); ofp()->printf("%-30s ", name.c_str()); @@ -484,7 +484,8 @@ void EmitCSyms::emitSymHdr() { for (const V3GraphVertex* vxp = v3Global.rootp()->execGraphp()->depGraphp()->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - ExecMTask* mtp = dynamic_cast(const_cast(vxp)); + const ExecMTask* const mtp + = dynamic_cast(const_cast(vxp)); if (maxProfilerId < mtp->profilerId()) maxProfilerId = mtp->profilerId(); } } @@ -553,7 +554,7 @@ void EmitCSyms::checkSplit(bool usesVfinal) { m_numStmts = 0; string filename = v3Global.opt.makeDir() + "/" + symClassName() + "__" + cvtToStr(++m_funcNum) + ".cpp"; - AstCFile* cfilep = newCFile(filename, true /*slow*/, true /*source*/); + AstCFile* const cfilep = newCFile(filename, true /*slow*/, true /*source*/); cfilep->support(true); m_usesVfinal[m_funcNum] = usesVfinal; closeSplit(); diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index acff39cf0..0b152bd30 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -116,7 +116,7 @@ public: } else { for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep; nodep = VN_AS(nodep->nextp(), NodeFile)) { - AstCFile* cfilep = VN_CAST(nodep, CFile); + const AstCFile* const cfilep = VN_CAST(nodep, CFile); if (cfilep && cfilep->source() && cfilep->slow() == (slow != 0) && cfilep->support() == (support != 0)) { putMakeClassEntry(of, cfilep->name()); diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 8c21a17b3..52a1543f8 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -170,7 +170,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } virtual void visit(AstNodeCase* nodep) override { putfs(nodep, ""); - if (const AstCase* casep = VN_CAST(nodep, Case)) { + if (const AstCase* const casep = VN_CAST(nodep, Case)) { if (casep->priorityPragma()) puts("priority "); if (casep->uniquePragma()) puts("unique "); if (casep->unique0Pragma()) puts("unique0 "); @@ -179,7 +179,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { puts(" ("); iterateAndNextNull(nodep->exprp()); puts(")\n"); - if (const AstCase* casep = VN_CAST(nodep, Case)) { + if (const AstCase* const casep = VN_CAST(nodep, Case)) { if (casep->fullPragma() || casep->parallelPragma()) { puts(" // synopsys"); if (casep->fullPragma()) puts(" full_case"); @@ -342,7 +342,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { } virtual void visit(AstNodeIf* nodep) override { putfs(nodep, ""); - if (const AstIf* ifp = VN_CAST(nodep, If)) { + if (const AstIf* const ifp = VN_CAST(nodep, If)) { if (ifp->priorityPragma()) puts("priority "); if (ifp->uniquePragma()) puts("unique "); if (ifp->unique0Pragma()) puts("unique0 "); @@ -416,7 +416,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { // Operators virtual void emitVerilogFormat(AstNode* nodep, const string& format, AstNode* lhsp = nullptr, - AstNode* rhsp = nullptr, AstNode* thsp = nullptr, + AstNode* const rhsp = nullptr, AstNode* thsp = nullptr, AstNode* fhsp = nullptr) { // Look at emitVerilog() format for term/uni/dual/triops, // and write out appropriate text. @@ -503,7 +503,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { if (comma++) putbs(", "); puts(cvtToStr(itr.first)); puts(":"); - AstNode* valuep = itr.second->valuep(); + AstNode* const valuep = itr.second->valuep(); iterate(valuep); } puts("}"); @@ -650,7 +650,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { std::vector unpackps; for (AstNodeDType* dtypep = nodep->dtypep(); dtypep;) { dtypep = dtypep->skipRefp(); - if (AstUnpackArrayDType* unpackp = VN_CAST(dtypep, UnpackArrayDType)) { + if (AstUnpackArrayDType* const unpackp = VN_CAST(dtypep, UnpackArrayDType)) { unpackps.push_back(unpackp); dtypep = unpackp->subDTypep(); } else { @@ -838,7 +838,7 @@ void V3EmitV::emitvFiles() { UINFO(2, __FUNCTION__ << ": " << endl); for (AstNodeFile* filep = v3Global.rootp()->filesp(); filep; filep = VN_AS(filep->nextp(), NodeFile)) { - AstVFile* vfilep = VN_CAST(filep, VFile); + AstVFile* const vfilep = VN_CAST(filep, VFile); if (vfilep && vfilep->tblockp()) { V3OutVFile of(vfilep->name()); of.puts("// DESCR" diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index 01af7930a..3db3f6ad5 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -75,7 +75,7 @@ class EmitXmlFileVisitor final : public AstNVisitor { puts(" tag="); putsQuoted(nodep->tag()); } - if (AstNodeDType* dtp = VN_CAST(nodep, NodeDType)) { + if (const AstNodeDType* const dtp = VN_CAST(nodep, NodeDType)) { if (dtp->subDTypep()) { puts(" sub_dtype_id="); outputId(dtp->subDTypep()->skipRefp()); diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 602b56eaf..2ac31587b 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -78,7 +78,7 @@ void V3Error::init() { string V3Error::lineStr(const char* filename, int lineno) { std::ostringstream out; - const char* fnslashp = std::strrchr(filename, '/'); + const char* const fnslashp = std::strrchr(filename, '/'); if (fnslashp) filename = fnslashp + 1; out << filename << ":" << std::dec << lineno << ":"; const char* const spaces = " "; diff --git a/src/V3File.cpp b/src/V3File.cpp index f26e60c67..f3c2d3992 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -190,7 +190,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm iter != m_filenameList.end(); ++iter) { // Read stats of files we create after we're done making them // (except for this file, of course) - DependFile* dfp = const_cast(&(*iter)); + DependFile* const dfp = const_cast(&(*iter)); V3Options::fileNfsFlush(dfp->filename()); dfp->loadStats(); off_t showSize = iter->size(); diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index bca5846cc..f05e004eb 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -181,7 +181,7 @@ void FileLine::lineDirective(const char* textp, int& enterExitRef) { // Grab linenumber bool fail = false; - const char* ln = textp; + const char* const ln = textp; while (*textp && !isspace(*textp)) textp++; if (isdigit(*ln)) { lineno(atoi(ln)); @@ -193,7 +193,7 @@ void FileLine::lineDirective(const char* textp, int& enterExitRef) { while (*textp && (isspace(*textp) || *textp == '"')) textp++; // Grab filename - const char* fn = textp; + const char* const fn = textp; while (*textp && !(isspace(*textp) || *textp == '"')) textp++; if (textp != fn) { string strfn = fn; @@ -244,7 +244,7 @@ FileLine* FileLine::copyOrSameFileLine() { if (lastNewp && *lastNewp == *this) { // Compares lineno, filename, etc return lastNewp; } - FileLine* newp = new FileLine(this); + FileLine* const newp = new FileLine(this); lastNewp = newp; return newp; } @@ -430,14 +430,14 @@ string FileLine::warnContext(bool secondary) const { std::unordered_set fileLineLeakChecks; void* FileLine::operator new(size_t size) { - FileLine* objp = static_cast(::operator new(size)); + FileLine* const objp = static_cast(::operator new(size)); fileLineLeakChecks.insert(objp); return objp; } void FileLine::operator delete(void* objp, size_t size) { if (!objp) return; - FileLine* flp = static_cast(objp); + FileLine* const flp = static_cast(objp); const auto it = fileLineLeakChecks.find(flp); if (it != fileLineLeakChecks.end()) { fileLineLeakChecks.erase(it); diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 9c88263bb..ccd8d7126 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -67,7 +67,7 @@ public: // Support classes class GateEitherVertex VL_NOT_FINAL : public V3GraphVertex { - AstScope* m_scopep; // Scope vertex refers to + AstScope* const m_scopep; // Scope vertex refers to bool m_reducible = true; // True if this node should be able to be eliminated bool m_dedupable = true; // True if this node should be able to be deduped bool m_consumed = false; // Output goes to something meaningful @@ -124,7 +124,7 @@ public: }; class GateVarVertex final : public GateEitherVertex { - AstVarScope* m_varScp; + AstVarScope* const m_varScp; bool m_isTop = false; bool m_isClock = false; AstNode* m_rstSyncNodep = nullptr; // Used as reset and not in SenItem, in clocked always @@ -164,8 +164,8 @@ public: }; class GateLogicVertex final : public GateEitherVertex { - AstNode* m_nodep; - AstActive* m_activep; // Under what active; nullptr is ok (under cfunc or such) + AstNode* const m_nodep; + AstActive* const m_activep; // Under what active; nullptr is ok (under cfunc or such) bool m_slow; // In slow block public: GateLogicVertex(V3Graph* graphp, AstScope* scopep, AstNode* nodep, AstActive* activep, @@ -227,7 +227,7 @@ private: m_lhsVarRef = nodep; } else { if (m_rhsVarRefs.size() > 1) { - AstNodeVarRef* lastRefp = m_rhsVarRefs.back(); + const AstNodeVarRef* const lastRefp = m_rhsVarRefs.back(); if (m_buffersOnly) clearSimple(">1 rhs varRefs"); if (!nodep->varScopep()->varp()->gateMultiInputOptimizable() // We didn't check multiInput on the first varref, so check it here @@ -440,9 +440,9 @@ private: virtual void visit(AstNodeVarRef* nodep) override { if (m_scopep) { UASSERT_OBJ(m_logicVertexp, nodep, "Var ref not under a logic block"); - AstVarScope* varscp = nodep->varScopep(); + AstVarScope* const varscp = nodep->varScopep(); UASSERT_OBJ(varscp, nodep, "Var didn't get varscoped in V3Scope.cpp"); - GateVarVertex* vvertexp = makeVarVertex(varscp); + GateVarVertex* const vvertexp = makeVarVertex(varscp); UINFO(5, " VARREF to " << varscp << endl); if (m_inSenItem) { vvertexp->setIsClock(); @@ -536,7 +536,7 @@ public: void GateVisitor::optimizeSignals(bool allowMultiIn) { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(itp)) { + if (GateVarVertex* const vvertexp = dynamic_cast(itp)) { if (vvertexp->inEmpty()) { vvertexp->clearReducibleAndDedupable("inEmpty"); // Can't deal with no sources if (!vvertexp->isTop() // Ok if top inputs are driverless @@ -562,7 +562,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { UINFO(8, "SigNotRed " << vvertexp->name() << endl); } else { UINFO(8, "Sig " << vvertexp->name() << endl); - GateLogicVertex* logicVertexp + GateLogicVertex* const logicVertexp = dynamic_cast(vvertexp->inBeginp()->fromp()); UINFO(8, " From " << logicVertexp->name() << endl); AstNode* logicp = logicVertexp->nodep(); @@ -578,7 +578,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { int n = 0; for (V3GraphEdge* edgep = vvertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - GateLogicVertex* consumeVertexp + const GateLogicVertex* const consumeVertexp = dynamic_cast(edgep->top()); if (!consumeVertexp->slow()) { // Not tracing or other slow path junk if (edgep->top()->outBeginp()) { // Destination is itself used @@ -602,29 +602,29 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { << " " << vvertexp->name() << endl); for (V3GraphEdge* edgep = vvertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - GateLogicVertex* consumeVertexp + const GateLogicVertex* const consumeVertexp = dynamic_cast(edgep->top()); UINFO(9, " edge " << edgep << " to: " << consumeVertexp->nodep() << endl); } for (V3GraphEdge* edgep = vvertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - GateLogicVertex* consumeVertexp + const GateLogicVertex* const consumeVertexp = dynamic_cast(edgep->fromp()); UINFO(9, " edge " << edgep << " from: " << consumeVertexp->nodep() << endl); } } } else { - AstNode* substp = okVisitor.substTree(); + AstNode* const substp = okVisitor.substTree(); if (debug() >= 5) logicp->dumpTree(cout, " elimVar: "); if (debug() >= 5) substp->dumpTree(cout, " subst: "); ++m_statSigs; bool removedAllUsages = true; for (V3GraphEdge* edgep = vvertexp->outBeginp(); edgep;) { - GateLogicVertex* consumeVertexp + GateLogicVertex* const consumeVertexp = dynamic_cast(edgep->top()); - AstNode* consumerp = consumeVertexp->nodep(); + AstNode* const consumerp = consumeVertexp->nodep(); if (!elimLogicOkOutputs(consumeVertexp, okVisitor /*ref*/)) { // Cannot optimize this replacement removedAllUsages = false; @@ -636,9 +636,9 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { const GateVarRefList& rhsVarRefs = okVisitor.rhsVarRefs(); for (GateVarRefList::const_iterator it = rhsVarRefs.begin(); it != rhsVarRefs.end(); ++it) { - AstVarScope* newvarscp = (*it)->varScopep(); + AstVarScope* const newvarscp = (*it)->varScopep(); UINFO(9, " Point-to-new vertex " << newvarscp << endl); - GateVarVertex* varvertexp = makeVarVertex(newvarscp); + GateVarVertex* const varvertexp = makeVarVertex(newvarscp); new V3GraphEdge(&m_graph, varvertexp, consumeVertexp, 1); // Propagate clock attribute onto generating node varvertexp->propagateAttrClocksFrom(vvertexp); @@ -685,12 +685,12 @@ bool GateVisitor::elimLogicOkOutputs(GateLogicVertex* consumeVertexp, // Replacement logic usually has shorter input list, so faster to build list based on it const GateVarRefList& rhsVarRefs = okVisitor.rhsVarRefs(); for (GateVarRefList::const_iterator it = rhsVarRefs.begin(); it != rhsVarRefs.end(); ++it) { - AstVarScope* vscp = (*it)->varScopep(); + AstVarScope* const vscp = (*it)->varScopep(); varscopes.insert(vscp); } for (V3GraphEdge* edgep = consumeVertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - GateVarVertex* consVVertexp = dynamic_cast(edgep->top()); - AstVarScope* vscp = consVVertexp->varScp(); + const GateVarVertex* const consVVertexp = dynamic_cast(edgep->top()); + AstVarScope* const vscp = consVVertexp->varScp(); if (varscopes.find(vscp) != varscopes.end()) { UINFO(9, " Block-unopt, insertion generates input vscp " << vscp << endl); return false; @@ -701,29 +701,29 @@ bool GateVisitor::elimLogicOkOutputs(GateLogicVertex* consumeVertexp, void GateVisitor::replaceAssigns() { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(itp)) { + if (const GateVarVertex* const vvertexp = dynamic_cast(itp)) { // Take the Comments/assigns that were moved to the VarScope and change them to a // simple value assignment - AstVarScope* vscp = vvertexp->varScp(); + const AstVarScope* const vscp = vvertexp->varScp(); if (vscp->valuep() && !VN_IS(vscp->valuep(), NodeMath)) { // if (debug() > 9) vscp->dumpTree(cout, "-vscPre: "); while (AstNode* delp = VN_CAST(vscp->valuep(), Comment)) { VL_DO_DANGLING(delp->unlinkFrBack()->deleteTree(), delp); } - if (AstInitial* delp = VN_CAST(vscp->valuep(), Initial)) { - AstNode* bodyp = delp->bodysp(); + if (AstInitial* const delp = VN_CAST(vscp->valuep(), Initial)) { + AstNode* const bodyp = delp->bodysp(); bodyp->unlinkFrBackWithNext(); delp->replaceWith(bodyp); VL_DO_DANGLING(delp->deleteTree(), delp); } - if (AstAlways* delp = VN_CAST(vscp->valuep(), Always)) { - AstNode* bodyp = delp->bodysp(); + if (AstAlways* const delp = VN_CAST(vscp->valuep(), Always)) { + AstNode* const bodyp = delp->bodysp(); bodyp->unlinkFrBackWithNext(); delp->replaceWith(bodyp); VL_DO_DANGLING(delp->deleteTree(), delp); } - if (AstNodeAssign* delp = VN_CAST(vscp->valuep(), NodeAssign)) { - AstNode* rhsp = delp->rhsp(); + if (AstNodeAssign* const delp = VN_CAST(vscp->valuep(), NodeAssign)) { + AstNode* const rhsp = delp->rhsp(); rhsp->unlinkFrBack(); delp->replaceWith(rhsp); VL_DO_DANGLING(delp->deleteTree(), delp); @@ -745,7 +745,7 @@ void GateVisitor::consumedMark() { m_graph.userClearVertices(); for (V3GraphVertex* vertexp = m_graph.verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - GateEitherVertex* evertexp = static_cast(vertexp); + GateEitherVertex* const evertexp = static_cast(vertexp); if (!evertexp->user() && evertexp->consumed()) consumedMarkRecurse(evertexp); } } @@ -756,7 +756,7 @@ void GateVisitor::consumedMarkRecurse(GateEitherVertex* vertexp) { if (!vertexp->consumed()) vertexp->setConsumed("propagated"); // Walk sources and mark them too for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - GateEitherVertex* eFromVertexp = static_cast(edgep->fromp()); + GateEitherVertex* const eFromVertexp = static_cast(edgep->fromp()); consumedMarkRecurse(eFromVertexp); } } @@ -766,14 +766,14 @@ void GateVisitor::consumedMove() { // We need the "usually" block logic to do a better job at this for (V3GraphVertex* vertexp = m_graph.verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(vertexp)) { + if (const GateVarVertex* const vvertexp = dynamic_cast(vertexp)) { if (!vvertexp->consumed() && !vvertexp->user()) { UINFO(8, "Unconsumed " << vvertexp->varScp() << endl); } } - if (GateLogicVertex* lvertexp = dynamic_cast(vertexp)) { - AstNode* nodep = lvertexp->nodep(); - AstActive* oldactp = lvertexp->activep(); // nullptr under cfunc + if (const GateLogicVertex* const lvertexp = dynamic_cast(vertexp)) { + AstNode* const nodep = lvertexp->nodep(); + const AstActive* const oldactp = lvertexp->activep(); // nullptr under cfunc if (!lvertexp->consumed() && oldactp) { // Eventually: Move the statement to a new active block // with "tracing-on" sensitivity @@ -790,10 +790,10 @@ void GateVisitor::consumedMove() { void GateVisitor::warnSignals() { AstNode::user2ClearTree(); for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(itp)) { - AstVarScope* vscp = vvertexp->varScp(); - AstNode* sp = vvertexp->rstSyncNodep(); - AstNode* ap = vvertexp->rstAsyncNodep(); + if (const GateVarVertex* const vvertexp = dynamic_cast(itp)) { + const AstVarScope* const vscp = vvertexp->varScp(); + const AstNode* const sp = vvertexp->rstSyncNodep(); + const AstNode* const ap = vvertexp->rstAsyncNodep(); if (ap && sp && !vscp->varp()->user2()) { // This is somewhat wrong, as marking one flop as ok for sync // may mean a different flop now fails. However it's a pain to @@ -842,7 +842,7 @@ private: m_didReplace = true; UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Can't replace lvalue assignments with const var"); - AstNode* substp = m_replaceTreep->cloneTree(false); + AstNode* const substp = m_replaceTreep->cloneTree(false); UASSERT_OBJ(!(VN_IS(substp, NodeVarRef) && nodep->same(substp)), // Prevent an infinite loop... substp, "Replacing node with itself; perhaps circular logic?"); @@ -853,7 +853,7 @@ private: // to throw warnings that point to a PIN rather than where the pin us used. if (VN_IS(substp, VarRef)) substp->fileline(nodep->fileline()); // Make the substp an rvalue like nodep. This facilitates the hashing in dedupe. - if (AstNodeVarRef* varrefp = VN_CAST(substp, NodeVarRef)) + if (AstNodeVarRef* const varrefp = VN_CAST(substp, NodeVarRef)) varrefp->access(VAccess::READ); hashReplace(nodep, substp); nodep->replaceWith(substp); @@ -961,8 +961,8 @@ public: bool isReplaced(AstNode* nodep) { // Assignment may have been hashReplaced, if so consider non-match (effectively removed) UASSERT_OBJ(!VN_IS(nodep, NodeAssign), nodep, "Dedup attempt on non-assign"); - AstNode* extra1p = nodep->user3p(); - AstNode* extra2p = nodep->user5p(); + AstNode* const extra1p = nodep->user3p(); + AstNode* const extra2p = nodep->user5p(); return ((extra1p && m_nodeDeleteds.find(extra1p) != m_nodeDeleteds.end()) || (extra2p && m_nodeDeleteds.find(extra2p) != m_nodeDeleteds.end())); } @@ -981,7 +981,7 @@ public: AstNodeAssign* hashAndFindDupe(AstNodeAssign* assignp, AstNode* extra1p, AstNode* extra2p) { // Legal for extra1p/2p to be nullptr, we'll compare with other assigns with extras also // nullptr - AstNode* rhsp = assignp->rhsp(); + AstNode* const rhsp = assignp->rhsp(); rhsp->user2p(assignp); rhsp->user3p(extra1p); rhsp->user5p(extra2p); @@ -1001,9 +1001,9 @@ public: void check() { for (const auto& itr : m_dupFinder) { - AstNode* nodep = itr.second; - AstNode* activep = nodep->user3p(); - AstNode* condVarp = nodep->user5p(); + AstNode* const nodep = itr.second; + const AstNode* const activep = nodep->user3p(); + const AstNode* const condVarp = nodep->user5p(); if (!isReplaced(nodep)) { // This class won't break if activep isn't an active, or // ifVar isn't a var, but this is checking the caller's construction. @@ -1094,12 +1094,13 @@ public: m_dedupable = true; iterate(nodep); if (m_dedupable && m_assignp) { - AstNode* lhsp = m_assignp->lhsp(); + AstNode* const lhsp = m_assignp->lhsp(); // Possible todo, handle more complex lhs expressions - if (AstNodeVarRef* lhsVarRefp = VN_CAST(lhsp, NodeVarRef)) { + if (const AstNodeVarRef* const lhsVarRefp = VN_CAST(lhsp, NodeVarRef)) { UASSERT_OBJ(lhsVarRefp->varScopep() == consumerVarScopep, consumerVarScopep, "Consumer doesn't match lhs of assign"); - if (AstNodeAssign* dup = m_ghash.hashAndFindDupe(m_assignp, activep, m_ifCondp)) { + if (const AstNodeAssign* const dup + = m_ghash.hashAndFindDupe(m_assignp, activep, m_ifCondp)) { return static_cast(dup->lhsp()); } } @@ -1137,26 +1138,26 @@ private: m_depth++; if (vvertexp->inSize1()) { - AstNodeVarRef* dupVarRefp = static_cast( + AstNodeVarRef* const dupVarRefp = static_cast( vvertexp->iterateInEdges(*this, VNUser(vvertexp)).toNodep()); if (dupVarRefp) { // visit(GateLogicVertex*...) returned match V3GraphEdge* edgep = vvertexp->inBeginp(); - GateLogicVertex* lvertexp = static_cast(edgep->fromp()); + GateLogicVertex* const lvertexp = static_cast(edgep->fromp()); UASSERT_OBJ(vvertexp->dedupable(), vvertexp->varScp(), "GateLogicVertex* visit should have returned nullptr " "if consumer var vertex is not dedupable."); GateOkVisitor okVisitor{lvertexp->nodep(), false, true}; if (okVisitor.isSimple()) { - AstVarScope* dupVarScopep = dupVarRefp->varScopep(); - GateVarVertex* dupVvertexp + const AstVarScope* const dupVarScopep = dupVarRefp->varScopep(); + GateVarVertex* const dupVvertexp = reinterpret_cast(dupVarScopep->user1p()); UINFO(4, "replacing " << vvertexp << " with " << dupVvertexp << endl); ++m_numDeduped; // Replace all of this varvertex's consumers with dupVarRefp for (V3GraphEdge* outedgep = vvertexp->outBeginp(); outedgep;) { - GateLogicVertex* consumeVertexp + const GateLogicVertex* const consumeVertexp = dynamic_cast(outedgep->top()); - AstNode* consumerp = consumeVertexp->nodep(); + AstNode* const consumerp = consumeVertexp->nodep(); // if (debug() >= 9) m_graphp->dumpDotFilePrefixed("gate_preelim"); UINFO(9, "elim src vtx" << lvertexp << " node " << lvertexp->nodep() << endl); @@ -1198,15 +1199,16 @@ private: virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { lvertexp->iterateInEdges(*this); - GateVarVertex* consumerVvertexpp = static_cast(vu.toGraphVertex()); + const GateVarVertex* const consumerVvertexpp + = static_cast(vu.toGraphVertex()); if (lvertexp->dedupable() && consumerVvertexpp->dedupable()) { - AstNode* nodep = lvertexp->nodep(); - AstVarScope* consumerVarScopep = consumerVvertexpp->varScp(); + AstNode* const nodep = lvertexp->nodep(); + AstVarScope* const consumerVarScopep = consumerVvertexpp->varScp(); // TODO: Doing a simple pointer comparison of activep won't work // optimally for statements under generated clocks. Statements under // different generated clocks will never compare as equal, even if the // generated clocks are deduped into one clock. - AstActive* activep = lvertexp->activep(); + AstActive* const activep = lvertexp->activep(); return VNUser(m_varVisitor.findDupe(nodep, consumerVarScopep, activep)); } return VNUser(0); @@ -1227,14 +1229,14 @@ void GateVisitor::dedupe() { // Traverse starting from each of the clocks UINFO(9, "Gate dedupe() clocks:\n"); for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(itp)) { + if (GateVarVertex* const vvertexp = dynamic_cast(itp)) { if (vvertexp->isClock()) deduper.dedupeTree(vvertexp); } } // Traverse starting from each of the outputs UINFO(9, "Gate dedupe() outputs:\n"); for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(itp)) { + if (GateVarVertex* const vvertexp = dynamic_cast(itp)) { if (vvertexp->isTop() && vvertexp->varScp()->varp()->isWritable()) { deduper.dedupeTree(vvertexp); } @@ -1256,15 +1258,15 @@ private: // assemble two Sel into one if possible AstSel* merge(AstSel* pre, AstSel* cur) { - AstVarRef* preVarRefp = VN_CAST(pre->fromp(), VarRef); - AstVarRef* curVarRefp = VN_CAST(cur->fromp(), VarRef); + const AstVarRef* const preVarRefp = VN_CAST(pre->fromp(), VarRef); + AstVarRef* const curVarRefp = VN_CAST(cur->fromp(), VarRef); if (!preVarRefp || !curVarRefp || !curVarRefp->same(preVarRefp)) { return nullptr; // not the same var } - const AstConst* pstart = VN_CAST(pre->lsbp(), Const); - const AstConst* pwidth = VN_CAST(pre->widthp(), Const); - const AstConst* cstart = VN_CAST(cur->lsbp(), Const); - const AstConst* cwidth = VN_CAST(cur->widthp(), Const); + const AstConst* const pstart = VN_CAST(pre->lsbp(), Const); + const AstConst* const pwidth = VN_CAST(pre->widthp(), Const); + const AstConst* const cstart = VN_CAST(cur->lsbp(), Const); + const AstConst* const cwidth = VN_CAST(cur->widthp(), Const); if (!pstart || !pwidth || !cstart || !cwidth) return nullptr; // too complicated if (cur->lsbConst() + cur->widthConst() == pre->lsbConst()) { return new AstSel(curVarRefp->fileline(), curVarRefp->cloneTree(false), @@ -1278,8 +1280,9 @@ private: for (V3GraphEdge* edgep = vvertexp->inBeginp(); edgep;) { V3GraphEdge* oldedgep = edgep; edgep = edgep->inNextp(); // for recursive since the edge could be deleted - if (GateLogicVertex* lvertexp = dynamic_cast(oldedgep->fromp())) { - if (AstNodeAssign* assignp = VN_CAST(lvertexp->nodep(), NodeAssign)) { + if (GateLogicVertex* const lvertexp + = dynamic_cast(oldedgep->fromp())) { + if (AstNodeAssign* const assignp = VN_CAST(lvertexp->nodep(), NodeAssign)) { // if (lvertexp->outSize1() && VN_IS(assignp->lhsp(), Sel)) { if (VN_IS(assignp->lhsp(), Sel) && lvertexp->outSize1()) { UINFO(9, "assing to the nodep[" << VN_AS(assignp->lhsp(), Sel)->lsbConst() @@ -1297,20 +1300,20 @@ private: continue; } - AstSel* preselp = VN_CAST(m_assignp->lhsp(), Sel); - AstSel* curselp = VN_CAST(assignp->lhsp(), Sel); + AstSel* const preselp = VN_CAST(m_assignp->lhsp(), Sel); + AstSel* const curselp = VN_CAST(assignp->lhsp(), Sel); if (!preselp || !curselp) continue; - if (AstSel* newselp = merge(preselp, curselp)) { + if (AstSel* const newselp = merge(preselp, curselp)) { UINFO(5, "assemble to new sel: " << newselp << endl); // replace preSel with newSel preselp->replaceWith(newselp); VL_DO_DANGLING(preselp->deleteTree(), preselp); // create new rhs for pre assignment - AstNode* newrhsp = new AstConcat(m_assignp->rhsp()->fileline(), - m_assignp->rhsp()->cloneTree(false), - assignp->rhsp()->cloneTree(false)); - AstNode* oldrhsp = m_assignp->rhsp(); + AstNode* const newrhsp = new AstConcat( + m_assignp->rhsp()->fileline(), m_assignp->rhsp()->cloneTree(false), + assignp->rhsp()->cloneTree(false)); + AstNode* const oldrhsp = m_assignp->rhsp(); oldrhsp->replaceWith(newrhsp); VL_DO_DANGLING(oldrhsp->deleteTree(), oldrhsp); m_assignp->dtypeChgWidthSigned(m_assignp->width() + assignp->width(), @@ -1327,7 +1330,7 @@ private: for (V3GraphEdge* ledgep = lvertexp->inBeginp(); ledgep;) { V3GraphEdge* oedgep = ledgep; ledgep = ledgep->inNextp(); - GateEitherVertex* fromvp + GateEitherVertex* const fromvp = dynamic_cast(oedgep->fromp()); new V3GraphEdge(m_graphp, fromvp, m_logicvp, 1); VL_DO_DANGLING(oedgep->unlinkDelete(), oedgep); @@ -1366,7 +1369,7 @@ void GateVisitor::mergeAssigns() { UINFO(6, "mergeAssigns\n"); GateMergeAssignsGraphVisitor merger{&m_graph}; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vvertexp = dynamic_cast(itp)) { + if (GateVarVertex* const vvertexp = dynamic_cast(itp)) { merger.mergeAssignsTree(vvertexp); } } @@ -1430,7 +1433,7 @@ public: class GateClkDecompState final { public: int m_offset; - AstVarScope* m_last_vsp; + AstVarScope* const m_last_vsp; GateClkDecompState(int offset, AstVarScope* vsp) : m_offset{offset} , m_last_vsp{vsp} {} @@ -1450,14 +1453,14 @@ private: virtual VNUser visit(GateVarVertex* vvertexp, VNUser vu) override { // Check that we haven't been here before - AstVarScope* vsp = vvertexp->varScp(); + AstVarScope* const vsp = vvertexp->varScp(); if (vsp->user2SetOnce()) return VNUser(0); UINFO(9, "CLK DECOMP Var - " << vvertexp << " : " << vsp << endl); if (vsp->varp()->width() > 1) { m_seen_clk_vectors++; m_total_seen_clk_vectors++; } - GateClkDecompState* currState = reinterpret_cast(vu.c()); + GateClkDecompState* const currState = reinterpret_cast(vu.c()); GateClkDecompState nextState(currState->m_offset, vsp); vvertexp->iterateCurrentOutEdges(*this, VNUser(&nextState)); if (vsp->varp()->width() > 1) --m_seen_clk_vectors; @@ -1466,13 +1469,13 @@ private: } virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { - GateClkDecompState* currState = reinterpret_cast(vu.c()); + GateClkDecompState* const currState = reinterpret_cast(vu.c()); int clk_offset = currState->m_offset; - if (const AstAssignW* assignp = VN_CAST(lvertexp->nodep(), AssignW)) { + if (const AstAssignW* const assignp = VN_CAST(lvertexp->nodep(), AssignW)) { UINFO(9, "CLK DECOMP Logic (off = " << clk_offset << ") - " << lvertexp << " : " << m_clk_vsp << endl); // RHS - if (AstSel* rselp = VN_CAST(assignp->rhsp(), Sel)) { + if (AstSel* const rselp = VN_CAST(assignp->rhsp(), Sel)) { if (VN_IS(rselp->lsbp(), Const) && VN_IS(rselp->widthp(), Const)) { if (clk_offset < rselp->lsbConst() || clk_offset > rselp->msbConst()) { UINFO(9, "CLK DECOMP Sel [ " << rselp->msbConst() << " : " @@ -1498,7 +1501,7 @@ private: return VNUser(0); } // LHS - if (const AstSel* lselp = VN_CAST(assignp->lhsp(), Sel)) { + if (const AstSel* const lselp = VN_CAST(assignp->lhsp(), Sel)) { if (VN_IS(lselp->lsbp(), Const) && VN_IS(lselp->widthp(), Const)) { clk_offset += lselp->lsbConst(); } else { @@ -1512,7 +1515,7 @@ private: } UINFO(9, "CLK DECOMP Connecting - " << assignp->lhsp() << endl); UINFO(9, " to - " << m_clk_vsp << endl); - AstNode* rhsp = assignp->rhsp(); + AstNode* const rhsp = assignp->rhsp(); rhsp->replaceWith(new AstVarRef(rhsp->fileline(), m_clk_vsp, VAccess::READ)); while (V3GraphEdge* edgep = lvertexp->inBeginp()) { VL_DO_DANGLING(edgep->unlinkDelete(), edgep); @@ -1552,8 +1555,8 @@ void GateVisitor::decomposeClkVectors() { AstNode::user2ClearTree(); GateClkDecompGraphVisitor decomposer{&m_graph}; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (GateVarVertex* vertp = dynamic_cast(itp)) { - AstVarScope* vsp = vertp->varScp(); + if (GateVarVertex* const vertp = dynamic_cast(itp)) { + AstVarScope* const vsp = vertp->varScp(); if (vsp->varp()->attrClocker() == VVarAttrClocker::CLOCKER_YES) { if (vsp->varp()->width() > 1) { UINFO(9, "Clocker > 1 bit, not decomposing: " << vsp << endl); @@ -1573,9 +1576,9 @@ class GateDeassignVisitor final : public GateBaseVisitor { private: // VISITORS virtual void visit(AstVarScope* nodep) override { - if (AstNodeAssign* assp = VN_CAST(nodep->valuep(), NodeAssign)) { + if (AstNodeAssign* const assp = VN_CAST(nodep->valuep(), NodeAssign)) { UINFO(5, " Removeassign " << assp << endl); - AstNode* valuep = assp->rhsp(); + AstNode* const valuep = assp->rhsp(); valuep->unlinkFrBack(); assp->replaceWith(valuep); VL_DO_DANGLING(assp->deleteTree(), assp); diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index 498d6fe08..4c136ba38 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -48,7 +48,7 @@ private: // STATE AstActive* m_activep = nullptr; // Inside activate statement - AstNodeModule* m_topModp; // Top module + AstNodeModule* const m_topModp; // Top module AstScope* const m_scopetopp = v3Global.rootp()->topScopep()->scopep(); // The top AstScope // METHODS @@ -69,18 +69,18 @@ private: // that might have dependents scheduled earlier. UASSERT_OBJ(vscp != v3Global.rootp()->dpiExportTriggerp(), vscp, "DPI export trigger should not need __VinpClk"); - AstVar* varp = vscp->varp(); + AstVar* const varp = vscp->varp(); string newvarname = "__VinpClk__" + vscp->scopep()->nameDotless() + "__" + varp->name(); // Create: VARREF(inpclk) // ... // ASSIGN(VARREF(inpclk), VARREF(var)) - AstVar* newvarp + AstVar* const newvarp = new AstVar(varp->fileline(), AstVarType::MODULETEMP, newvarname, varp); m_topModp->addStmtp(newvarp); - AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopetopp, newvarp); + AstVarScope* const newvscp = new AstVarScope(vscp->fileline(), m_scopetopp, newvarp); m_scopetopp->addVarp(newvscp); - AstAssign* asninitp = new AstAssign( + AstAssign* const asninitp = new AstAssign( vscp->fileline(), new AstVarRef(vscp->fileline(), newvscp, VAccess::WRITE), new AstVarRef(vscp->fileline(), vscp, VAccess::READ)); m_scopetopp->addFinalClkp(asninitp); @@ -98,15 +98,16 @@ private: //---- virtual void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); if (m_activep && !nodep->user3()) { nodep->user3(true); if (vscp->isCircular()) { UINFO(8, " VarActReplace " << nodep << endl); // Replace with the new variable - AstVarScope* newvscp = genInpClk(vscp); - AstVarRef* newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->access()); + AstVarScope* const newvscp = genInpClk(vscp); + AstVarRef* const newrefp + = new AstVarRef(nodep->fileline(), newvscp, nodep->access()); nodep->replaceWith(newrefp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } @@ -187,7 +188,7 @@ private: virtual void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); if (m_activep) { UINFO(8, " VarAct " << nodep << endl); diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index cd0663a5c..87aeef471 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -58,7 +58,7 @@ class GraphAcycEdge final : public V3GraphEdge { private: using OrigEdgeList = std::list; // List of orig edges, see also GraphAcyc's decl V3GraphEdge* origEdgep() const { - OrigEdgeList* oEListp = static_cast(userp()); + const OrigEdgeList* const oEListp = static_cast(userp()); if (!oEListp) v3fatalSrc("No original edge associated with acyc edge " << this); return (oEListp->front()); } @@ -127,8 +127,8 @@ private: } V3GraphEdge* edgeFromEdge(V3GraphEdge* oldedgep, V3GraphVertex* fromp, V3GraphVertex* top) { // Make new breakGraph edge, with old edge as a template - GraphAcycEdge* newEdgep = new GraphAcycEdge(&m_breakGraph, fromp, top, oldedgep->weight(), - oldedgep->cutable()); + GraphAcycEdge* const newEdgep = new GraphAcycEdge(&m_breakGraph, fromp, top, + oldedgep->weight(), oldedgep->cutable()); newEdgep->userp(oldedgep->userp()); // Keep pointer to OrigEdgeList return newEdgep; } @@ -137,12 +137,12 @@ private: // Note addEdge may already have a bunch of similar linked edge representations. Yuk. UASSERT(addEdgep, "Adding nullptr"); if (!toEdgep->userp()) { - OrigEdgeList* oep = new OrigEdgeList; + OrigEdgeList* const oep = new OrigEdgeList; m_origEdgeDelp.push_back(oep); toEdgep->userp(oep); } - OrigEdgeList* oEListp = static_cast(toEdgep->userp()); - if (OrigEdgeList* addListp = static_cast(addEdgep->userp())) { + OrigEdgeList* const oEListp = static_cast(toEdgep->userp()); + if (OrigEdgeList* const addListp = static_cast(addEdgep->userp())) { for (const auto& itr : *addListp) oEListp->push_back(itr); addListp->clear(); // Done with it } else { @@ -153,7 +153,7 @@ private: // From the break edge, cut edges in original graph it represents UINFO(8, why << " CUT " << breakEdgep->fromp() << endl); breakEdgep->cut(); - OrigEdgeList* oEListp = static_cast(breakEdgep->userp()); + const OrigEdgeList* const oEListp = static_cast(breakEdgep->userp()); if (!oEListp) { v3fatalSrc("No original edge associated with cutting edge " << breakEdgep); } @@ -166,7 +166,7 @@ private: } // Work Queue void workPush(V3GraphVertex* vertexp) { - GraphAcycVertex* avertexp = static_cast(vertexp); + GraphAcycVertex* const avertexp = static_cast(vertexp); // Add vertex to list of nodes needing further optimization trials if (!avertexp->m_onWorkList) { avertexp->m_onWorkList = true; @@ -175,7 +175,7 @@ private: } GraphAcycVertex* workBeginp() { return m_work.begin(); } void workPop() { - GraphAcycVertex* avertexp = workBeginp(); + GraphAcycVertex* const avertexp = workBeginp(); avertexp->m_onWorkList = false; avertexp->m_work.unlink(m_work, avertexp); } @@ -204,7 +204,7 @@ void GraphAcyc::buildGraph(V3Graph* origGraphp) { for (V3GraphVertex* overtexp = origGraphp->verticesBeginp(); overtexp; overtexp = overtexp->verticesNextp()) { if (overtexp->color()) { - GraphAcycVertex* avertexp = new GraphAcycVertex(&m_breakGraph, overtexp); + GraphAcycVertex* const avertexp = new GraphAcycVertex(&m_breakGraph, overtexp); overtexp->userp(avertexp); // Stash so can look up later } } @@ -213,7 +213,7 @@ void GraphAcyc::buildGraph(V3Graph* origGraphp) { for (V3GraphVertex* overtexp = origGraphp->verticesBeginp(); overtexp; overtexp = overtexp->verticesNextp()) { if (overtexp->color()) { - GraphAcycVertex* avertexp = static_cast(overtexp->userp()); + GraphAcycVertex* const avertexp = static_cast(overtexp->userp()); buildGraphIterate(overtexp, avertexp); } } @@ -225,7 +225,8 @@ void GraphAcyc::buildGraphIterate(V3GraphVertex* overtexp, GraphAcycVertex* aver if (origFollowEdge(edgep)) { // not cut V3GraphVertex* toVertexp = edgep->top(); if (toVertexp->color()) { - GraphAcycVertex* toAVertexp = static_cast(toVertexp->userp()); + GraphAcycVertex* const toAVertexp + = static_cast(toVertexp->userp()); // Replicate the old edge into the new graph // There may be multiple edges between same pairs of vertices V3GraphEdge* breakEdgep = new GraphAcycEdge(&m_breakGraph, avertexp, toAVertexp, @@ -266,7 +267,7 @@ void GraphAcyc::deleteMarked() { for (V3GraphVertex *nextp, *vertexp = m_breakGraph.verticesBeginp(); vertexp; vertexp = nextp) { nextp = vertexp->verticesNextp(); - GraphAcycVertex* avertexp = static_cast(vertexp); + GraphAcycVertex* const avertexp = static_cast(vertexp); if (avertexp->isDelete()) { VL_DO_DANGLING(avertexp->unlinkDelete(&m_breakGraph), avertexp); } diff --git a/src/V3GraphDfa.cpp b/src/V3GraphDfa.cpp index 16cc3c066..f004fdbc4 100644 --- a/src/V3GraphDfa.cpp +++ b/src/V3GraphDfa.cpp @@ -33,7 +33,7 @@ DfaVertex* DfaGraph::findStart() { DfaVertex* startp = nullptr; for (V3GraphVertex* vertexp = this->verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (DfaVertex* vvertexp = dynamic_cast(vertexp)) { + if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { if (vvertexp->start()) { UASSERT_OBJ(!startp, vertexp, "Multiple start points in NFA graph"); startp = vvertexp; @@ -84,7 +84,7 @@ private: } DfaVertex* newDfaVertex(DfaVertex* nfaTemplatep = nullptr) { - DfaVertex* vertexp = new DfaVertex(graphp()); + DfaVertex* const vertexp = new DfaVertex(graphp()); vertexp->color(1); // Mark as dfa if (nfaTemplatep && nfaTemplatep->start()) vertexp->start(true); if (nfaTemplatep && nfaTemplatep->accepting()) vertexp->accepting(true); @@ -95,7 +95,7 @@ private: // Hashing static uint32_t hashVertex(V3GraphVertex* vertexp) { union { - void* up; + const void* up; struct { uint32_t upper; uint32_t lower; @@ -118,7 +118,7 @@ private: for (V3GraphEdge* dfaEdgep = dfaStatep->outBeginp(); dfaEdgep; dfaEdgep = dfaEdgep->outNextp()) { if (nfaState(dfaEdgep->top())) { - DfaVertex* nfaStatep = static_cast(dfaEdgep->top()); + DfaVertex* const nfaStatep = static_cast(dfaEdgep->top()); hash ^= hashVertex(nfaStatep); if (debug()) { UASSERT_OBJ(nfaStatep->user() != m_step, nfaStatep, @@ -178,7 +178,7 @@ private: const auto eqrange = m_hashMap.equal_range(hash); for (auto it = eqrange.first; it != eqrange.second; ++it) { - DfaVertex* testp = it->second; + DfaVertex* const testp = it->second; if (compareDfaOrigins(nfasWithInput, testp)) { UINFO(9, " DFA match for set: " << testp << endl); return testp; // Identical @@ -197,13 +197,13 @@ private: for (V3GraphEdge* dfaEdgep = dfaStatep->outBeginp(); dfaEdgep; dfaEdgep = dfaEdgep->outNextp()) { if (nfaState(dfaEdgep->top())) { - DfaVertex* nfaStatep = static_cast(dfaEdgep->top()); + const DfaVertex* const nfaStatep = static_cast(dfaEdgep->top()); // Foreach input transition (on this nfaStatep) for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; nfaEdgep = nfaEdgep->outNextp()) { - DfaEdge* cNfaEdgep = static_cast(nfaEdgep); + const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); if (cNfaEdgep->input().toNodep() == input.toNodep()) { - DfaVertex* nextStatep = static_cast(cNfaEdgep->top()); + DfaVertex* const nextStatep = static_cast(cNfaEdgep->top()); if (unseenNfaThisStep(nextStatep)) { // Not processed? nfasWithInput.push_back(nextStatep); nextStatep->user(m_step); @@ -220,15 +220,15 @@ private: DfaStates nfasTodo = nfasWithInput; nfasWithInput.clear(); // Now the completed list while (!nfasTodo.empty()) { - DfaVertex* nfaStatep = nfasTodo.front(); + DfaVertex* const nfaStatep = nfasTodo.front(); nfasTodo.pop_front(); nfasWithInput.push_back(nfaStatep); // Foreach epsilon-reachable (on this nfaStatep) for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; nfaEdgep = nfaEdgep->outNextp()) { - DfaEdge* cNfaEdgep = static_cast(nfaEdgep); + const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); if (cNfaEdgep->epsilon()) { - DfaVertex* nextStatep = static_cast(cNfaEdgep->top()); + DfaVertex* const nextStatep = static_cast(cNfaEdgep->top()); if (unseenNfaThisStep(nextStatep)) { // Not processed? nfasTodo.push_back(nextStatep); nextStatep->user(m_step); @@ -250,10 +250,10 @@ private: if (debug() >= 6) m_graphp->dumpDotFilePrefixed("dfa_nfa"); // Find NFA start - DfaVertex* nfaStartp = graphp()->findStart(); + DfaVertex* const nfaStartp = graphp()->findStart(); // Create new DFA State (start state) from the NFA states - DfaVertex* dfaStartp = newDfaVertex(nfaStartp); + DfaVertex* const dfaStartp = newDfaVertex(nfaStartp); DfaStates dfaUnprocps; // Unprocessed DFA nodes dfaUnprocps.push_back(dfaStartp); @@ -265,7 +265,7 @@ private: workps.push_back(nfaStartp); while (!workps.empty()) { // While work - DfaVertex* nfaStatep = workps.back(); + DfaVertex* const nfaStatep = workps.back(); workps.pop_back(); // UINFO(9," Processing "<user(m_step); // Mark as processed @@ -275,8 +275,8 @@ private: // Find epsilon closure of this nfa node, and destinations to work list for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; nfaEdgep = nfaEdgep->outNextp()) { - DfaEdge* cNfaEdgep = static_cast(nfaEdgep); - DfaVertex* ecNfaStatep = static_cast(nfaEdgep->top()); + const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); + DfaVertex* const ecNfaStatep = static_cast(nfaEdgep->top()); // UINFO(9," Consider "<top()<<" EP "<epsilon()<epsilon() && unseenNfaThisStep(ecNfaStatep)) { // Not processed? workps.push_back(ecNfaStatep); @@ -289,7 +289,7 @@ private: int i = 0; UINFO(5, "Main state conversion...\n"); while (!dfaUnprocps.empty()) { - DfaVertex* dfaStatep = dfaUnprocps.back(); + DfaVertex* const dfaStatep = dfaUnprocps.back(); dfaUnprocps.pop_back(); UINFO(9, " On dfaState " << dfaStatep << endl); @@ -299,11 +299,11 @@ private: for (V3GraphEdge* dfaEdgep = dfaStatep->outBeginp(); dfaEdgep; dfaEdgep = dfaEdgep->outNextp()) { if (nfaState(dfaEdgep->top())) { - DfaVertex* nfaStatep = static_cast(dfaEdgep->top()); + const DfaVertex* const nfaStatep = static_cast(dfaEdgep->top()); // Foreach input on this nfaStatep for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; nfaEdgep = nfaEdgep->outNextp()) { - DfaEdge* cNfaEdgep = static_cast(nfaEdgep); + const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); if (!cNfaEdgep->epsilon()) { if (inputs.find(cNfaEdgep->input().toInt()) == inputs.end()) { inputs.insert(cNfaEdgep->input().toInt()); @@ -403,7 +403,7 @@ private: // (As once we've accepted, we no longer care about anything else.) for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (DfaVertex* vvertexp = dynamic_cast(vertexp)) { + if (const DfaVertex* const vvertexp = dynamic_cast(vertexp)) { if (vvertexp->accepting()) { for (V3GraphEdge *nextp, *edgep = vertexp->outBeginp(); edgep; edgep = nextp) { nextp = edgep->outNextp(); @@ -422,7 +422,7 @@ private: // (Otherwise we might have nodes on the list twice, and reference after deleting them.) m_graphp->userClearVertices(); - DfaVertex* startp = graphp()->findStart(); + DfaVertex* const startp = graphp()->findStart(); std::stack workps; workps.push(startp); @@ -462,7 +462,7 @@ private: std::stack workps; for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (DfaVertex* vvertexp = dynamic_cast(vertexp)) { + if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { workps.push(vvertexp); vertexp->user(1); } else { @@ -473,13 +473,13 @@ private: // While deadness... Delete and find new dead nodes. while (!workps.empty()) { - DfaVertex* vertexp = workps.top(); + DfaVertex* const vertexp = workps.top(); workps.pop(); vertexp->user(0); if (isDead(vertexp)) { // Add nodes that go here to the work list for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - DfaVertex* fromvertexp = static_cast(edgep->fromp()); + DfaVertex* const fromvertexp = static_cast(edgep->fromp()); if (fromvertexp != vertexp && !fromvertexp->user()) { workps.push(fromvertexp); fromvertexp->user(1); @@ -541,7 +541,7 @@ private: DfaVertex* acceptp = nullptr; for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (DfaVertex* vvertexp = dynamic_cast(vertexp)) { + if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { if (vvertexp->accepting()) { acceptp = vvertexp; break; @@ -553,15 +553,16 @@ private: // Remap edges for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (DfaVertex* vvertexp = dynamic_cast(vertexp)) { + if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { // UINFO(9, " on vertex "<name()<accepting() && vvertexp != m_tempNewerReject) { for (V3GraphEdge *nextp, *edgep = vertexp->outBeginp(); edgep; edgep = nextp) { nextp = edgep->outNextp(); if (!edgep->user()) { // Not processed // Old edges to accept now go to new reject - DfaEdge* vedgep = static_cast(edgep); - DfaVertex* tovertexp = static_cast(edgep->top()); + const DfaEdge* const vedgep = static_cast(edgep); + const DfaVertex* const tovertexp + = static_cast(edgep->top()); if (tovertexp->accepting()) { new DfaEdge(graphp(), vvertexp, m_tempNewerReject, vedgep); VL_DO_DANGLING(edgep->unlinkDelete(), edgep); @@ -572,7 +573,8 @@ private: // edge(complemented,a) edge(complemented,b) means !(a | b) if (!tovertexp->accepting()) { // Note we must include edges moved above to reject - DfaEdge* newp = new DfaEdge(graphp(), vvertexp, acceptp, vedgep); + DfaEdge* const newp + = new DfaEdge(graphp(), vvertexp, acceptp, vedgep); newp->complement(!newp->complement()); newp->user(1); } diff --git a/src/V3GraphPathChecker.cpp b/src/V3GraphPathChecker.cpp index 9f6013ace..0ee60def4 100644 --- a/src/V3GraphPathChecker.cpp +++ b/src/V3GraphPathChecker.cpp @@ -65,7 +65,7 @@ GraphPathChecker::GraphPathChecker(const V3Graph* graphp, V3EdgeFuncP edgeFuncp) GraphPathChecker::~GraphPathChecker() { // Free every GraphPCNode for (V3GraphVertex* vxp = m_graphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - GraphPCNode* nodep = static_cast(vxp->userp()); + const GraphPCNode* const nodep = static_cast(vxp->userp()); VL_DO_DANGLING(delete nodep, nodep); vxp->userp(nullptr); } @@ -80,11 +80,11 @@ void GraphPathChecker::initHalfCriticalPaths(GraphWay way, bool checkOnly) { if (!m_edgeFuncp(edgep)) continue; V3GraphVertex* wrelativep = edgep->furtherp(rev); - GraphPCNode* wrelUserp = static_cast(wrelativep->userp()); + const GraphPCNode* const wrelUserp = static_cast(wrelativep->userp()); critPathCost = std::max(critPathCost, wrelUserp->m_cp[way] + 1); } - GraphPCNode* ourUserp = static_cast(vertexp->userp()); + GraphPCNode* const ourUserp = static_cast(vertexp->userp()); if (checkOnly) { UASSERT_OBJ(ourUserp->m_cp[way] == critPathCost, vertexp, "Validation of critical paths failed"); @@ -96,8 +96,8 @@ void GraphPathChecker::initHalfCriticalPaths(GraphWay way, bool checkOnly) { bool GraphPathChecker::pathExistsInternal(const V3GraphVertex* ap, const V3GraphVertex* bp, unsigned* costp) { - GraphPCNode* auserp = static_cast(ap->userp()); - GraphPCNode* buserp = static_cast(bp->userp()); + GraphPCNode* const auserp = static_cast(ap->userp()); + const GraphPCNode* const buserp = static_cast(bp->userp()); // If have already searched this node on the current search, don't // recurse through it again. Since we're still searching, we must not diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index 82c53d495..ed14f17fc 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -277,17 +277,17 @@ class V3GraphTestDfa final : public V3GraphTest { public: virtual string name() override { return "dfa"; } virtual void runTest() override { - DfaGraph* gp = &m_graph; + DfaGraph* const gp = &m_graph; // NFA Pattern for ( (LR) | (L*R)) Z - DfaTestVertex* st = new DfaTestVertex(gp, "*START*"); + DfaTestVertex* const st = new DfaTestVertex(gp, "*START*"); st->start(true); - DfaTestVertex* sl = new DfaTestVertex(gp, "sL"); - DfaTestVertex* srs = new DfaTestVertex(gp, "sR*"); - DfaTestVertex* sls = new DfaTestVertex(gp, "sL*"); - DfaTestVertex* sr = new DfaTestVertex(gp, "sR"); - DfaTestVertex* sz = new DfaTestVertex(gp, "sZ"); - DfaTestVertex* sac = new DfaTestVertex(gp, "*ACCEPT*"); + DfaTestVertex* const sl = new DfaTestVertex(gp, "sL"); + DfaTestVertex* const srs = new DfaTestVertex(gp, "sR*"); + DfaTestVertex* const sls = new DfaTestVertex(gp, "sL*"); + DfaTestVertex* const sr = new DfaTestVertex(gp, "sR"); + DfaTestVertex* const sz = new DfaTestVertex(gp, "sZ"); + DfaTestVertex* const sac = new DfaTestVertex(gp, "*ACCEPT*"); sac->accepting(true); VNUser L = VNUser::fromInt(0xaa); @@ -332,7 +332,7 @@ class V3GraphTestImport final : public V3GraphTest { public: virtual string name() override { return "import"; } virtual void runTest() override { - DfaGraph* gp = &m_graph; + DfaGraph* const gp = &m_graph; if (V3GraphTest::debug()) DfaGraph::debug(9); dotImport(); dump(); diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index 259656989..1306247dd 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -353,7 +353,7 @@ private: virtual void visit(AstInitArray* nodep) override { // Hash unpacked array initializers by value, as the order of initializer nodes does not // matter, and we want semantically equivalent initializers to map to the same hash. - AstUnpackArrayDType* const dtypep = VN_CAST(nodep->dtypep(), UnpackArrayDType); + const AstUnpackArrayDType* const dtypep = VN_CAST(nodep->dtypep(), UnpackArrayDType); m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, /* hashChildren: */ !dtypep, [=]() { if (dtypep) { const uint32_t size = dtypep->elementsConst(); diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index dc7ba5a95..18a5b1c3b 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -108,7 +108,7 @@ static void V3HierWriteCommonInputs(const V3HierBlock* hblockp, std::ostream* of V3HierBlock::StrGParams V3HierBlock::stringifyParams(const GParams& gparams, bool forGOption) { StrGParams strParams; for (const auto& gparam : gparams) { - if (const AstConst* constp = VN_CAST(gparam->valuep(), Const)) { + if (const AstConst* const constp = VN_CAST(gparam->valuep(), Const)) { string s; // Only constant parameter needs to be set to -G because already checked in // V3Param.cpp. See also ParamVisitor::checkSupportedParam() in the file. diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 539728e1b..3c13d9e56 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -177,14 +177,14 @@ private: // Iterate through all modules in bottom-up order. // Make a final inlining decision for each. for (auto it = m_allMods.rbegin(); it != m_allMods.rend(); ++it) { - AstNodeModule* modp = *it; + AstNodeModule* const modp = *it; // If we're going to inline some modules into this one, // update user4 (statement count) to reflect that: int statements = modp->user4(); LocalInstanceMap& localsr = m_instances[modp]; for (LocalInstanceMap::iterator iti = localsr.begin(); iti != localsr.end(); ++iti) { - AstNodeModule* childp = iti->first; + const AstNodeModule* const childp = iti->first; if (childp->user1()) { // inlining child statements += (childp->user4() * iti->second); } @@ -270,8 +270,8 @@ private: // STATE std::unordered_set m_renamedInterfaces; // Name of renamed interface variables - AstNodeModule* m_modp; // Current module - AstCell* m_cellp; // Cell being cloned + AstNodeModule* const m_modp; // Current module + AstCell* const m_cellp; // Cell being cloned // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -307,8 +307,8 @@ private: if (nodep->user2p()) { // Make an assignment, so we'll trace it properly // user2p is either a const or a var. - AstConst* exprconstp = VN_CAST(nodep->user2p(), Const); - AstVarRef* exprvarrefp = VN_CAST(nodep->user2p(), VarRef); + AstConst* const exprconstp = VN_CAST(nodep->user2p(), Const); + const AstVarRef* const exprvarrefp = VN_CAST(nodep->user2p(), VarRef); UINFO(8, "connectto: " << nodep->user2p() << endl); UASSERT_OBJ(exprconstp || exprvarrefp, nodep, "Unknown interconnect type; pinReconnectSimple should have cleared up"); @@ -339,7 +339,7 @@ private: m_modp->addStmtp(new AstAssignVarScope( nodep->fileline(), new AstVarRef(nodep->fileline(), nodep, VAccess::WRITE), new AstVarRef(nodep->fileline(), exprvarrefp->varp(), VAccess::READ))); - AstNode* nodebp = exprvarrefp->varp(); + const AstNode* const nodebp = exprvarrefp->varp(); nodep->fileline()->modifyStateInherit(nodebp->fileline()); nodebp->fileline()->modifyStateInherit(nodep->fileline()); } else { @@ -348,23 +348,23 @@ private: m_modp->addStmtp(new AstAssignAlias( nodep->fileline(), new AstVarRef(nodep->fileline(), nodep, VAccess::WRITE), new AstVarRef(nodep->fileline(), exprvarrefp->varp(), VAccess::READ))); - AstNode* nodebp = exprvarrefp->varp(); + const AstNode* const nodebp = exprvarrefp->varp(); nodep->fileline()->modifyStateInherit(nodebp->fileline()); nodebp->fileline()->modifyStateInherit(nodep->fileline()); } } // Iterate won't hit AstIfaceRefDType directly as it is no longer underneath the module - if (AstIfaceRefDType* ifacerefp = VN_CAST(nodep->dtypep(), IfaceRefDType)) { + if (AstIfaceRefDType* const ifacerefp = VN_CAST(nodep->dtypep(), IfaceRefDType)) { m_renamedInterfaces.insert(nodep->name()); // Each inlined cell that contain an interface variable need to // copy the IfaceRefDType and point it to the newly cloned // interface cell. - AstIfaceRefDType* newdp = ifacerefp->cloneTree(false); + AstIfaceRefDType* const newdp = ifacerefp->cloneTree(false); nodep->dtypep(newdp); ifacerefp->addNextHere(newdp); // Relink to point to newly cloned cell if (newdp->cellp()) { - if (AstCell* newcellp = VN_CAST(newdp->cellp()->user4p(), Cell)) { + if (AstCell* const newcellp = VN_CAST(newdp->cellp()->user4p(), Cell)) { newdp->cellp(newcellp); newdp->cellName(newcellp->name()); // Tag the old ifacerefp to ensure it leaves no stale @@ -398,8 +398,8 @@ private: && !nodep->varp()->user3() // Don't constant propagate aliases (we just made) && !VN_IS(nodep->backp(), AssignAlias)) { - AstConst* exprconstp = VN_CAST(nodep->varp()->user2p(), Const); - AstVarRef* exprvarrefp = VN_CAST(nodep->varp()->user2p(), VarRef); + AstConst* const exprconstp = VN_CAST(nodep->varp()->user2p(), Const); + const AstVarRef* const exprvarrefp = VN_CAST(nodep->varp()->user2p(), VarRef); if (exprconstp) { nodep->replaceWith(exprconstp->cloneTree(true)); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -543,14 +543,14 @@ private: // Clone original module if (debug() >= 9) nodep->dumpTree(cout, "inlcell:"); // if (debug() >= 9) nodep->modp()->dumpTree(cout, "oldmod:"); - AstNodeModule* newmodp = nodep->modp()->cloneTree(false); + AstNodeModule* const newmodp = nodep->modp()->cloneTree(false); if (debug() >= 9) newmodp->dumpTree(cout, "newmod:"); // Clear var markings and find cell cross references AstNode::user2ClearTree(); AstNode::user4ClearTree(); { InlineCollectVisitor{nodep->modp()}; } // {} to destroy visitor immediately // Create data for dotted variable resolution - AstCellInline* inlinep + AstCellInline* const inlinep = new AstCellInline(nodep->fileline(), nodep->name(), nodep->modp()->origName(), nodep->modp()->timeunit()); m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells @@ -561,11 +561,11 @@ private: // Make new signal; even though we'll optimize the interconnect, we // need an alias to trace correctly. If tracing is disabled, we'll // delete it in later optimizations. - AstVar* pinOldVarp = pinp->modVarp(); - AstVar* pinNewVarp = pinOldVarp->clonep(); + AstVar* const pinOldVarp = pinp->modVarp(); + AstVar* const pinNewVarp = pinOldVarp->clonep(); UASSERT_OBJ(pinNewVarp, pinOldVarp, "Cloning failed"); - AstNode* connectRefp = pinp->exprp(); + AstNode* const connectRefp = pinp->exprp(); UASSERT_OBJ( VN_IS(connectRefp, Const) || VN_IS(connectRefp, VarRef), pinp, "Unknown interconnect type; pinReconnectSimple should have cleared up"); @@ -594,7 +594,7 @@ private: { InlineRelinkVisitor{newmodp, m_modp, nodep}; } // Move statements to top module if (debug() >= 9) newmodp->dumpTree(cout, "fixmod:"); - AstNode* stmtsp = newmodp->stmtsp(); + AstNode* const stmtsp = newmodp->stmtsp(); if (stmtsp) stmtsp->unlinkFrBackWithNext(); if (stmtsp) m_modp->addStmtp(stmtsp); // Remove the cell @@ -646,14 +646,14 @@ private: m_scope += "__DOT__" + nodep->name(); } - if (AstModule* modp = VN_CAST(nodep->modp(), Module)) { + if (AstModule* const modp = VN_CAST(nodep->modp(), Module)) { // Pass Cell pointers down to the next module for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { - AstVar* varp = pinp->modVarp(); - AstVarRef* varrefp = VN_CAST(pinp->exprp(), VarRef); + AstVar* const varp = pinp->modVarp(); + const AstVarRef* const varrefp = VN_CAST(pinp->exprp(), VarRef); if (!varrefp) continue; - AstVar* fromVarp = varrefp->varp(); - AstIfaceRefDType* irdtp = VN_CAST(fromVarp->dtypep(), IfaceRefDType); + const AstVar* const fromVarp = varrefp->varp(); + const AstIfaceRefDType* const irdtp = VN_CAST(fromVarp->dtypep(), IfaceRefDType); if (!irdtp) continue; AstCell* cellp; @@ -672,18 +672,18 @@ private: } virtual void visit(AstAssignVarScope* nodep) override { // Reference - AstVarRef* reflp = VN_CAST(nodep->lhsp(), VarRef); + const AstVarRef* const reflp = VN_CAST(nodep->lhsp(), VarRef); // What the reference refers to - AstVarRef* refrp = VN_CAST(nodep->rhsp(), VarRef); + const AstVarRef* const refrp = VN_CAST(nodep->rhsp(), VarRef); if (!(reflp && refrp)) return; - AstVar* varlp = reflp->varp(); - AstVar* varrp = refrp->varp(); + const AstVar* const varlp = reflp->varp(); + const AstVar* const varrp = refrp->varp(); if (!(varlp && varrp)) return; AstCell* cellp = VN_CAST(varrp->user1p(), Cell); if (!cellp) { - AstIfaceRefDType* irdtp = VN_CAST(varrp->dtypep(), IfaceRefDType); + const AstIfaceRefDType* const irdtp = VN_CAST(varrp->dtypep(), IfaceRefDType); if (!irdtp) return; cellp = irdtp->cellp(); diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 92fdfb954..e35a9b9e0 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -70,23 +70,24 @@ private: // Use user1p on the PIN to indicate we created an assign for this pin if (!nodep->user1SetOnce()) { // Make an ASSIGNW (expr, pin) - AstNode* exprp = nodep->exprp()->cloneTree(false); + AstNode* const exprp = nodep->exprp()->cloneTree(false); UASSERT_OBJ(exprp->width() == nodep->modVarp()->width(), nodep, "Width mismatch, should have been handled in pinReconnectSimple"); if (nodep->modVarp()->isInoutish()) { nodep->v3fatalSrc("Unsupported: Verilator is a 2-state simulator"); } else if (nodep->modVarp()->isWritable()) { - AstNode* rhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), - m_cellp->name(), VAccess::READ); - AstAssignW* assp = new AstAssignW(exprp->fileline(), exprp, rhsp); + AstNode* const rhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), + m_cellp->name(), VAccess::READ); + AstAssignW* const assp = new AstAssignW(exprp->fileline(), exprp, rhsp); m_cellp->addNextHere(assp); } else if (nodep->modVarp()->isNonOutput()) { // Don't bother moving constants now, // we'll be pushing the const down to the cell soon enough. - AstNode* assp = new AstAssignW(exprp->fileline(), - new AstVarXRef(exprp->fileline(), nodep->modVarp(), - m_cellp->name(), VAccess::WRITE), - exprp); + AstNode* const assp + = new AstAssignW(exprp->fileline(), + new AstVarXRef(exprp->fileline(), nodep->modVarp(), + m_cellp->name(), VAccess::WRITE), + exprp); m_cellp->addNextHere(assp); if (debug() >= 9) assp->dumpTree(cout, " _new: "); } else if (nodep->modVarp()->isIfaceRef() @@ -96,13 +97,14 @@ private: IfaceRefDType))) { // Create an AstAssignVarScope for Vars to Cells so we can // link with their scope later - AstNode* lhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), - m_cellp->name(), VAccess::READ); - const AstVarRef* refp = VN_CAST(exprp, VarRef); - const AstVarXRef* xrefp = VN_CAST(exprp, VarXRef); + AstNode* const lhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(), + m_cellp->name(), VAccess::READ); + const AstVarRef* const refp = VN_CAST(exprp, VarRef); + const AstVarXRef* const xrefp = VN_CAST(exprp, VarXRef); UASSERT_OBJ(refp || xrefp, exprp, "Interfaces: Pin is not connected to a VarRef or VarXRef"); - AstAssignVarScope* assp = new AstAssignVarScope(exprp->fileline(), lhsp, exprp); + AstAssignVarScope* const assp + = new AstAssignVarScope(exprp->fileline(), lhsp, exprp); m_cellp->addNextHere(assp); } else { nodep->v3error("Assigned pin is neither input nor output"); @@ -204,18 +206,18 @@ private: if (VN_IS(nodep->dtypep(), UnpackArrayDType) && VN_IS(VN_AS(nodep->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType)) { UINFO(8, " dv-vec-VAR " << nodep << endl); - AstUnpackArrayDType* arrdtype = VN_AS(nodep->dtypep(), UnpackArrayDType); + AstUnpackArrayDType* const arrdtype = VN_AS(nodep->dtypep(), UnpackArrayDType); AstNode* prevp = nullptr; for (int i = arrdtype->lo(); i <= arrdtype->hi(); ++i) { const string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__"; UINFO(8, "VAR name insert " << varNewName << " " << nodep << endl); if (!m_deModVars.find(varNewName)) { - AstIfaceRefDType* ifaceRefp + AstIfaceRefDType* const ifaceRefp = VN_AS(arrdtype->subDTypep(), IfaceRefDType)->cloneTree(false); arrdtype->addNextHere(ifaceRefp); ifaceRefp->cellp(nullptr); - AstVar* varNewp = nodep->cloneTree(false); + AstVar* const varNewp = nodep->cloneTree(false); varNewp->name(varNewName); varNewp->origName(varNewp->origName() + "__BRA__" + cvtToStr(i) + "__KET__"); varNewp->dtypep(ifaceRefp); @@ -245,7 +247,7 @@ private: if (nodep->rangep()) { m_cellRangep = nodep->rangep(); - AstVar* ifaceVarp = VN_CAST(nodep->nextp(), Var); + AstVar* const ifaceVarp = VN_CAST(nodep->nextp(), Var); const bool isIface = ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType) && VN_IS(VN_AS(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(), @@ -257,7 +259,7 @@ private: = m_cellRangep->littleEndian() ? (m_cellRangep->elementsConst() - 1 - i) : i; const int instNum = m_cellRangep->loConst() + i; - AstCell* newp = nodep->cloneTree(false); + AstCell* const newp = nodep->cloneTree(false); nodep->addNextHere(newp); // Remove ranging and fix name newp->rangep()->unlinkFrBack()->deleteTree(); @@ -271,11 +273,13 @@ private: // If this AstCell is actually an interface instantiation, also clone the IfaceRef // within the same parent module as the cell if (isIface) { - AstUnpackArrayDType* arrdtype = VN_AS(ifaceVarp->dtypep(), UnpackArrayDType); - AstIfaceRefDType* origIfaceRefp = VN_AS(arrdtype->subDTypep(), IfaceRefDType); + AstUnpackArrayDType* const arrdtype + = VN_AS(ifaceVarp->dtypep(), UnpackArrayDType); + AstIfaceRefDType* const origIfaceRefp + = VN_AS(arrdtype->subDTypep(), IfaceRefDType); origIfaceRefp->cellp(nullptr); - AstVar* varNewp = ifaceVarp->cloneTree(false); - AstIfaceRefDType* ifaceRefp = origIfaceRefp->cloneTree(false); + AstVar* const varNewp = ifaceVarp->cloneTree(false); + AstIfaceRefDType* const ifaceRefp = origIfaceRefp->cloneTree(false); arrdtype->addNextHere(ifaceRefp); ifaceRefp->cellp(newp); ifaceRefp->cellName(newp->name()); @@ -327,7 +331,8 @@ private: << pinDim.second << endl); if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) { // Connection to array, where array dimensions match the instant dimension - AstRange* rangep = VN_AS(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep(); + AstRange* const rangep + = VN_AS(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep(); const int arraySelNum = rangep->littleEndian() ? (rangep->elementsConst() - 1 - m_instSelNum) : m_instSelNum; @@ -362,11 +367,12 @@ private: } } // end expanding ranged cell else if (AstArraySel* arrselp = VN_CAST(nodep->exprp(), ArraySel)) { - if (AstUnpackArrayDType* arrp = VN_CAST(arrselp->lhsp()->dtypep(), UnpackArrayDType)) { + if (AstUnpackArrayDType* const arrp + = VN_CAST(arrselp->lhsp()->dtypep(), UnpackArrayDType)) { if (!VN_IS(arrp->subDTypep(), IfaceRefDType)) return; // Interface pin attaches to one element of arrayed interface V3Const::constifyParamsEdit(arrselp->rhsp()); - const AstConst* constp = VN_CAST(arrselp->rhsp(), Const); + const AstConst* const constp = VN_CAST(arrselp->rhsp(), Const); if (!constp) { nodep->v3warn( E_UNSUPPORTED, @@ -376,19 +382,19 @@ private: const string index = AstNode::encodeNumber(constp->toSInt()); if (VN_IS(arrselp->lhsp(), SliceSel)) arrselp->lhsp()->v3error("Unsupported: interface slices"); - AstVarRef* varrefp = VN_CAST(arrselp->lhsp(), VarRef); + AstVarRef* const varrefp = VN_CAST(arrselp->lhsp(), VarRef); UASSERT_OBJ(varrefp, arrselp, "No interface varref under array"); - AstVarXRef* newp = new AstVarXRef(nodep->fileline(), - varrefp->name() + "__BRA__" + index + "__KET__", - "", VAccess::WRITE); + AstVarXRef* const newp = new AstVarXRef( + nodep->fileline(), varrefp->name() + "__BRA__" + index + "__KET__", "", + VAccess::WRITE); newp->dtypep(nodep->modVarp()->dtypep()); newp->classOrPackagep(varrefp->classOrPackagep()); arrselp->addNextHere(newp); VL_DO_DANGLING(arrselp->unlinkFrBack()->deleteTree(), arrselp); } } else { - AstVar* pinVarp = nodep->modVarp(); - AstUnpackArrayDType* pinArrp = VN_CAST(pinVarp->dtypep(), UnpackArrayDType); + AstVar* const pinVarp = nodep->modVarp(); + AstUnpackArrayDType* const pinArrp = VN_CAST(pinVarp->dtypep(), UnpackArrayDType); if (!pinArrp || !VN_IS(pinArrp->subDTypep(), IfaceRefDType)) return; // Arrayed pin/var attaches to arrayed submodule lower port/var, expand it AstNode* prevp = nullptr; @@ -404,7 +410,7 @@ private: if (!pinVarp->backp()) { varNewp = m_deModVars.find(varNewName); } else { - AstIfaceRefDType* ifaceRefp = VN_AS(pinArrp->subDTypep(), IfaceRefDType); + AstIfaceRefDType* const ifaceRefp = VN_AS(pinArrp->subDTypep(), IfaceRefDType); ifaceRefp->cellp(nullptr); varNewp = pinVarp->cloneTree(false); varNewp->name(varNewName); @@ -425,18 +431,18 @@ private: // But clone the pin for each module instance // Now also clone the pin itself and update its varref - AstPin* newp = nodep->cloneTree(false); + AstPin* const newp = nodep->cloneTree(false); newp->modVarp(varNewp); newp->name(newp->name() + "__BRA__" + cvtToStr(i) + "__KET__"); // And replace exprp with a new varxref const AstVarRef* varrefp = VN_CAST(newp->exprp(), VarRef); // Maybe null int expr_i = i; - if (AstSliceSel* slicep = VN_CAST(newp->exprp(), SliceSel)) { + if (AstSliceSel* const slicep = VN_CAST(newp->exprp(), SliceSel)) { varrefp = VN_AS(slicep->fromp(), VarRef); UASSERT(VN_IS(slicep->rhsp(), Const), "Slices should be constant"); int slice_index = slicep->declRange().left() + in * slicep->declRange().leftToRightInc(); - auto* exprArrp = VN_AS(varrefp->dtypep(), UnpackArrayDType); + auto* const exprArrp = VN_AS(varrefp->dtypep(), UnpackArrayDType); UASSERT_OBJ(exprArrp, slicep, "Slice of non-array"); expr_i = slice_index + exprArrp->lo(); } else if (!varrefp) { @@ -446,7 +452,7 @@ private: } const string newname = varrefp->name() + "__BRA__" + cvtToStr(expr_i) + "__KET__"; - AstVarXRef* newVarXRefp + AstVarXRef* const newVarXRefp = new AstVarXRef(nodep->fileline(), newname, "", VAccess::WRITE); newVarXRefp->varp(newp->modVarp()); newp->exprp()->unlinkFrBack()->deleteTree(); @@ -506,7 +512,7 @@ public: // Else create a intermediate wire to perform the interconnect // Return the new assignment, if one was made // Note this module calles cloneTree() via new AstVar - AstVar* pinVarp = pinp->modVarp(); + AstVar* const pinVarp = pinp->modVarp(); if (!pinp->exprp()) { // No-connect, perhaps promote based on `unconnected_drive, // otherwise done @@ -520,9 +526,9 @@ public: return nullptr; } } - AstVarRef* connectRefp = VN_CAST(pinp->exprp(), VarRef); - AstVarXRef* connectXRefp = VN_CAST(pinp->exprp(), VarXRef); - AstBasicDType* pinBasicp = VN_CAST(pinVarp->dtypep(), BasicDType); // Maybe nullptr + AstVarRef* const connectRefp = VN_CAST(pinp->exprp(), VarRef); + AstVarXRef* const connectXRefp = VN_CAST(pinp->exprp(), VarXRef); + AstBasicDType* const pinBasicp = VN_CAST(pinVarp->dtypep(), BasicDType); // Maybe nullptr AstBasicDType* connBasicp = nullptr; AstAssignW* assignp = nullptr; if (connectRefp) connBasicp = VN_CAST(connectRefp->varp()->dtypep(), BasicDType); @@ -547,12 +553,12 @@ public: // Make a new temp wire // if (1 || debug() >= 9) pinp->dumpTree(cout, "-in_pin:"); V3Inst::checkOutputShort(pinp); - AstNode* pinexprp = pinp->exprp()->unlinkFrBack(); + AstNode* const pinexprp = pinp->exprp()->unlinkFrBack(); string newvarname = (string(pinVarp->isWritable() ? "__Vcellout" : "__Vcellinp") // Prevent name conflict if both tri & non-tri add signals + (forTristate ? "t" : "") + "__" + cellp->name() + "__" + pinp->name()); - AstVar* newvarp + AstVar* const newvarp = new AstVar(pinVarp->fileline(), AstVarType::MODULETEMP, newvarname, pinVarp); // Important to add statement next to cell, in case there is a // generate with same named cell @@ -567,7 +573,7 @@ public: << pinexprp->width() << endl); rhsp = extendOrSel(pinp->fileline(), rhsp, pinVarp); pinp->exprp(new AstVarRef(newvarp->fileline(), newvarp, VAccess::WRITE)); - AstNode* rhsSelp = extendOrSel(pinp->fileline(), rhsp, pinexprp); + AstNode* const rhsSelp = extendOrSel(pinp->fileline(), rhsp, pinexprp); assignp = new AstAssignW(pinp->fileline(), pinexprp, rhsSelp); } else { // V3 width should have range/extended to make the widths correct diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index 49e67e0d7..7b1a6ab0e 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -38,7 +38,7 @@ private: // MEMBERS uint32_t m_instrCount = 0; // Running count of instructions - const AstNode* m_startNodep; // Start node of count + const AstNode* const m_startNodep; // Start node of count bool m_tracingCall = false; // Iterating into a CCall to a CFunc bool m_inCFunc = false; // Inside AstCFunc bool m_assertNoDups; // Check for duplicates @@ -50,8 +50,8 @@ private: private: // MEMBERS uint32_t m_savedCount; - AstNode* m_nodep; - InstrCountVisitor* m_visitor; + AstNode* const m_nodep; + InstrCountVisitor* const m_visitor; public: // CONSTRUCTORS diff --git a/src/V3Life.cpp b/src/V3Life.cpp index c0fcb0ed3..7096f6558 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -138,13 +138,13 @@ public: ~LifeBlock() = default; // METHODS void checkRemoveAssign(const LifeMap::iterator& it) { - AstVar* varp = it->first->varp(); - LifeVarEntry* entp = &(it->second); + const AstVar* const varp = it->first->varp(); + LifeVarEntry* const entp = &(it->second); if (!varp->isSigPublic()) { // Rather than track what sigs AstUCFunc/AstUCStmt may change, // we just don't optimize any public sigs // Check the var entry, and remove if appropriate - if (AstNode* oldassp = entp->assignp()) { + if (AstNode* const oldassp = entp->assignp()) { UINFO(7, " PREV: " << oldassp << endl); // Redundant assignment, in same level block // Don't delete it now as it will confuse iteration since it maybe WAY @@ -182,7 +182,7 @@ public: // Variable rvalue. If it references a constant, we can simply replace it const auto it = m_map.find(nodep); if (it != m_map.end()) { - if (AstConst* constp = it->second.constNodep()) { + if (AstConst* const constp = it->second.constNodep()) { if (!varrefp->varp()->isSigPublic()) { // Aha, variable is constant; substitute in. // We'll later constant propagate @@ -220,7 +220,7 @@ public: // Any varrefs under a if/else branch affect statements outside and after the if/else if (!m_aboveLifep) v3fatalSrc("Pushing life when already at the top level"); for (LifeMap::iterator it = m_map.begin(); it != m_map.end(); ++it) { - AstVarScope* nodep = it->first; + AstVarScope* const nodep = it->first; m_aboveLifep->complexAssignFind(nodep); if (it->second.everSet()) { // Record there may be an assignment, so we don't constant propagate across the if. @@ -242,7 +242,7 @@ public: } for (LifeMap::iterator it = life2p->m_map.begin(); it != life2p->m_map.end(); ++it) { // When the else branch sets a var before it's used - AstVarScope* nodep = it->first; + AstVarScope* const nodep = it->first; if (it->second.setBeforeUse() && nodep->user1()) { // Both branches set the var, we can remove the assignment before the IF. UINFO(4, "DUALBRANCH " << nodep << endl); @@ -291,7 +291,7 @@ private: // it's used so can't elim assignment before this use. UASSERT_OBJ(nodep->varScopep(), nodep, "nullptr"); // - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); if (nodep->access().isWriteOrRW()) { m_sideEffect = true; // $sscanf etc may have RHS vars that are lvalues @@ -313,7 +313,7 @@ private: } // Has to be direct assignment without any EXTRACTing. if (VN_IS(nodep->lhsp(), VarRef) && !m_sideEffect && !m_noopt) { - AstVarScope* vscp = VN_AS(nodep->lhsp(), VarRef)->varScopep(); + AstVarScope* const vscp = VN_AS(nodep->lhsp(), VarRef)->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope lost on variable"); m_lifep->simpleAssign(vscp, nodep); } else { @@ -330,9 +330,9 @@ private: UINFO(4, " IF " << nodep << endl); // Condition is part of PREVIOUS block iterateAndNextNull(nodep->condp()); - LifeBlock* prevLifep = m_lifep; - LifeBlock* ifLifep = new LifeBlock(prevLifep, m_statep); - LifeBlock* elseLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const prevLifep = m_lifep; + LifeBlock* const ifLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const elseLifep = new LifeBlock(prevLifep, m_statep); { m_lifep = ifLifep; iterateAndNextNull(nodep->ifsp()); @@ -360,9 +360,9 @@ private: // would because it only appears used after-the-fact. So, we model // it as a IF statement, and just don't allow elimination of // variables across the body. - LifeBlock* prevLifep = m_lifep; - LifeBlock* condLifep = new LifeBlock(prevLifep, m_statep); - LifeBlock* bodyLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const prevLifep = m_lifep; + LifeBlock* const condLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const bodyLifep = new LifeBlock(prevLifep, m_statep); { m_lifep = condLifep; iterateAndNextNull(nodep->precondsp()); @@ -385,8 +385,8 @@ private: // As with While's we can't predict if a JumpGo will kill us or not // It's worse though as an IF(..., JUMPGO) may change the control flow. // Just don't optimize blocks with labels; they're rare - so far. - LifeBlock* prevLifep = m_lifep; - LifeBlock* bodyLifep = new LifeBlock(prevLifep, m_statep); + LifeBlock* const prevLifep = m_lifep; + LifeBlock* const bodyLifep = new LifeBlock(prevLifep, m_statep); const bool prev_noopt = m_noopt; { m_lifep = bodyLifep; @@ -455,7 +455,7 @@ class LifeTopVisitor final : public AstNVisitor { // finding code within. private: // STATE - LifeState* m_statep; // Current state + LifeState* const m_statep; // Current state // VISITORS virtual void visit(AstCFunc* nodep) override { diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 7eee9d96d..dbfbf8de0 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -54,11 +54,11 @@ private: // VISITORS virtual void visit(AstVarRef* nodep) override { - AstVarScope* vscp = nodep->varScopep(); + const AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); - if (AstVarScope* newvscp = reinterpret_cast(vscp->user4p())) { + if (AstVarScope* const newvscp = reinterpret_cast(vscp->user4p())) { UINFO(9, " Replace " << nodep << " to " << newvscp << endl); - AstVarRef* newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->access()); + AstVarRef* const newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->access()); nodep->replaceWith(newrefp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -186,11 +186,11 @@ private: } void squashAssignposts() { for (auto& itr : m_assignposts) { - LifePostLocation* app = &itr.second; - AstVarRef* lhsp = VN_AS(app->nodep->lhsp(), VarRef); // original var - AstVarRef* rhsp = VN_AS(app->nodep->rhsp(), VarRef); // dly var - AstVarScope* dlyVarp = rhsp->varScopep(); - AstVarScope* origVarp = lhsp->varScopep(); + LifePostLocation* const app = &itr.second; + AstVarRef* const lhsp = VN_AS(app->nodep->lhsp(), VarRef); // original var + AstVarRef* const rhsp = VN_AS(app->nodep->rhsp(), VarRef); // dly var + AstVarScope* const dlyVarp = rhsp->varScopep(); + AstVarScope* const origVarp = lhsp->varScopep(); // Scrunch these: // X1: __Vdly__q = __PVT__clk_clocks; @@ -275,7 +275,7 @@ private: } virtual void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); LifeLocation loc(m_execMTaskp, ++m_sequence); @@ -292,9 +292,9 @@ private: virtual void visit(AstAssignPost* nodep) override { // Don't record ASSIGNPOST in the read/write maps, record them in a // separate map - if (AstVarRef* rhsp = VN_CAST(nodep->rhsp(), VarRef)) { + if (AstVarRef* const rhsp = VN_CAST(nodep->rhsp(), VarRef)) { // rhsp is the dly var - AstVarScope* dlyVarp = rhsp->varScopep(); + AstVarScope* const dlyVarp = rhsp->varScopep(); UASSERT_OBJ(m_assignposts.find(dlyVarp) == m_assignposts.end(), nodep, "LifePostLocation attempted duplicate dlyvar map addition"); LifeLocation loc(m_execMTaskp, ++m_sequence); @@ -318,7 +318,7 @@ private: m_mtasksGraphp = nodep->depGraphp(); for (V3GraphVertex* mtaskVxp = m_mtasksGraphp->verticesBeginp(); mtaskVxp; mtaskVxp = mtaskVxp->verticesNextp()) { - ExecMTask* mtaskp = dynamic_cast(mtaskVxp); + ExecMTask* const mtaskp = dynamic_cast(mtaskVxp); m_execMTaskp = mtaskp; m_sequence = 0; iterate(mtaskp->bodyp()); diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index 7e29a669c..ee631f419 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -49,7 +49,7 @@ public: }; class LinkCellsVertex final : public V3GraphVertex { - AstNodeModule* m_modp; + AstNodeModule* const m_modp; public: LinkCellsVertex(V3Graph* graphp, AstNodeModule* modp) @@ -74,7 +74,7 @@ public: }; void LinkCellsGraph::loopsMessageCb(V3GraphVertex* vertexp) { - if (LinkCellsVertex* vvertexp = dynamic_cast(vertexp)) { + if (const LinkCellsVertex* const vvertexp = dynamic_cast(vertexp)) { vvertexp->modp()->v3warn(E_UNSUPPORTED, "Unsupported: Recursive multiple modules (module instantiates " "something leading back to itself): " @@ -127,7 +127,7 @@ private: } AstNodeModule* findModuleSym(const string& modName) { - VSymEnt* foundp = m_mods.rootp()->findIdFallback(modName); + const VSymEnt* const foundp = m_mods.rootp()->findIdFallback(modName); if (!foundp) { return nullptr; } else { @@ -169,9 +169,9 @@ private: m_graph.dumpDotFilePrefixed("linkcells"); m_graph.rank(); for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (LinkCellsVertex* vvertexp = dynamic_cast(itp)) { + if (const LinkCellsVertex* const vvertexp = dynamic_cast(itp)) { // +1 so we leave level 1 for the new wrapper we'll make in a moment - AstNodeModule* modp = vvertexp->modp(); + AstNodeModule* const modp = vvertexp->modp(); modp->level(vvertexp->rank() + 1); } } @@ -228,7 +228,7 @@ private: UINFO(4, "Link IfaceRef: " << nodep << endl); // Use findIdUpward instead of findIdFlat; it doesn't matter for now // but we might support modules-under-modules someday. - AstNodeModule* modp = resolveModule(nodep, nodep->ifaceName()); + AstNodeModule* const modp = resolveModule(nodep, nodep->ifaceName()); if (modp) { if (VN_IS(modp, Iface)) { // Track module depths, so can sort list from parent down to children @@ -256,9 +256,9 @@ private: // this move to post param, which would mean we do not auto-read modules // and means we cannot compute module levels until later. UINFO(4, "Link Bind: " << nodep << endl); - AstNodeModule* modp = resolveModule(nodep, nodep->name()); + AstNodeModule* const modp = resolveModule(nodep, nodep->name()); if (modp) { - AstNode* cellsp = nodep->cellsp()->unlinkFrBackWithNext(); + AstNode* const cellsp = nodep->cellsp()->unlinkFrBackWithNext(); // Module may have already linked, so need to pick up these new cells VL_RESTORER(m_modp); { @@ -388,13 +388,13 @@ private: // and it's easier to do it now than in V3LinkDot when we'd need to repeat steps. for (AstNode* portnodep = nodep->modp()->stmtsp(); portnodep; portnodep = portnodep->nextp()) { - if (const AstPort* portp = VN_CAST(portnodep, Port)) { + if (const AstPort* const portp = VN_CAST(portnodep, Port)) { if (ports.find(portp->name()) == ports.end() && ports.find("__pinNumber" + cvtToStr(portp->pinNum())) == ports.end()) { if (pinStar) { UINFO(9, " need .* PORT " << portp << endl); // Create any not already connected - AstPin* newp = new AstPin( + AstPin* const newp = new AstPin( nodep->fileline(), 0, portp->name(), new AstParseRef(nodep->fileline(), VParseRefExp::PX_TEXT, portp->name(), nullptr, nullptr)); @@ -403,7 +403,7 @@ private: } else { // warn on the CELL that needs it, not the port nodep->v3warn(PINMISSING, "Cell has missing pin: " << portp->prettyNameQ()); - AstPin* newp + AstPin* const newp = new AstPin(nodep->fileline(), 0, portp->name(), nullptr); nodep->addPinsp(newp); } @@ -421,14 +421,14 @@ private: if (!nodep->hasIfaceVar()) { const string varName = nodep->name() + "__Viftop"; // V3LinkDot looks for this naming - AstIfaceRefDType* idtypep = new AstIfaceRefDType(nodep->fileline(), nodep->name(), - nodep->modp()->name()); + AstIfaceRefDType* const idtypep = new AstIfaceRefDType( + nodep->fileline(), nodep->name(), nodep->modp()->name()); idtypep->ifacep(nullptr); // cellp overrides // In the case of arrayed interfaces, we replace cellp when de-arraying in V3Inst idtypep->cellp(nodep); // Only set when real parent cell known. AstVar* varp; if (nodep->rangep()) { - AstNodeArrayDType* arrp + AstNodeArrayDType* const arrp = new AstUnpackArrayDType(nodep->fileline(), VFlagChildDType(), idtypep, nodep->rangep()->cloneTree(true)); varp = new AstVar(nodep->fileline(), AstVarType::IFACEREF, varName, @@ -474,7 +474,7 @@ private: nodep->name(hierIt->first); // Change name of this module to be mangled name // considering parameter } - AstNodeModule* foundp = findModuleSym(nodep->name()); + AstNodeModule* const foundp = findModuleSym(nodep->name()); if (foundp && foundp != nodep) { if (!(foundp->fileline()->warnIsOff(V3ErrorCode::MODDUP) || nodep->fileline()->warnIsOff(V3ErrorCode::MODDUP) diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index d2388e2d5..60dd287a6 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -99,7 +99,7 @@ public: class LinkNodeMatcherVarIO final : public VNodeMatcher { public: virtual bool nodeMatch(const AstNode* nodep) const override { - const AstVar* varp = VN_CAST(nodep, Var); + const AstVar* const varp = VN_CAST(nodep, Var); if (!varp) return false; return varp->isIO(); } @@ -107,7 +107,7 @@ public: class LinkNodeMatcherVarParam final : public VNodeMatcher { public: virtual bool nodeMatch(const AstNode* nodep) const override { - const AstVar* varp = VN_CAST(nodep, Var); + const AstVar* const varp = VN_CAST(nodep, Var); if (!varp) return false; return varp->isParam(); } @@ -249,8 +249,8 @@ public: // // Note we only check for conflicts at the same level; it's ok if one block hides another // We also wouldn't want to not insert it even though it's lower down - VSymEnt* foundp = lookupSymp->findIdFlat(name); - AstNode* fnodep = foundp ? foundp->nodep() : nullptr; + VSymEnt* const foundp = lookupSymp->findIdFlat(name); + AstNode* const fnodep = foundp ? foundp->nodep() : nullptr; if (!fnodep) { // Not found, will add in a moment. } else if (nodep == fnodep) { // Already inserted. @@ -284,7 +284,7 @@ public: } void insertDUnit(AstNetlist* nodep) { // $unit on top scope - VSymEnt* symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt(&m_syms, nodep); UINFO(9, " INSERTdunit se" << cvtToHex(symp) << endl); symp->parentp(rootEntp()); // Needed so backward search can find name of top module symp->fallbackp(nullptr); @@ -295,7 +295,7 @@ public: } VSymEnt* insertTopCell(AstNodeModule* nodep, const string& scopename) { // Only called on the module at the very top of the hierarchy - VSymEnt* symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt(&m_syms, nodep); UINFO(9, " INSERTtop se" << cvtToHex(symp) << " " << scopename << " " << nodep << endl); symp->parentp(rootEntp()); // Needed so backward search can find name of top module @@ -309,7 +309,7 @@ public: VSymEnt* insertCell(VSymEnt* abovep, VSymEnt* modSymp, AstCell* nodep, const string& scopename) { UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt(&m_syms, nodep); UINFO(9, " INSERTcel se" << cvtToHex(symp) << " " << scopename << " above=se" << cvtToHex(abovep) << " mods=se" << cvtToHex(modSymp) << " node=" << nodep << endl); @@ -337,7 +337,7 @@ public: // A fake point in the hierarchy, corresponding to an inlined module // This references to another Sym, and eventually resolves to a module with a prefix UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt(&m_syms, nodep); UINFO(9, " INSERTinl se" << cvtToHex(symp) << " " << basename << " above=se" << cvtToHex(abovep) << " mods=se" << cvtToHex(modSymp) << " node=" << nodep << endl); @@ -360,7 +360,7 @@ public: // Note we fallback to the symbol table of the parent, as we want to find variables there // However, cells walk the graph, so cells will appear under the begin/ftask itself UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt(&m_syms, nodep); UINFO(9, " INSERTblk se" << cvtToHex(symp) << " above=se" << cvtToHex(abovep) << " pkg=" << cvtToHex(classOrPackagep) << " node=" << nodep << endl); @@ -376,7 +376,7 @@ public: VSymEnt* insertSym(VSymEnt* abovep, const string& name, AstNode* nodep, AstNodeModule* classOrPackagep) { UASSERT_OBJ(abovep, nodep, "Null symbol table inserting node"); - VSymEnt* symp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symp = new VSymEnt(&m_syms, nodep); UINFO(9, " INSERTsym se" << cvtToHex(symp) << " name='" << name << "' above=se" << cvtToHex(abovep) << " pkg=" << cvtToHex(classOrPackagep) << " node=" << nodep << endl); @@ -394,7 +394,7 @@ public: static VSymEnt* getNodeSym(AstNode* nodep) { // Don't use this in ResolveVisitor, as we need to pick up the proper // reference under each SCOPE - VSymEnt* symp = nodep->user1u().toSymEnt(); + VSymEnt* const symp = nodep->user1u().toSymEnt(); UASSERT_OBJ(symp, nodep, "Module/etc never assigned a symbol entry?"); return symp; } @@ -431,7 +431,7 @@ public: static AstIfaceRefDType* ifaceRefFromArray(AstNodeDType* nodep) { AstIfaceRefDType* ifacerefp = VN_CAST(nodep, IfaceRefDType); if (!ifacerefp) { - if (AstBracketArrayDType* arrp = VN_CAST(nodep, BracketArrayDType)) { + if (AstBracketArrayDType* const arrp = VN_CAST(nodep, BracketArrayDType)) { ifacerefp = VN_CAST(arrp->subDTypep(), IfaceRefDType); } else if (AstUnpackArrayDType* arrp = VN_CAST(nodep, UnpackArrayDType)) { ifacerefp = VN_CAST(arrp->subDTypep(), IfaceRefDType); @@ -441,9 +441,9 @@ public: } void computeIfaceVarSyms() { for (VSymEnt* varSymp : m_ifaceVarSyms) { - AstVar* varp = varSymp ? VN_AS(varSymp->nodep(), Var) : nullptr; + AstVar* const varp = varSymp ? VN_AS(varSymp->nodep(), Var) : nullptr; UINFO(9, " insAllIface se" << cvtToHex(varSymp) << " " << varp << endl); - AstIfaceRefDType* ifacerefp = ifaceRefFromArray(varp->subDTypep()); + AstIfaceRefDType* const ifacerefp = ifaceRefFromArray(varp->subDTypep()); UASSERT_OBJ(ifacerefp, varp, "Non-ifacerefs on list!"); if (!ifacerefp->ifaceViaCellp()) { if (!ifacerefp->cellp()) { // Probably a NotFoundModule, or a normal module if @@ -461,14 +461,14 @@ public: << AstNode::prettyNameQ(ifacerefp->ifaceName())); continue; } - VSymEnt* ifaceSymp = getNodeSym(ifacerefp->ifaceViaCellp()); + VSymEnt* const ifaceSymp = getNodeSym(ifacerefp->ifaceViaCellp()); VSymEnt* ifOrPortSymp = ifaceSymp; // Link Modport names to the Modport Node under the Interface if (ifacerefp->isModport()) { - VSymEnt* foundp = ifaceSymp->findIdFallback(ifacerefp->modportName()); + VSymEnt* const foundp = ifaceSymp->findIdFallback(ifacerefp->modportName()); bool ok = false; if (foundp) { - if (AstModport* modportp = VN_CAST(foundp->nodep(), Modport)) { + if (AstModport* const modportp = VN_CAST(foundp->nodep(), Modport)) { UINFO(4, "Link Modport: " << modportp << endl); ifacerefp->modportp(modportp); ifOrPortSymp = foundp; @@ -506,7 +506,7 @@ public: for (int samn = 0; samn < SAMN__MAX; ++samn) { for (ScopeAliasMap::iterator it = m_scopeAliasMap[samn].begin(); it != m_scopeAliasMap[samn].end(); ++it) { - VSymEnt* lhsp = it->first; + VSymEnt* const lhsp = it->first; VSymEnt* srcp = lhsp; while (true) { // Follow chain of aliases up to highest level non-alias const auto it2 = m_scopeAliasMap[samn].find(srcp); @@ -582,7 +582,7 @@ public: : nullptr; // Replicated below AstCellInline* inlinep = lookupSymp ? VN_CAST(lookupSymp->nodep(), CellInline) : nullptr; // Replicated below - if (VSymEnt* findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) { + if (VSymEnt* const findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) { lookupSymp = findSymp; } // Check this module - cur modname @@ -629,15 +629,15 @@ public: if (!lookupSymp) return nullptr; // Not found } } else { // Searching for middle submodule, must be a cell name - if (VSymEnt* findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) { + if (VSymEnt* const findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) { lookupSymp = findSymp; } else { return nullptr; // Not found } } if (lookupSymp) { - if (AstCell* cellp = VN_CAST(lookupSymp->nodep(), Cell)) { - if (AstNodeModule* modp = cellp->modp()) { + if (AstCell* const cellp = VN_CAST(lookupSymp->nodep(), Cell)) { + if (AstNodeModule* const modp = cellp->modp()) { if (modp->hierBlock()) { refLocationp->v3error("Cannot access inside hierarchical block"); } else if (VN_IS(modp, NotFoundModule)) { @@ -708,7 +708,7 @@ LinkDotState* LinkDotState::s_errorThisp = nullptr; class LinkDotFindVisitor final : public AstNVisitor { // STATE - LinkDotState* m_statep; // State to pass between visitors, including symbol table + LinkDotState* const m_statep; // State to pass between visitors, including symbol table AstNodeModule* m_classOrPackagep = nullptr; // Current package VSymEnt* m_modSymp = nullptr; // Symbol Entry for current module VSymEnt* m_curSymp = nullptr; // Symbol Entry for current table, where to lookup/insert @@ -725,7 +725,7 @@ class LinkDotFindVisitor final : public AstNVisitor { static int debug() { return LinkDotState::debug(); } void makeImplicitNew(AstClass* nodep) { - AstFunc* newp = new AstFunc(nodep->fileline(), "new", nullptr, nullptr); + AstFunc* const newp = new AstFunc(nodep->fileline(), "new", nullptr, nullptr); newp->isConstructor(true); nodep->addMembersp(newp); UINFO(8, "Made implicit new for " << nodep->name() << ": " << nodep << endl); @@ -793,8 +793,8 @@ class LinkDotFindVisitor final : public AstNVisitor { } else if (doit) { UINFO(4, " Link Module: " << nodep << endl); UASSERT_OBJ(!nodep->dead(), nodep, "Module in instance tree mislabeled as dead?"); - VSymEnt* upperSymp = m_curSymp ? m_curSymp : m_statep->rootEntp(); - AstPackage* pkgp = VN_CAST(nodep, Package); + VSymEnt* const upperSymp = m_curSymp ? m_curSymp : m_statep->rootEntp(); + AstPackage* const pkgp = VN_CAST(nodep, Package); m_classOrPackagep = pkgp; if (standalonePkg) { if (pkgp->isDollarUnit()) { @@ -818,13 +818,13 @@ class LinkDotFindVisitor final : public AstNVisitor { nodep->user2(false); nodep->user4(true); // Interfaces need another pass when signals are resolved - if (AstIface* ifacep = VN_CAST(nodep, Iface)) { + if (AstIface* const ifacep = VN_CAST(nodep, Iface)) { m_statep->insertIfaceModSym(ifacep, m_curSymp); } } else if (isHierBlockWrapper(nodep->name())) { UINFO(5, "Module is hierarchical block, must not be dead: " << nodep << endl); m_scope = nodep->name(); - VSymEnt* upperSymp = m_curSymp ? m_curSymp : m_statep->rootEntp(); + VSymEnt* const upperSymp = m_curSymp ? m_curSymp : m_statep->rootEntp(); m_curSymp = m_modSymp = m_statep->insertBlock(upperSymp, nodep->name() + "::", nodep, m_classOrPackagep); iterateChildren(nodep); @@ -847,7 +847,7 @@ class LinkDotFindVisitor final : public AstNVisitor { VL_RESTORER(m_modWithNum); { UINFO(4, " Link Class: " << nodep << endl); - VSymEnt* upperSymp = m_curSymp; + VSymEnt* const upperSymp = m_curSymp; m_scope = m_scope + "." + nodep->name(); m_classOrPackagep = nodep; m_curSymp = m_modSymp @@ -1180,8 +1180,8 @@ class LinkDotFindVisitor final : public AstNVisitor { m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_classOrPackagep); if (m_statep->forPrimary() && nodep->isGParam()) { ++m_paramNum; - VSymEnt* symp = m_statep->insertSym(m_curSymp, "__paramNumber" + cvtToStr(m_paramNum), - nodep, m_classOrPackagep); + VSymEnt* const symp = m_statep->insertSym( + m_curSymp, "__paramNumber" + cvtToStr(m_paramNum), nodep, m_classOrPackagep); symp->exported(false); } } diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index 248e47902..1480dc3dc 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -74,7 +74,7 @@ private: } else if (m_insMode == IM_AFTER) { m_insStmtp->addNextHere(newp); } else if (m_insMode == IM_WHILE_PRECOND) { - AstWhile* whilep = VN_AS(m_insStmtp, While); + AstWhile* const whilep = VN_AS(m_insStmtp, While); UASSERT_OBJ(whilep, nodep, "Insert should be under WHILE"); whilep->addPrecondsp(newp); } else { @@ -151,12 +151,12 @@ private: void prepost_non_stmt_visit(AstNodeTriop* nodep) { iterateChildren(nodep); - AstConst* constp = VN_AS(nodep->lhsp(), Const); + AstConst* const constp = VN_AS(nodep->lhsp(), Const); UASSERT_OBJ(nodep, constp, "Expecting CONST"); - AstConst* newconstp = constp->cloneTree(true); + AstConst* const newconstp = constp->cloneTree(true); - AstNode* storetop = nodep->thsp(); - AstNode* valuep = nodep->rhsp(); + AstNode* const storetop = nodep->thsp(); + AstNode* const valuep = nodep->rhsp(); storetop->unlinkFrBack(); valuep->unlinkFrBack(); @@ -175,22 +175,22 @@ private: void prepost_stmt_visit(AstNodeTriop* nodep) { iterateChildren(nodep); - AstNodeVarRef* varrefp = nullptr; + const AstNodeVarRef* varrefp = nullptr; if (m_unsupportedHere || !(varrefp = VN_CAST(nodep->rhsp(), VarRef))) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Incrementation in this context."); return; } - AstConst* constp = VN_AS(nodep->lhsp(), Const); + AstConst* const constp = VN_AS(nodep->lhsp(), Const); UASSERT_OBJ(nodep, constp, "Expecting CONST"); - AstNode* backp = nodep->backp(); - AstConst* newconstp = constp->cloneTree(true); + const AstNode* const backp = nodep->backp(); + AstConst* const newconstp = constp->cloneTree(true); // Prepare a temporary variable - FileLine* fl = backp->fileline(); + FileLine* const fl = backp->fileline(); const string name = string("__Vincrement") + cvtToStr(++m_modIncrementsNum); - AstVar* varp = new AstVar(fl, AstVarType::BLOCKTEMP, name, VFlagChildDType(), - varrefp->varp()->subDTypep()->cloneTree(true)); + AstVar* const varp = new AstVar(fl, AstVarType::BLOCKTEMP, name, VFlagChildDType(), + varrefp->varp()->subDTypep()->cloneTree(true)); // Declare the variable insertBeforeStmt(nodep, varp); diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index 46e60a544..20bacaf38 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -89,8 +89,8 @@ private: if (VN_IS(underp, JumpLabel)) { return VN_AS(underp, JumpLabel); } else { // Move underp stuff to be under a new label - AstJumpBlock* blockp = new AstJumpBlock(nodep->fileline(), nullptr); - AstJumpLabel* labelp = new AstJumpLabel(nodep->fileline(), blockp); + AstJumpBlock* const blockp = new AstJumpBlock(nodep->fileline(), nullptr); + AstJumpLabel* const labelp = new AstJumpLabel(nodep->fileline(), blockp); blockp->labelp(labelp); AstNRelinker repHandle; @@ -143,23 +143,23 @@ private: // So later optimizations don't need to deal with them, // REPEAT(count,body) -> loop=count,WHILE(loop>0) { body, loop-- } // Note var can be signed or unsigned based on original number. - AstNode* countp = nodep->countp()->unlinkFrBackWithNext(); + AstNode* const countp = nodep->countp()->unlinkFrBackWithNext(); const string name = string("__Vrepeat") + cvtToStr(m_modRepeatNum++); // Spec says value is integral, if negative is ignored - AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name, - nodep->findSigned32DType()); + AstVar* const varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name, + nodep->findSigned32DType()); varp->usedLoopIdx(true); m_modp->addStmtp(varp); AstNode* initsp = new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), varp, VAccess::WRITE), countp); - AstNode* decp = new AstAssign( + AstNode* const decp = new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), varp, VAccess::WRITE), new AstSub(nodep->fileline(), new AstVarRef(nodep->fileline(), varp, VAccess::READ), new AstConst(nodep->fileline(), 1))); - AstNode* zerosp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); - AstNode* condp = new AstGtS(nodep->fileline(), - new AstVarRef(nodep->fileline(), varp, VAccess::READ), zerosp); - AstNode* bodysp = nodep->bodysp(); + AstNode* const zerosp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); + AstNode* const condp = new AstGtS( + nodep->fileline(), new AstVarRef(nodep->fileline(), varp, VAccess::READ), zerosp); + AstNode* const bodysp = nodep->bodysp(); if (bodysp) bodysp->unlinkFrBackWithNext(); AstNode* newp = new AstWhile(nodep->fileline(), condp, bodysp, decp); initsp = initsp->addNext(newp); @@ -170,7 +170,7 @@ private: virtual void visit(AstWait* nodep) override { nodep->v3warn(E_UNSUPPORTED, "Unsupported: wait statements"); // Statements we'll just execute immediately; equivalent to if they followed this - if (AstNode* bodysp = nodep->bodysp()) { + if (AstNode* const bodysp = nodep->bodysp()) { bodysp->unlinkFrBackWithNext(); nodep->replaceWith(bodysp); } else { @@ -194,7 +194,7 @@ private: } virtual void visit(AstReturn* nodep) override { iterateChildren(nodep); - AstFunc* funcp = VN_CAST(m_ftaskp, Func); + const AstFunc* const funcp = VN_CAST(m_ftaskp, Func); if (m_inFork) { nodep->v3error("Return isn't legal under fork (IEEE 1800-2017 9.2.3)"); VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep); @@ -214,7 +214,7 @@ private: nodep->lhsp()->unlinkFrBackWithNext())); } // Jump to the end of the function call - AstJumpLabel* labelp = findAddLabel(m_ftaskp, false); + AstJumpLabel* const labelp = findAddLabel(m_ftaskp, false); nodep->addPrev(new AstJumpGo(nodep->fileline(), labelp)); } nodep->unlinkFrBack(); @@ -226,7 +226,7 @@ private: nodep->v3error("break isn't underneath a loop"); } else { // Jump to the end of the loop - AstJumpLabel* labelp = findAddLabel(m_loopp, false); + AstJumpLabel* const labelp = findAddLabel(m_loopp, false); nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp)); } nodep->unlinkFrBack(); @@ -239,7 +239,7 @@ private: } else { // Jump to the end of this iteration // If a "for" loop then need to still do the post-loop increment - AstJumpLabel* labelp = findAddLabel(m_loopp, true); + AstJumpLabel* const labelp = findAddLabel(m_loopp, true); nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp)); } nodep->unlinkFrBack(); @@ -261,7 +261,7 @@ private: nodep->v3error("disable isn't underneath a begin with name: " << nodep->prettyNameQ()); } else if (AstBegin* beginp = VN_CAST(blockp, Begin)) { // Jump to the end of the named block - AstJumpLabel* labelp = findAddLabel(beginp, false); + AstJumpLabel* const labelp = findAddLabel(beginp, false); nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp)); } else { nodep->v3warn(E_UNSUPPORTED, "Unsupported: disable fork"); diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index 9d9fadace..29b3bf5cd 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -262,11 +262,11 @@ private: } virtual void visit(AstNodeFTaskRef* nodep) override { AstNode* pinp = nodep->pinsp(); - AstNodeFTask* taskp = nodep->taskp(); + const AstNodeFTask* const taskp = nodep->taskp(); // We'll deal with mismatching pins later if (!taskp) return; for (AstNode* stmtp = taskp->stmtsp(); stmtp && pinp; stmtp = stmtp->nextp()) { - if (const AstVar* portp = VN_CAST(stmtp, Var)) { + if (const AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO()) { if (portp->isWritable()) { m_setRefLvalue = VAccess::WRITE; diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index 3d8a9a266..9868b04f4 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -54,7 +54,7 @@ void V3LinkLevel::modSortByLevel() { mods.push_back(nodep); } if (tops.size() >= 2) { - AstNode* secp = tops[1]; // Complain about second one, as first often intended + const AstNode* const secp = tops[1]; // Complain about second one, as first often intended if (!secp->fileline()->warnIsOff(V3ErrorCode::MULTITOP)) { secp->v3warn(MULTITOP, "Multiple top level modules\n" << secp->warnMore() @@ -86,7 +86,7 @@ void V3LinkLevel::modSortByLevel() { void V3LinkLevel::timescaling(const ModVec& mods) { // Timescale determination - AstNodeModule* modTimedp = nullptr; + const AstNodeModule* modTimedp = nullptr; VTimescale unit(VTimescale::NONE); // Use highest level module as default unit - already sorted in proper order for (const auto& modp : mods) { diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index be349ee45..c9b0e0113 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -80,7 +80,7 @@ private: string nameFromTypedef(AstNode* nodep) { // Try to find a name for a typedef'ed enum/struct - if (AstTypedef* typedefp = VN_CAST(nodep->backp(), Typedef)) { + if (const AstTypedef* const typedefp = VN_CAST(nodep->backp(), Typedef)) { // Create a name for the enum, to aid debug and tracing // This name is not guaranteed to be globally unique (due to later parameterization) string above; @@ -112,7 +112,7 @@ private: // -> 1:3: BEGIN [GEN] [IMPLIED] // nodep passed to this function // 1:3:1: GENIF // 1:3:1:2: BEGIN genblk1 [GEN] [IMPLIED] - AstNode* const backp = nodep->backp(); + const AstNode* const backp = nodep->backp(); return (nodep->implied() // User didn't provide begin/end && VN_IS(backp, GenIf) && VN_CAST(backp, GenIf)->elsesp() == nodep && !nodep->nextp() // No other statements under upper genif else @@ -554,7 +554,7 @@ private: virtual void visit(AstBegin* nodep) override { V3Config::applyCoverageBlock(m_modp, nodep); cleanFileline(nodep); - AstNode* const backp = nodep->backp(); + const AstNode* const backp = nodep->backp(); // IEEE says directly nested item is not a new block // The genblk name will get attached to the if true/false LOWER begin block(s) const bool nestedIf = nestedIfBegin(nodep); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index d5582a101..2273bc8ed 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -152,12 +152,12 @@ private: // If it's not a simple variable wrap in a temporary // This is a bit unfortunate as we haven't done width resolution // and any width errors will look a bit odd, but it works. - AstNode* sensp = nodep->sensp(); + AstNode* const sensp = nodep->sensp(); if (sensp && !VN_IS(sensp, NodeVarRef) && !VN_IS(sensp, Const)) { // Make a new temp wire const string newvarname = "__Vsenitemexpr" + cvtToStr(++m_senitemCvtNum); - AstVar* newvarp = new AstVar(sensp->fileline(), AstVarType::MODULETEMP, newvarname, - VFlagLogicPacked(), 1); + AstVar* const newvarp = new AstVar(sensp->fileline(), AstVarType::MODULETEMP, + newvarname, VFlagLogicPacked(), 1); // We can't just add under the module, because we may be // inside a generate, begin, etc. // We know a SenItem should be under a SenTree/Always etc, @@ -175,7 +175,7 @@ private: addwherep->addNext(newvarp); sensp->replaceWith(new AstVarRef(sensp->fileline(), newvarp, VAccess::READ)); - AstAssignW* assignp = new AstAssignW( + AstAssignW* const assignp = new AstAssignW( sensp->fileline(), new AstVarRef(sensp->fileline(), newvarp, VAccess::WRITE), sensp); addwherep->addNext(assignp); @@ -184,21 +184,21 @@ private: bool did = true; while (did) { did = false; - if (AstNodeSel* selp = VN_CAST(nodep->sensp(), NodeSel)) { - AstNode* fromp = selp->fromp()->unlinkFrBack(); + if (AstNodeSel* const selp = VN_CAST(nodep->sensp(), NodeSel)) { + AstNode* const fromp = selp->fromp()->unlinkFrBack(); selp->replaceWith(fromp); VL_DO_DANGLING(selp->deleteTree(), selp); did = true; } // NodeSel doesn't include AstSel.... - if (AstSel* selp = VN_CAST(nodep->sensp(), Sel)) { - AstNode* fromp = selp->fromp()->unlinkFrBack(); + if (AstSel* const selp = VN_CAST(nodep->sensp(), Sel)) { + AstNode* const fromp = selp->fromp()->unlinkFrBack(); selp->replaceWith(fromp); VL_DO_DANGLING(selp->deleteTree(), selp); did = true; } - if (AstNodePreSel* selp = VN_CAST(nodep->sensp(), NodePreSel)) { - AstNode* fromp = selp->fromp()->unlinkFrBack(); + if (AstNodePreSel* const selp = VN_CAST(nodep->sensp(), NodePreSel)) { + AstNode* const fromp = selp->fromp()->unlinkFrBack(); selp->replaceWith(fromp); VL_DO_DANGLING(selp->deleteTree(), selp); did = true; @@ -220,8 +220,8 @@ private: // variable we're extracting from (to determine MSB/LSB/endianness/etc.) // So we replicate it in another node // Note that V3Param knows not to replace AstVarRef's under AstAttrOf's - AstNode* basefromp = AstArraySel::baseFromp(nodep, false); - if (AstNodeVarRef* varrefp + AstNode* const basefromp = AstArraySel::baseFromp(nodep, false); + if (AstNodeVarRef* const varrefp = VN_CAST(basefromp, NodeVarRef)) { // Maybe varxref - so need to clone nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::VAR_BASE, varrefp->cloneTree(false))); @@ -254,7 +254,7 @@ private: iterateChildren(nodep); if (!nodep->user2() && nodep->isDefault() && nodep->nextp()) { nodep->user2(true); - AstNode* nextp = nodep->nextp(); + AstNode* const nextp = nodep->nextp(); nodep->unlinkFrBack(); nextp->addNext(nodep); } @@ -355,7 +355,7 @@ private: skipCount--; continue; } - AstConst* constp = VN_CAST(argp, Const); + const AstConst* const constp = VN_CAST(argp, Const); const bool isFromString = (constp) ? constp->num().isFromString() : false; if (isFromString) { const int numchars = argp->dtypep()->width() / 8; @@ -389,7 +389,7 @@ private: } } newFormat.append(str); - AstNode* nextp = argp->nextp(); + AstNode* const nextp = argp->nextp(); argp->unlinkFrBack(); VL_DO_DANGLING(pushDeletep(argp), argp); argp = nextp; @@ -450,7 +450,7 @@ private: "Non-format $sformatf should have \"\" format"); if (VN_IS(nodep->exprsp(), Const) && VN_AS(nodep->exprsp(), Const)->num().isFromString()) { - AstConst* fmtp = VN_AS(nodep->exprsp()->unlinkFrBack(), Const); + AstConst* const fmtp = VN_AS(nodep->exprsp()->unlinkFrBack(), Const); nodep->text(fmtp->num().toString()); VL_DO_DANGLING(pushDeletep(fmtp), fmtp); } @@ -472,9 +472,9 @@ private: // never used won't result in any warnings. } else { // Massive hack, just tie off all outputs so our analysis can proceed - AstVar* varoutp = nullptr; + const AstVar* varoutp = nullptr; for (AstNode* stmtp = m_modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isReadOnly()) { } else if (varp->isWritable()) { if (varoutp) { diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index deb1f301e..e9c048f28 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -135,7 +135,7 @@ private: if (m_nodeDepth == 0) { // Check if simple "VARREF = ..." assignment, i.e.: this assignment sets the whole // variable (and in particular, it is not assigned only in part). - if (AstVarRef* const refp = VN_CAST(nodep->lhsp(), VarRef)) { + if (const AstVarRef* const refp = VN_CAST(nodep->lhsp(), VarRef)) { // Mark this VarScope as assigned in this function refp->varScopep()->user2(1); } diff --git a/src/V3OptionParser.cpp b/src/V3OptionParser.cpp index f1db000af..c5eee01d2 100644 --- a/src/V3OptionParser.cpp +++ b/src/V3OptionParser.cpp @@ -65,7 +65,7 @@ struct V3OptionParser::Impl { #define V3OPTION_PARSER_DEF_ACT_CLASS(className, type, body, enType) \ template <> class V3OptionParser::Impl::className final : public ActionBase { \ - type* m_valp; /* Pointer to a option variable*/ \ + type* const m_valp; /* Pointer to a option variable*/ \ \ public: \ explicit className(type* valp) \ diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 6b4fc0207..d2bb5c34d 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -234,7 +234,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr const char* cp = textp; for (; isspace(*cp); ++cp) {} - const char* unitp = cp; + const char* const unitp = cp; for (; *cp && *cp != '/'; ++cp) {} string unitStr(unitp, cp - unitp); for (; isspace(*cp); ++cp) {} @@ -242,7 +242,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr if (*cp == '/') { ++cp; for (; isspace(*cp); ++cp) {} - const char* precp = cp; + const char* const precp = cp; for (; *cp && *cp != '/'; ++cp) {} precStr = string(precp, cp - precp); } @@ -442,7 +442,7 @@ void V3Options::fileNfsFlush(const string& filename) { // NFS caches stat() calls so to get up-to-date information must // do a open or opendir on the filename. // Faster to just try both rather than check if a file is a dir. - if (DIR* dirp = opendir(filename.c_str())) { // LCOV_EXCL_BR_LINE + if (DIR* const dirp = opendir(filename.c_str())) { // LCOV_EXCL_BR_LINE closedir(dirp); // LCOV_EXCL_LINE } else if (int fd = ::open(filename.c_str(), O_RDONLY)) { // LCOV_EXCL_BR_LINE if (fd > 0) ::close(fd); @@ -465,7 +465,7 @@ string V3Options::fileExists(const string& filename) { std::set* setp = &(diriter->second); - if (DIR* dirp = opendir(dir.c_str())) { + if (DIR* const dirp = opendir(dir.c_str())) { while (struct dirent* direntp = readdir(dirp)) setp->insert(direntp->d_name); closedir(dirp); } @@ -710,7 +710,7 @@ bool V3Options::systemCFound() { // V3 Options notification methods void V3Options::notify() { - FileLine* cmdfl = new FileLine(FileLine::commandLineFilename()); + FileLine* const cmdfl = new FileLine(FileLine::commandLineFilename()); // Notify that all arguments have been passed and final modification can be made. if (!outFormatOk() && !cdc() && !dpiHdrOnly() && !lintOnly() && !preprocOnly() && !xmlOnly()) { diff --git a/src/V3Order.cpp b/src/V3Order.cpp index d4e4db5b4..05b7b52d6 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -130,8 +130,8 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) { const bool fromInitial = fromp->hasInitial() || fromp->hasSettle(); if (toInitial != fromInitial) return true; - const AstSenItem* fromSenListp = fromp->sensesp(); - const AstSenItem* toSenListp = top->sensesp(); + const AstSenItem* const fromSenListp = fromp->sensesp(); + const AstSenItem* const toSenListp = top->sensesp(); UASSERT_OBJ(fromSenListp, fromp, "sensitivity list empty"); UASSERT_OBJ(toSenListp, top, "sensitivity list empty"); @@ -139,8 +139,8 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) { if (fromSenListp->nextp()) return false; if (toSenListp->nextp()) return false; - const AstNodeVarRef* fromVarrefp = fromSenListp->varrefp(); - const AstNodeVarRef* toVarrefp = toSenListp->varrefp(); + const AstNodeVarRef* const fromVarrefp = fromSenListp->varrefp(); + const AstNodeVarRef* const toVarrefp = toSenListp->varrefp(); if (!fromVarrefp || !toVarrefp) return false; // We know nothing about the relationship between different clocks here, diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 9b6e6b428..d3b5e30b6 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -72,7 +72,7 @@ string V3Os::getenvStr(const string& envvar, const string& defaultValue) { #if defined(_MSC_VER) // Note: MinGW does not offer _dupenv_s - char* envvalue = nullptr; + const char* const envvalue = nullptr; _dupenv_s(&envvalue, nullptr, envvar.c_str()); if (envvalue != nullptr) { const std::string result{envvalue}; @@ -82,7 +82,7 @@ string V3Os::getenvStr(const string& envvar, const string& defaultValue) { return defaultValue; } #else - if (const char* envvalue = getenv(envvar.c_str())) { + if (const char* const envvalue = getenv(envvar.c_str())) { return envvalue; } else { return defaultValue; diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 7a63456a2..d9a192f69 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -142,7 +142,7 @@ public: if (!pinp->exprp()) continue; UASSERT_OBJ(!pinp->modPTypep(), pinp, "module with type parameter must not be a hierarchical block"); - if (AstVar* modvarp = pinp->modVarp()) { + if (const AstVar* modvarp = pinp->modVarp()) { AstConst* const constp = VN_AS(pinp->exprp(), Const); UASSERT_OBJ(constp, pinp, "parameter for a hierarchical block must have been constified"); diff --git a/src/V3ParseGrammar.cpp b/src/V3ParseGrammar.cpp index 4af73bab2..d26ade756 100644 --- a/src/V3ParseGrammar.cpp +++ b/src/V3ParseGrammar.cpp @@ -71,10 +71,10 @@ AstNode* V3ParseGrammar::argWrapList(AstNode* nodep) { // Convert list of expressions to list of arguments if (!nodep) return nullptr; AstNode* outp = nullptr; - AstBegin* tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", nodep); + AstBegin* const tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", nodep); while (nodep) { - AstNode* nextp = nodep->nextp(); - AstNode* exprp = nodep->unlinkFrBack(); + AstNode* const nextp = nodep->nextp(); + AstNode* const exprp = nodep->unlinkFrBack(); nodep = nextp; // addNext can handle nulls: outp = AstNode::addNext(outp, new AstArg(exprp->fileline(), "", exprp)); @@ -117,9 +117,9 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra if (nrangep) { // Maybe no range - return unmodified base type while (nrangep->nextp()) nrangep = VN_AS(nrangep->nextp(), NodeRange); while (nrangep) { - AstNodeRange* prevp = VN_AS(nrangep->backp(), NodeRange); + AstNodeRange* const prevp = VN_AS(nrangep->backp(), NodeRange); if (prevp) nrangep->unlinkFrBack(); - AstRange* rangep = VN_CAST(nrangep, Range); + AstRange* const rangep = VN_CAST(nrangep, Range); if (rangep && isPacked) { arrayp = new AstPackArrayDType(rangep->fileline(), VFlagChildDType(), arrayp, rangep); @@ -134,8 +134,8 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra } else if (VN_IS(nrangep, UnsizedRange)) { arrayp = new AstUnsizedArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp); } else if (VN_IS(nrangep, BracketRange)) { - AstBracketRange* arangep = VN_AS(nrangep, BracketRange); - AstNode* keyp = arangep->elementsp()->unlinkFrBack(); + const AstBracketRange* const arangep = VN_AS(nrangep, BracketRange); + AstNode* const keyp = arangep->elementsp()->unlinkFrBack(); arrayp = new AstBracketArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp, keyp); } else { @@ -182,9 +182,9 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name, // Split RANGE0-RANGE1-RANGE2 into // ARRAYDTYPE0(ARRAYDTYPE1(ARRAYDTYPE2(BASICTYPE3), RANGE), RANGE) - AstNodeDType* arrayDTypep = createArray(dtypep, arrayp, false); + AstNodeDType* const arrayDTypep = createArray(dtypep, arrayp, false); - AstVar* nodep = new AstVar(fileline, type, name, VFlagChildDType(), arrayDTypep); + AstVar* const nodep = new AstVar(fileline, type, name, VFlagChildDType(), arrayDTypep); nodep->addAttrsp(attrsp); nodep->ansi(m_pinAnsi); nodep->declTyped(m_varDeclTyped); @@ -203,7 +203,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name, } if (VN_IS(dtypep, ParseTypeDType)) { // Parser needs to know what is a type - AstNode* newp = new AstTypedefFwd(fileline, name); + AstNode* const newp = new AstTypedefFwd(fileline, name); nodep->addNext(newp); SYMP->reinsert(newp); } diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index f1c042aa8..22793e5ca 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -67,7 +67,7 @@ V3ParseImp::~V3ParseImp() { void V3ParseImp::lexPpline(const char* textp) { // Handle lexer `line directive - FileLine* prevFl = copyOrSameFileLine(); + FileLine* const prevFl = copyOrSameFileLine(); int enterExit; lexFileline()->lineDirective(textp, enterExit /*ref*/); if (enterExit == 1) { // Enter @@ -186,7 +186,7 @@ string V3ParseImp::lexParseTag(const char* textp) { double V3ParseImp::lexParseTimenum(const char* textp) { const size_t length = strlen(textp); - char* strgp = new char[length + 1]; + char* const strgp = new char[length + 1]; char* dp = strgp; const char* sp = textp; for (; isdigit(*sp) || *sp == '_' || *sp == '.'; ++sp) { @@ -281,7 +281,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i if (!ok) { if (errmsg != "") return; // Threw error already // Create fake node for later error reporting - AstNodeModule* nodep = new AstNotFoundModule(fileline, modname); + AstNodeModule* const nodep = new AstNotFoundModule(fileline, modname); v3Global.rootp()->addModulep(nodep); return; } @@ -488,7 +488,7 @@ void V3ParseImp::tokenPipelineSym() { int token = yylval.token; if (token == yaID__LEX || token == yaID__CC) { VSymEnt* foundp; - if (VSymEnt* look_underp = V3ParseImp::parsep()->symp()->nextId()) { + if (VSymEnt* const look_underp = V3ParseImp::parsep()->symp()->nextId()) { UINFO(7, " tokenPipelineSym: next id lookup forced under " << look_underp << endl); // if (debug() >= 7) V3ParseImp::parsep()->symp()->dump(cout, " -symtree: "); foundp = look_underp->findIdFallback(*(yylval.strp)); @@ -503,7 +503,7 @@ void V3ParseImp::tokenPipelineSym() { foundp = V3ParseImp::parsep()->symp()->symCurrentp()->findIdFallback(*(yylval.strp)); } if (foundp) { - AstNode* scp = foundp->nodep(); + AstNode* const scp = foundp->nodep(); yylval.scp = scp; UINFO(7, " tokenPipelineSym: Found " << scp << endl); if (token == yaID__LEX) { // i.e. not yaID__CC diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 9b6f5982e..34980026d 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -165,7 +165,7 @@ private: GraphWay m_way; // CPs oriented in this direction: either FORWARD // // from graph-start to current node, or REVERSE // // from graph-end to current node. - T_CostAccessor* m_accessp; // Access cost and CPs on V3GraphVertex's. + T_CostAccessor* const m_accessp; // Access cost and CPs on V3GraphVertex's. vluint64_t m_generation = 0; // Mark each vertex with this number; // // confirm we only process each vertex once. bool m_slowAsserts; // Enable nontrivial asserts diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index c3a43f880..bcfa9af8f 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -46,7 +46,7 @@ class VDefine final { // Define class. One for each define. // string m_name; // Name of the define (list is keyed by this) - FileLine* m_fileline; // Where it was declared + FileLine* const m_fileline; // Where it was declared string m_value; // Value of define string m_params; // Parameters bool m_cmdline; // Set on command line, don't `undefineall @@ -801,7 +801,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam } // Save file contents for future error reporting - FileLine* flsp = new FileLine(filename); + FileLine* const flsp = new FileLine(filename); flsp->lineno(1); flsp->newContent(); for (const string& i : wholefile) flsp->contentp()->pushText(i); @@ -818,8 +818,8 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam for (StrList::iterator it = wholefile.begin(); it != wholefile.end(); ++it) { // We don't end-loop at \0 as we allow and strip mid-string '\0's (for now). bool strip = false; - const char* sp = it->data(); - const char* ep = sp + it->length(); + const char* const sp = it->data(); + const char* const ep = sp + it->length(); // Only process if needed, as saves extra string allocations for (const char* cp = sp; cp < ep; cp++) { if (VL_UNLIKELY(*cp == '\r' || *cp == '\0')) { @@ -848,7 +848,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam // Warning check if (eof_newline) { - FileLine* fl = new FileLine{flsp}; + FileLine* const fl = new FileLine{flsp}; fl->contentLineno(eof_lineno); fl->column(eof_newline + 1, eof_newline + 1); fl->v3warn(EOFNEWLINE, "Missing newline at end of file (POSIX 3.206).\n" @@ -1180,7 +1180,7 @@ int V3PreProcImp::getStateToken() { if (VL_UNCOVERABLE(m_defRefs.empty())) { fatalSrc("Shouldn't be in DEFPAREN w/o active defref"); } - VDefineRef* refp = &(m_defRefs.top()); + VDefineRef* const refp = &(m_defRefs.top()); error(string("Expecting ( to begin argument list for define reference `") + refp->name() + "\n"); statePop(); @@ -1463,7 +1463,7 @@ int V3PreProcImp::getStateToken() { // Can't subst now, or // `define a x,y // foo(`a,`b) would break because a contains comma - VDefineRef* refp = &(m_defRefs.top()); + VDefineRef* const refp = &(m_defRefs.top()); refp->nextarg(refp->nextarg() + m_lexp->m_defValue + out); m_lexp->m_defValue = ""; } diff --git a/src/V3PreShell.cpp b/src/V3PreShell.cpp index 00671044b..ff50c8e0e 100644 --- a/src/V3PreShell.cpp +++ b/src/V3PreShell.cpp @@ -53,11 +53,11 @@ protected: // Create the implementation pointer if (env) {} if (!s_preprocp) { - FileLine* cmdfl = new FileLine(FileLine::commandLineFilename()); + FileLine* const cmdfl = new FileLine(FileLine::commandLineFilename()); s_preprocp = V3PreProc::createPreProc(cmdfl); s_preprocp->debug(debug()); // Default defines - FileLine* prefl = new FileLine(FileLine::builtInFilename()); + FileLine* const prefl = new FileLine(FileLine::builtInFilename()); s_preprocp->defineCmdLine(prefl, "VERILATOR", "1"); // LEAK_OK s_preprocp->defineCmdLine(prefl, "verilator", "1"); // LEAK_OK s_preprocp->defineCmdLine(prefl, "verilator3", "1"); // LEAK_OK @@ -104,7 +104,7 @@ protected: // from the V3LangCode to the various Lex BEGIN states. The language // of this source file is updated here, in case there have been any // intervening +ext+ options since it was first encountered. - FileLine* modfileline = new FileLine(modfilename); + FileLine* const modfileline = new FileLine(modfilename); modfileline->language(v3Global.opt.fileLanguage(modfilename)); V3Parse::ppPushText( parsep, (string("`begin_keywords \"") + modfileline->language().ascii() + "\"\n")); @@ -171,7 +171,7 @@ void V3PreShell::preprocInclude(FileLine* fl, const string& modname) { V3PreShellImp::s_preImp.preprocInclude(fl, modname); } void V3PreShell::defineCmdLine(const string& name, const string& value) { - FileLine* prefl = new FileLine(FileLine::commandLineFilename()); + FileLine* const prefl = new FileLine(FileLine::commandLineFilename()); V3PreShellImp::s_preprocp->defineCmdLine(prefl, name, value); } void V3PreShell::undef(const string& name) { V3PreShellImp::s_preprocp->undef(name); } diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index e1bae6365..cb44de52a 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -79,7 +79,7 @@ private: } else { UASSERT_OBJ(!m_foundTop, nodep, "Multiple root modules"); } - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); // Need to know the existence of clk before createSvFile() m_hasClk = checkIfClockExists(nodep); createSvFile(fl, nodep); @@ -126,7 +126,7 @@ private: void createSvFile(FileLine* fl, AstNodeModule* modp) { // Comments - AstTextBlock* txtp = new AstTextBlock(fl); + AstTextBlock* const txtp = new AstTextBlock(fl); addComment(txtp, fl, "Wrapper module for DPI protected library"); addComment(txtp, fl, "This module requires lib" + m_libName + ".a or lib" + m_libName @@ -288,7 +288,7 @@ private: void createCppFile(FileLine* fl) { // Comments - AstTextBlock* txtp = new AstTextBlock(fl); + AstTextBlock* const txtp = new AstTextBlock(fl); addComment(txtp, fl, "Wrapper functions for DPI protected library\n"); // Includes @@ -408,7 +408,7 @@ private: } void handleClock(AstVar* varp) { - FileLine* fl = varp->fileline(); + FileLine* const fl = varp->fileline(); handleInput(varp); m_seqPortsp->addNodep(varp->cloneTree(false)); if (m_hasClk) { @@ -420,7 +420,7 @@ private: } void handleDataInput(AstVar* varp) { - FileLine* fl = varp->fileline(); + FileLine* const fl = varp->fileline(); handleInput(varp); m_comboPortsp->addNodep(varp->cloneTree(false)); m_comboParamsp->addText(fl, varp->name() + "\n"); @@ -434,13 +434,13 @@ private: void handleInput(AstVar* varp) { m_modPortsp->addNodep(varp->cloneTree(false)); } static void addLocalVariable(AstTextBlock* textp, AstVar* varp, const char* suffix) { - AstVar* newVarp + AstVar* const newVarp = new AstVar(varp->fileline(), AstVarType::VAR, varp->name() + suffix, varp->dtypep()); textp->addNodep(newVarp); } void handleOutput(AstVar* varp) { - FileLine* fl = varp->fileline(); + FileLine* const fl = varp->fileline(); m_modPortsp->addNodep(varp->cloneTree(false)); m_comboPortsp->addNodep(varp->cloneTree(false)); m_comboParamsp->addText(fl, varp->name() + "_combo__V\n"); @@ -471,7 +471,7 @@ private: static bool checkIfClockExists(AstNodeModule* modp) { for (AstNode* stmtp = modp->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* varp = VN_CAST(stmtp, Var)) { + if (const AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->direction() == VDirection::INPUT && (varp->isUsedClock() || varp->attrClocker() == VVarAttrClocker::CLOCKER_YES)) { diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index c14ed2364..7eb5c4750 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -53,8 +53,8 @@ private: for (auto* memberp = classp->stmtsp(); memberp; memberp = memberp->nextp()) { // If member is rand and of class type, mark its class if (VN_IS(memberp, Var) && VN_AS(memberp, Var)->isRand()) { - if (auto* classRefp = VN_CAST(memberp->dtypep(), ClassRefDType)) { - auto* rclassp = classRefp->classp(); + if (const auto* const classRefp = VN_CAST(memberp->dtypep(), ClassRefDType)) { + auto* const rclassp = classRefp->classp(); markMembers(rclassp); markDerived(rclassp); rclassp->user1(true); @@ -84,15 +84,16 @@ private: iterateChildren(nodep); if (nodep->extendsp()) { // Save pointer to derived class - auto* basep = nodep->extendsp()->classp(); + auto* const basep = nodep->extendsp()->classp(); m_baseToDerivedMap[basep].insert(nodep); } } virtual void visit(AstMethodCall* nodep) override { iterateChildren(nodep); if (nodep->name() != "randomize") return; - if (AstClassRefDType* classRefp = VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) { - auto* classp = classRefp->classp(); + if (const AstClassRefDType* const classRefp + = VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) { + auto* const classp = classRefp->classp(); classp->user1(true); markMembers(classp); } @@ -129,13 +130,14 @@ private: AstVar* enumValueTabp(AstEnumDType* nodep) { if (nodep->user2p()) return VN_AS(nodep->user2p(), Var); UINFO(9, "Construct Venumvaltab " << nodep << endl); - AstNodeArrayDType* vardtypep + AstNodeArrayDType* const vardtypep = new AstUnpackArrayDType(nodep->fileline(), nodep->dtypep(), new AstRange(nodep->fileline(), nodep->itemCount(), 0)); - AstInitArray* initp = new AstInitArray(nodep->fileline(), vardtypep, nullptr); + AstInitArray* const initp = new AstInitArray(nodep->fileline(), vardtypep, nullptr); v3Global.rootp()->typeTablep()->addTypesp(vardtypep); - AstVar* varp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, - "__Venumvaltab_" + cvtToStr(m_enumValueTabCount++), vardtypep); + AstVar* const varp + = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, + "__Venumvaltab_" + cvtToStr(m_enumValueTabCount++), vardtypep); varp->isConst(true); varp->isStatic(true); varp->valuep(initp); @@ -144,7 +146,7 @@ private: UASSERT_OBJ(nodep->itemsp(), nodep, "Enum without items"); for (AstEnumItem* itemp = nodep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), EnumItem)) { - AstConst* vconstp = VN_AS(itemp->valuep(), Const); + AstConst* const vconstp = VN_AS(itemp->valuep(), Const); UASSERT_OBJ(vconstp, nodep, "Enum item without constified value"); initp->addValuep(vconstp->cloneTree(false)); } @@ -153,15 +155,15 @@ private: } AstNodeStmt* newRandStmtsp(FileLine* fl, AstNodeVarRef* varrefp, int offset = 0, AstMemberDType* memberp = nullptr) { - if (auto* structDtp + if (const auto* const structDtp = VN_CAST(memberp ? memberp->subDTypep()->skipRefp() : varrefp->dtypep()->skipRefp(), StructDType)) { AstNodeStmt* stmtsp = nullptr; offset += memberp ? memberp->lsb() : 0; for (auto* smemberp = structDtp->membersp(); smemberp; smemberp = VN_AS(smemberp->nextp(), MemberDType)) { - auto* randp = newRandStmtsp(fl, stmtsp ? varrefp->cloneTree(false) : varrefp, - offset, smemberp); + auto* const randp = newRandStmtsp(fl, stmtsp ? varrefp->cloneTree(false) : varrefp, + offset, smemberp); if (stmtsp) { stmtsp->addNext(randp); } else { @@ -171,13 +173,15 @@ private: return stmtsp; } else { AstNodeMath* valp; - if (auto* enumDtp = VN_CAST(memberp ? memberp->subDTypep()->subDTypep() - : varrefp->dtypep()->subDTypep(), - EnumDType)) { - AstVarRef* tabRefp = new AstVarRef(fl, enumValueTabp(enumDtp), VAccess::READ); + if (auto* const enumDtp = VN_CAST(memberp ? memberp->subDTypep()->subDTypep() + : varrefp->dtypep()->subDTypep(), + EnumDType)) { + AstVarRef* const tabRefp + = new AstVarRef(fl, enumValueTabp(enumDtp), VAccess::READ); tabRefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); - auto* randp = new AstRand(fl, nullptr, false); - auto* moddivp = new AstModDiv(fl, randp, new AstConst(fl, enumDtp->itemCount())); + auto* const randp = new AstRand(fl, nullptr, false); + auto* const moddivp + = new AstModDiv(fl, randp, new AstConst(fl, enumDtp->itemCount())); randp->dtypep(varrefp->findBasicDType(AstBasicDTypeKwd::UINT32)); moddivp->dtypep(enumDtp); valp = new AstArraySel(fl, tabRefp, moddivp); @@ -197,25 +201,28 @@ private: iterateChildren(nodep); if (!nodep->user1()) return; // Doesn't need randomize, or already processed UINFO(9, "Define randomize() for " << nodep << endl); - auto* funcp = V3Randomize::newRandomizeFunc(nodep); - auto* fvarp = VN_AS(funcp->fvarp(), Var); + auto* const funcp = V3Randomize::newRandomizeFunc(nodep); + auto* const fvarp = VN_AS(funcp->fvarp(), Var); funcp->addStmtsp(new AstAssign( nodep->fileline(), new AstVarRef(nodep->fileline(), fvarp, VAccess::WRITE), new AstConst(nodep->fileline(), AstConst::WidthedValue(), 32, 1))); for (auto* classp = nodep; classp; classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr) { for (auto* memberp = classp->stmtsp(); memberp; memberp = memberp->nextp()) { - auto* memberVarp = VN_CAST(memberp, Var); + auto* const memberVarp = VN_CAST(memberp, Var); if (!memberVarp || !memberVarp->isRand()) continue; - auto* dtypep = memberp->dtypep()->skipRefp(); + const auto* const dtypep = memberp->dtypep()->skipRefp(); if (VN_IS(dtypep, BasicDType) || VN_IS(dtypep, StructDType)) { - auto* refp = new AstVarRef(nodep->fileline(), memberVarp, VAccess::WRITE); - auto* stmtp = newRandStmtsp(nodep->fileline(), refp); + auto* const refp + = new AstVarRef(nodep->fileline(), memberVarp, VAccess::WRITE); + auto* const stmtp = newRandStmtsp(nodep->fileline(), refp); funcp->addStmtsp(stmtp); } else if (auto* classRefp = VN_CAST(dtypep, ClassRefDType)) { - auto* refp = new AstVarRef(nodep->fileline(), memberVarp, VAccess::WRITE); - auto* memberFuncp = V3Randomize::newRandomizeFunc(classRefp->classp()); - auto* callp = new AstMethodCall(nodep->fileline(), refp, "randomize", nullptr); + auto* const refp + = new AstVarRef(nodep->fileline(), memberVarp, VAccess::WRITE); + auto* const memberFuncp = V3Randomize::newRandomizeFunc(classRefp->classp()); + auto* const callp + = new AstMethodCall(nodep->fileline(), refp, "randomize", nullptr); callp->taskp(memberFuncp); callp->dtypeFrom(memberFuncp); funcp->addStmtsp(new AstAssign( @@ -255,9 +262,9 @@ void V3Randomize::randomizeNetlist(AstNetlist* nodep) { AstFunc* V3Randomize::newRandomizeFunc(AstClass* nodep) { auto* funcp = VN_AS(nodep->findMember("randomize"), Func); if (!funcp) { - auto* dtypep + auto* const dtypep = nodep->findBitDType(32, 32, VSigning::SIGNED); // IEEE says int return of 0/1 - auto* fvarp = new AstVar(nodep->fileline(), AstVarType::MEMBER, "randomize", dtypep); + auto* const fvarp = new AstVar(nodep->fileline(), AstVarType::MEMBER, "randomize", dtypep); fvarp->lifetime(VLifetime::AUTOMATIC); fvarp->funcLocal(true); fvarp->funcReturn(true); diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 219e203ca..0a923615c 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -168,7 +168,7 @@ private: return; } // Of a constant index - AstConst* const lbitp = VN_CAST(lselp->bitp(), Const); + const AstConst* const lbitp = VN_CAST(lselp->bitp(), Const); if (!lbitp) { mergeEnd(); return; @@ -192,7 +192,7 @@ private: uint32_t rindex = lindex; if (rconstp) { // Ok } else if (rselp) { - AstConst* const rbitp = VN_CAST(rselp->bitp(), Const); + const AstConst* const rbitp = VN_CAST(rselp->bitp(), Const); rvarrefp = VN_CAST(rselp->fromp(), NodeVarRef); if (!rbitp || !rvarrefp || lvarrefp->varp() == rvarrefp->varp()) { mergeEnd(); diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index d9b73b4de..3d9d37fc1 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -65,7 +65,7 @@ private: void cleanupVarRefs() { for (const auto& itr : m_varRefScopes) { - AstVarRef* nodep = itr.first; + AstVarRef* const nodep = itr.first; AstScope* scopep = itr.second; if (nodep->classOrPackagep()) { const auto it2 = m_packageScopes.find(nodep->classOrPackagep()); @@ -74,14 +74,14 @@ private: } const auto it3 = m_varScopes.find(std::make_pair(nodep->varp(), scopep)); UASSERT_OBJ(it3 != m_varScopes.end(), nodep, "Can't locate varref scope"); - AstVarScope* varscp = it3->second; + AstVarScope* const varscp = it3->second; nodep->varScopep(varscp); } } // VISITORS virtual void visit(AstNetlist* nodep) override { - AstNodeModule* modp = nodep->topModulep(); + AstNodeModule* const modp = nodep->topModulep(); if (!modp) { nodep->v3error("No top level module found"); return; @@ -112,7 +112,7 @@ private: // Now for each child cell, iterate the module this cell points to for (AstNode* cellnextp = nodep->stmtsp(); cellnextp; cellnextp = cellnextp->nextp()) { - if (AstCell* cellp = VN_CAST(cellnextp, Cell)) { + if (AstCell* const cellp = VN_CAST(cellnextp, Cell)) { VL_RESTORER(m_scopep); // Protects m_scopep set in called module // which is "above" in this code, but later in code execution order VL_RESTORER(m_aboveCellp); @@ -120,7 +120,7 @@ private: { m_aboveCellp = cellp; m_aboveScopep = m_scopep; - AstNodeModule* modp = cellp->modp(); + AstNodeModule* const modp = cellp->modp(); UASSERT_OBJ(modp, cellp, "Unlinked mod"); iterate(modp); // Recursive call to visit(AstNodeModule) } @@ -163,8 +163,8 @@ private: UINFO(4, " CLASS AT " << scopename << " " << nodep << endl); AstNode::user1ClearTree(); - AstNode* abovep = (m_aboveCellp ? static_cast(m_aboveCellp) - : static_cast(nodep)); + const AstNode* const abovep = (m_aboveCellp ? static_cast(m_aboveCellp) + : static_cast(nodep)); m_scopep = new AstScope(abovep->fileline(), m_modp, scopename, m_aboveScopep, m_aboveCellp); m_packageScopes.emplace(nodep, m_scopep); @@ -185,7 +185,7 @@ private: virtual void visit(AstNodeProcedure* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); - AstNode* clonep = nodep->cloneTree(false); + AstNode* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* @@ -193,7 +193,7 @@ private: virtual void visit(AstAssignAlias* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); - AstNode* clonep = nodep->cloneTree(false); + AstNode* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* @@ -201,7 +201,7 @@ private: virtual void visit(AstAssignVarScope* nodep) override { // Copy under the scope but don't recurse UINFO(4, " Move " << nodep << endl); - AstNode* clonep = nodep->cloneTree(false); + AstNode* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* @@ -209,7 +209,7 @@ private: virtual void visit(AstAssignW* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); - AstNode* clonep = nodep->cloneTree(false); + AstNode* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* @@ -217,7 +217,7 @@ private: virtual void visit(AstAlwaysPublic* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); - AstNode* clonep = nodep->cloneTree(false); + AstNode* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* @@ -225,7 +225,7 @@ private: virtual void visit(AstCoverToggle* nodep) override { // Add to list of blocks under this scope UINFO(4, " Move " << nodep << endl); - AstNode* clonep = nodep->cloneTree(false); + AstNode* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); iterateChildren(clonep); // We iterate under the *clone* @@ -233,7 +233,7 @@ private: virtual void visit(AstCFunc* nodep) override { // Add to list of blocks under this scope UINFO(4, " CFUNC " << nodep << endl); - AstCFunc* clonep = nodep->cloneTree(false); + AstCFunc* const clonep = nodep->cloneTree(false); nodep->user2p(clonep); m_scopep->addActivep(clonep); clonep->scopep(m_scopep); @@ -259,7 +259,7 @@ private: virtual void visit(AstVar* nodep) override { // Make new scope variable if (!nodep->user1p()) { - AstVarScope* varscp = new AstVarScope(nodep->fileline(), m_scopep, nodep); + AstVarScope* const varscp = new AstVarScope(nodep->fileline(), m_scopep, nodep); UINFO(6, " New scope " << varscp << endl); if (m_aboveCellp && !m_aboveCellp->isTrace()) varscp->trace(false); nodep->user1p(varscp); @@ -369,7 +369,7 @@ private: if (nodep->classOrPackagep()) { // Point to the clone UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked"); - AstNodeFTask* newp = VN_AS(nodep->taskp()->user2p(), NodeFTask); + AstNodeFTask* const newp = VN_AS(nodep->taskp()->user2p(), NodeFTask); UASSERT_OBJ(newp, nodep, "No clone for package function"); nodep->taskp(newp); UINFO(9, " New pkg-taskref " << nodep << endl); diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index 203f863fa..81887f2b0 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -61,7 +61,8 @@ class SliceVisitor final : public AstNVisitor { AstNode* cloneAndSel(AstNode* nodep, int elements, int offset) { // Insert an ArraySel, except for a few special cases - AstUnpackArrayDType* arrayp = VN_CAST(nodep->dtypep()->skipRefp(), UnpackArrayDType); + const AstUnpackArrayDType* const arrayp + = VN_CAST(nodep->dtypep()->skipRefp(), UnpackArrayDType); if (!arrayp) { // V3Width should have complained, but... if (!m_assignError) { nodep->v3error( @@ -84,7 +85,7 @@ class SliceVisitor final : public AstNVisitor { offset = 0; } AstNode* newp; - if (AstInitArray* initp = VN_CAST(nodep, InitArray)) { + if (const AstInitArray* const initp = VN_CAST(nodep, InitArray)) { UINFO(9, " cloneInitArray(" << elements << "," << offset << ") " << nodep << endl); const int leOffset = !arrayp->rangep()->littleEndian() ? arrayp->rangep()->elementsConst() - 1 - offset @@ -132,17 +133,17 @@ class SliceVisitor final : public AstNVisitor { nodep->user1(true); m_assignError = false; if (debug() >= 9) nodep->dumpTree(cout, " Deslice-In: "); - AstNodeDType* dtp = nodep->lhsp()->dtypep()->skipRefp(); - if (AstUnpackArrayDType* arrayp = VN_CAST(dtp, UnpackArrayDType)) { + AstNodeDType* const dtp = nodep->lhsp()->dtypep()->skipRefp(); + if (const AstUnpackArrayDType* const arrayp = VN_CAST(dtp, UnpackArrayDType)) { // Left and right could have different msb/lsbs/endianness, but #elements is common // and all variables are realigned to start at zero // Assign of a little endian'ed slice to a big endian one must reverse the elements AstNode* newlistp = nullptr; const int elements = arrayp->rangep()->elementsConst(); for (int offset = 0; offset < elements; ++offset) { - AstNode* newp = nodep->cloneType // AstNodeAssign - (cloneAndSel(nodep->lhsp(), elements, offset), - cloneAndSel(nodep->rhsp(), elements, offset)); + AstNode* const newp = nodep->cloneType // AstNodeAssign + (cloneAndSel(nodep->lhsp(), elements, offset), + cloneAndSel(nodep->rhsp(), elements, offset)); if (debug() >= 9) newp->dumpTree(cout, "-new "); newlistp = AstNode::addNextNull(newlistp, newp); } @@ -167,9 +168,9 @@ class SliceVisitor final : public AstNVisitor { if (!nodep->user1()) { nodep->user1(true); // If it's an unpacked array, blow it up into comparing each element - AstNodeDType* fromDtp = nodep->lhsp()->dtypep()->skipRefp(); + AstNodeDType* const fromDtp = nodep->lhsp()->dtypep()->skipRefp(); UINFO(9, " Bi-Eq/Neq expansion " << nodep << endl); - if (AstUnpackArrayDType* adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { + if (const AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { AstNodeBiop* logp = nullptr; if (!VN_IS(nodep->lhsp()->dtypep()->skipRefp(), NodeArrayDType)) { nodep->lhsp()->v3error( @@ -184,7 +185,7 @@ class SliceVisitor final : public AstNVisitor { } else { for (int index = 0; index < adtypep->rangep()->elementsConst(); ++index) { // EQ(a,b) -> LOGAND(EQ(ARRAYSEL(a,0), ARRAYSEL(b,0)), ...[1]) - AstNodeBiop* clonep + AstNodeBiop* const clonep = VN_AS(nodep->cloneType( new AstArraySel(nodep->fileline(), nodep->lhsp()->cloneTree(false), index), diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 551dfd25c..61e193653 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -96,7 +96,7 @@ // Support classes class SplitNodeVertex VL_NOT_FINAL : public V3GraphVertex { - AstNode* m_nodep; + AstNode* const m_nodep; protected: SplitNodeVertex(V3Graph* graphp, AstNode* nodep) @@ -169,13 +169,13 @@ public: void setIgnoreThisStep() { m_ignoreInStep = s_stepNum; } virtual bool followScoreboard() const = 0; static bool followScoreboard(const V3GraphEdge* edgep) { - const SplitEdge* oedgep = dynamic_cast(edgep); + const SplitEdge* const oedgep = dynamic_cast(edgep); if (!oedgep) v3fatalSrc("Following edge of non-SplitEdge type"); if (oedgep->ignoreThisStep()) return false; return oedgep->followScoreboard(); } static bool followCyclic(const V3GraphEdge* edgep) { - const SplitEdge* oedgep = dynamic_cast(edgep); + const SplitEdge* const oedgep = dynamic_cast(edgep); if (!oedgep) v3fatalSrc("Following edge of non-SplitEdge type"); return (!oedgep->ignoreThisStep()); } @@ -296,7 +296,7 @@ private: } void scoreboardPushStmt(AstNode* nodep) { // UINFO(9, " push " << nodep << endl); - SplitLogicVertex* vertexp = new SplitLogicVertex(&m_graph, nodep); + SplitLogicVertex* const vertexp = new SplitLogicVertex(&m_graph, nodep); m_stmtStackps.push_back(vertexp); UASSERT_OBJ(!nodep->user3p(), nodep, "user3p should not be used; cleared in processBlock"); nodep->user3p(vertexp); @@ -322,12 +322,12 @@ protected: vertexp = vertexp->verticesNextp()) { if (!vertexp->outBeginp() && dynamic_cast(vertexp)) { if (debug() >= 9) { - SplitVarStdVertex* stdp = static_cast(vertexp); + SplitVarStdVertex* const stdp = static_cast(vertexp); UINFO(0, "Will prune deps on var " << stdp->nodep() << endl); stdp->nodep()->dumpTree(cout, "- "); } for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - SplitEdge* oedgep = dynamic_cast(edgep); + SplitEdge* const oedgep = dynamic_cast(edgep); oedgep->setIgnoreThisStep(); } } @@ -351,7 +351,7 @@ protected: } virtual void visit(AstVarRef* nodep) override { if (!m_stmtStackps.empty()) { - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Not linked"); if (!nodep->varp()->isConst()) { // Constant lookups can be ignored // --- @@ -374,21 +374,22 @@ protected: // Create vertexes for variable if (!vscp->user1p()) { - SplitVarStdVertex* vstdp = new SplitVarStdVertex(&m_graph, vscp); + SplitVarStdVertex* const vstdp = new SplitVarStdVertex(&m_graph, vscp); vscp->user1p(vstdp); } - SplitVarStdVertex* vstdp = reinterpret_cast(vscp->user1p()); + SplitVarStdVertex* const vstdp + = reinterpret_cast(vscp->user1p()); // SPEEDUP: We add duplicate edges, that should be fixed if (m_inDly && nodep->access().isWriteOrRW()) { UINFO(4, " VARREFDLY: " << nodep << endl); // Delayed variable is different from non-delayed variable if (!vscp->user2p()) { - SplitVarPostVertex* vpostp = new SplitVarPostVertex(&m_graph, vscp); + SplitVarPostVertex* const vpostp = new SplitVarPostVertex(&m_graph, vscp); vscp->user2p(vpostp); new SplitPostEdge(&m_graph, vstdp, vpostp); } - SplitVarPostVertex* vpostp + SplitVarPostVertex* const vpostp = reinterpret_cast(vscp->user2p()); // Add edges for (SplitLogicVertex* vxp : m_stmtStackps) { @@ -462,7 +463,8 @@ protected: // Vertex::m_user begin: true indicates logic for this step m_graph.userClearVertices(); for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) { - SplitLogicVertex* vvertexp = reinterpret_cast(nextp->user3p()); + SplitLogicVertex* const vvertexp + = reinterpret_cast(nextp->user3p()); vvertexp->user(true); } @@ -475,16 +477,16 @@ protected: // vertexes not involved with this step as unimportant for (V3GraphVertex* vertexp = m_graph.verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (SplitLogicVertex* vvertexp = dynamic_cast(vertexp)) { + if (SplitLogicVertex* const vvertexp = dynamic_cast(vertexp)) { if (!vvertexp->user()) { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - SplitEdge* oedgep = dynamic_cast(edgep); + SplitEdge* const oedgep = dynamic_cast(edgep); oedgep->setIgnoreThisStep(); } for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - SplitEdge* oedgep = dynamic_cast(edgep); + SplitEdge* const oedgep = dynamic_cast(edgep); oedgep->setIgnoreThisStep(); } } @@ -498,7 +500,8 @@ protected: // Add hard orderings between all nodes of same color, in the order they appeared std::unordered_map lastOfColor; for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) { - SplitLogicVertex* vvertexp = reinterpret_cast(nextp->user3p()); + SplitLogicVertex* const vvertexp + = reinterpret_cast(nextp->user3p()); uint32_t color = vvertexp->color(); UASSERT_OBJ(color, nextp, "No node color assigned"); if (lastOfColor[color]) { @@ -523,7 +526,8 @@ protected: std::multimap rankMap; int currOrder = 0; // Existing sequence number of assignment for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) { - SplitLogicVertex* vvertexp = reinterpret_cast(nextp->user3p()); + SplitLogicVertex* const vvertexp + = reinterpret_cast(nextp->user3p()); rankMap.emplace(vvertexp->rank(), nextp); nextp->user4(++currOrder); // Record current ordering } @@ -532,7 +536,7 @@ protected: bool leaveAlone = true; int newOrder = 0; // New sequence number of assignment for (auto it = rankMap.cbegin(); it != rankMap.cend(); ++it) { - AstNode* nextp = it->second; + AstNode* const nextp = it->second; if (++newOrder != nextp->user4()) leaveAlone = false; } if (leaveAlone) { @@ -541,7 +545,7 @@ protected: AstNRelinker replaceHandle; // Where to add the list AstNode* newListp = nullptr; for (auto it = rankMap.cbegin(); it != rankMap.cend(); ++it) { - AstNode* nextp = it->second; + AstNode* const nextp = it->second; UINFO(6, " New order: " << nextp << endl); if (nextp == nodep) { nodep->unlinkFrBack(&replaceHandle); @@ -564,7 +568,7 @@ protected: // Check there's >= 2 sub statements, else nothing to analyze // Save recursion state AstNode* firstp = nodep; // We may reorder, and nodep is no longer first. - void* oldBlockUser3 = nodep->user3p(); // May be overloaded in below loop, save it + void* const oldBlockUser3 = nodep->user3p(); // May be overloaded in below loop, save it nodep->user3p(nullptr); UASSERT_OBJ(nodep->firstAbovep(), nodep, "Node passed is in next list; should have processed all list at once"); @@ -586,7 +590,7 @@ protected: // First, walk back to first in list while (firstp->backp()->nextp() == firstp) firstp = firstp->backp(); for (AstNode* nextp = firstp; nextp; nextp = nextp->nextp()) { - SplitLogicVertex* vvertexp + SplitLogicVertex* const vvertexp = reinterpret_cast(nextp->user3p()); vvertexp->unlinkDelete(&m_graph); } @@ -646,7 +650,7 @@ public: private: void trackNode(AstNode* nodep) { if (nodep->user3p()) { - SplitLogicVertex* vertexp = reinterpret_cast(nodep->user3p()); + SplitLogicVertex* const vertexp = reinterpret_cast(nodep->user3p()); uint32_t color = vertexp->color(); m_colors.insert(color); UINFO(8, " SVL " << vertexp << " has color " << color << "\n"); @@ -677,13 +681,13 @@ private: class EmitSplitVisitor final : public AstNVisitor { // MEMBERS - AstAlways* m_origAlwaysp; // Block that *this will split - const IfColorVisitor* m_ifColorp; // Digest of results of prior coloring + AstAlways* const m_origAlwaysp; // Block that *this will split + const IfColorVisitor* const m_ifColorp; // Digest of results of prior coloring // Map each color to our current place within the color's new always std::unordered_map m_addAfter; - AlwaysVec* m_newBlocksp; // Split always blocks we have generated + AlwaysVec* const m_newBlocksp; // Split always blocks we have generated // CONSTRUCTORS public: @@ -706,11 +710,11 @@ public: for (unsigned int color : colors) { // We don't need to clone m_origAlwaysp->sensesp() here; // V3Activate already moved it to a parent node. - AstAlways* alwaysp + AstAlways* const alwaysp = new AstAlways(m_origAlwaysp->fileline(), VAlwaysKwd::ALWAYS, nullptr, nullptr); // Put a placeholder node into stmtp to track our position. // We'll strip these out after the blocks are fully cloned. - AstSplitPlaceholder* placeholderp = makePlaceholderp(); + AstSplitPlaceholder* const placeholderp = makePlaceholderp(); alwaysp->addStmtp(placeholderp); m_addAfter[color] = placeholderp; m_newBlocksp->push_back(alwaysp); @@ -743,9 +747,9 @@ protected: UASSERT_OBJ(nodep->user3p(), nodep, "null user3p in V3Split leaf"); // Clone the leaf into its new always block - SplitLogicVertex* vxp = reinterpret_cast(nodep->user3p()); + SplitLogicVertex* const vxp = reinterpret_cast(nodep->user3p()); uint32_t color = vxp->color(); - AstNode* clonedp = nodep->cloneTree(false); + AstNode* const clonedp = nodep->cloneTree(false); m_addAfter[color]->addNextHere(clonedp); m_addAfter[color] = clonedp; } @@ -757,11 +761,11 @@ protected: for (unsigned int color : colors) { // Clone this if into its set of split blocks - AstSplitPlaceholder* if_placeholderp = makePlaceholderp(); - AstSplitPlaceholder* else_placeholderp = makePlaceholderp(); - AstIf* clonep = new AstIf(nodep->fileline(), nodep->condp()->cloneTree(true), - if_placeholderp, else_placeholderp); - AstIf* origp = VN_CAST(nodep, If); + AstSplitPlaceholder* const if_placeholderp = makePlaceholderp(); + AstSplitPlaceholder* const else_placeholderp = makePlaceholderp(); + AstIf* const clonep = new AstIf(nodep->fileline(), nodep->condp()->cloneTree(true), + if_placeholderp, else_placeholderp); + AstIf* const origp = VN_CAST(nodep, If); if (origp) { // Preserve pragmas from unique if's // so assertions work properly @@ -824,7 +828,7 @@ public: // from newly-split blocks. Delete the original always blocks // that we're replacing. for (auto it = m_replaceBlocks.begin(); it != m_replaceBlocks.end(); ++it) { - AstAlways* origp = it->first; + AstAlways* const origp = it->first; for (AlwaysVec::iterator addme = it->second.begin(); addme != it->second.end(); ++addme) { origp->addNextHere(*addme); @@ -843,7 +847,7 @@ protected: // Each 'if' depends on rvalues in its own conditional ONLY, // not rvalues in the if/else bodies. for (auto it = m_stmtStackps.cbegin(); it != m_stmtStackps.cend(); ++it) { - AstNodeIf* ifNodep = VN_CAST((*it)->nodep(), NodeIf); + AstNodeIf* const ifNodep = VN_CAST((*it)->nodep(), NodeIf); if (ifNodep && (m_curIfConditional != ifNodep)) continue; new SplitRVEdge(&m_graph, *it, vstdp); } @@ -867,15 +871,15 @@ protected: // inputs) prune all edges that depend on the 'if'. for (V3GraphVertex* vertexp = m_graph.verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - SplitLogicVertex* logicp = dynamic_cast(vertexp); + SplitLogicVertex* const logicp = dynamic_cast(vertexp); if (!logicp) continue; - AstNodeIf* ifNodep = VN_CAST(logicp->nodep(), NodeIf); + AstNodeIf* const ifNodep = VN_CAST(logicp->nodep(), NodeIf); if (!ifNodep) continue; bool pruneMe = true; for (V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) { - SplitEdge* oedgep = dynamic_cast(edgep); + SplitEdge* const oedgep = dynamic_cast(edgep); if (!oedgep->ignoreThisStep()) { // This if conditional depends on something we can't // prune -- a variable generated in the current block. @@ -885,7 +889,7 @@ protected: // give a hint about why... if (debug() >= 9) { V3GraphVertex* vxp = oedgep->top(); - SplitNodeVertex* nvxp = dynamic_cast(vxp); + SplitNodeVertex* const nvxp = dynamic_cast(vxp); UINFO(0, "Cannot prune if-node due to edge " << oedgep << " pointing to node " << nvxp->nodep() << endl); nvxp->nodep()->dumpTree(cout, "- "); @@ -899,7 +903,7 @@ protected: // This if can be split; prune dependencies on it. for (V3GraphEdge* edgep = logicp->inBeginp(); edgep; edgep = edgep->inNextp()) { - SplitEdge* oedgep = dynamic_cast(edgep); + SplitEdge* const oedgep = dynamic_cast(edgep); oedgep->setIgnoreThisStep(); } } diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index ee9bf9236..9cd9765a8 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -69,7 +69,7 @@ public: class SplitAsCleanVisitor final : public SplitAsBaseVisitor { private: // STATE - AstVarScope* m_splitVscp; // Variable we want to split + AstVarScope* const m_splitVscp; // Variable we want to split bool m_modeMatch; // Remove matching Vscp, else non-matching bool m_keepStmt = false; // Current Statement must be preserved bool m_matches = false; // Statement below has matching lvalue reference @@ -140,7 +140,7 @@ private: UINFO(3, " For " << m_splitVscp << endl); if (debug() >= 9) nodep->dumpTree(cout, "-in : "); // Duplicate it and link in - AstAlways* newp = nodep->cloneTree(false); + AstAlways* const newp = nodep->cloneTree(false); newp->user1(true); // So we don't clone it again nodep->addNextHere(newp); { // Delete stuff we don't want in old @@ -156,7 +156,7 @@ private: virtual void visit(AstAlways* nodep) override { // Are there any lvalue references below this? // There could be more than one. So, we process the first one found first. - AstVarScope* lastSplitVscp = nullptr; + const AstVarScope* lastSplitVscp = nullptr; while (!nodep->user1()) { // Find any splittable variables SplitAsFindVisitor visitor{nodep}; diff --git a/src/V3String.cpp b/src/V3String.cpp index caf5a8283..76798e8d5 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -140,7 +140,7 @@ bool VString::isWhitespace(const string& str) { } double VString::parseDouble(const string& str, bool* successp) { - char* strgp = new char[str.size() + 1]; + char* const strgp = new char[str.size() + 1]; char* dp = strgp; if (successp) *successp = true; for (const char* sp = str.c_str(); *sp; ++sp) { diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 9c0536ad8..a210403d6 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -66,7 +66,7 @@ protected: class SubstVarEntry final { // MEMBERS - AstVar* m_varp; // Variable this tracks + AstVar* const m_varp; // Variable this tracks bool m_wordAssign = false; // True if any word assignments bool m_wordUse = false; // True if any individual word usage SubstVarWord m_whole; // Data for whole vector used at once @@ -127,7 +127,7 @@ public: // ACCESSORS AstNode* substWhole(AstNode* errp) { if (!m_varp->isWide() && !m_whole.m_complex && m_whole.m_assignp && !m_wordAssign) { - AstNodeAssign* assp = m_whole.m_assignp; + const AstNodeAssign* const assp = m_whole.m_assignp; UASSERT_OBJ(assp, errp, "Reading whole that was never assigned"); return (assp->rhsp()); } else { @@ -137,7 +137,7 @@ public: // Return what to substitute given word number for AstNode* substWord(AstNode* errp, int word) { if (!m_whole.m_complex && !m_whole.m_assignp && !m_words[word].m_complex) { - AstNodeAssign* assp = getWordAssignp(word); + const AstNodeAssign* const assp = getWordAssignp(word); UASSERT_OBJ(assp, errp, "Reading a word that was never assigned, or bad word #"); return (assp->rhsp()); } else { @@ -189,7 +189,7 @@ private: } // VISITORS virtual void visit(AstVarRef* nodep) override { - SubstVarEntry* entryp = findEntryp(nodep); + const SubstVarEntry* const entryp = findEntryp(nodep); if (entryp) { // Don't sweat it. We assign a new temp variable for every new assignment, // so there's no way we'd ever replace a old value. @@ -244,12 +244,13 @@ private: // METHODS SubstVarEntry* getEntryp(AstVarRef* nodep) { if (!nodep->varp()->user1p()) { - SubstVarEntry* entryp = new SubstVarEntry(nodep->varp()); + SubstVarEntry* const entryp = new SubstVarEntry(nodep->varp()); m_entryps.push_back(entryp); nodep->varp()->user1p(entryp); return entryp; } else { - SubstVarEntry* entryp = reinterpret_cast(nodep->varp()->user1p()); + SubstVarEntry* const entryp + = reinterpret_cast(nodep->varp()->user1p()); return entryp; } } @@ -261,9 +262,9 @@ private: m_assignStep++; iterateAndNextNull(nodep->rhsp()); bool hit = false; - if (AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef)) { + if (AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef)) { if (isSubstVar(varrefp->varp())) { - SubstVarEntry* entryp = getEntryp(varrefp); + SubstVarEntry* const entryp = getEntryp(varrefp); hit = true; if (m_ops > SUBST_MAX_OPS_SUBST) { UINFO(8, " ASSIGNtooDeep " << varrefp << endl); @@ -274,10 +275,10 @@ private: } } } else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) { - if (AstVarRef* varrefp = VN_CAST(wordp->lhsp(), VarRef)) { + if (AstVarRef* const varrefp = VN_CAST(wordp->lhsp(), VarRef)) { if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) { const int word = VN_AS(wordp->rhsp(), Const)->toUInt(); - SubstVarEntry* entryp = getEntryp(varrefp); + SubstVarEntry* const entryp = getEntryp(varrefp); hit = true; if (m_ops > SUBST_MAX_OPS_SUBST) { UINFO(8, " ASSIGNtooDeep " << varrefp << endl); @@ -304,15 +305,15 @@ private: } virtual void visit(AstWordSel* nodep) override { iterate(nodep->rhsp()); - AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); - AstConst* constp = VN_CAST(nodep->rhsp(), Const); + AstVarRef* const varrefp = VN_CAST(nodep->lhsp(), VarRef); + const AstConst* const constp = VN_CAST(nodep->rhsp(), Const); if (varrefp && isSubstVar(varrefp->varp()) && varrefp->access().isReadOnly() && constp) { // Nicely formed lvalues handled in NodeAssign // Other lvalues handled as unknown mess in AstVarRef const int word = constp->toUInt(); UINFO(8, " USEword" << word << " " << varrefp << endl); - SubstVarEntry* entryp = getEntryp(varrefp); - if (AstNode* substp = entryp->substWord(nodep, word)) { + SubstVarEntry* const entryp = getEntryp(varrefp); + if (AstNode* const substp = entryp->substWord(nodep, word)) { // Check that the RHS hasn't changed value since we recorded it. SubstUseVisitor visitor{substp, entryp->getWordStep(word)}; if (visitor.ok()) { @@ -335,7 +336,7 @@ private: UINFO(9, " ASSIGNstep u2=" << nodep->varp()->user2() << " " << nodep << endl); } if (isSubstVar(nodep->varp())) { - SubstVarEntry* entryp = getEntryp(nodep); + SubstVarEntry* const entryp = getEntryp(nodep); if (nodep->access().isWriteOrRW()) { UINFO(8, " ASSIGNcpx " << nodep << endl); entryp->assignComplex(); diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 4ea0ae3a4..54fd9395f 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -95,8 +95,8 @@ public: // each non-directional edge: void addEdge(const T_Key& from, const T_Key& to, int cost) { UASSERT(from != to, "Adding edge would form a loop"); - Vertex* fp = findVertex(from); - Vertex* tp = findVertex(to); + Vertex* const fp = findVertex(from); + Vertex* const tp = findVertex(to); // No need to dedup edges. // The only time we may create duplicate edges is when @@ -164,7 +164,7 @@ public: // Choose an arbitrary start vertex and visit it; // all incident edges from this vertex go into a pending edge set. - Vertex* start_vertexp = castVertexp(verticesBeginp()); + Vertex* const start_vertexp = castVertexp(verticesBeginp()); visited_set.insert(start_vertexp); for (V3GraphEdge* edgep = start_vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { pendingEdges.insert(edgep); @@ -181,12 +181,12 @@ public: pendingEdges.erase(firstIt); // bestEdgep->fromp() should be already seen - Vertex* from_vertexp = castVertexp(bestEdgep->fromp()); + Vertex* const from_vertexp = castVertexp(bestEdgep->fromp()); UASSERT(visited_set.find(from_vertexp) != visited_set.end(), "Can't find vertex"); // If the neighbor is not yet visited, visit it and add its edges // to the pending set. - Vertex* neighborp = castVertexp(bestEdgep->top()); + Vertex* const neighborp = castVertexp(bestEdgep->top()); if (visited_set.find(neighborp) == visited_set.end()) { const int bestCost = bestEdgep->weight(); UINFO(6, "bestCost = " << bestCost << " from " << from_vertexp->key() << " to " @@ -260,8 +260,8 @@ public: // haven't been matched yet, match them. for (typename PendingEdgeSet::iterator it = pendingEdges.begin(); it != pendingEdges.end(); ++it) { - Vertex* fromp = castVertexp((*it)->fromp()); - Vertex* top = castVertexp((*it)->top()); + Vertex* const fromp = castVertexp((*it)->fromp()); + Vertex* const top = castVertexp((*it)->top()); if ((unmatchedOdds.find(fromp) != unmatchedOdds.end()) && (unmatchedOdds.find(top) != unmatchedOdds.end())) { outp->addEdge(fromp->key(), top->key(), (*it)->weight()); @@ -275,9 +275,9 @@ public: void combineGraph(const TspGraphTmpl& g) { std::unordered_set edges_done; for (V3GraphVertex* vxp = g.verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - Vertex* fromp = castVertexp(vxp); + const Vertex* const fromp = castVertexp(vxp); for (V3GraphEdge* edgep = fromp->outBeginp(); edgep; edgep = edgep->outNextp()) { - Vertex* top = castVertexp(edgep->top()); + const Vertex* const top = castVertexp(edgep->top()); if (edges_done.find(edgep->user()) == edges_done.end()) { addEdge(fromp->key(), top->key(), edgep->weight()); edges_done.insert(edgep->user()); @@ -302,7 +302,7 @@ public: if (markedEdgesp->end() == markedEdgesp->find(edgeId)) { // This edge is not yet marked, so follow it. markedEdgesp->insert(edgeId); - Vertex* neighborp = castVertexp(edgep->top()); + Vertex* const neighborp = castVertexp(edgep->top()); UINFO(6, "following edge " << edgeId << " from " << cur_vertexp->key() << " to " << neighborp->key() << endl); cur_vertexp = neighborp; @@ -344,10 +344,10 @@ public: // UINFO(0) as controlled by caller os << "At " << nameComment << ", dumping graph. Keys:\n"; for (V3GraphVertex* vxp = verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - Vertex* tspvp = castVertexp(vxp); + const Vertex* const tspvp = castVertexp(vxp); os << " " << tspvp->key() << '\n'; for (V3GraphEdge* edgep = tspvp->outBeginp(); edgep; edgep = edgep->outNextp()) { - Vertex* neighborp = castVertexp(edgep->top()); + const Vertex* const neighborp = castVertexp(edgep->top()); os << " has edge " << edgep->user() << " to " << neighborp->key() << '\n'; } } @@ -366,14 +366,14 @@ public: if (debug() >= 6) dumpDotFilePrefixed("findEulerTour"); std::unordered_set markedEdges; // Pick a start node - Vertex* start_vertexp = castVertexp(verticesBeginp()); + Vertex* const start_vertexp = castVertexp(verticesBeginp()); findEulerTourRecurse(&markedEdges, start_vertexp, sortedOutp); } std::vector getOddDegreeKeys() const { std::vector result; for (V3GraphVertex* vxp = verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - Vertex* tspvp = castVertexp(vxp); + const Vertex* const tspvp = castVertexp(vxp); vluint32_t degree = 0; for (V3GraphEdge* edgep = vxp->outBeginp(); edgep; edgep = edgep->outNextp()) { degree++; @@ -442,7 +442,7 @@ void V3TSP::tspSort(const V3TSP::StateVec& states, V3TSP::StateVec* resultp) { std::unordered_set seen; for (V3TSP::StateVec::iterator it = prelim_result.begin(); it != prelim_result.end(); ++it) { - const TspStateBase* elemp = *it; + const TspStateBase* const elemp = *it; if (seen.find(elemp) == seen.end()) { seen.insert(elemp); resultp->push_back(elemp); @@ -460,8 +460,8 @@ void V3TSP::tspSort(const V3TSP::StateVec& states, V3TSP::StateVec* resultp) { unsigned max_cost = 0; unsigned max_cost_idx = 0; for (unsigned i = 0; i < resultp->size(); ++i) { - const TspStateBase* ap = (*resultp)[i]; - const TspStateBase* bp + const TspStateBase* const ap = (*resultp)[i]; + const TspStateBase* const bp = (i + 1 == resultp->size()) ? (*resultp)[0] : (*resultp)[i + 1]; const unsigned cost = ap->cost(bp); if (cost > max_cost) { @@ -560,7 +560,7 @@ void V3TSP::selfTestStates() { expect.push_back(&s5); if (VL_UNCOVERABLE(expect != result)) { for (V3TSP::StateVec::iterator it = result.begin(); it != result.end(); ++it) { - const TspTestState* statep = dynamic_cast(*it); + const TspTestState* const statep = dynamic_cast(*it); cout << statep->xpos() << " "; } cout << endl; @@ -602,7 +602,7 @@ void V3TSP::selfTestStates() { if (VL_UNCOVERABLE(expect != result)) { for (V3TSP::StateVec::iterator it = result.begin(); it != result.end(); ++it) { - const TspTestState* statep = dynamic_cast(*it); + const TspTestState* const statep = dynamic_cast(*it); cout << statep->xpos() << "," << statep->ypos() << " "; } cout << endl; diff --git a/src/V3Table.cpp b/src/V3Table.cpp index f81c83021..0220a2df5 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -54,7 +54,7 @@ class TableVisitor; class TableSimulateVisitor final : public SimulateVisitor { // MEMBERS - TableVisitor* m_cbthis; ///< Class for callback + TableVisitor* const m_cbthis; ///< Class for callback public: ///< Call other-this function on all new var references diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 73042fe34..890af9975 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -56,7 +56,7 @@ public: class TaskFTaskVertex final : public TaskBaseVertex { // Every task gets a vertex, and we link tasks together based on funcrefs. - AstNodeFTask* m_nodep; + AstNodeFTask* const m_nodep; AstCFunc* m_cFuncp = nullptr; public: @@ -118,7 +118,7 @@ private: public: // METHODS AstScope* getScope(AstNodeFTask* nodep) { - AstScope* scopep = VN_AS(nodep->user3p(), Scope); + AstScope* const scopep = VN_AS(nodep->user3p(), Scope); UASSERT_OBJ(scopep, nodep, "No scope for function"); return scopep; } @@ -128,7 +128,7 @@ public: return iter->second; } AstClass* getClassp(AstNodeFTask* nodep) { - AstClass* classp = m_funcToClassMap[nodep]; + AstClass* const classp = m_funcToClassMap[nodep]; UASSERT_OBJ(classp, nodep, "No class for ctor func"); return classp; } @@ -171,7 +171,7 @@ private: // However, to create variables, we need to track the scopes involved. // Find all var->varscope mappings, for later cleanup for (AstNode* stmtp = nodep->varsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVarScope* vscp = VN_CAST(stmtp, VarScope)) { + if (AstVarScope* const vscp = VN_CAST(stmtp, VarScope)) { if (vscp->varp()->isFuncLocal()) { UINFO(9, " funcvsc " << vscp << endl); m_varToScopeMap.insert( @@ -181,7 +181,7 @@ private: } // Likewise, all FTask->scope mappings for (AstNode* stmtp = nodep->blocksp(); stmtp; stmtp = stmtp->nextp()) { - if (AstNodeFTask* taskp = VN_CAST(stmtp, NodeFTask)) taskp->user3p(nodep); + if (AstNodeFTask* const taskp = VN_CAST(stmtp, NodeFTask)) taskp->user3p(nodep); } iterateChildren(nodep); } @@ -248,7 +248,7 @@ private: } UASSERT_OBJ(m_ctorp, nodep, "class constructor missing"); // LinkDot always makes it for (AstInitial* initialp : m_initialps) { - if (AstNode* newp = initialp->bodysp()) { + if (AstNode* const newp = initialp->bodysp()) { newp->unlinkFrBackWithNext(); if (!m_ctorp->stmtsp()) { m_ctorp->addStmtsp(newp); @@ -300,7 +300,7 @@ private: if (nodep->varp()->user2p()) { // It's being converted to an alias. UINFO(9, " relinkVar " << cvtToHex(nodep->varp()->user2p()) << " " << nodep << endl); - AstVarScope* newvscp = VN_AS(nodep->varp()->user2p(), VarScope); + AstVarScope* const newvscp = VN_AS(nodep->varp()->user2p(), VarScope); UASSERT_OBJ(newvscp, nodep, "not linked"); nodep->varScopep(newvscp); nodep->varp(nodep->varScopep()->varp()); @@ -327,7 +327,7 @@ struct TaskDpiUtils { static std::vector> unpackDimsAndStrides(AstNodeDType* dtypep) { std::vector> dimStrides; - if (AstUnpackArrayDType* unpackp = VN_CAST(dtypep->skipRefp(), UnpackArrayDType)) { + if (AstUnpackArrayDType* const unpackp = VN_CAST(dtypep->skipRefp(), UnpackArrayDType)) { const std::vector dims = unpackp->unpackDimensions(); dimStrides.resize(dims.size(), {nullptr, 0}); dimStrides.back() = {dims.back(), 1}; @@ -353,7 +353,7 @@ struct TaskDpiUtils { frstmt = "VL_SET_W_" + frSvType + "(" + cvtToStr(portp->width()) + ","; return true; } else { - const AstNodeDType* dtypep = portp->dtypep()->skipRefp(); + const AstNodeDType* const dtypep = portp->dtypep()->skipRefp(); frstmt = "VL_SET_" + string(dtypep->charIQWN()) + "_" + frSvType + "("; if (VN_IS(dtypep, UnpackArrayDType)) frstmt += "&"; frstmt += frName; diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index a2b3553da..747ef9d3b 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -97,7 +97,7 @@ public: }; class TraceCFuncVertex final : public V3GraphVertex { - AstCFunc* m_nodep; + AstCFunc* const m_nodep; public: TraceCFuncVertex(V3Graph* graphp, AstCFunc* nodep) @@ -134,7 +134,7 @@ public: }; class TraceVarVertex final : public V3GraphVertex { - AstVarScope* m_nodep; + AstVarScope* const m_nodep; public: TraceVarVertex(V3Graph* graphp, AstVarScope* nodep) diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index a48245c84..c70942e29 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -79,7 +79,7 @@ public: // Graph support classes class TristateVertex final : public V3GraphVertex { - AstNode* m_nodep; + AstNode* const m_nodep; bool m_isTristate = false; // Logic indicates a tristate bool m_feedsTri = false; // Propagates to a tristate node (on RHS) bool m_processed = false; // Tristating was cleaned up @@ -90,7 +90,7 @@ public: virtual ~TristateVertex() override = default; // ACCESSORS AstNode* nodep() const { return m_nodep; } - AstVar* varp() const { return VN_CAST(nodep(), Var); } + const AstVar* varp() const { return VN_CAST(nodep(), Var); } virtual string name() const override { return ((isTristate() ? "tri\\n" : feedsTri() ? "feed\\n" @@ -160,7 +160,7 @@ private: UINFO(9, " Mark tri " << level << " " << vtxp << endl); if (!vtxp->varp()) { // not a var where we stop the recursion for (V3GraphEdge* edgep = vtxp->outBeginp(); edgep; edgep = edgep->outNextp()) { - TristateVertex* vvertexp = dynamic_cast(edgep->top()); + TristateVertex* const vvertexp = dynamic_cast(edgep->top()); // Doesn't hurt to not check if already set, but by doing so when we // print out the debug messages, we'll see this node at level 0 instead. if (!vvertexp->isTristate()) { @@ -172,8 +172,8 @@ private: // A variable is tristated. Find all of the LHS VARREFs that // drive this signal now need tristate drivers for (V3GraphEdge* edgep = vtxp->inBeginp(); edgep; edgep = edgep->inNextp()) { - TristateVertex* vvertexp = dynamic_cast(edgep->fromp()); - if (const AstVarRef* refp = VN_CAST(vvertexp->nodep(), VarRef)) { + TristateVertex* const vvertexp = dynamic_cast(edgep->fromp()); + if (const AstVarRef* const refp = VN_CAST(vvertexp->nodep(), VarRef)) { if (refp->access().isWriteOrRW() // Doesn't hurt to not check if already set, but by doing so when we // print out the debug messages, we'll see this node at level 0 instead. @@ -197,7 +197,7 @@ private: UINFO(9, " Mark feedstri " << level << " " << vtxp << endl); if (!vtxp->varp()) { // not a var where we stop the recursion for (V3GraphEdge* edgep = vtxp->inBeginp(); edgep; edgep = edgep->inNextp()) { - TristateVertex* vvertexp = dynamic_cast(edgep->fromp()); + TristateVertex* const vvertexp = dynamic_cast(edgep->fromp()); // Doesn't hurt to not check if already set, but by doing so when we // print out the debug messages, we'll see this node at level 0 instead. if (!vvertexp->feedsTri()) { @@ -213,7 +213,7 @@ public: bool empty() const { return m_graph.empty(); } void clear() { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - TristateVertex* vvertexp = static_cast(itp); + TristateVertex* const vvertexp = static_cast(itp); if (vvertexp->isTristate() && !vvertexp->processed()) { // Not v3errorSrc as no reason to stop the world vvertexp->nodep()->v3error("Unsupported tristate construct" @@ -240,15 +240,15 @@ public: new V3GraphEdge(&m_graph, makeVertex(fromp), makeVertex(top), 1); } bool isTristate(AstNode* nodep) { - TristateVertex* vertexp = reinterpret_cast(nodep->user5p()); + TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); return vertexp && vertexp->isTristate(); } bool feedsTri(AstNode* nodep) { - TristateVertex* vertexp = reinterpret_cast(nodep->user5p()); + TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); return vertexp && vertexp->feedsTri(); } void didProcess(AstNode* nodep) { - TristateVertex* vertexp = reinterpret_cast(nodep->user5p()); + TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); if (!vertexp) { // Not v3errorSrc as no reason to stop the world nodep->v3error("Unsupported tristate construct (not in propagation graph): " @@ -264,9 +264,9 @@ public: // Return all tristate variables VarVec v; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - TristateVertex* vvertexp = static_cast(itp); + TristateVertex* const vvertexp = static_cast(itp); if (vvertexp->isTristate()) { - if (AstVar* nodep = VN_CAST(vvertexp->nodep(), Var)) v.push_back(nodep); + if (AstVar* const nodep = VN_CAST(vvertexp->nodep(), Var)) v.push_back(nodep); } } return v; @@ -371,7 +371,7 @@ class TristateVisitor final : public TristateBaseVisitor { if (!nodep->user1p()) { V3Number num(nodep, nodep->width()); num.setAllBits1(); - AstNode* enp = new AstConst(nodep->fileline(), num); + AstNode* const enp = new AstConst(nodep->fileline(), num); nodep->user1p(enp); } return nodep->user1p(); @@ -380,8 +380,8 @@ class TristateVisitor final : public TristateBaseVisitor { AstVar* getCreateEnVarp(AstVar* invarp) { // Return the master __en for the specified input variable if (!invarp->user1p()) { - AstVar* newp = new AstVar(invarp->fileline(), AstVarType::MODULETEMP, - invarp->name() + "__en", invarp); + AstVar* const newp = new AstVar(invarp->fileline(), AstVarType::MODULETEMP, + invarp->name() + "__en", invarp); UINFO(9, " newenv " << newp << endl); if (!m_modp) { invarp->v3warn(E_UNSUPPORTED, @@ -398,8 +398,8 @@ class TristateVisitor final : public TristateBaseVisitor { AstVar* getCreateOutVarp(AstVar* invarp) { // Return the master __out for the specified input variable if (!invarp->user4p()) { - AstVar* newp = new AstVar(invarp->fileline(), AstVarType::MODULETEMP, - invarp->name() + "__out", invarp); + AstVar* const newp = new AstVar(invarp->fileline(), AstVarType::MODULETEMP, + invarp->name() + "__out", invarp); UINFO(9, " newout " << newp << endl); if (!m_modp) { invarp->v3warn(E_UNSUPPORTED, @@ -414,8 +414,8 @@ class TristateVisitor final : public TristateBaseVisitor { } AstVar* getCreateUnconnVarp(AstNode* fromp, AstNodeDType* dtypep) { - AstVar* newp = new AstVar(fromp->fileline(), AstVarType::MODULETEMP, - "__Vtriunconn" + cvtToStr(m_unique++), dtypep); + AstVar* const newp = new AstVar(fromp->fileline(), AstVarType::MODULETEMP, + "__Vtriunconn" + cvtToStr(m_unique++), dtypep); UINFO(9, " newunc " << newp << endl); if (!m_modp) { newp->v3warn(E_UNSUPPORTED, @@ -427,11 +427,11 @@ class TristateVisitor final : public TristateBaseVisitor { } void mapInsertLhsVarRef(AstVarRef* nodep) { - AstVar* key = nodep->varp(); + AstVar* const key = nodep->varp(); const auto it = m_lhsmap.find(key); UINFO(9, " mapInsertLhsVarRef " << nodep << endl); if (it == m_lhsmap.end()) { // Not found - RefVec* refsp = new RefVec(); + RefVec* const refsp = new RefVec(); refsp->push_back(nodep); m_lhsmap.emplace(key, refsp); } else { @@ -442,14 +442,14 @@ class TristateVisitor final : public TristateBaseVisitor { AstNode* newEnableDeposit(AstSel* selp, AstNode* enp) { // Form a "deposit" instruction for given enable, using existing select as a template. // Would be nicer if we made this a new AST type - AstNode* newp = new AstShiftL(selp->fileline(), - new AstExtend(selp->fileline(), enp, selp->fromp()->width()), - selp->lsbp()->cloneTree(false), selp->fromp()->width()); + AstNode* const newp = new AstShiftL( + selp->fileline(), new AstExtend(selp->fileline(), enp, selp->fromp()->width()), + selp->lsbp()->cloneTree(false), selp->fromp()->width()); return newp; } void setPullDirection(AstVar* varp, AstPull* pullp) { - AstPull* oldpullp = static_cast(varp->user3p()); + AstPull* const oldpullp = static_cast(varp->user3p()); if (!oldpullp) { varp->user3p(pullp); // save off to indicate the pull direction } else { @@ -493,10 +493,11 @@ class TristateVisitor final : public TristateBaseVisitor { // set output enable to always be off on this assign // statement so that this var is floating UINFO(8, " Adding driver to var " << varp << endl); - AstConst* constp = new AstConst(varp->fileline(), AstConst::WidthedValue(), - varp->width(), 0); - AstVarRef* varrefp = new AstVarRef(varp->fileline(), varp, VAccess::WRITE); - AstNode* newp = new AstAssignW(varp->fileline(), varrefp, constp); + AstConst* const constp = new AstConst( + varp->fileline(), AstConst::WidthedValue(), varp->width(), 0); + AstVarRef* const varrefp + = new AstVarRef(varp->fileline(), varp, VAccess::WRITE); + AstNode* const newp = new AstAssignW(varp->fileline(), varrefp, constp); UINFO(9, " newoev " << newp << endl); varrefp->user1p(new AstConst(varp->fileline(), AstConst::WidthedValue(), varp->width(), 0)); @@ -513,8 +514,8 @@ class TristateVisitor final : public TristateBaseVisitor { for (VarMap::iterator nextit, it = m_lhsmap.begin(); it != m_lhsmap.end(); it = nextit) { nextit = it; ++nextit; - AstVar* invarp = it->first; - RefVec* refsp = it->second; + AstVar* const invarp = it->first; + RefVec* const refsp = it->second; // Figure out if this var needs tristate expanded. if (!m_tgraph.isTristate(invarp)) { @@ -566,40 +567,40 @@ class TristateVisitor final : public TristateBaseVisitor { int w = lhsp->width(); // create the new lhs driver for this var - AstVar* newlhsp = new AstVar(lhsp->fileline(), AstVarType::MODULETEMP, - lhsp->name() + "__out" + cvtToStr(m_unique), - VFlagBitPacked(), w); // 2-state ok; sep enable + AstVar* const newlhsp = new AstVar(lhsp->fileline(), AstVarType::MODULETEMP, + lhsp->name() + "__out" + cvtToStr(m_unique), + VFlagBitPacked(), w); // 2-state ok; sep enable UINFO(9, " newout " << newlhsp << endl); nodep->addStmtp(newlhsp); refp->varp(newlhsp); // assign the new var to the varref refp->name(newlhsp->name()); // create a new var for this drivers enable signal - AstVar* newenp = new AstVar(lhsp->fileline(), AstVarType::MODULETEMP, - lhsp->name() + "__en" + cvtToStr(m_unique++), - VFlagBitPacked(), w); // 2-state ok + AstVar* const newenp = new AstVar(lhsp->fileline(), AstVarType::MODULETEMP, + lhsp->name() + "__en" + cvtToStr(m_unique++), + VFlagBitPacked(), w); // 2-state ok UINFO(9, " newenp " << newenp << endl); nodep->addStmtp(newenp); - AstNode* enassp = new AstAssignW( + AstNode* const enassp = new AstAssignW( refp->fileline(), new AstVarRef(refp->fileline(), newenp, VAccess::WRITE), getEnp(refp)); UINFO(9, " newass " << enassp << endl); nodep->addStmtp(enassp); // now append this driver to the driver logic. - AstNode* ref1p = new AstVarRef(refp->fileline(), newlhsp, VAccess::READ); - AstNode* ref2p = new AstVarRef(refp->fileline(), newenp, VAccess::READ); - AstNode* andp = new AstAnd(refp->fileline(), ref1p, ref2p); + AstNode* const ref1p = new AstVarRef(refp->fileline(), newlhsp, VAccess::READ); + AstNode* const ref2p = new AstVarRef(refp->fileline(), newenp, VAccess::READ); + AstNode* const andp = new AstAnd(refp->fileline(), ref1p, ref2p); // or this to the others orp = (!orp) ? andp : new AstOr(refp->fileline(), orp, andp); if (envarp) { - AstNode* ref3p = new AstVarRef(refp->fileline(), newenp, VAccess::READ); + AstNode* const ref3p = new AstVarRef(refp->fileline(), newenp, VAccess::READ); enp = (!enp) ? ref3p : new AstOr(ref3p->fileline(), enp, ref3p); } - AstNode* tmp = new AstNot( + AstNode* const tmp = new AstNot( newenp->fileline(), new AstVarRef(newenp->fileline(), newenp, VAccess::READ)); undrivenp = ((!undrivenp) ? tmp : new AstAnd(refp->fileline(), tmp, undrivenp)); } @@ -612,7 +613,7 @@ class TristateVisitor final : public TristateBaseVisitor { // This is the final resolution of the tristate, so we apply // the pull direction to any undriven pins. V3Number pull(invarp, lhsp->width()); - AstPull* pullp = static_cast(lhsp->user3p()); + AstPull* const pullp = static_cast(lhsp->user3p()); if (pullp && pullp->direction() == 1) { pull.setAllBits1(); UINFO(9, "Has pullup " << pullp << endl); @@ -631,7 +632,7 @@ class TristateVisitor final : public TristateBaseVisitor { enp)); } // __out (child) or (parent) = drive-value expression - AstNode* assp = new AstAssignW( + AstNode* const assp = new AstAssignW( lhsp->fileline(), new AstVarRef(lhsp->fileline(), lhsp, VAccess::WRITE), orp); assp->user2(U2_BOTH); // Don't process further; already resolved if (debug() >= 9) assp->dumpTree(cout, "-lhsp-eqn: "); @@ -653,22 +654,22 @@ class TristateVisitor final : public TristateBaseVisitor { // A pin with 1'b0 or similar connection results in an assign with constant on LHS // due to the pinReconnectSimple call in visit AstPin. // We can ignore the output override by making a temporary - AstVar* varp = getCreateUnconnVarp(nodep, nodep->dtypep()); - AstNode* newp = new AstVarRef(nodep->fileline(), varp, VAccess::WRITE); + AstVar* const varp = getCreateUnconnVarp(nodep, nodep->dtypep()); + AstNode* const newp = new AstVarRef(nodep->fileline(), varp, VAccess::WRITE); UINFO(9, " const->" << newp << endl); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (m_tgraph.isTristate(nodep)) { m_tgraph.didProcess(nodep); - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); V3Number numz(nodep, nodep->width()); numz.opBitsZ(nodep->num()); // Z->1, else 0 V3Number numz0(nodep, nodep->width()); numz0.opNot(numz); // Z->0, else 1 V3Number num1(nodep, nodep->width()); num1.opAnd(nodep->num(), numz0); // 01X->01X, Z->0 - AstConst* newconstp = new AstConst(fl, num1); - AstConst* enp = new AstConst(fl, numz0); + AstConst* const newconstp = new AstConst(fl, num1); + AstConst* const enp = new AstConst(fl, numz0); nodep->replaceWith(newconstp); VL_DO_DANGLING(pushDeletep(nodep), nodep); newconstp->user1p(enp); // Propagate up constant with non-Z bits as 1 @@ -698,20 +699,21 @@ class TristateVisitor final : public TristateBaseVisitor { // expression 1 or 2 have an output enable '__en' signal. If the // condition has an enable, not sure what to do, so generate an // error. - AstNode* condp = nodep->condp(); + AstNode* const condp = nodep->condp(); if (condp->user1p()) { condp->v3warn(E_UNSUPPORTED, "Unsupported: don't know how to deal with " "tristate logic in the conditional expression"); } - AstNode* expr1p = nodep->expr1p(); - AstNode* expr2p = nodep->expr2p(); + AstNode* const expr1p = nodep->expr1p(); + AstNode* const expr2p = nodep->expr2p(); if (expr1p->user1p() || expr2p->user1p()) { // else no tristates m_tgraph.didProcess(nodep); - AstNode* en1p = getEnp(expr1p); - AstNode* en2p = getEnp(expr2p); + AstNode* const en1p = getEnp(expr1p); + AstNode* const en2p = getEnp(expr2p); // The output enable of a cond is a cond of the output enable of the // two expressions with the same conditional. - AstNode* enp = new AstCond(nodep->fileline(), condp->cloneTree(false), en1p, en2p); + AstNode* const enp + = new AstCond(nodep->fileline(), condp->cloneTree(false), en1p, en2p); UINFO(9, " newcond " << enp << endl); nodep->user1p(enp); // propagate up COND(lhsp->enable, rhsp->enable) expr1p->user1p(nullptr); @@ -733,7 +735,7 @@ class TristateVisitor final : public TristateBaseVisitor { UINFO(9, dbgState() << nodep << endl); if (nodep->user1p()) { // Form a "deposit" instruction. Would be nicer if we made this a new AST type - AstNode* newp = newEnableDeposit(nodep, nodep->user1p()); + AstNode* const newp = newEnableDeposit(nodep, nodep->user1p()); nodep->fromp()->user1p(newp); // Push to varref (etc) if (debug() >= 9) newp->dumpTree(cout, "-assign-sel; "); m_tgraph.didProcess(nodep); @@ -747,8 +749,8 @@ class TristateVisitor final : public TristateBaseVisitor { << nodep->prettyTypeName()); } if (nodep->fromp()->user1p()) { // SEL(VARREF, lsb) - AstNode* en1p = getEnp(nodep->fromp()); - AstNode* enp + AstNode* const en1p = getEnp(nodep->fromp()); + AstNode* const enp = new AstSel(nodep->fileline(), en1p, nodep->lsbp()->cloneTree(true), nodep->widthp()->cloneTree(true)); UINFO(9, " newsel " << enp << endl); @@ -774,7 +776,7 @@ class TristateVisitor final : public TristateBaseVisitor { UINFO(9, dbgState() << nodep << endl); if (nodep->user1p()) { // Each half of the concat gets a select of the enable expression - AstNode* enp = nodep->user1p(); + AstNode* const enp = nodep->user1p(); nodep->user1p(nullptr); nodep->lhsp()->user1p(new AstSel(nodep->fileline(), enp->cloneTree(true), nodep->rhsp()->width(), @@ -789,13 +791,13 @@ class TristateVisitor final : public TristateBaseVisitor { UINFO(9, dbgState() << nodep << endl); // Generate the new output enable signal, just as a concat // identical to the data concat - AstNode* expr1p = nodep->lhsp(); - AstNode* expr2p = nodep->rhsp(); + AstNode* const expr1p = nodep->lhsp(); + AstNode* const expr2p = nodep->rhsp(); if (expr1p->user1p() || expr2p->user1p()) { // else no tristates m_tgraph.didProcess(nodep); - AstNode* en1p = getEnp(expr1p); - AstNode* en2p = getEnp(expr2p); - AstNode* enp = new AstConcat(nodep->fileline(), en1p, en2p); + AstNode* const en1p = getEnp(expr1p); + AstNode* const en2p = getEnp(expr2p); + AstNode* const enp = new AstConcat(nodep->fileline(), en1p, en2p); UINFO(9, " newconc " << enp << endl); nodep->user1p(enp); // propagate up CONCAT(lhsp->enable, rhsp->enable) expr1p->user1p(nullptr); @@ -820,10 +822,10 @@ class TristateVisitor final : public TristateBaseVisitor { return; } m_tgraph.didProcess(nodep); - AstNode* expr1p = nodep->lhsp()->unlinkFrBack(); - AstNode* expr2p = nodep->rhsp()->unlinkFrBack(); + AstNode* const expr1p = nodep->lhsp()->unlinkFrBack(); + AstNode* const expr2p = nodep->rhsp()->unlinkFrBack(); AstNode* enp; - if (AstNode* en2p = expr2p->user1p()) { + if (AstNode* const en2p = expr2p->user1p()) { enp = new AstAnd(nodep->fileline(), expr1p, en2p); } else { enp = expr1p; @@ -863,14 +865,14 @@ class TristateVisitor final : public TristateBaseVisitor { // have to define what is means to OR 1'bz with other // expressions. Here I take the approach that when one expression // is 0, that is passes the other. - AstNode* expr1p = nodep->lhsp(); - AstNode* expr2p = nodep->rhsp(); + AstNode* const expr1p = nodep->lhsp(); + AstNode* const expr2p = nodep->rhsp(); if (!expr1p->user1p() && !expr2p->user1p()) { return; // no tristates in either expression, so nothing to do } m_tgraph.didProcess(nodep); - AstNode* en1p = getEnp(expr1p); - AstNode* en2p = getEnp(expr2p); + AstNode* const en1p = getEnp(expr1p); + AstNode* const en2p = getEnp(expr2p); AstNode* subexpr1p = expr1p->cloneTree(false); AstNode* subexpr2p = expr2p->cloneTree(false); if (isAnd) { @@ -878,7 +880,7 @@ class TristateVisitor final : public TristateBaseVisitor { subexpr2p = new AstNot(nodep->fileline(), subexpr2p); } // calc new output enable - AstNode* enp = new AstOr( + AstNode* const enp = new AstOr( nodep->fileline(), new AstAnd(nodep->fileline(), en1p, en2p), new AstOr(nodep->fileline(), new AstAnd(nodep->fileline(), en1p->cloneTree(false), subexpr1p), @@ -942,16 +944,16 @@ class TristateVisitor final : public TristateBaseVisitor { iterateChildren(nodep); UINFO(9, dbgState() << nodep << endl); // Constification always moves const to LHS - const AstConst* constp = VN_CAST(nodep->lhsp(), Const); - AstVarRef* varrefp = VN_CAST(nodep->rhsp(), VarRef); // Input variable + const AstConst* const constp = VN_CAST(nodep->lhsp(), Const); + AstVarRef* const varrefp = VN_CAST(nodep->rhsp(), VarRef); // Input variable if (constp && constp->user1p() && varrefp) { // 3'b1z0 -> ((3'b101 == in__en) && (3'b100 == in)) varrefp->unlinkFrBack(); - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); V3Number oneIfEn = VN_AS(constp->user1p(), Const) ->num(); // visit(AstConst) already split into en/ones const V3Number& oneIfEnOne = constp->num(); - AstVar* envarp = getCreateEnVarp(varrefp->varp()); + AstVar* const envarp = getCreateEnVarp(varrefp->varp()); AstNode* newp = new AstLogAnd(fl, new AstEq(fl, new AstConst(fl, oneIfEn), @@ -993,7 +995,7 @@ class TristateVisitor final : public TristateBaseVisitor { dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyZ(); dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_AS(nodep->fhsp(), Const)->num().isAnyZ(); UINFO(4, " COUNTBITS(" << dropop[0] << dropop[1] << dropop[2] << " " << nodep << endl); - AstVarRef* varrefp = VN_AS(nodep->lhsp(), VarRef); // Input variable + AstVarRef* const varrefp = VN_AS(nodep->lhsp(), VarRef); // Input variable if (m_graphing) { iterateAndNextNull(nodep->lhsp()); if (!dropop[0]) iterateAndNextNull(nodep->rhsp()); @@ -1018,7 +1020,7 @@ class TristateVisitor final : public TristateBaseVisitor { << nodep->prettyTypeName()); return; } - AstVar* envarp = getCreateEnVarp(varrefp->varp()); + AstVar* const envarp = getCreateEnVarp(varrefp->varp()); // If any drops, we need to add in the count of Zs (from __en) UINFO(4, " COUNTBITS('z)-> " << nodep << endl); AstNRelinker relinkHandle; @@ -1126,7 +1128,7 @@ class TristateVisitor final : public TristateBaseVisitor { if (nodep->user2() & U2_GRAPHING) return; // This pin is already expanded nodep->user2(U2_GRAPHING); // Find child module's new variables. - AstVar* enModVarp = static_cast(nodep->modVarp()->user1p()); + AstVar* const enModVarp = static_cast(nodep->modVarp()->user1p()); if (!enModVarp) { // May have an output only that later connects to a tristate, so simplify now. V3Inst::pinReconnectSimple(nodep, m_cellp, false); @@ -1147,7 +1149,7 @@ class TristateVisitor final : public TristateBaseVisitor { && !nodep->modVarp()->declDirection().isWritable()); if (!nodep->exprp()) { // No-connect; covert to empty connection UINFO(5, "Unconnected pin terminate " << nodep << endl); - AstVar* ucVarp = getCreateUnconnVarp(nodep, nodep->modVarp()->dtypep()); + AstVar* const ucVarp = getCreateUnconnVarp(nodep, nodep->modVarp()->dtypep()); nodep->exprp(new AstVarRef(nodep->fileline(), ucVarp, // We converted, so use declaration output state nodep->modVarp()->declDirection().isWritable() @@ -1158,7 +1160,8 @@ class TristateVisitor final : public TristateBaseVisitor { } else if (inDeclProcessing) { // Not an input that was a converted tristate // Input only may have driver in underneath module which would stomp // the input value. So make a temporary connection. - AstAssignW* reAssignp = V3Inst::pinReconnectSimple(nodep, m_cellp, true, true); + AstAssignW* const reAssignp + = V3Inst::pinReconnectSimple(nodep, m_cellp, true, true); UINFO(5, "Input pin buffering: " << reAssignp << endl); m_tgraph.setTristate(reAssignp->lhsp()); } @@ -1169,12 +1172,12 @@ class TristateVisitor final : public TristateBaseVisitor { // Create the output enable pin, connect to new signal AstNode* enrefp; { - AstVar* enVarp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, - nodep->name() + "__en" + cvtToStr(m_unique++), - VFlagBitPacked(), enModVarp->width()); + AstVar* const enVarp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, + nodep->name() + "__en" + cvtToStr(m_unique++), + VFlagBitPacked(), enModVarp->width()); enModVarp->direction(VDirection::INPUT); UINFO(9, " newenv " << enVarp << endl); - AstPin* enpinp + AstPin* const enpinp = new AstPin(nodep->fileline(), nodep->pinNum(), enModVarp->name(), // should be {var}"__en" new AstVarRef(nodep->fileline(), enVarp, VAccess::WRITE)); @@ -1190,7 +1193,7 @@ class TristateVisitor final : public TristateBaseVisitor { // Create new output pin AstAssignW* outAssignp = nullptr; // If reconnected, the related assignment AstPin* outpinp = nullptr; - AstVar* outModVarp = static_cast(nodep->modVarp()->user4p()); + AstVar* const outModVarp = static_cast(nodep->modVarp()->user4p()); if (!outModVarp) { // At top, no need for __out as might be input only. Otherwise resolvable. if (!m_modp->isTop()) { @@ -1198,7 +1201,8 @@ class TristateVisitor final : public TristateBaseVisitor { << nodep->prettyNameQ()); } } else { - AstNode* outexprp = nodep->exprp()->cloneTree(false); // Note has lvalue() set + AstNode* const outexprp + = nodep->exprp()->cloneTree(false); // Note has lvalue() set outpinp = new AstPin(nodep->fileline(), nodep->pinNum(), outModVarp->name(), // should be {var}"__out" outexprp); @@ -1225,7 +1229,7 @@ class TristateVisitor final : public TristateBaseVisitor { // Existing pin becomes an input, and we mark each resulting signal as tristate TristatePinVisitor visitor{nodep->exprp(), m_tgraph, false}; - AstNode* inAssignp = V3Inst::pinReconnectSimple( + AstNode* const inAssignp = V3Inst::pinReconnectSimple( nodep, m_cellp, true); // Note may change nodep->exprp() if (debug() >= 9) nodep->dumpTree(cout, "-pin-in: "); if (debug() >= 9 && inAssignp) inAssignp->dumpTree(cout, "-pin-as: "); @@ -1264,7 +1268,7 @@ class TristateVisitor final : public TristateBaseVisitor { // Propagate any pullups/pulldowns upwards if necessary if (exprrefp) { - if (AstPull* pullp = static_cast(nodep->modVarp()->user3p())) { + if (AstPull* const pullp = static_cast(nodep->modVarp()->user3p())) { UINFO(9, "propagate pull on " << exprrefp << endl); setPullDirection(exprrefp->varp(), pullp); } @@ -1309,7 +1313,7 @@ class TristateVisitor final : public TristateBaseVisitor { && m_tgraph.feedsTri(nodep)) { // Then propagate the enable from the original variable UINFO(9, " Ref-to-tri " << nodep << endl); - AstVar* enVarp = getCreateEnVarp(nodep->varp()); + AstVar* const enVarp = getCreateEnVarp(nodep->varp()); nodep->user1p(new AstVarRef(nodep->fileline(), enVarp, VAccess::READ)); } if (m_alhs) {} // NOP; user1() already passed down from assignment @@ -1324,7 +1328,7 @@ class TristateVisitor final : public TristateBaseVisitor { if (nodep->user2() & U2_GRAPHING) return; // Already processed nodep->user2(U2_GRAPHING); if (nodep->isPulldown() || nodep->isPullup()) { - AstNode* newp = new AstPull( + AstNode* const newp = new AstPull( nodep->fileline(), new AstVarRef(nodep->fileline(), nodep, VAccess::WRITE), nodep->isPullup()); UINFO(9, " newpul " << newp << endl); diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index ccf6ea283..90b67a78e 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -86,7 +86,7 @@ private: msb = bit; } } else if (prev) { - AstBasicDType* bdtypep = m_varp->basicp(); + const AstBasicDType* const bdtypep = m_varp->basicp(); const int lsb = bit + 1; if (bits != "") bits += ","; if (lsb == msb) { @@ -148,7 +148,7 @@ public: } void reportViolations() { // Combine bits into overall state - AstVar* nodep = m_varp; + AstVar* const nodep = m_varp; { bool allU = true; bool allD = true; diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index b8a259949..70f4dc99f 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -91,9 +91,9 @@ private: if (m_assigndlyp) { // Delayed assignments become normal assignments, // then the temp created becomes the delayed assignment - AstNode* newp = new AstAssign(m_assigndlyp->fileline(), - m_assigndlyp->lhsp()->unlinkFrBackWithNext(), - m_assigndlyp->rhsp()->unlinkFrBackWithNext()); + AstNode* const newp = new AstAssign(m_assigndlyp->fileline(), + m_assigndlyp->lhsp()->unlinkFrBackWithNext(), + m_assigndlyp->rhsp()->unlinkFrBackWithNext()); m_assigndlyp->replaceWith(newp); VL_DO_CLEAR(pushDeletep(m_assigndlyp), m_assigndlyp = nullptr); } @@ -103,16 +103,16 @@ private: while (VN_IS(prep->backp(), NodeSel) || VN_IS(prep->backp(), Sel)) { prep = prep->backp(); } - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); VL_DANGLING(nodep); // Zap it so we don't use it by mistake - use prep // Already exists; rather than IF(a,... IF(b... optimize to IF(a&&b, // Saves us teaching V3Const how to optimize, and it won't be needed again. - if (AstIf* ifp = VN_AS(prep->user2p(), If)) { + if (const AstIf* const ifp = VN_AS(prep->user2p(), If)) { UASSERT_OBJ(!needDly, prep, "Should have already converted to non-delay"); AstNRelinker replaceHandle; - AstNode* earliercondp = ifp->condp()->unlinkFrBack(&replaceHandle); - AstNode* newp = new AstLogAnd(condp->fileline(), condp, earliercondp); + AstNode* const earliercondp = ifp->condp()->unlinkFrBack(&replaceHandle); + AstNode* const newp = new AstLogAnd(condp->fileline(), condp, earliercondp); UINFO(4, "Edit BOUNDLVALUE " << newp << endl); replaceHandle.relink(newp); } else { @@ -363,7 +363,7 @@ private: iterateChildren(nodep); if (!nodep->user1SetOnce()) { // Guard against reading/writing past end of bit vector array - AstNode* basefromp = AstArraySel::baseFromp(nodep, true); + const AstNode* basefromp = AstArraySel::baseFromp(nodep, true); bool lvalue = false; if (const AstNodeVarRef* varrefp = VN_CAST(basefromp, NodeVarRef)) { lvalue = varrefp->access().isWriteOrRW(); diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index e3353c4c0..2c5efb113 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -85,12 +85,12 @@ private: return bodySizeOverRecurse(nodep->nextp(), bodySize, bodyLimit); } - bool - forUnrollCheck(AstNode* nodep, - AstNode* initp, // Maybe under nodep (no nextp), or standalone (ignore nextp) - AstNode* precondsp, AstNode* condp, - AstNode* incp, // Maybe under nodep or in bodysp - AstNode* bodysp) { + bool forUnrollCheck( + AstNode* nodep, + AstNode* const initp, // Maybe under nodep (no nextp), or standalone (ignore nextp) + AstNode* const precondsp, AstNode* condp, + AstNode* const incp, // Maybe under nodep or in bodysp + AstNode* bodysp) { // To keep the IF levels low, we return as each test fails. UINFO(4, " FOR Check " << nodep << endl); if (initp) UINFO(6, " Init " << initp << endl); @@ -99,7 +99,7 @@ private: if (incp) UINFO(6, " Inc " << incp << endl); // Initial value check - AstAssign* initAssp = VN_CAST(initp, Assign); + AstAssign* const initAssp = VN_CAST(initp, Assign); if (!initAssp) return cantUnroll(nodep, "no initial assignment"); UASSERT_OBJ(!(initp->nextp() && initp->nextp() != nodep), nodep, "initial assignment shouldn't be a list"); @@ -111,7 +111,7 @@ private: UASSERT_OBJ(!condp->nextp(), nodep, "conditional shouldn't be a list"); // // Assignment of next value check - AstAssign* incAssp = VN_CAST(incp, Assign); + const AstAssign* const incAssp = VN_CAST(incp, Assign); if (!incAssp) return cantUnroll(nodep, "no increment assignment"); if (incAssp->nextp()) return cantUnroll(nodep, "multiple increments"); @@ -131,7 +131,7 @@ private: // however, for repeat loops, the loop variable is auto-generated // and the initp statements will reference a variable outside of the initp scope // alas, failing to simulate. - AstConst* constInitp = VN_CAST(initAssp->rhsp(), Const); + const AstConst* const constInitp = VN_CAST(initAssp->rhsp(), Const); if (!constInitp) return cantUnroll(nodep, "non-constant initializer"); // @@ -155,7 +155,7 @@ private: if (debug() >= 9) nodep->dumpTree(cout, "- for: "); if (!m_generate) { - AstAssign* incpAssign = VN_AS(incp, Assign); + const AstAssign* const incpAssign = VN_AS(incp, Assign); if (!canSimulate(incpAssign->rhsp())) { return cantUnroll(incp, "Unable to simulate increment"); } @@ -255,7 +255,7 @@ private: outLoopsr++; // Run inc - AstAssign* incpass = VN_AS(incp, Assign); + AstAssign* const incpass = VN_AS(incp, Assign); V3Number newLoopValue = V3Number(initp); if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) { return false; @@ -315,7 +315,7 @@ private: // Iteration requires a back, so put under temporary node if (oneloopp) { - AstBegin* tempp + AstBegin* const tempp = new AstBegin(oneloopp->fileline(), "[EditWrapper]", oneloopp); m_varModeReplace = true; iterateAndNextNull(tempp->stmtsp()); @@ -345,7 +345,7 @@ private: } // loopValue += valInc - AstAssign* incpass = VN_AS(incp, Assign); + AstAssign* const incpass = VN_AS(incp, Assign); V3Number newLoopValue = V3Number(nodep); if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) { nodep->v3error("Loop unrolling failed"); @@ -452,7 +452,7 @@ private: if (m_varModeReplace && nodep->varp() == m_forVarp && nodep->varScopep() == m_forVscp && nodep->access().isReadOnly()) { - AstNode* newconstp = m_varValuep->cloneTree(false); + AstNode* const newconstp = m_varValuep->cloneTree(false); nodep->replaceWith(newconstp); pushDeletep(nodep); } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 5f6647ab6..d53574c2f 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -112,7 +112,7 @@ std::ostream& operator<<(std::ostream& str, const Castable& rhs) { class WidthVP final { // Parameters to pass down hierarchy with visit functions. - AstNodeDType* m_dtypep; // Parent's data type to resolve to + AstNodeDType* const m_dtypep; // Parent's data type to resolve to Stage m_stage; // If true, report errors public: WidthVP(AstNodeDType* dtypep, Stage stage) @@ -475,8 +475,8 @@ private: } } if (m_vup->final()) { - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); - AstNodeDType* subDTypep = expDTypep; + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const subDTypep = expDTypep; nodep->dtypeFrom(expDTypep); // Error report and change sizes for suboperands of this node. iterateCheck(nodep, "Conditional True", nodep->expr1p(), CONTEXT, FINAL, subDTypep, @@ -492,20 +492,20 @@ private: // LHS, RHS is self-determined // signed: Unsigned (11.8.1) // width: LHS + RHS - AstNodeDType* vdtypep = m_vup->dtypeNullSkipRefp(); + AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp(); userIterate(vdtypep, WidthVP(SELF, BOTH).p()); if (VN_IS(vdtypep, QueueDType)) { // Queue "element 0" is lhsp, so we need to swap arguments - auto* newp = new AstConsQueue(nodep->fileline(), nodep->rhsp()->unlinkFrBack(), - nodep->lhsp()->unlinkFrBack()); + auto* const newp = new AstConsQueue(nodep->fileline(), nodep->rhsp()->unlinkFrBack(), + nodep->lhsp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); userIterateChildren(newp, m_vup); return; } if (VN_IS(vdtypep, DynArrayDType)) { - auto* newp = new AstConsDynArray(nodep->fileline(), nodep->rhsp()->unlinkFrBack(), - nodep->lhsp()->unlinkFrBack()); + auto* const newp = new AstConsDynArray( + nodep->fileline(), nodep->rhsp()->unlinkFrBack(), nodep->lhsp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); userIterateChildren(newp, m_vup); @@ -526,14 +526,14 @@ private: VSigning::UNSIGNED); // Cleanup zero width Verilog2001 {x,{0{foo}}} now, // otherwise having width(0) will cause later assertions to fire - if (AstReplicate* repp = VN_CAST(nodep->lhsp(), Replicate)) { + if (const AstReplicate* const repp = VN_CAST(nodep->lhsp(), Replicate)) { if (repp->width() == 0) { // Keep rhs nodep->replaceWith(nodep->rhsp()->unlinkFrBack()); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; } } - if (AstReplicate* repp = VN_CAST(nodep->rhsp(), Replicate)) { + if (const AstReplicate* const repp = VN_CAST(nodep->rhsp(), Replicate)) { if (repp->width() == 0) { // Keep lhs nodep->replaceWith(nodep->lhsp()->unlinkFrBack()); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -543,8 +543,9 @@ private: } if (m_vup->final()) { if (nodep->lhsp()->isString() || nodep->rhsp()->isString()) { - AstNode* newp = new AstConcatN(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), - nodep->rhsp()->unlinkFrBack()); + AstNode* const newp + = new AstConcatN(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), + nodep->rhsp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; @@ -601,7 +602,7 @@ private: || (!nodep->stmtsp()->nextp() && !nodep->joinType().joinNone())) { AstNode* stmtsp = nullptr; if (nodep->stmtsp()) stmtsp = nodep->stmtsp()->unlinkFrBack(); - AstBegin* newp = new AstBegin{nodep->fileline(), nodep->name(), stmtsp}; + AstBegin* const newp = new AstBegin{nodep->fileline(), nodep->name(), stmtsp}; nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else { @@ -636,7 +637,7 @@ private: if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->rhsp()); // rhsp may change - const AstConst* constp = VN_CAST(nodep->rhsp(), Const); + const AstConst* const constp = VN_CAST(nodep->rhsp(), Const); if (!constp) { nodep->v3error("Replication value isn't a constant."); return; @@ -649,7 +650,7 @@ private: times = 1; } - AstNodeDType* vdtypep = m_vup->dtypeNullSkipRefp(); + AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp(); if (VN_IS(vdtypep, QueueDType) || VN_IS(vdtypep, DynArrayDType)) { if (times != 1) nodep->v3warn(E_UNSUPPORTED, "Unsupported: Non-1 replication to form " @@ -668,8 +669,9 @@ private: } iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); if (nodep->lhsp()->isString()) { - AstNode* newp = new AstReplicateN(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), - nodep->rhsp()->unlinkFrBack()); + AstNode* const newp + = new AstReplicateN(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), + nodep->rhsp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; @@ -693,7 +695,7 @@ private: iterateCheckString(nodep, "LHS", nodep->lhsp(), BOTH); iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->rhsp()); // rhsp may change - const AstConst* constp = VN_CAST(nodep->rhsp(), Const); + const AstConst* const constp = VN_CAST(nodep->rhsp(), Const); if (!constp) { nodep->v3error("Replication value isn't a constant."); return; @@ -719,14 +721,14 @@ private: iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "RHS", nodep->rhsp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->rhsp()); // rhsp may change - const AstConst* constp = VN_CAST(nodep->rhsp(), Const); - AstBasicDType* basicp = VN_CAST(nodep->rhsp(), BasicDType); + const AstConst* const constp = VN_CAST(nodep->rhsp(), Const); + AstBasicDType* const basicp = VN_CAST(nodep->rhsp(), BasicDType); if (!constp && !basicp) { nodep->v3error("Slice size isn't a constant or basic data type."); return; } if (basicp) { // Convert data type to a constant size - AstConst* newp = new AstConst(basicp->fileline(), basicp->width()); + AstConst* const newp = new AstConst(basicp->fileline(), basicp->width()); nodep->rhsp()->replaceWith(newp); pushDeletep(basicp); } else { @@ -787,7 +789,7 @@ private: iterateCheckSizedSelf(nodep, "Select Width", nodep->widthp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "Select LHS", nodep->lhsp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->widthp()); // widthp may change - AstConst* widthConstp = VN_CAST(nodep->widthp(), Const); + AstConst* const widthConstp = VN_CAST(nodep->widthp(), Const); if (!widthConstp) { nodep->v3error("Width of bit extract isn't a constant"); nodep->dtypeSetBit(); @@ -808,7 +810,7 @@ private: nodep->v3warn(SELRANGE, "Extracting " << width << " bits from only " << nodep->fromp()->width() << " bit number"); // Extend it. - AstNodeDType* subDTypep + AstNodeDType* const subDTypep = nodep->findLogicDType(width, width, nodep->fromp()->dtypep()->numeric()); widthCheckSized(nodep, "errorless...", nodep->fromp(), subDTypep, EXTEND_EXP, false /*noerror*/); @@ -828,7 +830,7 @@ private: // nodep->v3fatalSrc("Should have been declRanged in V3WidthSel"); } const int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit - AstNodeDType* selwidthDTypep + AstNodeDType* const selwidthDTypep = nodep->findLogicDType(selwidth, selwidth, nodep->lsbp()->dtypep()->numeric()); userIterateAndNext(nodep->fromp(), WidthVP(SELF, FINAL).p()); userIterateAndNext(nodep->lsbp(), WidthVP(SELF, FINAL).p()); @@ -890,8 +892,8 @@ private: // int frommsb; int fromlsb; - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefp(); - if (const AstUnpackArrayDType* adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); + if (const AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { frommsb = adtypep->hi(); fromlsb = adtypep->lo(); if (fromlsb > frommsb) { @@ -909,7 +911,7 @@ private: frommsb = fromlsb = 0; } const int selwidth = V3Number::log2b(frommsb + 1 - 1) + 1; // Width to address a bit - AstNodeDType* selwidthDTypep + AstNodeDType* const selwidthDTypep = nodep->findLogicDType(selwidth, selwidth, nodep->bitp()->dtypep()->numeric()); if (widthBad(nodep->bitp(), selwidthDTypep) && nodep->bitp()->width() != 32) { nodep->v3warn(WIDTH, "Bit extraction of array[" @@ -945,8 +947,8 @@ private: virtual void visit(AstAssocSel* nodep) override { // Signed/Real: Output type based on array-declared type; binary operator if (m_vup->prelim()) { - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefp(); - AstAssocArrayDType* adtypep = VN_CAST(fromDtp, AssocArrayDType); + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); + AstAssocArrayDType* const adtypep = VN_CAST(fromDtp, AssocArrayDType); if (!adtypep) { UINFO(1, " Related dtype: " << fromDtp << endl); nodep->v3fatalSrc("Associative array reference is not to associative array"); @@ -963,14 +965,14 @@ private: userIterateAndNext(nodep->fromp(), WidthVP(SELF, BOTH).p()); // // Array indices are always constant - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefp(); - AstUnpackArrayDType* adtypep = VN_CAST(fromDtp, UnpackArrayDType); + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); + AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType); if (!adtypep) { UINFO(1, " Related dtype: " << fromDtp << endl); nodep->v3fatalSrc("Packed array reference exceeds dimension of array"); } // Build new array Dtype based on the original's base type, but with new bounds - AstNodeDType* newDtp + AstNodeDType* const newDtp = new AstUnpackArrayDType(nodep->fileline(), adtypep->subDTypep(), new AstRange(nodep->fileline(), nodep->declRange())); v3Global.rootp()->typeTablep()->addTypesp(newDtp); @@ -1007,7 +1009,7 @@ private: userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->thsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->attrp(), WidthVP(SELF, BOTH).p()); - AstNode* selp = V3Width::widthSelNoIterEdit(nodep); + AstNode* const selp = V3Width::widthSelNoIterEdit(nodep); if (selp != nodep) { nodep = nullptr; userIterate(selp, m_vup); @@ -1021,7 +1023,7 @@ private: userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->thsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->attrp(), WidthVP(SELF, BOTH).p()); - AstNode* selp = V3Width::widthSelNoIterEdit(nodep); + AstNode* const selp = V3Width::widthSelNoIterEdit(nodep); if (selp != nodep) { nodep = nullptr; userIterate(selp, m_vup); @@ -1034,7 +1036,7 @@ private: userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->thsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->attrp(), WidthVP(SELF, BOTH).p()); - AstNode* selp = V3Width::widthSelNoIterEdit(nodep); + AstNode* const selp = V3Width::widthSelNoIterEdit(nodep); if (selp != nodep) { nodep = nullptr; userIterate(selp, m_vup); @@ -1047,7 +1049,7 @@ private: userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->thsp(), WidthVP(CONTEXT, PRELIM).p()); // FINAL in AstSel userIterateAndNext(nodep->attrp(), WidthVP(SELF, BOTH).p()); - AstNode* selp = V3Width::widthSelNoIterEdit(nodep); + AstNode* const selp = V3Width::widthSelNoIterEdit(nodep); if (selp != nodep) { nodep = nullptr; userIterate(selp, m_vup); @@ -1097,7 +1099,7 @@ private: if (nodep->ticksp()) { iterateCheckSizedSelf(nodep, "Ticks", nodep->ticksp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->ticksp()); // ticksp may change - const AstConst* constp = VN_CAST(nodep->ticksp(), Const); + const AstConst* const constp = VN_CAST(nodep->ticksp(), Const); if (!constp) { nodep->v3error("$past tick value must be constant (IEEE 1800-2017 16.9.3)"); nodep->ticksp()->unlinkFrBack()->deleteTree(); @@ -1156,7 +1158,7 @@ private: virtual void visit(AstURandomRange* nodep) override { if (m_vup->prelim()) { nodep->dtypeSetUInt32(); // Says the spec - AstNodeDType* expDTypep = nodep->findUInt32DType(); + AstNodeDType* const expDTypep = nodep->findUInt32DType(); userIterateAndNext(nodep->lhsp(), WidthVP(CONTEXT, PRELIM).p()); userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); iterateCheck(nodep, "LHS", nodep->lhsp(), SELF, FINAL, expDTypep, EXTEND_EXP); @@ -1167,11 +1169,11 @@ private: nodep->dtypeSetSigned32(); // Used in int context if (VN_IS(nodep->backp(), IsUnbounded)) return; // Ok, leave if (VN_IS(nodep->backp(), BracketArrayDType)) return; // Ok, leave - if (auto* varp = VN_CAST(nodep->backp(), Var)) { + if (auto* const varp = VN_CAST(nodep->backp(), Var)) { if (varp->isParam()) return; // Ok, leave } // queue_slice[#:$] - if (auto* selp = VN_CAST(nodep->backp(), SelExtract)) { + if (auto* const selp = VN_CAST(nodep->backp(), SelExtract)) { if (VN_IS(selp->fromp()->dtypep(), QueueDType)) { nodep->replaceWith( new AstConst(nodep->fileline(), AstConst::Signed32(), 0x7FFFFFFF)); @@ -1195,7 +1197,7 @@ private: userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } if (m_vup->final()) { - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); nodep->dtypeFrom(expDTypep); // Assume user knows the rules; go with the flow if (nodep->width() > 64) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: $c can't generate wider than 64 bits"); @@ -1229,7 +1231,7 @@ private: } if (m_vup->final()) { - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); nodep->dtypeFrom(expDTypep); // rhs already finalized in iterate_shift_prelim iterateCheck(nodep, "LHS", nodep->lhsp(), SELF, FINAL, nodep->dtypep(), EXTEND_EXP); @@ -1300,14 +1302,14 @@ private: // LHS is a real number in seconds // Need to round to time units and precision userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); - AstConst* constp = VN_CAST(nodep->lhsp(), Const); + AstConst* const constp = VN_CAST(nodep->lhsp(), Const); if (!constp || !constp->isDouble()) nodep->v3fatalSrc("Times should be doubles"); if (nodep->timeunit().isNone()) nodep->v3fatalSrc("$time import no units"); double time = constp->num().toDouble(); if (v3Global.rootp()->timeprecision().isNone()) nodep->v3fatalSrc("Never set precision?"); time /= nodep->timeunit().multiplier(); // IEEE claims you should round to time precision here, but no simulator seems to do this - AstConst* newp = new AstConst(nodep->fileline(), AstConst::RealDouble(), time); + AstConst* const newp = new AstConst(nodep->fileline(), AstConst::RealDouble(), time); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -1352,7 +1354,7 @@ private: if (VN_IS(nodep->fromp()->dtypep(), QueueDType)) { switch (nodep->attrType()) { case AstAttrType::DIM_SIZE: { - AstNode* newp = new AstCMethodHard( + AstNode* const newp = new AstCMethodHard( nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", nullptr); newp->dtypeSetSigned32(); newp->didWidth(true); @@ -1363,19 +1365,19 @@ private: } case AstAttrType::DIM_LEFT: case AstAttrType::DIM_LOW: { - AstNode* newp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); + AstNode* const newp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); break; } case AstAttrType::DIM_RIGHT: case AstAttrType::DIM_HIGH: { - AstNode* sizep = new AstCMethodHard( + AstNode* const sizep = new AstCMethodHard( nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", nullptr); sizep->dtypeSetSigned32(); sizep->didWidth(true); sizep->protect(false); - AstNode* newp + AstNode* const newp = new AstSub(nodep->fileline(), sizep, new AstConst(nodep->fileline(), AstConst::Signed32(), 1)); nodep->replaceWith(newp); @@ -1383,7 +1385,8 @@ private: break; } case AstAttrType::DIM_INCREMENT: { - AstNode* newp = new AstConst(nodep->fileline(), AstConst::Signed32(), -1); + AstNode* const newp + = new AstConst(nodep->fileline(), AstConst::Signed32(), -1); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); break; @@ -1400,25 +1403,26 @@ private: uint32_t msbdim = dimpair.first + dimpair.second; if (!nodep->dimp() || msbdim < 1) { const int dim = 1; - AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(), - nodep->attrType(), dim); + AstConst* const newp = dimensionValue( + nodep->fileline(), nodep->fromp()->dtypep(), nodep->attrType(), dim); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (VN_IS(nodep->dimp(), Const)) { const int dim = VN_AS(nodep->dimp(), Const)->toSInt(); - AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(), - nodep->attrType(), dim); + AstConst* const newp = dimensionValue( + nodep->fileline(), nodep->fromp()->dtypep(), nodep->attrType(), dim); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else { // Need a runtime lookup table. Yuk. UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression"); - AstVar* varp + AstVar* const varp = dimensionVarp(nodep->fromp()->dtypep(), nodep->attrType(), msbdim); - AstNode* dimp = nodep->dimp()->unlinkFrBack(); - AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); + AstNode* const dimp = nodep->dimp()->unlinkFrBack(); + AstVarRef* const varrefp + = new AstVarRef(nodep->fileline(), varp, VAccess::READ); varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); - AstNode* newp = new AstArraySel(nodep->fileline(), varrefp, dimp); + AstNode* const newp = new AstArraySel(nodep->fileline(), varrefp, dimp); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -1428,7 +1432,7 @@ private: case AstAttrType::TYPENAME: { UASSERT_OBJ(nodep->fromp(), nodep, "Unprovided expression"); const string result = nodep->fromp()->dtypep()->prettyDTypeName(); - AstNode* newp = new AstConst(nodep->fileline(), AstConst::String(), result); + AstNode* const newp = new AstConst(nodep->fileline(), AstConst::String(), result); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); break; @@ -1455,12 +1459,12 @@ private: if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed if (nodep->subDTypep() == nodep->basicp()) { // Innermost dimension - AstBasicDType* basicp = nodep->basicp(); + AstBasicDType* const basicp = nodep->basicp(); // If basic dtype is LOGIC_IMPLICIT, it is actually 1 bit LOGIC if (basicp->implicit()) { UASSERT_OBJ(basicp->width() <= 1, basicp, "must be 1 bit but actually " << basicp->width() << " bits"); - AstBasicDType* newp = new AstBasicDType( + AstBasicDType* const newp = new AstBasicDType( basicp->fileline(), AstBasicDTypeKwd::LOGIC, basicp->numeric()); newp->widthForce(1, 1); basicp->replaceWith(newp); @@ -1472,7 +1476,7 @@ private: // Cleanup array size userIterateAndNext(nodep->rangep(), WidthVP(SELF, BOTH).p()); nodep->dtypep(nodep); // The array itself, not subDtype - if (auto* adtypep = VN_CAST(nodep, UnpackArrayDType)) { + if (auto* const adtypep = VN_CAST(nodep, UnpackArrayDType)) { // Historically array elements have width of the ref type not the full array nodep->widthFromSub(nodep->subDTypep()); if (nodep->subDTypep()->skipRefp()->isCompound()) adtypep->isCompound(true); @@ -1496,9 +1500,9 @@ private: userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); // We must edit when dtype still under normal nodes and before type table // See notes in iterateEditMoveDTypep - AstNodeDType* childp = nodep->childDTypep(); + AstNodeDType* const childp = nodep->childDTypep(); childp->unlinkFrBack(); - AstNode* elementsp = nodep->elementsp()->unlinkFrBack(); + AstNode* const elementsp = nodep->elementsp()->unlinkFrBack(); AstNode* newp; if (VN_IS(elementsp, Unbounded)) { newp = new AstQueueDType(nodep->fileline(), VFlagChildDType(), childp, nullptr); @@ -1593,7 +1597,7 @@ private: if (nodep->typeofp()) { // type(typeofp_expression) // Type comes from expression's type userIterateAndNext(nodep->typeofp(), WidthVP(SELF, BOTH).p()); - AstNode* typeofp = nodep->typeofp(); + AstNode* const typeofp = nodep->typeofp(); nodep->typedefp(nullptr); nodep->refDTypep(typeofp->dtypep()); VL_DO_DANGLING(typeofp->unlinkFrBack()->deleteTree(), typeofp); @@ -1621,7 +1625,7 @@ private: } virtual void visit(AstTypedef* nodep) override { if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed - if (auto* refp = checkRefToTypedefRecurse(nodep, nodep)) { + if (auto* const refp = checkRefToTypedefRecurse(nodep, nodep)) { nodep->v3error("Typedef has self-reference: " << nodep->prettyNameQ() << '\n' << nodep->warnContextPrimary() << '\n' << refp->warnOther() @@ -1644,9 +1648,9 @@ private: virtual void visit(AstCastDynamic* nodep) override { nodep->dtypeChgWidthSigned(32, 1, VSigning::SIGNED); // Spec says integer return userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); - AstNodeDType* toDtp = nodep->top()->dtypep()->skipRefToEnump(); - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); - FileLine* fl = nodep->fileline(); + AstNodeDType* const toDtp = nodep->top()->dtypep()->skipRefToEnump(); + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); + FileLine* const fl = nodep->fileline(); const auto castable = computeCastable(toDtp, fromDtp, nodep->fromp()); AstNode* newp; if (castable == DYNAMIC_CLASS) { @@ -1657,16 +1661,17 @@ private: // elimination should do much the same // Form: "( ((v > size) ? false : enum_valid[v[N:0]]) // ? ExprStmt(ExprAssign(out, Cast(v, type)), 1) : 0)" - auto* enumDtp = VN_AS(toDtp, EnumDType); + auto* const enumDtp = VN_AS(toDtp, EnumDType); UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type"); uint64_t maxval = enumMaxValue(nodep, enumDtp); const int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit - AstVar* varp = enumVarp(enumDtp, AstAttrType::ENUM_VALID, (1ULL << selwidth) - 1); - AstVarRef* varrefp = new AstVarRef(fl, varp, VAccess::READ); + AstVar* const varp + = enumVarp(enumDtp, AstAttrType::ENUM_VALID, (1ULL << selwidth) - 1); + AstVarRef* const varrefp = new AstVarRef(fl, varp, VAccess::READ); varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); - FileLine* fl_nowarn = new FileLine(fl); + FileLine* const fl_nowarn = new FileLine(fl); fl_nowarn->warnOff(V3ErrorCode::WIDTH, true); - auto* testp = new AstCond{ + auto* const testp = new AstCond{ fl, new AstGt{fl_nowarn, nodep->fromp()->cloneTree(false), new AstConst{fl_nowarn, AstConst::Unsized64{}, maxval}}, @@ -1712,9 +1717,9 @@ private: // nodep->dtp could be data type, or a primary_constant // Don't iterate lhsp, will deal with that once convert the type V3Const::constifyParamsEdit(nodep->dtp()); // itemp may change - if (AstConst* constp = VN_CAST(nodep->dtp(), Const)) { + if (AstConst* const constp = VN_CAST(nodep->dtp(), Const)) { constp->unlinkFrBack(); - AstNode* newp + AstNode* const newp = new AstCastSize(nodep->fileline(), nodep->lhsp()->unlinkFrBack(), constp); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -1730,8 +1735,8 @@ private: if (m_vup->prelim()) { // if (debug()) nodep->dumpTree(cout, " CastPre: "); userIterateAndNext(nodep->fromp(), WidthVP(SELF, PRELIM).p()); - AstNodeDType* toDtp = nodep->dtypep()->skipRefToEnump(); - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); + AstNodeDType* const toDtp = nodep->dtypep()->skipRefToEnump(); + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); const auto castable = computeCastable(toDtp, fromDtp, nodep->fromp()); bool bad = false; if (castable == UNSUPPORTED) { @@ -1805,7 +1810,7 @@ private: if (m_vup->final()) { iterateCheck(nodep, "value", nodep->lhsp(), SELF, FINAL, nodep->lhsp()->dtypep(), EXTEND_EXP, false); - AstNode* underp = nodep->lhsp()->unlinkFrBack(); + AstNode* const underp = nodep->lhsp()->unlinkFrBack(); if (debug()) underp->dumpTree(cout, " CastRep: "); nodep->replaceWith(underp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -1827,7 +1832,7 @@ private: } if (m_vup->final()) { // CastSize not needed once sizes determined - AstNode* underp = nodep->lhsp()->unlinkFrBack(); + AstNode* const underp = nodep->lhsp()->unlinkFrBack(); underp->dtypeFrom(nodep); nodep->replaceWith(underp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -1848,7 +1853,7 @@ private: // So two steps, first do the calculation's width (max of the two widths) { const int calcWidth = std::max(width, underDtp->width()); - AstNodeDType* calcDtp + AstNodeDType* const calcDtp = (underDtp->isFourstate() ? nodep->findLogicDType(calcWidth, calcWidth, underDtp->numeric()) : nodep->findBitDType(calcWidth, calcWidth, underDtp->numeric())); @@ -1861,9 +1866,10 @@ private: // if (debug()) nodep->dumpTree(cout, " CastSizeClc: "); // Next step, make the proper output width { - AstNodeDType* outDtp = (underDtp->isFourstate() - ? nodep->findLogicDType(width, width, underDtp->numeric()) - : nodep->findBitDType(width, width, underDtp->numeric())); + AstNodeDType* const outDtp + = (underDtp->isFourstate() + ? nodep->findLogicDType(width, width, underDtp->numeric()) + : nodep->findBitDType(width, width, underDtp->numeric())); nodep->dtypep(outDtp); // We ignore warnings as that is sort of the point of a cast widthCheckSized(nodep, "Cast expr", underp, outDtp, EXTEND_EXP, false); @@ -1889,10 +1895,11 @@ private: // Make sure dtype is sized nodep->dtypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); UASSERT_OBJ(nodep->dtypep(), nodep, "No dtype determined for var"); - if (AstUnsizedArrayDType* unsizedp = VN_CAST(nodep->dtypeSkipRefp(), UnsizedArrayDType)) { + if (AstUnsizedArrayDType* const unsizedp + = VN_CAST(nodep->dtypeSkipRefp(), UnsizedArrayDType)) { if (!(m_ftaskp && m_ftaskp->dpiImport())) { UINFO(9, "Unsized becomes dynamic array " << nodep << endl); - AstDynArrayDType* newp + AstDynArrayDType* const newp = new AstDynArrayDType(unsizedp->fileline(), unsizedp->subDTypep()); nodep->dtypep(newp); v3Global.rootp()->typeTablep()->addTypesp(newp); @@ -1900,7 +1907,7 @@ private: } if (VN_IS(nodep->dtypep()->skipRefToConstp(), ConstDType)) nodep->isConst(true); // Parameters if implicit untyped inherit from what they are assigned to - AstBasicDType* bdtypep = VN_CAST(nodep->dtypep(), BasicDType); + AstBasicDType* const bdtypep = VN_CAST(nodep->dtypep(), BasicDType); bool didchk = false; const bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit(); if (implicitParam) { @@ -1916,7 +1923,7 @@ private: VL_DANGLING(bdtypep); } else { int width = 0; - AstBasicDType* valueBdtypep = nodep->valuep()->dtypep()->basicp(); + AstBasicDType* const valueBdtypep = nodep->valuep()->dtypep()->basicp(); bool issigned = false; if (bdtypep->isNosign()) { if (valueBdtypep && valueBdtypep->isSigned()) issigned = true; @@ -2052,7 +2059,7 @@ private: itemp->valuep(new AstConst(itemp->fileline(), num)); } - AstConst* constp = VN_AS(itemp->valuep(), Const); + AstConst* const constp = VN_AS(itemp->valuep(), Const); if (constp->num().isFourState() && nodep->dtypep()->basicp() && !nodep->dtypep()->basicp()->isFourstate()) { itemp->v3error("Enum value with X/Zs cannot be assigned to non-fourstate type " @@ -2061,7 +2068,7 @@ private: num.opAssign(constp->num()); // Look for duplicates if (inits.find(num) != inits.end()) { // IEEE says illegal - AstNode* otherp = inits.find(num)->second; + AstNode* const otherp = inits.find(num)->second; itemp->v3error("Overlapping enumeration value: " << itemp->prettyNameQ() << '\n' << itemp->warnContextPrimary() << '\n' @@ -2075,7 +2082,7 @@ private: } virtual void visit(AstEnumItem* nodep) override { UINFO(5, " ENUMITEM " << nodep << endl); - AstNodeDType* vdtypep = m_vup->dtypep(); + AstNodeDType* const vdtypep = m_vup->dtypep(); UASSERT_OBJ(vdtypep, nodep, "ENUMITEM not under ENUM"); nodep->dtypep(vdtypep); if (nodep->valuep()) { // else the value will be assigned sequentially @@ -2102,7 +2109,7 @@ private: } virtual void visit(AstConsAssoc* nodep) override { // Type computed when constructed here - auto* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); + auto* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsAssoc requires assoc upper parent data type"); if (m_vup->prelim()) { nodep->dtypeFrom(vdtypep); @@ -2114,7 +2121,7 @@ private: } virtual void visit(AstSetAssoc* nodep) override { // Type computed when constructed here - auto* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); + auto* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType); UASSERT_OBJ(vdtypep, nodep, "SetsAssoc requires assoc upper parent data type"); if (m_vup->prelim()) { nodep->dtypeFrom(vdtypep); @@ -2127,7 +2134,7 @@ private: } virtual void visit(AstConsDynArray* nodep) override { // Type computed when constructed here - AstDynArrayDType* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), DynArrayDType); + AstDynArrayDType* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), DynArrayDType); UASSERT_OBJ(vdtypep, nodep, "ConsDynArray requires queue upper parent data type"); if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, PRELIM).p()); @@ -2159,7 +2166,7 @@ private: } virtual void visit(AstConsQueue* nodep) override { // Type computed when constructed here - AstQueueDType* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), QueueDType); + AstQueueDType* const vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), QueueDType); UASSERT_OBJ(vdtypep, nodep, "ConsQueue requires queue upper parent data type"); if (m_vup->prelim()) { userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, PRELIM).p()); diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 6a4ff4289..ca2523f96 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -60,8 +60,8 @@ private: // RETURN TYPE struct FromData { - AstNodeDType* m_errp; // Node that was found, for error reporting if not known type - AstNodeDType* m_dtypep; // Data type for the 'from' slice + AstNodeDType* const m_errp; // Node that was found, for error reporting if not known type + AstNodeDType* const m_dtypep; // Data type for the 'from' slice VNumRange m_fromRange; // Numeric range bounds for the 'from' slice FromData(AstNodeDType* errp, AstNodeDType* dtypep, const VNumRange& fromRange) : m_errp{errp} @@ -81,10 +81,10 @@ private: break; } UASSERT_OBJ(basefromp && basefromp->dtypep(), nodep, "Select with no from dtype"); - AstNodeDType* ddtypep = basefromp->dtypep()->skipRefp(); - AstNodeDType* errp = ddtypep; + AstNodeDType* const ddtypep = basefromp->dtypep()->skipRefp(); + AstNodeDType* const errp = ddtypep; UINFO(9, " fromData.ddtypep = " << ddtypep << endl); - if (const AstNodeArrayDType* adtypep = VN_CAST(ddtypep, NodeArrayDType)) { + if (const AstNodeArrayDType* const adtypep = VN_CAST(ddtypep, NodeArrayDType)) { fromRange = adtypep->declRange(); } else if (VN_IS(ddtypep, AssocArrayDType)) { } else if (VN_IS(ddtypep, DynArrayDType)) { @@ -122,16 +122,17 @@ private: V3Number num(lhsp, lhsp->width()); num.opSub(VN_AS(lhsp, Const)->num(), V3Number(lhsp, 32, rhs)); num.isSigned(lhsp->isSigned()); - AstNode* newp = new AstConst(lhsp->fileline(), num); + AstNode* const newp = new AstConst(lhsp->fileline(), num); return newp; } else if (rhs > 0) { - AstNode* newp = new AstSub(lhsp->fileline(), lhsp, - new AstConst(lhsp->fileline(), AstConst::Unsized32(), rhs)); + AstNode* const newp + = new AstSub(lhsp->fileline(), lhsp, + new AstConst(lhsp->fileline(), AstConst::Unsized32(), rhs)); // We must make sure sub gets sign of original value, not from the constant newp->dtypeFrom(lhsp); return newp; } else { // rhs < 0; - AstNode* newp + AstNode* const newp = new AstAdd(lhsp->fileline(), lhsp, new AstConst(lhsp->fileline(), AstConst::Unsized32(), -rhs)); // We must make sure sub gets sign of original value, not from the constant @@ -142,7 +143,7 @@ private: AstNode* newSubNeg(vlsint32_t lhs, AstNode* rhsp) { // Return lhs-rhs // We must make sure sub gets sign of original value - AstNode* newp = new AstSub( + AstNode* const newp = new AstSub( rhsp->fileline(), new AstConst(rhsp->fileline(), AstConst::Unsized32(), lhs), rhsp); newp->dtypeFrom(rhsp); // Important as AstSub default is lhs's sign return newp; @@ -160,11 +161,11 @@ private: } else { if (fromRange.littleEndian()) { // reg [1:3] was swapped to [3:1] (lsbEndianedp==3) and needs a SUB(3,under) - AstNode* newp = newSubNeg(fromRange.hi(), underp); + AstNode* const newp = newSubNeg(fromRange.hi(), underp); return newp; } else { // reg [3:1] needs a SUB(under,1) - AstNode* newp = newSubNeg(underp, fromRange.lo()); + AstNode* const newp = newSubNeg(underp, fromRange.lo()); return newp; } } @@ -179,7 +180,7 @@ private: // Need a slice data type, which is an array of the extracted // type, but with (presumably) different size VNumRange newRange(msb, lsb, nodep->declRange().littleEndian()); - AstNodeDType* vardtypep + AstNodeDType* const vardtypep = new AstPackArrayDType(nodep->fileline(), nodep->subDTypep(), // Need to strip off array reference new AstRange(nodep->fileline(), newRange)); @@ -204,20 +205,20 @@ private: UINFO(6, "SELBIT " << nodep << endl); if (debug() >= 9) nodep->backp()->dumpTree(cout, "--SELBT0: "); // lhsp/rhsp do not need to be constant - AstNode* fromp = nodep->fromp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); // bit we're extracting + AstNode* const fromp = nodep->fromp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); // bit we're extracting if (debug() >= 9) nodep->dumpTree(cout, "--SELBT2: "); const FromData fromdata = fromDataForArray(nodep, fromp); - AstNodeDType* ddtypep = fromdata.m_dtypep; + AstNodeDType* const ddtypep = fromdata.m_dtypep; const VNumRange fromRange = fromdata.m_fromRange; UINFO(6, " ddtypep " << ddtypep << endl); - if (AstUnpackArrayDType* adtypep = VN_CAST(ddtypep, UnpackArrayDType)) { + if (AstUnpackArrayDType* const adtypep = VN_CAST(ddtypep, UnpackArrayDType)) { // SELBIT(array, index) -> ARRAYSEL(array, index) AstNode* subp = rhsp; if (fromRange.lo() != 0 || fromRange.hi() < 0) { subp = newSubNeg(subp, fromRange.lo()); } - AstArraySel* newp = new AstArraySel(nodep->fileline(), fromp, subp); + AstArraySel* const newp = new AstArraySel(nodep->fileline(), fromp, subp); newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off array reference if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); nodep->replaceWith(newp); @@ -235,7 +236,7 @@ private: "Array extraction with width miscomputed " << adtypep->width() << "/" << fromRange.elements()); const int elwidth = adtypep->width() / fromRange.elements(); - AstSel* newp = new AstSel( + AstSel* const newp = new AstSel( nodep->fileline(), fromp, new AstMul(nodep->fileline(), new AstConst(nodep->fileline(), AstConst::Unsized32(), elwidth), subp), @@ -248,31 +249,31 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (AstAssocArrayDType* adtypep = VN_CAST(ddtypep, AssocArrayDType)) { // SELBIT(array, index) -> ASSOCSEL(array, index) - AstNode* subp = rhsp; - AstAssocSel* newp = new AstAssocSel(nodep->fileline(), fromp, subp); + AstNode* const subp = rhsp; + AstAssocSel* const newp = new AstAssocSel(nodep->fileline(), fromp, subp); newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off array reference if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (AstDynArrayDType* adtypep = VN_CAST(ddtypep, DynArrayDType)) { // SELBIT(array, index) -> CMETHODCALL(queue, "at", index) - AstNode* subp = rhsp; - AstCMethodHard* newp = new AstCMethodHard(nodep->fileline(), fromp, "at", subp); + AstNode* const subp = rhsp; + AstCMethodHard* const newp = new AstCMethodHard(nodep->fileline(), fromp, "at", subp); newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off queue reference if (debug() >= 9) newp->dumpTree(cout, "--SELBTq: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (AstQueueDType* adtypep = VN_CAST(ddtypep, QueueDType)) { // SELBIT(array, index) -> CMETHODCALL(queue, "at", index) - AstNode* subp = rhsp; - AstCMethodHard* newp = new AstCMethodHard(nodep->fileline(), fromp, "at", subp); + AstNode* const subp = rhsp; + AstCMethodHard* const newp = new AstCMethodHard(nodep->fileline(), fromp, "at", subp); newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off queue reference if (debug() >= 9) newp->dumpTree(cout, "--SELBTq: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(ddtypep, BasicDType) && ddtypep->isString()) { // SELBIT(string, index) -> GETC(string, index) - AstNodeVarRef* varrefp = VN_CAST(fromp, NodeVarRef); + AstNodeVarRef* const varrefp = VN_CAST(fromp, NodeVarRef); if (!varrefp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: String array operation on non-variable"); @@ -288,9 +289,10 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(ddtypep, BasicDType)) { // SELBIT(range, index) -> SEL(array, index, 1) - AstSel* newp = new AstSel(nodep->fileline(), fromp, newSubLsbOf(rhsp, fromRange), - // Unsized so width from user - new AstConst(nodep->fileline(), AstConst::Unsized32(), 1)); + AstSel* const newp + = new AstSel(nodep->fileline(), fromp, newSubLsbOf(rhsp, fromRange), + // Unsized so width from user + new AstConst(nodep->fileline(), AstConst::Unsized32(), 1)); newp->declRange(fromRange); UINFO(6, " new " << newp << endl); if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); @@ -298,9 +300,10 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(ddtypep, NodeUOrStructDType)) { // A bit from the packed struct // SELBIT(range, index) -> SEL(array, index, 1) - AstSel* newp = new AstSel(nodep->fileline(), fromp, newSubLsbOf(rhsp, fromRange), - // Unsized so width from user - new AstConst(nodep->fileline(), AstConst::Unsized32(), 1)); + AstSel* const newp + = new AstSel(nodep->fileline(), fromp, newSubLsbOf(rhsp, fromRange), + // Unsized so width from user + new AstConst(nodep->fileline(), AstConst::Unsized32(), 1)); newp->declRange(fromRange); UINFO(6, " new " << newp << endl); if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); @@ -329,14 +332,14 @@ private: "First value of [a:b] isn't a constant, maybe you want +: or -:"); checkConstantOrReplace(nodep->rightp(), "Second value of [a:b] isn't a constant, maybe you want +: or -:"); - AstNode* fromp = nodep->fromp()->unlinkFrBack(); - AstNode* msbp = nodep->rhsp()->unlinkFrBack(); - AstNode* lsbp = nodep->thsp()->unlinkFrBack(); + AstNode* const fromp = nodep->fromp()->unlinkFrBack(); + AstNode* const msbp = nodep->rhsp()->unlinkFrBack(); + AstNode* const lsbp = nodep->thsp()->unlinkFrBack(); vlsint32_t msb = VN_AS(msbp, Const)->toSInt(); vlsint32_t lsb = VN_AS(lsbp, Const)->toSInt(); vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1); const FromData fromdata = fromDataForArray(nodep, fromp); - AstNodeDType* ddtypep = fromdata.m_dtypep; + AstNodeDType* const ddtypep = fromdata.m_dtypep; const VNumRange fromRange = fromdata.m_fromRange; if (VN_IS(ddtypep, UnpackArrayDType)) { // Slice extraction @@ -345,11 +348,11 @@ private: nodep->replaceWith(fromp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (fromRange.elements() == 1) { // Extracting single element - AstArraySel* newp = new AstArraySel(nodep->fileline(), fromp, lsbp); + AstArraySel* const newp = new AstArraySel(nodep->fileline(), fromp, lsbp); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else { // Slice - AstSliceSel* newp + AstSliceSel* const newp = new AstSliceSel{nodep->fileline(), fromp, VNumRange{msb - fromRange.lo(), lsb - fromRange.lo()}}; nodep->replaceWith(newp); @@ -379,7 +382,7 @@ private: lsb = x; } const int elwidth = adtypep->width() / fromRange.elements(); - AstSel* newp = new AstSel( + AstSel* const newp = new AstSel( nodep->fileline(), fromp, new AstMul(nodep->fileline(), newSubLsbOf(lsbp, fromRange), new AstConst(nodep->fileline(), AstConst::Unsized32(), elwidth)), @@ -408,10 +411,11 @@ private: msb = lsb; lsb = x; } - AstNode* widthp = new AstConst(msbp->fileline(), - AstConst::Unsized32(), // Unsized so width from user - msb + 1 - lsb); - AstSel* newp + AstNode* const widthp + = new AstConst(msbp->fileline(), + AstConst::Unsized32(), // Unsized so width from user + msb + 1 - lsb); + AstSel* const newp = new AstSel(nodep->fileline(), fromp, newSubLsbOf(lsbp, fromRange), widthp); newp->declRange(fromRange); UINFO(6, " new " << newp << endl); @@ -430,10 +434,11 @@ private: msb = lsb; lsb = x; } - AstNode* widthp = new AstConst(msbp->fileline(), - AstConst::Unsized32(), // Unsized so width from user - msb + 1 - lsb); - AstSel* newp + AstNode* const widthp + = new AstConst(msbp->fileline(), + AstConst::Unsized32(), // Unsized so width from user + msb + 1 - lsb); + AstSel* const newp = new AstSel(nodep->fileline(), fromp, newSubLsbOf(lsbp, fromRange), widthp); newp->declRange(fromRange); UINFO(6, " new " << newp << endl); @@ -441,7 +446,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(ddtypep, QueueDType)) { - auto* newp = new AstCMethodHard(nodep->fileline(), fromp, "slice", msbp); + auto* const newp = new AstCMethodHard(nodep->fileline(), fromp, "slice", msbp); msbp->addNext(lsbp); newp->dtypep(ddtypep); newp->didWidth(true); @@ -475,9 +480,9 @@ private: checkConstantOrReplace(nodep->thsp(), "Width of :+ or :- bit extract isn't a constant"); if (debug() >= 9) nodep->dumpTree(cout, "--SELPM3: "); // Now replace it with an AstSel - AstNode* fromp = nodep->fromp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); - AstNode* widthp = nodep->thsp()->unlinkFrBack(); + AstNode* const fromp = nodep->fromp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); + AstNode* const widthp = nodep->thsp()->unlinkFrBack(); warnTri(rhsp); const int width = VN_AS(widthp, Const)->toSInt(); if (width > (1 << 28)) { @@ -486,7 +491,7 @@ private: } if (width < 0) nodep->v3error("Width of :+ or :- is < 0: " << widthp->prettyName()); const FromData fromdata = fromDataForArray(nodep, fromp); - AstNodeDType* ddtypep = fromdata.m_dtypep; + AstNodeDType* const ddtypep = fromdata.m_dtypep; const VNumRange fromRange = fromdata.m_fromRange; if (VN_IS(ddtypep, UnpackArrayDType)) { // Slice +: and -: extraction @@ -496,7 +501,7 @@ private: nodep->replaceWith(fromp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (fromRange.elements() == 1) { // Extracting single element - AstArraySel* newp = new AstArraySel(nodep->fileline(), fromp, rhsp); + AstArraySel* const newp = new AstArraySel(nodep->fileline(), fromp, rhsp); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(rhsp, Const)) { // Slice @@ -507,8 +512,8 @@ private: // up array: lsb/hi -: width vlsint32_t msb = VN_IS(nodep, SelPlus) ? rhs + width - 1 : rhs; vlsint32_t lsb = VN_IS(nodep, SelPlus) ? rhs : rhs - width + 1; - AstSliceSel* newp = new AstSliceSel(nodep->fileline(), fromp, - VNumRange(msb, lsb, fromRange.littleEndian())); + AstSliceSel* const newp = new AstSliceSel( + nodep->fileline(), fromp, VNumRange(msb, lsb, fromRange.littleEndian())); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else { @@ -519,7 +524,7 @@ private: && VN_AS(ddtypep, NodeUOrStructDType)->packedUnsup())) { int elwidth = 1; AstNode* newwidthp = widthp; - if (const AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) { + if (const AstPackArrayDType* const adtypep = VN_CAST(ddtypep, PackArrayDType)) { elwidth = adtypep->width() / fromRange.elements(); newwidthp = new AstConst(nodep->fileline(), AstConst::Unsized32(), width * elwidth); @@ -548,7 +553,7 @@ private: newlsbp = new AstMul(nodep->fileline(), newlsbp, new AstConst(nodep->fileline(), elwidth)); } - AstSel* newp = new AstSel(nodep->fileline(), fromp, newlsbp, newwidthp); + AstSel* const newp = new AstSel(nodep->fileline(), fromp, newlsbp, newwidthp); newp->declRange(fromRange); newp->declElWidth(elwidth); UINFO(6, " new " << newp << endl); diff --git a/src/VlcTop.cpp b/src/VlcTop.cpp index 219218232..a36b50d7a 100644 --- a/src/VlcTop.cpp +++ b/src/VlcTop.cpp @@ -157,7 +157,7 @@ void VlcTop::rank() { VlcBuckets remaining; for (const auto& i : m_points) { - VlcPoint* const pointp = &points().pointNumber(i.second); + const VlcPoint* const pointp = &points().pointNumber(i.second); // If any tests hit this point, then we'll need to cover it. if (pointp->testsCovering()) remaining.addData(pointp->pointNum(), 1); } From c496649c493a8a14fa5538005ef84fdbf8bd4a00 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 14:48:21 -0500 Subject: [PATCH 35/79] Internals: Remove unused DfaGraph code. --- nodist/code_coverage.dat | 4 - src/Makefile_obj.in | 1 - src/V3Assert.cpp | 1 - src/V3GraphDfa.cpp | 607 --------------------------- src/V3GraphDfa.h | 152 ------- src/V3GraphTest.cpp | 68 +-- test_regress/t/t_debug_graph_test.pl | 2 +- 7 files changed, 3 insertions(+), 832 deletions(-) delete mode 100644 src/V3GraphDfa.cpp delete mode 100644 src/V3GraphDfa.h diff --git a/nodist/code_coverage.dat b/nodist/code_coverage.dat index d725dad4b..88c21b5f1 100644 --- a/nodist/code_coverage.dat +++ b/nodist/code_coverage.dat @@ -23,10 +23,6 @@ source_globs("include/*/*.c") # Note *'s are removed when using fastcov remove_source("/usr/*") remove_source("*/include/sysc/*") -remove_source("*/V3ClkGater.cpp") -remove_source("*/V3ClkGater.h") -remove_source("*/V3GraphDfa.cpp") -remove_source("*/V3GraphDfa.h") remove_source("*/V3Lexer_pregen.yy.cpp") remove_source("*/V3PreLex_pregen.yy.cpp") remove_source("*/verilog.c") diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index abb5f1a36..c2e832bdc 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -203,7 +203,6 @@ RAW_OBJS = \ V3Graph.o \ V3GraphAlg.o \ V3GraphAcyc.o \ - V3GraphDfa.o \ V3GraphPathChecker.o \ V3GraphTest.o \ V3Hash.o \ diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 196113a02..72803b93e 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -20,7 +20,6 @@ #include "V3Global.h" #include "V3Assert.h" #include "V3Ast.h" -#include "V3GraphDfa.h" #include "V3Stats.h" //###################################################################### diff --git a/src/V3GraphDfa.cpp b/src/V3GraphDfa.cpp deleted file mode 100644 index f004fdbc4..000000000 --- a/src/V3GraphDfa.cpp +++ /dev/null @@ -1,607 +0,0 @@ -// -*- mode: C++; c-file-style: "cc-mode" -*- -//************************************************************************* -// DESCRIPTION: Verilator: Graph optimizations -// -// Code available from: https://verilator.org -// -//************************************************************************* -// -// Copyright 2005-2021 by Wilson Snyder. This program is free software; you -// can redistribute it and/or modify it under the terms of either the GNU -// Lesser General Public License Version 3 or the Perl Artistic License -// Version 2.0. -// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 -// -//************************************************************************* - -#include "config_build.h" -#include "verilatedos.h" - -#include "V3Global.h" -#include "V3GraphDfa.h" -#include "V3GraphAlg.h" - -#include -#include -#include - -//###################################################################### -//###################################################################### -// Algorithms - find starting node - -DfaVertex* DfaGraph::findStart() { - DfaVertex* startp = nullptr; - for (V3GraphVertex* vertexp = this->verticesBeginp(); vertexp; - vertexp = vertexp->verticesNextp()) { - if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { - if (vvertexp->start()) { - UASSERT_OBJ(!startp, vertexp, "Multiple start points in NFA graph"); - startp = vvertexp; - } - } else { - vertexp->v3fatalSrc("Non DfaVertex in DfaGraph"); - } - } - if (!startp) v3fatalSrc("No start point in NFA graph"); - return startp; -} - -//###################################################################### -//###################################################################### -// Algorithms - convert NFA to a DFA -// Uses the Subset Construction Algorithm - -class GraphNfaToDfa final : GraphAlg<> { - // We have two types of nodes in one graph, NFA and DFA nodes. - // Edges from NFA to NFA come from the user, and indicate input or epsilon transitions - // Edges from DFA to NFA indicate the NFA from which that DFA was formed. - // Edges from DFA to DFA indicate a completed input transition -private: - // TYPES - using DfaStates = std::deque; - using HashMap = std::multimap; - - // MEMBERS - uint32_t m_step; // Processing step, so we can avoid clearUser all the time - HashMap m_hashMap; // Dfa Vertex for each set of NFA vertexes - -#ifdef VL_CPPCHECK - static int debug() { return 9; } -#else - static int debug() { return 0; } -#endif - - // METHODS - DfaGraph* graphp() { return static_cast(m_graphp); } - static bool nfaState(V3GraphVertex* vertexp) { return vertexp->color() == 0; } - // static bool dfaState(V3GraphVertex* vertexp) { return vertexp->color()==1; } - - void nextStep() { m_step++; } - - bool unseenNfaThisStep(V3GraphVertex* vertexp) { - // A nfa node not already seen this processing step - return (nfaState(vertexp) && !(vertexp->user() == m_step)); - } - - DfaVertex* newDfaVertex(DfaVertex* nfaTemplatep = nullptr) { - DfaVertex* const vertexp = new DfaVertex(graphp()); - vertexp->color(1); // Mark as dfa - if (nfaTemplatep && nfaTemplatep->start()) vertexp->start(true); - if (nfaTemplatep && nfaTemplatep->accepting()) vertexp->accepting(true); - UINFO(9, " New " << vertexp << endl); - return vertexp; - } - - // Hashing - static uint32_t hashVertex(V3GraphVertex* vertexp) { - union { - const void* up; - struct { - uint32_t upper; - uint32_t lower; - } l; - } u; - u.l.upper = 0; - u.l.lower = 0; - u.up = vertexp; - return u.l.upper ^ u.l.lower; - } - - uint32_t hashDfaOrigins(DfaVertex* dfaStatep) { - // Find the NFA states this dfa came from, - // Record a checksum, so we can search for it later by the list of nfa nodes. - // The order of the nodes is not deterministic; the hash thus must - // not depend on order of edges - uint32_t hash = 0; - // Foreach NFA state (this DFA state was formed from) - if (debug()) nextStep(); - for (V3GraphEdge* dfaEdgep = dfaStatep->outBeginp(); dfaEdgep; - dfaEdgep = dfaEdgep->outNextp()) { - if (nfaState(dfaEdgep->top())) { - DfaVertex* const nfaStatep = static_cast(dfaEdgep->top()); - hash ^= hashVertex(nfaStatep); - if (debug()) { - UASSERT_OBJ(nfaStatep->user() != m_step, nfaStatep, - "DFA state points to duplicate NFA state."); - nfaStatep->user(m_step); - } - } - } - return hash; - } - - uint32_t hashDfaOrigins(const DfaStates& nfasWithInput) { - // Find the NFA states this dfa came from, - uint32_t hash = 0; - for (DfaVertex* nfaStatep : nfasWithInput) hash ^= hashVertex(nfaStatep); - return hash; - } - - bool compareDfaOrigins(const DfaStates& nfasWithInput, DfaVertex* dfa2p) { - // Return true if the NFA nodes both DFAs came from are the same list - // Assume there are no duplicates in either input list or NFAs under dfa2 - nextStep(); - // Mark all input vertexes - int num1s = 0; - for (DfaVertex* nfaStatep : nfasWithInput) { - nfaStatep->user(m_step); - num1s++; - } - if (!num1s) v3fatalSrc("DFA node construction that contains no NFA states"); - - // Check comparison; must all be marked - // (Check all in dfa2p were in dfa1p) - int num2s = 0; - for (V3GraphEdge* dfaEdgep = dfa2p->outBeginp(); dfaEdgep; - dfaEdgep = dfaEdgep->outNextp()) { - if (nfaState(dfaEdgep->top())) { - if (dfaEdgep->top()->user() != m_step) return false; - num2s++; - } - } - // If we saw all of the nodes, then they have the same number of hits - // (Else something in dfa1p that wasn't in dfa2p) - return (num1s == num2s); - } - - void insertDfaOrigins(DfaVertex* dfaStatep) { - // Record the NFA states this dfa came from - uint32_t hash = hashDfaOrigins(dfaStatep); - m_hashMap.emplace(hash, dfaStatep); - } - - DfaVertex* findDfaOrigins(const DfaStates& nfasWithInput) { - // Find another DFA state which comes from the identical set of NFA states - // The order of the nodes is not deterministic; the hash thus must - // not depend on order of edges - uint32_t hash = hashDfaOrigins(nfasWithInput); - - const auto eqrange = m_hashMap.equal_range(hash); - for (auto it = eqrange.first; it != eqrange.second; ++it) { - DfaVertex* const testp = it->second; - if (compareDfaOrigins(nfasWithInput, testp)) { - UINFO(9, " DFA match for set: " << testp << endl); - return testp; // Identical - } - } - return nullptr; // No match - } - - void findNfasWithInput(DfaVertex* dfaStatep, const DfaInput& input, DfaStates& nfasWithInput) { - // Return all NFA states, with the given input transition from - // the nfa states a given dfa state was constructed from. - nextStep(); - nfasWithInput.clear(); // NFAs with given input - - // Foreach NFA state (this DFA state was formed from) - for (V3GraphEdge* dfaEdgep = dfaStatep->outBeginp(); dfaEdgep; - dfaEdgep = dfaEdgep->outNextp()) { - if (nfaState(dfaEdgep->top())) { - const DfaVertex* const nfaStatep = static_cast(dfaEdgep->top()); - // Foreach input transition (on this nfaStatep) - for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; - nfaEdgep = nfaEdgep->outNextp()) { - const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); - if (cNfaEdgep->input().toNodep() == input.toNodep()) { - DfaVertex* const nextStatep = static_cast(cNfaEdgep->top()); - if (unseenNfaThisStep(nextStatep)) { // Not processed? - nfasWithInput.push_back(nextStatep); - nextStatep->user(m_step); - UINFO(9, " Reachable " << nextStatep << endl); - } - } - } - } - } - - // Expand the nfasWithInput list to include epsilon states - // reachable by those on nfasWithInput - { - DfaStates nfasTodo = nfasWithInput; - nfasWithInput.clear(); // Now the completed list - while (!nfasTodo.empty()) { - DfaVertex* const nfaStatep = nfasTodo.front(); - nfasTodo.pop_front(); - nfasWithInput.push_back(nfaStatep); - // Foreach epsilon-reachable (on this nfaStatep) - for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; - nfaEdgep = nfaEdgep->outNextp()) { - const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); - if (cNfaEdgep->epsilon()) { - DfaVertex* const nextStatep = static_cast(cNfaEdgep->top()); - if (unseenNfaThisStep(nextStatep)) { // Not processed? - nfasTodo.push_back(nextStatep); - nextStatep->user(m_step); - UINFO(9, " Epsilon Reachable " << nextStatep << endl); - } - } - } - } - } - } - - void main() { - UINFO(5, "Dfa to Nfa conversion...\n"); - // Vertex::color() begin: 1 indicates vertex on DFA graph, 0=NFA graph - m_graphp->clearColors(); - // Vertex::m_user begin: # indicates processed this m_step number - m_graphp->userClearVertices(); - - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("dfa_nfa"); - - // Find NFA start - DfaVertex* const nfaStartp = graphp()->findStart(); - - // Create new DFA State (start state) from the NFA states - DfaVertex* const dfaStartp = newDfaVertex(nfaStartp); - - DfaStates dfaUnprocps; // Unprocessed DFA nodes - dfaUnprocps.push_back(dfaStartp); - - UINFO(5, "Starting state conversion...\n"); - // Form DFA starting state from epsilon closure of NFA start - nextStep(); - DfaStates workps; - workps.push_back(nfaStartp); - - while (!workps.empty()) { // While work - DfaVertex* const nfaStatep = workps.back(); - workps.pop_back(); - // UINFO(9," Processing "<user(m_step); // Mark as processed - // Add a edge so we can find NFAs from a given DFA. - // The NFA will never see this edge, because we only look at TO edges. - new DfaEdge(graphp(), dfaStartp, nfaStatep, DfaEdge::NA()); - // Find epsilon closure of this nfa node, and destinations to work list - for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; - nfaEdgep = nfaEdgep->outNextp()) { - const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); - DfaVertex* const ecNfaStatep = static_cast(nfaEdgep->top()); - // UINFO(9," Consider "<top()<<" EP "<epsilon()<epsilon() && unseenNfaThisStep(ecNfaStatep)) { // Not processed? - workps.push_back(ecNfaStatep); - } - } - } - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("dfa_start"); - insertDfaOrigins(dfaStartp); - - int i = 0; - UINFO(5, "Main state conversion...\n"); - while (!dfaUnprocps.empty()) { - DfaVertex* const dfaStatep = dfaUnprocps.back(); - dfaUnprocps.pop_back(); - UINFO(9, " On dfaState " << dfaStatep << endl); - - // From this dfaState, what corresponding nfaStates have what inputs? - std::unordered_set inputs; - // Foreach NFA state (this DFA state was formed from) - for (V3GraphEdge* dfaEdgep = dfaStatep->outBeginp(); dfaEdgep; - dfaEdgep = dfaEdgep->outNextp()) { - if (nfaState(dfaEdgep->top())) { - const DfaVertex* const nfaStatep = static_cast(dfaEdgep->top()); - // Foreach input on this nfaStatep - for (V3GraphEdge* nfaEdgep = nfaStatep->outBeginp(); nfaEdgep; - nfaEdgep = nfaEdgep->outNextp()) { - const DfaEdge* const cNfaEdgep = static_cast(nfaEdgep); - if (!cNfaEdgep->epsilon()) { - if (inputs.find(cNfaEdgep->input().toInt()) == inputs.end()) { - inputs.insert(cNfaEdgep->input().toInt()); - UINFO(9, " Input to " << dfaStatep << " is " - << (cNfaEdgep->input().toInt()) << " via " - << nfaStatep << endl); - } - } - } - } - } - - // Foreach input state (NFA inputs of this DFA state) - for (int inIt : inputs) { - const DfaInput input = inIt; - UINFO(9, " ===" << ++i << "=======================\n"); - UINFO(9, " On input " << cvtToHex(input.toNodep()) << endl); - - // Find all states reachable for given input - DfaStates nfasWithInput; - findNfasWithInput(dfaStatep, input, nfasWithInput /*ref*/); - - // nfasWithInput now maps to the DFA we want a transition to. - // Does a DFA already exist with this, and only this subset of NFA's? - DfaVertex* toDfaStatep = findDfaOrigins(nfasWithInput); - if (!toDfaStatep) { - // Doesn't exist, make new dfa state corresponding to this one, - toDfaStatep = newDfaVertex(); - dfaUnprocps.push_back(toDfaStatep); // Add to process list - // Track what nfa's point to it. - for (DfaStates::const_iterator nfaIt = nfasWithInput.begin(); - nfaIt != nfasWithInput.end(); ++nfaIt) { - UINFO(9, " NewContainsNfa " << *nfaIt << endl); - new DfaEdge(graphp(), toDfaStatep, *nfaIt, DfaEdge::NA()); - if ((*nfaIt)->accepting()) toDfaStatep->accepting(true); - } - insertDfaOrigins(toDfaStatep); - } - // Add input transition - new DfaEdge(graphp(), dfaStatep, toDfaStatep, input); - - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("step"); - } - } - - // Remove old NFA states - UINFO(5, "Removing NFA states...\n"); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("dfa_withnfa"); - for (V3GraphVertex *nextp, *vertexp = m_graphp->verticesBeginp(); vertexp; - vertexp = nextp) { - nextp = vertexp->verticesNextp(); - if (nfaState(vertexp)) VL_DO_DANGLING(vertexp->unlinkDelete(m_graphp), vertexp); - } - - UINFO(5, "Done.\n"); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("dfa_done"); - } - -public: - GraphNfaToDfa(V3Graph* graphp, V3EdgeFuncP edgeFuncp) - : GraphAlg<>{graphp, edgeFuncp} { - m_step = 0; - main(); - } - ~GraphNfaToDfa() = default; -}; - -void DfaGraph::nfaToDfa() { GraphNfaToDfa(this, &V3GraphEdge::followAlwaysTrue); } - -//###################################################################### -//###################################################################### -// Algorithms - optimize a DFA structure -// -// Scan the DFA, cleaning up trailing states. - -class DfaGraphReduce final : GraphAlg<> { -private: - // METHODS -#ifdef VL_CPPCHECK - static int debug() { return 9; } -#else - static int debug() { return 0; } -#endif - DfaGraph* graphp() { return static_cast(m_graphp); } - - bool isDead(DfaVertex* vertexp) { - // A state is dead if not accepting, and goes nowhere - if (vertexp->accepting() || vertexp->start()) return false; - for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - if (edgep->top() != vertexp) return false; - } - return true; - } - - void optimize_accepting_out() { - // Delete outbound edges from accepting states - // (As once we've accepted, we no longer care about anything else.) - for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; - vertexp = vertexp->verticesNextp()) { - if (const DfaVertex* const vvertexp = dynamic_cast(vertexp)) { - if (vvertexp->accepting()) { - for (V3GraphEdge *nextp, *edgep = vertexp->outBeginp(); edgep; edgep = nextp) { - nextp = edgep->outNextp(); - VL_DO_DANGLING(edgep->unlinkDelete(), edgep); - } - } - } - } - } - - void optimize_orphans() { - // Remove states that don't come from start - // Presumably the previous optimization orphaned them. - - // Vertex::m_user begin: 1 indicates on the work list, 2 processed - // (Otherwise we might have nodes on the list twice, and reference after deleting them.) - m_graphp->userClearVertices(); - - DfaVertex* const startp = graphp()->findStart(); - std::stack workps; - workps.push(startp); - - // Mark all nodes connected to start - while (!workps.empty()) { - V3GraphVertex* vertexp = workps.top(); - workps.pop(); - vertexp->user(2); // Processed - // Add nodes from here to the work list - for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - V3GraphVertex* tovertexp = edgep->top(); - if (!tovertexp->user()) { - workps.push(tovertexp); - tovertexp->user(1); - } - } - } - - // Delete all nodes not connected - for (V3GraphVertex *nextp, *vertexp = m_graphp->verticesBeginp(); vertexp; - vertexp = nextp) { - nextp = vertexp->verticesNextp(); - if (!vertexp->user()) VL_DO_DANGLING(vertexp->unlinkDelete(m_graphp), vertexp); - } - } - - void optimize_no_outbound() { - // Non-accepting states with no outbound transitions may be - // deleted. Then, any arcs feeding those states, and perhaps those - // states... - - // Vertex::m_user begin: 1 indicates on the work list - // (Otherwise we might have nodes on the list twice, and reference after deleting them.) - m_graphp->userClearVertices(); - - // Find all dead vertexes - std::stack workps; - for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; - vertexp = vertexp->verticesNextp()) { - if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { - workps.push(vvertexp); - vertexp->user(1); - } else { - // If ever remove this, need dyn cast below - vertexp->v3fatalSrc("Non DfaVertex in dfa graph"); - } - } - - // While deadness... Delete and find new dead nodes. - while (!workps.empty()) { - DfaVertex* const vertexp = workps.top(); - workps.pop(); - vertexp->user(0); - if (isDead(vertexp)) { - // Add nodes that go here to the work list - for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - DfaVertex* const fromvertexp = static_cast(edgep->fromp()); - if (fromvertexp != vertexp && !fromvertexp->user()) { - workps.push(fromvertexp); - fromvertexp->user(1); - } - } - // Transitions to this state removed by the unlink function - VL_DO_DANGLING(vertexp->unlinkDelete(m_graphp), vertexp); - } - } - } - -public: - DfaGraphReduce(V3Graph* graphp, V3EdgeFuncP edgeFuncp) - : GraphAlg<>{graphp, edgeFuncp} { - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("opt_in"); - optimize_accepting_out(); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("opt_acc"); - optimize_orphans(); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("opt_orph"); - optimize_no_outbound(); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("opt_noout"); - } - ~DfaGraphReduce() = default; -}; - -void DfaGraph::dfaReduce() { DfaGraphReduce(this, &V3GraphEdge::followAlwaysTrue); } - -//###################################################################### -//###################################################################### -// Algorithms - complement a DFA -// -// The traditional algorithm is to make a rejecting state, add edges to -// reject from all missing values, then swap accept and reject. Rather -// than swap at the end, it's faster if we swap up front, then do the edge -// changes. -// -// 1. Since we didn't log rejecting states, make a temp state (this will be -// the old accept, and new reject). -// -// 2. All vertexes except start/accept get edges to NEW accept for any -// non-existing case. Weedely we don't have a nice way of representing -// this so we just create a edge for each case and mark it "complemented." -// -// 3. Delete temp vertex (old accept/new reject) and related edges. -// The user's old accept is now the new accept. This is important as -// we want the virtual type of it to be intact. - -class DfaGraphComplement final : GraphAlg<> { -private: - // MEMBERS - DfaVertex* m_tempNewerReject; - - // METHODS - static int debug() { return 9; } - DfaGraph* graphp() { return static_cast(m_graphp); } - - void add_complement_edges() { - // Find accepting vertex - DfaVertex* acceptp = nullptr; - for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; - vertexp = vertexp->verticesNextp()) { - if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { - if (vvertexp->accepting()) { - acceptp = vvertexp; - break; - } - } - } - if (!acceptp) v3fatalSrc("No accepting vertex in DFA"); - - // Remap edges - for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; - vertexp = vertexp->verticesNextp()) { - if (DfaVertex* const vvertexp = dynamic_cast(vertexp)) { - // UINFO(9, " on vertex "<name()<accepting() && vvertexp != m_tempNewerReject) { - for (V3GraphEdge *nextp, *edgep = vertexp->outBeginp(); edgep; edgep = nextp) { - nextp = edgep->outNextp(); - if (!edgep->user()) { // Not processed - // Old edges to accept now go to new reject - const DfaEdge* const vedgep = static_cast(edgep); - const DfaVertex* const tovertexp - = static_cast(edgep->top()); - if (tovertexp->accepting()) { - new DfaEdge(graphp(), vvertexp, m_tempNewerReject, vedgep); - VL_DO_DANGLING(edgep->unlinkDelete(), edgep); - } - - // NOT of all values goes to accept - // We make a edge for each value to OR, IE - // edge(complemented,a) edge(complemented,b) means !(a | b) - if (!tovertexp->accepting()) { - // Note we must include edges moved above to reject - DfaEdge* const newp - = new DfaEdge(graphp(), vvertexp, acceptp, vedgep); - newp->complement(!newp->complement()); - newp->user(1); - } - } - } - } - } - } - } - -public: - DfaGraphComplement(V3Graph* dfagraphp, V3EdgeFuncP edgeFuncp) - : GraphAlg<>{dfagraphp, edgeFuncp} { - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("comp_in"); - - // Vertex::m_user begin: 1 indicates new edge, no more processing - m_graphp->userClearEdges(); - - m_tempNewerReject = new DfaVertex(graphp()); - add_complement_edges(); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("comp_preswap"); - - VL_DO_CLEAR(m_tempNewerReject->unlinkDelete(graphp()), m_tempNewerReject = nullptr); - if (debug() >= 6) m_graphp->dumpDotFilePrefixed("comp_out"); - } - ~DfaGraphComplement() = default; - VL_UNCOPYABLE(DfaGraphComplement); -}; - -void DfaGraph::dfaComplement() { DfaGraphComplement(this, &V3GraphEdge::followAlwaysTrue); } diff --git a/src/V3GraphDfa.h b/src/V3GraphDfa.h deleted file mode 100644 index 8550bdad4..000000000 --- a/src/V3GraphDfa.h +++ /dev/null @@ -1,152 +0,0 @@ -// -*- mode: C++; c-file-style: "cc-mode" -*- -//************************************************************************* -// DESCRIPTION: Verilator: Graph automata base class -// -// Code available from: https://verilator.org -// -//************************************************************************* -// -// Copyright 2003-2021 by Wilson Snyder. This program is free software; you -// can redistribute it and/or modify it under the terms of either the GNU -// Lesser General Public License Version 3 or the Perl Artistic License -// Version 2.0. -// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 -// -//************************************************************************* - -#ifndef VERILATOR_V3GRAPHDFA_H_ -#define VERILATOR_V3GRAPHDFA_H_ -#include "config_build.h" -#include "verilatedos.h" - -#include "V3Ast.h" // for VNUser -#include "V3Global.h" -#include "V3Graph.h" - -class DfaGraph; -class DfaVertex; -class DfaEdge; - -//============================================================================= -// NFA/DFA Graphs -/// The NFA graph consists of: -/// DfaVertex(START) The starting point -/// DfaVertex() Interior states -/// DfaVertex(ACCEPT) The completion point -/// -/// Transitions include a list of all inputs (arbitrary user pointers), -/// or epsilon, represented as a empty list of inputs. -/// -/// We're only looking for matches, so the only accepting states are -/// at the end of the transformations. (If we want the complement, we -/// call complement and the algorithm makes a REJECT state, then flips -/// accept and reject for you.) -/// -/// Common transforms: -/// -/// "*": DfaVertex(START) --> [epsilon] -->DfaVertex(ACCEPT) -/// -/// "L": ...->[ON_L]-->DfaVtx-->[epsilon]-->DfaVtx(ACCEPT) -/// -/// "LR": ...->[ON_L]-->DfaVtx-->[epsilon]-->DfaVtx(ACCEPT) -/// ->[ON_R]-->DfaVtx-->[epsilon]-/ -/// -/// "L|R": ...->DfaVtx-->[epsilon]-->DfaVtx-->[ON_L]-->DfaVtx()->[epsilon]-->DfaVtx(ACCEPT) -/// \->[epsilon]-->DfaVtx-->[ON_R]-->DfaVtx()->[epsilon]-/ -/// -/// "L*": ...->DfaVtx-->[epsilon]-->DfaVtx-->[ON_L]-->DfaVtx()->[epsilon]-->DfaVtx(ACCEPT) -/// | ^\----[epsilon]<-------/ | -/// \->[epsilon]-----------------------------------------/ - -class DfaGraph final : public V3Graph { -public: - // CONSTRUCTORS - DfaGraph() = default; - virtual ~DfaGraph() override = default; - // METHODS - /// Find start node - DfaVertex* findStart(); - /// Convert automata: NFA to DFA - void nfaToDfa(); - /// Simplify a DFA automata - void dfaReduce(); - /// Complement result (must already be dfa) - void dfaComplement(); -}; - -//============================================================================= -// Vertex - -class DfaVertex VL_NOT_FINAL : public V3GraphVertex { - // Each DFA state is captured in this vertex. - // Start and accepting are members, rather than the more intuitive - // subclasses, as subclassing them would make it harder to inherit from here. - bool m_start; // Start state - bool m_accepting; // Accepting state? -public: - // CONSTRUCTORS - explicit DfaVertex(DfaGraph* graphp, bool start = false, bool accepting = false) - : V3GraphVertex{graphp} - , m_start{start} - , m_accepting{accepting} {} - using V3GraphVertex::clone; // We are overriding, not overloading clone(V3Graph*) - virtual DfaVertex* clone(DfaGraph* graphp) { - return new DfaVertex(graphp, start(), accepting()); - } - virtual ~DfaVertex() override = default; - // ACCESSORS - virtual string dotShape() const override { return (accepting() ? "doublecircle" : ""); } - virtual string dotColor() const override { - return start() ? "blue" : (color() ? "red" : "black"); - } - bool start() const { return m_start; } - void start(bool flag) { m_start = flag; } - bool accepting() const { return m_accepting; } - void accepting(bool flag) { m_accepting = flag; } -}; - -//============================================================================ -/// Abstract type indicating a specific "input" to the NFA -/// DFA assumes each .toInt() is unique -using DfaInput = VNUser; - -//============================================================================ -// Edge types - -class DfaEdge final : public V3GraphEdge { - DfaInput m_input; - bool m_complement; // Invert value when doing compare -public: - static DfaInput EPSILON() { return VNUser::fromInt(0); } - static DfaInput NA() { return VNUser::fromInt(1); } // as in not-applicable - // CONSTRUCTORS - DfaEdge(DfaGraph* graphp, DfaVertex* fromp, DfaVertex* top, const DfaInput& input) - : V3GraphEdge{graphp, fromp, top, 1} - , m_input{input} - , m_complement{false} {} - DfaEdge(DfaGraph* graphp, DfaVertex* fromp, DfaVertex* top, const DfaEdge* copyfrom) - : V3GraphEdge{graphp, fromp, top, copyfrom->weight()} - , m_input{copyfrom->input()} - , m_complement{copyfrom->complement()} {} - virtual ~DfaEdge() override = default; - // METHODS - virtual string dotColor() const override { - return (na() ? "yellow" : epsilon() ? "green" : "black"); - } - virtual string dotLabel() const override { - return (na() ? "" - : epsilon() ? "e" - : complement() ? ("not " + cvtToStr(input().toInt())) - : cvtToStr(input().toInt())); - } - virtual string dotStyle() const override { return (na() || cutable()) ? "dashed" : ""; } - bool epsilon() const { return input().toInt() == EPSILON().toInt(); } - bool na() const { return input().toInt() == NA().toInt(); } - bool complement() const { return m_complement; } - void complement(bool value) { m_complement = value; } - DfaInput input() const { return m_input; } -}; - -//============================================================================ - -#endif // Guard diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index ed14f17fc..e14297946 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -19,7 +19,6 @@ #include "V3Global.h" #include "V3Graph.h" -#include "V3GraphDfa.h" //###################################################################### //###################################################################### @@ -28,7 +27,7 @@ class V3GraphTest VL_NOT_FINAL { protected: // MEMBERS - DfaGraph m_graph; + V3Graph m_graph; // METHODS - for children virtual void runTest() = 0; // Run the test @@ -260,67 +259,6 @@ public: //====================================================================== -class DfaTestVertex final : public DfaVertex { - string m_name; - -public: - DfaTestVertex(DfaGraph* graphp, const string& name) - : DfaVertex{graphp} - , m_name{name} {} - virtual ~DfaTestVertex() override = default; - // ACCESSORS - virtual string name() const override { return m_name; } -}; - -class V3GraphTestDfa final : public V3GraphTest { - -public: - virtual string name() override { return "dfa"; } - virtual void runTest() override { - DfaGraph* const gp = &m_graph; - - // NFA Pattern for ( (LR) | (L*R)) Z - DfaTestVertex* const st = new DfaTestVertex(gp, "*START*"); - st->start(true); - DfaTestVertex* const sl = new DfaTestVertex(gp, "sL"); - DfaTestVertex* const srs = new DfaTestVertex(gp, "sR*"); - DfaTestVertex* const sls = new DfaTestVertex(gp, "sL*"); - DfaTestVertex* const sr = new DfaTestVertex(gp, "sR"); - DfaTestVertex* const sz = new DfaTestVertex(gp, "sZ"); - DfaTestVertex* const sac = new DfaTestVertex(gp, "*ACCEPT*"); - sac->accepting(true); - - VNUser L = VNUser::fromInt(0xaa); - VNUser R = VNUser::fromInt(0xbb); - VNUser Z = VNUser::fromInt(0xcc); - - new DfaEdge(gp, st, sl, DfaEdge::EPSILON()); - new DfaEdge(gp, sl, srs, L); - new DfaEdge(gp, srs, srs, R); - new DfaEdge(gp, srs, sz, Z); - new DfaEdge(gp, sz, sac, DfaEdge::EPSILON()); - - new DfaEdge(gp, st, sls, DfaEdge::EPSILON()); - new DfaEdge(gp, sls, sls, L); - new DfaEdge(gp, sls, sr, R); - new DfaEdge(gp, sr, sz, Z); - new DfaEdge(gp, sz, sac, DfaEdge::EPSILON()); - - dump(); - gp->nfaToDfa(); - dump(); - gp->dfaReduce(); - dump(); - - gp->dfaComplement(); - dump(); - gp->dfaReduce(); - dump(); - } -}; - -//====================================================================== - class V3GraphTestImport final : public V3GraphTest { #ifdef GRAPH_IMPORT @@ -332,8 +270,7 @@ class V3GraphTestImport final : public V3GraphTest { public: virtual string name() override { return "import"; } virtual void runTest() override { - DfaGraph* const gp = &m_graph; - if (V3GraphTest::debug()) DfaGraph::debug(9); + V3Graph* const gp = &m_graph; dotImport(); dump(); gp->acyclic(&V3GraphEdge::followAlwaysTrue); @@ -358,7 +295,6 @@ void V3Graph::selfTest() { { V3GraphTestStrong test; test.run(); } { V3GraphTestAcyc test; test.run(); } { V3GraphTestVars test; test.run(); } - { V3GraphTestDfa test; test.run(); } { V3GraphTestImport test; test.run(); } // clang-format on } diff --git a/test_regress/t/t_debug_graph_test.pl b/test_regress/t/t_debug_graph_test.pl index 961994545..64bc7a996 100755 --- a/test_regress/t/t_debug_graph_test.pl +++ b/test_regress/t/t_debug_graph_test.pl @@ -13,7 +13,7 @@ $ENV{VERILATOR_TEST_NO_GDB} and skip("Skipping due to VERILATOR_TEST_NO_GDB"); lint( # Check we can call dump() on graph, and other things - v_flags => ["--lint-only --debug --debugi-V3GraphTest 9 --debugi-V3GraphDfa 9 --debug-self-test"], + v_flags => ["--lint-only --debug --debugi-V3GraphTest 9 --debug-self-test"], ); ok(1); From fe5822ba54b0bf7630ea752f982806cb789ee9e0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 13 Nov 2021 15:01:27 -0500 Subject: [PATCH 36/79] Commentary --- examples/cmake_hello_sc/Makefile | 2 +- examples/make_hello_c/Makefile | 2 +- examples/make_hello_c/top.v | 3 ++- examples/make_hello_sc/Makefile | 2 +- examples/make_hello_sc/top.v | 3 ++- examples/make_protect_lib/top.v | 3 ++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/cmake_hello_sc/Makefile b/examples/cmake_hello_sc/Makefile index 633e4addd..540a32fec 100644 --- a/examples/cmake_hello_sc/Makefile +++ b/examples/cmake_hello_sc/Makefile @@ -99,7 +99,7 @@ run: @echo "-- DONE --------------------" @echo "Note: Once this example is understood, see examples/cmake_tracing_sc." - @echo "Note: Also see the EXAMPLE section in the verilator manpage/document." + @echo "Note: See also https://verilator.org/guide/latest/examples.html" clean mostlyclean distclean maintainer-clean: @rm -rf build logs diff --git a/examples/make_hello_c/Makefile b/examples/make_hello_c/Makefile index cdf8db58a..98ce3a67e 100644 --- a/examples/make_hello_c/Makefile +++ b/examples/make_hello_c/Makefile @@ -40,7 +40,7 @@ default: obj_dir/Vtop @echo "-- DONE --------------------" @echo "Note: Once this example is understood, see examples/make_tracing_c." - @echo "Note: Also see the EXAMPLE section in the verilator manpage/document." + @echo "Note: See also https://verilator.org/guide/latest/examples.html" ###################################################################### diff --git a/examples/make_hello_c/top.v b/examples/make_hello_c/top.v index 803566f1a..3deb48f2d 100644 --- a/examples/make_hello_c/top.v +++ b/examples/make_hello_c/top.v @@ -4,7 +4,8 @@ // any use, without warranty, 2017 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 -// See also the EXAMPLE section in the verilator manpage/document. +// See also https://verilator.org/guide/latest/examples.html" + module top; initial begin $display("Hello World!"); diff --git a/examples/make_hello_sc/Makefile b/examples/make_hello_sc/Makefile index f406379f0..9548d716c 100644 --- a/examples/make_hello_sc/Makefile +++ b/examples/make_hello_sc/Makefile @@ -49,7 +49,7 @@ run: obj_dir/Vtop @echo "-- DONE --------------------" @echo "Note: Once this example is understood, see examples/make_tracing_sc." - @echo "Note: Also see the EXAMPLE section in the verilator manpage/document." + @echo "Note: See also https://verilator.org/guide/latest/examples.html" ###################################################################### diff --git a/examples/make_hello_sc/top.v b/examples/make_hello_sc/top.v index 803566f1a..3deb48f2d 100644 --- a/examples/make_hello_sc/top.v +++ b/examples/make_hello_sc/top.v @@ -4,7 +4,8 @@ // any use, without warranty, 2017 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 -// See also the EXAMPLE section in the verilator manpage/document. +// See also https://verilator.org/guide/latest/examples.html" + module top; initial begin $display("Hello World!"); diff --git a/examples/make_protect_lib/top.v b/examples/make_protect_lib/top.v index 16a0e2740..b9b71ef87 100644 --- a/examples/make_protect_lib/top.v +++ b/examples/make_protect_lib/top.v @@ -4,7 +4,8 @@ // any use, without warranty, 2019 by Todd Strader. // SPDX-License-Identifier: CC0-1.0 -// See also the EXAMPLE section in the verilator manpage/document. +// See also https://verilator.org/guide/latest/examples.html" + module top (input clk); integer cyc = 0; From 28b6e79cf7358d220e61a5462328ca323f1d3827 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Nov 2021 08:58:04 -0500 Subject: [PATCH 37/79] Tests: Rename t_lib_prot tests in prep for new options. --- test_regress/t/{t_noprot_lib.pl => t_lib_nolib.pl} | 8 ++++---- test_regress/t/{t_prot_lib.pl => t_lib_prot.pl} | 6 +++--- test_regress/t/{t_prot_lib.v => t_lib_prot.v} | 0 .../{t_prot_lib_clk_gated.pl => t_lib_prot_clk_gated.pl} | 8 ++++---- test_regress/t/{t_prot_lib_comb.pl => t_lib_prot_comb.pl} | 6 +++--- test_regress/t/{t_prot_lib_comb.v => t_lib_prot_comb.v} | 0 ...{t_prot_lib_inout_bad.out => t_lib_prot_inout_bad.out} | 2 +- .../{t_prot_lib_inout_bad.pl => t_lib_prot_inout_bad.pl} | 0 .../t/{t_prot_lib_inout_bad.v => t_lib_prot_inout_bad.v} | 0 .../t/{t_prot_lib_secret.pl => t_lib_prot_secret.pl} | 0 .../t/{t_prot_lib_secret.v => t_lib_prot_secret.v} | 0 .../t/{t_prot_lib_shared.pl => t_lib_prot_shared.pl} | 8 ++++---- 12 files changed, 19 insertions(+), 19 deletions(-) rename test_regress/t/{t_noprot_lib.pl => t_lib_nolib.pl} (84%) rename test_regress/t/{t_prot_lib.pl => t_lib_prot.pl} (94%) rename test_regress/t/{t_prot_lib.v => t_lib_prot.v} (100%) rename test_regress/t/{t_prot_lib_clk_gated.pl => t_lib_prot_clk_gated.pl} (93%) rename test_regress/t/{t_prot_lib_comb.pl => t_lib_prot_comb.pl} (94%) rename test_regress/t/{t_prot_lib_comb.v => t_lib_prot_comb.v} (100%) rename test_regress/t/{t_prot_lib_inout_bad.out => t_lib_prot_inout_bad.out} (78%) rename test_regress/t/{t_prot_lib_inout_bad.pl => t_lib_prot_inout_bad.pl} (100%) rename test_regress/t/{t_prot_lib_inout_bad.v => t_lib_prot_inout_bad.v} (100%) rename test_regress/t/{t_prot_lib_secret.pl => t_lib_prot_secret.pl} (100%) rename test_regress/t/{t_prot_lib_secret.v => t_lib_prot_secret.v} (100%) rename test_regress/t/{t_prot_lib_shared.pl => t_lib_prot_shared.pl} (94%) diff --git a/test_regress/t/t_noprot_lib.pl b/test_regress/t/t_lib_nolib.pl similarity index 84% rename from test_regress/t/t_noprot_lib.pl rename to test_regress/t/t_lib_nolib.pl index ad155e829..d4b9b47e9 100755 --- a/test_regress/t/t_noprot_lib.pl +++ b/test_regress/t/t_lib_nolib.pl @@ -17,12 +17,12 @@ scenarios( ); $Self->{sim_time} = $Self->{benchmark} * 100 if $Self->{benchmark}; -top_filename("t/t_prot_lib.v"); +top_filename("t/t_lib_prot.v"); -# Tests the same code as t_prot_lib.pl but without --protect-lib +# Tests the same code as t_lib_prot.pl but without --protect-lib compile( - verilator_flags2 => ["t/t_prot_lib_secret.v"], - xsim_flags2 => ["t/t_prot_lib_secret.v"], + verilator_flags2 => ["t/t_lib_prot_secret.v"], + xsim_flags2 => ["t/t_lib_prot_secret.v"], ); execute( diff --git a/test_regress/t/t_prot_lib.pl b/test_regress/t/t_lib_prot.pl similarity index 94% rename from test_regress/t/t_prot_lib.pl rename to test_regress/t/t_lib_prot.pl index 22fb1c6d1..2df0816e8 100755 --- a/test_regress/t/t_prot_lib.pl +++ b/test_regress/t/t_lib_prot.pl @@ -29,7 +29,7 @@ while (1) { cmd => ["perl", "$ENV{VERILATOR_ROOT}/bin/verilator", "--prefix", - "Vt_prot_lib_secret", + "Vt_lib_prot_secret", "-cc", "-Mdir", $secret_dir, @@ -37,7 +37,7 @@ while (1) { $secret_prefix, "--protect-key", "secret-key", - "t/t_prot_lib_secret.v"], + "t/t_lib_prot_secret.v"], verilator_run => 1, ); last if $Self->{errors}; @@ -47,7 +47,7 @@ while (1) { "-C", $secret_dir, "-f", - "Vt_prot_lib_secret.mk"]); + "Vt_lib_prot_secret.mk"]); last if $Self->{errors}; compile( diff --git a/test_regress/t/t_prot_lib.v b/test_regress/t/t_lib_prot.v similarity index 100% rename from test_regress/t/t_prot_lib.v rename to test_regress/t/t_lib_prot.v diff --git a/test_regress/t/t_prot_lib_clk_gated.pl b/test_regress/t/t_lib_prot_clk_gated.pl similarity index 93% rename from test_regress/t/t_prot_lib_clk_gated.pl rename to test_regress/t/t_lib_prot_clk_gated.pl index 0f7fcd125..4a290d26d 100755 --- a/test_regress/t/t_prot_lib_clk_gated.pl +++ b/test_regress/t/t_lib_prot_clk_gated.pl @@ -18,7 +18,7 @@ scenarios( $Self->{sim_time} = $Self->{benchmark} * 100 if $Self->{benchmark}; -top_filename("t/t_prot_lib.v"); +top_filename("t/t_lib_prot.v"); my $secret_prefix = "secret"; my $secret_dir = "$Self->{obj_dir}/$secret_prefix"; mkdir $secret_dir; @@ -30,7 +30,7 @@ while (1) { cmd => ["perl", "$ENV{VERILATOR_ROOT}/bin/verilator", "--prefix", - "Vt_prot_lib_secret", + "Vt_lib_prot_secret", "-cc", "-Mdir", $secret_dir, @@ -39,7 +39,7 @@ while (1) { $secret_prefix, "--protect-key", "secret-key", - "t/t_prot_lib_secret.v"], + "t/t_lib_prot_secret.v"], verilator_run => 1, ); last if $Self->{errors}; @@ -49,7 +49,7 @@ while (1) { "-C", $secret_dir, "-f", - "Vt_prot_lib_secret.mk"]); + "Vt_lib_prot_secret.mk"]); last if $Self->{errors}; compile( diff --git a/test_regress/t/t_prot_lib_comb.pl b/test_regress/t/t_lib_prot_comb.pl similarity index 94% rename from test_regress/t/t_prot_lib_comb.pl rename to test_regress/t/t_lib_prot_comb.pl index 856e3ebd0..73cfd8aef 100755 --- a/test_regress/t/t_prot_lib_comb.pl +++ b/test_regress/t/t_lib_prot_comb.pl @@ -29,7 +29,7 @@ while (1) { cmd => ["perl", "$ENV{VERILATOR_ROOT}/bin/verilator", "--prefix", - "Vt_prot_lib_secret", + "Vt_lib_prot_secret", "-cc", "-Mdir", $secret_dir, @@ -37,7 +37,7 @@ while (1) { $secret_prefix, "--protect-key", "secret-key", - "t/t_prot_lib_comb.v"], + "t/t_lib_prot_comb.v"], verilator_run => 1, ); last if $Self->{errors}; @@ -47,7 +47,7 @@ while (1) { "-C", $secret_dir, "-f", - "Vt_prot_lib_secret.mk"]); + "Vt_lib_prot_secret.mk"]); last if $Self->{errors}; compile( diff --git a/test_regress/t/t_prot_lib_comb.v b/test_regress/t/t_lib_prot_comb.v similarity index 100% rename from test_regress/t/t_prot_lib_comb.v rename to test_regress/t/t_lib_prot_comb.v diff --git a/test_regress/t/t_prot_lib_inout_bad.out b/test_regress/t/t_lib_prot_inout_bad.out similarity index 78% rename from test_regress/t/t_prot_lib_inout_bad.out rename to test_regress/t/t_lib_prot_inout_bad.out index df36c979d..1b58aebdb 100644 --- a/test_regress/t/t_prot_lib_inout_bad.out +++ b/test_regress/t/t_lib_prot_inout_bad.out @@ -1,4 +1,4 @@ -%Error-UNSUPPORTED: t/t_prot_lib_inout_bad.v:9:28: Unsupported: protect-lib port direction: INOUT +%Error-UNSUPPORTED: t/t_lib_prot_inout_bad.v:9:28: Unsupported: protect-lib port direction: INOUT 9 | inout z, | ^ ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest diff --git a/test_regress/t/t_prot_lib_inout_bad.pl b/test_regress/t/t_lib_prot_inout_bad.pl similarity index 100% rename from test_regress/t/t_prot_lib_inout_bad.pl rename to test_regress/t/t_lib_prot_inout_bad.pl diff --git a/test_regress/t/t_prot_lib_inout_bad.v b/test_regress/t/t_lib_prot_inout_bad.v similarity index 100% rename from test_regress/t/t_prot_lib_inout_bad.v rename to test_regress/t/t_lib_prot_inout_bad.v diff --git a/test_regress/t/t_prot_lib_secret.pl b/test_regress/t/t_lib_prot_secret.pl similarity index 100% rename from test_regress/t/t_prot_lib_secret.pl rename to test_regress/t/t_lib_prot_secret.pl diff --git a/test_regress/t/t_prot_lib_secret.v b/test_regress/t/t_lib_prot_secret.v similarity index 100% rename from test_regress/t/t_prot_lib_secret.v rename to test_regress/t/t_lib_prot_secret.v diff --git a/test_regress/t/t_prot_lib_shared.pl b/test_regress/t/t_lib_prot_shared.pl similarity index 94% rename from test_regress/t/t_prot_lib_shared.pl rename to test_regress/t/t_lib_prot_shared.pl index 91e2e5cc6..a770be51b 100755 --- a/test_regress/t/t_prot_lib_shared.pl +++ b/test_regress/t/t_lib_prot_shared.pl @@ -16,7 +16,7 @@ scenarios( vltmt => 1, xsim => 1, ); -top_filename("t/t_prot_lib.v"); +top_filename("t/t_lib_prot.v"); $Self->{sim_time} = $Self->{benchmark} * 100 if $Self->{benchmark}; @@ -33,7 +33,7 @@ while (1) { "$ENV{VERILATOR_ROOT}/bin/verilator", ($Self->{vltmt} ? ' --threads 6' : ''), "--prefix", - "Vt_prot_lib_secret", + "Vt_lib_prot_secret", "-cc", "-Mdir", $secret_dir, @@ -41,7 +41,7 @@ while (1) { $secret_prefix, "--protect-key", "secret-key", - "t/t_prot_lib_secret.v"], + "t/t_lib_prot_secret.v"], verilator_run => 1, ); last if $Self->{errors}; @@ -51,7 +51,7 @@ while (1) { "-C", $secret_dir, "-f", - "Vt_prot_lib_secret.mk"]); + "Vt_lib_prot_secret.mk"]); last if $Self->{errors}; compile( From 4b593f8eb39a80ce39762f238a652aa051ddd0e9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Nov 2021 09:01:03 -0500 Subject: [PATCH 38/79] Commentary --- docs/guide/exe_verilator.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index 508492d16..bd0fe1928 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -179,19 +179,6 @@ Summary: remove it from the combinatorial logic reevaluation checking code. This may greatly improve performance. -.. option:: --make - - Generates a script for the specified build tool. - - Supported values are ``gmake`` for GNU Make and ``cmake`` for CMake. - Both can be specified together. If no build tool is specified, gmake is - assumed. The executable of gmake can be configured via environment - variable "MAKE". - - When using :vlopt:`--build` Verilator takes over the responsibility of - building the model library/executable. For this reason :option:`--make` - cannot be specified when using :vlopt:`--build`. - .. option:: --compiler Enables workarounds for the specified C++ compiler (list below). @@ -599,6 +586,19 @@ Summary: If the design is not to be completely Verilated see also the :vlopt:`--bbox-sys` and :vlopt:`--bbox-unsup` options. +.. option:: --make + + Generates a script for the specified build tool. + + Supported values are ``gmake`` for GNU Make and ``cmake`` for CMake. + Both can be specified together. If no build tool is specified, gmake is + assumed. The executable of gmake can be configured via environment + variable "MAKE". + + When using :vlopt:`--build` Verilator takes over the responsibility of + building the model library/executable. For this reason :option:`--make` + cannot be specified when using :vlopt:`--build`. + .. option:: -MAKEFLAGS When using :vlopt:`--build`, add the specified argument to the invoked From 899de9a28266f780b31532d8357a1b9c50a22411 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Nov 2021 09:39:31 -0500 Subject: [PATCH 39/79] Add --lib-create, similar to --protect-lib but without protections (#3200). --- Changes | 6 ++- bin/verilator | 1 + docs/guide/exe_verilator.rst | 32 ++++++----- docs/guide/verilating.rst | 7 ++- include/verilated.cpp | 2 +- src/V3EmitCMake.cpp | 6 +-- src/V3EmitMk.cpp | 27 +++++----- src/V3HierBlock.cpp | 20 ++++--- src/V3LinkResolve.cpp | 4 +- src/V3Options.cpp | 14 ++--- src/V3Options.h | 20 +++---- src/V3Param.cpp | 6 +-- src/V3ProtectLib.cpp | 8 +-- src/Verilator.cpp | 2 +- test_regress/t/t_lib.pl | 70 +++++++++++++++++++++++++ test_regress/t/t_lib_prot_inout_bad.out | 2 +- 16 files changed, 155 insertions(+), 72 deletions(-) create mode 100755 test_regress/t/t_lib.pl diff --git a/Changes b/Changes index 830293acf..8b62759f9 100644 --- a/Changes +++ b/Changes @@ -11,11 +11,15 @@ contributors that suggested a given feature are shown in []. Thanks! Verilator 4.215 devel ========================== +**Major:** + +* Add --lib-create, similar to --protect-lib but without protections. + **Minor:** * Internal code cleanups and improvements. [Geza Lore] * Improve --thread verilation-time performance. -* Fix array method names with parens (#3181) (#3183). [Teng Huang] +* Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] diff --git a/bin/verilator b/bin/verilator index fbd06550a..505933437 100755 --- a/bin/verilator +++ b/bin/verilator @@ -336,6 +336,7 @@ detailed descriptions of these arguments. -LDFLAGS Linker pre-object arguments for makefile --l2-name Verilog scope name of the top module --language Default language standard to parse + --lib-create Create a DPI library +libext++[ext]... Extensions for finding modules --lint-only Lint, but do not make output -MAKEFLAGS Arguments to pass to make during --build diff --git a/docs/guide/exe_verilator.rst b/docs/guide/exe_verilator.rst index bd0fe1928..40d9fc8e2 100644 --- a/docs/guide/exe_verilator.rst +++ b/docs/guide/exe_verilator.rst @@ -575,6 +575,23 @@ Summary: "+libext+" is fairly standard across Verilog tools. Defaults to ".v+.sv". +.. option:: --lib-create + + Produces C++, Verilog wrappers and a Makefile which can in turn produce + a DPI library which can be used by Verilator or other simulators along + with the corresponding Verilog wrapper. The Makefile will build both a + static and dynamic version of the library named :file:`lib.a` and + :file:`lib.so` respectively. This is done because some simulators + require a dynamic library, but the static library is arguably easier to + use if possible. :vlopt:`--protect-lib` implies :vlopt:`--protect-ids`. + + When using :vlopt:`--lib-create` it is advised to also use + :vlopt:`--timescale-override /1fs <--timescale-override>` to ensure the + model has a time resolution that is always compatible with the time + precision of the upper instantiating module. + + See also :vlopt:`--protect-lib`. + .. option:: --lint-only Check the files for lint violations only, do not create any other @@ -872,24 +889,15 @@ Summary: .. option:: --protect-lib - Produces C++, Verilog wrappers and a Makefile which can in turn produce - a DPI library which can be used by Verilator or other simulators along - with the corresponding Verilog wrapper. The Makefile will build both a - static and dynamic version of the library named :file:`lib.a` and - :file:`lib.so` respectively. This is done because some simulators - require a dynamic library, but the static library is arguably easier to - use if possible. :vlopt:`--protect-lib` implies :vlopt:`--protect-ids`. + Produces a DPI library similar to :vlopt:`--lib-create`, but hides + internal design details. :vlopt:`--protect-lib` implies + :vlopt:`--protect-ids`, and :vlopt:`--lib-create`. This allows for the secure delivery of sensitive IP without the need for encrypted RTL (i.e. IEEE P1735). See :file:`examples/make_protect_lib` in the distribution for a demonstration of how to build and use the DPI library. - When using :vlopt:`--protect-lib` it is advised to also use - :vlopt:`--timescale-override /1fs <--timescale-override>` to ensure the - model has a time resolution that is always compatible with the time - precision of the upper instantiating module. - .. option:: --private Opposite of :vlopt:`--public`. Is the default; this option exists for diff --git a/docs/guide/verilating.rst b/docs/guide/verilating.rst index b33dd4acd..e2e10c32b 100644 --- a/docs/guide/verilating.rst +++ b/docs/guide/verilating.rst @@ -70,10 +70,9 @@ Verilator is run in hierarchical mode on the whole SoC. Verilator will make two models, one for the CPU hierarchy block, and one for the SoC. The Verialted code for the SoC will automatically call the CPU Verilated model. -The current hierarchical Verilation is based on protect-lib. Each hierarchy -block is Verilated to a protect-lib. User modules of the hierarchy blocks -will see a tiny wrapper generated by protect-lib instead of the actual -design. +The current hierarchical Verilation is based on :vlopt:`--lib-create`. Each +hierarchy block is Verilated into a library. User modules of the hierarchy +blocks will see a tiny wrapper generated by :vlopt:`--lib-create`. Usage diff --git a/include/verilated.cpp b/include/verilated.cpp index fb349c41f..173f0fc7f 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -25,7 +25,7 @@ //========================================================================= // Internal note: // -// verilated.o may exist both in protect-lib (incrementally linked .a/.so) +// verilated.o may exist both in --lib-create (incrementally linked .a/.so) // and the main module. Both refer the same instance of static // variables/VL_THREAD_LOCAL in verilated.o such as Verilated, or // VerilatedImpData. This is important to share that state, but the diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index b9c875e41..d8b2170aa 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -178,8 +178,8 @@ class CMakeEmitter final { if (v3Global.opt.mtasks()) { global.emplace_back("${VERILATOR_ROOT}/include/verilated_threads.cpp"); } - if (!v3Global.opt.protectLib().empty()) { - global.emplace_back(v3Global.opt.makeDir() + "/" + v3Global.opt.protectLib() + ".cpp"); + if (!v3Global.opt.libCreate().empty()) { + global.emplace_back(v3Global.opt.makeDir() + "/" + v3Global.opt.libCreate() + ".cpp"); } *of << "# Global classes, need linked once per executable\n"; @@ -238,7 +238,7 @@ class CMakeEmitter final { // with .so << ")\n"; } - *of << "\n# Verilate the top module that refers protect-lib wrappers of above\n"; + *of << "\n# Verilate the top module that refers to lib-create wrappers of above\n"; *of << "verilate(${TOP_TARGET_NAME} PREFIX " << v3Global.opt.prefix() << " TOP_MODULE " << v3Global.rootp()->topModulep()->name() << " DIRECTORY " << deslash(v3Global.opt.makeDir()) << " SOURCES "; diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 0b152bd30..d74745109 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -145,8 +145,8 @@ public: if (v3Global.opt.exe()) { of.puts("default: " + v3Global.opt.exeName() + "\n"); - } else if (!v3Global.opt.protectLib().empty()) { - of.puts("default: lib" + v3Global.opt.protectLib() + "\n"); + } else if (!v3Global.opt.libCreate().empty()) { + of.puts("default: lib" + v3Global.opt.libCreate() + "\n"); } else { of.puts("default: " + v3Global.opt.prefix() + "__ALL.a\n"); } @@ -188,7 +188,7 @@ public: of.puts("# User CFLAGS (from -CFLAGS on Verilator command line)\n"); of.puts("VM_USER_CFLAGS = \\\n"); - if (!v3Global.opt.protectLib().empty()) of.puts("\t-fPIC \\\n"); + if (!v3Global.opt.libCreate().empty()) of.puts("\t-fPIC \\\n"); const V3StringList& cFlags = v3Global.opt.cFlags(); for (const string& i : cFlags) of.puts("\t" + i + " \\\n"); of.puts("\n"); @@ -243,19 +243,19 @@ public: of.puts("\n"); } - if (!v3Global.opt.protectLib().empty()) { - const string protectLibDeps = "$(VK_OBJS) $(VK_GLOBAL_OBJS) " - + v3Global.opt.protectLib() + ".o $(VM_HIER_LIBS)"; - of.puts("\n### Library rules from --protect-lib\n"); + if (!v3Global.opt.libCreate().empty()) { + const string libCreateDeps = "$(VK_OBJS) $(VK_GLOBAL_OBJS) " + v3Global.opt.libCreate() + + ".o $(VM_HIER_LIBS)"; + of.puts("\n### Library rules from --lib-create\n"); // The rule to create .a is defined in verilated.mk, so just define dependency here. - of.puts(v3Global.opt.protectLibName(false) + ": " + protectLibDeps + "\n"); + of.puts(v3Global.opt.libCreateName(false) + ": " + libCreateDeps + "\n"); of.puts("\n"); if (v3Global.opt.hierChild()) { // Hierarchical child does not need .so because hierTop() will create .so from .a - of.puts("lib" + v3Global.opt.protectLib() + ": " - + v3Global.opt.protectLibName(false) + "\n"); + of.puts("lib" + v3Global.opt.libCreate() + ": " + v3Global.opt.libCreateName(false) + + "\n"); } else { - of.puts(v3Global.opt.protectLibName(true) + ": " + protectLibDeps + "\n"); + of.puts(v3Global.opt.libCreateName(true) + ": " + libCreateDeps + "\n"); // Linker on mac emits an error if all symbols are not found here, // but some symbols that are referred as "DPI-C" can not be found at this moment. // So add dynamic_lookup @@ -267,9 +267,8 @@ public: "\t$(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -shared -o $@ $^\n"); of.puts("endif\n"); of.puts("\n"); - of.puts("lib" + v3Global.opt.protectLib() + ": " - + v3Global.opt.protectLibName(false) + " " - + v3Global.opt.protectLibName(true) + "\n"); + of.puts("lib" + v3Global.opt.libCreate() + ": " + v3Global.opt.libCreateName(false) + + " " + v3Global.opt.libCreateName(true) + "\n"); } } diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 18a5b1c3b..58103c813 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -18,8 +18,9 @@ // - time and memory for Verilation // - compilation time especially when a hierarchical block is used many times // -// Hierarchical Verilation internally creates protect-lib for each hierarchical block. -// Upper modules read wrapper for the protect-lib instead of the actual design. +// Hierarchical Verilation internally uses --lib-create for each +// hierarchical block. Upper modules read the wrapper from --lib-create +// instead of the Verilog design. // // Hierarchical Verilation runs as the following step // 1) Find modules marked by /*verilator hier_block*/ metacomment @@ -29,7 +30,7 @@ // // There are 3 kinds of Verilator run. // a) To create ${prefix}_hier.mk (--hierarchical) -// b) To create protect-lib for each hierarchical block (--hierarchical-child) +// b) To --lib-create on each hierarchical block (--hierarchical-child) // c) To load wrappers and Verilate the top module (... what primary flags?) // // Then user can build Verilated module as usual. @@ -52,7 +53,7 @@ // 4) V3LinkDot.cpp checks dotted access across hierarchical block boundary. // 5) In V3Dead.cpp, some parameters of parameterized modules are protected not to be deleted even // if the parameter is not referred. This protection is necessary to match step 6) below. -// 6) In V3Param.cpp, use protect-lib wrapper of parameterized module made in b) and c). +// 6) In V3Param.cpp, use --lib-create wrapper of the parameterized module made in b) and c). // If a hierarchical block is a parameterized module and instantiated in multiple locations, // all parameters must exactly match. // 7) In V3HierBlock.cpp, relationship among hierarchical blocks are checked in run a). @@ -152,8 +153,9 @@ V3StringList V3HierBlock::commandArgs(bool forCMake) const { opts.push_back(" --mod-prefix " + prefix); opts.push_back(" --top-module " + modp()->name()); } - opts.push_back(" --protect-lib " + modp()->name()); // mangled name - opts.push_back(" --protect-key " + v3Global.opt.protectKeyDefaulted()); + opts.push_back(" --lib-create " + modp()->name()); // possibly mangled name + if (v3Global.opt.protectKeyProvided()) + opts.push_back(" --protect-key " + v3Global.opt.protectKeyDefaulted()); opts.push_back(" --hierarchical-child"); const StrGParams gparamsStr = stringifyParams(gparams(), true); @@ -418,8 +420,10 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const { *of << it->second->hierBlockArgs().front() << "\n"; } - if (!v3Global.opt.protectLib().empty()) { - *of << "--protect-lib " << v3Global.opt.protectLib() << "\n"; + if (!v3Global.opt.libCreate().empty()) { + *of << "--lib-create " << v3Global.opt.libCreate() << "\n"; + } + if (v3Global.opt.protectKeyProvided()) { *of << "--protect-key " << v3Global.opt.protectKeyDefaulted() << "\n"; } if (v3Global.opt.threads() > 0) { diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index 2273bc8ed..ef77a6ae9 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -263,9 +263,9 @@ private: virtual void visit(AstPragma* nodep) override { if (nodep->pragType() == AstPragmaType::HIER_BLOCK) { UASSERT_OBJ(m_modp, nodep, "HIER_BLOCK not under a module"); - // If this is hierarchical mode which is to create protect-lib, + // If this is hierarchical mode which is to lib-create, // sub modules do not have hier_block meta comment in the source code. - // But .vlt files may still mark a module which is actually a protect-lib wrapper + // But .vlt files may still mark a module which is actually a lib-create wrapper // hier_block. AstNodeModule::hierBlock() can be true only when --hierarchical is // specified. m_modp->hierBlock(v3Global.opt.hierarchical()); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index d2bb5c34d..c9cfcbbe5 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -500,9 +500,9 @@ string V3Options::filePathCheckOneDir(const string& modname, const string& dirna // 1: Delete the option which has no argument // 2: Delete the option and its argument int V3Options::stripOptionsForChildRun(const string& opt, bool forTop) { - if (opt == "Mdir" || opt == "clk" || opt == "f" || opt == "j" || opt == "l2-name" - || opt == "mod-prefix" || opt == "prefix" || opt == "protect-lib" || opt == "protect-key" - || opt == "threads" || opt == "top-module" || opt == "v") { + if (opt == "Mdir" || opt == "clk" || opt == "lib-create" || opt == "f" || opt == "j" + || opt == "l2-name" || opt == "mod-prefix" || opt == "prefix" || opt == "protect-lib" + || opt == "protect-key" || opt == "threads" || opt == "top-module" || opt == "v") { return 2; } if (opt == "build" || (!forTop && (opt == "cc" || opt == "exe" || opt == "sc")) @@ -732,11 +732,6 @@ void V3Options::notify() { if (m_hierChild && m_hierBlocks.empty()) { cmdfl->v3error("--hierarchical-block must be set when --hierarchical-child is set"); } - if (m_hierarchical && m_protectLib.empty() && m_protectKey.empty()) { - // Key for hierarchical Verilation is fixed to be ccache friendly when the aim of this run - // is not to create protec-lib. - m_protectKey = "VL-KEY-HIERARCHICAL"; - } if (protectIds()) { if (allPublic()) { @@ -1121,6 +1116,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char }; DECL_OPTION("-default-language", CbVal, setLang); DECL_OPTION("-language", CbVal, setLang); + DECL_OPTION("-lib-create", Set, &m_libCreate); DECL_OPTION("-lint-only", OnOff, &m_lintOnly); DECL_OPTION("-l2-name", Set, &m_l2Name); DECL_OPTION("-no-l2name", CbCall, [this]() { m_l2Name = ""; }).undocumented(); // Historical @@ -1237,7 +1233,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-protect-ids", OnOff, &m_protectIds); DECL_OPTION("-protect-key", Set, &m_protectKey); DECL_OPTION("-protect-lib", CbVal, [this](const char* valp) { - m_protectLib = valp; + m_libCreate = valp; m_protectIds = true; }); DECL_OPTION("-public", OnOff, &m_public); diff --git a/src/V3Options.h b/src/V3Options.h index acea42e08..fb35022dc 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -321,12 +321,12 @@ private: string m_exeName; // main switch: -o {name} string m_flags; // main switch: -f {name} string m_l2Name; // main switch: --l2name; "" for top-module's name + string m_libCreate; // main switch: --lib-create {lib_name} string m_makeDir; // main switch: -Mdir string m_modPrefix; // main switch: --mod-prefix string m_pipeFilter; // main switch: --pipe-filter string m_prefix; // main switch: --prefix string m_protectKey; // main switch: --protect-key - string m_protectLib; // main switch: --protect-lib {lib_name} string m_topModule; // main switch: --top-module string m_unusedRegexp; // main switch: --unused-regexp string m_waiverOutput; // main switch: --waiver-output {filename} @@ -526,14 +526,9 @@ public: string exeName() const { return m_exeName != "" ? m_exeName : prefix(); } string l2Name() const { return m_l2Name; } - string makeDir() const { return m_makeDir; } - string modPrefix() const { return m_modPrefix; } - string pipeFilter() const { return m_pipeFilter; } - string prefix() const { return m_prefix; } - string protectKeyDefaulted(); // Set default key if not set by user - string protectLib() const { return m_protectLib; } - string protectLibName(bool shared) { - string libName = "lib" + protectLib(); + string libCreate() const { return m_libCreate; } + string libCreateName(bool shared) { + string libName = "lib" + libCreate(); if (shared) { libName += ".so"; } else { @@ -541,6 +536,13 @@ public: } return libName; } + string makeDir() const { return m_makeDir; } + string modPrefix() const { return m_modPrefix; } + string pipeFilter() const { return m_pipeFilter; } + string prefix() const { return m_prefix; } + // Not just called protectKey() to avoid bugs of not using protectKeyDefaulted() + bool protectKeyProvided() const { return !m_protectKey.empty(); } + string protectKeyDefaulted(); // Set default key if not set by user string topModule() const { return m_topModule; } string unusedRegexp() const { return m_unusedRegexp; } string waiverOutput() const { return m_waiverOutput; } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index d9a192f69..28e8775db 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -127,7 +127,7 @@ public: if (m_hierBlockOptsByOrigName.find(origName) == m_hierBlockOptsByOrigName.end()) { return nullptr; } - // This module is a hierarchical block. Need to replace it by the protect-lib wrapper. + // This module is a hierarchical block. Need to replace it by the --lib-create wrapper. const std::pair candidates = m_hierBlockOptsByOrigName.equal_range(origName); const auto paramsIt = m_modParams.find(origName); @@ -168,7 +168,7 @@ public: } if (found && paramIdx == hierIt->second->params().size()) break; } - UASSERT_OBJ(hierIt != candidates.second, firstPinp, "No protect-lib wrapper found"); + UASSERT_OBJ(hierIt != candidates.second, firstPinp, "No --lib-create wrapper found"); // parameter settings will be removed in the bottom of caller visitCell(). const HierBlockModMap::const_iterator modIt = m_hierBlockMod.find(hierIt->second->mangledName()); @@ -258,7 +258,7 @@ class ParamProcessor final { AstNodeModule* m_modp = nullptr; // Current module being processed - // Database to get protect-lib wrapper that matches parameters in hierarchical Verilation + // Database to get lib-create wrapper that matches parameters in hierarchical Verilation ParameterizedHierBlocks m_hierBlocks; // Default parameter values key:parameter name, value:default value (can be nullptr) using DefaultValueMap = std::map; diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index cb44de52a..0b005fd4b 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -57,8 +57,8 @@ private: AstTextBlock* m_cSeqClksp = nullptr; // Sequential clock copy list AstTextBlock* m_cSeqOutsp = nullptr; // Sequential output copy list AstTextBlock* m_cIgnoreParamsp = nullptr; // Combo ignore parameter list - string m_libName; - string m_topName; + const string m_libName; + const string m_topName; bool m_foundTop = false; // Have seen the top module bool m_hasClk = false; // True if the top module has sequential logic @@ -396,7 +396,7 @@ private: } else if (nodep->direction() == VDirection::OUTPUT) { handleOutput(nodep); } else { - nodep->v3warn(E_UNSUPPORTED, "Unsupported: protect-lib port direction: " + nodep->v3warn(E_UNSUPPORTED, "Unsupported: --lib-create port direction: " << nodep->direction().ascii()); } } @@ -484,7 +484,7 @@ private: public: explicit ProtectVisitor(AstNode* nodep) - : m_libName{v3Global.opt.protectLib()} + : m_libName{v3Global.opt.libCreate()} , m_topName{v3Global.opt.prefix()} { iterate(nodep); } diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 6bde19f70..2d20c24c5 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -536,7 +536,7 @@ static void process() { } // Output DPI protected library files - if (!v3Global.opt.protectLib().empty()) { + if (!v3Global.opt.libCreate().empty()) { V3ProtectLib::protect(); V3EmitV::emitvFiles(); V3EmitC::emitcFiles(); diff --git a/test_regress/t/t_lib.pl b/test_regress/t/t_lib.pl new file mode 100755 index 000000000..93aa4bfd8 --- /dev/null +++ b/test_regress/t/t_lib.pl @@ -0,0 +1,70 @@ +#!/usr/bin/env perl +# Makes the test run with tracing enabled by default, can be overridden +# with --notrace +unshift(@ARGV, "--trace"); +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2019 by Todd Strader. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios( + vlt => 1, + xsim => 1, + ); + +top_filename("t/t_lib_prot.v"); + +$Self->{sim_time} = $Self->{benchmark} * 100 if $Self->{benchmark}; + +my $secret_prefix = "secret"; +my $secret_dir = "$Self->{obj_dir}/$secret_prefix"; +mkdir $secret_dir; + +while (1) { + # Always compile the secret file with Verilator no matter what simulator + # we are testing with + run(logfile => "$secret_dir/vlt_compile.log", + cmd => ["perl", + "$ENV{VERILATOR_ROOT}/bin/verilator", + "--prefix", + "Vt_lib_prot_secret", + "-cc", + "-Mdir", + $secret_dir, + "--lib-create", + $secret_prefix, + "t/t_lib_prot_secret.v"], + verilator_run => 1, + ); + last if $Self->{errors}; + + run(logfile => "$secret_dir/secret_gcc.log", + cmd=>[$ENV{MAKE}, + "-C", + $secret_dir, + "-f", + "Vt_lib_prot_secret.mk"]); + last if $Self->{errors}; + + compile( + verilator_flags2 => ["$secret_dir/secret.sv", + "-LDFLAGS", + "$secret_prefix/libsecret.a"], + xsim_flags2 => ["$secret_dir/secret.sv"], + ); + + execute( + check_finished => 1, + xsim_run_flags2 => ["--sv_lib", + "$secret_dir/libsecret", + "--dpi_absolute"], + ); + + ok(1); + last; +} +1; diff --git a/test_regress/t/t_lib_prot_inout_bad.out b/test_regress/t/t_lib_prot_inout_bad.out index 1b58aebdb..d2ff6d8e6 100644 --- a/test_regress/t/t_lib_prot_inout_bad.out +++ b/test_regress/t/t_lib_prot_inout_bad.out @@ -1,4 +1,4 @@ -%Error-UNSUPPORTED: t/t_lib_prot_inout_bad.v:9:28: Unsupported: protect-lib port direction: INOUT +%Error-UNSUPPORTED: t/t_lib_prot_inout_bad.v:9:28: Unsupported: --lib-create port direction: INOUT 9 | inout z, | ^ ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest From c0892dd11c3ecf15f096af3fe03f1ec9a3f3bb80 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Nov 2021 10:16:59 -0500 Subject: [PATCH 40/79] When using --lib-create, disable tracing hash/internals. Partial (#3200). --- src/V3ProtectLib.cpp | 12 +- test_regress/t/t_hier_block_trace.out | 251 ++++++++++++++++++++++++++ test_regress/t/t_hier_block_trace.pl | 35 ++++ 3 files changed, 295 insertions(+), 3 deletions(-) create mode 100644 test_regress/t/t_hier_block_trace.out create mode 100755 test_regress/t/t_hier_block_trace.pl diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index 0b005fd4b..a65aeaa07 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -197,15 +197,21 @@ private: + "_protectlib_final(chandle handle__V);\n\n"); // Local variables - txtp->addText(fl, "chandle handle__V;\n\n"); + // Avoid tracing handle, as it is not a stable value, so breaks vcddiff + // Likewise other internals aren't interesting to the user + txtp->addText(fl, "// verilator tracing_off\n"); + + txtp->addText(fl, "chandle handle__V;\n"); + txtp->addText(fl, "time last_combo_seqnum__V;\n"); + if (m_hasClk) txtp->addText(fl, "time last_seq_seqnum__V;\n"); + txtp->addText(fl, "\n"); + m_comboDeclsp = new AstTextBlock(fl); txtp->addNodep(m_comboDeclsp); m_seqDeclsp = new AstTextBlock(fl); txtp->addNodep(m_seqDeclsp); m_tmpDeclsp = new AstTextBlock(fl); txtp->addNodep(m_tmpDeclsp); - txtp->addText(fl, "\ntime last_combo_seqnum__V;\n"); - if (m_hasClk) txtp->addText(fl, "time last_seq_seqnum__V;\n\n"); // CPP hash value addComment(txtp, fl, "Hash value to make sure this file and the corresponding"); diff --git a/test_regress/t/t_hier_block_trace.out b/test_regress/t/t_hier_block_trace.out new file mode 100644 index 000000000..91473c385 --- /dev/null +++ b/test_regress/t/t_hier_block_trace.out @@ -0,0 +1,251 @@ +$version Generated by VerilatedVcd $end +$date Sun Nov 14 10:12:01 2021 $end +$timescale 1ps $end + + $scope module top $end + $var wire 1 ) clk $end + $scope module t $end + $var wire 1 ) clk $end + $var wire 32 + count [31:0] $end + $var wire 8 # out0 [7:0] $end + $var wire 8 $ out1 [7:0] $end + $var wire 8 % out2 [7:0] $end + $var wire 8 & out3 [7:0] $end + $var wire 8 * out3_2 [7:0] $end + $var wire 8 ' out5 [7:0] $end + $var wire 8 ( out6 [7:0] $end + $scope module i_delay0 $end + $var wire 1 ) clk $end + $var wire 8 & in [7:0] $end + $var wire 8 ' out [7:0] $end + $upscope $end + $scope module i_delay1 $end + $var wire 1 ) clk $end + $var wire 8 ' in [7:0] $end + $var wire 8 ( out [7:0] $end + $upscope $end + $scope module i_sub0 $end + $var wire 1 ) clk $end + $var wire 8 & in [7:0] $end + $var wire 8 # out [7:0] $end + $scope module i_sub0 $end + $var wire 1 ) clk $end + $var wire 8 & in [7:0] $end + $var wire 8 # out [7:0] $end + $upscope $end + $upscope $end + $scope module i_sub1 $end + $var wire 1 ) clk $end + $var wire 8 # in [7:0] $end + $var wire 8 $ out [7:0] $end + $upscope $end + $scope module i_sub2 $end + $var wire 1 ) clk $end + $var wire 8 $ in [7:0] $end + $var wire 8 % out [7:0] $end + $upscope $end + $scope module i_sub3 $end + $var wire 1 ) clk $end + $var wire 8 % in [7:0] $end + $var wire 8 & out [7:0] $end + $upscope $end + $scope module i_sub3_2 $end + $var wire 1 ) clk $end + $var wire 8 % in [7:0] $end + $var wire 8 * out [7:0] $end + $upscope $end + $upscope $end + $upscope $end +$enddefinitions $end + + +#0 +b00000000 # +b00000000 $ +b00000000 % +b00000000 & +b00000000 ' +b00000000 ( +0) +b00000000 * +b00000000000000000000000000000000 + +#10 +b00000001 $ +b00000010 % +b00000010 & +1) +b00000010 * +b00000000000000000000000000000001 + +#15 +0) +#20 +b00000010 # +b00000101 % +b00000011 & +1) +b00000011 * +b00000000000000000000000000000010 + +#25 +0) +#30 +b00000011 # +b00000011 $ +b00000111 % +b00000101 & +b00000010 ' +1) +b00000101 * +b00000000000000000000000000000011 + +#35 +0) +#40 +b00000101 # +b00000100 $ +b00001000 % +b00001000 & +b00000011 ' +1) +b00001000 * +b00000000000000000000000000000100 + +#45 +0) +#50 +b00001000 # +b00000110 $ +b00001010 & +b00000101 ' +1) +b00001010 * +b00000000000000000000000000000101 + +#55 +0) +#60 +b00001010 # +b00001001 $ +b00001010 % +b00001011 & +b00001000 ' +b00000010 ( +1) +b00001011 * +b00000000000000000000000000000110 + +#65 +0) +#70 +b00001011 # +b00001011 $ +b00001011 % +b00001010 ' +b00000011 ( +1) +b00000000000000000000000000000111 + +#75 +0) +#80 +b00001100 $ +b00001101 % +b00001101 & +b00001011 ' +b00000101 ( +1) +b00001101 * +b00000000000000000000000000001000 + +#85 +0) +#90 +b00001101 # +b00010000 % +b00001110 & +b00001000 ( +1) +b00001110 * +b00000000000000000000000000001001 + +#95 +0) +#100 +b00001110 # +b00001110 $ +b00010010 % +b00010000 & +b00001101 ' +b00001010 ( +1) +b00010000 * +b00000000000000000000000000001010 + +#105 +0) +#110 +b00010000 # +b00001111 $ +b00010011 % +b00010011 & +b00001110 ' +b00001011 ( +1) +b00010011 * +b00000000000000000000000000001011 + +#115 +0) +#120 +b00010011 # +b00010001 $ +b00010101 & +b00010000 ' +1) +b00010101 * +b00000000000000000000000000001100 + +#125 +0) +#130 +b00010101 # +b00010100 $ +b00010101 % +b00010110 & +b00010011 ' +b00001101 ( +1) +b00010110 * +b00000000000000000000000000001101 + +#135 +0) +#140 +b00010110 # +b00010110 $ +b00010110 % +b00010101 ' +b00001110 ( +1) +b00000000000000000000000000001110 + +#145 +0) +#150 +b00010111 $ +b00011000 % +b00011000 & +b00010110 ' +b00010000 ( +1) +b00011000 * +b00000000000000000000000000001111 + +#155 +0) +#160 +b00011000 # +b00011011 % +b00011001 & +b00010011 ( +1) +b00011001 * +b00000000000000000000000000010000 + +#165 +0) +#170 +b00011001 # +b00011001 $ +b00011101 % +b00011011 & +b00011000 ' +b00010101 ( +1) +b00011011 * +b00000000000000000000000000010001 + diff --git a/test_regress/t/t_hier_block_trace.pl b/test_regress/t/t_hier_block_trace.pl new file mode 100755 index 000000000..ed212b921 --- /dev/null +++ b/test_regress/t/t_hier_block_trace.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you can +# redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. + +scenarios(vlt_all => 1); + +top_filename("t/t_hier_block.v"); + +# CI environment offers 2 VCPUs, 2 thread setting causes the following warning. +# %Warning-UNOPTTHREADS: Thread scheduler is unable to provide requested parallelism; consider asking for fewer threads. +# So use 6 threads here though it's not optimal in performace wise, but ok. + +compile( + v_flags2 => ['t/t_hier_block.cpp'], + verilator_flags2 => [($Self->{vltmt} ? ' --threads 6' : ''), + '--hierarchical', + '--Wno-TIMESCALEMOD', + '--trace', + '--no-trace-underscore', # To avoid handle mismatches + ], + ); + +execute( + check_finished => 1, + ); + +vcd_identical("$Self->{obj_dir}/simx.vcd", $Self->{golden_filename}); + +ok(1); +1; From d6195e354f0c2bf678a07236b0dba140afb32a18 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Nov 2021 11:05:20 -0500 Subject: [PATCH 41/79] Add some missing COLD attributes. --- src/V3EmitCModel.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 10688305d..a6aa85b40 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -515,12 +515,6 @@ class EmitCModel final : public EmitCFunc { puts("}\n"); } - putSectionDelimiter("Invoke final blocks"); - // ::final - puts("\nvoid " + topClassName() + "::final() {\n"); - puts(topModNameProtected + "__" + protect("_final") + "(&(vlSymsp->TOP));\n"); - puts("}\n"); - putSectionDelimiter("Utilities"); // ::contextp puts("\nVerilatedContext* " + topClassName() + "::contextp() const {\n"); @@ -533,6 +527,12 @@ class EmitCModel final : public EmitCFunc { puts(/**/ "return vlSymsp->name();\n"); puts("}\n"); } + + putSectionDelimiter("Invoke final blocks"); + // ::final + puts("\nVL_ATTR_COLD void " + topClassName() + "::final() {\n"); + puts(topModNameProtected + "__" + protect("_final") + "(&(vlSymsp->TOP));\n"); + puts("}\n"); } void emitTraceMethods(AstNodeModule* modp) { @@ -546,7 +546,7 @@ class EmitCModel final : public EmitCFunc { + "* tracep);\n"); // Static helper function - puts("\nstatic void " + protect("trace_init") + "(void* voidSelf, " + puts("\nVL_ATTR_COLD static void " + protect("trace_init") + "(void* voidSelf, " + v3Global.opt.traceClassBase() + "* tracep, uint32_t code) {\n"); putsDecoration("// Callback from tracep->open()\n"); puts(voidSelfAssign(modp)); @@ -569,7 +569,7 @@ class EmitCModel final : public EmitCFunc { + "* tracep);\n"); // ::trace - puts("\nvoid " + topClassName() + "::trace("); + puts("\nVL_ATTR_COLD void " + topClassName() + "::trace("); puts(v3Global.opt.traceClassBase() + "C* tfp, int, int) {\n"); puts("tfp->spTrace()->addInitCb(&" + protect("trace_init") + ", &(vlSymsp->TOP));\n"); puts(topModNameProtected + "__" + protect("trace_register") From cfa401e01d87af794fa6ce3845cc4496669eaf1b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 14 Nov 2021 12:01:02 -0500 Subject: [PATCH 42/79] Internals: Add lib-create const and improve comments. --- src/V3EmitCModel.cpp | 20 ++++++++++---------- src/V3ProtectLib.cpp | 27 ++++++++++++++------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index a6aa85b40..26495020f 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -531,7 +531,7 @@ class EmitCModel final : public EmitCFunc { putSectionDelimiter("Invoke final blocks"); // ::final puts("\nVL_ATTR_COLD void " + topClassName() + "::final() {\n"); - puts(topModNameProtected + "__" + protect("_final") + "(&(vlSymsp->TOP));\n"); + puts(/**/ topModNameProtected + "__" + protect("_final") + "(&(vlSymsp->TOP));\n"); puts("}\n"); } @@ -564,15 +564,15 @@ class EmitCModel final : public EmitCFunc { puts("}\n"); // Forward declaration - puts("\nvoid " + topModNameProtected + "__" + protect("trace_register") + "(" + puts("\nVL_ATTR_COLD void " + topModNameProtected + "__" + protect("trace_register") + "(" + topModNameProtected + "* vlSelf, " + v3Global.opt.traceClassBase() + "* tracep);\n"); // ::trace puts("\nVL_ATTR_COLD void " + topClassName() + "::trace("); puts(v3Global.opt.traceClassBase() + "C* tfp, int, int) {\n"); - puts("tfp->spTrace()->addInitCb(&" + protect("trace_init") + ", &(vlSymsp->TOP));\n"); - puts(topModNameProtected + "__" + protect("trace_register") + puts(/**/ "tfp->spTrace()->addInitCb(&" + protect("trace_init") + ", &(vlSymsp->TOP));\n"); + puts(/**/ topModNameProtected + "__" + protect("trace_register") + "(&(vlSymsp->TOP), tfp->spTrace());\n"); puts("}\n"); } @@ -582,16 +582,16 @@ class EmitCModel final : public EmitCFunc { puts("\nVerilatedSerialize& operator<<(VerilatedSerialize& os, " + topClassName() + "& rhs) {\n"); - puts("Verilated::quiesce();\n"); - puts("rhs.vlSymsp->" + protect("__Vserialize") + "(os);\n"); - puts("return os;\n"); + puts(/**/ "Verilated::quiesce();\n"); + puts(/**/ "rhs.vlSymsp->" + protect("__Vserialize") + "(os);\n"); + puts(/**/ "return os;\n"); puts("}\n"); puts("\nVerilatedDeserialize& operator>>(VerilatedDeserialize& os, " + topClassName() + "& rhs) {\n"); - puts("Verilated::quiesce();\n"); - puts("rhs.vlSymsp->" + protect("__Vdeserialize") + "(os);\n"); - puts("return os;\n"); + puts(/**/ "Verilated::quiesce();\n"); + puts(/**/ "rhs.vlSymsp->" + protect("__Vdeserialize") + "(os);\n"); + puts(/**/ "return os;\n"); puts("}\n"); } diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index a65aeaa07..b79fe56df 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -102,9 +102,9 @@ private: } void initialComment(AstTextBlock* txtp, FileLine* fl) { - addComment(txtp, fl, "Creates an instance of the secret module at initial-time"); + addComment(txtp, fl, "Creates an instance of the library module at initial-time"); addComment(txtp, fl, "(one for each instance in the user's design) also evaluates"); - addComment(txtp, fl, "the secret module's initial process"); + addComment(txtp, fl, "the library module's initial process"); } void comboComment(AstTextBlock* txtp, FileLine* fl) { @@ -121,7 +121,7 @@ private: } void finalComment(AstTextBlock* txtp, FileLine* fl) { - addComment(txtp, fl, "Evaluates the secret module's final process"); + addComment(txtp, fl, "Evaluates the library module's final process"); } void createSvFile(FileLine* fl, AstNodeModule* modp) { @@ -192,6 +192,7 @@ private: m_comboIgnorePortsp->addText(fl, "chandle handle__V\n"); txtp->addNodep(m_comboIgnorePortsp); txtp->addText(fl, ");\n\n"); + finalComment(txtp, fl); txtp->addText(fl, "import \"DPI-C\" function void " + m_libName + "_protectlib_final(chandle handle__V);\n\n"); @@ -287,7 +288,7 @@ private: void castPtr(FileLine* fl, AstTextBlock* txtp) { txtp->addText(fl, m_topName - + "_container* handlep__V = " // LCOV_EXCL_LINE // lcov bug + + "_container* const handlep__V = " // LCOV_EXCL_LINE // lcov bug "static_cast<" + m_topName + "_container*>(vhandlep__V);\n"); } @@ -320,23 +321,23 @@ private: txtp->addText(fl, "void " + m_libName + "_protectlib_check_hash" "(int protectlib_hash__V) {\n"); - m_cHashValuep = new AstTextBlock(fl, "int expected_hash__V = "); + m_cHashValuep = new AstTextBlock(fl, "const int expected_hash__V = "); txtp->addNodep(m_cHashValuep); - txtp->addText(fl, "if (protectlib_hash__V != expected_hash__V) {\n"); - txtp->addText(fl, "fprintf(stderr, \"%%Error: cannot use " + m_libName + txtp->addText(fl, /**/ "if (protectlib_hash__V != expected_hash__V) {\n"); + txtp->addText(fl, /****/ "fprintf(stderr, \"%%Error: cannot use " + m_libName + " library, " "Verliog (%u) and library (%u) hash values do not " "agree\\n\", protectlib_hash__V, expected_hash__V);\n"); - txtp->addText(fl, "std::exit(EXIT_FAILURE);\n"); - txtp->addText(fl, "}\n"); + txtp->addText(fl, /****/ "std::exit(EXIT_FAILURE);\n"); + txtp->addText(fl, /**/ "}\n"); txtp->addText(fl, "}\n\n"); // Initial initialComment(txtp, fl); txtp->addText(fl, "void* " + m_libName + "_protectlib_create(const char* scopep__V) {\n"); - txtp->addText(fl, m_topName + "_container* handlep__V = new " + m_topName + txtp->addText(fl, /**/ m_topName + "_container* const handlep__V = new " + m_topName + "_container(scopep__V);\n"); - txtp->addText(fl, "return handlep__V;\n"); + txtp->addText(fl, /**/ "return handlep__V;\n"); txtp->addText(fl, "}\n\n"); // Updates @@ -382,8 +383,8 @@ private: finalComment(txtp, fl); txtp->addText(fl, "void " + m_libName + "_protectlib_final(void* vhandlep__V) {\n"); castPtr(fl, txtp); - txtp->addText(fl, "handlep__V->final();\n"); - txtp->addText(fl, "delete handlep__V;\n"); + txtp->addText(fl, /**/ "handlep__V->final();\n"); + txtp->addText(fl, /**/ "delete handlep__V;\n"); txtp->addText(fl, "}\n\n"); txtp->addText(fl, "}\n"); From cff9f8143e02da0af058e30f206ef92e03104797 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 07:06:43 -0500 Subject: [PATCH 43/79] Commentary --- docs/guide/extensions.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/guide/extensions.rst b/docs/guide/extensions.rst index 6e2d26495..0b17a725e 100644 --- a/docs/guide/extensions.rst +++ b/docs/guide/extensions.rst @@ -48,6 +48,14 @@ or "`ifdef`"'s may break other tools. Verilog functions where the variable is flattened out, and also enable other optimizations. + Verilator does not use any text inside the quotes for + ordering/scheduling. If you need the $c to be called at a specific + time, e.g. when a variable changes, then the $c must be under an + appropriate sensitivity statement, e.g. :code:`always @(posedge clk) + $c("func()")` to call it on every edge, or e.g. :code:`always @* + c("func(",a,")")` to call it when :code:`a` changes (the latter working + because :code:`a` is outside the quotes). + If you will be reading or writing any Verilog variables inside the C++ functions, the Verilog signals must be declared with :option:`/*verilator&32;public*/` metacomments. From 106d635d0ff2de3bf63028c21a6cc2b50b44cedd Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 07:10:48 -0500 Subject: [PATCH 44/79] Fix vluint64 portability (#3150). --- src/V3Config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/V3Config.h b/src/V3Config.h index 2931b53e3..1559e64a0 100644 --- a/src/V3Config.h +++ b/src/V3Config.h @@ -48,7 +48,7 @@ public: static void applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp); static void applyVarAttr(AstNodeModule* modulep, AstNodeFTask* ftaskp, AstVar* varp); - static uint64_t getProfileData(const string& model, const string& key); + static vluint64_t getProfileData(const string& model, const string& key); static FileLine* getProfileDataFileLine(); static bool waive(FileLine* filelinep, V3ErrorCode code, const string& message); }; From d2a8fa74409d5fc35db36b67fd15aa0dbccbf0f4 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 17:46:08 -0500 Subject: [PATCH 45/79] Fix display of empty string constant (#3207). --- Changes | 1 + src/V3Number.h | 1 + src/verilog.y | 10 +++++++++- test_regress/t/t_display.out | 1 + test_regress/t/t_display.v | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 8b62759f9..8c089b387 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,7 @@ Verilator 4.215 devel * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] +* Fix display of empty string constant (#3207). [Julie Schwartz] Verilator 4.214 2021-10-17 diff --git a/src/V3Number.h b/src/V3Number.h index f43fd6619..e62ad8562 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -233,6 +233,7 @@ public: V3Number(String, AstNode* nodep, const string& value) { init(nodep, 0); setString(value); + m_fromString = true; } class Null {}; V3Number(Null, AstNode* nodep) { diff --git a/src/verilog.y b/src/verilog.y index 7d6e44d16..18779d05e 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -5006,7 +5006,15 @@ str: // yaSTRING but with \{escapes} need decoded strAsInt: yaSTRING - { $$ = new AstConst{$1, AstConst::VerilogStringLiteral(), GRAMMARP->deQuote($1, *$1)}; } + { if ($1->empty()) { + // else "" is not representable as number as is width 0 + // TODO all strings should be represented this way + // until V3Width converts as/if needed to a numerical constant + $$ = new AstConst{$1, AstConst::String{}, GRAMMARP->deQuote($1, *$1)}; + } else { + $$ = new AstConst{$1, AstConst::VerilogStringLiteral(), GRAMMARP->deQuote($1, *$1)}; + } + } ; strAsIntIgnore: // strAsInt, but never matches for when expr shouldn't parse strings diff --git a/test_regress/t/t_display.out b/test_regress/t/t_display.out index 0475a1952..5b3ba2aa9 100644 --- a/test_regress/t/t_display.out +++ b/test_regress/t/t_display.out @@ -56,6 +56,7 @@ hello, from a concatenated string. hello, from a concatenated format string [0]. extra argument: 0 0 : pre argument after +empty: >< [0] Embedded tab ' ' and <#013> return [0] Embedded multiline diff --git a/test_regress/t/t_display.v b/test_regress/t/t_display.v index 3f191f9b1..fa280f616 100644 --- a/test_regress/t/t_display.v +++ b/test_regress/t/t_display.v @@ -149,6 +149,7 @@ module t; $write("hel", "lo, fr", "om a concatenated format string [%0t].\n", $time); $display("extra argument: ", $time); $display($time,, ": pre argument",, "after"); + $display("empty: >%s<", ""); $write("[%0t] Embedded tab '\t' and \r return\n", $time); $display("[%0t] Embedded\ multiline", $time); From 0abc856be94b37e5aaae0bc6040f905845f452f9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 17:54:07 -0500 Subject: [PATCH 46/79] Fix %0 format on $value$plusargs. --- Changes | 1 + include/verilated.cpp | 1 + test_regress/t/t_sys_plusargs.v | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 8c089b387..0a5f0c2f2 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,7 @@ Verilator 4.215 devel * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] * Fix display of empty string constant (#3207). [Julie Schwartz] +* Fix %0 format on $value$plusargs. Verilator 4.214 2021-10-17 diff --git a/include/verilated.cpp b/include/verilated.cpp index 173f0fc7f..0386a40b9 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1600,6 +1600,7 @@ IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_M inPct = true; } else if (!inPct) { // Normal text prefix += *posp; + } else if (inPct && posp[0] == '0') { // %0 } else { // Format character switch (std::tolower(*posp)) { case '%': diff --git a/test_regress/t/t_sys_plusargs.v b/test_regress/t/t_sys_plusargs.v index 73600e6cd..55daf5085 100644 --- a/test_regress/t/t_sys_plusargs.v +++ b/test_regress/t/t_sys_plusargs.v @@ -23,11 +23,16 @@ module t; if ($test$plusargs("NOTTHERE")!==0) $stop; p_i = 10; - if ($value$plusargs("NOTTHERE%d", p_i)!==0) $stop; + if ($value$plusargs("NOTTHERE%d", p_i) !== 0) $stop; + if ($value$plusargs("NOTTHERE%0d", p_i) !== 0) $stop; if (p_i !== 10) $stop; p_i = 0; - if ($value$plusargs("INT=%d", p_i)!==1) $stop; + if ($value$plusargs("INT=%d", p_i) !== 1) $stop; + if (p_i !== 32'd1234) $stop; + + p_i = 0; + if ($value$plusargs("INT=%0d", p_i) !== 1) $stop; if (p_i !== 32'd1234) $stop; p_i = 0; From 2ccf49031b86a54fdfc766e8b3ac14cc1b752d3b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 18:50:52 -0500 Subject: [PATCH 47/79] Fix $display of signed/unsigned without format (#3207). --- Changes | 1 + src/V3Width.cpp | 2 ++ test_regress/t/t_debug_emitv.out | 4 ++-- test_regress/t/t_display.out | 6 ++++++ test_regress/t/t_display.v | 6 ++++++ test_regress/t/t_sys_file_basic.out | 2 +- 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 0a5f0c2f2..cc0bc92e2 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,7 @@ Verilator 4.215 devel * Improve --thread verilation-time performance. * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] +* Fix $display of signed/unsigned without format (#3207). [Julie Schwartz] * Fix nested generate if genblk naming (#3189). [yanx21] * Fix display of empty string constant (#3207). [Julie Schwartz] * Fix %0 format on $value$plusargs. diff --git a/src/V3Width.cpp b/src/V3Width.cpp index d53574c2f..efb66f75b 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -3916,6 +3916,8 @@ private: ch = 'g'; } else if (argp && argp->isString()) { ch = '@'; + } else if (nodep->missingArgChar() == 'd' && argp->isSigned()) { + ch = '~'; } else { ch = nodep->missingArgChar(); } diff --git a/test_regress/t/t_debug_emitv.out b/test_regress/t/t_debug_emitv.out index d10784ec3..c7b2e8201 100644 --- a/test_regress/t/t_debug_emitv.out +++ b/test_regress/t/t_debug_emitv.out @@ -88,7 +88,7 @@ module Vt_debug_emitv___024root; $fflush(t.fd); $fscanf(t.fd, "%d", t.sum); ; - $fdisplay(32'h69203d20, "%d", t.sum); + $fdisplay(32'h69203d20, "%~", t.sum); $fwrite(t.fd, "hello"); $readmemh(t.fd, t.array); $readmemh(t.fd, t.array, 32'sh0); @@ -161,7 +161,7 @@ module Vt_debug_emitv___024root; else begin $display("0"); end - $display("%d%d", t._Vpast_0_0t._Vpast_1_0, + $display("%~%~", t._Vpast_0_0t._Vpast_1_0, t._Vpast_1_0); t.str = $sformatf("cyc=%~", t.cyc); ; diff --git a/test_regress/t/t_display.out b/test_regress/t/t_display.out index 5b3ba2aa9..7774e9e34 100644 --- a/test_regress/t/t_display.out +++ b/test_regress/t/t_display.out @@ -51,6 +51,12 @@ o: 014 014 b: 000001100 000001100 +-1431655766 +-1431655766 +4294967294 +4294967294 +2863311530 +2863311530 [0] hello, from a very long string. Percent %s are literally substituted in. hello, from a concatenated string. hello, from a concatenated format string [0]. diff --git a/test_regress/t/t_display.v b/test_regress/t/t_display.v index fa280f616..0da4596e2 100644 --- a/test_regress/t/t_display.v +++ b/test_regress/t/t_display.v @@ -142,6 +142,12 @@ module t; $writeb; $displayb; $writeb("b: "); $writeb(nine); $writeb(" "); $displayb(nine); $writeo; $displayo; + $display("%d", $signed(32'haaaaaaaa)); // -1431655766 + $display($signed(32'haaaaaaaa)); // -1431655766 + $display("%d", $unsigned(-2)); // 4294967294 + $display($unsigned(-2)); // 4294967294 + $display("%d", 32'haaaaaaaa); // 2863311530 + $display(32'haaaaaaaa); // 2863311530 $display("[%0t] %s%s%s", $time, "hel", "lo, fr", "om a very long string. Percent %s are literally substituted in."); diff --git a/test_regress/t/t_sys_file_basic.out b/test_regress/t/t_sys_file_basic.out index 848109f37..931ff0fc2 100644 --- a/test_regress/t/t_sys_file_basic.out +++ b/test_regress/t/t_sys_file_basic.out @@ -1,6 +1,6 @@ [0] hello v=12345667 [0] Hello2 -d: 12 12 +d: 12 12 h: 0000000c 0000000c From 1e440765c0ee2deb962a03ecb18c187443f9a069 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 18:52:53 -0500 Subject: [PATCH 48/79] Commentary, about previous commit: Fix display of signed without format (#3204). --- Changes | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes b/Changes index cc0bc92e2..c56ff829a 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,7 @@ Verilator 4.215 devel * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix $display of signed/unsigned without format (#3207). [Julie Schwartz] * Fix nested generate if genblk naming (#3189). [yanx21] +* Fix display of signed without format (#3204). [Julie Schwartz] * Fix display of empty string constant (#3207). [Julie Schwartz] * Fix %0 format on $value$plusargs. From 96b7831243125fe4d233cb9ee7429e78a7f56da6 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 17 Nov 2021 18:56:11 -0500 Subject: [PATCH 49/79] Commentary: C++14 moves to 2023. --- docs/guide/deprecations.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/deprecations.rst b/docs/guide/deprecations.rst index 8d3124175..9f8edda3b 100644 --- a/docs/guide/deprecations.rst +++ b/docs/guide/deprecations.rst @@ -9,7 +9,7 @@ The following deprecated items are scheduled for future removal: C++11 compiler support Verilator currently requires C++11 or newer compilers. Verilator will require C++14 or newer compilers for both compiling Verilator and - compiling Verilated models no sooner than January 2022. + compiling Verilated models no sooner than January 2023. Verilated_heavy.h The legacy "verilated_heavy.h" include was replaced with just including From a14394dbb5b8b8b6cbbd4e6cbc3976419ffd69a4 Mon Sep 17 00:00:00 2001 From: Julie Schwartz Date: Thu, 18 Nov 2021 23:15:02 +1300 Subject: [PATCH 50/79] Commentary: remove duplicate/wrong change-log entry (#3212) --- Changes | 1 - docs/CONTRIBUTORS | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Changes b/Changes index c56ff829a..be8d3300a 100644 --- a/Changes +++ b/Changes @@ -21,7 +21,6 @@ Verilator 4.215 devel * Improve --thread verilation-time performance. * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] -* Fix $display of signed/unsigned without format (#3207). [Julie Schwartz] * Fix nested generate if genblk naming (#3189). [yanx21] * Fix display of signed without format (#3204). [Julie Schwartz] * Fix display of empty string constant (#3207). [Julie Schwartz] diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 898bd3ba7..125977415 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -45,6 +45,7 @@ John Coiner John Demme Jonathan Drolet Josh Redford +Julie Schwartz Julien Margetts Kaleb Barrett Kanad Kanhere From b1b92b7dd4486539ab0c2abb85d8230a2f25ef2a Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 23 Nov 2021 07:27:41 -0500 Subject: [PATCH 51/79] Fix hang on recursive definition error (#3199). --- Changes | 1 + src/V3LinkDot.cpp | 12 ++++++++++-- test_regress/t/t_type_param_circ_bad.out | 4 ++++ test_regress/t/t_type_param_circ_bad.pl | 19 +++++++++++++++++++ test_regress/t/t_type_param_circ_bad.v | 20 ++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 test_regress/t/t_type_param_circ_bad.out create mode 100755 test_regress/t/t_type_param_circ_bad.pl create mode 100644 test_regress/t/t_type_param_circ_bad.v diff --git a/Changes b/Changes index be8d3300a..1201afb71 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,7 @@ Verilator 4.215 devel * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] +* Fix hang on recursive definition error (#3199). [Jonathan Kimmitt] * Fix display of signed without format (#3204). [Julie Schwartz] * Fix display of empty string constant (#3207). [Julie Schwartz] * Fix %0 format on $value$plusargs. diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 60dd287a6..402638d82 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2952,8 +2952,16 @@ private: nodep->classOrPackagep(foundp->classOrPackagep()); } else if (AstParamTypeDType* defp = foundp ? VN_CAST(foundp->nodep(), ParamTypeDType) : nullptr) { - nodep->refDTypep(defp); - nodep->classOrPackagep(foundp->classOrPackagep()); + if (defp == nodep->backp()) { // Where backp is typically typedef + nodep->v3error("Reference to '" << m_ds.m_dotText + << (m_ds.m_dotText == "" ? "" : ".") + << nodep->prettyName() << "'" + << " type would form a recursive definition"); + nodep->refDTypep(nodep->findVoidDType()); // Try to reduce later errors + } else { + nodep->refDTypep(defp); + nodep->classOrPackagep(foundp->classOrPackagep()); + } } else if (AstClass* defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) { AstNode* paramsp = nodep->paramsp(); if (paramsp) paramsp->unlinkFrBackWithNext(); diff --git a/test_regress/t/t_type_param_circ_bad.out b/test_regress/t/t_type_param_circ_bad.out new file mode 100644 index 000000000..832185a4b --- /dev/null +++ b/test_regress/t/t_type_param_circ_bad.out @@ -0,0 +1,4 @@ +%Error: t/t_type_param_circ_bad.v:14:27: Reference to 'SZ' type would form a recursive definition + 14 | # (parameter type SZ = SZ) + | ^~ +%Error: Exiting due to diff --git a/test_regress/t/t_type_param_circ_bad.pl b/test_regress/t/t_type_param_circ_bad.pl new file mode 100755 index 000000000..59ba0d6c6 --- /dev/null +++ b/test_regress/t/t_type_param_circ_bad.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(linter => 1); + +lint( + fails => $Self->{vlt_all}, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_type_param_circ_bad.v b/test_regress/t/t_type_param_circ_bad.v new file mode 100644 index 000000000..9eea5887a --- /dev/null +++ b/test_regress/t/t_type_param_circ_bad.v @@ -0,0 +1,20 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +package pkg; + parameter [7:0] WIDTH = 8; + typedef logic [WIDTH-1:0] SZ; +endpackage // pkg + +module t + import pkg::*; + # (parameter type SZ = SZ) + (input SZ i, + output SZ o); + + always_comb o = i; + +endmodule From c14bbb9421a33430a7990c5826a279bbe6bb2189 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 23 Nov 2021 18:15:21 -0500 Subject: [PATCH 52/79] Fix incorrect width after and-or optimization (#3208). --- Changes | 1 + src/V3Const.cpp | 2 ++ src/astgen | 4 ++-- test_regress/t/t_display_concat.out | 3 +++ test_regress/t/t_display_concat.pl | 22 ++++++++++++++++++++ test_regress/t/t_display_concat.v | 32 +++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 test_regress/t/t_display_concat.out create mode 100755 test_regress/t/t_display_concat.pl create mode 100644 test_regress/t/t_display_concat.v diff --git a/Changes b/Changes index 1201afb71..b5750639a 100644 --- a/Changes +++ b/Changes @@ -25,6 +25,7 @@ Verilator 4.215 devel * Fix hang on recursive definition error (#3199). [Jonathan Kimmitt] * Fix display of signed without format (#3204). [Julie Schwartz] * Fix display of empty string constant (#3207). [Julie Schwartz] +* Fix incorrect width after and-or optimization (#3208). [Julie Schwartz] * Fix %0 format on $value$plusargs. diff --git a/src/V3Const.cpp b/src/V3Const.cpp index a1277871e..69a212c84 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1670,6 +1670,7 @@ private: if (operandsSame(llp, rlp)) { lp->lhsp(llp); lp->rhsp(nodep); + lp->dtypeFrom(nodep); nodep->lhsp(lrp); nodep->rhsp(rrp); VL_DO_DANGLING(rp->deleteTree(), rp); @@ -1677,6 +1678,7 @@ private: } else if (operandsSame(lrp, rrp)) { lp->lhsp(nodep); lp->rhsp(rrp); + lp->dtypeFrom(nodep); nodep->lhsp(llp); nodep->rhsp(rlp); VL_DO_DANGLING(rp->deleteTree(), rp); diff --git a/src/astgen b/src/astgen index 579a7f014..7fe3d9fdd 100755 --- a/src/astgen +++ b/src/astgen @@ -283,8 +283,8 @@ class Cpt: self.print("\t// " + typefunc['comment'] + "\n") self.print("\tif (" + typefunc['match_if'] + ") {\n") self.print("\t UINFO(" + str(typefunc['uinfo_level']) + - ",cvtToHex(nodep)" + "<<\" " + typefunc['uinfo'] + - "\\n\");\n") + ", cvtToHex(nodep)" + " << \" " + + typefunc['uinfo'] + "\\n\");\n") self.print("\t " + typefunc['exec_func'] + "\n") self.print("\t return true;\n") self.print("\t}\n") diff --git a/test_regress/t/t_display_concat.out b/test_regress/t/t_display_concat.out new file mode 100644 index 000000000..abcf79f7a --- /dev/null +++ b/test_regress/t/t_display_concat.out @@ -0,0 +1,3 @@ +abcd=abcd +ab0d=ab0d +*-* All Finished *-* diff --git a/test_regress/t/t_display_concat.pl b/test_regress/t/t_display_concat.pl new file mode 100755 index 000000000..03b63c1a0 --- /dev/null +++ b/test_regress/t/t_display_concat.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2021 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); + +compile( + ); + +execute( + check_finished => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_display_concat.v b/test_regress/t/t_display_concat.v new file mode 100644 index 000000000..f0fa3fa81 --- /dev/null +++ b/test_regress/t/t_display_concat.v @@ -0,0 +1,32 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t(/*AUTOARG*/ + // Inputs + clk + ); + input clk; + + int cyc = 0; + always @ (posedge clk) ++cyc; + + reg [15 : 0] t2; + + always@(posedge clk) begin + if (cyc == 0) begin + t2 <= 16'd0; + end + else if (cyc == 2) begin + t2 <= 16'habcd; + end + else if (cyc == 4) begin + $display("abcd=%x", t2); + $display("ab0d=%x", { t2[15:8], 4'd0, t2[3:0] }); + $write("*-* All Finished *-*\n"); + $finish(32'd0); + end + end +endmodule From e7ebe0e280d44323680c53c05c041965b7cc2f40 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 23 Nov 2021 18:22:16 -0500 Subject: [PATCH 53/79] Fix $fopen etc on integer arrays (#3214). --- Changes | 1 + src/V3EmitCFunc.cpp | 2 +- src/V3LinkResolve.cpp | 6 ++---- test_regress/t/t_sys_file_basic.v | 7 +++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index b5750639a..3377a875b 100644 --- a/Changes +++ b/Changes @@ -26,6 +26,7 @@ Verilator 4.215 devel * Fix display of signed without format (#3204). [Julie Schwartz] * Fix display of empty string constant (#3207). [Julie Schwartz] * Fix incorrect width after and-or optimization (#3208). [Julie Schwartz] +* Fix $fopen etc on integer arrays (#3214). [adrienlemasle] * Fix %0 format on $value$plusargs. diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 89d6b47db..55280e201 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -679,7 +679,7 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, const string& varNameP return ""; } else if (basicp) { bool zeroit - = (varp->attrFileDescr() // Zero so we don't core dump if never $fopen + = (varp->attrFileDescr() // Zero so we don't do file IO if never $fopen || (basicp && basicp->isZeroInit()) || (v3Global.opt.underlineZero() && !varp->name().empty() && varp->name()[0] == '_') || (v3Global.opt.xInitial() == "fast" || v3Global.opt.xInitial() == "0")); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index ef77a6ae9..d88a03c51 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -403,10 +403,8 @@ private: } static void expectDescriptor(AstNode* nodep, AstNodeVarRef* filep) { - if (!filep) { - nodep->v3warn(E_UNSUPPORTED, - "Unsupported: $fopen/$fclose/$f* descriptor must be a simple variable"); - } + // This might fail on complex expressions like arrays + // We use attrFileDescr() only for lint suppression, so that's ok if (filep && filep->varp()) filep->varp()->attrFileDescr(true); } diff --git a/test_regress/t/t_sys_file_basic.v b/test_regress/t/t_sys_file_basic.v index d38c8580a..10bbf62bc 100644 --- a/test_regress/t/t_sys_file_basic.v +++ b/test_regress/t/t_sys_file_basic.v @@ -14,6 +14,7 @@ module t; integer file; + integer file_a[0]; integer chars; reg [1*8:1] letterl; @@ -91,8 +92,10 @@ module t; begin // Check quadword access; a little strange, but it's legal to open "." - file = $fopen(".","r"); - $fclose(file); + // Also checks using array reference + file_a[0] = $fopen(".","r"); + if (file_a[0] == 0) $stop; + $fclose(file_a[0]); end begin From 4184ad1921721667c75dc3a72b33bf4dc5038c32 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 23 Nov 2021 18:27:40 -0500 Subject: [PATCH 54/79] Commentary --- .github/ISSUE_TEMPLATE/bug_report.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 048e84fa1..b5956e2de 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -13,4 +13,6 @@ Can you attach an example that shows the issue? (Must be openly licensed, ideal What 'verilator --version' are you using? Did you try it with the git master version? +What OS and distribution are you using? + Would you be willing to try to fix Verilator yourself with assistance? From 31079ca8b50d2c13e3a1ced562c322a566a0f17b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 25 Nov 2021 07:50:47 -0500 Subject: [PATCH 55/79] Fix $size on dynamic strings (#3216). --- Changes | 3 ++- src/V3Width.cpp | 39 ++++++++++++++++++++------------ test_regress/t/t_string_size.out | 4 ++++ test_regress/t/t_string_size.pl | 22 ++++++++++++++++++ test_regress/t/t_string_size.v | 27 ++++++++++++++++++++++ 5 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 test_regress/t/t_string_size.out create mode 100755 test_regress/t/t_string_size.pl create mode 100644 test_regress/t/t_string_size.v diff --git a/Changes b/Changes index 3377a875b..10f50d405 100644 --- a/Changes +++ b/Changes @@ -27,7 +27,8 @@ Verilator 4.215 devel * Fix display of empty string constant (#3207). [Julie Schwartz] * Fix incorrect width after and-or optimization (#3208). [Julie Schwartz] * Fix $fopen etc on integer arrays (#3214). [adrienlemasle] -* Fix %0 format on $value$plusargs. +* Fix $size on dynamic strings (#3216). +* Fix %0 format on $value$plusargs (#3217). Verilator 4.214 2021-10-17 diff --git a/src/V3Width.cpp b/src/V3Width.cpp index efb66f75b..15df19767 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1351,7 +1351,8 @@ private: case AstAttrType::DIM_RIGHT: case AstAttrType::DIM_SIZE: { UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression"); - if (VN_IS(nodep->fromp()->dtypep(), QueueDType)) { + AstNodeDType* const dtypep = nodep->fromp()->dtypep(); + if (VN_IS(dtypep, QueueDType)) { switch (nodep->attrType()) { case AstAttrType::DIM_SIZE: { AstNode* const newp = new AstCMethodHard( @@ -1398,26 +1399,34 @@ private: default: nodep->v3error("Unhandled attribute type"); } } else { - std::pair dimpair - = nodep->fromp()->dtypep()->skipRefp()->dimensions(true); - uint32_t msbdim = dimpair.first + dimpair.second; + const std::pair dimpair = dtypep->skipRefp()->dimensions(true); + const uint32_t msbdim = dimpair.first + dimpair.second; if (!nodep->dimp() || msbdim < 1) { - const int dim = 1; - AstConst* const newp = dimensionValue( - nodep->fileline(), nodep->fromp()->dtypep(), nodep->attrType(), dim); - nodep->replaceWith(newp); - VL_DO_DANGLING(nodep->deleteTree(), nodep); + if (VN_IS(dtypep, BasicDType) && dtypep->basicp()->isString()) { + // IEEE undocumented but $bits(string) must give length(string) * 8 + AstNode* const newp = new AstShiftL{ + nodep->fileline(), + new AstLenN{nodep->fileline(), nodep->fromp()->unlinkFrBack()}, + new AstConst{nodep->fileline(), 3}, // * 8 + 32}; + nodep->replaceWith(newp); + VL_DO_DANGLING(pushDeletep(nodep), nodep); + } else { + const int dim = 1; + AstConst* const newp + = dimensionValue(nodep->fileline(), dtypep, nodep->attrType(), dim); + nodep->replaceWith(newp); + VL_DO_DANGLING(nodep->deleteTree(), nodep); + } } else if (VN_IS(nodep->dimp(), Const)) { const int dim = VN_AS(nodep->dimp(), Const)->toSInt(); - AstConst* const newp = dimensionValue( - nodep->fileline(), nodep->fromp()->dtypep(), nodep->attrType(), dim); + AstConst* const newp + = dimensionValue(nodep->fileline(), dtypep, nodep->attrType(), dim); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else { // Need a runtime lookup table. Yuk. - UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, - "Unsized expression"); - AstVar* const varp - = dimensionVarp(nodep->fromp()->dtypep(), nodep->attrType(), msbdim); + UASSERT_OBJ(nodep->fromp() && dtypep, nodep, "Unsized expression"); + AstVar* const varp = dimensionVarp(dtypep, nodep->attrType(), msbdim); AstNode* const dimp = nodep->dimp()->unlinkFrBack(); AstVarRef* const varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); diff --git a/test_regress/t/t_string_size.out b/test_regress/t/t_string_size.out new file mode 100644 index 000000000..cd674d097 --- /dev/null +++ b/test_regress/t/t_string_size.out @@ -0,0 +1,4 @@ +>< == >< +>< == >< +> < == > < +*-* All Finished *-* diff --git a/test_regress/t/t_string_size.pl b/test_regress/t/t_string_size.pl new file mode 100755 index 000000000..03b63c1a0 --- /dev/null +++ b/test_regress/t/t_string_size.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2021 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); + +compile( + ); + +execute( + check_finished => 1, + expect_filename => $Self->{golden_filename}, + ); + +ok(1); +1; diff --git a/test_regress/t/t_string_size.v b/test_regress/t/t_string_size.v new file mode 100644 index 000000000..f9d87caa3 --- /dev/null +++ b/test_regress/t/t_string_size.v @@ -0,0 +1,27 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 by wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +module t; + parameter string ES = ""; + parameter EI = ""; // B is an integer of width 8 + parameter string OS = "O"; + parameter OI = "O"; // B is an integer of width 8 + + initial begin + $display(">< == >%s<", ""); + $display(">< == >%s<", ES); + $display("> < == >%s<", EI); + + if ($bits("") != 0) $stop; + if ($bits("A") != 8) $stop; + if ($bits(ES) != 0) $stop; + if ($bits(OS) != 8) $stop; + if ($bits(OI) != 8) $stop; + + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule From 62387a0e326460e3dd1fcd7bda4f7b85506b78b4 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 25 Nov 2021 08:03:27 -0500 Subject: [PATCH 56/79] Fix display of empty string constant (#3207) (#3215). --- Changes | 2 +- src/V3Width.cpp | 10 +++++++++- test_regress/t/t_string_size.v | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 10f50d405..ba85d7c42 100644 --- a/Changes +++ b/Changes @@ -24,7 +24,7 @@ Verilator 4.215 devel * Fix nested generate if genblk naming (#3189). [yanx21] * Fix hang on recursive definition error (#3199). [Jonathan Kimmitt] * Fix display of signed without format (#3204). [Julie Schwartz] -* Fix display of empty string constant (#3207). [Julie Schwartz] +* Fix display of empty string constant (#3207) (#3215). [Julie Schwartz] * Fix incorrect width after and-or optimization (#3208). [Julie Schwartz] * Fix $fopen etc on integer arrays (#3214). [adrienlemasle] * Fix $size on dynamic strings (#3216). diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 15df19767..284eeab1e 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1939,7 +1939,15 @@ private: } else { issigned = bdtypep->isSigned(); } - if (nodep->valuep()->dtypep()->widthSized()) { + if (valueBdtypep->isString()) { + // parameter X = "str", per IEEE is a number, not a string + if (const auto* const constp = VN_CAST(nodep->valuep(), Const)) { + if (constp->num().isString()) { + width = constp->num().toString().length() * 8; + } + } + if (width < 8) width = 8; + } else if (nodep->valuep()->dtypep()->widthSized()) { width = nodep->valuep()->width(); } else { if (nodep->valuep()->width() > 32) { diff --git a/test_regress/t/t_string_size.v b/test_regress/t/t_string_size.v index f9d87caa3..b18b92137 100644 --- a/test_regress/t/t_string_size.v +++ b/test_regress/t/t_string_size.v @@ -10,6 +10,11 @@ module t; parameter string OS = "O"; parameter OI = "O"; // B is an integer of width 8 + parameter bit [31:0] NEST = "NEST"; + parameter bit [31:0] TEST = "TEST"; + bit [31:0] rest; + string s; + initial begin $display(">< == >%s<", ""); $display(">< == >%s<", ES); @@ -18,9 +23,23 @@ module t; if ($bits("") != 0) $stop; if ($bits("A") != 8) $stop; if ($bits(ES) != 0) $stop; + if ($bits(EI) != 8) $stop; if ($bits(OS) != 8) $stop; if ($bits(OI) != 8) $stop; + if (ES == "TEST") $stop; // Illegal in some simulators as not both strings + if (EI == "TEST") $stop; + if (OS == "TEST") $stop; // Illegal in some simulators as not both strings + // verilator lint_off WIDTH + if (OI == "TEST") $stop; + if (rest == "TEST") $stop; + + if (ES == TEST) $stop; + if (EI == TEST) $stop; + if (OS == TEST) $stop; + if (OI == TEST) $stop; + if (rest == TEST) $stop; + $write("*-* All Finished *-*\n"); $finish; end From e87a7269898367c69809878e54e48854125f0539 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 25 Nov 2021 09:05:50 -0500 Subject: [PATCH 57/79] Internals: More const. No functional change intended. --- include/verilated.cpp | 54 +++++++++++----------- include/verilated.h | 2 +- include/verilated_cov.cpp | 15 ++++--- include/verilated_dpi.cpp | 6 +-- include/verilated_funcs.h | 40 +++++++++-------- include/verilated_imp.h | 10 ++--- include/verilated_profiler.h | 4 +- include/verilated_save.cpp | 2 +- include/verilated_save.h | 2 +- include/verilated_sym_props.h | 10 ++--- include/verilated_threads.h | 8 ++-- include/verilated_types.h | 10 ++--- include/verilated_vcd_c.cpp | 8 ++-- include/verilated_vcd_c.h | 2 +- include/verilated_vpi.cpp | 84 +++++++++++++++++------------------ 15 files changed, 130 insertions(+), 127 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 0386a40b9..0320a8d86 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -208,7 +208,7 @@ void VL_FATAL_MT(const char* filename, int linenum, const char* hier, const char std::string _vl_string_vprintf(const char* formatp, va_list ap) VL_MT_SAFE { va_list aq; va_copy(aq, ap); - size_t len = VL_VSNPRINTF(nullptr, 0, formatp, aq); + const size_t len = VL_VSNPRINTF(nullptr, 0, formatp, aq); va_end(aq); if (VL_UNLIKELY(len < 1)) return ""; @@ -387,7 +387,7 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, const WDataInP lwp, const WData if (vw == 1) { // Single divisor word breaks rest of algorithm vluint64_t k = 0; for (int j = uw - 1; j >= 0; --j) { - vluint64_t unw64 = ((k << 32ULL) + static_cast(lwp[j])); + const vluint64_t unw64 = ((k << 32ULL) + static_cast(lwp[j])); owp[j] = unw64 / static_cast(rwp[0]); k = unw64 - static_cast(owp[j]) * static_cast(rwp[0]); } @@ -444,7 +444,7 @@ WDataOutP _vl_moddiv_w(int lbits, WDataOutP owp, const WDataInP lwp, const WData vlsint64_t t = 0; // Must be signed vluint64_t k = 0; for (int i = 0; i < vw; ++i) { - vluint64_t p = qhat * vn[i]; // Multiply by estimate + const vluint64_t p = qhat * vn[i]; // Multiply by estimate t = un[i + j] - k - (p & 0xFFFFFFFFULL); // Subtract un[i + j] = t; k = (p >> 32ULL) - (t >> 32ULL); @@ -698,8 +698,8 @@ std::string _vl_vsformat_time(char* tmp, T ld, int timeunit, bool left, size_t w } } } else { - double shiftd = vl_time_multiplier(shift); - double scaled = ld * shiftd; + const double shiftd = vl_time_multiplier(shift); + const double scaled = ld * shiftd; const double fracDiv = vl_time_multiplier(fracDigits); const double whole = scaled / fracDiv; if (!fracDigits) { @@ -749,7 +749,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } } else { // Format character inPct = false; - char fmt = pos[0]; + const char fmt = pos[0]; switch (fmt) { case '0': // FALLTHRU case '1': // FALLTHRU @@ -809,7 +809,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA output += _vl_vsformat_time(t_tmp, d, timeunit, left, width); } else { const size_t len = pos - pctp + 1; - std::string fmts{pctp, len}; + const std::string fmts{pctp, len}; VL_SNPRINTF(t_tmp, VL_VALUE_STRING_MAX_WIDTH, fmts.c_str(), d); output += t_tmp; } @@ -869,7 +869,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA } digits = append.length(); } - int needmore = width - digits; + const int needmore = width - digits; std::string padding; if (needmore > 0) { if (pctp && pctp[0] && pctp[1] == '0') { // %0 @@ -892,7 +892,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA append = VL_DECIMAL_NW(lbits, lwp); digits = append.length(); } - int needmore = width - digits; + const int needmore = width - digits; std::string padding; if (needmore > 0) { if (pctp && pctp[0] && pctp[1] == '0') { // %0 @@ -953,7 +953,7 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA case 'x': for (; lsb >= 0; --lsb) { lsb = (lsb / 4) * 4; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xf; + const IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xf; output += "0123456789abcdef"[charval]; } break; @@ -1027,7 +1027,7 @@ static inline void _vl_vsss_read_str(FILE* fp, int& floc, const WDataInP fromp, } static inline char* _vl_vsss_read_bin(FILE* fp, int& floc, const WDataInP fromp, const std::string& fstr, char* beginp, std::size_t n, - bool inhibit = false) { + const bool inhibit = false) { // Variant of _vl_vsss_read_str using the same underlying I/O functions but optimized // specifically for block reads of N bytes (read operations are not demarcated by // whitespace). In the fp case, except descriptor to have been opened in binary mode. @@ -1100,16 +1100,16 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf _vl_vsss_skipspace(fp, floc, fromp, fstr); } else if (!inPct) { // Expected Format _vl_vsss_skipspace(fp, floc, fromp, fstr); - int c = _vl_vsss_peek(fp, floc, fromp, fstr); + const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c != pos[0]) goto done; _vl_vsss_advance(fp, floc); } else { // Format character // Skip loading spaces inPct = false; - char fmt = pos[0]; + const char fmt = pos[0]; switch (fmt) { case '%': { - int c = _vl_vsss_peek(fp, floc, fromp, fstr); + const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c != '%') goto done; _vl_vsss_advance(fp, floc); break; @@ -1139,7 +1139,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf for (int i = 0; i < VL_WORDS_I(obits); ++i) owp[i] = 0; switch (fmt) { case 'c': { - int c = _vl_vsss_peek(fp, floc, fromp, fstr); + const int c = _vl_vsss_peek(fp, floc, fromp, fstr); if (c == EOF) goto done; _vl_vsss_advance(fp, floc); owp[0] = c; @@ -1292,7 +1292,7 @@ void _vl_vint_to_string(int obits, char* destoutp, const WDataInP sourcep) VL_MT char* destp = destoutp; for (; lsb >= 0; --lsb) { lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(sourcep, lsb) & 0xff; + const IData charval = VL_BITRSHIFT_W(sourcep, lsb) & 0xff; if (!start || charval) { *destp++ = (charval == 0) ? ' ' : charval; start = false; // Drop leading 0s @@ -1530,16 +1530,16 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size, void* memp, IData fpi // Prep for reading IData read_count = 0; IData read_elements = 0; - int start_shift = (width - 1) & ~7; // bit+7:bit gets first character + const int start_shift = (width - 1) & ~7; // bit+7:bit gets first character int shift = start_shift; // Read the data // We process a character at a time, as then we don't need to deal // with changing buffer sizes dynamically, etc. while (true) { - int c = std::fgetc(fp); + const int c = std::fgetc(fp); if (VL_UNLIKELY(c == EOF)) break; // Shift value in - IData entry = read_elements + start - array_lsb; + const IData entry = read_elements + start - array_lsb; if (width <= 8) { CData* const datap = &(reinterpret_cast(memp))[entry]; if (shift == start_shift) *datap = 0; @@ -1728,14 +1728,14 @@ std::string VL_TOUPPER_NN(const std::string& ld) VL_MT_SAFE { std::string VL_CVT_PACK_STR_NW(int lwords, const WDataInP lwp) VL_MT_SAFE { // See also _vl_vint_to_string char destout[VL_VALUE_STRING_MAX_CHARS + 1]; - int obits = lwords * VL_EDATASIZE; + const int obits = lwords * VL_EDATASIZE; int lsb = obits - 1; bool start = true; char* destp = destout; size_t len = 0; for (; lsb >= 0; --lsb) { lsb = (lsb / 8) * 8; // Next digit - IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; + const IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff; if (!start || charval) { *destp++ = (charval == 0) ? ' ' : charval; ++len; @@ -2069,7 +2069,7 @@ void VL_READMEM_N(bool hex, // Hex format, else binary VL_FATAL_MT(filename.c_str(), rmem.linenum(), "", "$readmem file address beyond bounds of array"); } else { - QData entry = addr - array_lsb; + const QData entry = addr - array_lsb; if (bits <= 8) { CData* const datap = &(reinterpret_cast(memp))[entry]; rmem.setData(datap, value); @@ -2104,7 +2104,7 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary QData start, // First array row address to write QData end // Last address to write, or ~0 when not specified ) VL_MT_SAFE { - QData addr_max = array_lsb + depth - 1; + const QData addr_max = array_lsb + depth - 1; if (start < static_cast(array_lsb)) start = array_lsb; if (end > addr_max) end = addr_max; @@ -2828,7 +2828,7 @@ size_t VerilatedVarProps::totalSize() const { void* VerilatedVarProps::datapAdjustIndex(void* datap, int dim, int indx) const { if (VL_UNLIKELY(dim <= 0 || dim > udims())) return nullptr; if (VL_UNLIKELY(indx < low(dim) || indx > high(dim))) return nullptr; - int indxAdj = indx - low(dim); + const int indxAdj = indx - low(dim); vluint8_t* bytep = reinterpret_cast(datap); // If on index 1 of a 2 index array, then each index 1 is index2sz*entsz size_t slicesz = entSize(); @@ -2873,7 +2873,7 @@ void VerilatedScope::configure(VerilatedSyms* symsp, const char* prefixp, const void VerilatedScope::exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE { // Slowpath - called once/scope*export at construction // Insert a exported function into scope table - int funcnum = VerilatedImp::exportInsert(namep); + const int funcnum = VerilatedImp::exportInsert(namep); if (!finalize) { // Need two passes so we know array size to create // Alternative is to dynamically stretch the array, which is more code, and slower. @@ -2915,7 +2915,7 @@ void VerilatedScope::varInsert(int finalize, const char* namep, void* datap, boo } else { // We could have a linked list of ranges, but really this whole thing needs // to be generalized to support structs and unions, etc. - std::string msg + const std::string msg = std::string{"Unsupported multi-dimensional public varInsert: "} + namep; VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); } @@ -2962,7 +2962,7 @@ void VerilatedScope::scopeDump() const { VerilatedImp::exportName(i)); } } - if (VerilatedVarNameMap* const varsp = this->varsp()) { + if (const VerilatedVarNameMap* const varsp = this->varsp()) { for (const auto& i : *varsp) VL_PRINTF_MT(" VAR %p: %s\n", &(i.second), i.first); } } diff --git a/include/verilated.h b/include/verilated.h index c6d6815c6..8e502fd08 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -359,7 +359,7 @@ protected: } m_args VL_GUARDED_BY(m_argMutex); // Implementation details - std::unique_ptr m_impdatap; + const std::unique_ptr m_impdatap; // Coverage access std::unique_ptr m_coveragep; // Pointer for coveragep() diff --git a/include/verilated_cov.cpp b/include/verilated_cov.cpp index af6080275..d52ecc8f8 100644 --- a/include/verilated_cov.cpp +++ b/include/verilated_cov.cpp @@ -206,9 +206,9 @@ private: } // Forward to . so we have a whole word - std::string suffix = *bpost ? std::string{bpost + 1} : ""; + const std::string suffix = *bpost ? std::string{bpost + 1} : ""; - std::string out = prefix + "*" + suffix; + const std::string out = prefix + "*" + suffix; // cout << "\nch pre="<m_vals[addKeynum] = valueIndex(val); ++addKeynum; if (VL_UNCOVERABLE(!legalKey(key))) { - std::string msg + const std::string msg = ("%Error: Coverage keys of one character, or letter+digit are illegal: " + key); // LCOV_EXCL_LINE VL_FATAL_MT("", 0, "", msg.c_str()); @@ -380,8 +380,9 @@ public: for (int i = 0; i < VerilatedCovConst::MAX_KEYS; ++i) { if (itemp->m_keys[i] != VerilatedCovConst::KEY_UNDEF) { - std::string key = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]); - std::string val = m_indexValues[itemp->m_vals[i]]; + const std::string key + = VerilatedCovKey::shortKey(m_indexValues[itemp->m_keys[i]]); + const std::string val = m_indexValues[itemp->m_vals[i]]; if (key == VL_CIK_PER_INSTANCE) { if (val != "0") per_instance = true; } diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index 69fbada12..d9c826481 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -428,13 +428,13 @@ void* svGetArrElemPtr(const svOpenArrayHandle h, int indx1, ...) { switch (varp->udims()) { case 1: datap = _vl_svGetArrElemPtr(h, 1, indx1, 0, 0); break; case 2: { - int indx2 = va_arg(ap, int); + const int indx2 = va_arg(ap, int); datap = _vl_svGetArrElemPtr(h, 2, indx1, indx2, 0); break; } case 3: { - int indx2 = va_arg(ap, int); - int indx3 = va_arg(ap, int); + const int indx2 = va_arg(ap, int); + const int indx3 = va_arg(ap, int); datap = _vl_svGetArrElemPtr(h, 3, indx1, indx2, indx3); break; } diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index cddc44842..6aa228ee1 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -80,7 +80,7 @@ extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); #endif extern IData VL_RANDOM_SEEDED_II(int obits, IData seed) VL_MT_SAFE; inline IData VL_URANDOM_RANGE_I(IData hi, IData lo) { - vluint64_t rnd = vl_rand64(); + const vluint64_t rnd = vl_rand64(); if (VL_LIKELY(hi > lo)) { // (hi - lo + 1) can be zero when hi is UINT_MAX and lo is zero if (VL_UNLIKELY(hi - lo + 1 == 0)) return rnd; @@ -410,7 +410,7 @@ static inline void VL_ASSIGNBIT_QI(int, int bit, QData& lhsr, QData rhs) VL_PURE lhsr = ((lhsr & ~(1ULL << VL_BITBIT_Q(bit))) | (static_cast(rhs) << VL_BITBIT_Q(bit))); } static inline void VL_ASSIGNBIT_WI(int, int bit, WDataOutP owp, IData rhs) VL_MT_SAFE { - EData orig = owp[VL_BITWORD_E(bit)]; + const EData orig = owp[VL_BITWORD_E(bit)]; owp[VL_BITWORD_E(bit)] = ((orig & ~(VL_EUL(1) << VL_BITBIT_E(bit))) | (static_cast(rhs) << VL_BITBIT_E(bit))); } @@ -696,11 +696,11 @@ static inline IData VL_COUNTONES_W(int words, WDataInP const lwp) VL_MT_SAFE { // EMIT_RULE: VL_COUNTBITS_II: oclean = false; lhs clean static inline IData VL_COUNTBITS_I(int lbits, IData lhs, IData ctrl0, IData ctrl1, IData ctrl2) VL_PURE { - int ctrlSum = (ctrl0 & 0x1) + (ctrl1 & 0x1) + (ctrl2 & 0x1); + const int ctrlSum = (ctrl0 & 0x1) + (ctrl1 & 0x1) + (ctrl2 & 0x1); if (ctrlSum == 3) { return VL_COUNTONES_I(lhs); } else if (ctrlSum == 0) { - IData mask = (lbits == 32) ? -1 : ((1 << lbits) - 1); + const IData mask = (lbits == 32) ? -1 : ((1 << lbits) - 1); return VL_COUNTONES_I(~lhs & mask); } else { return (lbits == 32) ? 32 : lbits; @@ -771,7 +771,7 @@ static inline IData VL_CLOG2_Q(QData lhs) VL_PURE { return shifts; } static inline IData VL_CLOG2_W(int words, WDataInP const lwp) VL_MT_SAFE { - EData adjust = (VL_COUNTONES_W(words, lwp) == 1) ? 0 : 1; + const EData adjust = (VL_COUNTONES_W(words, lwp) == 1) ? 0 : 1; for (int i = words - 1; i >= 0; --i) { if (VL_UNLIKELY(lwp[i])) { // Shorter worst case if predict not taken for (int bit = VL_EDATASIZE - 1; bit >= 0; --bit) { @@ -943,7 +943,7 @@ static inline WDataOutP VL_NEGATE_W(int words, WDataOutP owp, WDataInP const lwp static inline void VL_NEGATE_INPLACE_W(int words, WDataOutP owp_lwp) VL_MT_SAFE { EData carry = 1; for (int i = 0; i < words; ++i) { - EData word = ~owp_lwp[i] + carry; + const EData word = ~owp_lwp[i] + carry; carry = (word < ~owp_lwp[i]); owp_lwp[i] = word; } @@ -1022,13 +1022,13 @@ static inline WDataOutP VL_MULS_WWW(int, int lbits, int, WDataOutP owp, WDataInP WData rwstore[VL_MULS_MAX_WORDS]; WDataInP lwusp = lwp; WDataInP rwusp = rwp; - EData lneg = VL_SIGN_E(lbits, lwp[words - 1]); + const EData lneg = VL_SIGN_E(lbits, lwp[words - 1]); if (lneg) { // Negate lhs lwusp = lwstore; VL_NEGATE_W(words, lwstore, lwp); lwstore[words - 1] &= VL_MASK_E(lbits); // Clean it } - EData rneg = VL_SIGN_E(lbits, rwp[words - 1]); + const EData rneg = VL_SIGN_E(lbits, rwp[words - 1]); if (rneg) { // Negate rhs rwusp = rwstore; VL_NEGATE_W(words, rwstore, rwp); @@ -1496,7 +1496,8 @@ static inline WDataOutP VL_STREAML_WWI(int, int lbits, int, WDataOutP owp, WData for (int sbit = 0; sbit < ssize && sbit < lbits - istart; ++sbit) { // Extract a single bit from lwp and shift it to the correct // location for owp. - EData bit = (VL_BITRSHIFT_W(lwp, (istart + sbit)) & 1) << VL_BITBIT_E(ostart + sbit); + const EData bit = (VL_BITRSHIFT_W(lwp, (istart + sbit)) & 1) + << VL_BITBIT_E(ostart + sbit); owp[VL_BITWORD_E(ostart + sbit)] |= bit; } } @@ -1766,7 +1767,8 @@ static inline WDataOutP VL_SHIFTRS_WWI(int obits, int lbits, int, WDataOutP owp, owp[lmsw] &= VL_MASK_E(lbits); } else { const int loffset = rd & VL_SIZEBITS_E; - int nbitsonright = VL_EDATASIZE - loffset; // bits that end up in lword (know loffset!=0) + const int nbitsonright + = VL_EDATASIZE - loffset; // bits that end up in lword (know loffset!=0) // Middle words const int words = VL_WORDS_I(obits - rd); for (int i = 0; i < words; ++i) { @@ -1842,7 +1844,7 @@ static inline QData VL_SHIFTRS_QQQ(int obits, int lbits, int rbits, QData lhs, Q static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP const lwp, IData rd) VL_MT_SAFE { - int word = VL_BITWORD_E(rd); + const int word = VL_BITWORD_E(rd); if (VL_UNLIKELY(rd > static_cast(lbits))) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. // We return all 1's as that's more likely to find bugs (?) than 0's. @@ -1860,14 +1862,14 @@ static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP const lwp, static inline IData VL_SEL_IWII(int, int lbits, int, int, WDataInP const lwp, IData lsb, IData width) VL_MT_SAFE { - int msb = lsb + width - 1; + const int msb = lsb + width - 1; if (VL_UNLIKELY(msb >= lbits)) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. } else if (VL_BITWORD_E(msb) == VL_BITWORD_E(static_cast(lsb))) { return VL_BITRSHIFT_W(lwp, lsb); } else { // 32 bit extraction may span two words - int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); // bits that come from low word + const int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); // bits that come from low word return ((lwp[VL_BITWORD_E(msb)] << nbitsfromlow) | VL_BITRSHIFT_W(lwp, lsb)); } } @@ -1886,7 +1888,7 @@ static inline QData VL_SEL_QWII(int, int lbits, int, int, WDataInP const lwp, ID return (hi << nbitsfromlow) | lo; } else { // 64 bit extraction may span three words - int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); + const int nbitsfromlow = VL_EDATASIZE - VL_BITBIT_E(lsb); const QData hi = (lwp[VL_BITWORD_E(msb)]); const QData mid = (lwp[VL_BITWORD_E(lsb) + 1]); const QData lo = VL_BITRSHIFT_W(lwp, lsb); @@ -2220,31 +2222,31 @@ extern void VL_TIMEFORMAT_IINI(int units, int precision, const std::string& suff extern IData VL_VALUEPLUSARGS_INW(int rbits, const std::string& ld, WDataOutP rwp) VL_MT_SAFE; inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, CData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, SData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INI(int rbits, const std::string& ld, IData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = rwp[0]; return got; } inline IData VL_VALUEPLUSARGS_INQ(int rbits, const std::string& ld, QData& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = VL_SET_QW(rwp); return got; } inline IData VL_VALUEPLUSARGS_INQ(int rbits, const std::string& ld, double& rdr) VL_MT_SAFE { VlWide<2> rwp; - IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); + const IData got = VL_VALUEPLUSARGS_INW(rbits, ld, rwp); if (got) rdr = VL_CVT_D_Q(VL_SET_QW(rwp)); return got; } diff --git a/include/verilated_imp.h b/include/verilated_imp.h index f63b158d0..3a3003437 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -60,8 +60,8 @@ public: private: // MEMBERS - vluint32_t m_mtaskId; // MTask that did enqueue - std::function m_cb; // Lambda to execute when message received + const vluint32_t m_mtaskId; // MTask that did enqueue + const std::function m_cb; // Lambda to execute when message received public: // CONSTRUCTORS explicit VerilatedMsg(const std::function& cb) @@ -277,7 +277,7 @@ public: // But only for verilated*.cpp IData fdNewMcd(const char* filenamep) VL_MT_SAFE_EXCLUDES(m_fdMutex) { const VerilatedLockGuard lock{m_fdMutex}; if (m_fdFreeMct.empty()) return 0; - IData idx = m_fdFreeMct.back(); + const IData idx = m_fdFreeMct.back(); m_fdFreeMct.pop_back(); m_fdps[idx] = std::fopen(filenamep, "w"); if (VL_UNLIKELY(!m_fdps[idx])) return 0; @@ -299,7 +299,7 @@ public: // But only for verilated*.cpp m_fdFree[i] = id; } } - IData idx = m_fdFree.back(); + const IData idx = m_fdFree.back(); m_fdFree.pop_back(); m_fdps[idx] = fp; return (idx | (1UL << 31)); // bit 31 indicates not MCD @@ -334,7 +334,7 @@ public: // But only for verilated*.cpp const VerilatedLockGuard lock{m_fdMutex}; if (VL_BITISSET_I(fdi, 31)) { // Non-MCD case - IData idx = VL_MASK_I(31) & fdi; + const IData idx = VL_MASK_I(31) & fdi; if (VL_UNLIKELY(idx >= m_fdps.size())) return; if (VL_UNLIKELY(idx <= 2)) return; // stdout/stdin/stderr if (VL_UNLIKELY(!m_fdps[idx])) return; // Already free diff --git a/include/verilated_profiler.h b/include/verilated_profiler.h index 129d0870c..9895b6062 100644 --- a/include/verilated_profiler.h +++ b/include/verilated_profiler.h @@ -27,8 +27,8 @@ // Profile record, private class used only by this header class VerilatedProfilerRec final { - std::string m_name; // Hashed name of mtask/etc - size_t m_counterNumber = 0; // Which counter has data + const std::string m_name; // Hashed name of mtask/etc + const size_t m_counterNumber = 0; // Which counter has data public: // METHODS VerilatedProfilerRec(size_t counterNumber, const std::string& name) diff --git a/include/verilated_save.cpp b/include/verilated_save.cpp index eada7a572..0c2d2e3c2 100644 --- a/include/verilated_save.cpp +++ b/include/verilated_save.cpp @@ -192,7 +192,7 @@ void VerilatedRestore::close() VL_MT_UNSAFE_ONE { void VerilatedSave::flush() VL_MT_UNSAFE_ONE { m_assertOne.check(); if (VL_UNLIKELY(!isOpen())) return; - vluint8_t* wp = m_bufp; + const vluint8_t* wp = m_bufp; while (true) { const ssize_t remaining = (m_cp - wp); if (remaining == 0) break; diff --git a/include/verilated_save.h b/include/verilated_save.h index f49c15f91..8f95a85b9 100644 --- a/include/verilated_save.h +++ b/include/verilated_save.h @@ -279,7 +279,7 @@ inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, float& rhs) { return os.read(&rhs, sizeof(rhs)); } inline VerilatedSerialize& operator<<(VerilatedSerialize& os, const std::string& rhs) { - vluint32_t len = rhs.length(); + const vluint32_t len = rhs.length(); os << len; return os.write(rhs.data(), len); } diff --git a/include/verilated_sym_props.h b/include/verilated_sym_props.h index 2373760e0..990b4564d 100644 --- a/include/verilated_sym_props.h +++ b/include/verilated_sym_props.h @@ -192,8 +192,8 @@ public: class VerilatedDpiOpenVar final { // MEMBERS - const VerilatedVarProps* m_propsp; // Variable properties - void* m_datap; // Location of data (local to thread always, so safe) + const VerilatedVarProps* const m_propsp; // Variable properties + void* const m_datap; // Location of data (local to thread always, so safe) public: // CONSTRUCTORS VerilatedDpiOpenVar(const VerilatedVarProps* propsp, void* datap) @@ -230,10 +230,10 @@ public: class VerilatedVar final : public VerilatedVarProps { // MEMBERS - void* m_datap; // Location of data - const char* m_namep; // Name - slowpath + void* const m_datap; // Location of data + const char* const m_namep; // Name - slowpath protected: - bool m_isParam; + const bool m_isParam; friend class VerilatedScope; // CONSTRUCTORS VerilatedVar(const char* namep, void* datap, VerilatedVarType vltype, diff --git a/include/verilated_threads.h b/include/verilated_threads.h index e07e4418f..c3af2f681 100644 --- a/include/verilated_threads.h +++ b/include/verilated_threads.h @@ -217,12 +217,12 @@ private: // Store the size atomically, so we can spin wait std::atomic m_ready_size; - VlThreadPool* m_poolp; // Our associated thread pool + VlThreadPool* const m_poolp; // Our associated thread pool - bool m_profiling; // Is profiling enabled? + const bool m_profiling; // Is profiling enabled? std::atomic m_exiting; // Worker thread should exit std::thread m_cthread; // Underlying C++ thread record - VerilatedContext* m_contextp; // Context for spawned thread + VerilatedContext* const m_contextp; // Context for spawned thread VL_UNCOPYABLE(VlWorkerThread); @@ -274,7 +274,7 @@ class VlThreadPool final { // MEMBERS std::vector m_workers; // our workers - bool m_profiling; // is profiling enabled? + const bool m_profiling; // is profiling enabled? // Support profiling -- we can append records of profiling events // to this vector with very low overhead, and then dump them out diff --git a/include/verilated_types.h b/include/verilated_types.h index 8a0dde96d..364378080 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -79,10 +79,10 @@ public: // Readmem/Writemem operation classes class VlReadMem final { - bool m_hex; // Hex format - int m_bits; // Bit width of values + const bool m_hex; // Hex format + const int m_bits; // Bit width of values const std::string& m_filename; // Filename - QData m_end; // End address (as specified by user) + const QData m_end; // End address (as specified by user) FILE* m_fp; // File handle for filename QData m_addr; // Next address to read int m_linenum; // Line number last read from file @@ -96,8 +96,8 @@ public: }; class VlWriteMem final { - bool m_hex; // Hex format - int m_bits; // Bit width of values + const bool m_hex; // Hex format + const int m_bits; // Bit width of values FILE* m_fp; // File handle for filename QData m_addr; // Next address to write public: diff --git a/include/verilated_vcd_c.cpp b/include/verilated_vcd_c.cpp index 1a21bdbf2..860c9de41 100644 --- a/include/verilated_vcd_c.cpp +++ b/include/verilated_vcd_c.cpp @@ -281,7 +281,7 @@ void VerilatedVcd::bufferResize(vluint64_t minsize) { // minsize is size of largest write. We buffer at least 8 times as much data, // writing when we are 3/4 full (with thus 2*minsize remaining free) if (VL_UNLIKELY(minsize > m_wrChunkSize)) { - char* oldbufp = m_wrBufp; + const char* oldbufp = m_wrBufp; m_wrChunkSize = minsize * 2; m_wrBufp = new char[m_wrChunkSize * 8]; std::memcpy(m_wrBufp, oldbufp, m_writep - oldbufp); @@ -298,7 +298,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE { // When it gets nearly full we dump it using this routine which calls write() // This is much faster than using buffered I/O if (VL_UNLIKELY(!isOpen())) return; - char* wp = m_wrBufp; + const char* wp = m_wrBufp; while (true) { const ssize_t remaining = (m_writep - wp); if (remaining == 0) break; @@ -311,7 +311,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE { if (VL_UNCOVERABLE(errno != EAGAIN && errno != EINTR)) { // LCOV_EXCL_START // write failed, presume error (perhaps out of disk space) - std::string msg + const std::string msg = std::string{"VerilatedVcd::bufferFlush: "} + std::strerror(errno); VL_FATAL_MT("", 0, "", msg.c_str()); closeErr(); @@ -386,7 +386,7 @@ void VerilatedVcd::dumpHeader() { const std::string& decl = i.second; // Determine difference between the old and new names - const char* hiername = hiernamestr.c_str(); + const char* const hiername = hiernamestr.c_str(); const char* lp = lastName; const char* np = hiername; lastName = hiername; diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 6eb3f1d6b..07b8fb0be 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -74,7 +74,7 @@ private: int m_modDepth = 0; // Depth of module hierarchy char* m_wrBufp; // Output buffer - char* m_wrFlushp; // Output buffer flush trigger location + const char* m_wrFlushp; // Output buffer flush trigger location char* m_writep; // Write pointer into output buffer vluint64_t m_wrChunkSize; // Output buffer size vluint64_t m_wroteBytes = 0; // Number of bytes written to this file diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 5b7bbfe5c..9d8901012 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -123,8 +123,8 @@ public: class VerilatedVpioTimedCb final : public VerilatedVpio { // A handle to a timed callback created with vpi_register_cb // User can call vpi_remove_cb or vpi_release_handle on it - vluint64_t m_id; // Unique id/sequence number to find schedule's event - QData m_time; + const vluint64_t m_id; // Unique id/sequence number to find schedule's event + const QData m_time; public: VerilatedVpioTimedCb(vluint64_t id, QData time) @@ -141,8 +141,8 @@ public: class VerilatedVpioReasonCb final : public VerilatedVpio { // A handle to a non-timed callback created with vpi_register_cb // User can call vpi_remove_cb or vpi_release_handle on it - vluint64_t m_id; // Unique id/sequence number to find schedule's event - PLI_INT32 m_reason; // VPI callback reason code + const vluint64_t m_id; // Unique id/sequence number to find schedule's event + const PLI_INT32 m_reason; // VPI callback reason code public: // cppcheck-suppress uninitVar // m_value @@ -158,7 +158,7 @@ public: }; class VerilatedVpioConst final : public VerilatedVpio { - vlsint32_t m_num; + const vlsint32_t m_num; public: explicit VerilatedVpioConst(vlsint32_t num) @@ -219,7 +219,7 @@ public: }; class VerilatedVpioRange final : public VerilatedVpio { - const VerilatedRange* m_range; + const VerilatedRange* const m_range; public: explicit VerilatedVpioRange(const VerilatedRange* range) @@ -235,7 +235,7 @@ public: class VerilatedVpioRangeIter final : public VerilatedVpio { // Only supports 1 dimension - const VerilatedRange* m_range; + const VerilatedRange* const m_range; bool m_done = false; public: @@ -258,7 +258,7 @@ public: class VerilatedVpioScope VL_NOT_FINAL : public VerilatedVpio { protected: - const VerilatedScope* m_scopep; + const VerilatedScope* const m_scopep; public: explicit VerilatedVpioScope(const VerilatedScope* scopep) @@ -352,7 +352,7 @@ public: }; class VerilatedVpioVarIter final : public VerilatedVpio { - const VerilatedScope* m_scopep; + const VerilatedScope* const m_scopep; VerilatedVarNameMap::const_iterator m_it; bool m_started = false; @@ -389,9 +389,9 @@ public: class VerilatedVpioMemoryWordIter final : public VerilatedVpio { const vpiHandle m_handle; - const VerilatedVar* m_varp; + const VerilatedVar* const m_varp; vlsint32_t m_iteration; - vlsint32_t m_direction; + const vlsint32_t m_direction; bool m_done = false; public: @@ -413,7 +413,7 @@ public: delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; } - vpiHandle result = vpi_handle_by_index(m_handle, m_iteration); + const vpiHandle result = vpi_handle_by_index(m_handle, m_iteration); iterationInc(); return result; } @@ -457,7 +457,7 @@ public: delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle return nullptr; } - const VerilatedScope* modp = *m_it++; + const VerilatedScope* const modp = *m_it++; return (new VerilatedVpioModule{modp})->castVpiHandle(); } }; @@ -595,7 +595,7 @@ public: const auto last = std::prev(cbObjList.end()); // prevent looping over newly added elements for (auto it = cbObjList.begin(); true;) { // cbReasonRemove sets to nullptr, so we know on removal the old end() will still exist - bool was_last = it == last; + const bool was_last = it == last; if (VL_UNLIKELY(it->invalid())) { // Deleted earlier, cleanup it = cbObjList.erase(it); if (was_last) break; @@ -1111,7 +1111,7 @@ const char* VerilatedVpiError::strFromVpiProp(PLI_INT32 vpiVal) VL_MT_SAFE { #define SELF_CHECK_RESULT_CSTR(got, exp) \ if (0 != std::strcmp((got), (exp))) { \ - std::string msg \ + const std::string msg \ = std::string{"%Error: "} + "GOT = '" + (got) + "'" + " EXP = '" + (exp) + "'"; \ VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); \ } @@ -1305,7 +1305,7 @@ vpiHandle vpi_register_cb(p_cb_data cb_data_p) { QData time = 0; if (cb_data_p->time) time = VL_SET_QII(cb_data_p->time->high, cb_data_p->time->low); const QData abstime = VL_TIME_Q() + time; - vluint64_t id = VerilatedVpiImp::nextCallbackId(); + const vluint64_t id = VerilatedVpiImp::nextCallbackId(); VerilatedVpioTimedCb* const vop = new VerilatedVpioTimedCb{id, abstime}; VerilatedVpiImp::cbTimedAdd(id, cb_data_p, abstime); return vop->castVpiHandle(); @@ -1410,7 +1410,7 @@ vpiHandle vpi_handle_by_index(vpiHandle object, PLI_INT32 indx) { VerilatedVpiImp::assertOneCheck(); VL_VPI_ERROR_RESET_(); // Memory words are not indexable - VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); + const VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); if (VL_UNLIKELY(vop)) return nullptr; const VerilatedVpioVar* const varop = VerilatedVpioVar::castp(object); if (VL_LIKELY(varop)) { @@ -1442,7 +1442,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { VL_VPI_ERROR_RESET_(); switch (type) { case vpiLeftRange: { - if (VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { + if (const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->left()})->castVpiHandle(); } else if (VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { @@ -1455,7 +1455,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { return nullptr; } case vpiRightRange: { - if (VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { + if (const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->right()})->castVpiHandle(); } else if (VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { @@ -1468,18 +1468,18 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { return nullptr; } case vpiIndex: { - VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object); + const VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; const vlsint32_t val = vop->index(); return (new VerilatedVpioConst{val})->castVpiHandle(); } case vpiScope: { - VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object); + const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; return (new VerilatedVpioScope{vop->scopep()})->castVpiHandle(); } case vpiParent: { - VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); + const VerilatedVpioMemoryWord* const vop = VerilatedVpioMemoryWord::castp(object); if (VL_UNLIKELY(!vop)) return nullptr; return (new VerilatedVpioVar{vop->varp(), vop->scopep()})->castVpiHandle(); } @@ -1697,7 +1697,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, // Maximum required size is for binary string, one byte per bit plus null termination static VL_THREAD_LOCAL char t_outStr[VL_VALUE_STRING_MAX_WORDS * VL_EDATASIZE + 1]; // cppcheck-suppress variableScope - static VL_THREAD_LOCAL int t_outStrSz = sizeof(t_outStr) - 1; + const static VL_THREAD_LOCAL int t_outStrSz = sizeof(t_outStr) - 1; // We used to presume vpiValue.format = vpiIntVal or if single bit vpiScalarVal // This may cause backward compatibility issues with older code. if (valuep->format == vpiVectorVal) { @@ -1718,14 +1718,14 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, t_out[0].bval = 0; return; } else if (varp->vltype() == VLVT_UINT64) { - QData data = *(reinterpret_cast(varDatap)); + const QData data = *(reinterpret_cast(varDatap)); t_out[1].aval = static_cast(data >> 32ULL); t_out[1].bval = 0; t_out[0].aval = static_cast(data); t_out[0].bval = 0; return; } else if (varp->vltype() == VLVT_WDATA) { - int words = VL_WORDS_I(varp->packed().elements()); + const int words = VL_WORDS_I(varp->packed().elements()); if (VL_UNCOVERABLE(words >= VL_VALUE_STRING_MAX_WORDS)) { VL_FATAL_MT(__FILE__, __LINE__, "", "vpi_get_value with more than VL_VALUE_STRING_MAX_WORDS; increase and " @@ -1741,7 +1741,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else if (valuep->format == vpiBinStrVal) { valuep->value.str = t_outStr; int bits = varp->packed().elements(); - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (bits > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1754,7 +1754,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, VL_VALUE_STRING_MAX_WORDS, bits); } for (i = 0; i < bits; ++i) { - char val = (datap[i >> 3] >> (i & 7)) & 1; + const char val = (datap[i >> 3] >> (i & 7)) & 1; t_outStr[bits - i - 1] = val ? '1' : '0'; } t_outStr[i] = '\0'; @@ -1763,7 +1763,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, valuep->value.str = t_outStr; int chars = (varp->packed().elements() + 2) / 3; const int bytes = VL_BYTES_I(varp->packed().elements()); - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (chars > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1788,7 +1788,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, if (i == (chars - 1)) { // most signifcant char, mask off non existant bits when vector // size is not a multiple of 3 - unsigned int rem = varp->packed().elements() % 3; + const unsigned int rem = varp->packed().elements() % 3; if (rem) { // generate bit mask & zero non existant bits val &= (1 << rem) - 1; @@ -1821,7 +1821,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else if (valuep->format == vpiHexStrVal) { valuep->value.str = t_outStr; int chars = (varp->packed().elements() + 3) >> 2; - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (chars > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1855,7 +1855,7 @@ void vl_get_value(const VerilatedVar* varp, void* varDatap, p_vpi_value valuep, } else { valuep->value.str = t_outStr; int bytes = VL_BYTES_I(varp->packed().elements()); - CData* datap = (reinterpret_cast(varDatap)); + const CData* datap = (reinterpret_cast(varDatap)); int i; if (bytes > t_outStrSz) { // limit maximum size of output to size of buffer to prevent overrun. @@ -1899,7 +1899,7 @@ void vpi_get_value(vpiHandle object, p_vpi_value valuep) { VL_VPI_ERROR_RESET_(); if (VL_UNLIKELY(!valuep)) return; - if (VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object)) { + if (const VerilatedVpioVar* const vop = VerilatedVpioVar::castp(object)) { vl_get_value(vop->varp(), vop->varDatap(), valuep, vop->fullname()); return; } else if (const VerilatedVpioParam* const vop = VerilatedVpioParam::castp(object)) { @@ -1970,9 +1970,9 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } else if (valuep->format == vpiBinStrVal) { const int bits = vop->varp()->packed().elements(); const int len = std::strlen(valuep->value.str); - CData* datap = (reinterpret_cast(vop->varDatap())); + CData* const datap = (reinterpret_cast(vop->varDatap())); for (int i = 0; i < bits; ++i) { - char set = (i < len) ? (valuep->value.str[len - i - 1] == '1') : 0; + const char set = (i < len) ? (valuep->value.str[len - i - 1] == '1') : 0; // zero bits 7:1 of byte when assigning to bit 0, else // or in 1 if bit set if (i & 7) { @@ -1986,7 +1986,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ const int chars = (vop->varp()->packed().elements() + 2) / 3; const int bytes = VL_BYTES_I(vop->varp()->packed().elements()); const int len = std::strlen(valuep->value.str); - CData* datap = (reinterpret_cast(vop->varDatap())); + CData* const datap = (reinterpret_cast(vop->varDatap())); div_t idx; datap[0] = 0; // reset zero'th byte for (int i = 0; i < chars; ++i) { @@ -1997,7 +1997,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ idx = div(i * 3, 8); if (i < len) { // ignore illegal chars - char digit = valuep->value.str[len - i - 1]; + const char digit = valuep->value.str[len - i - 1]; if (digit >= '0' && digit <= '7') { val.half = digit - '0'; } else { @@ -2064,8 +2064,8 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } } else if (valuep->format == vpiHexStrVal) { const int chars = (vop->varp()->packed().elements() + 3) >> 2; - CData* datap = (reinterpret_cast(vop->varDatap())); - char* val = valuep->value.str; + CData* const datap = (reinterpret_cast(vop->varDatap())); + const char* val = valuep->value.str; // skip hex ident if one is detected at the start of the string if (val[0] == '0' && (val[1] == 'x' || val[1] == 'X')) val += 2; const int len = std::strlen(val); @@ -2073,7 +2073,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ char hex; // compute hex digit value if (i < len) { - char digit = val[len - i - 1]; + const char digit = val[len - i - 1]; if (digit >= '0' && digit <= '9') { hex = digit - '0'; } else if (digit >= 'a' && digit <= 'f') { @@ -2105,7 +2105,7 @@ vpiHandle vpi_put_value(vpiHandle object, p_vpi_value valuep, p_vpi_time /*time_ } else if (valuep->format == vpiStringVal) { const int bytes = VL_BYTES_I(vop->varp()->packed().elements()); const int len = std::strlen(valuep->value.str); - CData* datap = (reinterpret_cast(vop->varDatap())); + CData* const datap = (reinterpret_cast(vop->varDatap())); for (int i = 0; i < bytes; ++i) { // prepend with 0 values before placing string the least significant bytes datap[i] = (i < len) ? valuep->value.str[len - i - 1] : 0; @@ -2167,7 +2167,7 @@ void vpi_get_time(vpiHandle object, p_vpi_time time_p) { return; } else if (time_p->type == vpiScaledRealTime) { double dtime = VL_TIME_D(); - if (VerilatedVpioScope* const vop = VerilatedVpioScope::castp(object)) { + if (const VerilatedVpioScope* const vop = VerilatedVpioScope::castp(object)) { const int scalePow10 = Verilated::threadContextp()->timeprecision() - vop->scopep()->timeunit(); const double scale = vl_time_multiplier(scalePow10); // e.g. 0.0001 @@ -2287,7 +2287,7 @@ PLI_INT32 vpi_release_handle(vpiHandle object) { PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p) VL_MT_SAFE { VerilatedVpiImp::assertOneCheck(); VL_VPI_ERROR_RESET_(); - auto argc_argv = Verilated::threadContextp()->impp()->argc_argv(); + const auto argc_argv = Verilated::threadContextp()->impp()->argc_argv(); vlog_info_p->argc = argc_argv.first; vlog_info_p->argv = argc_argv.second; vlog_info_p->product = const_cast(Verilated::productName()); From 393b9e435d788c9fcb75d1b73e81c657537a94e7 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 25 Nov 2021 09:47:06 -0500 Subject: [PATCH 58/79] Internals: Revert previous commit const for clang. --- include/verilated_imp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/verilated_imp.h b/include/verilated_imp.h index 3a3003437..f612c55f5 100644 --- a/include/verilated_imp.h +++ b/include/verilated_imp.h @@ -60,8 +60,8 @@ public: private: // MEMBERS - const vluint32_t m_mtaskId; // MTask that did enqueue - const std::function m_cb; // Lambda to execute when message received + vluint32_t m_mtaskId; // MTask that did enqueue + std::function m_cb; // Lambda to execute when message received public: // CONSTRUCTORS explicit VerilatedMsg(const std::function& cb) From 9bda2cb4ada7040c8bb946332b50592627234533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lefebvre?= <70458911+mlefebvre1@users.noreply.github.com> Date: Fri, 26 Nov 2021 10:51:11 -0500 Subject: [PATCH 59/79] Fix some SliceSels not being constants (#3186) (#3218). --- .gitignore | 1 + docs/CONTRIBUTORS | 1 + src/V3Const.cpp | 2 +- test_regress/t/t_const_slicesel.pl | 19 +++++++++++++++++++ test_regress/t/t_const_slicesel.v | 20 ++++++++++++++++++++ test_regress/t/t_const_slicesel_bad.pl | 20 ++++++++++++++++++++ test_regress/t/t_const_slicesel_bad.v | 14 ++++++++++++++ 7 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 test_regress/t/t_const_slicesel.pl create mode 100644 test_regress/t/t_const_slicesel.v create mode 100755 test_regress/t/t_const_slicesel_bad.pl create mode 100644 test_regress/t/t_const_slicesel_bad.v diff --git a/.gitignore b/.gitignore index 7545baa1d..2bfa23d4b 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ verilator-config-version.cmake **/__pycache__/* **/_build/* **/obj_dir/* +/.vscode/ diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 125977415..ca842b952 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -64,6 +64,7 @@ Marshal Qiao Martin Schmidt Matthew Ballance Michael Killough +Michaël Lefebvre Mike Popoloski Miodrag Milanović Morten Borup Petersen diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 69a212c84..470120f63 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -3430,7 +3430,7 @@ private: virtual void visit(AstNode* nodep) override { // Default: Just iterate if (m_required) { - if (VN_IS(nodep, NodeDType) || VN_IS(nodep, Range)) { + if (VN_IS(nodep, NodeDType) || VN_IS(nodep, Range) || VN_IS(nodep, SliceSel)) { // Ignore dtypes for parameter type pins } else { nodep->v3error("Expecting expression to be constant, but can't convert a " diff --git a/test_regress/t/t_const_slicesel.pl b/test_regress/t/t_const_slicesel.pl new file mode 100755 index 000000000..becd8a5aa --- /dev/null +++ b/test_regress/t/t_const_slicesel.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl + +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003-2009 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } + +scenarios(linter => 1); + +lint( +); + +ok(1); +1; diff --git a/test_regress/t/t_const_slicesel.v b/test_regress/t/t_const_slicesel.v new file mode 100644 index 000000000..244fa28ae --- /dev/null +++ b/test_regress/t/t_const_slicesel.v @@ -0,0 +1,20 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 by Michael Lefebvre. + + +module t(/*AUTOARG*/); + +localparam int unsigned A2 [1:0] = '{5,6}; +localparam int unsigned A3 [2:0] = '{4,5,6}; + +// Matching sizes with slicesel are okay. +localparam int unsigned B22 [1:0] = A2[1:0]; +localparam int unsigned B33 [2:0] = A3[2:0]; + +// bug #3186 +localparam int unsigned B32_B [1:0] = A3[1:0]; +localparam int unsigned B32_T [1:0] = A3[2:1]; + +endmodule diff --git a/test_regress/t/t_const_slicesel_bad.pl b/test_regress/t/t_const_slicesel_bad.pl new file mode 100755 index 000000000..9d8b88724 --- /dev/null +++ b/test_regress/t/t_const_slicesel_bad.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl + +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003-2009 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } + +scenarios(linter => 1); + +lint( + fails => 1 +); + +ok(1); +1; diff --git a/test_regress/t/t_const_slicesel_bad.v b/test_regress/t/t_const_slicesel_bad.v new file mode 100644 index 000000000..15a7e0dc1 --- /dev/null +++ b/test_regress/t/t_const_slicesel_bad.v @@ -0,0 +1,14 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2021 by Michael Lefebvre. + + +module t(/*AUTOARG*/); + +localparam int unsigned A3 [2:0] = '{4,5,6}; + +// slicesel out of range should fail +localparam int unsigned B32_T [1:0] = A3[3:1]; + +endmodule From 05e12ab60ea1c50d7dec96f5c8806cfce9406572 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 10:02:04 -0500 Subject: [PATCH 60/79] Internals: More const. No functional change intended. --- src/V3Active.cpp | 2 +- src/V3ActiveTop.cpp | 2 +- src/V3Assert.cpp | 2 +- src/V3Begin.cpp | 2 +- src/V3Branch.cpp | 2 +- src/V3CUse.cpp | 2 +- src/V3Case.cpp | 2 +- src/V3Cast.cpp | 4 ++-- src/V3Cdc.cpp | 6 +++--- src/V3Changed.cpp | 2 +- src/V3Class.cpp | 2 +- src/V3Clean.cpp | 6 +++--- src/V3Clock.cpp | 2 +- src/V3Combine.cpp | 2 +- src/V3Common.cpp | 2 +- src/V3Const.cpp | 6 +++--- src/V3Coverage.cpp | 2 +- src/V3Dead.cpp | 2 +- src/V3Delayed.cpp | 12 ++++++------ src/V3Descope.cpp | 2 +- src/V3EmitCBase.h | 2 +- src/V3EmitCFunc.h | 2 +- src/V3EmitCImp.cpp | 2 +- src/V3EmitCSyms.cpp | 2 +- src/V3Expand.cpp | 2 +- src/V3Gate.cpp | 8 ++++---- src/V3GenClk.cpp | 8 ++++---- src/V3Global.cpp | 2 +- src/V3Hasher.h | 2 +- src/V3HierBlock.cpp | 2 +- src/V3Inline.cpp | 22 ++++++++++------------ src/V3Inst.cpp | 2 +- src/V3InstrCount.cpp | 2 +- src/V3Life.cpp | 2 +- src/V3LifePost.cpp | 2 +- src/V3LinkCells.cpp | 4 ++-- src/V3LinkDot.cpp | 10 +++++----- src/V3LinkParse.cpp | 4 ++-- src/V3LinkResolve.cpp | 2 +- src/V3Localize.cpp | 8 ++++---- src/V3MergeCond.cpp | 4 ++-- src/V3Name.cpp | 2 +- src/V3Order.cpp | 6 +++--- src/V3Param.cpp | 4 ++-- src/V3Partition.cpp | 2 +- src/V3Premit.cpp | 6 +++--- src/V3Randomize.cpp | 4 ++-- src/V3Reloop.cpp | 2 +- src/V3Scope.cpp | 4 ++-- src/V3Simulate.h | 6 +++--- src/V3Slice.cpp | 2 +- src/V3Split.cpp | 8 ++++---- src/V3SplitAs.cpp | 2 +- src/V3SplitVar.cpp | 2 +- src/V3Subst.cpp | 6 +++--- src/V3Task.cpp | 12 +++++------- src/V3Trace.cpp | 6 +++--- src/V3Tristate.cpp | 10 +++++----- src/V3Undriven.cpp | 4 ++-- src/V3Unknown.cpp | 4 ++-- src/V3VariableOrder.cpp | 2 +- src/V3WidthCommit.h | 2 +- 62 files changed, 125 insertions(+), 129 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index e2e3ddd0e..a20bae1fc 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -299,7 +299,7 @@ private: // NODE STATE // Input: // AstVar::user1p // V2LatchGraphVertex* The vertex handling this node - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE LatchDetectGraph m_graph; // Graph used to detect latches in combo always // VISITORS diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index cf786c44a..ab5155cd4 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -42,7 +42,7 @@ private: // AstNode::user() bool. True if processed // Each call to V3Const::constify // AstNode::user4() Used by V3Const::constify, called below - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE SenTreeFinder m_finder; // Find global sentree's / add them under the AstTopScope diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 72803b93e..20f8c3725 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -30,7 +30,7 @@ private: // NODE STATE/TYPES // Cleared on netlist // AstNode::user() -> bool. True if processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstNodeModule* m_modp = nullptr; // Last module diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index d8797ce62..9d9d4a483 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -41,7 +41,7 @@ private: // NODE STATE // Entire netlist: // AstNodeFTask::user1 -> bool, 1=processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; bool m_anyFuncInBegin = false; public: diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index ae8a6f1d8..a3690bddc 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -40,7 +40,7 @@ private: // NODE STATE // Entire netlist: // AstFTask::user1() -> int. Number of references - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE int m_likely = false; // Excuses for branch likely taken diff --git a/src/V3CUse.cpp b/src/V3CUse.cpp index 5e35527df..2b4543bfe 100644 --- a/src/V3CUse.cpp +++ b/src/V3CUse.cpp @@ -39,7 +39,7 @@ class CUseVisitor final : public AstNVisitor { // NODE STATE // AstNode::user1() -> bool. True if already visited - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // MEMBERS bool m_impOnly = false; // In details needed only for implementation diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 7e3502d99..830694d1a 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -122,7 +122,7 @@ private: // NODE STATE // Cleared each Case // AstIf::user3() -> bool. Set true to indicate clone not needed - AstUser3InUse m_inuser3; + const AstUser3InUse m_inuser3; // STATE VDouble0 m_statCaseFast; // Statistic tracking diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index d8db3abe1..149202c70 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -54,7 +54,7 @@ private: // NODE STATE // Entire netlist: // AstNode::user() // bool. Indicates node is of known size - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE @@ -203,6 +203,6 @@ public: void V3Cast::castAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CastVisitor visitor{nodep}; } // Destruct before checking + { const CastVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("cast", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 2bd9da2cb..28851bcdb 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -217,9 +217,9 @@ private: // AstVarScope::user2 -> bool Used in sensitivity list // {statement}Node::user1p -> CdcLogicVertex* for this statement // AstNode::user3 -> bool True indicates to print %% (via V3EmitV) - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; // STATE V3Graph m_graph; // Scoreboard of var usages/dependencies diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index daef2b0f1..9d28c7ab2 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -247,7 +247,7 @@ private: // NODE STATE // Entire netlist: // AstVarScope::user1() -> bool. True indicates processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE ChangedState* m_statep; // Shared state across visitors diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 7d1393f9e..5310b7862 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -32,7 +32,7 @@ class ClassVisitor final : public AstNVisitor { private: // MEMBERS - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; string m_prefix; // String prefix to add to name based on hier AstScope* m_classScopep = nullptr; // Package moving scopes into AstScope* m_packageScopep = nullptr; // Class package scope diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 4d0295a43..9eda5e56f 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -42,9 +42,9 @@ private: // AstNode::user() -> CleanState. For this node, 0==UNKNOWN // AstNode::user2() -> bool. True indicates widthMin has been propagated // AstNodeDType::user3() -> AstNodeDType*. Alternative node with C size - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; // TYPES enum CleanState : uint8_t { CS_UNKNOWN, CS_CLEAN, CS_DIRTY }; diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index c16316a3e..8dde574f9 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -73,7 +73,7 @@ private: // NODE STATE // Cleared each Module: // AstVarScope::user1p() -> AstVarScope*. Temporary signal that was created. - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstNodeModule* m_modp = nullptr; // Current module diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index 5fbfd1f3a..aa38734e4 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -121,7 +121,7 @@ class CombineVisitor final : CombBaseVisitor { private: // NODE STATE // Entire netlist: - AstUser3InUse m_user3InUse; // Marks replaced AstCFuncs + const AstUser3InUse m_user3InUse; // Marks replaced AstCFuncs // AstUser4InUse part of V3Hasher in V3DupFinder // STATE diff --git a/src/V3Common.cpp b/src/V3Common.cpp index 7dcf3f8b7..1bfb366f3 100644 --- a/src/V3Common.cpp +++ b/src/V3Common.cpp @@ -109,7 +109,7 @@ void V3Common::commonAll() { // NODE STATE // Entire netlist: // AstClass::user1() -> bool. True if class needs to_string dumper - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // Create ToString methods makeVlToString(classp); makeToString(classp); diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 470120f63..ab5f73d1d 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -110,7 +110,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { // NODE STATE // AstVarRef::user4u -> Base index of m_varInfos that points VarInfo // AstVarScope::user4u -> Same as AstVarRef::user4 - AstUser4InUse m_inuser4; + const AstUser4InUse m_inuser4; // TYPES @@ -1975,7 +1975,7 @@ private: if (m_warn && !VN_IS(nodep, AssignDly)) { // Is same var on LHS and RHS? // Note only do this (need user4) when m_warn, which is // done as unique visitor - AstUser4InUse m_inuser4; + const AstUser4InUse m_inuser4; ConstVarMarkVisitor mark{nodep->lhsp()}; ConstVarFindVisitor find{nodep->rhsp()}; if (find.found()) need_temp = true; @@ -2669,7 +2669,7 @@ private: // SENGATE(SENITEM(x)) -> SENITEM(x), then let it collapse with the // other SENITEM(x). { - AstUser4InUse m_inuse4; + const AstUser4InUse m_inuse4; // Mark x in SENITEM(x) for (AstSenItem* senp = nodep->sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) { diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index e32a395e5..766149504 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -73,7 +73,7 @@ private: // NODE STATE // Entire netlist: // AstIf::user1() -> bool. True indicates ifelse processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE CheckState m_state; // State save-restored on each new coverage scope/block diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index bbdcad753..7af22c0c4 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -76,7 +76,7 @@ private: // AstVar::user1() -> int. Count of number of references // AstVarScope::user1() -> int. Count of number of references // AstNodeDType::user1() -> int. Count of number of references - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // TYPES using AssignMap = std::multimap; diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 4b7d444de..9d16c28c6 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -81,11 +81,11 @@ private: // Cleared each scope/active: // AstAssignDly::user3() -> AstVarScope*. __Vdlyvset__ created for this assign // AstAlwaysPost::user3() -> AstVarScope*. __Vdlyvset__ last referenced in IF - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; - AstUser5InUse m_inuser5; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; + const AstUser5InUse m_inuser5; // STATE AstActive* m_activep = nullptr; // Current activate @@ -512,6 +512,6 @@ public: void V3Delayed::delayedAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DelayedVisitor visitor{nodep}; } // Destruct before checking + { const DelayedVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("delayed", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 05633fec0..b875ac291 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -39,7 +39,7 @@ private: // NODE STATE // Cleared entire netlist // AstCFunc::user() // bool. Indicates processing completed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // TYPES using FuncMmap = std::multimap; diff --git a/src/V3EmitCBase.h b/src/V3EmitCBase.h index 5843c80bc..65a83f69c 100644 --- a/src/V3EmitCBase.h +++ b/src/V3EmitCBase.h @@ -34,7 +34,7 @@ class EmitCParentModule final { // NODE STATE // AstFunc::user4p() AstNodeModule* Parent module pointer // AstVar::user4p() AstNodeModule* Parent module pointer - AstUser4InUse user4InUse; + const AstUser4InUse user4InUse; public: EmitCParentModule(); diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 55d3a8151..4d1c342a3 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -37,7 +37,7 @@ constexpr int EMITC_NUM_CONSTW = 8; class EmitCLazyDecls final : public AstNVisitor { // NODE STATE/TYPES // AstNode::user2() -> bool. Already emitted decl for symbols. - AstUser2InUse m_inuser2; + const AstUser2InUse m_inuser2; // MEMBERS std::unordered_set m_emittedManually; // Set of names already declared manually. diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 73aff137d..749c74e39 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -556,7 +556,7 @@ class EmitCTrace final : EmitCFunc { // NODE STATE/TYPES // Cleared on netlist // AstNode::user1() -> int. Enum number - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // MEMBERS const bool m_slow; // Making slow file diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 024972b4d..b2e0f2942 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -34,7 +34,7 @@ class EmitCSyms final : EmitCBaseVisitor { // NODE STATE // Cleared on Netlist // AstNodeModule::user1() -> bool. Set true __Vconfigure called - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // TYPES struct ScopeData { diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 3afd020bd..8d7634dda 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -42,7 +42,7 @@ class ExpandVisitor final : public AstNVisitor { private: // NODE STATE // AstNode::user1() -> bool. Processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstNode* m_stmtp = nullptr; // Current statement diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index ccd8d7126..33e60c1f5 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -308,8 +308,8 @@ private: // AstVarScope::user2 -> bool: Signal used in SenItem in *this* always statement // AstVar::user2 -> bool: Warned about SYNCASYNCNET // AstNodeVarRef::user2 -> bool: ConcatOffset visited - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // STATE V3Graph m_graph; // Scoreboard of var usages/dependencies @@ -907,9 +907,9 @@ private: // Set to nullptr if this assign's tree was later replaced // AstUser1InUse m_inuser1; (Allocated for use in GateVisitor) // AstUser2InUse m_inuser2; (Allocated for use in GateVisitor) - AstUser3InUse m_inuser3; + const AstUser3InUse m_inuser3; // AstUser4InUse m_inuser4; (Allocated for use in V3Hasher via V3DupFinder) - AstUser5InUse m_inuser5; + const AstUser5InUse m_inuser5; V3DupFinder m_dupFinder; // Duplicate finder for rhs of assigns std::unordered_set m_nodeDeleteds; // Any node in this hash was deleted diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index 4c136ba38..ad2f012cb 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -43,8 +43,8 @@ private: // Cleared on top scope // AstVarScope::user2() -> AstVarScope*. Signal replacing activation with // AstVarRef::user3() -> bool. Signal is replaced activation (already done) - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; // STATE AstActive* m_activep = nullptr; // Inside activate statement @@ -141,7 +141,7 @@ private: // NODE STATE // Cleared on top scope // AstVarScope::user() -> bool. Set when the var has been used as clock - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE bool m_tracingCall = false; // Iterating into a call to a cfunc @@ -231,6 +231,6 @@ public: void V3GenClk::genClkAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { GenClkReadVisitor visitor{nodep}; } // Destruct before checking + { const GenClkReadVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("genclk", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Global.cpp b/src/V3Global.cpp index f86106411..1e6f41a9b 100644 --- a/src/V3Global.cpp +++ b/src/V3Global.cpp @@ -46,7 +46,7 @@ void V3Global::checkTree() const { rootp()->checkTree(); } void V3Global::readFiles() { // NODE STATE // AstNode::user4p() // VSymEnt* Package and typedef symbol names - AstUser4InUse inuser4; + const AstUser4InUse inuser4; VInFilter filter(v3Global.opt.pipeFilter()); V3ParseSym parseSyms(v3Global.rootp()); // Symbol table must be common across all parsing diff --git a/src/V3Hasher.h b/src/V3Hasher.h index 6207515f1..6bdfdc6be 100644 --- a/src/V3Hasher.h +++ b/src/V3Hasher.h @@ -32,7 +32,7 @@ class V3Hasher final { // NODE STATE // AstNode::user4() -> V3Hash. Hash value of this node (hash of 0 is illegal) - AstUser4InUse m_inuser4; + const AstUser4InUse m_inuser4; public: // CONSTRUCTORS diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 58103c813..7940e0270 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -239,7 +239,7 @@ string V3HierBlock::commandArgsFileName(bool forCMake) const { class HierBlockUsageCollectVisitor final : public AstNVisitor { // NODE STATE // AstNode::user1() -> bool. Processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE using ModuleSet = std::unordered_set; diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 3c13d9e56..b071728cc 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -53,9 +53,9 @@ private: // AstNodeModule::user2() // CIL_*. Allowed to automatically inline module // AstNodeModule::user3() // int. Number of cells referencing this module // AstNodeModule::user4() // int. Statements in module - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; // For the user2 field: enum : uint8_t { @@ -493,11 +493,10 @@ private: // // is a direct connect to // AstVar::user3() // bool Don't alias the user2, keep it as signal // AstCell::user4 // AstCell* of the created clone - - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; - AstUser5InUse m_inuser5; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; + const AstUser5InUse m_inuser5; // STATE AstNodeModule* m_modp = nullptr; // Current module @@ -625,8 +624,7 @@ class InlineIntfRefVisitor final : public AstNVisitor { private: // NODE STATE // AstVar::user1p() // AstCell which this Var points to - - AstUser2InUse m_inuser2; + const AstUser2InUse m_inuser2; string m_scope; // Scope name @@ -710,8 +708,8 @@ public: void V3Inline::inlineAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - AstUser1InUse m_inuser1; // output of InlineMarkVisitor, - // input to InlineVisitor. + const AstUser1InUse m_inuser1; // output of InlineMarkVisitor, + // input to InlineVisitor. // Scoped to clean up temp userN's { InlineMarkVisitor mvisitor{nodep}; } { InlineVisitor visitor{nodep}; } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index e35a9b9e0..55754113c 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -39,7 +39,7 @@ private: // NODE STATE // Cleared each Cell: // AstPin::user1p() -> bool. True if created assignment already - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstCell* m_cellp = nullptr; // Current cell diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index 7b1a6ab0e..6d1984a7c 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -34,7 +34,7 @@ private: // NODE STATE // AstNode::user4() -> int. Path cost + 1, 0 means don't dump // AstNode::user5() -> bool. Processed if assertNoDups - AstUser4InUse m_inuser4; + const AstUser4InUse m_inuser4; // MEMBERS uint32_t m_instrCount = 0; // Running count of instructions diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 7096f6558..38433a58e 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -41,7 +41,7 @@ class LifeState final { // NODE STATE // See below - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE public: diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index dbfbf8de0..9dded9c9d 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -133,7 +133,7 @@ private: // NODE STATE // Cleared on entire tree // AstVarScope::user4() -> AstVarScope*: Passed to LifePostElim to substitute this var - AstUser4InUse m_inuser4; + const AstUser4InUse m_inuser4; // STATE uint32_t m_sequence = 0; // Sequence number of assigns/varrefs, diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index ee631f419..d29440ed3 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -101,8 +101,8 @@ private: // AstCell::user2() // bool clone renaming completed // Allocated across all readFiles in V3Global::readFiles: // AstNode::user4p() // VSymEnt* Package and typedef symbol names - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // STATE VInFilter* m_filterp; // Parser filter diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 402638d82..31e2b9815 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -129,9 +129,9 @@ private: // AstVar::user4() // bool. True if port set for this variable // AstNodeBlock::user4() // bool. Did name processing // AstNodeModule::user4() // bool. Live module - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser4InUse m_inuser4; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser4InUse m_inuser4; public: // ENUMS @@ -1783,8 +1783,8 @@ private: // *::user4() -> See LinkDotState // Cleared on Cell // AstVar::user5() // bool. True if pin used in this cell - AstUser3InUse m_inuser3; - AstUser5InUse m_inuser5; + const AstUser3InUse m_inuser3; + const AstUser5InUse m_inuser5; // TYPES enum DotPosition : uint8_t { diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index c9b0e0113..305150cb7 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -40,8 +40,8 @@ private: // Cleared on netlist // AstNode::user1() -> bool. True if processed // AstNode::user2() -> bool. True if fileline recomputed - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // TYPES using ImplTypedefMap = std::map, AstTypedef*>; diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index d88a03c51..d013ab90e 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -43,7 +43,7 @@ private: // NODE STATE // Entire netlist: // AstCaseItem::user2() // bool Moved default caseitems - AstUser2InUse m_inuser2; + const AstUser2InUse m_inuser2; // STATE // Below state needs to be preserved between each module call. diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index e9c048f28..c8f8289d6 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -45,10 +45,10 @@ private: // AstVarScope::user3p() -> Set of CFuncs referencing this VarScope. (via m_accessors) // AstCFunc::user4p() -> Multimap of 'VarScope -> VarRefs that reference that VarScope' // in this function. (via m_references) - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; AstUser3Allocator> m_accessors; AstUser4Allocator> diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index f8bbf8bcb..1c01230e9 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -131,8 +131,8 @@ private: // NODE STATE // AstVar::user1 -> Flag set for variables referenced by m_mgCondp // AstNode::user2 -> Flag marking node as included in merge because cheap to duplicate - AstUser1InUse m_user1InUse; - AstUser2InUse m_user2InUse; + const AstUser1InUse m_user1InUse; + const AstUser2InUse m_user2InUse; // STATE VDouble0 m_statMerges; // Statistic tracking diff --git a/src/V3Name.cpp b/src/V3Name.cpp index 0583dc90c..7d1537792 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -37,7 +37,7 @@ private: // AstCell::user1() -> bool. Set true if already processed // AstScope::user1() -> bool. Set true if already processed // AstVar::user1() -> bool. Set true if already processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstNodeModule* m_modp = nullptr; diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 05b7b52d6..42c6765cb 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -364,8 +364,8 @@ class OrderBuildVisitor final : public AstNVisitor { // NODE STATE // AstVarScope::user1 -> OrderUser instance for variable (via m_orderUser) // AstVarScope::user2 -> VarUsage within logic blocks - AstUser1InUse user1InUse; - AstUser2InUse user2InUse; + const AstUser1InUse user1InUse; + const AstUser2InUse user2InUse; AstUser1Allocator m_orderUser; // STATE @@ -1038,7 +1038,7 @@ class OrderProcess final : AstNDeleter { // NODE STATE // AstNodeModule::user3 -> int: Number of AstCFuncs created under this module // AstNode::user4 -> Used by V3Const::constifyExpensiveEdit - AstUser3InUse user3InUse; + const AstUser3InUse user3InUse; // STATE OrderGraph& m_graph; // The ordering graph diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 28e8775db..45f3727fd 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -226,8 +226,8 @@ class ParamProcessor final { // AstGenFor::user5() // bool True if processed // AstVar::user5() // bool True if constant propagated // AstCell::user5p() // string* Generate portion of hierarchical name - AstUser4InUse m_inuser4; - AstUser5InUse m_inuser5; + const AstUser4InUse m_inuser4; + const AstUser5InUse m_inuser5; // User1/2/3 used by constant function simulations // TYPES diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 34980026d..3ea1bfd85 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -2566,7 +2566,7 @@ void V3Partition::go(V3Graph* mtasksp) { { // The V3InstrCount within LogicMTask will set user5 on each AST // node, to assert that we never count any node twice. - AstUser5InUse inUser5; + const AstUser5InUse inUser5; Vx2MTaskMap vx2mtask; for (V3GraphVertex* vxp = m_fineDepsGraphp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 9ffda7800..30116e97e 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -44,7 +44,7 @@ class PremitAssignVisitor final : public AstNVisitor { private: // NODE STATE // AstVar::user3() // bool; occurs on LHS of current assignment - AstUser3InUse m_inuser3; + const AstUser3InUse m_inuser3; // STATE bool m_noopt = false; // Disable optimization of variables in this block @@ -93,8 +93,8 @@ private: // AstShiftL::user2() -> bool. True if converted to conditional // AstShiftR::user2() -> bool. True if converted to conditional // *::user3() -> See PremitAssignVisitor - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // STATE AstCFunc* m_cfuncp = nullptr; // Current block diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index 7eb5c4750..e3b4ab315 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -37,7 +37,7 @@ private: // NODE STATE // Cleared on Netlist // AstClass::user1() -> bool. Set true to indicate needs randomize processing - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; using DerivedSet = std::unordered_set; using BaseToDerivedMap = std::unordered_map; @@ -119,7 +119,7 @@ private: // AstClass::user1() -> bool. Set true to indicate needs randomize processing // AstEnumDType::user2() -> AstVar*. Pointer to table with enum values // AstUser1InUse m_inuser1; (Allocated for use in RandomizeMarkVisitor) - AstUser2InUse m_inuser2; + const AstUser2InUse m_inuser2; // STATE size_t m_enumValueTabCount = 0; // Number of tables with enum values created diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 0a923615c..6b3154f0b 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -45,7 +45,7 @@ class ReloopVisitor final : public AstNVisitor { private: // NODE STATE // AstCFunc::user1p -> Var* for temp var, 0=not set yet - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE VDouble0 m_statReloops; // Statistic tracking diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 3d9d37fc1..788c2a617 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -41,8 +41,8 @@ private: // NODE STATE // AstVar::user1p -> AstVarScope replacement for this variable // AstTask::user2p -> AstTask*. Replacement task - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // TYPES // These cannot be unordered unless make a specialized hashing pair (gcc-8) diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 727538ada..8b96b97a6 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -72,9 +72,9 @@ class SimulateVisitor VL_NOT_FINAL : public AstNVisitor { private: // NODE STATE // Cleared on each always/assignw - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; // Checking: // AstVar(Scope)::user1() -> VarUsage. Set true to indicate tracking as lvalue/rvalue diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index 81887f2b0..f2c24fd07 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -50,7 +50,7 @@ class SliceVisitor final : public AstNVisitor { // AstNodeAssign::user1() -> bool. True if find is complete // AstNodeUniop::user1() -> bool. True if find is complete // AstArraySel::user1p() -> AstVarRef. The VarRef that the final ArraySel points to - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstNode* m_assignp = nullptr; // Assignment we are under diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 61e193653..2e4e4608d 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -242,10 +242,10 @@ private: // AstVarScope::user2p -> Var SplitNodeVertex* for delayed assignment var, 0=not set yet // Ast*::user3p -> Statement SplitLogicVertex* (temporary only) // Ast*::user4 -> Current ordering number (reorderBlock usage) - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; protected: // STATE diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index 9cd9765a8..bf7f0c0cc 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -128,7 +128,7 @@ class SplitAsVisitor final : public SplitAsBaseVisitor { private: // NODE STATE // AstAlways::user() -> bool. True if already processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE VDouble0 m_statSplits; // Statistic tracking diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 3541c63de..60c845d19 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -127,7 +127,7 @@ struct SplitVarImpl { // NODE STATE // AstNodeModule::user1() -> Block number counter for generating unique names - AstUser1InUse m_user1InUse; // Only used in SplitUnpackedVarVisitor + const AstUser1InUse m_user1InUse; // Only used in SplitUnpackedVarVisitor static AstNodeAssign* newAssign(FileLine* fileline, AstNode* lhsp, AstNode* rhsp, const AstVar* varp) { diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index a210403d6..356188cb4 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -227,8 +227,8 @@ private: // Passed to SubstUseVisitor // AstVar::user1p -> SubstVar* for usage var, 0=not set yet // AstVar::user2 -> int step number for last assignment, 0=not set yet - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // STATE std::vector m_entryps; // Nodes to delete when we are finished @@ -381,6 +381,6 @@ public: void V3Subst::substituteAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SubstVisitor visitor{nodep}; } // Destruct before checking + { const SubstVisitor visitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("subst", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 890af9975..c60db1737 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -98,9 +98,8 @@ private: // AstNodeFTask::user3p // AstScope* this FTask is under // AstNodeFTask::user4p // GraphFTaskVertex* this FTask is under // AstVar::user4p // GraphFTaskVertex* this variable is declared in - - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; // TYPES using VarToScopeMap = std::map, AstVarScope*>; @@ -370,7 +369,7 @@ struct TaskDpiUtils { class TaskGatherWrittenVisitor final : public AstNVisitor { // NODE STATE // AstVarScope::user5 -> Already considered variable - AstUser5InUse m_user5InUse; + const AstUser5InUse m_user5InUse; std::vector m_writtenVariables; // Variables written @@ -408,9 +407,8 @@ private: // Each funccall // to TaskRelinkVisitor: // AstVar::user2p // AstVarScope* to replace varref with - - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // TYPES enum InsertMode : uint8_t { diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 747ef9d3b..e7d17db0c 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -162,9 +162,9 @@ private: // AstVarScope::user1() // V3GraphVertex* for this node // AstCCall::user2() // bool; walked next list for other ccalls // Ast*::user3() // TraceActivityVertex* for this node - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; // AstUser4InUse In V3Hasher via V3DupFinder // STATE diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index c70942e29..a3eb01cf6 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -327,11 +327,11 @@ class TristateVisitor final : public TristateBaseVisitor { // See TristateGraph: // AstVar::user5p -> TristateVertex* for variable being built // AstStmt*::user5p -> TristateVertex* for this statement - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; - AstUser3InUse m_inuser3; - AstUser4InUse m_inuser4; - AstUser5InUse m_inuser5; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; + const AstUser3InUse m_inuser3; + const AstUser4InUse m_inuser4; + const AstUser5InUse m_inuser5; // TYPES using RefVec = std::vector; diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 90b67a78e..1c2eedc90 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -240,10 +240,10 @@ private: // NODE STATE // Netlist: // AstVar::user1p -> UndrivenVar* for usage var, 0=not set yet - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // Each always: // AstNode::user2p -> UndrivenVar* for usage var, 0=not set yet - AstUser2InUse m_inuser2; + const AstUser2InUse m_inuser2; // STATE std::array, 3> m_entryps; // Nodes to delete when finished diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 70f4dc99f..ff88d14c6 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -49,8 +49,8 @@ private: // AstSel::user() -> bool. Set true if already processed // AstArraySel::user() -> bool. Set true if already processed // AstNode::user2p() -> AstIf* Inserted if assignment for conditional - AstUser1InUse m_inuser1; - AstUser2InUse m_inuser2; + const AstUser1InUse m_inuser1; + const AstUser2InUse m_inuser2; // STATE AstNodeModule* m_modp = nullptr; // Current module diff --git a/src/V3VariableOrder.cpp b/src/V3VariableOrder.cpp index e3df0d1d0..bf6d9c505 100644 --- a/src/V3VariableOrder.cpp +++ b/src/V3VariableOrder.cpp @@ -78,7 +78,7 @@ unsigned VarTspSorter::s_serialNext = 0; class VariableOrder final { // NODE STATE // AstVar::user1() -> attributes, via m_attributes - AstUser1InUse m_user1InUse; // AstVar + const AstUser1InUse m_user1InUse; // AstVar struct VarAttributes { uint32_t stratum; // Roughly equivalent to alignment requirement, to avoid padding diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index 77514ff3b..5dc34c028 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -67,7 +67,7 @@ public: class WidthCommitVisitor final : public AstNVisitor { // NODE STATE // AstVar::user1p -> bool, processed - AstUser1InUse m_inuser1; + const AstUser1InUse m_inuser1; // STATE AstNodeModule* m_modp = nullptr; From 2742a8c8131e8e2768329b1aec4d6b7172e249f9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 10:52:36 -0500 Subject: [PATCH 61/79] Internals: No need for variable name on immediate visitors. No functional change intended. --- src/V3Active.cpp | 8 ++++---- src/V3ActiveTop.cpp | 2 +- src/V3Assert.cpp | 2 +- src/V3AssertPre.cpp | 2 +- src/V3Begin.cpp | 4 ++-- src/V3Branch.cpp | 2 +- src/V3Case.cpp | 4 ++-- src/V3Cast.cpp | 2 +- src/V3Cdc.cpp | 2 +- src/V3Changed.cpp | 4 ++-- src/V3Class.cpp | 2 +- src/V3Clean.cpp | 2 +- src/V3Clock.cpp | 2 +- src/V3Combine.cpp | 2 +- src/V3Coverage.cpp | 2 +- src/V3CoverageJoin.cpp | 2 +- src/V3Dead.cpp | 12 ++++++------ src/V3Delayed.cpp | 2 +- src/V3Depth.cpp | 2 +- src/V3DepthBlock.cpp | 2 +- src/V3Descope.cpp | 2 +- src/V3EmitV.cpp | 10 ++++++---- src/V3Expand.cpp | 2 +- src/V3Gate.cpp | 2 +- src/V3GenClk.cpp | 4 ++-- src/V3Hasher.cpp | 2 +- src/V3Inline.cpp | 6 +++--- src/V3Inst.cpp | 4 ++-- src/V3Life.cpp | 6 +++--- src/V3LifePost.cpp | 4 ++-- src/V3LinkCells.cpp | 2 +- src/V3LinkDot.cpp | 2 +- src/V3LinkInc.cpp | 2 +- src/V3LinkJump.cpp | 2 +- src/V3LinkLValue.cpp | 4 ++-- src/V3LinkParse.cpp | 2 +- src/V3LinkResolve.cpp | 2 +- src/V3Localize.cpp | 2 +- src/V3MergeCond.cpp | 2 +- src/V3Name.cpp | 2 +- src/V3Param.cpp | 2 +- src/V3Premit.cpp | 2 +- src/V3Randomize.cpp | 2 +- src/V3Reloop.cpp | 2 +- src/V3Scope.cpp | 2 +- src/V3Slice.cpp | 2 +- src/V3Split.cpp | 4 ++-- src/V3SplitAs.cpp | 2 +- src/V3SplitVar.cpp | 2 +- src/V3Stats.cpp | 2 +- src/V3Subst.cpp | 2 +- src/V3Table.cpp | 2 +- src/V3Trace.cpp | 2 +- src/V3TraceDecl.cpp | 2 +- src/V3Tristate.cpp | 4 ++-- src/V3Undriven.cpp | 2 +- src/V3Unknown.cpp | 2 +- src/V3Width.cpp | 2 +- 58 files changed, 84 insertions(+), 82 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index a20bae1fc..6bf73461c 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -542,12 +542,12 @@ private: if (combo && !sequent) { ActiveLatchCheckVisitor latchvisitor{nodep, kwd}; if (kwd == VAlwaysKwd::ALWAYS_LATCH) { - ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_LATCH}; + ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_LATCH}; } else { - ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_COMBO}; + ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_COMBO}; } } else if (!combo && sequent) { - ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_SEQ}; + ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_SEQ}; } } virtual void visit(AstAlways* nodep) override { @@ -620,6 +620,6 @@ public: void V3Active::activeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ActiveVisitor visitor{nodep}; } // Destruct before checking + { ActiveVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("active", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3ActiveTop.cpp b/src/V3ActiveTop.cpp index ab5155cd4..04aa7f79e 100644 --- a/src/V3ActiveTop.cpp +++ b/src/V3ActiveTop.cpp @@ -128,6 +128,6 @@ public: void V3ActiveTop::activeTopAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ActiveTopVisitor visitor{nodep}; } // Destruct before checking + { ActiveTopVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("activetop", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 20f8c3725..db87a0b10 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -475,6 +475,6 @@ public: void V3Assert::assertAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { AssertVisitor visitor{nodep}; } // Destruct before checking + { AssertVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("assert", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3AssertPre.cpp b/src/V3AssertPre.cpp index d4754597c..758d0acf1 100644 --- a/src/V3AssertPre.cpp +++ b/src/V3AssertPre.cpp @@ -205,6 +205,6 @@ public: void V3AssertPre::assertPreAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { AssertPreVisitor visitor{nodep}; } // Destruct before checking + { AssertPreVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("assertpre", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 9d9d4a483..9ed6706e9 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -308,8 +308,8 @@ void V3Begin::debeginAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { BeginState state; - { BeginVisitor bvisitor{nodep, &state}; } - if (state.anyFuncInBegin()) { BeginRelinkVisitor brvisitor(nodep, &state); } + { BeginVisitor{nodep, &state}; } + if (state.anyFuncInBegin()) { BeginRelinkVisitor{nodep, &state}; } } // Destruct before checking V3Global::dumpCheckGlobalTree("begin", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index a3690bddc..da13df889 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -123,5 +123,5 @@ public: void V3Branch::branchAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - BranchVisitor visitor{nodep}; + { BranchVisitor{nodep}; } } diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 830694d1a..c61b1ed7d 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -532,10 +532,10 @@ public: void V3Case::caseAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CaseVisitor visitor{nodep}; } // Destruct before checking + { CaseVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("case", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Case::caseLint(AstNodeCase* nodep) { UINFO(4, __FUNCTION__ << ": " << endl); - CaseLintVisitor visitor{nodep}; + { CaseLintVisitor{nodep}; } } diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index 149202c70..2436d532c 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -203,6 +203,6 @@ public: void V3Cast::castAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { const CastVisitor visitor{nodep}; } // Destruct before checking + { CastVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("cast", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 28851bcdb..2e04c826f 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -761,5 +761,5 @@ public: void V3Cdc::cdcAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - CdcVisitor visitor{nodep}; + { CdcVisitor{nodep}; } } diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 9d28c7ab2..f8a321406 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -257,7 +257,7 @@ private: void genChangeDet(AstVarScope* vscp) { vscp->v3warn(IMPERFECTSCH, "Imperfect scheduling of variable: " << vscp->prettyNameQ()); - ChangedInsertVisitor visitor{vscp, m_statep}; + { ChangedInsertVisitor{vscp, m_statep}; } } // VISITORS @@ -304,7 +304,7 @@ void V3Changed::changedAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { ChangedState state; - ChangedVisitor visitor{nodep, &state}; + ChangedVisitor{nodep, &state}; } // Destruct before checking V3Global::dumpCheckGlobalTree("changed", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 5310b7862..8a5b37821 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -157,6 +157,6 @@ public: void V3Class::classAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ClassVisitor visitor{nodep}; } // Destruct before checking + { ClassVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("class", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 9eda5e56f..329f667f5 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -314,6 +314,6 @@ public: void V3Clean::cleanAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CleanVisitor visitor{nodep}; } // Destruct before checking + { CleanVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("clean", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 8dde574f9..eeaf0dae0 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -444,6 +444,6 @@ public: void V3Clock::clockAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ClockVisitor visitor{nodep}; } // Destruct before checking + { ClockVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("clock", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index aa38734e4..89b81accd 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -223,6 +223,6 @@ public: void V3Combine::combineAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { CombineVisitor visitor{nodep}; } // Destruct before checking + { CombineVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("combine", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 766149504..3f822259d 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -543,6 +543,6 @@ public: void V3Coverage::coverage(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); - { CoverageVisitor visitor{rootp}; } // Destruct before checking + { CoverageVisitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("coverage", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3CoverageJoin.cpp b/src/V3CoverageJoin.cpp index 905b52969..f372571ab 100644 --- a/src/V3CoverageJoin.cpp +++ b/src/V3CoverageJoin.cpp @@ -114,6 +114,6 @@ public: void V3CoverageJoin::coverageJoin(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); - { CoverageJoinVisitor visitor{rootp}; } // Destruct before checking + { CoverageJoinVisitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("coveragejoin", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 7af22c0c4..1ee856172 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -318,7 +318,7 @@ private: // And its children may now be killable too; correct counts // Recurse, as cells may not be directly under the module but in a generate if (!modp->dead()) { // If was dead didn't increment user1's - DeadModVisitor visitor{modp}; + DeadModVisitor{modp}; } VL_DO_DANGLING(modp->unlinkFrBack()->deleteTree(), modp); retry = true; @@ -463,31 +463,31 @@ public: void V3Dead::deadifyModules(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor{nodep, false, false, false, false}; } // Destruct before checking + { DeadVisitor{nodep, false, false, false, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadModules", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } void V3Dead::deadifyDTypes(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor{nodep, false, true, false, false}; } // Destruct before checking + { DeadVisitor{nodep, false, true, false, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadDtypes", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Dead::deadifyDTypesScoped(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor{nodep, false, true, true, false}; } // Destruct before checking + { DeadVisitor{nodep, false, true, true, false}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadDtypesScoped", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Dead::deadifyAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor{nodep, true, true, false, true}; } // Destruct before checking + { DeadVisitor{nodep, true, true, false, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadAll", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Dead::deadifyAllScoped(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DeadVisitor visitor{nodep, true, true, true, true}; } // Destruct before checking + { DeadVisitor{nodep, true, true, true, true}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deadAllScoped", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 9d16c28c6..1f7aa2c32 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -512,6 +512,6 @@ public: void V3Delayed::delayedAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { const DelayedVisitor visitor{nodep}; } // Destruct before checking + { DelayedVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("delayed", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Depth.cpp b/src/V3Depth.cpp index 72fc81d6d..912d900fa 100644 --- a/src/V3Depth.cpp +++ b/src/V3Depth.cpp @@ -152,6 +152,6 @@ public: void V3Depth::depthAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DepthVisitor visitor{nodep}; } // Destruct before checking + { DepthVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("depth", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 99bfb8ca5..2fcaaab91 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -129,6 +129,6 @@ public: void V3DepthBlock::depthBlockAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DepthBlockVisitor visitor{nodep}; } // Destruct before checking + { DepthBlockVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("deepblock", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index b875ac291..a8f75006f 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -289,6 +289,6 @@ public: void V3Descope::descopeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { DescopeVisitor visitor{nodep}; } // Destruct before checking + { DescopeVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("descope", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 52a1543f8..0904bd638 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -827,11 +827,13 @@ public: //###################################################################### // EmitV class functions -void V3EmitV::verilogForTree(AstNode* nodep, std::ostream& os) { EmitVStreamVisitor(nodep, os); } +void V3EmitV::verilogForTree(AstNode* nodep, std::ostream& os) { + { EmitVStreamVisitor{nodep, os}; } +} void V3EmitV::verilogPrefixedTree(AstNode* nodep, std::ostream& os, const string& prefix, int flWidth, AstSenTree* domainp, bool user3mark) { - EmitVPrefixedVisitor{nodep, os, prefix, flWidth, domainp, user3mark}; + { EmitVPrefixedVisitor{nodep, os, prefix, flWidth, domainp, user3mark}; } } void V3EmitV::emitvFiles() { @@ -843,7 +845,7 @@ void V3EmitV::emitvFiles() { V3OutVFile of(vfilep->name()); of.puts("// DESCR" "IPTION: Verilator generated Verilog\n"); - EmitVFileVisitor visitor{vfilep->tblockp(), &of, true, false}; + { EmitVFileVisitor{vfilep->tblockp(), &of, true, false}; } } } } @@ -853,5 +855,5 @@ void V3EmitV::debugEmitV(const string& stage) { const string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v"; V3OutVFile of(filename); - EmitVFileVisitor visitor{v3Global.rootp(), &of, true, true}; + { EmitVFileVisitor{v3Global.rootp(), &of, true, true}; } } diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 8d7634dda..2fd3e08f5 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -910,6 +910,6 @@ public: void V3Expand::expandAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ExpandVisitor visitor{nodep}; } // Destruct before checking + { ExpandVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("expand", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 33e60c1f5..49db774bf 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -1602,7 +1602,7 @@ void V3Gate::gateAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { GateVisitor visitor{nodep}; - GateDeassignVisitor deassign{nodep}; + GateDeassignVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("gate", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index ad2f012cb..a530e084d 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -156,7 +156,7 @@ private: { // Make the new clock signals and replace any activate references // See rename, it does some AstNode::userClearTree()'s - GenClkRenameVisitor visitor{nodep, m_topModp}; + GenClkRenameVisitor{nodep, m_topModp}; } } virtual void visit(AstNodeModule* nodep) override { @@ -231,6 +231,6 @@ public: void V3GenClk::genClkAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { const GenClkReadVisitor visitor{nodep}; } // Destruct before checking + { GenClkReadVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("genclk", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index 1306247dd..b40dc8e9a 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -491,7 +491,7 @@ public: // V3Hasher methods V3Hash V3Hasher::operator()(AstNode* nodep) const { - if (!nodep->user4()) { HasherVisitor visitor{nodep}; } + if (!nodep->user4()) { HasherVisitor{nodep}; } return V3Hash(nodep->user4()); } diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index b071728cc..6fdc28ee4 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -711,8 +711,8 @@ void V3Inline::inlineAll(AstNetlist* nodep) { const AstUser1InUse m_inuser1; // output of InlineMarkVisitor, // input to InlineVisitor. // Scoped to clean up temp userN's - { InlineMarkVisitor mvisitor{nodep}; } - { InlineVisitor visitor{nodep}; } + { InlineMarkVisitor{nodep}; } + { InlineVisitor{nodep}; } // Remove all modules that were inlined // V3Dead will also clean them up, but if we have debug on, it's a good // idea to avoid dumping the hugely exploded tree. @@ -723,6 +723,6 @@ void V3Inline::inlineAll(AstNetlist* nodep) { VL_DO_DANGLING(modp->unlinkFrBack()->deleteTree(), modp); } } - { InlineIntfRefVisitor crvisitor{nodep}; } + { InlineIntfRefVisitor{nodep}; } V3Global::dumpCheckGlobalTree("inline", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 55754113c..fcbf1e743 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -615,12 +615,12 @@ void V3Inst::checkOutputShort(AstPin* nodep) { void V3Inst::instAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { InstVisitor visitor{nodep}; } // Destruct before checking + { InstVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("inst", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Inst::dearrayAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { InstDeVisitor visitor{nodep}; } // Destruct before checking + { InstDeVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("dearray", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 38433a58e..7d3bca186 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -461,12 +461,12 @@ private: virtual void visit(AstCFunc* nodep) override { if (nodep->entryPoint()) { // Usage model 1: Simulate all C code, doing lifetime analysis - LifeVisitor visitor{nodep, m_statep}; + LifeVisitor{nodep, m_statep}; } } virtual void visit(AstNodeProcedure* nodep) override { // Usage model 2: Cleanup basic blocks - LifeVisitor visitor{nodep, m_statep}; + LifeVisitor{nodep, m_statep}; } virtual void visit(AstVar*) override {} // Accelerate virtual void visit(AstNodeStmt*) override {} // Accelerate @@ -489,7 +489,7 @@ void V3Life::lifeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { LifeState state; - LifeTopVisitor visitor{nodep, &state}; + LifeTopVisitor{nodep, &state}; } // Destruct before checking V3Global::dumpCheckGlobalTree("life", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 9dded9c9d..0fb60cdad 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -271,7 +271,7 @@ private: squashAssignposts(); // Replace any node4p varscopes with the new scope - LifePostElimVisitor visitor{nodep}; + LifePostElimVisitor{nodep}; } virtual void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, @@ -348,6 +348,6 @@ public: void V3LifePost::lifepostAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); // Mark redundant AssignPost - { LifePostDlyVisitor visitor{nodep}; } // Destruct before checking + { LifePostDlyVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("life_post", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index d29440ed3..d9ef034ed 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -523,5 +523,5 @@ public: void V3LinkCells::link(AstNetlist* nodep, VInFilter* filterp, V3ParseSym* parseSymp) { UINFO(4, __FUNCTION__ << ": " << endl); - LinkCellsVisitor visitor{nodep, filterp, parseSymp}; + { LinkCellsVisitor{nodep, filterp, parseSymp}; } } diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 31e2b9815..fc70c4945 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -3075,5 +3075,5 @@ void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) { state.computeIfaceVarSyms(); state.computeScopeAliases(); state.dump(); - LinkDotResolveVisitor visitorb{rootp, &state}; + { LinkDotResolveVisitor{rootp, &state}; } } diff --git a/src/V3LinkInc.cpp b/src/V3LinkInc.cpp index 1480dc3dc..b27eaac91 100644 --- a/src/V3LinkInc.cpp +++ b/src/V3LinkInc.cpp @@ -245,6 +245,6 @@ public: void V3LinkInc::linkIncrements(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { LinkIncVisitor bvisitor{nodep}; } // Destruct before checking + { LinkIncVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkInc", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index 20bacaf38..a2626bc03 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -287,6 +287,6 @@ public: void V3LinkJump::linkJump(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { LinkJumpVisitor bvisitor{nodep}; } // Destruct before checking + { LinkJumpVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("link", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3LinkLValue.cpp b/src/V3LinkLValue.cpp index 29b3bf5cd..05f546502 100644 --- a/src/V3LinkLValue.cpp +++ b/src/V3LinkLValue.cpp @@ -298,12 +298,12 @@ public: void V3LinkLValue::linkLValue(AstNetlist* nodep) { UINFO(4, __FUNCTION__ << ": " << endl); - { LinkLValueVisitor visitor{nodep, VAccess::NOCHANGE}; } // Destruct before checking + { LinkLValueVisitor{nodep, VAccess::NOCHANGE}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linklvalue", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } void V3LinkLValue::linkLValueSet(AstNode* nodep) { // Called by later link functions when it is known a node needs // to be converted to a lvalue. UINFO(9, __FUNCTION__ << ": " << endl); - LinkLValueVisitor visitor{nodep, VAccess::WRITE}; + { LinkLValueVisitor{nodep, VAccess::WRITE}; } } diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 305150cb7..5952ea46f 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -674,6 +674,6 @@ public: void V3LinkParse::linkParse(AstNetlist* rootp) { UINFO(4, __FUNCTION__ << ": " << endl); - { LinkParseVisitor visitor{rootp}; } // Destruct before checking + { LinkParseVisitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkparse", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index d013ab90e..a570bfec6 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -585,7 +585,7 @@ void V3LinkResolve::linkResolve(AstNetlist* rootp) { UINFO(4, __FUNCTION__ << ": " << endl); { LinkResolveVisitor visitor{rootp}; - LinkBotupVisitor visitorb{rootp}; + LinkBotupVisitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkresolve", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Localize.cpp b/src/V3Localize.cpp index c8f8289d6..6b538c4c7 100644 --- a/src/V3Localize.cpp +++ b/src/V3Localize.cpp @@ -201,6 +201,6 @@ public: void V3Localize::localizeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { LocalizeVisitor visitor{nodep}; } // Destruct before checking + { LocalizeVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("localize", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 1c01230e9..8172aeff4 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -537,6 +537,6 @@ public: void V3MergeCond::mergeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { MergeCondVisitor visitor{nodep}; } + { MergeCondVisitor{nodep}; } V3Global::dumpCheckGlobalTree("merge_cond", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Name.cpp b/src/V3Name.cpp index 7d1537792..5e1c13239 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -142,6 +142,6 @@ public: void V3Name::nameAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { NameVisitor visitor{nodep}; } // Destruct before checking + { NameVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("name", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 45f3727fd..4583c32c0 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -1201,6 +1201,6 @@ public: void V3Param::param(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); - { ParamVisitor visitor{rootp}; } // Destruct before checking + { ParamVisitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("param", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 30116e97e..24babc53c 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -430,6 +430,6 @@ public: void V3Premit::premitAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { PremitVisitor visitor{nodep}; } // Destruct before checking + { PremitVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("premit", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index e3b4ab315..d1241cf08 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -254,7 +254,7 @@ void V3Randomize::randomizeNetlist(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { RandomizeMarkVisitor markVisitor{nodep}; - RandomizeVisitor visitor{nodep}; + RandomizeVisitor{nodep}; } V3Global::dumpCheckGlobalTree("randomize", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 6b3154f0b..77508429d 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -267,6 +267,6 @@ public: void V3Reloop::reloopAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ReloopVisitor visitor{nodep}; } // Destruct before checking + { ReloopVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("reloop", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 788c2a617..6b31c84c9 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -402,7 +402,7 @@ void V3Scope::scopeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { ScopeVisitor visitor{nodep}; - ScopeCleanupVisitor cleanVisitor{nodep}; + ScopeCleanupVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("scope", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index f2c24fd07..1c220d4fa 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -237,6 +237,6 @@ public: void V3Slice::sliceAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SliceVisitor visitor{nodep}; } // Destruct before checking + { SliceVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("slice", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Split.cpp b/src/V3Split.cpp index 2e4e4608d..b4e59315b 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -968,11 +968,11 @@ private: void V3Split::splitReorderAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { ReorderVisitor visitor{nodep}; } // Destruct before checking + { ReorderVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("reorder", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } void V3Split::splitAlwaysAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SplitVisitor visitor{nodep}; } // Destruct before checking + { SplitVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("split", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index bf7f0c0cc..b87e3bcb1 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -194,6 +194,6 @@ public: void V3SplitAs::splitAsAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { SplitAsVisitor visitor{nodep}; } // Destruct before checking + { SplitAsVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("splitas", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 60c845d19..38c32fc4f 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -1259,7 +1259,7 @@ void V3SplitVar::splitVariable(AstNetlist* nodep) { refs = visitor.getPackedVarRefs(); } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); - { SplitPackedVarVisitor visitor{nodep, refs}; } + { SplitPackedVarVisitor{nodep, refs}; } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); } diff --git a/src/V3Stats.cpp b/src/V3Stats.cpp index 3084b233b..7bfada996 100644 --- a/src/V3Stats.cpp +++ b/src/V3Stats.cpp @@ -279,7 +279,7 @@ public: // Top Stats class void V3Stats::statsStageAll(AstNetlist* nodep, const string& stage, bool fast) { - StatsVisitor visitor{nodep, stage, fast}; + { StatsVisitor{nodep, stage, fast}; } } void V3Stats::statsFinalAll(AstNetlist* nodep) { diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 356188cb4..19e44e3c7 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -381,6 +381,6 @@ public: void V3Subst::substituteAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { const SubstVisitor visitor{nodep}; } // Destruct before checking + { SubstVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("subst", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 0220a2df5..85e179be6 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -425,6 +425,6 @@ void TableSimulateVisitor::varRefCb(AstVarRef* nodep) { void V3Table::tableAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TableVisitor visitor{nodep}; } // Destruct before checking + { TableVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("table", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index e7d17db0c..7719c77e6 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -901,6 +901,6 @@ public: void V3Trace::traceAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TraceVisitor visitor{nodep}; } // Destruct before checking + { TraceVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("trace", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index a37ddb8c8..51535a3d1 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -360,6 +360,6 @@ public: void V3TraceDecl::traceDeclAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TraceDeclVisitor visitor{nodep}; } // Destruct before checking + { TraceDeclVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("tracedecl", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index a3eb01cf6..64b8d5e45 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -1217,7 +1217,7 @@ class TristateVisitor final : public TristateBaseVisitor { // simple, it will flip ArraySel's and such, but if the // pin is an input the earlier reconnectSimple made it // a VarRef without any ArraySel, etc - TristatePinVisitor visitor{outexprp, m_tgraph, true}; + TristatePinVisitor{outexprp, m_tgraph, true}; } if (debug() >= 9) outpinp->dumpTree(cout, "-pin-opr: "); outAssignp = V3Inst::pinReconnectSimple(outpinp, m_cellp, @@ -1428,6 +1428,6 @@ public: void V3Tristate::tristateAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { TristateVisitor visitor{nodep}; } // Destruct before checking + { TristateVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("tristate", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 1c2eedc90..b601b8563 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -461,5 +461,5 @@ public: void V3Undriven::undrivenAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - UndrivenVisitor visitor{nodep}; + { UndrivenVisitor{nodep}; } } diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index ff88d14c6..f45b9dfec 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -496,6 +496,6 @@ public: void V3Unknown::unknownAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { UnknownVisitor visitor{nodep}; } // Destruct before checking + { UnknownVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("unknown", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 284eeab1e..494d3aa28 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -6250,6 +6250,6 @@ AstNode* V3Width::widthGenerateParamsEdit( void V3Width::widthCommit(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); - { WidthCommitVisitor visitor{nodep}; } // Destruct before checking + { WidthCommitVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("widthcommit", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); } From b0018fd6803f497104bfb68d85912dc6898935c1 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 15:13:36 -0500 Subject: [PATCH 62/79] Internals: Remove dead output variable. No functional change. --- src/V3File.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/V3File.cpp b/src/V3File.cpp index f3c2d3992..6260c61cb 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -394,8 +394,7 @@ private: #endif } - string readBlocks(int fd, int size, StrList& outl) { - string out; + void readBlocks(int fd, int size, StrList& outl) { char buf[INFILTER_IPC_BUFSIZ]; ssize_t sizegot = 0; while (!m_readEof && (size < 0 || size > sizegot)) { @@ -421,7 +420,6 @@ private: break; } } - return out; } // cppcheck-suppress unusedFunction unusedPrivateFunction string readFilterLine() { From d1862e25eb722c55e5c8e8cd7fc498a43835ad44 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 16:05:07 -0500 Subject: [PATCH 63/79] Internals: Cleanup some constructor-constructor assigns. No functional change intended. --- src/V3Unroll.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 2c5efb113..e63eb1e0c 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -86,7 +86,7 @@ private: } bool forUnrollCheck( - AstNode* nodep, + AstNode* const nodep, AstNode* const initp, // Maybe under nodep (no nextp), or standalone (ignore nextp) AstNode* const precondsp, AstNode* condp, AstNode* const incp, // Maybe under nodep or in bodysp @@ -219,34 +219,34 @@ private: return false; } // Fetch the result - V3Number* res = simvis.fetchNumberNull(clonep); - if (!res) { + V3Number* resp = simvis.fetchNumberNull(clonep); + if (!resp) { UINFO(3, "No number returned from simulation" << endl); VL_DO_DANGLING(clonep->deleteTree(), clonep); return false; } // Patch up datatype if (dtypep) { - AstConst new_con(clonep->fileline(), *res); + AstConst new_con{clonep->fileline(), *resp}; new_con.dtypeFrom(dtypep); outNum = new_con.num(); outNum.isSigned(dtypep->isSigned()); VL_DO_DANGLING(clonep->deleteTree(), clonep); return true; } - outNum = *res; + outNum = *resp; VL_DO_DANGLING(clonep->deleteTree(), clonep); return true; } bool countLoops(AstAssign* initp, AstNode* condp, AstNode* incp, int max, int& outLoopsr) { outLoopsr = 0; - V3Number loopValue = V3Number(initp); + V3Number loopValue{initp}; if (!simulateTree(initp->rhsp(), nullptr, initp, loopValue)) { // return false; } while (true) { - V3Number res = V3Number(initp); + V3Number res{initp}; if (!simulateTree(condp, &loopValue, nullptr, res)) { // return false; } @@ -256,7 +256,7 @@ private: // Run inc AstAssign* const incpass = VN_AS(incp, Assign); - V3Number newLoopValue = V3Number(initp); + V3Number newLoopValue{initp}; if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) { return false; } @@ -269,7 +269,7 @@ private: bool forUnroller(AstNode* nodep, AstAssign* initp, AstNode* condp, AstNode* precondsp, AstNode* incp, AstNode* bodysp) { UINFO(9, "forUnroller " << nodep << endl); - V3Number loopValue = V3Number(nodep); + V3Number loopValue{nodep}; if (!simulateTree(initp->rhsp(), nullptr, initp, loopValue)) { // return false; } @@ -300,7 +300,7 @@ private: int times = 0; while (true) { UINFO(8, " Looping " << loopValue << endl); - V3Number res = V3Number(nodep); + V3Number res{nodep}; if (!simulateTree(condp, &loopValue, nullptr, res)) { nodep->v3error("Loop unrolling failed."); return false; @@ -346,7 +346,7 @@ private: // loopValue += valInc AstAssign* const incpass = VN_AS(incp, Assign); - V3Number newLoopValue = V3Number(nodep); + V3Number newLoopValue{nodep}; if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) { nodep->v3error("Loop unrolling failed"); return false; From 60f7eff701bc3da5ddecdfdd107f2ff039866363 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 16:10:16 -0500 Subject: [PATCH 64/79] Remove dead statistic. --- src/V3Trace.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 7719c77e6..26fcdd4b7 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -180,7 +180,6 @@ private: TraceActivityVertex* const m_alwaysVtxp; // "Always trace" vertex bool m_finding = false; // Pass one of algorithm? - VDouble0 m_statChgSigs; // Statistic tracking VDouble0 m_statUniqSigs; // Statistic tracking VDouble0 m_statUniqCodes; // Statistic tracking @@ -890,7 +889,6 @@ public: iterate(nodep); } virtual ~TraceVisitor() override { - V3Stats::addStat("Tracing, Unique changing signals", m_statChgSigs); V3Stats::addStat("Tracing, Unique traced signals", m_statUniqSigs); V3Stats::addStat("Tracing, Unique trace codes", m_statUniqCodes); } From 010084201a2b634d5abf14b7cb0a61eebd49315f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 16:15:08 -0500 Subject: [PATCH 65/79] Internals: Remove dead code. --- src/V3Partition.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index 3ea1bfd85..de8f72e91 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -166,7 +166,6 @@ private: // // from graph-start to current node, or REVERSE // // from graph-end to current node. T_CostAccessor* const m_accessp; // Access cost and CPs on V3GraphVertex's. - vluint64_t m_generation = 0; // Mark each vertex with this number; // // confirm we only process each vertex once. bool m_slowAsserts; // Enable nontrivial asserts SortByValueMap m_pending; // Pending rescores From cd737065f2cf6bb298dea1b6ecb5b056bc9da70c Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 26 Nov 2021 17:55:36 -0500 Subject: [PATCH 66/79] Internals: More const. No functional change intended. --- include/verilated_vpi.cpp | 6 +- src/V3Active.cpp | 14 +- src/V3Assert.cpp | 2 +- src/V3Ast.cpp | 6 +- src/V3Ast.h | 20 +- src/V3AstNodes.cpp | 88 ++--- src/V3AstNodes.h | 111 ++++--- src/V3AstUserAllocator.h | 2 +- src/V3Begin.cpp | 8 +- src/V3Broken.cpp | 4 +- src/V3CCtors.cpp | 5 +- src/V3Case.cpp | 12 +- src/V3Cdc.cpp | 10 +- src/V3Changed.cpp | 8 +- src/V3Class.cpp | 6 +- src/V3Clean.cpp | 2 +- src/V3Clock.cpp | 38 +-- src/V3Config.cpp | 10 +- src/V3Const.cpp | 573 +++++++++++++++---------------- src/V3Coverage.cpp | 20 +- src/V3Dead.cpp | 2 +- src/V3Delayed.cpp | 8 +- src/V3DepthBlock.cpp | 8 +- src/V3Descope.cpp | 2 +- src/V3EmitCBase.cpp | 4 +- src/V3EmitCConstInit.h | 2 +- src/V3EmitCFunc.cpp | 43 +-- src/V3EmitCFunc.h | 38 +-- src/V3EmitCImp.cpp | 32 +- src/V3EmitCMake.cpp | 4 +- src/V3EmitCModel.cpp | 6 +- src/V3EmitCSyms.cpp | 52 +-- src/V3EmitMk.cpp | 2 +- src/V3EmitV.cpp | 8 +- src/V3EmitXml.cpp | 8 +- src/V3Error.cpp | 4 +- src/V3Expand.cpp | 4 +- src/V3File.cpp | 10 +- src/V3File.h | 4 +- src/V3FileLine.cpp | 20 +- src/V3Gate.cpp | 52 +-- src/V3GenClk.cpp | 8 +- src/V3Graph.cpp | 4 +- src/V3GraphAcyc.cpp | 11 +- src/V3GraphAlg.cpp | 4 +- src/V3GraphAlg.h | 4 +- src/V3GraphPathChecker.cpp | 4 +- src/V3GraphStream.h | 18 +- src/V3GraphTest.cpp | 2 +- src/V3Hasher.cpp | 2 +- src/V3HierBlock.cpp | 9 +- src/V3HierBlock.h | 4 +- src/V3Inline.cpp | 4 +- src/V3Inst.cpp | 41 ++- src/V3InstrCount.cpp | 30 +- src/V3Life.cpp | 2 +- src/V3LifePost.cpp | 18 +- src/V3LinkCells.cpp | 4 +- src/V3LinkDot.cpp | 345 ++++++++++--------- src/V3LinkJump.cpp | 2 +- src/V3LinkLevel.cpp | 25 +- src/V3LinkParse.cpp | 61 ++-- src/V3LinkResolve.cpp | 12 +- src/V3MergeCond.cpp | 28 +- src/V3Name.cpp | 2 +- src/V3Number.cpp | 73 ++-- src/V3Number.h | 2 +- src/V3OptionParser.cpp | 4 +- src/V3OptionParser.h | 2 +- src/V3Options.cpp | 18 +- src/V3Order.cpp | 141 ++++---- src/V3OrderGraph.h | 18 +- src/V3Os.cpp | 2 +- src/V3Param.cpp | 42 +-- src/V3ParseImp.cpp | 15 +- src/V3ParseImp.h | 13 +- src/V3ParseSym.h | 14 +- src/V3Partition.cpp | 79 ++--- src/V3PreProc.cpp | 22 +- src/V3Premit.cpp | 13 +- src/V3ProtectLib.cpp | 2 +- src/V3Randomize.cpp | 4 +- src/V3Reloop.cpp | 24 +- src/V3Scope.cpp | 2 +- src/V3Scoreboard.h | 6 +- src/V3Simulate.h | 114 ++++--- src/V3Slice.cpp | 4 +- src/V3Split.cpp | 40 +-- src/V3SplitAs.cpp | 8 +- src/V3SplitVar.cpp | 60 ++-- src/V3Stats.cpp | 8 +- src/V3Stats.h | 8 +- src/V3StatsReport.cpp | 2 +- src/V3String.cpp | 12 +- src/V3Subst.cpp | 10 +- src/V3SymTable.h | 18 +- src/V3TSP.cpp | 44 +-- src/V3Table.cpp | 6 +- src/V3Task.cpp | 177 +++++----- src/V3Trace.cpp | 8 +- src/V3TraceDecl.cpp | 6 +- src/V3Tristate.cpp | 37 ++- src/V3Undriven.cpp | 20 +- src/V3Unknown.cpp | 46 +-- src/V3Unroll.cpp | 4 +- src/V3Unroll.h | 2 +- src/V3Width.cpp | 666 +++++++++++++++++++------------------ src/V3WidthCommit.h | 12 +- src/V3WidthSel.cpp | 41 +-- src/VlcBucket.h | 2 +- 110 files changed, 1917 insertions(+), 1836 deletions(-) diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 9d8901012..7316d1474 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -1445,7 +1445,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { if (const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->left()})->castVpiHandle(); - } else if (VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { + } else if (const VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->left()})->castVpiHandle(); } @@ -1458,7 +1458,7 @@ vpiHandle vpi_handle(PLI_INT32 type, vpiHandle object) { if (const VerilatedVpioVarBase* const vop = VerilatedVpioVarBase::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->right()})->castVpiHandle(); - } else if (VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { + } else if (const VerilatedVpioRange* const vop = VerilatedVpioRange::castp(object)) { if (VL_UNLIKELY(!vop->rangep())) return nullptr; return (new VerilatedVpioConst{vop->rangep()->right()})->castVpiHandle(); } @@ -1905,7 +1905,7 @@ void vpi_get_value(vpiHandle object, p_vpi_value valuep) { } else if (const VerilatedVpioParam* const vop = VerilatedVpioParam::castp(object)) { vl_get_value(vop->varp(), vop->varDatap(), valuep, vop->fullname()); return; - } else if (VerilatedVpioConst* const vop = VerilatedVpioConst::castp(object)) { + } else if (const VerilatedVpioConst* const vop = VerilatedVpioConst::castp(object)) { if (valuep->format == vpiIntVal) { valuep->value.integer = vop->num(); return; diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 6bf73461c..f50ecada3 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -50,8 +50,8 @@ public: enum VertexType : uint8_t { VT_BLOCK, VT_BRANCH, VT_OUTPUT }; private: - string m_name; // Only used for .dot file generation - VertexType m_type; // Vertex type (BLOCK/BRANCH/OUTPUT) + const string m_name; // Only used for .dot file generation + const VertexType m_type; // Vertex type (BLOCK/BRANCH/OUTPUT) string typestr() const { // " switch (m_type) { @@ -342,8 +342,8 @@ public: private: const CheckType m_check; // Combo logic or other - AstNode* const m_alwaysp; // Always we're under - AstNode* m_assignp = nullptr; // In assign + const AstNode* const m_alwaysp; // Always we're under + const AstNode* m_assignp = nullptr; // In assign // VISITORS virtual void visit(AstAssignDly* nodep) override { if (m_check != CT_SEQ) { @@ -438,7 +438,7 @@ private: virtual void visit(AstInitial* nodep) override { // Relink to IACTIVE, unless already under it UINFO(4, " INITIAL " << nodep << endl); - ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; + const ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; AstActive* const wantactivep = m_namer.getIActive(nodep->fileline()); nodep->unlinkFrBack(); wantactivep->addStmtsp(nodep); @@ -471,7 +471,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; } - ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; + const ActiveDlyVisitor dlyvisitor{nodep, ActiveDlyVisitor::CT_INITIAL}; if (!m_scopeFinalp) { m_scopeFinalp = new AstCFunc( nodep->fileline(), "_final_" + m_namer.scopep()->nameDotless(), m_namer.scopep()); @@ -540,7 +540,7 @@ private: // Warn and/or convert any delayed assignments if (combo && !sequent) { - ActiveLatchCheckVisitor latchvisitor{nodep, kwd}; + const ActiveLatchCheckVisitor latchvisitor{nodep, kwd}; if (kwd == VAlwaysKwd::ALWAYS_LATCH) { ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_LATCH}; } else { diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index db87a0b10..9bb03a37b 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -34,7 +34,7 @@ private: // STATE AstNodeModule* m_modp = nullptr; // Last module - AstBegin* m_beginp = nullptr; // Last begin + const AstBegin* m_beginp = nullptr; // Last begin unsigned m_monitorNum = 0; // Global $monitor numbering (not per module) AstVar* m_monitorNumVarp = nullptr; // $monitor number variable AstVar* m_monitorOffVarp = nullptr; // $monitoroff variable diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 56e9740a2..05d2f99cf 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -777,14 +777,14 @@ void AstNode::deleteTree() { #ifdef VL_LEAK_CHECKS void* AstNode::operator new(size_t size) { // Optimization note: Aligning to cache line is a loss, due to lost packing - AstNode* const objp = static_cast(::operator new(size)); + const AstNode* const objp = static_cast(::operator new(size)); V3Broken::addNewed(objp); return objp; } void AstNode::operator delete(void* objp, size_t size) { if (!objp) return; - AstNode* const nodep = static_cast(objp); + const AstNode* const nodep = static_cast(objp); V3Broken::deleted(nodep); ::operator delete(objp); } @@ -995,7 +995,7 @@ void AstNode::checkTreeIterList(AstNode* backp) { // private: Check a (possible) list of nodes, this is always the head of the list // Audited to make sure this is never nullptr AstNode* const headp = this; - AstNode* tailp = this; + const AstNode* tailp = this; for (AstNode* nodep = headp; nodep; nodep = nodep->nextp()) { nodep->checkTreeIter(backp); UASSERT_OBJ(headp == this || !nextp(), this, diff --git a/src/V3Ast.h b/src/V3Ast.h index 25807aecf..873ea632e 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1008,7 +1008,7 @@ public: // MEMBERS void init(int hi, int lo, bool littleEndian) { if (lo > hi) { - int t = hi; + const int t = hi; hi = lo; lo = t; } @@ -1077,11 +1077,11 @@ inline std::ostream& operator<<(std::ostream& os, const VUseType& rhs) { class VBasicTypeKey final { public: - int m_width; // From AstNodeDType: Bit width of operation - int m_widthMin; // From AstNodeDType: If unsized, bitwidth of minimum implementation - VSigning m_numeric; // From AstNodeDType: Node is signed - AstBasicDTypeKwd m_keyword; // From AstBasicDType: What keyword created basic type - VNumRange m_nrange; // From AstBasicDType: Numeric msb/lsb (if non-opaque keyword) + const int m_width; // From AstNodeDType: Bit width of operation + const int m_widthMin; // From AstNodeDType: If unsized, bitwidth of minimum implementation + const VSigning m_numeric; // From AstNodeDType: Node is signed + const AstBasicDTypeKwd m_keyword; // From AstBasicDType: What keyword created basic type + const VNumRange m_nrange; // From AstBasicDType: Numeric msb/lsb (if non-opaque keyword) bool operator==(const VBasicTypeKey& rhs) const { return m_width == rhs.m_width && m_widthMin == rhs.m_widthMin && m_numeric == rhs.m_numeric && m_keyword == rhs.m_keyword && m_nrange == rhs.m_nrange; @@ -2612,12 +2612,12 @@ public: if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstNodeArrayDType* asamep = static_cast(samep); + const AstNodeArrayDType* const asamep = static_cast(samep); return (hi() == asamep->hi() && subDTypep() == asamep->subDTypep() && rangenp()->sameTree(asamep->rangenp())); } // HashedDT doesn't recurse, so need to check children virtual bool similarDType(AstNodeDType* samep) const override { - const AstNodeArrayDType* asamep = static_cast(samep); + const AstNodeArrayDType* const asamep = static_cast(samep); return (asamep && type() == samep->type() && hi() == asamep->hi() && rangenp()->sameTree(asamep->rangenp()) && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp())); @@ -2705,7 +2705,7 @@ public: virtual const char* broken() const override; virtual int instrCount() const override { return INSTR_COUNT_CALL; } virtual bool same(const AstNode* samep) const override { - const AstNodeCCall* asamep = static_cast(samep); + const AstNodeCCall* const asamep = static_cast(samep); return (funcp() == asamep->funcp() && argTypes() == asamep->argTypes()); } AstNode* exprsp() const { return op2p(); } // op2 = expressions to print @@ -2901,7 +2901,7 @@ class AstNodeModule VL_NOT_FINAL : public AstNode { // excluding $unit package stuff private: string m_name; // Name of the module - string m_origName; // Name of the module, ignoring name() changes, for dot lookup + const string m_origName; // Name of the module, ignoring name() changes, for dot lookup string m_hierName; // Hierarchical name for errors, etc. bool m_modPublic : 1; // Module has public references bool m_modTrace : 1; // Tracing this module diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index ddcaead8a..9235cb14e 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -226,11 +226,11 @@ AstConst* AstConst::parseParamLiteral(FileLine* fl, const string& literal) { bool success = false; if (literal[0] == '"') { // This is a string - string v = literal.substr(1, literal.find('"', 1) - 1); + const string v = literal.substr(1, literal.find('"', 1) - 1); return new AstConst(fl, AstConst::VerilogStringLiteral(), v); } else if (literal.find_first_of(".eEpP") != string::npos) { // This may be a real - double v = VString::parseDouble(literal, &success); + const double v = VString::parseDouble(literal, &success); if (success) return new AstConst(fl, AstConst::RealDouble(), v); } if (!success) { @@ -242,7 +242,7 @@ AstConst* AstConst::parseParamLiteral(FileLine* fl, const string& literal) { // the string after the number, this is invalid C and we try // the Verilog literal parser. char* endp; - int v = strtol(literal.c_str(), &endp, 0); + const int v = strtol(literal.c_str(), &endp, 0); if ((v != 0) && (endp[0] == 0)) { // C literal return new AstConst(fl, AstConst::Signed32(), v); } else { // Try a Verilog literal (fatals if not) @@ -475,7 +475,7 @@ public: string convert(const AstVar* varp) const { if (varp->isDpiOpenArray()) { return openArray(varp); - } else if (const AstBasicDType* basicp = varp->basicp()) { + } else if (const AstBasicDType* const basicp = varp->basicp()) { if (basicp->isDpiBitVec() || basicp->isDpiLogicVec()) { return bitLogicVector(varp, basicp->isDpiBitVec()); } else { @@ -515,9 +515,9 @@ string AstVar::dpiArgType(bool named, bool forReturn) const { string AstVar::dpiTmpVarType(const string& varName) const { class converter final : public dpiTypesToStringConverter { - string m_name; + const string m_name; string arraySuffix(const AstVar* varp, size_t n) const { - if (AstUnpackArrayDType* unpackp + if (AstUnpackArrayDType* const unpackp = VN_CAST(varp->dtypep()->skipRefp(), UnpackArrayDType)) { // Convert multi dimensional unpacked array to 1D array if (n == 0) n = 1; @@ -583,7 +583,7 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) { // See if this is a SC assignment; if so return that type // Historically sc variables are identified by a variable // attribute. TODO it would better be a data type attribute. - if (AstVar* anodep = VN_CAST(nodep, Var)) { + if (AstVar* const anodep = VN_CAST(nodep, Var)) { if (anodep->isSc()) { return anodep; } else { @@ -642,29 +642,29 @@ AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound) const { // Legacy compound argument currently just passed through and unused CTypeRecursed info; - const AstNodeDType* dtypep = this->skipRefp(); - if (const auto* adtypep = VN_CAST(dtypep, AssocArrayDType)) { + const AstNodeDType* const dtypep = this->skipRefp(); + if (const auto* const adtypep = VN_CAST(dtypep, AssocArrayDType)) { const CTypeRecursed key = adtypep->keyDTypep()->cTypeRecurse(true); const CTypeRecursed val = adtypep->subDTypep()->cTypeRecurse(true); info.m_type = "VlAssocArray<" + key.m_type + ", " + val.m_type + ">"; - } else if (const auto* adtypep = VN_CAST(dtypep, DynArrayDType)) { + } else if (const auto* const adtypep = VN_CAST(dtypep, DynArrayDType)) { const CTypeRecursed sub = adtypep->subDTypep()->cTypeRecurse(true); info.m_type = "VlQueue<" + sub.m_type + ">"; - } else if (const auto* adtypep = VN_CAST(dtypep, QueueDType)) { + } else if (const auto* const adtypep = VN_CAST(dtypep, QueueDType)) { const CTypeRecursed sub = adtypep->subDTypep()->cTypeRecurse(true); info.m_type = "VlQueue<" + sub.m_type; // + 1 below as VlQueue uses 0 to mean unlimited, 1 to mean size() max is 1 if (adtypep->boundp()) info.m_type += ", " + cvtToStr(adtypep->boundConst() + 1); info.m_type += ">"; - } else if (const auto* adtypep = VN_CAST(dtypep, ClassRefDType)) { + } else if (const auto* const adtypep = VN_CAST(dtypep, ClassRefDType)) { info.m_type = "VlClassRef<" + EmitCBaseVisitor::prefixNameProtect(adtypep) + ">"; - } else if (const auto* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { + } else if (const auto* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) { if (adtypep->isCompound()) compound = true; const CTypeRecursed sub = adtypep->subDTypep()->cTypeRecurse(compound); info.m_type = "VlUnpacked<" + sub.m_type; info.m_type += ", " + cvtToStr(adtypep->declRange().elements()); info.m_type += ">"; - } else if (const AstBasicDType* bdtypep = dtypep->basicp()) { + } else if (const AstBasicDType* const bdtypep = dtypep->basicp()) { // We don't print msb()/lsb() as multidim packed would require recursion, // and may confuse users as C++ data is stored always with bit 0 used const string bitvec = (!bdtypep->isOpaque() && !v3Global.opt.protectIds()) @@ -704,7 +704,7 @@ uint32_t AstNodeDType::arrayUnpackedElements() { uint32_t entries = 1; for (AstNodeDType* dtypep = this; dtypep;) { dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node - if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { + if (AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) { entries *= adtypep->elementsConst(); dtypep = adtypep->subDTypep(); } else { @@ -721,7 +721,7 @@ std::pair AstNodeDType::dimensions(bool includeBasic) { uint32_t unpacked = 0; for (AstNodeDType* dtypep = this; dtypep;) { dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node - if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) { + if (const AstNodeArrayDType* const adtypep = VN_CAST(dtypep, NodeArrayDType)) { if (VN_IS(adtypep, PackArrayDType)) { ++packed; } else { @@ -729,11 +729,11 @@ std::pair AstNodeDType::dimensions(bool includeBasic) { } dtypep = adtypep->subDTypep(); continue; - } else if (const AstQueueDType* qdtypep = VN_CAST(dtypep, QueueDType)) { + } else if (const AstQueueDType* const qdtypep = VN_CAST(dtypep, QueueDType)) { unpacked++; dtypep = qdtypep->subDTypep(); continue; - } else if (const AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) { + } else if (const AstBasicDType* const adtypep = VN_CAST(dtypep, BasicDType)) { if (includeBasic && (adtypep->isRanged() || adtypep->isString())) packed++; } else if (VN_IS(dtypep, StructDType)) { packed++; @@ -745,7 +745,7 @@ std::pair AstNodeDType::dimensions(bool includeBasic) { int AstNodeDType::widthPow2() const { // I.e. width 30 returns 32, width 32 returns 32. - uint32_t width = this->width(); + const uint32_t width = this->width(); for (int p2 = 30; p2 >= 0; p2--) { if (width > (1UL << p2)) return (1UL << (p2 + 1)); } @@ -753,11 +753,11 @@ int AstNodeDType::widthPow2() const { } bool AstNodeDType::isLiteralType() const { - if (auto* const dtypep = VN_CAST(skipRefp(), BasicDType)) { + if (const auto* const dtypep = VN_CAST(skipRefp(), BasicDType)) { return dtypep->keyword().isLiteralType(); - } else if (auto* const dtypep = VN_CAST(skipRefp(), UnpackArrayDType)) { + } else if (const auto* const dtypep = VN_CAST(skipRefp(), UnpackArrayDType)) { return dtypep->basicp()->isLiteralType(); - } else if (auto* const dtypep = VN_CAST(skipRefp(), StructDType)) { + } else if (const auto* const dtypep = VN_CAST(skipRefp(), StructDType)) { // Currently all structs are packed, later this can be expanded to // 'forall members _.isLiteralType()' return dtypep->packed(); @@ -894,7 +894,7 @@ void AstTypeTable::clearCache() { m_detailedMap.clear(); // Clear generic()'s so dead detection will work for (AstNode* nodep = typesp(); nodep; nodep = nodep->nextp()) { - if (AstBasicDType* bdtypep = VN_CAST(nodep, BasicDType)) bdtypep->generic(false); + if (AstBasicDType* const bdtypep = VN_CAST(nodep, BasicDType)) bdtypep->generic(false); } } @@ -902,7 +902,7 @@ void AstTypeTable::repairCache() { // After we mass-change widthMin in V3WidthCommit, we need to correct the table. clearCache(); for (AstNode* nodep = typesp(); nodep; nodep = nodep->nextp()) { - if (AstBasicDType* bdtypep = VN_CAST(nodep, BasicDType)) { + if (AstBasicDType* const bdtypep = VN_CAST(nodep, BasicDType)) { (void)findInsertSameDType(bdtypep); } } @@ -910,7 +910,7 @@ void AstTypeTable::repairCache() { AstEmptyQueueDType* AstTypeTable::findEmptyQueueDType(FileLine* fl) { if (VL_UNLIKELY(!m_emptyQueuep)) { - AstEmptyQueueDType* newp = new AstEmptyQueueDType{fl}; + AstEmptyQueueDType* const newp = new AstEmptyQueueDType{fl}; addTypesp(newp); m_emptyQueuep = newp; } @@ -919,7 +919,7 @@ AstEmptyQueueDType* AstTypeTable::findEmptyQueueDType(FileLine* fl) { AstVoidDType* AstTypeTable::findVoidDType(FileLine* fl) { if (VL_UNLIKELY(!m_voidp)) { - AstVoidDType* newp = new AstVoidDType{fl}; + AstVoidDType* const newp = new AstVoidDType{fl}; addTypesp(newp); m_voidp = newp; } @@ -928,7 +928,7 @@ AstVoidDType* AstTypeTable::findVoidDType(FileLine* fl) { AstQueueDType* AstTypeTable::findQueueIndexDType(FileLine* fl) { if (VL_UNLIKELY(!m_queueIndexp)) { - AstQueueDType* newp = new AstQueueDType(fl, AstNode::findUInt32DType(), nullptr); + AstQueueDType* const newp = new AstQueueDType(fl, AstNode::findUInt32DType(), nullptr); addTypesp(newp); m_queueIndexp = newp; } @@ -938,11 +938,11 @@ AstQueueDType* AstTypeTable::findQueueIndexDType(FileLine* fl) { AstBasicDType* AstTypeTable::findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd) { if (m_basicps[kwd]) return m_basicps[kwd]; // - AstBasicDType* new1p = new AstBasicDType(fl, kwd); + AstBasicDType* const new1p = new AstBasicDType(fl, kwd); // Because the detailed map doesn't update this map, // check the detailed map for this same node // Also adds this new node to the detailed map - AstBasicDType* newp = findInsertSameDType(new1p); + AstBasicDType* const newp = findInsertSameDType(new1p); if (newp != new1p) { VL_DO_DANGLING(new1p->deleteTree(), new1p); } else { @@ -955,8 +955,8 @@ AstBasicDType* AstTypeTable::findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd) AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, int width, int widthMin, VSigning numeric) { - AstBasicDType* new1p = new AstBasicDType(fl, kwd, numeric, width, widthMin); - AstBasicDType* newp = findInsertSameDType(new1p); + AstBasicDType* const new1p = new AstBasicDType(fl, kwd, numeric, width, widthMin); + AstBasicDType* const newp = findInsertSameDType(new1p); if (newp != new1p) { VL_DO_DANGLING(new1p->deleteTree(), new1p); } else { @@ -968,8 +968,8 @@ AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kw AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, const VNumRange& range, int widthMin, VSigning numeric) { - AstBasicDType* new1p = new AstBasicDType(fl, kwd, numeric, range, widthMin); - AstBasicDType* newp = findInsertSameDType(new1p); + AstBasicDType* const new1p = new AstBasicDType(fl, kwd, numeric, range, widthMin); + AstBasicDType* const newp = findInsertSameDType(new1p); if (newp != new1p) { VL_DO_DANGLING(new1p->deleteTree(), new1p); } else { @@ -979,8 +979,8 @@ AstBasicDType* AstTypeTable::findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kw } AstBasicDType* AstTypeTable::findInsertSameDType(AstBasicDType* nodep) { - VBasicTypeKey key(nodep->width(), nodep->widthMin(), nodep->numeric(), nodep->keyword(), - nodep->nrange()); + const VBasicTypeKey key(nodep->width(), nodep->widthMin(), nodep->numeric(), nodep->keyword(), + nodep->nrange()); DetailedMap& mapr = m_detailedMap; const auto it = mapr.find(key); if (it != mapr.end()) return it->second; @@ -1037,14 +1037,14 @@ static bool sameInit(const AstInitArray* ap, const AstInitArray* bp) { } AstVarScope* AstConstPool::findTable(AstInitArray* initp) { - AstNode* const defaultp = initp->defaultp(); + const AstNode* const defaultp = initp->defaultp(); // Verify initializer is well formed UASSERT_OBJ(VN_IS(initp->dtypep(), UnpackArrayDType), initp, "Const pool table must have AstUnpackArrayDType dtype"); UASSERT_OBJ(!defaultp || VN_IS(defaultp, Const), initp, "Const pool table default must be Const"); for (AstNode* nodep = initp->initsp(); nodep; nodep = nodep->nextp()) { - AstNode* const valuep = VN_AS(nodep, InitItem)->valuep(); + const AstNode* const valuep = VN_AS(nodep, InitItem)->valuep(); UASSERT_OBJ(VN_IS(valuep, Const), valuep, "Const pool table entry must be Const"); } // Try to find an existing table with the same content @@ -1192,7 +1192,7 @@ void AstNode::dump(std::ostream& str) const { } else { str << " @dt=" << nodeAddr(dtypep()) << "@"; } - if (AstNodeDType* dtp = dtypep()) dtp->dumpSmall(str); + if (AstNodeDType* const dtp = dtypep()) dtp->dumpSmall(str); } else { // V3Broken will throw an error if (dtypep()) str << " %Error-dtype-exp=null,got=" << nodeAddr(dtypep()); } @@ -1285,7 +1285,7 @@ void AstClass::dump(std::ostream& str) const { if (isVirtual()) str << " [VIRT]"; } AstClass* AstClassExtends::classp() const { - AstClassRefDType* refp = VN_CAST(dtypep(), ClassRefDType); + const AstClassRefDType* refp = VN_CAST(dtypep(), ClassRefDType); if (VL_UNLIKELY(!refp)) { // LinkDot uses this for 'super.' refp = VN_AS(childDTypep(), ClassRefDType); } @@ -1474,7 +1474,7 @@ void AstNodeUOrStructDType::dump(std::ostream& str) const { void AstNodeDType::dump(std::ostream& str) const { this->AstNode::dump(str); if (generic()) str << " [GENERIC]"; - if (AstNodeDType* dtp = virtRefDTypep()) { + if (AstNodeDType* const dtp = virtRefDTypep()) { str << " refdt=" << nodeAddr(dtp); dtp->dumpSmall(str); } @@ -1488,7 +1488,7 @@ void AstNodeDType::dumpSmall(std::ostream& str) const { } void AstNodeArrayDType::dumpSmall(std::ostream& str) const { this->AstNodeDType::dumpSmall(str); - if (auto* adtypep = VN_CAST(this, UnpackArrayDType)) { + if (auto* const adtypep = VN_CAST(this, UnpackArrayDType)) { // uc = packed compound object, u = unpacked POD str << (adtypep->isCompound() ? "uc" : "u"); } else { @@ -1524,7 +1524,7 @@ std::vector AstUnpackArrayDType::unpackDimensions() { std::vector dims; for (AstUnpackArrayDType* unpackp = this; unpackp;) { dims.push_back(unpackp); - if (AstNodeDType* subp = unpackp->subDTypep()) { + if (AstNodeDType* const subp = unpackp->subDTypep()) { unpackp = VN_CAST(subp, UnpackArrayDType); } else { unpackp = nullptr; @@ -1581,7 +1581,7 @@ void AstMTaskBody::dump(std::ostream& str) const { void AstTypeTable::dump(std::ostream& str) const { this->AstNode::dump(str); for (int i = 0; i < static_cast(AstBasicDTypeKwd::_ENUM_MAX); ++i) { - if (AstBasicDType* subnodep = m_basicps[i]) { + if (AstBasicDType* const subnodep = m_basicps[i]) { str << '\n'; // Newline from caller, so newline first str << "\t\t" << std::setw(8) << AstBasicDTypeKwd(i).ascii(); str << " -> "; @@ -1591,7 +1591,7 @@ void AstTypeTable::dump(std::ostream& str) const { { const DetailedMap& mapr = m_detailedMap; for (const auto& itr : mapr) { - AstBasicDType* dtypep = itr.second; + AstBasicDType* const dtypep = itr.second; str << '\n'; // Newline from caller, so newline first str << "\t\tdetailed -> "; dtypep->dump(str); diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 5c60f657c..b116d72c9 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -172,7 +172,7 @@ public: virtual string emitC() override { V3ERROR_NA_RETURN(""); } virtual bool cleanOut() const override { return true; } virtual bool same(const AstNode* samep) const override { - const AstConst* sp = static_cast(samep); + const AstConst* const sp = static_cast(samep); return num().isCaseEq(sp->num()); } virtual int instrCount() const override { return widthInstrs(); } @@ -216,21 +216,21 @@ public: AstNode* leftp() const { return op2p(); } AstNode* rightp() const { return op3p(); } int leftConst() const { - AstConst* constp = VN_CAST(leftp(), Const); + AstConst* const constp = VN_CAST(leftp(), Const); return (constp ? constp->toSInt() : 0); } int rightConst() const { - AstConst* constp = VN_CAST(rightp(), Const); + AstConst* const constp = VN_CAST(rightp(), Const); return (constp ? constp->toSInt() : 0); } int hiConst() const { - int l = leftConst(); - int r = rightConst(); + const int l = leftConst(); + const int r = rightConst(); return l > r ? l : r; } int loConst() const { - int l = leftConst(); - int r = rightConst(); + const int l = leftConst(); + const int r = rightConst(); return l > r ? r : l; } int elementsConst() const { return hiConst() - loConst() + 1; } @@ -375,7 +375,7 @@ class AstParamTypeDType final : public AstNodeDType { // Parents: MODULE // A parameter type statement; much like a var or typedef private: - AstVarType m_varType; // Type of variable (for localparam vs. param) + const AstVarType m_varType; // Type of variable (for localparam vs. param) string m_name; // Name of variable public: AstParamTypeDType(FileLine* fl, AstVarType type, const string& name, VFlagChildDType, @@ -401,7 +401,7 @@ public: } virtual AstNodeDType* skipRefToEnump() const override { return subDTypep()->skipRefToEnump(); } virtual bool similarDType(AstNodeDType* samep) const override { - const AstParamTypeDType* sp = static_cast(samep); + const AstParamTypeDType* const sp = static_cast(samep); return type() == samep->type() && sp && this->subDTypep()->skipRefp()->similarDType(sp->subDTypep()->skipRefp()); } @@ -494,7 +494,7 @@ public: ASTNODE_NODE_FUNCS(DefImplicitDType) int uniqueNum() const { return m_uniqueNum; } virtual bool same(const AstNode* samep) const override { - const AstDefImplicitDType* sp = static_cast(samep); + const AstDefImplicitDType* const sp = static_cast(samep); return uniqueNum() == sp->uniqueNum(); } virtual bool similarDType(AstNodeDType* samep) const override { @@ -551,13 +551,13 @@ public: if (m_keyDTypep && m_keyDTypep->clonep()) m_keyDTypep = m_keyDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstAssocArrayDType* asamep = static_cast(samep); + const AstAssocArrayDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; if (!asamep->keyDTypep()) return false; return (subDTypep() == asamep->subDTypep() && keyDTypep() == asamep->keyDTypep()); } virtual bool similarDType(AstNodeDType* samep) const override { - const AstAssocArrayDType* asamep = static_cast(samep); + const AstAssocArrayDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } @@ -650,12 +650,12 @@ public: if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstAssocArrayDType* asamep = static_cast(samep); + const AstAssocArrayDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; return subDTypep() == asamep->subDTypep(); } virtual bool similarDType(AstNodeDType* samep) const override { - const AstAssocArrayDType* asamep = static_cast(samep); + const AstAssocArrayDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } @@ -736,7 +736,7 @@ public: ASTNODE_NODE_FUNCS(UnpackArrayDType) virtual string prettyDTypeName() const override; virtual bool same(const AstNode* samep) const override { - const AstUnpackArrayDType* sp = static_cast(samep); + const AstUnpackArrayDType* const sp = static_cast(samep); return m_isCompound == sp->m_isCompound; } // Outer dimension comes first. The first element is this node. @@ -767,12 +767,12 @@ public: if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstNodeArrayDType* asamep = static_cast(samep); + const AstNodeArrayDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; return (subDTypep() == asamep->subDTypep()); } virtual bool similarDType(AstNodeDType* samep) const override { - const AstNodeArrayDType* asamep = static_cast(samep); + const AstNodeArrayDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } @@ -876,7 +876,7 @@ public: virtual void dump(std::ostream& str) const override; // width/widthMin/numeric compared elsewhere virtual bool same(const AstNode* samep) const override { - const AstBasicDType* sp = static_cast(samep); + const AstBasicDType* const sp = static_cast(samep); return m == sp->m; } virtual bool similarDType(AstNodeDType* samep) const override { @@ -973,7 +973,7 @@ public: if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstConstDType* sp = static_cast(samep); + const AstConstDType* const sp = static_cast(samep); return (m_refDTypep == sp->m_refDTypep); } virtual bool similarDType(AstNodeDType* samep) const override { @@ -1025,7 +1025,7 @@ public: if (m_classp && m_classp->clonep()) m_classp = m_classp->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstClassRefDType* asamep = static_cast(samep); + const AstClassRefDType* const asamep = static_cast(samep); return (m_classp == asamep->m_classp && m_classOrPackagep == asamep->m_classOrPackagep); } virtual bool similarDType(AstNodeDType* samep) const override { @@ -1134,12 +1134,12 @@ public: if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstQueueDType* asamep = static_cast(samep); + const AstQueueDType* const asamep = static_cast(samep); if (!asamep->subDTypep()) return false; return (subDTypep() == asamep->subDTypep()); } virtual bool similarDType(AstNodeDType* samep) const override { - const AstQueueDType* asamep = static_cast(samep); + const AstQueueDType* const asamep = static_cast(samep); return type() == samep->type() && asamep->subDTypep() && subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()); } @@ -1156,7 +1156,7 @@ public: AstNode* boundp() const { return op2p(); } // op2 = Bound, nullptr = none void boundp(AstNode* nodep) { setNOp2p(nodep); } int boundConst() const { - AstConst* constp = VN_CAST(boundp(), Const); + AstConst* const constp = VN_CAST(boundp(), Const); return (constp ? constp->toSInt() : 0); } virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; } @@ -1210,7 +1210,7 @@ public: if (m_refDTypep && m_refDTypep->clonep()) m_refDTypep = m_refDTypep->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstRefDType* asamep = static_cast(samep); + const AstRefDType* const asamep = static_cast(samep); return (m_typedefp == asamep->m_typedefp && m_refDTypep == asamep->m_refDTypep && m_name == asamep->m_name && m_classOrPackagep == asamep->m_classOrPackagep); } @@ -1458,7 +1458,7 @@ public: if (m_itemp->clonep()) m_itemp = m_itemp->clonep(); } virtual bool same(const AstNode* samep) const override { - const AstEnumItemRef* sp = static_cast(samep); + const AstEnumItemRef* const sp = static_cast(samep); return itemp() == sp->itemp(); } AstEnumItem* itemp() const { return m_itemp; } @@ -1498,7 +1498,7 @@ public: } int uniqueNum() const { return m_uniqueNum; } virtual bool same(const AstNode* samep) const override { - const AstEnumDType* sp = static_cast(samep); + const AstEnumDType* const sp = static_cast(samep); return uniqueNum() == sp->uniqueNum(); } virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; } @@ -2572,7 +2572,7 @@ public: class AstModule final : public AstNodeModule { // A module declaration private: - bool m_isProgram; // Module represents a program + const bool m_isProgram; // Module represents a program public: AstModule(FileLine* fl, const string& name, bool program = false) : ASTGEN_SUPER_Module(fl, name) @@ -2884,7 +2884,8 @@ class AstCellInline final : public AstNode { // Children: When 2 levels inlined, other CellInline under this private: string m_name; // Cell name, possibly {a}__DOT__{b}... - string m_origModName; // Original name of the module, ignoring name() changes, for dot lookup + const string + m_origModName; // Original name of the module, ignoring name() changes, for dot lookup AstScope* m_scopep = nullptr; // The scope that the cell is inlined into VTimescale m_timeunit; // Parent module time unit public: @@ -3022,7 +3023,7 @@ public: virtual void dump(std::ostream& str) const override; virtual string name() const override { return m_name; } // * = Var name virtual bool same(const AstNode* samep) const override { - const AstParseRef* asamep = static_cast(samep); + const AstParseRef* const asamep = static_cast(samep); return (expect() == asamep->expect() && m_name == asamep->m_name); } virtual void name(const string& name) override { m_name = name; } @@ -3075,7 +3076,7 @@ public: class AstDot final : public AstNode { // A dot separating paths in an AstVarXRef, AstFuncRef or AstTaskRef // These are eliminated in the link stage - bool m_colon; // Is a "::" instead of a "." (lhs must be package/class) + const bool m_colon; // Is a "::" instead of a "." (lhs must be package/class) public: AstDot(FileLine* fl, bool colon, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_Dot(fl) @@ -3343,7 +3344,7 @@ public: }; class AstAlways final : public AstNodeProcedure { - VAlwaysKwd m_keyword; + const VAlwaysKwd m_keyword; public: AstAlways(FileLine* fl, VAlwaysKwd keyword, AstSenTree* sensesp, AstNode* bodysp) @@ -3447,10 +3448,10 @@ public: } virtual bool brokeLhsMustBeLvalue() const override { return true; } AstAlways* convertToAlways() { - AstNode* lhs1p = lhsp()->unlinkFrBack(); - AstNode* rhs1p = rhsp()->unlinkFrBack(); - AstAlways* newp = new AstAlways(fileline(), VAlwaysKwd::ALWAYS, nullptr, - new AstAssign(fileline(), lhs1p, rhs1p)); + AstNode* const lhs1p = lhsp()->unlinkFrBack(); + AstNode* const rhs1p = rhsp()->unlinkFrBack(); + AstAlways* const newp = new AstAlways(fileline(), VAlwaysKwd::ALWAYS, nullptr, + new AstAssign(fileline(), lhs1p, rhs1p)); replaceWith(newp); // User expected to then deleteTree(); return newp; } @@ -3552,8 +3553,8 @@ class AstComment final : public AstNodeStmt { // Parents: {statement list} // Children: none private: - bool m_showAt; // Show "at " - string m_name; // Text of comment + const bool m_showAt; // Show "at " + const string m_name; // Text of comment public: AstComment(FileLine* fl, const string& name, bool showAt = false) : ASTGEN_SUPER_Comment(fl) @@ -3641,7 +3642,7 @@ public: void hier(const string& flag) { m_hier = flag; } void comment(const string& flag) { m_text = flag; } virtual bool same(const AstNode* samep) const override { - const AstCoverDecl* asamep = static_cast(samep); + const AstCoverDecl* const asamep = static_cast(samep); return (fileline() == asamep->fileline() && linescov() == asamep->linescov() && hier() == asamep->hier() && comment() == asamep->comment()); } @@ -3798,9 +3799,9 @@ class AstSFormatF final : public AstNode { // Convert format to string, generally under an AstDisplay or AstSFormat // Also used as "real" function for /*verilator sformat*/ functions string m_text; - bool m_hidden; // Under display, etc + const bool m_hidden; // Under display, etc bool m_hasFormat; // Has format code - char m_missingArgChar; // Format code when argument without format, 'h'/'o'/'b' + const char m_missingArgChar; // Format code when argument without format, 'h'/'o'/'b' VTimescale m_timeunit; // Parent module time unit public: class NoFormat {}; @@ -3908,7 +3909,7 @@ class AstDumpCtl final : public AstNodeStmt { // $dumpon etc // Parents: expr // Child: expr based on type of control statement - VDumpCtlType m_ctlType; // Type of operation + const VDumpCtlType m_ctlType; // Type of operation public: AstDumpCtl(FileLine* fl, VDumpCtlType ctlType, AstNode* exprp = nullptr) : ASTGEN_SUPER_DumpCtl(fl) @@ -4305,7 +4306,7 @@ public: class AstNodeReadWriteMem VL_NOT_FINAL : public AstNodeStmt { private: - bool m_isHex; // readmemh, not readmemb + const bool m_isHex; // readmemh, not readmemb public: AstNodeReadWriteMem(AstType t, FileLine* fl, bool hex, AstNode* filenamep, AstNode* memp, AstNode* lsbp, AstNode* msbp) @@ -4353,7 +4354,7 @@ public: }; class AstMonitorOff final : public AstNodeStmt { - bool m_off; // Monitor off. Using 0=on allows faster init and comparison + const bool m_off; // Monitor off. Using 0=on allows faster init and comparison public: AstMonitorOff(FileLine* fl, bool off) @@ -4857,7 +4858,7 @@ class AstBegin final : public AstNodeBlock { // Children: statements private: bool m_generate; // Underneath a generate - bool m_implied; // Not inserted by user + const bool m_implied; // Not inserted by user public: // Node that simply puts name into the output stream AstBegin(FileLine* fl, const string& name, AstNode* stmtsp, bool generate = false, @@ -4994,7 +4995,7 @@ public: oldp = it->second->valuep(); it->second->valuep(newp); } else { - AstInitItem* itemp = new AstInitItem(fileline(), newp); + AstInitItem* const itemp = new AstInitItem(fileline(), newp); m_map.emplace(index, itemp); addOp2p(itemp); } @@ -5072,7 +5073,7 @@ public: class AstPragma final : public AstNode { private: - AstPragmaType m_pragType; // Type of pragma + const AstPragmaType m_pragType; // Type of pragma public: // Pragmas don't result in any output code, they're just flags that affect // other processing in verilator. @@ -5443,8 +5444,8 @@ class AstRand final : public AstNodeMath { // $random/$random(seed) or $urandom/$urandom(seed) // Return a random number, based upon width() private: - bool m_urandom = false; // $urandom vs $random - bool m_reset = false; // Random reset, versus always random + const bool m_urandom = false; // $urandom vs $random + const bool m_reset = false; // Random reset, versus always random public: class Reset {}; AstRand(FileLine* fl, Reset, AstNodeDType* dtp, bool reset) @@ -5642,7 +5643,7 @@ public: virtual string emitC() override { return "VL_REDXOR_%lq(%lW, %P, %li)"; } virtual bool cleanOut() const override { return false; } virtual bool cleanLhs() const override { - int w = lhsp()->width(); + const int w = lhsp()->width(); return (w != 1 && w != 2 && w != 4 && w != 8 && w != 16); } virtual bool sizeMattersLhs() const override { return false; } @@ -6527,7 +6528,7 @@ public: enum FmtType { ATOI = 10, ATOHEX = 16, ATOOCT = 8, ATOBIN = 2, ATOREAL = -1 }; private: - FmtType m_fmt; // Operation type + const FmtType m_fmt; // Operation type public: AstAtoN(FileLine* fl, AstNode* lhsp, FmtType fmt) : ASTGEN_SUPER_AtoN(fl, lhsp) @@ -7965,7 +7966,7 @@ public: AstReplicate(FileLine* fl, AstNode* lhsp, AstNode* rhsp) : ASTGEN_SUPER_Replicate(fl, lhsp, rhsp) { if (lhsp) { - if (const AstConst* constp = VN_CAST(rhsp, Const)) { + if (const AstConst* const constp = VN_CAST(rhsp, Const)) { dtypeSetLogicSized(lhsp->width() * constp->toUInt(), VSigning::UNSIGNED); } } @@ -8255,7 +8256,7 @@ public: class AstCompareNN final : public AstNodeBiop { // Verilog str.compare() and str.icompare() private: - bool m_ignoreCase; // True for str.icompare() + const bool m_ignoreCase; // True for str.icompare() public: AstCompareNN(FileLine* fl, AstNode* lhsp, AstNode* rhsp, bool ignoreCase) : ASTGEN_SUPER_CompareNN(fl, lhsp, rhsp) @@ -8510,7 +8511,7 @@ class AstNodeCoverOrAssert VL_NOT_FINAL : public AstNodeStmt { // Parents: {statement list} // Children: expression, report string private: - bool m_immediate; // Immediate assertion/cover + const bool m_immediate; // Immediate assertion/cover string m_name; // Name to report public: AstNodeCoverOrAssert(AstType t, FileLine* fl, AstNode* propp, AstNode* passsp, bool immediate, @@ -8816,7 +8817,7 @@ public: virtual bool maybePointedTo() const override { return true; } virtual void dump(std::ostream& str = std::cout) const override; virtual bool same(const AstNode* samep) const override { - const AstCFunc* asamep = static_cast(samep); + const AstCFunc* const asamep = static_cast(samep); return ((isTrace() == asamep->isTrace()) && (rtnTypeVoid() == asamep->rtnTypeVoid()) && (argTypes() == asamep->argTypes()) && (ctorInits() == asamep->ctorInits()) && isLoose() == asamep->isLoose() @@ -8969,7 +8970,7 @@ public: class AstCMath final : public AstNodeMath { private: - bool m_cleanOut; + const bool m_cleanOut; bool m_pure; // Pure optimizable public: // Emit C textual math function (like AstUCFunc) diff --git a/src/V3AstUserAllocator.h b/src/V3AstUserAllocator.h index 637b6d2aa..896d19dfe 100644 --- a/src/V3AstUserAllocator.h +++ b/src/V3AstUserAllocator.h @@ -103,7 +103,7 @@ public: // Get a reference to the user data T_Data& operator()(const T_Node* nodep) { - T_Data* userp = getUserp(nodep); + T_Data* const userp = getUserp(nodep); UASSERT_OBJ(userp, nodep, "Missing User data on const AstNode"); return *userp; } diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 9ed6706e9..05ab4072c 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -61,7 +61,7 @@ private: // STATE BeginState* const m_statep; // Current global state AstNodeModule* m_modp = nullptr; // Current module - AstNodeFTask* m_ftaskp = nullptr; // Current function/task + const AstNodeFTask* m_ftaskp = nullptr; // Current function/task AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp string m_namedScope; // Name of begin blocks above us string m_unnamedScope; // Name of begin blocks, including unnamed blocks @@ -149,7 +149,7 @@ private: m_unnamedScope = dot(m_unnamedScope, ident); // Create CellInline for dotted var resolution if (!m_ftaskp) { - AstCellInline* inlinep = new AstCellInline( + AstCellInline* const inlinep = new AstCellInline( nodep->fileline(), m_unnamedScope, "__BEGIN__", m_modp->timeunit()); m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells } @@ -162,7 +162,7 @@ private: // Cleanup AstNode* addsp = nullptr; - if (AstNode* stmtsp = nodep->stmtsp()) { + if (AstNode* const stmtsp = nodep->stmtsp()) { stmtsp->unlinkFrBackWithNext(); if (addsp) { addsp = addsp->addNextNull(stmtsp); @@ -222,7 +222,7 @@ private: if (nodep->user1SetOnce()) return; // Don't double-add text's if (m_namedScope != "") { // To keep correct visual order, must add before other Text's - AstNode* afterp = nodep->scopeAttrp(); + AstNode* const afterp = nodep->scopeAttrp(); if (afterp) afterp->unlinkFrBackWithNext(); nodep->scopeAttrp(new AstText(nodep->fileline(), string("__DOT__") + m_namedScope)); if (afterp) nodep->scopeAttrp(afterp); diff --git a/src/V3Broken.cpp b/src/V3Broken.cpp index a1f1e1613..f1e422ea1 100644 --- a/src/V3Broken.cpp +++ b/src/V3Broken.cpp @@ -343,8 +343,8 @@ void V3Broken::brokenAll(AstNetlist* nodep) { UINFO(1, "Broken called under broken, skipping recursion.\n"); // LCOV_EXCL_LINE } else { inBroken = true; - BrokenMarkVisitor mvisitor{nodep}; - BrokenCheckVisitor cvisitor{nodep}; + const BrokenMarkVisitor mvisitor{nodep}; + const BrokenCheckVisitor cvisitor{nodep}; s_allocTable.checkForLeaks(); s_linkableTable.clear(); s_brokenCntGlobal.inc(); diff --git a/src/V3CCtors.cpp b/src/V3CCtors.cpp index aebf6ceed..9ce40651f 100644 --- a/src/V3CCtors.cpp +++ b/src/V3CCtors.cpp @@ -39,7 +39,7 @@ public: enum en : uint8_t { MODULE, CLASS, COVERAGE }; private: - enum en m_e; + const enum en m_e; public: // cppcheck-suppress noExplicitConstructor @@ -139,7 +139,8 @@ void V3CCtors::evalAsserts() { for (AstNode* np = modp->stmtsp(); np; np = np->nextp()) { if (AstVar* const varp = VN_CAST(np, Var)) { if (varp->isPrimaryInish() && !varp->isSc()) { - if (const AstBasicDType* basicp = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { + if (const AstBasicDType* const basicp + = VN_CAST(varp->dtypeSkipRefp(), BasicDType)) { const int storedWidth = basicp->widthAlignBytes() * 8; const int lastWordWidth = varp->width() % storedWidth; if (lastWordWidth != 0) { diff --git a/src/V3Case.cpp b/src/V3Case.cpp index c61b1ed7d..a80bf9146 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -52,7 +52,7 @@ class CaseLintVisitor final : public AstNVisitor { private: - AstNodeCase* m_caseExprp + const AstNodeCase* m_caseExprp = nullptr; // Under a CASE value node, if so the relevant case statement // METHODS @@ -127,7 +127,7 @@ private: // STATE VDouble0 m_statCaseFast; // Statistic tracking VDouble0 m_statCaseSlow; // Statistic tracking - AstNode* m_alwaysp = nullptr; // Always in which case is located + const AstNode* m_alwaysp = nullptr; // Always in which case is located // Per-CASE int m_caseWidth = 0; // Width of valueItems @@ -159,7 +159,7 @@ private: return false; // Too wide for analysis } UINFO(8, "Simple case statement: " << nodep << endl); - uint32_t numCases = 1UL << m_caseWidth; + const uint32_t numCases = 1UL << m_caseWidth; // Zero list of items for each value for (uint32_t i = 0; i < numCases; ++i) m_valueItem[i] = nullptr; // Now pick up the values for each assignment @@ -177,10 +177,10 @@ private: } else { V3Number nummask(itemp, iconstp->width()); nummask.opBitsNonX(iconstp->num()); - uint32_t mask = nummask.toUInt(); + const uint32_t mask = nummask.toUInt(); V3Number numval(itemp, iconstp->width()); numval.opBitsOne(iconstp->num()); - uint32_t val = numval.toUInt(); + const uint32_t val = numval.toUInt(); uint32_t firstOverlap = 0; bool foundOverlap = false; @@ -364,7 +364,7 @@ private: // For simplicity, make expression that is not equal, and let later // optimizations remove it condp = new AstConst(itemp->fileline(), AstConst::BitFalse()); - } else if (AstInsideRange* irangep = VN_CAST(icondp, InsideRange)) { + } else if (AstInsideRange* const irangep = VN_CAST(icondp, InsideRange)) { // Similar logic in V3Width::visit(AstInside) condp = irangep->newAndFromInside(cexprp, irangep->lhsp()->unlinkFrBack(), irangep->rhsp()->unlinkFrBack()); diff --git a/src/V3Cdc.cpp b/src/V3Cdc.cpp index 2e04c826f..ee0f91ac6 100644 --- a/src/V3Cdc.cpp +++ b/src/V3Cdc.cpp @@ -225,7 +225,7 @@ private: V3Graph m_graph; // Scoreboard of var usages/dependencies CdcLogicVertex* m_logicVertexp = nullptr; // Current statement being tracked, nullptr=ignored AstScope* m_scopep = nullptr; // Current scope being processed - AstNodeModule* m_modp = nullptr; // Current module + const AstNodeModule* m_modp = nullptr; // Current module AstSenTree* m_domainp = nullptr; // Current sentree bool m_inDly = false; // In delayed assign int m_inSenItem = 0; // Number of senitems @@ -337,7 +337,7 @@ private: int filelineWidth() { if (!m_filelineWidth) { - CdcWidthVisitor visitor{v3Global.rootp()}; + const CdcWidthVisitor visitor{v3Global.rootp()}; m_filelineWidth = visitor.maxWidth(); } return m_filelineWidth; @@ -385,7 +385,7 @@ private: // Any logic considered bad, at the moment, anyhow if (vvertexp->hazard() && !mark_outp) mark_outp = vvertexp; // And keep tracing back so the user can understand what's up - } else if (CdcVarVertex* vvertexp = dynamic_cast(vertexp)) { + } else if (CdcVarVertex* const vvertexp = dynamic_cast(vertexp)) { if (mark) vvertexp->asyncPath(true); // If primary I/O, it's ok here back if (vvertexp->varScp()->varp()->isPrimaryInish()) { @@ -461,7 +461,7 @@ private: // Dump single variable/logic block // See also OrderGraph::loopsVertexCb(V3GraphVertex* vertexp) AstNode* const nodep = vertexp->nodep(); - string front + const string front = pad(filelineWidth(), nodep->fileline()->ascii() + ":") + " " + prefix + " +- "; if (VN_IS(nodep, VarScope)) { *m_ofp << front << "Variable: " << nodep->prettyName() << '\n'; @@ -562,7 +562,7 @@ private: std::set senouts; // List of all sensitivities for new signal if (const CdcLogicVertex* const vvertexp = dynamic_cast(vertexp)) { if (vvertexp) {} // Unused - } else if (CdcVarVertex* vvertexp = dynamic_cast(vertexp)) { + } else if (const CdcVarVertex* const vvertexp = dynamic_cast(vertexp)) { // If primary I/O, give it domain of the input const AstVar* const varp = vvertexp->varScp()->varp(); if (varp->isPrimaryIO() && varp->isNonOutput() && !traceDests) { diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index f8a321406..f4dbdde75 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -154,7 +154,7 @@ private: // Later code will expand words which adds to GCC compile time, // so add penalty based on word width also - EmitCBaseCounterVisitor visitor{initp}; + const EmitCBaseCounterVisitor visitor{initp}; m_statep->m_numStmts += visitor.count() + m_varEqnp->widthWords(); } @@ -214,8 +214,8 @@ public: m_detects = 0; { AstVar* const varp = m_vscp->varp(); - string newvarname{"__Vchglast__" + m_vscp->scopep()->nameDotless() + "__" - + varp->shortName()}; + const string newvarname{"__Vchglast__" + m_vscp->scopep()->nameDotless() + "__" + + varp->shortName()}; // Create: VARREF(_last) // ASSIGN(VARREF(_last), VARREF(var)) // ... @@ -250,7 +250,7 @@ private: const AstUser1InUse m_inuser1; // STATE - ChangedState* m_statep; // Shared state across visitors + ChangedState* const m_statep; // Shared state across visitors // METHODS VL_DEBUG_FUNC; // Declare debug() diff --git a/src/V3Class.cpp b/src/V3Class.cpp index 8a5b37821..421319f85 100644 --- a/src/V3Class.cpp +++ b/src/V3Class.cpp @@ -34,9 +34,9 @@ private: // MEMBERS const AstUser1InUse m_inuser1; string m_prefix; // String prefix to add to name based on hier - AstScope* m_classScopep = nullptr; // Package moving scopes into + const AstScope* m_classScopep = nullptr; // Package moving scopes into AstScope* m_packageScopep = nullptr; // Class package scope - AstNodeFTask* m_ftaskp = nullptr; // Current task + const AstNodeFTask* m_ftaskp = nullptr; // Current task std::vector> m_moves; // NODE STATE @@ -67,7 +67,7 @@ private: v3Global.rootp()->topModulep()->addStmtp(cellp); // Find class's scope // Alternative would be to move this and related to V3Scope - AstScope* classScopep = nullptr; + const AstScope* classScopep = nullptr; for (AstNode* itp = nodep->stmtsp(); itp; itp = itp->nextp()) { if ((classScopep = VN_CAST(itp, Scope))) break; } diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 329f667f5..666d5ccc1 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -50,7 +50,7 @@ private: enum CleanState : uint8_t { CS_UNKNOWN, CS_CLEAN, CS_DIRTY }; // STATE - AstNodeModule* m_modp = nullptr; + const AstNodeModule* m_modp = nullptr; // METHODS VL_DEBUG_FUNC; // Declare debug() diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index eeaf0dae0..2989aea3c 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -77,7 +77,7 @@ private: // STATE AstNodeModule* m_modp = nullptr; // Current module - AstTopScope* m_topScopep = nullptr; // Current top scope + const AstTopScope* m_topScopep = nullptr; // Current top scope AstScope* m_scopep = nullptr; // Current scope AstCFunc* m_evalFuncp = nullptr; // Top eval function we are creating AstCFunc* m_initFuncp = nullptr; // Top initial function we are creating @@ -97,7 +97,7 @@ private: varp->v3warn(E_UNSUPPORTED, "Unsupported: Clock edge on non-single bit signal: " << varp->prettyNameQ()); } - string newvarname + const string newvarname = (string("__Vclklast__") + vscp->scopep()->nameDotless() + "__" + varp->name()); AstVar* const newvarp = new AstVar(vscp->fileline(), AstVarType::MODULETEMP, newvarname, VFlagLogicPacked(), 1); @@ -184,9 +184,9 @@ private: return senEqnp; } AstIf* makeActiveIf(AstSenTree* sensesp) { - AstNode* senEqnp = createSenseEquation(sensesp->sensesp()); + AstNode* const senEqnp = createSenseEquation(sensesp->sensesp()); UASSERT_OBJ(senEqnp, sensesp, "No sense equation, shouldn't be in sequent activation."); - AstIf* newifp = new AstIf(sensesp->fileline(), senEqnp, nullptr, nullptr); + AstIf* const newifp = new AstIf(sensesp->fileline(), senEqnp, nullptr, nullptr); return newifp; } void clearLastSen() { @@ -215,11 +215,11 @@ private: AstCFunc* funcp = nullptr; // Unlink all statements, then add item by item to new sub-functions - AstBegin* tempp = new AstBegin{ofuncp->fileline(), "[EditWrapper]", - ofuncp->stmtsp()->unlinkFrBackWithNext()}; + AstBegin* const tempp = new AstBegin{ofuncp->fileline(), "[EditWrapper]", + ofuncp->stmtsp()->unlinkFrBackWithNext()}; if (ofuncp->finalsp()) tempp->addStmtsp(ofuncp->finalsp()->unlinkFrBackWithNext()); while (tempp->stmtsp()) { - AstNode* itemp = tempp->stmtsp()->unlinkFrBack(); + AstNode* const itemp = tempp->stmtsp()->unlinkFrBack(); const int stmts = EmitCBaseCounterVisitor(itemp).count(); if (!funcp || (func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) { // Make a new function @@ -231,7 +231,7 @@ private: funcp->slow(ofuncp->slow()); m_topScopep->scopep()->addActivep(funcp); // - AstCCall* callp = new AstCCall{funcp->fileline(), funcp}; + AstCCall* const callp = new AstCCall{funcp->fileline(), funcp}; ofuncp->addStmtsp(callp); func_stmts = 0; } @@ -289,7 +289,7 @@ private: // UINFO(4, " SCOPE " << nodep << endl); m_scopep = nodep; iterateChildren(nodep); - if (AstNode* movep = nodep->finalClksp()) { + if (AstNode* const movep = nodep->finalClksp()) { UASSERT_OBJ(m_topScopep, nodep, "Final clocks under non-top scope"); movep->unlinkFrBackWithNext(); m_evalFuncp->addFinalsp(movep); @@ -297,7 +297,7 @@ private: m_scopep = nullptr; } virtual void visit(AstNodeProcedure* nodep) override { - if (AstNode* stmtsp = nodep->bodysp()) { + if (AstNode* const stmtsp = nodep->bodysp()) { stmtsp->unlinkFrBackWithNext(); nodep->addNextHere(stmtsp); } @@ -307,12 +307,12 @@ private: // nodep->dumpTree(cout, "ct:"); // COVERTOGGLE(INC, ORIG, CHANGE) -> // IF(ORIG ^ CHANGE) { INC; CHANGE = ORIG; } - AstNode* incp = nodep->incp()->unlinkFrBack(); - AstNode* origp = nodep->origp()->unlinkFrBack(); - AstNode* changeWrp = nodep->changep()->unlinkFrBack(); - AstNode* changeRdp = ConvertWriteRefsToRead::main(changeWrp->cloneTree(false)); - AstIf* newp = new AstIf(nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), - incp, nullptr); + AstNode* const incp = nodep->incp()->unlinkFrBack(); + AstNode* const origp = nodep->origp()->unlinkFrBack(); + AstNode* const changeWrp = nodep->changep()->unlinkFrBack(); + AstNode* const changeRdp = ConvertWriteRefsToRead::main(changeWrp->cloneTree(false)); + AstIf* const newp = new AstIf( + nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), incp, nullptr); // We could add another IF to detect posedges, and only increment if so. // It's another whole branch though versus a potential memory miss. // We'll go with the miss. @@ -325,7 +325,7 @@ private: // Link to global function if (nodep->formCallTree()) { UINFO(4, " formCallTree " << nodep << endl); - AstCCall* callp = new AstCCall(nodep->fileline(), nodep); + AstCCall* const callp = new AstCCall(nodep->fileline(), nodep); m_finalFuncp->addStmtsp(callp); } } @@ -353,7 +353,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } else if (m_mtaskBodyp) { UINFO(4, " TR ACTIVE " << nodep << endl); - AstNode* stmtsp = nodep->stmtsp()->unlinkFrBackWithNext(); + AstNode* const stmtsp = nodep->stmtsp()->unlinkFrBackWithNext(); if (nodep->hasClocked()) { UASSERT_OBJ(!nodep->hasInitial(), nodep, "Initial block should not have clock sensitivity"); @@ -378,7 +378,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } else { UINFO(4, " ACTIVE " << nodep << endl); - AstNode* stmtsp = nodep->stmtsp()->unlinkFrBackWithNext(); + AstNode* const stmtsp = nodep->stmtsp()->unlinkFrBackWithNext(); if (nodep->hasClocked()) { // Remember the latest sensitivity so we can compare it next time UASSERT_OBJ(!nodep->hasInitial(), nodep, diff --git a/src/V3Config.cpp b/src/V3Config.cpp index 32609217e..c131ee826 100644 --- a/src/V3Config.cpp +++ b/src/V3Config.cpp @@ -190,7 +190,7 @@ public: void apply(AstNodeModule* modp) { if (m_inline) { - AstPragmaType type + const AstPragmaType type = m_inlineValue ? AstPragmaType::INLINE_MODULE : AstPragmaType::NO_INLINE_MODULE; AstNode* const nodep = new AstPragma(modp->fileline(), type); modp->addStmtp(nodep); @@ -223,9 +223,9 @@ using V3ConfigModuleResolver = V3ConfigWildcardResolver; // lint/coverage/tracing on/off class V3ConfigIgnoresLine final { public: - int m_lineno; // Line number to make change at - V3ErrorCode m_code; // Error code - bool m_on; // True to enable message + const int m_lineno; // Line number to make change at + const V3ErrorCode m_code; // Error code + const bool m_on; // True to enable message V3ConfigIgnoresLine(V3ErrorCode code, int lineno, bool on) : m_lineno{lineno} , m_code{code} @@ -502,7 +502,7 @@ void V3Config::applyFTask(AstNodeModule* modulep, AstNodeFTask* ftaskp) { const string& modname = modulep->name(); V3ConfigModule* modp = V3ConfigResolver::s().modules().resolve(modname); if (!modp) return; - V3ConfigFTask* ftp = modp->ftasks().resolve(ftaskp->name()); + const V3ConfigFTask* const ftp = modp->ftasks().resolve(ftaskp->name()); if (ftp) ftp->apply(ftaskp); } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index ab5f73d1d..62ef412c6 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -123,7 +123,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { int m_lsb = 0; int m_wordIdx = -1; // -1 means AstWordSel is not used. AstVarRef* m_refp = nullptr; - AstConst* m_constp = nullptr; + const AstConst* m_constp = nullptr; int width() const { UASSERT(m_refp, "m_refp should be set"); @@ -187,7 +187,8 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { class VarInfo final { // MEMBERS int m_knownResult = -1; // -1: result is not known, 0 or 1: result of this tree - ConstBitOpTreeVisitor* const m_parentp; // ConstBitOpTreeVisitor that holds this VarInfo + const ConstBitOpTreeVisitor* const + m_parentp; // ConstBitOpTreeVisitor holding this VarInfo AstVarRef* const m_refp; // Points the variable that this VarInfo covers const int m_width; // Width of term this VarInfo refers to V3Number m_bitPolarity; // Coefficient of each bit @@ -335,7 +336,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { unsigned m_ops; // Number of operations such as And, Or, Xor, Sel... int m_lsb = 0; // Current LSB LeafInfo* m_leafp = nullptr; // AstConst or AstVarRef that currently looking for - AstNode* const m_rootp; // Root of this AST subtree + const AstNode* const m_rootp; // Root of this AST subtree std::vector m_frozenNodes; // Nodes that cannot be optimized std::vector m_bitPolarities; // Polarity of bits found during iterate() @@ -415,7 +416,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { virtual void visit(AstCCast* nodep) override { iterateChildren(nodep); } virtual void visit(AstShiftR* nodep) override { CONST_BITOP_RETURN_IF(!m_leafp, nodep); - AstConst* constp = VN_CAST(nodep->rhsp(), Const); + AstConst* const constp = VN_CAST(nodep->rhsp(), Const); CONST_BITOP_RETURN_IF(!constp, nodep->rhsp()); m_lsb += constp->toUInt(); incrOps(nodep, __LINE__); @@ -425,7 +426,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { virtual void visit(AstNot* nodep) override { CONST_BITOP_RETURN_IF(nodep->widthMin() != 1, nodep); AstNode* lhsp = nodep->lhsp(); - if (AstCCast* castp = VN_CAST(lhsp, CCast)) lhsp = castp->lhsp(); + if (AstCCast* const castp = VN_CAST(lhsp, CCast)) lhsp = castp->lhsp(); CONST_BITOP_RETURN_IF(!VN_IS(lhsp, VarRef) && !VN_IS(lhsp, Xor) && !VN_IS(lhsp, RedXor) && !VN_IS(lhsp, ShiftR), lhsp); @@ -437,7 +438,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { } virtual void visit(AstWordSel* nodep) override { CONST_BITOP_RETURN_IF(!m_leafp, nodep); - AstConst* constp = VN_CAST(nodep->bitp(), Const); + AstConst* const constp = VN_CAST(nodep->bitp(), Const); CONST_BITOP_RETURN_IF(!constp, nodep->rhsp()); UASSERT_OBJ(m_leafp->m_wordIdx == -1, nodep, "Unexpected nested WordSel"); m_leafp->m_wordIdx = constp->toSInt(); @@ -461,8 +462,8 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { Restorer restorer{*this}; CONST_BITOP_RETURN_IF(!VN_IS(m_rootp, Xor), nodep); AstNode* lhsp = nodep->lhsp(); - if (AstCCast* const castp = VN_CAST(lhsp, CCast)) lhsp = castp->lhsp(); - if (AstAnd* const andp = VN_CAST(lhsp, And)) { // '^(mask & leaf)' + if (const AstCCast* const castp = VN_CAST(lhsp, CCast)) lhsp = castp->lhsp(); + if (const AstAnd* const andp = VN_CAST(lhsp, And)) { // '^(mask & leaf)' CONST_BITOP_RETURN_IF(!andp, lhsp); const LeafInfo& mask = findLeaf(andp->lhsp(), true); @@ -524,7 +525,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { // Revert changes in leaf restorer.restoreNow(); // Reach past a cast then add to frozen nodes to be added to final reduction - if (AstCCast* const castp = VN_CAST(opp, CCast)) opp = castp->lhsp(); + if (const AstCCast* const castp = VN_CAST(opp, CCast)) opp = castp->lhsp(); m_frozenNodes.push_back(opp); m_failed = origFailed; continue; @@ -548,15 +549,15 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { } else if ((isAndTree() && VN_IS(nodep, Eq)) || (isOrTree() && VN_IS(nodep, Neq))) { Restorer restorer{*this}; CONST_BITOP_RETURN_IF(!m_polarity, nodep); - AstNode* lhsp = nodep->lhsp(); - if (AstCCast* const castp = VN_CAST(lhsp, CCast)) lhsp = castp->lhsp(); - AstConst* const constp = VN_CAST(lhsp, Const); + const AstNode* lhsp = nodep->lhsp(); + if (const AstCCast* const castp = VN_CAST(lhsp, CCast)) lhsp = castp->lhsp(); + const AstConst* const constp = VN_CAST(lhsp, Const); CONST_BITOP_RETURN_IF(!constp, nodep->lhsp()); const bool maskFlip = isOrTree(); const V3Number& compNum = constp->num(); - if (AstAnd* const andp = VN_CAST(nodep->rhsp(), And)) { // comp == (mask & v) + if (const AstAnd* const andp = VN_CAST(nodep->rhsp(), And)) { // comp == (mask & v) const LeafInfo& mask = findLeaf(andp->lhsp(), true); CONST_BITOP_RETURN_IF(!mask.m_constp || mask.m_lsb != 0, andp->lhsp()); @@ -636,7 +637,7 @@ public: UASSERT_OBJ(1 <= resultWidth && resultWidth <= 64, nodep, "resultWidth out of range"); // Walk tree, gathering all terms referenced in expression - ConstBitOpTreeVisitor visitor{nodep, externalOps}; + const ConstBitOpTreeVisitor visitor{nodep, externalOps}; // If failed on root node is not optimizable, or there are no variable terms, then done if (visitor.m_failed || visitor.m_varInfos.size() == 1) return nullptr; @@ -815,6 +816,7 @@ private: // AstEnum::user4 -> bool. Recursing. // STATE + static constexpr bool m_doShort = true; // Remove expressions that short circuit bool m_params = false; // If true, propagate parameterized and true numbers only bool m_required = false; // If true, must become a constant bool m_wremove = true; // Inside scope, no assignw removal @@ -822,14 +824,13 @@ private: bool m_doExpensive = false; // Enable computationally expensive optimizations bool m_doCpp = false; // Enable late-stage C++ optimizations bool m_doNConst = false; // Enable non-constant-child simplifications - bool m_doShort = true; // Remove expressions that short circuit bool m_doV = false; // Verilog, not C++ conversion bool m_doGenerate = false; // Postpone width checking inside generate bool m_hasJumpDelay = false; // JumpGo or Delay under this while AstNodeModule* m_modp = nullptr; // Current module - AstArraySel* m_selp = nullptr; // Current select - AstNode* m_scopep = nullptr; // Current scope - AstAttrOf* m_attrp = nullptr; // Current attribute + const AstArraySel* m_selp = nullptr; // Current select + const AstNode* m_scopep = nullptr; // Current scope + const AstAttrOf* m_attrp = nullptr; // Current attribute VDouble0 m_statBitOpReduction; // Ops reduced in ConstBitOpTreeVisitor const bool m_globalPass; // ConstVisitor invoked as a global pass static uint32_t s_globalPassNum; // Counts number of times ConstVisitor invoked as global pass @@ -841,10 +842,10 @@ private: bool operandConst(AstNode* nodep) { return VN_IS(nodep, Const); } bool operandAsvConst(const AstNode* nodep) { // BIASV(CONST, BIASV(CONST,...)) -> BIASV( BIASV_CONSTED(a,b), ...) - const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* const bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; if (!VN_IS(bnodep->lhsp(), Const)) return false; - const AstNodeBiComAsv* rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); + const AstNodeBiComAsv* const rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); if (!rnodep) return false; if (rnodep->type() != bnodep->type()) return false; if (rnodep->width() != bnodep->width()) return false; @@ -854,9 +855,9 @@ private: } bool operandAsvSame(const AstNode* nodep) { // BIASV(SAMEa, BIASV(SAMEb,...)) -> BIASV( BIASV(SAMEa,SAMEb), ...) - const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* const bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; - const AstNodeBiComAsv* rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); + const AstNodeBiComAsv* const rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); if (!rnodep) return false; if (rnodep->type() != bnodep->type()) return false; if (rnodep->width() != bnodep->width()) return false; @@ -873,9 +874,9 @@ private: // BIASV(CONST_a_c,BIASV(c...,d...))) // // Idea for the future: All BiComAsvs could be lists, sorted by if they're constant - const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* const bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; - const AstNodeBiComAsv* lnodep = VN_CAST(bnodep->lhsp(), NodeBiComAsv); + const AstNodeBiComAsv* const lnodep = VN_CAST(bnodep->lhsp(), NodeBiComAsv); if (!lnodep) return false; if (lnodep->type() != bnodep->type()) return false; if (lnodep->width() != bnodep->width()) return false; @@ -883,9 +884,9 @@ private: } bool operandAsvRUp(const AstNode* nodep) { // BIASV(l,BIASV(CONSTrl,rr)) -> BIASV(CONSTrl,BIASV(l,rr)) ? - const AstNodeBiComAsv* bnodep = VN_CAST(nodep, NodeBiComAsv); + const AstNodeBiComAsv* const bnodep = VN_CAST(nodep, NodeBiComAsv); if (!bnodep) return false; - const AstNodeBiComAsv* rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); + const AstNodeBiComAsv* const rnodep = VN_CAST(bnodep->rhsp(), NodeBiComAsv); if (!rnodep) return false; if (rnodep->type() != bnodep->type()) return false; if (rnodep->width() != bnodep->width()) return false; @@ -893,8 +894,8 @@ private: } static bool operandSubAdd(const AstNode* nodep) { // SUB( ADD(CONSTx,y), CONSTz) -> ADD(SUB(CONSTx,CONSTz), y) - const AstNodeBiop* np = VN_CAST(nodep, NodeBiop); - const AstNodeBiop* lp = VN_CAST(np->lhsp(), NodeBiop); + const AstNodeBiop* const np = VN_CAST(nodep, NodeBiop); + const AstNodeBiop* const lp = VN_CAST(np->lhsp(), NodeBiop); return (lp && VN_IS(lp->lhsp(), Const) && VN_IS(np->rhsp(), Const) && lp->width() == np->width()); } @@ -902,15 +903,15 @@ private: // Remove And with constant one inserted by V3Clean // 1 & (a == b) -> (IData)(a == b) // When bool is casted to int, the value is either 0 or 1 - AstConst* constp = VN_AS(andp->lhsp(), Const); + AstConst* const constp = VN_AS(andp->lhsp(), Const); UASSERT_OBJ(constp && constp->isOne(), andp->lhsp(), "TRREEOPC must meet this condition"); - AstNode* rhsp = andp->rhsp(); + AstNode* const rhsp = andp->rhsp(); AstCCast* ccastp = nullptr; - auto isEqOrNeq + const auto isEqOrNeq = [](AstNode* nodep) -> bool { return VN_IS(nodep, Eq) || VN_IS(nodep, Neq); }; if (isEqOrNeq(rhsp)) { ccastp = new AstCCast{andp->fileline(), rhsp->unlinkFrBack(), andp}; - } else if (AstCCast* tmpp = VN_CAST(rhsp, CCast)) { + } else if (AstCCast* const tmpp = VN_CAST(rhsp, CCast)) { if (isEqOrNeq(tmpp->lhsp())) { if (tmpp->width() == andp->width()) { tmpp->unlinkFrBack(); @@ -931,9 +932,9 @@ private: static bool operandAndOrSame(const AstNode* nodep) { // OR( AND(VAL,x), AND(VAL,y)) -> AND(VAL,OR(x,y)) // OR( AND(x,VAL), AND(y,VAL)) -> AND(OR(x,y),VAL) - const AstNodeBiop* np = VN_CAST(nodep, NodeBiop); - const AstNodeBiop* lp = VN_CAST(np->lhsp(), NodeBiop); - const AstNodeBiop* rp = VN_CAST(np->rhsp(), NodeBiop); + const AstNodeBiop* const np = VN_CAST(nodep, NodeBiop); + const AstNodeBiop* const lp = VN_CAST(np->lhsp(), NodeBiop); + const AstNodeBiop* const rp = VN_CAST(np->rhsp(), NodeBiop); return (lp && rp && lp->width() == rp->width() && lp->type() == rp->type() && (operandsSame(lp->lhsp(), rp->lhsp()) || operandsSame(lp->rhsp(), rp->rhsp()))); } @@ -952,7 +953,7 @@ private: ap = nodep->lhsp(); } else return false; - AstNodeUniop* notp; + const AstNodeUniop* notp; AstNode* cp; if (VN_IS(andp->lhsp(), Not)) { notp = VN_AS(andp->lhsp(), Not); @@ -960,9 +961,10 @@ private: } else if (VN_IS(andp->rhsp(), Not)) { notp = VN_AS(andp->rhsp(), Not); cp = andp->lhsp(); - } else + } else { return false; - AstNode* bp = notp->lhsp(); + } + AstNode* const bp = notp->lhsp(); if (!operandsSame(ap, bp)) return false; // Do it cp->unlinkFrBack(); @@ -981,14 +983,14 @@ private: // (otherwise we'd be trading one operation for two operations) // V3Clean often makes this pattern, as it postpones the AND until // as high as possible, which is usally the right choice, except for this. - AstNodeCond* condp = VN_CAST(nodep->rhsp(), NodeCond); + AstNodeCond* const condp = VN_CAST(nodep->rhsp(), NodeCond); if (!condp) return false; if (!VN_IS(condp->expr1p(), Const) && !VN_IS(condp->expr2p(), Const)) return false; - AstConst* maskp = VN_CAST(nodep->lhsp(), Const); + AstConst* const maskp = VN_CAST(nodep->lhsp(), Const); if (!maskp) return false; UINFO(4, "AND(CONSTm, CONDcond(c, i, e))->CONDcond(c, AND(m,i), AND(m, e)) " << nodep << endl); - AstNodeCond* newp = static_cast( + AstNodeCond* const newp = static_cast( condp->cloneType(condp->condp()->unlinkFrBack(), new AstAnd(nodep->fileline(), maskp->cloneTree(false), condp->expr1p()->unlinkFrBack()), @@ -1062,15 +1064,15 @@ private: }; // Check if masking is redundant - if (AstShiftR* const shiftp = VN_CAST(nodep->rhsp(), ShiftR)) { - if (const AstConst* scp = VN_CAST(shiftp->rhsp(), Const)) { + if (const AstShiftR* const shiftp = VN_CAST(nodep->rhsp(), ShiftR)) { + if (const AstConst* const scp = VN_CAST(shiftp->rhsp(), Const)) { // Check if mask is full over the non-zero bits V3Number maskLo(nodep, nodep->width()); maskLo.setMask(nodep->width() - scp->num().toUInt()); return checkMask(maskLo); } - } else if (AstShiftL* const shiftp = VN_CAST(nodep->rhsp(), ShiftL)) { - if (const AstConst* scp = VN_CAST(shiftp->rhsp(), Const)) { + } else if (const AstShiftL* const shiftp = VN_CAST(nodep->rhsp(), ShiftL)) { + if (const AstConst* const scp = VN_CAST(shiftp->rhsp(), Const)) { // Check if mask is full over the non-zero bits V3Number maskLo(nodep, nodep->width()); V3Number maskHi(nodep, nodep->width()); @@ -1121,18 +1123,18 @@ private: return newp; } static bool operandShiftSame(const AstNode* nodep) { - const AstNodeBiop* np = VN_AS(nodep, NodeBiop); + const AstNodeBiop* const np = VN_AS(nodep, NodeBiop); { - const AstShiftL* lp = VN_CAST(np->lhsp(), ShiftL); - const AstShiftL* rp = VN_CAST(np->rhsp(), ShiftL); + const AstShiftL* const lp = VN_CAST(np->lhsp(), ShiftL); + const AstShiftL* const rp = VN_CAST(np->rhsp(), ShiftL); if (lp && rp) { return (lp->width() == rp->width() && lp->lhsp()->width() == rp->lhsp()->width() && operandsSame(lp->rhsp(), rp->rhsp())); } } { - const AstShiftR* lp = VN_CAST(np->lhsp(), ShiftR); - const AstShiftR* rp = VN_CAST(np->rhsp(), ShiftR); + const AstShiftR* const lp = VN_CAST(np->lhsp(), ShiftR); + const AstShiftR* const rp = VN_CAST(np->rhsp(), ShiftR); if (lp && rp) { return (lp->width() == rp->width() && lp->lhsp()->width() == rp->lhsp()->width() && operandsSame(lp->rhsp(), rp->rhsp())); @@ -1164,7 +1166,7 @@ private: } bool operandShiftOp(const AstNodeBiop* nodep) { if (!VN_IS(nodep->rhsp(), Const)) return false; - const AstNodeBiop* lhsp = VN_CAST(nodep->lhsp(), NodeBiop); + const AstNodeBiop* const lhsp = VN_CAST(nodep->lhsp(), NodeBiop); if (!lhsp || !(VN_IS(lhsp, And) || VN_IS(lhsp, Or) || VN_IS(lhsp, Xor))) return false; if (nodep->width() != lhsp->width()) return false; if (nodep->width() != lhsp->lhsp()->width()) return false; @@ -1173,7 +1175,7 @@ private: } bool operandShiftShift(const AstNodeBiop* nodep) { // We could add a AND though. - const AstNodeBiop* lhsp = VN_CAST(nodep->lhsp(), NodeBiop); + const AstNodeBiop* const lhsp = VN_CAST(nodep->lhsp(), NodeBiop); if (!lhsp || !(VN_IS(lhsp, ShiftL) || VN_IS(lhsp, ShiftR))) return false; // We can only get rid of a<>c or a< ... // Since select's return unsigned, this is always an extend - AstExtend* extendp = VN_CAST(nodep->fromp(), Extend); + AstExtend* const extendp = VN_CAST(nodep->fromp(), Extend); if (!(m_doV && extendp && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && nodep->lsbConst() == 0 && static_cast(nodep->widthConst()) == extendp->lhsp()->width())) @@ -1214,13 +1216,13 @@ private: bool operandSelBiLower(AstSel* nodep) { // SEL(ADD(a,b),(width-1),0) -> ADD(SEL(a),SEL(b)) // Add or any operation which doesn't care if we discard top bits - AstNodeBiop* bip = VN_CAST(nodep->fromp(), NodeBiop); + AstNodeBiop* const bip = VN_CAST(nodep->fromp(), NodeBiop); if (!(m_doV && bip && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && nodep->lsbConst() == 0)) return false; if (debug() >= 9) nodep->dumpTree(cout, "SEL(BI)-in:"); - AstNode* bilhsp = bip->lhsp()->unlinkFrBack(); - AstNode* birhsp = bip->rhsp()->unlinkFrBack(); + AstNode* const bilhsp = bip->lhsp()->unlinkFrBack(); + AstNode* const birhsp = bip->rhsp()->unlinkFrBack(); bip->lhsp(new AstSel(nodep->fileline(), bilhsp, 0, nodep->widthConst())); bip->rhsp(new AstSel(nodep->fileline(), birhsp, 0, nodep->widthConst())); if (debug() >= 9) bip->dumpTree(cout, "SEL(BI)-ou:"); @@ -1231,14 +1233,14 @@ private: // AND({a}, SHIFTR({b}, {c})) is often shorthand in C for Verilog {b}[{c} :+ {a}] // becomes thought other optimizations // SEL(SHIFTR({a},{b}),{lsb},{width}) -> SEL({a},{lsb+b},{width}) - AstShiftR* shiftp = VN_CAST(nodep->fromp(), ShiftR); + AstShiftR* const shiftp = VN_CAST(nodep->fromp(), ShiftR); if (!(m_doV && shiftp && VN_IS(shiftp->rhsp(), Const) && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const))) { return false; } - AstNode* ap = shiftp->lhsp(); - AstConst* bp = VN_AS(shiftp->rhsp(), Const); - AstConst* lp = VN_AS(nodep->lsbp(), Const); + AstNode* const ap = shiftp->lhsp(); + AstConst* const bp = VN_AS(shiftp->rhsp(), Const); + AstConst* const lp = VN_AS(nodep->lsbp(), Const); if (bp->isWide() || bp->num().isFourState() || bp->num().isNegative() || lp->isWide() || lp->num().isFourState() || lp->num().isNegative()) { return false; @@ -1248,7 +1250,7 @@ private: // UINFO(9, "SEL(SHIFTR(a,b),l,w) -> SEL(a,l+b,w)\n"); if (debug() >= 9) nodep->dumpTree(cout, "SEL(SH)-in:"); - AstSel* newp + AstSel* const newp = new AstSel(nodep->fileline(), ap->unlinkFrBack(), newLsb, nodep->widthConst()); newp->dtypeFrom(nodep); if (debug() >= 9) newp->dumpTree(cout, "SEL(SH)-ou:"); @@ -1261,11 +1263,11 @@ private: // EQ(const{width32}, EXTEND(xx{width3})) -> EQ(const{3}, xx{3}) // The constant must have zero bits (+ 1 if signed) or compare // would be incorrect. See also operandBiExtendConst - AstExtend* extendp = VN_CAST(nodep->rhsp(), Extend); + AstExtend* const extendp = VN_CAST(nodep->rhsp(), Extend); if (!extendp) return false; - AstNode* smallerp = extendp->lhsp(); + AstNode* const smallerp = extendp->lhsp(); const int subsize = smallerp->width(); - AstConst* constp = VN_CAST(nodep->lhsp(), Const); + AstConst* const constp = VN_CAST(nodep->lhsp(), Const); if (!constp) return false; if (!constp->num().isBitsZero(constp->width() - 1, subsize)) return false; // @@ -1286,11 +1288,11 @@ private: // EQ(const{width32}, EXTEND(xx{width3})) -> constant // When the constant has non-zero bits above the extend it's a constant. // Avoids compiler warning - const AstExtend* extendp = VN_CAST(nodep->rhsp(), Extend); + const AstExtend* const extendp = VN_CAST(nodep->rhsp(), Extend); if (!extendp) return false; - AstNode* smallerp = extendp->lhsp(); + AstNode* const smallerp = extendp->lhsp(); const int subsize = smallerp->width(); - const AstConst* constp = VN_CAST(nodep->lhsp(), Const); + const AstConst* const constp = VN_CAST(nodep->lhsp(), Const); if (!constp) return false; if (constp->num().isBitsZero(constp->width() - 1, subsize)) return false; return true; @@ -1384,8 +1386,8 @@ private: } } bool ifSameAssign(const AstNodeIf* nodep) { - const AstNodeAssign* ifp = VN_CAST(nodep->ifsp(), NodeAssign); - const AstNodeAssign* elsep = VN_CAST(nodep->elsesp(), NodeAssign); + const AstNodeAssign* const ifp = VN_CAST(nodep->ifsp(), NodeAssign); + const AstNodeAssign* const elsep = VN_CAST(nodep->elsesp(), NodeAssign); if (!ifp || ifp->nextp()) return false; // Must be SINGLE statement if (!elsep || elsep->nextp()) return false; if (ifp->type() != elsep->type()) return false; // Can't mix an assigndly and an assign @@ -1396,7 +1398,7 @@ private: } bool operandIfIf(const AstNodeIf* nodep) { if (nodep->elsesp()) return false; - const AstNodeIf* lowerIfp = VN_CAST(nodep->ifsp(), NodeIf); + const AstNodeIf* const lowerIfp = VN_CAST(nodep->ifsp(), NodeIf); if (!lowerIfp || lowerIfp->nextp()) return false; if (nodep->type() != lowerIfp->type()) return false; if (afterComment(lowerIfp->elsesp())) return false; @@ -1408,13 +1410,13 @@ private: bool ifAdjacentSel(const AstSel* lhsp, const AstSel* rhsp) { if (!v3Global.opt.oAssemble()) return false; // opt disabled if (!lhsp || !rhsp) return false; - const AstNode* lfromp = lhsp->fromp(); - const AstNode* rfromp = rhsp->fromp(); + const AstNode* const lfromp = lhsp->fromp(); + const AstNode* const rfromp = rhsp->fromp(); if (!lfromp || !rfromp || !lfromp->sameGateTree(rfromp)) return false; - const AstConst* lstart = VN_CAST(lhsp->lsbp(), Const); - const AstConst* rstart = VN_CAST(rhsp->lsbp(), Const); - const AstConst* lwidth = VN_CAST(lhsp->widthp(), Const); - const AstConst* rwidth = VN_CAST(rhsp->widthp(), Const); + const AstConst* const lstart = VN_CAST(lhsp->lsbp(), Const); + const AstConst* const rstart = VN_CAST(rhsp->lsbp(), Const); + const AstConst* const lwidth = VN_CAST(lhsp->widthp(), Const); + const AstConst* const rwidth = VN_CAST(rhsp->widthp(), Const); if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated const int rend = (rstart->toSInt() + rwidth->toSInt()); return (rend == lstart->toSInt()); @@ -1424,8 +1426,8 @@ private: if (!v3Global.opt.oAssemble()) return false; // opt disabled // two same varref if (operandsSame(lhsp, rhsp)) return true; - AstSel* lselp = VN_CAST(lhsp, Sel); - AstSel* rselp = VN_CAST(rhsp, Sel); + const AstSel* lselp = VN_CAST(lhsp, Sel); + const AstSel* rselp = VN_CAST(rhsp, Sel); // a[i:0] a if (lselp && !rselp && rhsp->sameGateTree(lselp->fromp())) rselp = new AstSel(rhsp->fileline(), rhsp->cloneTree(false), 0, rhsp->width()); @@ -1441,13 +1443,13 @@ private: if (!lselp || !rselp) return false; // a[a:b] a[b-1:c] are adjacent - AstNode* lfromp = lselp->fromp(); - AstNode* rfromp = rselp->fromp(); + AstNode* const lfromp = lselp->fromp(); + AstNode* const rfromp = rselp->fromp(); if (!lfromp || !rfromp || !lfromp->sameGateTree(rfromp)) return false; - AstConst* lstart = VN_CAST(lselp->lsbp(), Const); - AstConst* rstart = VN_CAST(rselp->lsbp(), Const); - AstConst* lwidth = VN_CAST(lselp->widthp(), Const); - AstConst* rwidth = VN_CAST(rselp->widthp(), Const); + AstConst* const lstart = VN_CAST(lselp->lsbp(), Const); + AstConst* const rstart = VN_CAST(rselp->lsbp(), Const); + AstConst* const lwidth = VN_CAST(lselp->widthp(), Const); + AstConst* const rwidth = VN_CAST(rselp->widthp(), Const); if (!lstart || !rstart || !lwidth || !rwidth) return false; // too complicated const int rend = (rstart->toSInt() + rwidth->toSInt()); // a[i:j] a[j-1:k] @@ -1462,8 +1464,8 @@ private: if (lhsp->type() != rhsp->type()) return false; if (!ifConcatMergeableBiop(lhsp)) return false; - const AstNodeBiop* lp = VN_CAST(lhsp, NodeBiop); - const AstNodeBiop* rp = VN_CAST(rhsp, NodeBiop); + const AstNodeBiop* const lp = VN_CAST(lhsp, NodeBiop); + const AstNodeBiop* const rp = VN_CAST(rhsp, NodeBiop); if (!lp || !rp) return false; // {a[]&b[], a[]&b[]} const bool lad = ifMergeAdjacent(lp->lhsp(), rp->lhsp()); @@ -1490,7 +1492,7 @@ private: UASSERT(oldp, "Null old"); UASSERT_OBJ(!(VN_IS(oldp, Const) && !VN_AS(oldp, Const)->num().isFourState()), oldp, "Already constant??"); - AstNode* newp = new AstConst(oldp->fileline(), num); + AstNode* const newp = new AstConst(oldp->fileline(), num); newp->dtypeFrom(oldp); if (debug() > 5) oldp->dumpTree(cout, " const_old: "); if (debug() > 5) newp->dumpTree(cout, " _new: "); @@ -1522,8 +1524,8 @@ private: if (isTPure(checkp)) { VL_DO_DANGLING(replaceNum(nodep, 0), nodep); } else { - AstNode* newp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), 0), - checkp->unlinkFrBack()); + AstNode* const newp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), 0), + checkp->unlinkFrBack()); newp->dtypeFrom(nodep); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -1567,7 +1569,7 @@ private: void replaceConstString(AstNode* oldp, const string& num) { // Replace oldp node with a constant set to specified value UASSERT(oldp, "Null old"); - AstNode* newp = new AstConst(oldp->fileline(), AstConst::String(), num); + AstNode* const newp = new AstConst(oldp->fileline(), AstConst::String(), num); if (debug() > 5) oldp->dumpTree(cout, " const_old: "); if (debug() > 5) newp->dumpTree(cout, " _new: "); oldp->replaceWith(newp); @@ -1590,14 +1592,14 @@ private: //! Replace a ternary node with its RHS after iterating //! Used with short-circuiting, where the RHS has not yet been iterated. void replaceWIteratedRhs(AstNodeTriop* nodep) { - if (AstNode* rhsp = nodep->rhsp()) iterateAndNextNull(rhsp); + if (AstNode* const rhsp = nodep->rhsp()) iterateAndNextNull(rhsp); replaceWChild(nodep, nodep->rhsp()); // May have changed } //! Replace a ternary node with its THS after iterating //! Used with short-circuiting, where the THS has not yet been iterated. void replaceWIteratedThs(AstNodeTriop* nodep) { - if (AstNode* thsp = nodep->thsp()) iterateAndNextNull(thsp); + if (AstNode* const thsp = nodep->thsp()) iterateAndNextNull(thsp); replaceWChild(nodep, nodep->thsp()); // May have changed } void replaceWLhs(AstNodeUniop* nodep) { @@ -1616,10 +1618,10 @@ private: // BIASV(CONSTa, BIASV(CONSTb, c)) -> BIASV( BIASV_CONSTED(a,b), c) // BIASV(SAMEa, BIASV(SAMEb, c)) -> BIASV( BIASV(SAMEa,SAMEb), c) // nodep->dumpTree(cout, " repAsvConst_old: "); - AstNode* ap = nodep->lhsp(); - AstNodeBiop* rp = VN_AS(nodep->rhsp(), NodeBiop); - AstNode* bp = rp->lhsp(); - AstNode* cp = rp->rhsp(); + AstNode* const ap = nodep->lhsp(); + AstNodeBiop* const rp = VN_AS(nodep->rhsp(), NodeBiop); + AstNode* const bp = rp->lhsp(); + AstNode* const cp = rp->rhsp(); ap->unlinkFrBack(); bp->unlinkFrBack(); cp->unlinkFrBack(); @@ -1633,10 +1635,10 @@ private: } void replaceAsvLUp(AstNodeBiop* nodep) { // BIASV(BIASV(CONSTll,lr),r) -> BIASV(CONSTll,BIASV(lr,r)) - AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); - AstNode* llp = lp->lhsp()->unlinkFrBack(); - AstNode* lrp = lp->rhsp()->unlinkFrBack(); - AstNode* rp = nodep->rhsp()->unlinkFrBack(); + AstNodeBiop* const lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); + AstNode* const llp = lp->lhsp()->unlinkFrBack(); + AstNode* const lrp = lp->rhsp()->unlinkFrBack(); + AstNode* const rp = nodep->rhsp()->unlinkFrBack(); nodep->lhsp(llp); nodep->rhsp(lp); lp->lhsp(lrp); @@ -1645,10 +1647,10 @@ private: } void replaceAsvRUp(AstNodeBiop* nodep) { // BIASV(l,BIASV(CONSTrl,rr)) -> BIASV(CONSTrl,BIASV(l,rr)) - AstNode* lp = nodep->lhsp()->unlinkFrBack(); - AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); - AstNode* rlp = rp->lhsp()->unlinkFrBack(); - AstNode* rrp = rp->rhsp()->unlinkFrBack(); + AstNode* const lp = nodep->lhsp()->unlinkFrBack(); + AstNodeBiop* const rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); + AstNode* const rlp = rp->lhsp()->unlinkFrBack(); + AstNode* const rrp = rp->rhsp()->unlinkFrBack(); nodep->lhsp(rlp); nodep->rhsp(rp); rp->lhsp(lp); @@ -1660,12 +1662,12 @@ private: // OR (AND (CONSTll,lr), AND(CONSTrl, rr=lr)) -> AND (OR(ll,rl), rr) // nodep ^lp ^llp ^lrp ^rp ^rlp ^rrp // (Or/And may also be reversed) - AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); - AstNode* llp = lp->lhsp()->unlinkFrBack(); - AstNode* lrp = lp->rhsp()->unlinkFrBack(); - AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); - AstNode* rlp = rp->lhsp()->unlinkFrBack(); - AstNode* rrp = rp->rhsp()->unlinkFrBack(); + AstNodeBiop* const lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); + AstNode* const llp = lp->lhsp()->unlinkFrBack(); + AstNode* const lrp = lp->rhsp()->unlinkFrBack(); + AstNodeBiop* const rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); + AstNode* const rlp = rp->lhsp()->unlinkFrBack(); + AstNode* const rrp = rp->rhsp()->unlinkFrBack(); nodep->replaceWith(lp); if (operandsSame(llp, rlp)) { lp->lhsp(llp); @@ -1691,12 +1693,12 @@ private: void replaceShiftSame(AstNodeBiop* nodep) { // Or(Shift(ll,CONSTlr),Shift(rl,CONSTrr==lr)) -> Shift(Or(ll,rl),CONSTlr) // (Or/And may also be reversed) - AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); - AstNode* llp = lp->lhsp()->unlinkFrBack(); - AstNode* lrp = lp->rhsp()->unlinkFrBack(); - AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); - AstNode* rlp = rp->lhsp()->unlinkFrBack(); - AstNode* rrp = rp->rhsp()->unlinkFrBack(); + AstNodeBiop* const lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop); + AstNode* const llp = lp->lhsp()->unlinkFrBack(); + AstNode* const lrp = lp->rhsp()->unlinkFrBack(); + AstNodeBiop* const rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop); + AstNode* const rlp = rp->lhsp()->unlinkFrBack(); + AstNode* const rrp = rp->rhsp()->unlinkFrBack(); nodep->replaceWith(lp); lp->lhsp(nodep); lp->rhsp(lrp); @@ -1708,8 +1710,8 @@ private: } void replaceConcatSel(AstConcat* nodep) { // {a[1], a[0]} -> a[1:0] - AstSel* lselp = VN_AS(nodep->lhsp()->unlinkFrBack(), Sel); - AstSel* rselp = VN_AS(nodep->rhsp()->unlinkFrBack(), Sel); + AstSel* const lselp = VN_AS(nodep->lhsp()->unlinkFrBack(), Sel); + AstSel* const rselp = VN_AS(nodep->rhsp()->unlinkFrBack(), Sel); const int lstart = lselp->lsbConst(); const int lwidth = lselp->widthConst(); const int rstart = rselp->lsbConst(); @@ -1717,8 +1719,8 @@ private: UASSERT_OBJ((rstart + rwidth) == lstart, nodep, "tried to merge two selects which are not adjacent"); - AstSel* newselp = new AstSel(lselp->fromp()->fileline(), rselp->fromp()->cloneTree(false), - rstart, lwidth + rwidth); + AstSel* const newselp = new AstSel( + lselp->fromp()->fileline(), rselp->fromp()->cloneTree(false), rstart, lwidth + rwidth); UINFO(5, "merged two adjacent sel " << lselp << " and " << rselp << " to one " << newselp << endl); @@ -1728,15 +1730,15 @@ private: VL_DO_DANGLING(nodep->deleteTree(), nodep); } void replaceConcatMerge(AstConcat* nodep) { - AstNodeBiop* lp = VN_AS(nodep->lhsp(), NodeBiop); - AstNodeBiop* rp = VN_AS(nodep->rhsp(), NodeBiop); - AstNode* llp = lp->lhsp()->cloneTree(false); - AstNode* lrp = lp->rhsp()->cloneTree(false); - AstNode* rlp = rp->lhsp()->cloneTree(false); - AstNode* rrp = rp->rhsp()->cloneTree(false); + AstNodeBiop* const lp = VN_AS(nodep->lhsp(), NodeBiop); + AstNodeBiop* const rp = VN_AS(nodep->rhsp(), NodeBiop); + AstNode* const llp = lp->lhsp()->cloneTree(false); + AstNode* const lrp = lp->rhsp()->cloneTree(false); + AstNode* const rlp = rp->lhsp()->cloneTree(false); + AstNode* const rrp = rp->rhsp()->cloneTree(false); if (concatMergeable(lp, rp)) { - AstConcat* newlp = new AstConcat(rlp->fileline(), llp, rlp); - AstConcat* newrp = new AstConcat(rrp->fileline(), lrp, rrp); + AstConcat* const newlp = new AstConcat(rlp->fileline(), llp, rlp); + AstConcat* const newrp = new AstConcat(rrp->fileline(), lrp, rrp); // use the lhs to replace the parent concat lp->lhsp()->replaceWith(newlp); lp->rhsp()->replaceWith(newrp); @@ -1765,8 +1767,8 @@ private: } void replacePowShift(AstNodeBiop* nodep) { // Pow or PowS UINFO(5, "POW(2,b)->SHIFTL(1,b) " << nodep << endl); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); - AstShiftL* newp + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); + AstShiftL* const newp = new AstShiftL(nodep->fileline(), new AstConst(nodep->fileline(), 1), rhsp); newp->dtypeFrom(nodep); newp->lhsp()->dtypeFrom(nodep); @@ -1776,8 +1778,8 @@ private: void replaceMulShift(AstMul* nodep) { // Mul, but not MulS as not simple shift UINFO(5, "MUL(2^n,b)->SHIFTL(b,n) " << nodep << endl); const int amount = VN_AS(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 - AstNode* opp = nodep->rhsp()->unlinkFrBack(); - AstShiftL* newp + AstNode* const opp = nodep->rhsp()->unlinkFrBack(); + AstShiftL* const newp = new AstShiftL(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount)); newp->dtypeFrom(nodep); nodep->replaceWith(newp); @@ -1786,8 +1788,8 @@ private: void replaceDivShift(AstDiv* nodep) { // Mul, but not MulS as not simple shift UINFO(5, "DIV(b,2^n)->SHIFTR(b,n) " << nodep << endl); const int amount = VN_AS(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 - AstNode* opp = nodep->lhsp()->unlinkFrBack(); - AstShiftR* newp + AstNode* const opp = nodep->lhsp()->unlinkFrBack(); + AstShiftR* const newp = new AstShiftR(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount)); newp->dtypeFrom(nodep); nodep->replaceWith(newp); @@ -1798,8 +1800,9 @@ private: const int amount = VN_AS(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1 V3Number mask(nodep, nodep->width()); mask.setMask(amount); - AstNode* opp = nodep->lhsp()->unlinkFrBack(); - AstAnd* newp = new AstAnd(nodep->fileline(), opp, new AstConst(nodep->fileline(), mask)); + AstNode* const opp = nodep->lhsp()->unlinkFrBack(); + AstAnd* const newp + = new AstAnd(nodep->fileline(), opp, new AstConst(nodep->fileline(), mask)); newp->dtypeFrom(nodep); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -1808,18 +1811,18 @@ private: UINFO(5, "SHIFT(AND(a,b),CONST)->AND(SHIFT(a,CONST),SHIFT(b,CONST)) " << nodep << endl); AstNRelinker handle; nodep->unlinkFrBack(&handle); - AstNodeBiop* lhsp = VN_AS(nodep->lhsp(), NodeBiop); + AstNodeBiop* const lhsp = VN_AS(nodep->lhsp(), NodeBiop); lhsp->unlinkFrBack(); - AstNode* shiftp = nodep->rhsp()->unlinkFrBack(); - AstNode* ap = lhsp->lhsp()->unlinkFrBack(); - AstNode* bp = lhsp->rhsp()->unlinkFrBack(); - AstNodeBiop* shift1p = nodep; - AstNodeBiop* shift2p = nodep->cloneTree(true); + AstNode* const shiftp = nodep->rhsp()->unlinkFrBack(); + AstNode* const ap = lhsp->lhsp()->unlinkFrBack(); + AstNode* const bp = lhsp->rhsp()->unlinkFrBack(); + AstNodeBiop* const shift1p = nodep; + AstNodeBiop* const shift2p = nodep->cloneTree(true); shift1p->lhsp(ap); shift1p->rhsp(shiftp->cloneTree(true)); shift2p->lhsp(bp); shift2p->rhsp(shiftp); - AstNodeBiop* newp = lhsp; + AstNodeBiop* const newp = lhsp; newp->lhsp(shift1p); newp->rhsp(shift2p); handle.relink(newp); @@ -1828,16 +1831,16 @@ private: void replaceShiftShift(AstNodeBiop* nodep) { UINFO(4, "SHIFT(SHIFT(a,s1),s2)->SHIFT(a,ADD(s1,s2)) " << nodep << endl); if (debug() >= 9) nodep->dumpTree(cout, " repShiftShift_old: "); - AstNodeBiop* lhsp = VN_AS(nodep->lhsp(), NodeBiop); + AstNodeBiop* const lhsp = VN_AS(nodep->lhsp(), NodeBiop); lhsp->unlinkFrBack(); - AstNode* ap = lhsp->lhsp()->unlinkFrBack(); - AstNode* shift1p = lhsp->rhsp()->unlinkFrBack(); - AstNode* shift2p = nodep->rhsp()->unlinkFrBack(); + AstNode* const ap = lhsp->lhsp()->unlinkFrBack(); + AstNode* const shift1p = lhsp->rhsp()->unlinkFrBack(); + AstNode* const shift2p = nodep->rhsp()->unlinkFrBack(); // Shift1p and shift2p may have different sizes, both are // self-determined so sum with infinite width if (nodep->type() == lhsp->type()) { - int shift1 = VN_AS(shift1p, Const)->toUInt(); - int shift2 = VN_AS(shift2p, Const)->toUInt(); + const int shift1 = VN_AS(shift1p, Const)->toUInt(); + const int shift2 = VN_AS(shift2p, Const)->toUInt(); const int newshift = shift1 + shift2; VL_DO_DANGLING(shift1p->deleteTree(), shift1p); VL_DO_DANGLING(shift2p->deleteTree(), shift2p); @@ -1893,21 +1896,21 @@ private: // Skip if we're not const'ing an entire module (IE doing only one assign, etc) if (!m_modp) return false; - AstSel* sel1p = VN_CAST(nodep->lhsp(), Sel); + AstSel* const sel1p = VN_CAST(nodep->lhsp(), Sel); if (!sel1p) return false; - AstNodeAssign* nextp = VN_CAST(nodep->nextp(), NodeAssign); + AstNodeAssign* const nextp = VN_CAST(nodep->nextp(), NodeAssign); if (!nextp) return false; if (nodep->type() != nextp->type()) return false; - AstSel* sel2p = VN_CAST(nextp->lhsp(), Sel); + AstSel* const sel2p = VN_CAST(nextp->lhsp(), Sel); if (!sel2p) return false; - AstVarRef* varref1p = VN_CAST(sel1p->fromp(), VarRef); + AstVarRef* const varref1p = VN_CAST(sel1p->fromp(), VarRef); if (!varref1p) return false; - AstVarRef* varref2p = VN_CAST(sel2p->fromp(), VarRef); + AstVarRef* const varref2p = VN_CAST(sel2p->fromp(), VarRef); if (!varref2p) return false; if (!varref1p->sameGateTree(varref2p)) return false; - AstConst* con1p = VN_CAST(sel1p->lsbp(), Const); + AstConst* const con1p = VN_CAST(sel1p->lsbp(), Const); if (!con1p) return false; - AstConst* con2p = VN_CAST(sel2p->lsbp(), Const); + AstConst* const con2p = VN_CAST(sel2p->lsbp(), Const); if (!con2p) return false; // We need to make sure there's no self-references involved in either // assignment. For speed, we only look 3 deep, then give up. @@ -1925,8 +1928,8 @@ private: UINFO(4, " && " << nextp << endl); // nodep->dumpTree(cout, "comb1: "); // nextp->dumpTree(cout, "comb2: "); - AstNode* rhs1p = nodep->rhsp()->unlinkFrBack(); - AstNode* rhs2p = nextp->rhsp()->unlinkFrBack(); + AstNode* const rhs1p = nodep->rhsp()->unlinkFrBack(); + AstNode* const rhs2p = nextp->rhsp()->unlinkFrBack(); AstNode* newp; if (lsbFirstAssign) { newp = nodep->cloneType(new AstSel(sel1p->fileline(), varref1p->unlinkFrBack(), @@ -1976,8 +1979,8 @@ private: // Note only do this (need user4) when m_warn, which is // done as unique visitor const AstUser4InUse m_inuser4; - ConstVarMarkVisitor mark{nodep->lhsp()}; - ConstVarFindVisitor find{nodep->rhsp()}; + const ConstVarMarkVisitor mark{nodep->lhsp()}; + const ConstVarFindVisitor find{nodep->rhsp()}; if (find.found()) need_temp = true; } if (need_temp) { @@ -1995,26 +1998,26 @@ private: } if (debug() >= 9) nodep->dumpTree(cout, " Ass_old: "); // Unlink the stuff - AstNode* lc1p = VN_AS(nodep->lhsp(), Concat)->lhsp()->unlinkFrBack(); - AstNode* lc2p = VN_AS(nodep->lhsp(), Concat)->rhsp()->unlinkFrBack(); - AstNode* conp = VN_AS(nodep->lhsp(), Concat)->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); - AstNode* rhs2p = rhsp->cloneTree(false); + AstNode* const lc1p = VN_AS(nodep->lhsp(), Concat)->lhsp()->unlinkFrBack(); + AstNode* const lc2p = VN_AS(nodep->lhsp(), Concat)->rhsp()->unlinkFrBack(); + AstNode* const conp = VN_AS(nodep->lhsp(), Concat)->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); + AstNode* const rhs2p = rhsp->cloneTree(false); // Calc widths - int lsb2 = 0; - int msb2 = lsb2 + lc2p->width() - 1; - int lsb1 = msb2 + 1; - int msb1 = lsb1 + lc1p->width() - 1; + const int lsb2 = 0; + const int msb2 = lsb2 + lc2p->width() - 1; + const int lsb1 = msb2 + 1; + const int msb1 = lsb1 + lc1p->width() - 1; UASSERT_OBJ(msb1 == (conp->width() - 1), nodep, "Width calc mismatch"); // Form ranges - AstSel* sel1p = new AstSel(conp->fileline(), rhsp, lsb1, msb1 - lsb1 + 1); - AstSel* sel2p = new AstSel(conp->fileline(), rhs2p, lsb2, msb2 - lsb2 + 1); + AstSel* const sel1p = new AstSel(conp->fileline(), rhsp, lsb1, msb1 - lsb1 + 1); + AstSel* const sel2p = new AstSel(conp->fileline(), rhs2p, lsb2, msb2 - lsb2 + 1); // Make new assigns of same flavor as old one //*** Not cloneTree; just one node. AstNode* newp = nullptr; if (!need_temp) { - AstNodeAssign* asn1ap = VN_AS(nodep->cloneType(lc1p, sel1p), NodeAssign); - AstNodeAssign* asn2ap = VN_AS(nodep->cloneType(lc2p, sel2p), NodeAssign); + AstNodeAssign* const asn1ap = VN_AS(nodep->cloneType(lc1p, sel1p), NodeAssign); + AstNodeAssign* const asn2ap = VN_AS(nodep->cloneType(lc2p, sel2p), NodeAssign); asn1ap->dtypeFrom(sel1p); asn2ap->dtypeFrom(sel2p); newp = AstNode::addNext(newp, asn1ap); @@ -2033,19 +2036,19 @@ private: m_concswapNames.get(sel2p), VFlagLogicPacked(), msb2 - lsb2 + 1); m_modp->addStmtp(temp1p); m_modp->addStmtp(temp2p); - AstNodeAssign* asn1ap + AstNodeAssign* const asn1ap = VN_AS(nodep->cloneType( new AstVarRef(sel1p->fileline(), temp1p, VAccess::WRITE), sel1p), NodeAssign); - AstNodeAssign* asn2ap + AstNodeAssign* const asn2ap = VN_AS(nodep->cloneType( new AstVarRef(sel2p->fileline(), temp2p, VAccess::WRITE), sel2p), NodeAssign); - AstNodeAssign* asn1bp + AstNodeAssign* const asn1bp = VN_AS(nodep->cloneType( lc1p, new AstVarRef(sel1p->fileline(), temp1p, VAccess::READ)), NodeAssign); - AstNodeAssign* asn2bp + AstNodeAssign* const asn2bp = VN_AS(nodep->cloneType( lc2p, new AstVarRef(sel2p->fileline(), temp2p, VAccess::READ)), NodeAssign); @@ -2070,9 +2073,9 @@ private: // The right-streaming operator on rhs of assignment does not // change the order of bits. Eliminate stream but keep its lhsp // Unlink the stuff - AstNode* srcp = VN_AS(nodep->rhsp(), StreamR)->lhsp()->unlinkFrBack(); - AstNode* sizep = VN_AS(nodep->rhsp(), StreamR)->rhsp()->unlinkFrBack(); - AstNode* streamp = VN_AS(nodep->rhsp(), StreamR)->unlinkFrBack(); + AstNode* const srcp = VN_AS(nodep->rhsp(), StreamR)->lhsp()->unlinkFrBack(); + AstNode* const sizep = VN_AS(nodep->rhsp(), StreamR)->rhsp()->unlinkFrBack(); + AstNode* const streamp = VN_AS(nodep->rhsp(), StreamR)->unlinkFrBack(); nodep->rhsp(srcp); // Cleanup VL_DO_DANGLING(sizep->deleteTree(), sizep); @@ -2084,9 +2087,9 @@ private: const int dWidth = VN_AS(nodep->lhsp(), StreamL)->lhsp()->width(); const int sWidth = nodep->rhsp()->width(); // Unlink the stuff - AstNode* dstp = VN_AS(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack(); + AstNode* const dstp = VN_AS(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack(); AstNode* streamp = VN_AS(nodep->lhsp(), StreamL)->unlinkFrBack(); - AstNode* srcp = nodep->rhsp()->unlinkFrBack(); + AstNode* const srcp = nodep->rhsp()->unlinkFrBack(); // Connect the rhs to the stream operator and update its width VN_AS(streamp, StreamL)->lhsp(srcp); streamp->dtypeSetLogicUnsized(srcp->width(), srcp->widthMin(), VSigning::UNSIGNED); @@ -2105,9 +2108,9 @@ private: const int dWidth = VN_AS(nodep->lhsp(), StreamR)->lhsp()->width(); const int sWidth = nodep->rhsp()->width(); // Unlink the stuff - AstNode* dstp = VN_AS(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack(); - AstNode* sizep = VN_AS(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack(); - AstNode* streamp = VN_AS(nodep->lhsp(), StreamR)->unlinkFrBack(); + AstNode* const dstp = VN_AS(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack(); + AstNode* const sizep = VN_AS(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack(); + AstNode* const streamp = VN_AS(nodep->lhsp(), StreamR)->unlinkFrBack(); AstNode* srcp = nodep->rhsp()->unlinkFrBack(); if (sWidth > dWidth) { srcp = new AstSel(streamp->fileline(), srcp, sWidth - dWidth, dWidth); @@ -2131,7 +2134,7 @@ private: if (!VN_IS(nodep, And)) return false; if (!VN_IS(VN_AS(nodep, And)->lhsp(), Const)) return false; if (!VN_IS(VN_AS(nodep, And)->rhsp(), ShiftR)) return false; - const AstShiftR* shiftp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR); + const AstShiftR* const shiftp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR); if (!VN_IS(shiftp->rhsp(), Const)) return false; if (static_cast(nodep->width()) <= VN_AS(shiftp->rhsp(), Const)->toUInt()) { return false; @@ -2140,12 +2143,14 @@ private: } void replaceBoolShift(AstNode* nodep) { if (debug() >= 9) nodep->dumpTree(cout, " bshft_old: "); - AstConst* andConstp = VN_AS(VN_AS(nodep, And)->lhsp(), Const); - AstNode* fromp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->lhsp()->unlinkFrBack(); - AstConst* shiftConstp = VN_AS(VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->rhsp(), Const); + AstConst* const andConstp = VN_AS(VN_AS(nodep, And)->lhsp(), Const); + AstNode* const fromp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->lhsp()->unlinkFrBack(); + AstConst* const shiftConstp + = VN_AS(VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->rhsp(), Const); V3Number val(andConstp, andConstp->width()); val.opShiftL(andConstp->num(), shiftConstp->num()); - AstAnd* newp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), val), fromp); + AstAnd* const newp + = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), val), fromp); // widthMin no longer applicable if different C-expanded width newp->dtypeSetLogicSized(nodep->width(), VSigning::UNSIGNED); nodep->replaceWith(newp); @@ -2158,7 +2163,7 @@ private: // Run it - may be unoptimizable due to large for loop, etc simvis.mainParamEmulate(nodep); if (!simvis.optimizable()) { - AstNode* errorp = simvis.whyNotNodep(); + const AstNode* errorp = simvis.whyNotNodep(); if (!errorp) errorp = nodep; nodep->v3error("Expecting expression to be constant, but can't determine constant for " << nodep->prettyTypeName() << '\n' @@ -2167,10 +2172,10 @@ private: VL_DO_DANGLING(replaceZero(nodep), nodep); } else { // Fetch the result - AstNode* valuep = simvis.fetchValueNull(nodep); // valuep is owned by Simulate + AstNode* const valuep = simvis.fetchValueNull(nodep); // valuep is owned by Simulate UASSERT_OBJ(valuep, nodep, "No value returned from simulation"); // Replace it - AstNode* newp = valuep->cloneTree(false); + AstNode* const newp = valuep->cloneTree(false); newp->dtypeFrom(nodep); newp->fileline(nodep->fileline()); UINFO(4, "Simulate->" << newp << endl); @@ -2227,12 +2232,12 @@ private: int operandConcatMove(AstConcat* nodep) { // CONCAT under concat (See moveConcat) // Return value: true indicates to do it; 2 means move to LHS - AstConcat* const abConcp = VN_CAST(nodep->lhsp(), Concat); - AstConcat* const bcConcp = VN_CAST(nodep->rhsp(), Concat); + const AstConcat* const abConcp = VN_CAST(nodep->lhsp(), Concat); + const AstConcat* const bcConcp = VN_CAST(nodep->rhsp(), Concat); if (!abConcp && !bcConcp) return 0; if (bcConcp) { - AstNode* ap = nodep->lhsp(); - AstNode* bp = bcConcp->lhsp(); + AstNode* const ap = nodep->lhsp(); + AstNode* const bp = bcConcp->lhsp(); // If a+b == 32,64,96 etc, then we want to have a+b together on LHS if (VL_BITBIT_I(ap->width() + bp->width()) == 0) return 2; // Transform 2: to abConc } else { // abConcp @@ -2250,12 +2255,12 @@ private: // like that, so on 32 bit boundaries, we'll do the opposite form. UINFO(4, "Move concat: " << nodep << endl); if (operandConcatMove(nodep) > 1) { - AstNode* ap = nodep->lhsp()->unlinkFrBack(); - AstConcat* bcConcp = VN_AS(nodep->rhsp(), Concat); + AstNode* const ap = nodep->lhsp()->unlinkFrBack(); + AstConcat* const bcConcp = VN_AS(nodep->rhsp(), Concat); bcConcp->unlinkFrBack(); - AstNode* bp = bcConcp->lhsp()->unlinkFrBack(); - AstNode* cp = bcConcp->rhsp()->unlinkFrBack(); - AstConcat* abConcp = new AstConcat(bcConcp->fileline(), ap, bp); + AstNode* const bp = bcConcp->lhsp()->unlinkFrBack(); + AstNode* const cp = bcConcp->rhsp()->unlinkFrBack(); + AstConcat* const abConcp = new AstConcat(bcConcp->fileline(), ap, bp); nodep->lhsp(abConcp); nodep->rhsp(cp); // If bp was a concat, then we have this exact same form again! @@ -2263,12 +2268,12 @@ private: if (operandConcatMove(abConcp)) moveConcat(abConcp); VL_DO_DANGLING(bcConcp->deleteTree(), bcConcp); } else { - AstConcat* abConcp = VN_AS(nodep->lhsp(), Concat); + AstConcat* const abConcp = VN_AS(nodep->lhsp(), Concat); abConcp->unlinkFrBack(); - AstNode* ap = abConcp->lhsp()->unlinkFrBack(); - AstNode* bp = abConcp->rhsp()->unlinkFrBack(); - AstNode* cp = nodep->rhsp()->unlinkFrBack(); - AstConcat* bcConcp = new AstConcat(abConcp->fileline(), bp, cp); + AstNode* const ap = abConcp->lhsp()->unlinkFrBack(); + AstNode* const bp = abConcp->rhsp()->unlinkFrBack(); + AstNode* const cp = nodep->rhsp()->unlinkFrBack(); + AstConcat* const bcConcp = new AstConcat(abConcp->fileline(), bp, cp); nodep->lhsp(ap); nodep->rhsp(bcConcp); if (operandConcatMove(bcConcp)) moveConcat(bcConcp); @@ -2290,10 +2295,10 @@ private: void replaceLogEq(AstLogEq* nodep) { // LOGEQ(a,b) => AstLogAnd{AstLogOr{AstLogNot{a},b},AstLogOr{AstLogNot{b},a}} - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); // Do exactly as IEEE says, might result in extra terms, so in future may do differently - AstLogAnd* newp = new AstLogAnd( + AstLogAnd* const newp = new AstLogAnd( nodep->fileline(), new AstLogOr(nodep->fileline(), new AstLogNot(nodep->fileline(), lhsp), rhsp), new AstLogOr(nodep->fileline(), @@ -2306,11 +2311,11 @@ private: void replaceSelSel(AstSel* nodep) { // SEL(SEL({x},a,b),c,d) => SEL({x},a+c,d) - AstSel* belowp = VN_AS(nodep->fromp(), Sel); - AstNode* fromp = belowp->fromp()->unlinkFrBack(); - AstNode* widthp = nodep->widthp()->unlinkFrBack(); - AstNode* lsb1p = nodep->lsbp()->unlinkFrBack(); - AstNode* lsb2p = belowp->lsbp()->unlinkFrBack(); + AstSel* const belowp = VN_AS(nodep->fromp(), Sel); + AstNode* const fromp = belowp->fromp()->unlinkFrBack(); + AstNode* const widthp = nodep->widthp()->unlinkFrBack(); + AstNode* const lsb1p = nodep->lsbp()->unlinkFrBack(); + AstNode* const lsb2p = belowp->lsbp()->unlinkFrBack(); // Eliminate lower range UINFO(4, "Elim Lower range: " << nodep << endl); AstNode* newlsbp; @@ -2327,31 +2332,32 @@ private: newlsbp->dtypeFrom(lsb2p); // Unsigned VN_AS(newlsbp, Add)->rhsp()->dtypeFrom(lsb2p); } - AstSel* newp = new AstSel(nodep->fileline(), fromp, newlsbp, widthp); + AstSel* const newp = new AstSel(nodep->fileline(), fromp, newlsbp, widthp); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } void replaceSelConcat(AstSel* nodep) { // SEL(CONCAT(a,b),c,d) => SEL(a or b, . .) - AstConcat* conp = VN_AS(nodep->fromp(), Concat); - AstNode* conLhsp = conp->lhsp(); - AstNode* conRhsp = conp->rhsp(); + AstConcat* const conp = VN_AS(nodep->fromp(), Concat); + AstNode* const conLhsp = conp->lhsp(); + AstNode* const conRhsp = conp->rhsp(); if (static_cast(nodep->lsbConst()) >= conRhsp->width()) { conLhsp->unlinkFrBack(); - AstSel* newp = new AstSel(nodep->fileline(), conLhsp, - nodep->lsbConst() - conRhsp->width(), nodep->widthConst()); + AstSel* const newp + = new AstSel(nodep->fileline(), conLhsp, nodep->lsbConst() - conRhsp->width(), + nodep->widthConst()); nodep->replaceWith(newp); } else if (static_cast(nodep->msbConst()) < conRhsp->width()) { conRhsp->unlinkFrBack(); - AstSel* newp + AstSel* const newp = new AstSel(nodep->fileline(), conRhsp, nodep->lsbConst(), nodep->widthConst()); nodep->replaceWith(newp); } else { // Yuk, split between the two conRhsp->unlinkFrBack(); conLhsp->unlinkFrBack(); - AstConcat* newp + AstConcat* const newp = new AstConcat(nodep->fileline(), new AstSel(nodep->fileline(), conLhsp, 0, nodep->msbConst() - conRhsp->width() + 1), @@ -2364,11 +2370,11 @@ private: bool operandSelReplicate(AstSel* nodep) { // SEL(REPLICATE(from,rep),lsb,width) => SEL(from,0,width) as long // as SEL's width <= b's width - AstReplicate* repp = VN_AS(nodep->fromp(), Replicate); - AstNode* fromp = repp->lhsp(); - AstConst* lsbp = VN_CAST(nodep->lsbp(), Const); + AstReplicate* const repp = VN_AS(nodep->fromp(), Replicate); + AstNode* const fromp = repp->lhsp(); + AstConst* const lsbp = VN_CAST(nodep->lsbp(), Const); if (!lsbp) return false; - AstNode* widthp = nodep->widthp(); + AstNode* const widthp = nodep->widthp(); if (!VN_IS(widthp, Const)) return false; UASSERT_OBJ(fromp->width(), nodep, "Not widthed"); if ((lsbp->toUInt() / fromp->width()) @@ -2378,7 +2384,7 @@ private: // fromp->unlinkFrBack(); widthp->unlinkFrBack(); - AstSel* newp + AstSel* const newp = new AstSel(nodep->fileline(), fromp, new AstConst(lsbp->fileline(), lsbp->toUInt() % fromp->width()), widthp); newp->dtypeFrom(nodep); @@ -2388,17 +2394,17 @@ private: } bool operandRepRep(AstReplicate* nodep) { // REPLICATE(REPLICATE2(from2,cnt2),cnt1) => REPLICATE(from2,(cnt1+cnt2)) - AstReplicate* rep2p = VN_AS(nodep->lhsp(), Replicate); - AstNode* from2p = rep2p->lhsp(); - AstConst* cnt1p = VN_CAST(nodep->rhsp(), Const); + AstReplicate* const rep2p = VN_AS(nodep->lhsp(), Replicate); + AstNode* const from2p = rep2p->lhsp(); + AstConst* const cnt1p = VN_CAST(nodep->rhsp(), Const); if (!cnt1p) return false; - AstConst* cnt2p = VN_CAST(rep2p->rhsp(), Const); + AstConst* const cnt2p = VN_CAST(rep2p->rhsp(), Const); if (!cnt2p) return false; // from2p->unlinkFrBack(); cnt1p->unlinkFrBack(); cnt2p->unlinkFrBack(); - AstReplicate* newp + AstReplicate* const newp = new AstReplicate(nodep->fileline(), from2p, cnt1p->toUInt() * cnt2p->toUInt()); newp->dtypeFrom(nodep); nodep->replaceWith(newp); @@ -2415,13 +2421,13 @@ private: AstNode* from2p = nodep->rhsp(); uint32_t cnt2 = 1; if (VN_IS(from1p, Replicate)) { - AstConst* cnt1p = VN_CAST(VN_CAST(from1p, Replicate)->rhsp(), Const); + AstConst* const cnt1p = VN_CAST(VN_CAST(from1p, Replicate)->rhsp(), Const); if (!cnt1p) return false; from1p = VN_AS(from1p, Replicate)->lhsp(); cnt1 = cnt1p->toUInt(); } if (VN_IS(from2p, Replicate)) { - AstConst* cnt2p = VN_CAST(VN_CAST(from2p, Replicate)->rhsp(), Const); + AstConst* const cnt2p = VN_CAST(VN_CAST(from2p, Replicate)->rhsp(), Const); if (!cnt2p) return false; from2p = VN_AS(from2p, Replicate)->lhsp(); cnt2 = cnt2p->toUInt(); @@ -2429,7 +2435,7 @@ private: if (!operandsSame(from1p, from2p)) return false; // from1p->unlinkFrBack(); - AstReplicate* newp = new AstReplicate(nodep->fileline(), from1p, cnt1 + cnt2); + AstReplicate* const newp = new AstReplicate(nodep->fileline(), from1p, cnt1 + cnt2); newp->dtypeFrom(nodep); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -2437,13 +2443,13 @@ private: } void replaceSelIntoBiop(AstSel* nodep) { // SEL(BUFIF1(a,b),1,bit) => BUFIF1(SEL(a,1,bit),SEL(b,1,bit)) - AstNodeBiop* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeBiop); + AstNodeBiop* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeBiop); UASSERT_OBJ(fromp, nodep, "Called on non biop"); - AstNode* lsbp = nodep->lsbp()->unlinkFrBack(); - AstNode* widthp = nodep->widthp()->unlinkFrBack(); + AstNode* const lsbp = nodep->lsbp()->unlinkFrBack(); + AstNode* const widthp = nodep->widthp()->unlinkFrBack(); // - AstNode* bilhsp = fromp->lhsp()->unlinkFrBack(); - AstNode* birhsp = fromp->rhsp()->unlinkFrBack(); + AstNode* const bilhsp = fromp->lhsp()->unlinkFrBack(); + AstNode* const birhsp = fromp->rhsp()->unlinkFrBack(); // fromp->lhsp( new AstSel(nodep->fileline(), bilhsp, lsbp->cloneTree(true), widthp->cloneTree(true))); @@ -2454,12 +2460,12 @@ private: } void replaceSelIntoUniop(AstSel* nodep) { // SEL(NOT(a),1,bit) => NOT(SEL(a,bit)) - AstNodeUniop* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeUniop); + AstNodeUniop* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeUniop); UASSERT_OBJ(fromp, nodep, "Called on non biop"); - AstNode* lsbp = nodep->lsbp()->unlinkFrBack(); - AstNode* widthp = nodep->widthp()->unlinkFrBack(); + AstNode* const lsbp = nodep->lsbp()->unlinkFrBack(); + AstNode* const widthp = nodep->widthp()->unlinkFrBack(); // - AstNode* bilhsp = fromp->lhsp()->unlinkFrBack(); + AstNode* const bilhsp = fromp->lhsp()->unlinkFrBack(); // fromp->lhsp(new AstSel(nodep->fileline(), bilhsp, lsbp, widthp)); fromp->dtypeFrom(nodep); @@ -2489,7 +2495,7 @@ private: if (!m_selp) { nodep->v3error("Illegal assignment of constant to unpacked array"); } else { - AstNode* fromp = nodep->fromp()->unlinkFrBack(); + AstNode* const fromp = nodep->fromp()->unlinkFrBack(); nodep->replaceWith(fromp); if (VN_IS(fromp->dtypep()->skipRefp(), NodeArrayDType)) { // Strip off array to find what array references @@ -2508,7 +2514,7 @@ private: if (m_doV && nodep->varp()->valuep() && !m_attrp) { // if (debug()) valuep->dumpTree(cout, " visitvaref: "); iterateAndNextNull(nodep->varp()->valuep()); // May change nodep->varp()->valuep() - AstNode* valuep = nodep->varp()->valuep(); + AstNode* const valuep = nodep->varp()->valuep(); if (nodep->access().isReadOnly() && ((!m_params // Can reduce constant wires into equations && m_doNConst @@ -2524,9 +2530,9 @@ private: VL_DO_DANGLING(replaceNum(nodep, num), nodep); did = true; } else if (m_selp && VN_IS(valuep, InitArray)) { - AstInitArray* initarp = VN_AS(valuep, InitArray); - uint32_t bit = m_selp->bitConst(); - AstNode* itemp = initarp->getIndexDefaultedValuep(bit); + AstInitArray* const initarp = VN_AS(valuep, InitArray); + const uint32_t bit = m_selp->bitConst(); + AstNode* const itemp = initarp->getIndexDefaultedValuep(bit); if (VN_IS(itemp, Const)) { const V3Number& num = VN_AS(itemp, Const)->num(); // UINFO(2,"constVisit "<cloneTree(false); + AstNode* const newp = valuep->cloneTree(false); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); did = true; } else if (nodep->varp()->isParam() && VN_IS(valuep, Unbounded)) { - AstNode* newp = valuep->cloneTree(false); + AstNode* const newp = valuep->cloneTree(false); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); did = true; @@ -2568,7 +2574,7 @@ private: iterateAndNextNull(nodep->itemp()->valuep()); nodep->itemp()->user4(false); } - if (AstConst* valuep = VN_CAST(nodep->itemp()->valuep(), Const)) { + if (AstConst* const valuep = VN_CAST(nodep->itemp()->valuep(), Const)) { const V3Number& num = valuep->num(); VL_DO_DANGLING(replaceNum(nodep, num), nodep); did = true; @@ -2607,7 +2613,7 @@ private: } } else if (m_doNConst && VN_IS(nodep->sensp(), Not)) { // V3Gate may propagate NOTs into clocks... Just deal with it - AstNode* sensp = nodep->sensp(); + AstNode* const sensp = nodep->sensp(); AstNode* lastSensp = sensp; bool invert = false; while (VN_IS(lastSensp, Not)) { @@ -2616,7 +2622,7 @@ private: } UINFO(8, "senItem(NOT...) " << nodep << " " << invert << endl); if (invert) nodep->edgeType(nodep->edgeType().invert()); - AstNodeVarRef* senvarp = VN_AS(lastSensp->unlinkFrBack(), NodeVarRef); + AstNodeVarRef* const senvarp = VN_AS(lastSensp->unlinkFrBack(), NodeVarRef); UASSERT_OBJ(senvarp, sensp, "Non-varref sensitivity variable"); sensp->replaceWith(senvarp); VL_DO_DANGLING(sensp->deleteTree(), sensp); @@ -2685,7 +2691,7 @@ private: for (AstSenItem *nextp, *senp = nodep->sensesp(); senp; senp = nextp) { nextp = VN_AS(senp->nextp(), SenItem); // cppcheck-suppress unassignedVariable // cppcheck bug - SenItemCmp cmp; + const SenItemCmp cmp; if (nextp && !cmp(senp, nextp)) { // Something's out of order, sort it senp = nullptr; @@ -2752,7 +2758,7 @@ private: virtual void visit(AstAssignW* nodep) override { iterateChildren(nodep); if (m_doNConst && replaceNodeAssign(nodep)) return; - AstNodeVarRef* varrefp = VN_CAST( + AstNodeVarRef* const varrefp = VN_CAST( nodep->lhsp(), VarRef); // Not VarXRef, as different refs may set different values to each hierarchy if (m_wremove && !m_params && m_doNConst && m_modp && operandConst(nodep->rhsp()) @@ -2764,14 +2770,14 @@ private: // ASSIGNW (VARREF, const) -> INITIAL ( ASSIGN (VARREF, const) ) UINFO(4, "constAssignW " << nodep << endl); // Make a initial assignment - AstNode* exprp = nodep->rhsp()->unlinkFrBack(); + AstNode* const exprp = nodep->rhsp()->unlinkFrBack(); varrefp->unlinkFrBack(); - AstInitial* newinitp = new AstInitial( + AstInitial* const newinitp = new AstInitial( nodep->fileline(), new AstAssign(nodep->fileline(), varrefp, exprp)); m_modp->addStmtp(newinitp); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); // Set the initial value right in the variable so we can constant propagate - AstNode* initvaluep = exprp->cloneTree(false); + AstNode* const initvaluep = exprp->cloneTree(false); varrefp->varp()->valuep(initvaluep); } } @@ -2779,7 +2785,7 @@ private: virtual void visit(AstNodeIf* nodep) override { iterateChildren(nodep); if (m_doNConst) { - if (const AstConst* constp = VN_CAST(nodep->condp(), Const)) { + if (const AstConst* const constp = VN_CAST(nodep->condp(), Const)) { AstNode* keepp = nullptr; if (constp->isZero()) { UINFO(4, "IF(0,{any},{x}) => {x}: " << nodep << endl); @@ -2808,8 +2814,8 @@ private: } } else if (!afterComment(nodep->ifsp())) { UINFO(4, "IF({x}) nullptr {...} => IF(NOT{x}}: " << nodep << endl); - AstNode* condp = nodep->condp(); - AstNode* elsesp = nodep->elsesp(); + AstNode* const condp = nodep->condp(); + AstNode* const elsesp = nodep->elsesp(); condp->unlinkFrBackWithNext(); elsesp->unlinkFrBackWithNext(); if (nodep->ifsp()) { // Must have been comment @@ -2822,10 +2828,11 @@ private: || VN_IS(nodep->condp(), LogNot)) && nodep->ifsp() && nodep->elsesp()) { UINFO(4, "IF(NOT {x}) => IF(x) swapped if/else" << nodep << endl); - AstNode* condp = VN_AS(nodep->condp(), NodeUniop)->lhsp()->unlinkFrBackWithNext(); - AstNode* ifsp = nodep->ifsp()->unlinkFrBackWithNext(); - AstNode* elsesp = nodep->elsesp()->unlinkFrBackWithNext(); - AstIf* ifp = new AstIf(nodep->fileline(), condp, elsesp, ifsp); + AstNode* const condp + = VN_AS(nodep->condp(), NodeUniop)->lhsp()->unlinkFrBackWithNext(); + AstNode* const ifsp = nodep->ifsp()->unlinkFrBackWithNext(); + AstNode* const elsesp = nodep->elsesp()->unlinkFrBackWithNext(); + AstIf* const ifp = new AstIf(nodep->fileline(), condp, elsesp, ifsp); ifp->branchPred(nodep->branchPred().invert()); nodep->replaceWith(ifp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -2833,12 +2840,12 @@ private: UINFO( 4, "IF({a}) ASSIGN({b},{c}) else ASSIGN({b},{d}) => ASSIGN({b}, {a}?{c}:{d})\n"); - AstNodeAssign* ifp = VN_AS(nodep->ifsp(), NodeAssign); - AstNodeAssign* elsep = VN_AS(nodep->elsesp(), NodeAssign); + AstNodeAssign* const ifp = VN_AS(nodep->ifsp(), NodeAssign); + AstNodeAssign* const elsep = VN_AS(nodep->elsesp(), NodeAssign); ifp->unlinkFrBack(); - AstNode* condp = nodep->condp()->unlinkFrBack(); - AstNode* truep = ifp->rhsp()->unlinkFrBack(); - AstNode* falsep = elsep->rhsp()->unlinkFrBack(); + AstNode* const condp = nodep->condp()->unlinkFrBack(); + AstNode* const truep = ifp->rhsp()->unlinkFrBack(); + AstNode* const falsep = elsep->rhsp()->unlinkFrBack(); ifp->rhsp(new AstCond(truep->fileline(), condp, truep, falsep)); nodep->replaceWith(ifp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -2846,10 +2853,10 @@ private: // without due to short-circuiting && operandIfIf(nodep)) { UINFO(9, "IF({a}) IF({b}) => IF({a} && {b})" << endl); - AstNodeIf* lowerIfp = VN_AS(nodep->ifsp(), NodeIf); - AstNode* condp = nodep->condp()->unlinkFrBack(); - AstNode* lowerIfsp = lowerIfp->ifsp()->unlinkFrBackWithNext(); - AstNode* lowerCondp = lowerIfp->condp()->unlinkFrBackWithNext(); + AstNodeIf* const lowerIfp = VN_AS(nodep->ifsp(), NodeIf); + AstNode* const condp = nodep->condp()->unlinkFrBack(); + AstNode* const lowerIfsp = lowerIfp->ifsp()->unlinkFrBackWithNext(); + AstNode* const lowerCondp = lowerIfp->condp()->unlinkFrBackWithNext(); nodep->condp(new AstLogAnd(lowerIfp->fileline(), condp, lowerCondp)); lowerIfp->replaceWith(lowerIfsp); VL_DO_DANGLING(lowerIfp->deleteTree(), lowerIfp); @@ -2867,7 +2874,7 @@ private: bool stmtDisplayDisplay(AstDisplay* nodep) { // DISPLAY(SFORMAT(text1)),DISPLAY(SFORMAT(text2)) -> DISPLAY(SFORMAT(text1+text2)) if (!m_modp) return false; // Don't optimize under single statement - AstDisplay* prevp = VN_CAST(nodep->backp(), Display); + AstDisplay* const prevp = VN_CAST(nodep->backp(), Display); if (!prevp) return false; if (!((prevp->displayType() == nodep->displayType()) || (prevp->displayType() == AstDisplayType::DT_WRITE @@ -2880,9 +2887,9 @@ private: return false; if (!prevp->fmtp() || prevp->fmtp()->nextp() || !nodep->fmtp() || nodep->fmtp()->nextp()) return false; - AstSFormatF* pformatp = prevp->fmtp(); + AstSFormatF* const pformatp = prevp->fmtp(); if (!pformatp) return false; - AstSFormatF* nformatp = nodep->fmtp(); + AstSFormatF* const nformatp = nodep->fmtp(); if (!nformatp) return false; // We don't merge scopeNames as can have only one and might be different scopes (late in // process) Also rare for real code to print %m multiple times in same message @@ -2951,7 +2958,7 @@ private: break; default: // Most operators, just move to next argument if (argp) { - AstNode* nextp = argp->nextp(); + AstNode* const nextp = argp->nextp(); if (VN_IS(argp, Const)) { // Convert it const string out = VN_AS(argp, Const)->num().displayed(nodep, fmt); UINFO(9, " DispConst: " << fmt << " -> " << out << " for " @@ -3059,7 +3066,7 @@ private: // If last statement in a jump label we have JumpLabel(...., JumpGo) // Often caused by "return" in a Verilog function. The Go is pointless, remove. if (!nodep->nextp()) { - if (AstJumpBlock* aboveBlockp = VN_CAST(nodep->abovep(), JumpBlock)) { + if (AstJumpBlock* const aboveBlockp = VN_CAST(nodep->abovep(), JumpBlock)) { if (aboveBlockp == nodep->labelp()->blockp()) { if (aboveBlockp->endStmtsp() == nodep->labelp()) { UINFO(4, "JUMPGO => last remove " << nodep << endl); @@ -3501,7 +3508,7 @@ AstNode* V3Const::constifyParamsEdit(AstNode* nodep) { // Make sure we've sized everything first nodep = V3Width::widthParamsEdit(nodep); ConstVisitor visitor{ConstVisitor::PROC_PARAMS, /* globalPass: */ false}; - if (AstVar* varp = VN_CAST(nodep, Var)) { + if (AstVar* const varp = VN_CAST(nodep, Var)) { // If a var wants to be constified, it's really a param, and // we want the value to be constant. We aren't passed just the // init value because we need widthing above to handle the var's type. @@ -3531,7 +3538,7 @@ AstNode* V3Const::constifyGenerateParamsEdit(AstNode* nodep) { // Make sure we've sized everything first nodep = V3Width::widthGenerateParamsEdit(nodep); ConstVisitor visitor{ConstVisitor::PROC_GENERATE, /* globalPass: */ false}; - if (AstVar* varp = VN_CAST(nodep, Var)) { + if (AstVar* const varp = VN_CAST(nodep, Var)) { // If a var wants to be constified, it's really a param, and // we want the value to be constant. We aren't passed just the // init value because we need widthing above to handle the var's type. diff --git a/src/V3Coverage.cpp b/src/V3Coverage.cpp index 3f822259d..8e0415bba 100644 --- a/src/V3Coverage.cpp +++ b/src/V3Coverage.cpp @@ -43,7 +43,7 @@ private: using LinenoSet = std::set; struct ToggleEnt { - string m_comment; // Comment for coverage dump + const string m_comment; // Comment for coverage dump AstNode* m_varRefp; // How to get to this element AstNode* m_chgRefp; // How to get to this element ToggleEnt(const string& comment, AstNode* vp, AstNode* cp) @@ -209,7 +209,7 @@ private: // VISITORS - BOTH virtual void visit(AstNodeModule* nodep) override { - AstNodeModule* const origModp = m_modp; + const AstNodeModule* const origModp = m_modp; VL_RESTORER(m_modp); VL_RESTORER(m_state); { @@ -245,9 +245,9 @@ private: linesCov(m_state, nodep), 0, traceNameForLine(nodep, "block")); if (AstNodeProcedure* const itemp = VN_CAST(nodep, NodeProcedure)) { itemp->addStmtp(newp); - } else if (AstNodeFTask* itemp = VN_CAST(nodep, NodeFTask)) { + } else if (AstNodeFTask* const itemp = VN_CAST(nodep, NodeFTask)) { itemp->addStmtsp(newp); - } else if (AstWhile* itemp = VN_CAST(nodep, While)) { + } else if (AstWhile* const itemp = VN_CAST(nodep, While)) { itemp->addBodysp(newp); } else { nodep->v3fatalSrc("Bad node type"); @@ -324,7 +324,7 @@ private: } else { toggleVarBottom(above, varp); } - } else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { + } else if (const AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) { for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) { const int index_code = index_docs - adtypep->lo(); ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]", @@ -336,9 +336,9 @@ private: chgVarp); newent.cleanup(); } - } else if (AstPackArrayDType* adtypep = VN_CAST(dtypep, PackArrayDType)) { + } else if (const AstPackArrayDType* const adtypep = VN_CAST(dtypep, PackArrayDType)) { for (int index_docs = adtypep->lo(); index_docs <= adtypep->hi(); ++index_docs) { - AstNodeDType* const subtypep = adtypep->subDTypep()->skipRefp(); + const AstNodeDType* const subtypep = adtypep->subDTypep()->skipRefp(); const int index_code = index_docs - adtypep->lo(); ToggleEnt newent(above.m_comment + string("[") + cvtToStr(index_docs) + "]", new AstSel(varp->fileline(), above.m_varRefp->cloneTree(true), @@ -349,7 +349,7 @@ private: chgVarp); newent.cleanup(); } - } else if (AstStructDType* adtypep = VN_CAST(dtypep, StructDType)) { + } else if (const AstStructDType* const adtypep = VN_CAST(dtypep, StructDType)) { // For now it's packed, so similar to array for (AstMemberDType* itemp = adtypep->membersp(); itemp; itemp = VN_AS(itemp->nextp(), MemberDType)) { @@ -363,9 +363,9 @@ private: toggleVarRecurse(subtypep, depth + 1, newent, varp, chgVarp); newent.cleanup(); } - } else if (AstUnionDType* adtypep = VN_CAST(dtypep, UnionDType)) { + } else if (const AstUnionDType* const adtypep = VN_CAST(dtypep, UnionDType)) { // Arbitrarily handle only the first member of the union - if (AstMemberDType* const itemp = adtypep->membersp()) { + if (const AstMemberDType* const itemp = adtypep->membersp()) { AstNodeDType* const subtypep = itemp->subDTypep()->skipRefp(); ToggleEnt newent(above.m_comment + string(".") + itemp->name(), above.m_varRefp->cloneTree(true), diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 1ee856172..1a2fc6be7 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -382,7 +382,7 @@ private: for (AstVarScope* vscp : m_vscsp) { if (vscp->user1() == 0) { UINFO(4, " Dead " << vscp << endl); - std::pair eqrange + const std::pair eqrange = m_assignMap.equal_range(vscp); for (AssignMap::iterator itr = eqrange.first; itr != eqrange.second; ++itr) { AstNodeAssign* const assp = itr->second; diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 1f7aa2c32..d1e2b80ca 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -89,7 +89,7 @@ private: // STATE AstActive* m_activep = nullptr; // Current activate - AstCFunc* m_cfuncp = nullptr; // Current public C Function + const AstCFunc* m_cfuncp = nullptr; // Current public C Function AstAssignDly* m_nextDlyp = nullptr; // Next delayed assignment in a list of assignments bool m_inDly = false; // True in delayed assignments bool m_inLoop = false; // True in for loops @@ -106,7 +106,7 @@ private: if (blocking) nodep->user5(true); AstVarScope* const vscp = nodep->varScopep(); // UINFO(4, " MVU " << blocking << " " << nodep << endl); - AstNode* const lastrefp = vscp->user5p(); + const AstNode* const lastrefp = vscp->user5p(); if (!lastrefp) { vscp->user5p(nodep); } else { @@ -275,7 +275,7 @@ private: // vval = constant, can just push constant into where we use it valreadp = nodep->rhsp()->unlinkFrBack(); } else { - string valvarname + const string valvarname = (string("__Vdlyvval__") + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); AstVarScope* const valvscp = createVarSc(varrefp->varScopep(), valvarname, 0, nodep->rhsp()->dtypep()); @@ -295,7 +295,7 @@ private: setvscp = VN_AS(nodep->user3p(), VarScope); ++m_statSharedSet; } else { // Create new one - string setvarname + const string setvarname = (string("__Vdlyvset__") + oldvarp->shortName() + "__v" + cvtToStr(modVecNum)); setvscp = createVarSc(varrefp->varScopep(), setvarname, 1, nullptr); setinitp = new AstAssignPre(nodep->fileline(), diff --git a/src/V3DepthBlock.cpp b/src/V3DepthBlock.cpp index 2fcaaab91..e0461f9ef 100644 --- a/src/V3DepthBlock.cpp +++ b/src/V3DepthBlock.cpp @@ -37,8 +37,8 @@ private: // NODE STATE // STATE - AstNodeModule* m_modp = nullptr; // Current module - AstCFunc* m_cfuncp = nullptr; // Current function + const AstNodeModule* m_modp = nullptr; // Current module + const AstCFunc* m_cfuncp = nullptr; // Current function int m_depth = 0; // How deep in an expression int m_deepNum = 0; // How many functions made @@ -94,9 +94,9 @@ private: if (m_depth > v3Global.opt.compLimitBlocks() && !VN_IS(nodep, NodeCCall)) { // Already done UINFO(4, "DeepBlocks " << m_depth << " " << nodep << endl); - const AstNode* backp = nodep->backp(); // Only for debug + const AstNode* const backp = nodep->backp(); // Only for debug if (debug() >= 9) backp->dumpTree(cout, "- pre : "); - AstCFunc* funcp = createDeepFunc(nodep); + AstCFunc* const funcp = createDeepFunc(nodep); iterate(funcp); if (debug() >= 9) backp->dumpTree(cout, "- post: "); if (debug() >= 9) funcp->dumpTree(cout, "- func: "); diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index a8f75006f..567875def 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -110,7 +110,7 @@ private: AstCFunc* const topFuncp = it->second; auto nextIt1 = it; ++nextIt1; - bool moreOfSame1 = (nextIt1 != m_modFuncs.end() && nextIt1->first == name); + const bool moreOfSame1 = (nextIt1 != m_modFuncs.end() && nextIt1->first == name); if (moreOfSame1) { // Multiple functions under this name, need a wrapper function UINFO(6, " Wrapping " << name << " multifuncs\n"); diff --git a/src/V3EmitCBase.cpp b/src/V3EmitCBase.cpp index 2dc5f5ea7..cc98971b9 100644 --- a/src/V3EmitCBase.cpp +++ b/src/V3EmitCBase.cpp @@ -220,7 +220,7 @@ void EmitCBaseVisitor::emitVarDecl(const AstVar* nodep, bool asRef) { void EmitCBaseVisitor::emitModCUse(const AstNodeModule* modp, VUseType useType) { string nl; for (AstNode* itemp = modp->stmtsp(); itemp; itemp = itemp->nextp()) { - if (AstCUse* usep = VN_CAST(itemp, CUse)) { + if (AstCUse* const usep = VN_CAST(itemp, CUse)) { if (usep->useType() == useType) { if (usep->useType().isInclude()) { puts("#include \"" + prefixNameProtect(usep) + ".h\"\n"); @@ -238,7 +238,7 @@ void EmitCBaseVisitor::emitModCUse(const AstNodeModule* modp, VUseType useType) void EmitCBaseVisitor::emitTextSection(const AstNodeModule* modp, AstType type) { int last_line = -999; for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstNodeText* textp = VN_CAST(nodep, NodeText)) { + if (const AstNodeText* const textp = VN_CAST(nodep, NodeText)) { if (nodep->type() == type) { if (last_line != nodep->fileline()->lineno()) { if (last_line < 0) { diff --git a/src/V3EmitCConstInit.h b/src/V3EmitCConstInit.h index 40233ef37..0c2b680f1 100644 --- a/src/V3EmitCConstInit.h +++ b/src/V3EmitCConstInit.h @@ -72,7 +72,7 @@ protected: virtual void visit(AstConst* nodep) override { const V3Number& num = nodep->num(); UASSERT_OBJ(!num.isFourState(), nodep, "4-state value in constant pool"); - AstNodeDType* const dtypep = nodep->dtypep(); + const AstNodeDType* const dtypep = nodep->dtypep(); if (num.isString()) { // Note: putsQuoted does not track indentation, so we use this instead puts("\""); diff --git a/src/V3EmitCFunc.cpp b/src/V3EmitCFunc.cpp index 55280e201..b60eca2db 100644 --- a/src/V3EmitCFunc.cpp +++ b/src/V3EmitCFunc.cpp @@ -202,7 +202,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) { puts("VL_FSCANF_IX("); iterate(dispp->filep()); puts(","); - } else if (const AstSScanF* dispp = VN_CAST(nodep, SScanF)) { + } else if (const AstSScanF* const dispp = VN_CAST(nodep, SScanF)) { isStmt = false; checkMaxWords(dispp->fromp()); puts("VL_SSCANF_I"); @@ -212,7 +212,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) { puts(","); iterate(dispp->fromp()); puts(","); - } else if (const AstDisplay* dispp = VN_CAST(nodep, Display)) { + } else if (const AstDisplay* const dispp = VN_CAST(nodep, Display)) { isStmt = true; if (dispp->filep()) { puts("VL_FWRITEF("); @@ -221,7 +221,7 @@ void EmitCFunc::displayEmit(AstNode* nodep, bool isScan) { } else { puts("VL_WRITEF("); } - } else if (const AstSFormat* dispp = VN_CAST(nodep, SFormat)) { + } else if (const AstSFormat* const dispp = VN_CAST(nodep, SFormat)) { isStmt = true; puts("VL_SFORMAT_X("); puts(cvtToStr(dispp->lhsp()->widthMin())); @@ -315,13 +315,14 @@ void EmitCFunc::displayArg(AstNode* dispp, AstNode** elistp, bool isScan, const } emitDispState.pushArg(fmtLetter, argp, ""); if (fmtLetter == 't' || fmtLetter == '^') { - AstSFormatF* fmtp = nullptr; - if (AstDisplay* const nodep = VN_CAST(dispp, Display)) + const AstSFormatF* fmtp = nullptr; + if (const AstDisplay* const nodep = VN_CAST(dispp, Display)) { fmtp = nodep->fmtp(); - else if (AstSFormat* nodep = VN_CAST(dispp, SFormat)) + } else if (const AstSFormat* const nodep = VN_CAST(dispp, SFormat)) { fmtp = nodep->fmtp(); - else + } else { fmtp = VN_CAST(dispp, SFormatF); + } UASSERT_OBJ(fmtp, dispp, "Use of %t must be under AstDisplay, AstSFormat, or AstSFormatF"); UASSERT_OBJ(!fmtp->timeunit().isNone(), fmtp, "timenunit must be set"); @@ -580,14 +581,14 @@ void EmitCFunc::emitConstant(AstConst* nodep, AstVarRef* assigntop, const string ofp()->printf("%.17e", nodep->num().toDouble()); } } else if (nodep->isQuad()) { - vluint64_t num = nodep->toUQuad(); + const vluint64_t num = nodep->toUQuad(); if (num < 10) { ofp()->printf("%" VL_PRI64 "uULL", num); } else { ofp()->printf("0x%" VL_PRI64 "xULL", num); } } else { - uint32_t num = nodep->toUInt(); + const uint32_t num = nodep->toUInt(); // Only 32 bits - llx + long long here just to appease CPP format warning if (num < 10) { puts(cvtToStr(num)); @@ -620,8 +621,8 @@ void EmitCFunc::emitVarReset(AstVar* varp) { // If a simple CONST value we initialize it using an enum // If an ARRAYINIT we initialize it using an initial block similar to a signal // puts("// parameter "+varp->nameProtect()+" = "+varp->valuep()->name()+"\n"); - } else if (AstInitArray* initarp = VN_CAST(varp->valuep(), InitArray)) { - if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { + } else if (const AstInitArray* const initarp = VN_CAST(varp->valuep(), InitArray)) { + if (AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) { if (initarp->defaultp()) { puts("for (int __Vi=0; __Vi<" + cvtToStr(adtypep->elementsConst())); puts("; ++__Vi) {\n"); @@ -630,7 +631,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) { } const AstInitArray::KeyItemMap& mapr = initarp->map(); for (const auto& itr : mapr) { - AstNode* valuep = itr.second->valuep(); + AstNode* const valuep = itr.second->valuep(); emitSetVarConstant(varNameProtected + "[" + cvtToStr(itr.first) + "]", VN_AS(valuep, Const)); } @@ -645,26 +646,26 @@ void EmitCFunc::emitVarReset(AstVar* varp) { string EmitCFunc::emitVarResetRecurse(const AstVar* varp, const string& varNameProtected, AstNodeDType* dtypep, int depth, const string& suffix) { dtypep = dtypep->skipRefp(); - AstBasicDType* basicp = dtypep->basicp(); + AstBasicDType* const basicp = dtypep->basicp(); // Returns string to do resetting, empty to do nothing (which caller should handle) - if (AstAssocArrayDType* adtypep = VN_CAST(dtypep, AssocArrayDType)) { + if (AstAssocArrayDType* const adtypep = VN_CAST(dtypep, AssocArrayDType)) { // Access std::array as C array const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : ""); return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1, suffix + ".atDefault()" + cvtarray); } else if (VN_IS(dtypep, ClassRefDType)) { return ""; // Constructor does it - } else if (AstDynArrayDType* adtypep = VN_CAST(dtypep, DynArrayDType)) { + } else if (const AstDynArrayDType* const adtypep = VN_CAST(dtypep, DynArrayDType)) { // Access std::array as C array const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : ""); return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1, suffix + ".atDefault()" + cvtarray); - } else if (AstQueueDType* adtypep = VN_CAST(dtypep, QueueDType)) { + } else if (const AstQueueDType* const adtypep = VN_CAST(dtypep, QueueDType)) { // Access std::array as C array const string cvtarray = (adtypep->subDTypep()->isWide() ? ".data()" : ""); return emitVarResetRecurse(varp, varNameProtected, adtypep->subDTypep(), depth + 1, suffix + ".atDefault()" + cvtarray); - } else if (AstUnpackArrayDType* adtypep = VN_CAST(dtypep, UnpackArrayDType)) { + } else if (const AstUnpackArrayDType* const adtypep = VN_CAST(dtypep, UnpackArrayDType)) { UASSERT_OBJ(adtypep->hi() >= adtypep->lo(), varp, "Should have swapped msb & lsb earlier."); const string ivar = string("__Vi") + cvtToStr(depth); @@ -678,7 +679,7 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, const string& varNameP // String's constructor deals with it return ""; } else if (basicp) { - bool zeroit + const bool zeroit = (varp->attrFileDescr() // Zero so we don't do file IO if never $fopen || (basicp && basicp->isZeroInit()) || (v3Global.opt.underlineZero() && !varp->name().empty() && varp->name()[0] == '_') @@ -687,7 +688,7 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, const string& varNameP if (dtypep->isWide()) { // Handle unpacked; not basicp->isWide string out; if (varp->valuep()) { - AstConst* const constp = VN_AS(varp->valuep(), Const); + const AstConst* const constp = VN_AS(varp->valuep(), Const); if (!constp) varp->v3fatalSrc("non-const initializer for variable"); for (int w = 0; w < varp->widthWords(); ++w) { out += varNameProtected + suffix + "[" + cvtToStr(w) + "] = "; @@ -732,8 +733,8 @@ void EmitCFunc::doubleOrDetect(AstChangeDet* changep, bool& gotOne) { } iterateAndNextNull(changep->lhsp()); } else { - AstNode* lhsp = changep->lhsp(); - AstNode* rhsp = changep->rhsp(); + AstNode* const lhsp = changep->lhsp(); + AstNode* const rhsp = changep->rhsp(); UASSERT_OBJ(VN_IS(lhsp, VarRef) || VN_IS(lhsp, ArraySel), changep, "Not ref?"); UASSERT_OBJ(VN_IS(rhsp, VarRef) || VN_IS(rhsp, ArraySel), changep, "Not ref?"); for (int word = 0; word < (changep->lhsp()->isWide() ? changep->lhsp()->widthWords() : 1); diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 4d1c342a3..4fa90a942 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -126,7 +126,7 @@ protected: EmitCLazyDecls m_lazyDecls; // Visitor for emitting lazy declarations bool m_useSelfForThis = false; // Replace "this" with "vlSelf" const AstNodeModule* m_modp = nullptr; // Current module being emitted - AstCFunc* m_cfuncp = nullptr; // Current function being emitted + const AstCFunc* m_cfuncp = nullptr; // Current function being emitted public: // METHODS @@ -229,7 +229,7 @@ public: puts(nodep->nameProtect() + "\\n\"); );\n"); for (AstNode* subnodep = nodep->argsp(); subnodep; subnodep = subnodep->nextp()) { - if (AstVar* varp = VN_CAST(subnodep, Var)) { + if (AstVar* const varp = VN_CAST(subnodep, Var)) { if (varp->isFuncReturn()) emitVarDecl(varp); } } @@ -265,7 +265,7 @@ public: virtual void visit(AstNodeAssign* nodep) override { bool paren = true; bool decind = false; - if (AstSel* selp = VN_CAST(nodep->lhsp(), Sel)) { + if (AstSel* const selp = VN_CAST(nodep->lhsp(), Sel)) { if (selp->widthMin() == 1) { putbs("VL_ASSIGNBIT_"); emitIQW(selp->fromp()); @@ -292,7 +292,7 @@ public: iterateAndNextNull(selp->fromp()); puts(", "); } - } else if (AstGetcRefN* selp = VN_CAST(nodep->lhsp(), GetcRefN)) { + } else if (const AstGetcRefN* const selp = VN_CAST(nodep->lhsp(), GetcRefN)) { iterateAndNextNull(selp->lhsp()); puts(" = "); putbs("VL_PUTC_N("); @@ -300,7 +300,7 @@ public: puts(", "); iterateAndNextNull(selp->rhsp()); puts(", "); - } else if (AstVar* varp = AstVar::scVarRecurse(nodep->lhsp())) { + } else if (AstVar* const varp = AstVar::scVarRecurse(nodep->lhsp())) { putbs("VL_ASSIGN_"); // Set a systemC variable emitScIQW(varp); emitIQW(nodep); @@ -308,7 +308,7 @@ public: puts(cvtToStr(nodep->widthMin()) + ","); iterateAndNextNull(nodep->lhsp()); puts(", "); - } else if (AstVar* varp = AstVar::scVarRecurse(nodep->rhsp())) { + } else if (AstVar* const varp = AstVar::scVarRecurse(nodep->rhsp())) { putbs("VL_ASSIGN_"); // Get a systemC variable emitIQW(nodep); emitScIQW(varp); @@ -348,7 +348,7 @@ public: virtual void visit(AstAssocSel* nodep) override { iterateAndNextNull(nodep->fromp()); putbs(".at("); - AstAssocArrayDType* adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType); + AstAssocArrayDType* const adtypep = VN_AS(nodep->fromp()->dtypep(), AssocArrayDType); UASSERT_OBJ(adtypep, nodep, "Associative select on non-associative type"); if (adtypep->keyDTypep()->isWide()) { emitCvtWideArray(nodep->bitp(), nodep->fromp()); @@ -429,11 +429,11 @@ public: virtual void visit(AstWith* nodep) override { // With uses a C++11 lambda putbs("[=]("); - if (auto* argrefp = nodep->indexArgRefp()) { + if (auto* const argrefp = nodep->indexArgRefp()) { putbs(argrefp->dtypep()->cType(argrefp->nameProtect(), false, false)); puts(","); } - if (auto* argrefp = nodep->valueArgRefp()) { + if (auto* const argrefp = nodep->valueArgRefp()) { putbs(argrefp->dtypep()->cType(argrefp->nameProtect(), false, false)); } // Probably fragile, V3Task may need to convert to a AstCReturn @@ -632,12 +632,12 @@ public: puts(cvtToStr(nodep->memp()->dtypep()->subDTypep()->widthMin())); uint32_t array_lo = 0; { - const AstVarRef* varrefp = VN_CAST(nodep->memp(), VarRef); + const AstVarRef* const varrefp = VN_CAST(nodep->memp(), VarRef); if (!varrefp) { nodep->v3error(nodep->verilogKwd() << " loading non-variable"); } else if (VN_IS(varrefp->varp()->dtypeSkipRefp(), AssocArrayDType)) { // nodep->memp() below will when verilated code is compiled create a C++ template - } else if (const AstUnpackArrayDType* adtypep + } else if (const AstUnpackArrayDType* const adtypep = VN_CAST(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType)) { putbs(", "); puts(cvtToStr(varrefp->varp()->dtypep()->arrayUnpackedElements())); @@ -716,11 +716,11 @@ public: uint32_t array_lo = 0; uint32_t array_size = 0; { - const AstVarRef* varrefp = VN_CAST(nodep->memp(), VarRef); + const AstVarRef* const varrefp = VN_CAST(nodep->memp(), VarRef); if (!varrefp) { nodep->v3error(nodep->verilogKwd() << " loading non-variable"); } else if (VN_CAST(varrefp->varp()->dtypeSkipRefp(), BasicDType)) { - } else if (const AstUnpackArrayDType* adtypep + } else if (const AstUnpackArrayDType* const adtypep = VN_CAST(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType)) { array_lo = adtypep->lo(); array_size = adtypep->elementsConst(); @@ -980,7 +980,7 @@ public: if (nodep->lhsp()->isWide()) { visit(static_cast(nodep)); } else { - AstVarRef* const vrefp = VN_CAST(nodep->lhsp(), VarRef); + const AstVarRef* const vrefp = VN_CAST(nodep->lhsp(), VarRef); const int widthPow2 = vrefp ? vrefp->varp()->dtypep()->widthPow2() : nodep->lhsp()->dtypep()->widthPow2(); UASSERT_OBJ(widthPow2 > 1, nodep, @@ -1064,8 +1064,8 @@ public: virtual void visit(AstStreamL* nodep) override { // Attempt to use a "fast" stream function for slice size = power of 2 if (!nodep->isWide()) { - uint32_t isPow2 = VN_AS(nodep->rhsp(), Const)->num().countOnes() == 1; - uint32_t sliceSize = VN_AS(nodep->rhsp(), Const)->toUInt(); + const uint32_t isPow2 = VN_AS(nodep->rhsp(), Const)->num().countOnes() == 1; + const uint32_t sliceSize = VN_AS(nodep->rhsp(), Const)->toUInt(); if (isPow2 && sliceSize <= (nodep->isQuad() ? sizeof(uint64_t) : sizeof(uint32_t))) { puts("VL_STREAML_FAST_"); emitIQW(nodep); @@ -1077,7 +1077,7 @@ public: puts(","); iterateAndNextNull(nodep->lhsp()); puts(", "); - uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt()); + const uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt()); puts(cvtToStr(rd_log2) + ")"); return; } @@ -1133,7 +1133,7 @@ public: } virtual void visit(AstAddrOfCFunc* nodep) override { // Note: Can be thought to handle more, but this is all that is needed right now - AstCFunc* const funcp = nodep->funcp(); + const AstCFunc* const funcp = nodep->funcp(); UASSERT_OBJ(funcp->isLoose(), nodep, "Cannot take address of non-loose method"); puts("&"); puts(funcNameProtect(funcp)); @@ -1205,7 +1205,7 @@ public: } } virtual void visit(AstCReset* nodep) override { - AstVar* varp = nodep->varrefp()->varp(); + AstVar* const varp = nodep->varrefp()->varp(); emitVarReset(varp); } virtual void visit(AstExecGraph* nodep) override { diff --git a/src/V3EmitCImp.cpp b/src/V3EmitCImp.cpp index 749c74e39..2b471b6f1 100644 --- a/src/V3EmitCImp.cpp +++ b/src/V3EmitCImp.cpp @@ -135,7 +135,7 @@ class EmitCGatherDependencies final : AstNVisitor { public: static const std::set gather(AstCFunc* cfuncp) { - EmitCGatherDependencies visitor{cfuncp}; + const EmitCGatherDependencies visitor{cfuncp}; return std::move(visitor.m_dependencies); } }; @@ -348,7 +348,7 @@ class EmitCImp final : EmitCFunc { // just looking for loading the wrong model VHashSha256 hash; for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* varp = VN_CAST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { hash.insert(varp->name()); hash.insert(varp->dtypep()->width()); } @@ -369,7 +369,7 @@ class EmitCImp final : EmitCFunc { // Save all members for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstVar* varp = VN_CAST(nodep, Var)) { + if (const AstVar* const varp = VN_CAST(nodep, Var)) { if (varp->isIO() && modp->isTop() && optSystemC()) { // System C top I/O doesn't need loading, as the // lower level subinst code does it. @@ -576,7 +576,7 @@ class EmitCTrace final : EmitCFunc { if (m_slow) filename += "__Slow"; filename += ".cpp"; - AstCFile* cfilep = newCFile(filename, m_slow, true /*source*/); + AstCFile* const cfilep = newCFile(filename, m_slow, true /*source*/); cfilep->support(true); if (optSystemC()) { @@ -595,23 +595,23 @@ class EmitCTrace final : EmitCFunc { } bool emitTraceIsScBv(AstTraceInc* nodep) { - const AstVarRef* varrefp = VN_CAST(nodep->declp()->valuep(), VarRef); + const AstVarRef* const varrefp = VN_CAST(nodep->declp()->valuep(), VarRef); if (!varrefp) return false; - AstVar* varp = varrefp->varp(); + AstVar* const varp = varrefp->varp(); return varp->isSc() && varp->isScBv(); } bool emitTraceIsScBigUint(AstTraceInc* nodep) { - const AstVarRef* varrefp = VN_CAST(nodep->declp()->valuep(), VarRef); + const AstVarRef* const varrefp = VN_CAST(nodep->declp()->valuep(), VarRef); if (!varrefp) return false; - AstVar* varp = varrefp->varp(); + AstVar* const varp = varrefp->varp(); return varp->isSc() && varp->isScBigUint(); } bool emitTraceIsScUint(AstTraceInc* nodep) { - const AstVarRef* varrefp = VN_CAST(nodep->declp()->valuep(), VarRef); + const AstVarRef* const varrefp = VN_CAST(nodep->declp()->valuep(), VarRef); if (!varrefp) return false; - AstVar* varp = varrefp->varp(); + AstVar* const varp = varrefp->varp(); return varp->isSc() && varp->isScUint(); } @@ -714,7 +714,7 @@ class EmitCTrace final : EmitCFunc { if (v3Global.opt.traceFormat().fst()) { // Skip over refs-to-refs, but stop before final ref so can get data type name // Alternatively back in V3Width we could push enum names from upper typedefs - if (AstEnumDType* enump = VN_CAST(nodep->skipRefToEnump(), EnumDType)) { + if (AstEnumDType* const enump = VN_CAST(nodep->skipRefToEnump(), EnumDType)) { int enumNum = enump->user1(); if (!enumNum) { enumNum = ++m_enumNum; @@ -734,7 +734,7 @@ class EmitCTrace final : EmitCFunc { puts("= {"); for (AstEnumItem* itemp = enump->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), EnumItem)) { - AstConst* constp = VN_AS(itemp->valuep(), Const); + AstConst* const constp = VN_AS(itemp->valuep(), Const); if (++nvals > 1) puts(", "); putbs("\"" + constp->num().displayed(nodep, "%0b") + "\""); } @@ -785,7 +785,7 @@ class EmitCTrace final : EmitCFunc { void emitTraceValue(AstTraceInc* nodep, int arrayindex) { if (AstVarRef* const varrefp = VN_CAST(nodep->valuep(), VarRef)) { - AstVar* varp = varrefp->varp(); + AstVar* const varp = varrefp->varp(); puts("("); if (emitTraceIsScBigUint(nodep)) { puts("(vluint32_t*)"); @@ -882,7 +882,7 @@ public: void V3EmitC::emitcImp() { UINFO(2, __FUNCTION__ << ": " << endl); // Make parent module pointers available. - EmitCParentModule emitCParentModule; + const EmitCParentModule emitCParentModule; // Process each module in turn for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) { @@ -903,12 +903,12 @@ void V3EmitC::emitcFiles() { UINFO(2, __FUNCTION__ << ": " << endl); for (AstNodeFile* filep = v3Global.rootp()->filesp(); filep; filep = VN_AS(filep->nextp(), NodeFile)) { - AstCFile* cfilep = VN_CAST(filep, CFile); + AstCFile* const cfilep = VN_CAST(filep, CFile); if (cfilep && cfilep->tblockp()) { V3OutCFile of(cfilep->name()); of.puts("// DESCR" "IPTION: Verilator generated C++\n"); - EmitCFunc visitor(cfilep->tblockp(), &of, true); + const EmitCFunc visitor(cfilep->tblockp(), &of, true); } } } diff --git a/src/V3EmitCMake.cpp b/src/V3EmitCMake.cpp index d8b2170aa..dbad11203 100644 --- a/src/V3EmitCMake.cpp +++ b/src/V3EmitCMake.cpp @@ -199,7 +199,7 @@ class CMakeEmitter final { *of << "# User .cpp files (from .cpp's on Verilator command line)\n"; cmake_set_raw(*of, name + "_USER_CLASSES", deslash(cmake_list(v3Global.opt.cppFiles()))); - if (const V3HierBlockPlan* planp = v3Global.hierPlanp()) { + if (const V3HierBlockPlan* const planp = v3Global.hierPlanp()) { *of << "# Verilate hierarchical blocks\n"; // Sorted hierarchical blocks in order of leaf-first. const V3HierBlockPlan::HierVector& hierBlocks = planp->hierBlocksSorted(); @@ -260,5 +260,5 @@ public: void V3EmitCMake::emit() { UINFO(2, __FUNCTION__ << ": " << endl); - CMakeEmitter emitter; + const CMakeEmitter emitter; } diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 26495020f..82ef2a97e 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -136,7 +136,7 @@ class EmitCModel final : public EmitCFunc { puts("\n"); ofp()->putsPrivate(false); // public: puts("// API METHODS\n"); - string callEvalEndStep + const string callEvalEndStep = (v3Global.needTraceDumper() && !optSystemC()) ? "eval_end_step(); " : ""; if (optSystemC()) { ofp()->putsPrivate(true); ///< eval() is invoked by our sensitive() calls. @@ -190,7 +190,7 @@ class EmitCModel final : public EmitCFunc { std::vector funcps; for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstCFunc* funcp = VN_CAST(nodep, CFunc)) { + if (const AstCFunc* const funcp = VN_CAST(nodep, CFunc)) { if (!funcp->dpiExportDispatcher()) continue; funcps.push_back(funcp); } @@ -422,7 +422,7 @@ class EmitCModel final : public EmitCFunc { + "(vlSymsp);\n"); if (v3Global.opt.threads() == 1) { - uint32_t mtaskId = 0; + const uint32_t mtaskId = 0; putsDecoration("// MTask " + cvtToStr(mtaskId) + " start\n"); puts("VL_DEBUG_IF(VL_DBG_MSGF(\"MTask" + cvtToStr(mtaskId) + " starting\\n\"););\n"); puts("Verilated::mtaskId(" + cvtToStr(mtaskId) + ");\n"); diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index b2e0f2942..d66d4fa67 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -38,9 +38,9 @@ class EmitCSyms final : EmitCBaseVisitor { // TYPES struct ScopeData { - string m_symName; - string m_prettyName; - int m_timeunit; + const string m_symName; + const string m_prettyName; + const int m_timeunit; string m_type; ScopeData(const string& symName, const string& prettyName, int timeunit, const string& type) @@ -59,13 +59,13 @@ class EmitCSyms final : EmitCBaseVisitor { , m_modp{modp} {} }; struct ScopeVarData { - string m_scopeName; - string m_varBasePretty; + const string m_scopeName; + const string m_varBasePretty; AstVar* const m_varp; - AstNodeModule* const m_modp; + const AstNodeModule* const m_modp; AstScope* const m_scopep; ScopeVarData(const string& scopeName, const string& varBasePretty, AstVar* varp, - AstNodeModule* modp, AstScope* scopep) + const AstNodeModule* modp, AstScope* scopep) : m_scopeName{scopeName} , m_varBasePretty{varBasePretty} , m_varp{varp} @@ -104,7 +104,7 @@ class EmitCSyms final : EmitCBaseVisitor { ScopeNames m_vpiScopeCandidates; // All scopes for VPI ScopeNameHierarchy m_vpiScopeHierarchy; // The actual hierarchy of scopes int m_coverBins = 0; // Coverage bin number - bool m_dpiHdrOnly; // Only emit the DPI header + const bool m_dpiHdrOnly; // Only emit the DPI header int m_numStmts = 0; // Number of statements output int m_funcNum = 0; // CFunc split function number V3OutCFile* m_ofpBase = nullptr; // Base (not split) C file @@ -197,7 +197,7 @@ class EmitCSyms final : EmitCBaseVisitor { const AstNodeModule* const smodp = itsc->second; for (std::vector::iterator it = m_modVars.begin(); it != m_modVars.end(); ++it) { - AstNodeModule* const modp = it->first; + const AstNodeModule* const modp = it->first; AstVar* const varp = it->second; if (modp == smodp) { // Need to split the module + var name into the @@ -208,7 +208,7 @@ class EmitCSyms final : EmitCBaseVisitor { string scpName; string varBase; if (whole.substr(0, 10) == "__DOT__TOP") whole.replace(0, 10, ""); - string::size_type dpos = whole.rfind("__DOT__"); + const string::size_type dpos = whole.rfind("__DOT__"); if (dpos != string::npos) { scpName = whole.substr(0, dpos); varBase = whole.substr(dpos + strlen("__DOT__")); @@ -245,7 +245,7 @@ class EmitCSyms final : EmitCBaseVisitor { if (above.substr(0, 4) == "TOP.") above.replace(0, 4, ""); while (!above.empty()) { - string::size_type pos = above.rfind("__"); + const string::size_type pos = above.rfind("__"); if (pos == string::npos) break; above.resize(pos); if (m_vpiScopeHierarchy.find(above) != m_vpiScopeHierarchy.end()) { @@ -552,7 +552,7 @@ void EmitCSyms::checkSplit(bool usesVfinal) { v3Global.useParallelBuild(true); m_numStmts = 0; - string filename + const string filename = v3Global.opt.makeDir() + "/" + symClassName() + "__" + cvtToStr(++m_funcNum) + ".cpp"; AstCFile* const cfilep = newCFile(filename, true /*slow*/, true /*source*/); cfilep->support(true); @@ -637,7 +637,7 @@ void EmitCSyms::emitScopeHier(bool destroy) { void EmitCSyms::emitSymImp() { UINFO(6, __FUNCTION__ << ": " << endl); const string filename = v3Global.opt.makeDir() + "/" + symClassName() + ".cpp"; - AstCFile* cfilep = newCFile(filename, true /*slow*/, true /*source*/); + AstCFile* const cfilep = newCFile(filename, true /*slow*/, true /*source*/); cfilep->support(true); if (v3Global.opt.systemC()) { @@ -747,7 +747,7 @@ void EmitCSyms::emitSymImp() { for (const V3GraphVertex* vxp = v3Global.rootp()->execGraphp()->depGraphp()->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - ExecMTask* mtp = dynamic_cast(const_cast(vxp)); + ExecMTask* const mtp = dynamic_cast(const_cast(vxp)); puts("_vm_profiler.addCounter(" + cvtToStr(mtp->profilerId()) + ", \"" + mtp->hashName() + "\");\n"); } @@ -789,8 +789,8 @@ void EmitCSyms::emitSymImp() { puts("// Setup each module's pointer back to symbol table (for public functions)\n"); for (const auto& i : m_scopes) { - AstScope* scopep = i.first; - AstNodeModule* modp = i.second; + AstScope* const scopep = i.first; + AstNodeModule* const modp = i.second; checkSplit(false); // first is used by AstCoverDecl's call to __vlCoverInsert const bool first = !modp->user1(); @@ -824,9 +824,9 @@ void EmitCSyms::emitSymImp() { m_ofpBase->puts("// Setup export functions\n"); m_ofpBase->puts("for (int __Vfinal=0; __Vfinal<2; __Vfinal++) {\n"); for (auto it = m_scopeFuncs.begin(); it != m_scopeFuncs.end(); ++it) { - AstScopeName* scopep = it->second.m_scopep; - AstCFunc* funcp = it->second.m_cfuncp; - AstNodeModule* modp = it->second.m_modp; + AstScopeName* const scopep = it->second.m_scopep; + AstCFunc* const funcp = it->second.m_cfuncp; + AstNodeModule* const modp = it->second.m_modp; if (funcp->dpiExportImpl()) { checkSplit(true); puts(protect("__Vscope_" + scopep->scopeSymName()) + ".exportInsert(__Vfinal, "); @@ -843,14 +843,14 @@ void EmitCSyms::emitSymImp() { // Someday. For now public isn't common. for (auto it = m_scopeVars.begin(); it != m_scopeVars.end(); ++it) { checkSplit(true); - AstScope* scopep = it->second.m_scopep; - AstVar* varp = it->second.m_varp; + AstScope* const scopep = it->second.m_scopep; + AstVar* const varp = it->second.m_varp; // int pwidth = 1; int pdim = 0; int udim = 0; string bounds; - if (AstBasicDType* basicp = varp->basicp()) { + if (AstBasicDType* const basicp = varp->basicp()) { // Range is always first, it's not in "C" order if (basicp->isRanged()) { bounds += " ,"; @@ -863,7 +863,7 @@ void EmitCSyms::emitSymImp() { for (AstNodeDType* dtypep = varp->dtypep(); dtypep;) { dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node - if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) { + if (const AstNodeArrayDType* const adtypep = VN_CAST(dtypep, NodeArrayDType)) { bounds += " ,"; bounds += cvtToStr(adtypep->left()); bounds += ","; @@ -965,7 +965,7 @@ void EmitCSyms::emitSymImp() { void EmitCSyms::emitDpiHdr() { UINFO(6, __FUNCTION__ << ": " << endl); const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.h"; - AstCFile* cfilep = newCFile(filename, false /*slow*/, false /*source*/); + AstCFile* const cfilep = newCFile(filename, false /*slow*/, false /*source*/); cfilep->support(true); V3OutCFile hf(filename); m_ofp = &hf; @@ -1019,7 +1019,7 @@ void EmitCSyms::emitDpiHdr() { void EmitCSyms::emitDpiImp() { UINFO(6, __FUNCTION__ << ": " << endl); const string filename = v3Global.opt.makeDir() + "/" + topClassName() + "__Dpi.cpp"; - AstCFile* cfilep = newCFile(filename, false /*slow*/, true /*source*/); + AstCFile* const cfilep = newCFile(filename, false /*slow*/, true /*source*/); cfilep->support(true); V3OutCFile hf(filename); m_ofp = &hf; @@ -1053,7 +1053,7 @@ void EmitCSyms::emitDpiImp() { puts("return " + topClassName() + "::" + nodep->name() + "("); string args; for (AstNode* stmtp = nodep->argsp(); stmtp; stmtp = stmtp->nextp()) { - if (const AstVar* portp = VN_CAST(stmtp, Var)) { + if (const AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn()) { if (args != "") args += ", "; args += portp->name(); diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index d74745109..abfb1fdac 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -407,7 +407,7 @@ public: void V3EmitMk::emitmk() { UINFO(2, __FUNCTION__ << ": " << endl); - EmitMk emitter; + const EmitMk emitter; } void V3EmitMk::emitHierVerilation(const V3HierBlockPlan* planp) { diff --git a/src/V3EmitV.cpp b/src/V3EmitV.cpp index 0904bd638..ff043a143 100644 --- a/src/V3EmitV.cpp +++ b/src/V3EmitV.cpp @@ -31,7 +31,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { // MEMBERS bool m_suppressSemi = false; - bool m_suppressUnknown = false; + const bool m_suppressUnknown = false; AstSenTree* m_sensesp; // Domain for printing one a ALWAYS under a ACTIVE // METHODS @@ -650,7 +650,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor { std::vector unpackps; for (AstNodeDType* dtypep = nodep->dtypep(); dtypep;) { dtypep = dtypep->skipRefp(); - if (AstUnpackArrayDType* const unpackp = VN_CAST(dtypep, UnpackArrayDType)) { + if (const AstUnpackArrayDType* const unpackp = VN_CAST(dtypep, UnpackArrayDType)) { unpackps.push_back(unpackp); dtypep = unpackp->subDTypep(); } else { @@ -752,8 +752,8 @@ public: class EmitVPrefixedFormatter final : public V3OutFormatter { std::ostream& m_os; - string m_prefix; // What to print at beginning of each line - int m_flWidth; // Padding of fileline + const string m_prefix; // What to print at beginning of each line + const int m_flWidth; // Padding of fileline int m_column; // Rough location; need just zero or non-zero FileLine* m_prefixFl; // METHODS diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index 3db3f6ad5..e2af26418 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -409,7 +409,7 @@ private: << nodep->fileline()->xmlDetailedLocation() << " name=\"" << nodep->name() << "\"" << " submodname=\"" << nodep->modName() << "\"" << " hier=\"" << m_hier + nodep->name() << "\""; - std::string hier = m_hier; + const std::string hier = m_hier; m_hier += nodep->name() + "."; m_hasChildren = false; iterateChildren(nodep->modp()); @@ -455,10 +455,10 @@ void V3EmitXml::emitxml() { } { std::stringstream sstr; - ModuleFilesXmlVisitor moduleFilesVisitor{v3Global.rootp(), sstr}; - HierCellsXmlVisitor cellsVisitor{v3Global.rootp(), sstr}; + const ModuleFilesXmlVisitor moduleFilesVisitor{v3Global.rootp(), sstr}; + const HierCellsXmlVisitor cellsVisitor{v3Global.rootp(), sstr}; of.puts(sstr.str()); } - EmitXmlFileVisitor visitor{v3Global.rootp(), &of}; + const EmitXmlFileVisitor visitor{v3Global.rootp(), &of}; of.puts("\n"); } diff --git a/src/V3Error.cpp b/src/V3Error.cpp index 2ac31587b..d4bd9e489 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -54,7 +54,7 @@ v3errorIniter v3errorInit; V3ErrorCode::V3ErrorCode(const char* msgp) { // Return error encoding for given string, or ERROR, which is a bad code for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code = V3ErrorCode(codei); if (0 == VL_STRCASECMP(msgp, code.ascii())) { m_e = code; return; @@ -131,7 +131,7 @@ bool V3Error::isError(V3ErrorCode code, bool supp) { } string V3Error::msgPrefix() { - V3ErrorCode code = s_errorCode; + const V3ErrorCode code = s_errorCode; const bool supp = s_errorSuppressed; if (supp) { return "-arning-suppressed: "; diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 2fd3e08f5..64fa466f1 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -678,10 +678,10 @@ private: newp = new AstNegate{fl, lhsp}; } else { UINFO(8, " REPLICATE " << nodep << endl); - const AstConst* constp = VN_AS(nodep->rhsp(), Const); + const AstConst* const constp = VN_AS(nodep->rhsp(), Const); UASSERT_OBJ(constp, nodep, "Replication value isn't a constant. Checked earlier!"); - uint32_t times = constp->toUInt(); + const uint32_t times = constp->toUInt(); if (nodep->isQuad() && !lhsp->isQuad()) { lhsp = new AstCCast{fl, lhsp, nodep}; } newp = lhsp->cloneTree(true); for (unsigned repnum = 1; repnum < times; repnum++) { diff --git a/src/V3File.cpp b/src/V3File.cpp index 6260c61cb..47cc857dd 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -66,9 +66,9 @@ class V3FileDependImp final { // TYPES class DependFile final { // A single file - bool m_target; // True if write, else read + const bool m_target; // True if write, else read bool m_exists = true; - string m_filename; // Filename + const string m_filename; // Filename struct stat m_stat; // Stat information public: DependFile(const string& filename, bool target) @@ -335,7 +335,7 @@ class VInFilterImp final { #ifdef INFILTER_PIPE pid_t m_pid = 0; // fork() process id #else - int m_pid = 0; // fork() process id - always zero as disabled + const int m_pid = 0; // fork() process id - always zero as disabled #endif bool m_pidExited = false; int m_pidStatus = 0; @@ -632,7 +632,7 @@ string V3OutFormatter::indentSpaces(int num) { --num; } *cp++ = '\0'; - string st(str); + string st{str}; // No const, move optimization return st; } @@ -1053,7 +1053,7 @@ public: private: void trySep(const string& old, string::size_type start, const string& trySep, string::size_type& posr, string& separatorr) { - string::size_type trypos = old.find(trySep, start); + const string::size_type trypos = old.find(trySep, start); if (trypos != string::npos) { if (posr == string::npos || (posr > trypos)) { posr = trypos; diff --git a/src/V3File.h b/src/V3File.h index 08abc7607..409c6dff4 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -113,8 +113,8 @@ public: private: // MEMBERS - string m_filename; - Language m_lang; // Indenting Verilog code + const string m_filename; + const Language m_lang; // Indenting Verilog code int m_blockIndent; // Characters per block indent int m_commaWidth; // Width after which to break at ,'s int m_lineno = 1; diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index f05e004eb..6a5bc2660 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -101,9 +101,9 @@ void VFileContent::pushText(const string& text) { // Insert line-by-line string::size_type line_start = 0; while (true) { - string::size_type line_end = leftover.find('\n', line_start); + const string::size_type line_end = leftover.find('\n', line_start); if (line_end != string::npos) { - string oneline(leftover, line_start, line_end - line_start + 1); + const string oneline(leftover, line_start, line_end - line_start + 1); m_lines.push_back(oneline); // Keeps newline UINFO(9, "PushStream[ct" << m_id << "+" << (m_lines.size() - 1) << "]: " << oneline); line_start = line_end + 1; @@ -148,7 +148,7 @@ FileLine::FileLine(FileLine::EmptySecret) { m_warnOn = 0; for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code = V3ErrorCode(codei); warnOff(code, code.defaultsOff()); } } @@ -264,8 +264,8 @@ string FileLine::filebasenameNoExt() const { } string FileLine::firstColumnLetters() const { - char a = ((firstColumn() / 26) % 26) + 'a'; - char b = (firstColumn() % 26) + 'a'; + const char a = ((firstColumn() / 26) % 26) + 'a'; + const char b = (firstColumn() % 26) + 'a'; return string(1, a) + string(1, b); } @@ -297,7 +297,7 @@ std::ostream& operator<<(std::ostream& os, FileLine* fileline) { } bool FileLine::warnOff(const string& msg, bool flag) { - V3ErrorCode code(msg.c_str()); + const V3ErrorCode code(msg.c_str()); if (code < V3ErrorCode::EC_FIRST_WARN) { return false; } else { @@ -308,14 +308,14 @@ bool FileLine::warnOff(const string& msg, bool flag) { void FileLine::warnLintOff(bool flag) { for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code = V3ErrorCode(codei); if (code.lintError()) warnOff(code, flag); } } void FileLine::warnStyleOff(bool flag) { for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code = V3ErrorCode(codei); if (code.styleError()) warnOff(code, flag); } } @@ -334,7 +334,7 @@ bool FileLine::warnIsOff(V3ErrorCode code) const { void FileLine::modifyStateInherit(const FileLine* fromp) { // Any warnings that are off in "from", become off in "this". for (int codei = V3ErrorCode::EC_MIN; codei < V3ErrorCode::_ENUM_MAX; codei++) { - V3ErrorCode code = V3ErrorCode(codei); + const V3ErrorCode code = V3ErrorCode(codei); if (fromp->warnIsOff(code)) warnOff(code, true); } } @@ -388,7 +388,7 @@ string FileLine::source() const { string FileLine::prettySource() const { string out = source(); // Drop ignore trailing newline - string::size_type pos = out.find('\n'); + const string::size_type pos = out.find('\n'); if (pos != string::npos) out = string(out, 0, pos); // Column tracking counts tabs = 1, so match that when print source return VString::spaceUnprintable(out); diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 49db774bf..b14618cfb 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -166,7 +166,7 @@ public: class GateLogicVertex final : public GateEitherVertex { AstNode* const m_nodep; AstActive* const m_activep; // Under what active; nullptr is ok (under cfunc or such) - bool m_slow; // In slow block + const bool m_slow; // In slow block public: GateLogicVertex(V3Graph* graphp, AstScope* scopep, AstNode* nodep, AstActive* activep, bool slow) @@ -200,7 +200,8 @@ private: AstNode* m_substTreep = nullptr; // What to replace the variable with // STATE bool m_buffersOnly; // Set when we only allow simple buffering, no equations (for clocks) - AstNodeVarRef* m_lhsVarRef = nullptr; // VarRef on lhs of assignment (what we're replacing) + const AstNodeVarRef* m_lhsVarRef + = nullptr; // VarRef on lhs of assignment (what we're replacing) bool m_dedupe; // Set when we use isGateDedupable instead of isGateOptimizable int m_ops = 0; // Operation count @@ -315,7 +316,7 @@ private: V3Graph m_graph; // Scoreboard of var usages/dependencies GateLogicVertex* m_logicVertexp = nullptr; // Current statement being tracked, nullptr=ignored AstScope* m_scopep = nullptr; // Current scope being processed - AstNodeModule* m_modp = nullptr; // Current module + const AstNodeModule* m_modp = nullptr; // Current module AstActive* m_activep = nullptr; // Current active bool m_activeReducible = true; // Is activation block reducible? bool m_inSenItem = false; // Underneath AstSenItem; any varrefs are clocks @@ -568,7 +569,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { AstNode* logicp = logicVertexp->nodep(); if (logicVertexp->reducible()) { // Can we eliminate? - GateOkVisitor okVisitor{logicp, vvertexp->isClock(), false}; + const GateOkVisitor okVisitor{logicp, vvertexp->isClock(), false}; const bool multiInputs = okVisitor.rhsVarRefs().size() > 1; // Was it ok? bool doit = okVisitor.isSimple(); @@ -651,7 +652,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) { } if (removedAllUsages) { // Remove input links - while (V3GraphEdge* edgep = vvertexp->inBeginp()) { + while (V3GraphEdge* const edgep = vvertexp->inBeginp()) { VL_DO_DANGLING(edgep->unlinkDelete(), edgep); } // Clone tree so we remember it for tracing, and keep the pointer @@ -825,7 +826,7 @@ class GateElimVisitor final : public GateBaseVisitor { private: // NODE STATE // STATE - AstVarScope* m_elimVarScp; // Variable being eliminated + const AstVarScope* m_elimVarScp; // Variable being eliminated AstNode* m_replaceTreep; // What to replace the variable with bool m_didReplace; // Did we do any replacements GateDedupeVarVisitor* m_varVisp; // Callback to keep hash up to date @@ -881,7 +882,7 @@ public: void GateVisitor::optimizeElimVar(AstVarScope* varscp, AstNode* substp, AstNode* consumerp) { if (debug() >= 5) consumerp->dumpTree(cout, " elimUsePre: "); - GateElimVisitor elimVisitor{consumerp, varscp, substp, nullptr}; + const GateElimVisitor elimVisitor{consumerp, varscp, substp, nullptr}; if (elimVisitor.didReplace()) { if (debug() >= 9) consumerp->dumpTree(cout, " elimUseCns: "); // Caution: Can't let V3Const change our handle to consumerp, such as by @@ -978,7 +979,8 @@ public: && node1p->user2p()->type() == node2p->user2p()->type(); } - AstNodeAssign* hashAndFindDupe(AstNodeAssign* assignp, AstNode* extra1p, AstNode* extra2p) { + const AstNodeAssign* hashAndFindDupe(AstNodeAssign* assignp, AstNode* extra1p, + AstNode* extra2p) { // Legal for extra1p/2p to be nullptr, we'll compare with other assigns with extras also // nullptr AstNode* const rhsp = assignp->rhsp(); @@ -1094,7 +1096,7 @@ public: m_dedupable = true; iterate(nodep); if (m_dedupable && m_assignp) { - AstNode* const lhsp = m_assignp->lhsp(); + const AstNode* const lhsp = m_assignp->lhsp(); // Possible todo, handle more complex lhs expressions if (const AstNodeVarRef* const lhsVarRefp = VN_CAST(lhsp, NodeVarRef)) { UASSERT_OBJ(lhsVarRefp->varScopep() == consumerVarScopep, consumerVarScopep, @@ -1141,12 +1143,12 @@ private: AstNodeVarRef* const dupVarRefp = static_cast( vvertexp->iterateInEdges(*this, VNUser(vvertexp)).toNodep()); if (dupVarRefp) { // visit(GateLogicVertex*...) returned match - V3GraphEdge* edgep = vvertexp->inBeginp(); + const V3GraphEdge* edgep = vvertexp->inBeginp(); GateLogicVertex* const lvertexp = static_cast(edgep->fromp()); UASSERT_OBJ(vvertexp->dedupable(), vvertexp->varScp(), "GateLogicVertex* visit should have returned nullptr " "if consumer var vertex is not dedupable."); - GateOkVisitor okVisitor{lvertexp->nodep(), false, true}; + const GateOkVisitor okVisitor{lvertexp->nodep(), false, true}; if (okVisitor.isSimple()) { const AstVarScope* const dupVarScopep = dupVarRefp->varScopep(); GateVarVertex* const dupVvertexp @@ -1169,15 +1171,15 @@ private: if (lvertexp == consumeVertexp) { UINFO(9, "skipping as self-recirculates\n"); } else { - GateElimVisitor elimVisitor(consumerp, vvertexp->varScp(), dupVarRefp, - &m_varVisitor); + const GateElimVisitor elimVisitor(consumerp, vvertexp->varScp(), + dupVarRefp, &m_varVisitor); } outedgep = outedgep->relinkFromp(dupVvertexp); } // Propagate attributes dupVvertexp->propagateAttrClocksFrom(vvertexp); // Remove inputs links - while (V3GraphEdge* inedgep = vvertexp->inBeginp()) { + while (V3GraphEdge* const inedgep = vvertexp->inBeginp()) { VL_DO_DANGLING(inedgep->unlinkDelete(), inedgep); } // replaceAssigns() does the deleteTree on lvertexNodep in a later step @@ -1252,7 +1254,7 @@ class GateMergeAssignsGraphVisitor final : public GateGraphBaseVisitor { private: // NODE STATE AstNodeAssign* m_assignp = nullptr; - AstActive* m_activep = nullptr; + const AstActive* m_activep = nullptr; GateLogicVertex* m_logicvp = nullptr; VDouble0 m_numMergedAssigns; // Statistic tracking @@ -1382,7 +1384,7 @@ void GateVisitor::mergeAssigns() { class GateConcatVisitor final : public GateBaseVisitor { private: // STATE - AstVarScope* m_vscp = nullptr; // Varscope we're trying to find + const AstVarScope* m_vscp = nullptr; // Varscope we're trying to find int m_offset = 0; // Current offset of varscope int m_found_offset = 0; // Found offset of varscope bool m_found = false; // Offset found @@ -1432,7 +1434,7 @@ public: class GateClkDecompState final { public: - int m_offset; + const int m_offset; AstVarScope* const m_last_vsp; GateClkDecompState(int offset, AstVarScope* vsp) : m_offset{offset} @@ -1460,7 +1462,7 @@ private: m_seen_clk_vectors++; m_total_seen_clk_vectors++; } - GateClkDecompState* const currState = reinterpret_cast(vu.c()); + const GateClkDecompState* const currState = reinterpret_cast(vu.c()); GateClkDecompState nextState(currState->m_offset, vsp); vvertexp->iterateCurrentOutEdges(*this, VNUser(&nextState)); if (vsp->varp()->width() > 1) --m_seen_clk_vectors; @@ -1469,13 +1471,13 @@ private: } virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) override { - GateClkDecompState* const currState = reinterpret_cast(vu.c()); + const GateClkDecompState* const currState = reinterpret_cast(vu.c()); int clk_offset = currState->m_offset; if (const AstAssignW* const assignp = VN_CAST(lvertexp->nodep(), AssignW)) { UINFO(9, "CLK DECOMP Logic (off = " << clk_offset << ") - " << lvertexp << " : " << m_clk_vsp << endl); // RHS - if (AstSel* const rselp = VN_CAST(assignp->rhsp(), Sel)) { + if (const AstSel* const rselp = VN_CAST(assignp->rhsp(), Sel)) { if (VN_IS(rselp->lsbp(), Const) && VN_IS(rselp->widthp(), Const)) { if (clk_offset < rselp->lsbConst() || clk_offset > rselp->msbConst()) { UINFO(9, "CLK DECOMP Sel [ " << rselp->msbConst() << " : " @@ -1487,7 +1489,7 @@ private: } else { return VNUser(0); } - } else if (AstConcat* catp = VN_CAST(assignp->rhsp(), Concat)) { + } else if (AstConcat* const catp = VN_CAST(assignp->rhsp(), Concat)) { UINFO(9, "CLK DECOMP Concat searching - " << assignp->lhsp() << endl); int concat_offset; if (!m_concat_visitor.concatOffset(catp, currState->m_last_vsp, @@ -1507,7 +1509,7 @@ private: } else { return VNUser(0); } - } else if (const AstVarRef* vrp = VN_CAST(assignp->lhsp(), VarRef)) { + } else if (const AstVarRef* const vrp = VN_CAST(assignp->lhsp(), VarRef)) { if (vrp->dtypep()->width() == 1 && m_seen_clk_vectors) { if (clk_offset != 0) { UINFO(9, "Should only make it here with clk_offset = 0" << endl); @@ -1517,7 +1519,7 @@ private: UINFO(9, " to - " << m_clk_vsp << endl); AstNode* const rhsp = assignp->rhsp(); rhsp->replaceWith(new AstVarRef(rhsp->fileline(), m_clk_vsp, VAccess::READ)); - while (V3GraphEdge* edgep = lvertexp->inBeginp()) { + while (V3GraphEdge* const edgep = lvertexp->inBeginp()) { VL_DO_DANGLING(edgep->unlinkDelete(), edgep); } new V3GraphEdge(m_graphp, m_clk_vvertexp, lvertexp, 1); @@ -1556,7 +1558,7 @@ void GateVisitor::decomposeClkVectors() { GateClkDecompGraphVisitor decomposer{&m_graph}; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { if (GateVarVertex* const vertp = dynamic_cast(itp)) { - AstVarScope* const vsp = vertp->varScp(); + const AstVarScope* const vsp = vertp->varScp(); if (vsp->varp()->attrClocker() == VVarAttrClocker::CLOCKER_YES) { if (vsp->varp()->width() > 1) { UINFO(9, "Clocker > 1 bit, not decomposing: " << vsp << endl); @@ -1601,7 +1603,7 @@ public: void V3Gate::gateAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - GateVisitor visitor{nodep}; + const GateVisitor visitor{nodep}; GateDeassignVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("gate", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); diff --git a/src/V3GenClk.cpp b/src/V3GenClk.cpp index a530e084d..0e17bb756 100644 --- a/src/V3GenClk.cpp +++ b/src/V3GenClk.cpp @@ -47,7 +47,7 @@ private: const AstUser3InUse m_inuser3; // STATE - AstActive* m_activep = nullptr; // Inside activate statement + const AstActive* m_activep = nullptr; // Inside activate statement AstNodeModule* const m_topModp; // Top module AstScope* const m_scopetopp = v3Global.rootp()->topScopep()->scopep(); // The top AstScope @@ -70,7 +70,7 @@ private: UASSERT_OBJ(vscp != v3Global.rootp()->dpiExportTriggerp(), vscp, "DPI export trigger should not need __VinpClk"); AstVar* const varp = vscp->varp(); - string newvarname + const string newvarname = "__VinpClk__" + vscp->scopep()->nameDotless() + "__" + varp->name(); // Create: VARREF(inpclk) // ... @@ -145,8 +145,8 @@ private: // STATE bool m_tracingCall = false; // Iterating into a call to a cfunc - AstActive* m_activep = nullptr; // Inside activate statement - AstNodeAssign* m_assignp = nullptr; // Inside assigndly statement + const AstActive* m_activep = nullptr; // Inside activate statement + const AstNodeAssign* m_assignp = nullptr; // Inside assigndly statement AstNodeModule* m_topModp = nullptr; // Top module // VISITORS diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index 6cbe5dc65..f16415441 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -327,7 +327,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const { // List of all possible subgraphs std::multimap subgraphs; for (V3GraphVertex* vertexp = verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - string vertexSubgraph + const string vertexSubgraph = (colorAsSubgraph && vertexp->color()) ? cvtToStr(vertexp->color()) : ""; subgraphs.emplace(vertexSubgraph, vertexp); } @@ -341,7 +341,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) const { string subgr; for (auto it = subgraphs.cbegin(); it != subgraphs.cend(); ++it) { const string vertexSubgraph = it->first; - V3GraphVertex* vertexp = it->second; + const V3GraphVertex* vertexp = it->second; numMap[vertexp] = n; if (subgr != vertexSubgraph) { if (subgr != "") *logp << "\t};\n"; diff --git a/src/V3GraphAcyc.cpp b/src/V3GraphAcyc.cpp index 87aeef471..ead5da693 100644 --- a/src/V3GraphAcyc.cpp +++ b/src/V3GraphAcyc.cpp @@ -102,7 +102,8 @@ private: V3Graph m_breakGraph; // Graph with only breakable edges represented V3List m_work; // List of vertices with optimization work left std::vector m_origEdgeDelp; // List of deletions to do when done - V3EdgeFuncP m_origEdgeFuncp; // Function that says we follow this edge (in original graph) + const V3EdgeFuncP + m_origEdgeFuncp; // Function that says we follow this edge (in original graph) uint32_t m_placeStep = 0; // Number that user() must be equal to to indicate processing static int debug() { return V3Graph::debug(); } @@ -223,7 +224,7 @@ void GraphAcyc::buildGraphIterate(V3GraphVertex* overtexp, GraphAcycVertex* aver // Make new edges for (V3GraphEdge* edgep = overtexp->outBeginp(); edgep; edgep = edgep->outNextp()) { if (origFollowEdge(edgep)) { // not cut - V3GraphVertex* toVertexp = edgep->top(); + const V3GraphVertex* toVertexp = edgep->top(); if (toVertexp->color()) { GraphAcycVertex* const toAVertexp = static_cast(toVertexp->userp()); @@ -282,13 +283,13 @@ void GraphAcyc::simplifyNone(GraphAcycVertex* avertexp) { UINFO(9, " SimplifyNoneRemove " << avertexp << endl); avertexp->setDelete(); // Mark so we won't delete it twice // Remove edges - while (V3GraphEdge* edgep = avertexp->outBeginp()) { + while (V3GraphEdge* const edgep = avertexp->outBeginp()) { V3GraphVertex* otherVertexp = edgep->top(); // UINFO(9, " out " << otherVertexp << endl); VL_DO_DANGLING(edgep->unlinkDelete(), edgep); workPush(otherVertexp); } - while (V3GraphEdge* edgep = avertexp->inBeginp()) { + while (V3GraphEdge* const edgep = avertexp->inBeginp()) { V3GraphVertex* otherVertexp = edgep->fromp(); // UINFO(9, " in " << otherVertexp << endl); VL_DO_DANGLING(edgep->unlinkDelete(), edgep); @@ -484,7 +485,7 @@ void GraphAcyc::placeTryEdge(V3GraphEdge* edgep) { // Vertex::m_user begin: number indicates this edge was completed // Try to assign ranks, presuming this edge is in place // If we come across user()==placestep, we've detected a loop and must back out - bool loop + const bool loop = placeIterate(static_cast(edgep->top()), edgep->fromp()->rank() + 1); if (!loop) { // No loop, we can keep it as uncutable diff --git a/src/V3GraphAlg.cpp b/src/V3GraphAlg.cpp index f1e769f97..7ced4a36e 100644 --- a/src/V3GraphAlg.cpp +++ b/src/V3GraphAlg.cpp @@ -31,7 +31,7 @@ // Algorithms - weakly connected components class GraphRemoveRedundant final : GraphAlg<> { - bool m_sumWeights; ///< Sum, rather then maximize weights + const bool m_sumWeights; ///< Sum, rather then maximize weights private: void main() { for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; @@ -213,7 +213,7 @@ private: } void vertexIterate(V3GraphVertex* vertexp) { - uint32_t thisDfsNum = m_currentDfs++; + const uint32_t thisDfsNum = m_currentDfs++; vertexp->user(thisDfsNum); vertexp->color(0); for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { diff --git a/src/V3GraphAlg.h b/src/V3GraphAlg.h index f87936830..d1c0861fd 100644 --- a/src/V3GraphAlg.h +++ b/src/V3GraphAlg.h @@ -30,8 +30,8 @@ template // Or sometimes const V3Graph class GraphAlg VL_NOT_FINAL { protected: - T_Graph* m_graphp; // Graph we're operating upon - V3EdgeFuncP m_edgeFuncp; // Function that says we follow this edge + T_Graph* const m_graphp; // Graph we're operating upon + const V3EdgeFuncP m_edgeFuncp; // Function that says we follow this edge // CONSTRUCTORS GraphAlg(T_Graph* graphp, V3EdgeFuncP edgeFuncp) : m_graphp{graphp} diff --git a/src/V3GraphPathChecker.cpp b/src/V3GraphPathChecker.cpp index 0ee60def4..a33a1d357 100644 --- a/src/V3GraphPathChecker.cpp +++ b/src/V3GraphPathChecker.cpp @@ -74,12 +74,12 @@ GraphPathChecker::~GraphPathChecker() { void GraphPathChecker::initHalfCriticalPaths(GraphWay way, bool checkOnly) { GraphStreamUnordered order(m_graphp, way); const GraphWay rev = way.invert(); - while (const V3GraphVertex* vertexp = order.nextp()) { + while (const V3GraphVertex* const vertexp = order.nextp()) { unsigned critPathCost = 0; for (V3GraphEdge* edgep = vertexp->beginp(rev); edgep; edgep = edgep->nextp(rev)) { if (!m_edgeFuncp(edgep)) continue; - V3GraphVertex* wrelativep = edgep->furtherp(rev); + const V3GraphVertex* wrelativep = edgep->furtherp(rev); const GraphPCNode* const wrelUserp = static_cast(wrelativep->userp()); critPathCost = std::max(critPathCost, wrelUserp->m_cp[way] + 1); } diff --git a/src/V3GraphStream.h b/src/V3GraphStream.h index 85d6ea32c..c465bd1fa 100644 --- a/src/V3GraphStream.h +++ b/src/V3GraphStream.h @@ -44,7 +44,7 @@ private: public: // MEMBERS const V3GraphVertex* m_vxp; // [mtask] Vertex - uint32_t m_pos; // Sort position + const uint32_t m_pos; // Sort position uint32_t m_numBlockingEdges; // Number of blocking edges // CONSTRUCTORS VxHolder(const V3GraphVertex* vxp, uint32_t pos, uint32_t numBlockingEdges) @@ -65,7 +65,7 @@ private: class VxHolderCmp final { public: // MEMBERS - T_Compare m_lessThan; // Sorting functor + const T_Compare m_lessThan; // Sorting functor // CONSTRUCTORS explicit VxHolderCmp(const T_Compare& lessThan) : m_lessThan{lessThan} {} @@ -87,7 +87,7 @@ private: ReadyVertices m_readyVertices; // List of ready vertices std::map m_waitingVertices; // List of waiting vertices typename ReadyVertices::iterator m_last; // Previously returned element - GraphWay m_way; // FORWARD or REVERSE order of traversal + const GraphWay m_way; // FORWARD or REVERSE order of traversal public: // CONSTRUCTORS @@ -106,26 +106,26 @@ public: // Every vertex initially is waiting, or ready. if (way == GraphWay::FORWARD) { if (vxp->inEmpty()) { - VxHolder newVx(vxp, pos++, 0); + const VxHolder newVx(vxp, pos++, 0); m_readyVertices.insert(newVx); } else { uint32_t depCount = 0; for (V3GraphEdge* depp = vxp->inBeginp(); depp; depp = depp->inNextp()) { ++depCount; } - VxHolder newVx(vxp, pos++, depCount); + const VxHolder newVx(vxp, pos++, depCount); m_waitingVertices.emplace(vxp, newVx); } } else { // REVERSE if (vxp->outEmpty()) { - VxHolder newVx(vxp, pos++, 0); + const VxHolder newVx(vxp, pos++, 0); m_readyVertices.insert(newVx); } else { uint32_t depCount = 0; for (V3GraphEdge* depp = vxp->outBeginp(); depp; depp = depp->outNextp()) { ++depCount; } - VxHolder newVx(vxp, pos++, depCount); + const VxHolder newVx(vxp, pos++, depCount); m_waitingVertices.emplace(vxp, newVx); } } @@ -194,7 +194,7 @@ private: void unblockDeps(const V3GraphVertex* vertexp) { if (m_way == GraphWay::FORWARD) { for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - V3GraphVertex* const toVertexp = edgep->top(); + const V3GraphVertex* const toVertexp = edgep->top(); const auto it = m_waitingVertices.find(toVertexp); UASSERT_OBJ(it != m_waitingVertices.end(), toVertexp, @@ -206,7 +206,7 @@ private: } } else { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - V3GraphVertex* const fromVertexp = edgep->fromp(); + const V3GraphVertex* const fromVertexp = edgep->fromp(); const auto it = m_waitingVertices.find(fromVertexp); UASSERT_OBJ(it != m_waitingVertices.end(), fromVertexp, diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index e14297946..aed59ae8a 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -50,7 +50,7 @@ public: // Vertices and nodes class V3GraphTestVertex VL_NOT_FINAL : public V3GraphVertex { - string m_name; + const string m_name; public: V3GraphTestVertex(V3Graph* graphp, const string& name) diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index b40dc8e9a..f520c4a0d 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -496,6 +496,6 @@ V3Hash V3Hasher::operator()(AstNode* nodep) const { } V3Hash V3Hasher::uncachedHash(const AstNode* nodep) { - HasherVisitor visitor{nodep}; + const HasherVisitor visitor{nodep}; return visitor.finalHash(); } diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index 7940e0270..57b781b04 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -210,7 +210,7 @@ string V3HierBlock::vFileIfNecessary() const { } void V3HierBlock::writeCommandArgsFile(bool forCMake) const { - std::unique_ptr of{V3File::new_ofstream(commandArgsFileName(forCMake))}; + const std::unique_ptr of{V3File::new_ofstream(commandArgsFileName(forCMake))}; *of << "--cc\n"; if (!forCMake) { @@ -279,7 +279,7 @@ class HierBlockUsageCollectVisitor final : public AstNVisitor { virtual void visit(AstCell* nodep) override { // Visit used module here to know that the module is hier_block or not. // This visitor behaves almost depth first search - if (AstModule* modp = VN_CAST(nodep->modp(), Module)) { + if (AstModule* const modp = VN_CAST(nodep->modp(), Module)) { iterate(modp); m_referred.insert(modp); } @@ -336,7 +336,7 @@ void V3HierBlockPlan::createPlan(AstNetlist* nodep) { // When processing a hierarchical block, no need to create a plan anymore. if (v3Global.opt.hierChild()) return; - AstNodeModule* modp = nodep->topModulep(); + AstNodeModule* const modp = nodep->topModulep(); if (modp->hierBlock()) { modp->v3warn(HIERBLOCK, "Top module illegally marked hierarchical block, ignoring marking\n" @@ -400,7 +400,8 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const { it->second->writeCommandArgsFile(forCMake); } // For the top module - std::unique_ptr of{V3File::new_ofstream(topCommandArgsFileName(forCMake))}; + const std::unique_ptr of{ + V3File::new_ofstream(topCommandArgsFileName(forCMake))}; if (!forCMake) { // Load wrappers first not to be overwritten by the original HDL for (const_iterator it = begin(); it != end(); ++it) { diff --git a/src/V3HierBlock.h b/src/V3HierBlock.h index b9fac2c58..38b34b4ed 100644 --- a/src/V3HierBlock.h +++ b/src/V3HierBlock.h @@ -49,13 +49,13 @@ private: using StrGParams = std::vector>; // MEMBERS - const AstNodeModule* m_modp; // Hierarchical block module + const AstNodeModule* const m_modp; // Hierarchical block module // Hierarchical blocks that directly or indirectly instantiate this block HierBlockSet m_parents; // Hierarchical blocks that this block directly or indirectly instantiates HierBlockSet m_children; // Parameters that are overridden by #(.param(value)) syntax. - GParams m_gparams; + const GParams m_gparams; // METHODS VL_UNCOPYABLE(V3HierBlock); diff --git a/src/V3Inline.cpp b/src/V3Inline.cpp index 6fdc28ee4..858f6a83d 100644 --- a/src/V3Inline.cpp +++ b/src/V3Inline.cpp @@ -271,7 +271,7 @@ private: // STATE std::unordered_set m_renamedInterfaces; // Name of renamed interface variables AstNodeModule* const m_modp; // Current module - AstCell* const m_cellp; // Cell being cloned + const AstCell* const m_cellp; // Cell being cloned // METHODS VL_DEBUG_FUNC; // Declare debug() @@ -423,7 +423,7 @@ private: break; } // If foo.bar, and foo is an interface, then need to search again for foo - string::size_type pos = tryname.rfind('.'); + const string::size_type pos = tryname.rfind('.'); if (pos == string::npos || pos == 0) { break; } else { diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index fcbf1e743..b98d56303 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -195,7 +195,7 @@ class InstDeVisitor final : public AstNVisitor { private: // STATE // Range for arrayed instantiations, nullptr for normal instantiations - AstRange* m_cellRangep = nullptr; + const AstRange* m_cellRangep = nullptr; int m_instSelNum = 0; // Current instantiation count 0..N-1 InstDeModVarVisitor m_deModVars; // State of variables for current cell module @@ -322,8 +322,10 @@ private: UINFO(4, " PIN " << nodep << endl); const int pinwidth = nodep->modVarp()->width(); const int expwidth = nodep->exprp()->width(); - std::pair pinDim = nodep->modVarp()->dtypep()->dimensions(false); - std::pair expDim = nodep->exprp()->dtypep()->dimensions(false); + const std::pair pinDim + = nodep->modVarp()->dtypep()->dimensions(false); + const std::pair expDim + = nodep->exprp()->dtypep()->dimensions(false); UINFO(4, " PINVAR " << nodep->modVarp() << endl); UINFO(4, " EXP " << nodep->exprp() << endl); UINFO(4, " pinwidth ew=" << expwidth << " pw=" << pinwidth << " ed=" << expDim.first @@ -331,7 +333,7 @@ private: << pinDim.second << endl); if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) { // Connection to array, where array dimensions match the instant dimension - AstRange* const rangep + const AstRange* const rangep = VN_AS(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep(); const int arraySelNum = rangep->littleEndian() ? (rangep->elementsConst() - 1 - m_instSelNum) @@ -366,8 +368,8 @@ private: nodep->v3fatalSrc("Width mismatch; V3Width should have errored out."); } } // end expanding ranged cell - else if (AstArraySel* arrselp = VN_CAST(nodep->exprp(), ArraySel)) { - if (AstUnpackArrayDType* const arrp + else if (AstArraySel* const arrselp = VN_CAST(nodep->exprp(), ArraySel)) { + if (const AstUnpackArrayDType* const arrp = VN_CAST(arrselp->lhsp()->dtypep(), UnpackArrayDType)) { if (!VN_IS(arrp->subDTypep(), IfaceRefDType)) return; // Interface pin attaches to one element of arrayed interface @@ -382,7 +384,7 @@ private: const string index = AstNode::encodeNumber(constp->toSInt()); if (VN_IS(arrselp->lhsp(), SliceSel)) arrselp->lhsp()->v3error("Unsupported: interface slices"); - AstVarRef* const varrefp = VN_CAST(arrselp->lhsp(), VarRef); + const AstVarRef* const varrefp = VN_CAST(arrselp->lhsp(), VarRef); UASSERT_OBJ(varrefp, arrselp, "No interface varref under array"); AstVarXRef* const newp = new AstVarXRef( nodep->fileline(), varrefp->name() + "__BRA__" + index + "__KET__", "", @@ -394,7 +396,8 @@ private: } } else { AstVar* const pinVarp = nodep->modVarp(); - AstUnpackArrayDType* const pinArrp = VN_CAST(pinVarp->dtypep(), UnpackArrayDType); + const AstUnpackArrayDType* const pinArrp + = VN_CAST(pinVarp->dtypep(), UnpackArrayDType); if (!pinArrp || !VN_IS(pinArrp->subDTypep(), IfaceRefDType)) return; // Arrayed pin/var attaches to arrayed submodule lower port/var, expand it AstNode* prevp = nullptr; @@ -402,7 +405,7 @@ private: // Clone the var referenced by the pin, and clone each var referenced by the varref // Clone pin varp: for (int in = 0; in < pinArrp->elementsConst(); ++in) { // 0 = leftmost - int i = pinArrp->left() + in * pinArrp->declRange().leftToRightInc(); + const int i = pinArrp->left() + in * pinArrp->declRange().leftToRightInc(); const string varNewName = pinVarp->name() + "__BRA__" + cvtToStr(i) + "__KET__"; AstVar* varNewp = nullptr; @@ -437,17 +440,18 @@ private: // And replace exprp with a new varxref const AstVarRef* varrefp = VN_CAST(newp->exprp(), VarRef); // Maybe null int expr_i = i; - if (AstSliceSel* const slicep = VN_CAST(newp->exprp(), SliceSel)) { + if (const AstSliceSel* const slicep = VN_CAST(newp->exprp(), SliceSel)) { varrefp = VN_AS(slicep->fromp(), VarRef); UASSERT(VN_IS(slicep->rhsp(), Const), "Slices should be constant"); - int slice_index + const int slice_index = slicep->declRange().left() + in * slicep->declRange().leftToRightInc(); - auto* const exprArrp = VN_AS(varrefp->dtypep(), UnpackArrayDType); + const auto* const exprArrp = VN_AS(varrefp->dtypep(), UnpackArrayDType); UASSERT_OBJ(exprArrp, slicep, "Slice of non-array"); expr_i = slice_index + exprArrp->lo(); } else if (!varrefp) { newp->exprp()->v3error("Unexpected connection to arrayed port"); - } else if (auto* exprArrp = VN_CAST(varrefp->dtypep(), UnpackArrayDType)) { + } else if (const auto* const exprArrp + = VN_CAST(varrefp->dtypep(), UnpackArrayDType)) { expr_i = exprArrp->left() + in * exprArrp->declRange().leftToRightInc(); } @@ -526,10 +530,11 @@ public: return nullptr; } } - AstVarRef* const connectRefp = VN_CAST(pinp->exprp(), VarRef); - AstVarXRef* const connectXRefp = VN_CAST(pinp->exprp(), VarXRef); - AstBasicDType* const pinBasicp = VN_CAST(pinVarp->dtypep(), BasicDType); // Maybe nullptr - AstBasicDType* connBasicp = nullptr; + const AstVarRef* const connectRefp = VN_CAST(pinp->exprp(), VarRef); + const AstVarXRef* const connectXRefp = VN_CAST(pinp->exprp(), VarXRef); + const AstBasicDType* const pinBasicp + = VN_CAST(pinVarp->dtypep(), BasicDType); // Maybe nullptr + const AstBasicDType* connBasicp = nullptr; AstAssignW* assignp = nullptr; if (connectRefp) connBasicp = VN_CAST(connectRefp->varp()->dtypep(), BasicDType); // @@ -554,7 +559,7 @@ public: // if (1 || debug() >= 9) pinp->dumpTree(cout, "-in_pin:"); V3Inst::checkOutputShort(pinp); AstNode* const pinexprp = pinp->exprp()->unlinkFrBack(); - string newvarname + const string newvarname = (string(pinVarp->isWritable() ? "__Vcellout" : "__Vcellinp") // Prevent name conflict if both tri & non-tri add signals + (forTristate ? "t" : "") + "__" + cellp->name() + "__" + pinp->name()); diff --git a/src/V3InstrCount.cpp b/src/V3InstrCount.cpp index 6d1984a7c..750322a2b 100644 --- a/src/V3InstrCount.cpp +++ b/src/V3InstrCount.cpp @@ -41,8 +41,8 @@ private: const AstNode* const m_startNodep; // Start node of count bool m_tracingCall = false; // Iterating into a CCall to a CFunc bool m_inCFunc = false; // Inside AstCFunc - bool m_assertNoDups; // Check for duplicates - std::ostream* m_osp; // Dump file + const bool m_assertNoDups; // Check for duplicates + const std::ostream* m_osp; // Dump file // TYPES // Little class to cleanly call startVisitBase/endVisitBase @@ -102,7 +102,7 @@ private: // Save the count, and add it back in during ~VisitBase This allows // debug prints to show local cost of each subtree, so we can see a // hierarchical view of the cost when in debug mode. - uint32_t savedCount = m_instrCount; + const uint32_t savedCount = m_instrCount; m_instrCount = nodep->instrCount(); return savedCount; } @@ -124,7 +124,7 @@ private: // // Hence, exclude the child of the AstWordSel from the computation, // whose cost scales with the size of the entire (maybe large) vector. - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateAndNextNull(nodep->bitp()); } virtual void visit(AstSel* nodep) override { @@ -132,7 +132,7 @@ private: // is not expensive. Count the cost of the AstSel itself (scales with // its width) and the cost of the lsbp() and widthp() nodes, but not // the fromp() node which could be disproportionately large. - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateAndNextNull(nodep->lsbp()); iterateAndNextNull(nodep->widthp()); } @@ -163,9 +163,9 @@ private: markCost(nodep); } virtual void visit(AstNodeIf* nodep) override { - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateAndNextNull(nodep->condp()); - uint32_t savedCount = m_instrCount; + const uint32_t savedCount = m_instrCount; UINFO(8, "ifsp:\n"); m_instrCount = 0; @@ -190,19 +190,19 @@ private: virtual void visit(AstNodeCond* nodep) override { // Just like if/else above, the ternary operator only evaluates // one of the two expressions, so only count the max. - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateAndNextNull(nodep->condp()); - uint32_t savedCount = m_instrCount; + const uint32_t savedCount = m_instrCount; UINFO(8, "?\n"); m_instrCount = 0; iterateAndNextNull(nodep->expr1p()); - uint32_t ifCount = m_instrCount; + const uint32_t ifCount = m_instrCount; UINFO(8, ":\n"); m_instrCount = 0; iterateAndNextNull(nodep->expr2p()); - uint32_t elseCount = m_instrCount; + const uint32_t elseCount = m_instrCount; if (ifCount < elseCount) { m_instrCount = savedCount + elseCount; @@ -229,7 +229,7 @@ private: UASSERT_OBJ(nodep == m_startNodep, nodep, "Multiple actives, or not start node"); } virtual void visit(AstNodeCCall* nodep) override { - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateChildren(nodep); m_tracingCall = true; iterate(nodep->funcp()); @@ -244,12 +244,12 @@ private: VL_RESTORER(m_inCFunc); { m_inCFunc = true; - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateChildren(nodep); } } virtual void visit(AstNode* nodep) override { - VisitBase vb(this, nodep); + const VisitBase vb{this, nodep}; iterateChildren(nodep); } @@ -294,7 +294,7 @@ private: }; uint32_t V3InstrCount::count(AstNode* nodep, bool assertNoDups, std::ostream* osp) { - InstrCountVisitor visitor{nodep, assertNoDups, osp}; + const InstrCountVisitor visitor{nodep, assertNoDups, osp}; if (osp) InstrCountDumpVisitor dumper(nodep, osp); return visitor.instrCount(); } diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 7d3bca186..3de19778f 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -303,7 +303,7 @@ private: virtual void visit(AstNodeAssign* nodep) override { // Collect any used variables first, as lhs may also be on rhs // Similar code in V3Dead - vluint64_t lastEdit = AstNode::editCountGbl(); // When it was last edited + const vluint64_t lastEdit = AstNode::editCountGbl(); // When it was last edited m_sideEffect = false; iterateAndNextNull(nodep->rhsp()); if (lastEdit != AstNode::editCountGbl()) { diff --git a/src/V3LifePost.cpp b/src/V3LifePost.cpp index 0fb60cdad..8d80d8a64 100644 --- a/src/V3LifePost.cpp +++ b/src/V3LifePost.cpp @@ -186,9 +186,9 @@ private: } void squashAssignposts() { for (auto& itr : m_assignposts) { - LifePostLocation* const app = &itr.second; - AstVarRef* const lhsp = VN_AS(app->nodep->lhsp(), VarRef); // original var - AstVarRef* const rhsp = VN_AS(app->nodep->rhsp(), VarRef); // dly var + const LifePostLocation* const app = &itr.second; + const AstVarRef* const lhsp = VN_AS(app->nodep->lhsp(), VarRef); // original var + const AstVarRef* const rhsp = VN_AS(app->nodep->rhsp(), VarRef); // dly var AstVarScope* const dlyVarp = rhsp->varScopep(); AstVarScope* const origVarp = lhsp->varScopep(); @@ -275,10 +275,10 @@ private: } virtual void visit(AstVarRef* nodep) override { // Consumption/generation of a variable, - AstVarScope* const vscp = nodep->varScopep(); + const AstVarScope* const vscp = nodep->varScopep(); UASSERT_OBJ(vscp, nodep, "Scope not assigned"); - LifeLocation loc(m_execMTaskp, ++m_sequence); + const LifeLocation loc(m_execMTaskp, ++m_sequence); if (nodep->access().isWriteOrRW()) m_writes[vscp].insert(loc); if (nodep->access().isReadOrRW()) m_reads[vscp].insert(loc); } @@ -292,12 +292,12 @@ private: virtual void visit(AstAssignPost* nodep) override { // Don't record ASSIGNPOST in the read/write maps, record them in a // separate map - if (AstVarRef* const rhsp = VN_CAST(nodep->rhsp(), VarRef)) { + if (const AstVarRef* const rhsp = VN_CAST(nodep->rhsp(), VarRef)) { // rhsp is the dly var - AstVarScope* const dlyVarp = rhsp->varScopep(); + const AstVarScope* const dlyVarp = rhsp->varScopep(); UASSERT_OBJ(m_assignposts.find(dlyVarp) == m_assignposts.end(), nodep, "LifePostLocation attempted duplicate dlyvar map addition"); - LifeLocation loc(m_execMTaskp, ++m_sequence); + const LifeLocation loc(m_execMTaskp, ++m_sequence); m_assignposts[dlyVarp] = LifePostLocation(loc, nodep); } } @@ -318,7 +318,7 @@ private: m_mtasksGraphp = nodep->depGraphp(); for (V3GraphVertex* mtaskVxp = m_mtasksGraphp->verticesBeginp(); mtaskVxp; mtaskVxp = mtaskVxp->verticesNextp()) { - ExecMTask* const mtaskp = dynamic_cast(mtaskVxp); + const ExecMTask* const mtaskp = dynamic_cast(mtaskVxp); m_execMTaskp = mtaskp; m_sequence = 0; iterate(mtaskp->bodyp()); diff --git a/src/V3LinkCells.cpp b/src/V3LinkCells.cpp index d9ef034ed..d0d7806b3 100644 --- a/src/V3LinkCells.cpp +++ b/src/V3LinkCells.cpp @@ -113,7 +113,7 @@ private: VSymGraph m_mods; // Symbol table of all module names LinkCellsGraph m_graph; // Linked graph of all cell interconnects LibraryVertex* m_libVertexp = nullptr; // Vertex at root of all libraries - V3GraphVertex* m_topVertexp = nullptr; // Vertex of top module + const V3GraphVertex* m_topVertexp = nullptr; // Vertex of top module std::unordered_set m_declfnWarned; // Files we issued DECLFILENAME on string m_origTopModuleName; // original name of the top module @@ -474,7 +474,7 @@ private: nodep->name(hierIt->first); // Change name of this module to be mangled name // considering parameter } - AstNodeModule* const foundp = findModuleSym(nodep->name()); + const AstNodeModule* const foundp = findModuleSym(nodep->name()); if (foundp && foundp != nodep) { if (!(foundp->fileline()->warnIsOff(V3ErrorCode::MODDUP) || nodep->fileline()->warnIsOff(V3ErrorCode::MODDUP) diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index fc70c4945..6f81421e9 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -249,7 +249,7 @@ public: // // Note we only check for conflicts at the same level; it's ok if one block hides another // We also wouldn't want to not insert it even though it's lower down - VSymEnt* const foundp = lookupSymp->findIdFlat(name); + const VSymEnt* const foundp = lookupSymp->findIdFlat(name); AstNode* const fnodep = foundp ? foundp->nodep() : nullptr; if (!fnodep) { // Not found, will add in a moment. @@ -431,9 +431,9 @@ public: static AstIfaceRefDType* ifaceRefFromArray(AstNodeDType* nodep) { AstIfaceRefDType* ifacerefp = VN_CAST(nodep, IfaceRefDType); if (!ifacerefp) { - if (AstBracketArrayDType* const arrp = VN_CAST(nodep, BracketArrayDType)) { + if (const AstBracketArrayDType* const arrp = VN_CAST(nodep, BracketArrayDType)) { ifacerefp = VN_CAST(arrp->subDTypep(), IfaceRefDType); - } else if (AstUnpackArrayDType* arrp = VN_CAST(nodep, UnpackArrayDType)) { + } else if (const AstUnpackArrayDType* const arrp = VN_CAST(nodep, UnpackArrayDType)) { ifacerefp = VN_CAST(arrp->subDTypep(), IfaceRefDType); } } @@ -441,7 +441,7 @@ public: } void computeIfaceVarSyms() { for (VSymEnt* varSymp : m_ifaceVarSyms) { - AstVar* const varp = varSymp ? VN_AS(varSymp->nodep(), Var) : nullptr; + const AstVar* const varp = varSymp ? VN_AS(varSymp->nodep(), Var) : nullptr; UINFO(9, " insAllIface se" << cvtToHex(varSymp) << " " << varp << endl); AstIfaceRefDType* const ifacerefp = ifaceRefFromArray(varp->subDTypep()); UASSERT_OBJ(ifacerefp, varp, "Non-ifacerefs on list!"); @@ -578,10 +578,11 @@ public: // then look up (inst name or modname) if (firstId) { // Check this module - subcellnames - AstCell* cellp = lookupSymp ? VN_CAST(lookupSymp->nodep(), Cell) - : nullptr; // Replicated below - AstCellInline* inlinep = lookupSymp ? VN_CAST(lookupSymp->nodep(), CellInline) - : nullptr; // Replicated below + const AstCell* cellp = lookupSymp ? VN_CAST(lookupSymp->nodep(), Cell) + : nullptr; // Replicated below + const AstCellInline* inlinep = lookupSymp + ? VN_CAST(lookupSymp->nodep(), CellInline) + : nullptr; // Replicated below if (VSymEnt* const findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) { lookupSymp = findSymp; } @@ -613,7 +614,7 @@ public: if ((cellp && cellp->modp()->origName() == ident) || (inlinep && inlinep->origModName() == ident)) { break; - } else if (VSymEnt* findSymp + } else if (VSymEnt* const findSymp = findWithAltFallback(lookupSymp, ident, altIdent)) { lookupSymp = findSymp; if (crossedCell && VN_IS(lookupSymp->nodep(), Var)) { @@ -636,8 +637,8 @@ public: } } if (lookupSymp) { - if (AstCell* const cellp = VN_CAST(lookupSymp->nodep(), Cell)) { - if (AstNodeModule* const modp = cellp->modp()) { + if (const AstCell* const cellp = VN_CAST(lookupSymp->nodep(), Cell)) { + if (const AstNodeModule* const modp = cellp->modp()) { if (modp->hierBlock()) { refLocationp->v3error("Cannot access inside hierarchical block"); } else if (VN_IS(modp, NotFoundModule)) { @@ -713,8 +714,8 @@ class LinkDotFindVisitor final : public AstNVisitor { VSymEnt* m_modSymp = nullptr; // Symbol Entry for current module VSymEnt* m_curSymp = nullptr; // Symbol Entry for current table, where to lookup/insert string m_scope; // Scope text - AstNodeBlock* m_blockp = nullptr; // Current Begin/end block - AstNodeFTask* m_ftaskp = nullptr; // Current function/task + const AstNodeBlock* m_blockp = nullptr; // Current Begin/end block + const AstNodeFTask* m_ftaskp = nullptr; // Current function/task bool m_inRecursion = false; // Inside a recursive module int m_paramNum = 0; // Parameter number, for position based connection bool m_explicitNew = false; // Hit a "new" function @@ -975,13 +976,13 @@ class LinkDotFindVisitor final : public AstNVisitor { { // Change to appropriate package if extern declaration (vs definition) if (nodep->classOrPackagep()) { - AstClassOrPackageRef* cpackagerefp + AstClassOrPackageRef* const cpackagerefp = VN_CAST(nodep->classOrPackagep(), ClassOrPackageRef); if (!cpackagerefp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: extern function definition with class-in-class"); } else { - AstClass* classp = VN_CAST(cpackagerefp->classOrPackagep(), Class); + AstClass* const classp = VN_CAST(cpackagerefp->classOrPackagep(), Class); if (!classp) { nodep->v3error("Extern declaration's scope is not a defined class"); } else { @@ -1017,8 +1018,9 @@ class LinkDotFindVisitor final : public AstNVisitor { } else { dtypep = new AstBasicDType(nodep->fileline(), AstBasicDTypeKwd::LOGIC); } - AstVar* newvarp = new AstVar(nodep->fileline(), AstVarType::VAR, nodep->name(), - VFlagChildDType(), dtypep); // Not dtype resolved yet + AstVar* const newvarp + = new AstVar(nodep->fileline(), AstVarType::VAR, nodep->name(), + VFlagChildDType(), dtypep); // Not dtype resolved yet newvarp->direction(VDirection::OUTPUT); newvarp->lifetime(VLifetime::AUTOMATIC); newvarp->funcReturn(true); @@ -1045,11 +1047,11 @@ class LinkDotFindVisitor final : public AstNVisitor { } if (!m_statep->forScopeCreation()) { // Find under either a task or the module's vars - VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); + const VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); if (!foundp && m_modSymp && nodep->name() == m_modSymp->nodep()->name()) { foundp = m_modSymp; // Conflicts with modname? } - AstVar* findvarp = foundp ? VN_CAST(foundp->nodep(), Var) : nullptr; + AstVar* const findvarp = foundp ? VN_CAST(foundp->nodep(), Var) : nullptr; bool ins = false; if (!foundp) { ins = true; @@ -1063,7 +1065,7 @@ class LinkDotFindVisitor final : public AstNVisitor { << cvtToHex(foundp->parentp()) << endl); if (foundp->parentp() == m_curSymp // Only when on same level && !foundp->imported()) { // and not from package - bool nansiBad + const bool nansiBad = ((findvarp->isDeclTyped() && nodep->isDeclTyped()) || (findvarp->isIO() && nodep->isIO())); // e.g. !(output && output) const bool ansiBad @@ -1091,11 +1093,12 @@ class LinkDotFindVisitor final : public AstNVisitor { } else { findvarp->combineType(nodep); findvarp->fileline()->modifyStateInherit(nodep->fileline()); - AstBasicDType* bdtypep = VN_CAST(findvarp->childDTypep(), BasicDType); + AstBasicDType* const bdtypep + = VN_CAST(findvarp->childDTypep(), BasicDType); if (bdtypep && bdtypep->implicit()) { // Then have "input foo" and "real foo" so the // dtype comes from the other side. - AstNodeDType* newdtypep = nodep->subDTypep(); + AstNodeDType* const newdtypep = nodep->subDTypep(); UASSERT_OBJ(newdtypep && nodep->childDTypep(), findvarp, "No child type?"); VL_DO_DANGLING(bdtypep->unlinkFrBack()->deleteTree(), bdtypep); @@ -1129,12 +1132,12 @@ class LinkDotFindVisitor final : public AstNVisitor { // We first search if the parameter is overwritten and then replace it with a // new value. It will keep the same FileLine information. if (v3Global.opt.hasParameter(nodep->name())) { - AstVar* newp + AstVar* const newp = new AstVar(nodep->fileline(), AstVarType(AstVarType::GPARAM), nodep->name(), nodep); newp->combineType(nodep); const string svalue = v3Global.opt.parameter(nodep->name()); - if (AstNode* valuep + if (AstNode* const valuep = AstConst::parseParamLiteral(nodep->fileline(), svalue)) { newp->valuep(valuep); UINFO(9, " replace parameter " << nodep << endl); @@ -1145,16 +1148,17 @@ class LinkDotFindVisitor final : public AstNVisitor { } } } - VSymEnt* insp + VSymEnt* const insp = m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_classOrPackagep); if (m_statep->forPrimary() && nodep->isGParam()) { ++m_paramNum; - VSymEnt* symp + VSymEnt* const symp = m_statep->insertSym(m_curSymp, "__paramNumber" + cvtToStr(m_paramNum), nodep, m_classOrPackagep); symp->exported(false); } - AstIfaceRefDType* ifacerefp = LinkDotState::ifaceRefFromArray(nodep->subDTypep()); + AstIfaceRefDType* const ifacerefp + = LinkDotState::ifaceRefFromArray(nodep->subDTypep()); if (ifacerefp) { // Can't resolve until interfaces and modport names are // known; see notes at top @@ -1193,11 +1197,11 @@ class LinkDotFindVisitor final : public AstNVisitor { // EnumItem: Remember its name for later resolution iterateChildren(nodep); // Find under either a task or the module's vars - VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); + const VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); if (!foundp && m_modSymp && nodep->name() == m_modSymp->nodep()->name()) { foundp = m_modSymp; // Conflicts with modname? } - AstEnumItem* findvarp = foundp ? VN_AS(foundp->nodep(), EnumItem) : nullptr; + AstEnumItem* const findvarp = foundp ? VN_AS(foundp->nodep(), EnumItem) : nullptr; bool ins = false; if (!foundp) { ins = true; @@ -1230,13 +1234,13 @@ class LinkDotFindVisitor final : public AstNVisitor { } virtual void visit(AstPackageImport* nodep) override { UINFO(4, " Link: " << nodep << endl); - VSymEnt* srcp = m_statep->getNodeSym(nodep->packagep()); + VSymEnt* const srcp = m_statep->getNodeSym(nodep->packagep()); if (nodep->name() == "*") { if (m_curSymp == m_statep->dunitEntp()) { nodep->v3warn(IMPORTSTAR, "Import::* in $unit scope may pollute global namespace"); } } else { - VSymEnt* impp = srcp->findIdFlat(nodep->name()); + VSymEnt* const impp = srcp->findIdFlat(nodep->name()); if (!impp) { nodep->v3error("Import object not found: '" << nodep->packagep()->prettyName() << "::" << nodep->prettyName() << "'"); @@ -1248,9 +1252,9 @@ class LinkDotFindVisitor final : public AstNVisitor { } virtual void visit(AstPackageExport* nodep) override { UINFO(9, " Link: " << nodep << endl); - VSymEnt* srcp = m_statep->getNodeSym(nodep->packagep()); + VSymEnt* const srcp = m_statep->getNodeSym(nodep->packagep()); if (nodep->name() != "*") { - VSymEnt* impp = srcp->findIdFlat(nodep->name()); + VSymEnt* const impp = srcp->findIdFlat(nodep->name()); if (!impp) { nodep->v3error("Export object not found: '" << nodep->packagep()->prettyName() << "::" << nodep->prettyName() << "'"); @@ -1335,7 +1339,7 @@ private: // *::user4() -> See LinkDotState // STATE - LinkDotState* m_statep; // State to pass between visitors, including symbol table + LinkDotState* const m_statep; // State to pass between visitors, including symbol table AstNodeModule* m_modp = nullptr; // Current module static int debug() { return LinkDotState::debug(); } @@ -1397,18 +1401,18 @@ private: << nodep->warnMore() << "... Suggest use instantiation with #(." << nodep->prettyName() << "(...etc...))"); - VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->path()); - AstCell* cellp = foundp ? VN_AS(foundp->nodep(), Cell) : nullptr; + VSymEnt* const foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->path()); + AstCell* const cellp = foundp ? VN_AS(foundp->nodep(), Cell) : nullptr; if (!cellp) { nodep->v3error("In defparam, instance " << nodep->path() << " never declared"); } else { - AstNode* exprp = nodep->rhsp()->unlinkFrBack(); + AstNode* const exprp = nodep->rhsp()->unlinkFrBack(); UINFO(9, "Defparam cell " << nodep->path() << "." << nodep->name() << " attach-to " << cellp << " <= " << exprp << endl); // Don't need to check the name of the defparam exists. V3Param does. - AstPin* pinp = new AstPin(nodep->fileline(), - -1, // Pin# not relevant - nodep->name(), exprp); + AstPin* const pinp = new AstPin(nodep->fileline(), + -1, // Pin# not relevant + nodep->name(), exprp); cellp->addParamsp(pinp); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } @@ -1417,8 +1421,8 @@ private: // Port: Stash the pin number // Need to set pin numbers after varnames are created // But before we do the final resolution based on names - VSymEnt* foundp = m_statep->getNodeSym(m_modp)->findIdFlat(nodep->name()); - AstVar* refp = foundp ? VN_AS(foundp->nodep(), Var) : nullptr; + VSymEnt* const foundp = m_statep->getNodeSym(m_modp)->findIdFlat(nodep->name()); + AstVar* const refp = foundp ? VN_AS(foundp->nodep(), Var) : nullptr; if (!refp) { nodep->v3error( "Input/output/inout declaration not found for port: " << nodep->prettyNameQ()); @@ -1433,9 +1437,9 @@ private: << refp->warnContextSecondary()); } refp->user4(true); - VSymEnt* symp = m_statep->insertSym(m_statep->getNodeSym(m_modp), - "__pinNumber" + cvtToStr(nodep->pinNum()), refp, - nullptr /*classOrPackagep*/); + VSymEnt* const symp = m_statep->insertSym(m_statep->getNodeSym(m_modp), + "__pinNumber" + cvtToStr(nodep->pinNum()), + refp, nullptr /*classOrPackagep*/); symp->exported(false); refp->pinNum(nodep->pinNum()); } @@ -1453,10 +1457,10 @@ private: // tran gates need implicit creation // As VarRefs don't exist in forPrimary, sanity check UASSERT_OBJ(!m_statep->forPrimary(), nodep, "Assign aliases unexpected pre-dot"); - if (AstVarRef* forrefp = VN_CAST(nodep->lhsp(), VarRef)) { + if (AstVarRef* const forrefp = VN_CAST(nodep->lhsp(), VarRef)) { pinImplicitExprRecurse(forrefp); } - if (AstVarRef* forrefp = VN_CAST(nodep->rhsp(), VarRef)) { + if (AstVarRef* const forrefp = VN_CAST(nodep->rhsp(), VarRef)) { pinImplicitExprRecurse(forrefp); } iterateChildren(nodep); @@ -1468,9 +1472,9 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); } virtual void visit(AstClassOrPackageRef* nodep) override { - if (auto* fwdp = VN_CAST(nodep->classOrPackageNodep(), TypedefFwd)) { + if (auto* const fwdp = VN_CAST(nodep->classOrPackageNodep(), TypedefFwd)) { // Relink forward definitions to the "real" definition - VSymEnt* foundp = m_statep->getNodeSym(fwdp)->findIdFallback(fwdp->name()); + VSymEnt* const foundp = m_statep->getNodeSym(fwdp)->findIdFallback(fwdp->name()); if (foundp && (VN_IS(foundp->nodep(), Class) || VN_IS(foundp->nodep(), Package))) { nodep->classOrPackagep(VN_AS(foundp->nodep(), NodeModule)); } else if (foundp && VN_IS(foundp->nodep(), ParamTypeDType)) { @@ -1490,7 +1494,7 @@ private: iterateChildren(nodep); } virtual void visit(AstTypedefFwd* nodep) override { - VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->name()); + VSymEnt* const foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->name()); if (!foundp && v3Global.opt.pedantic()) { // We only check it was ever really defined in pedantic mode, as it // might have been in a header file referring to a module we never @@ -1521,8 +1525,8 @@ public: class LinkDotScopeVisitor final : public AstNVisitor { // STATE - LinkDotState* m_statep; // State to pass between visitors, including symbol table - AstScope* m_scopep = nullptr; // The current scope + LinkDotState* const m_statep; // State to pass between visitors, including symbol table + const AstScope* m_scopep = nullptr; // The current scope VSymEnt* m_modSymp = nullptr; // Symbol entry for current module static int debug() { return LinkDotState::debug(); } @@ -1547,12 +1551,12 @@ class LinkDotScopeVisitor final : public AstNVisitor { } virtual void visit(AstVarScope* nodep) override { if (!nodep->varp()->isFuncLocal() && !nodep->varp()->isClassMember()) { - VSymEnt* varSymp + VSymEnt* const varSymp = m_statep->insertSym(m_modSymp, nodep->varp()->name(), nodep, nullptr); if (nodep->varp()->isIfaceRef() && nodep->varp()->isIfaceParent()) { UINFO(9, "Iface parent ref var " << nodep->varp()->name() << " " << nodep << endl); // Find the interface cell the var references - AstIfaceRefDType* dtypep + AstIfaceRefDType* const dtypep = LinkDotState::ifaceRefFromArray(nodep->varp()->dtypep()); UASSERT_OBJ(dtypep, nodep, "Non AstIfaceRefDType on isIfaceRef() var"); UINFO(9, "Iface parent dtype " << dtypep << endl); @@ -1567,8 +1571,8 @@ class LinkDotScopeVisitor final : public AstNVisitor { UINFO(5, " Found interface instance: se" << cvtToHex(cellSymp) << " " << cellSymp->nodep() << endl); if (dtypep->modportName() != "") { - VSymEnt* mpSymp = m_statep->findDotted(nodep->fileline(), m_modSymp, - ifcellname, baddot, okSymp); + VSymEnt* const mpSymp = m_statep->findDotted(nodep->fileline(), m_modSymp, + ifcellname, baddot, okSymp); UASSERT_OBJ(mpSymp, nodep, "No symbol for interface modport: " << nodep->prettyNameQ(dtypep->modportName())); @@ -1584,12 +1588,12 @@ class LinkDotScopeVisitor final : public AstNVisitor { } } virtual void visit(AstNodeFTask* nodep) override { - VSymEnt* symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); + VSymEnt* const symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); symp->fallbackp(m_modSymp); // No recursion, we don't want to pick up variables } virtual void visit(AstWith* nodep) override { - VSymEnt* symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); + VSymEnt* const symp = m_statep->insertBlock(m_modSymp, nodep->name(), nodep, nullptr); symp->fallbackp(m_modSymp); // No recursion, we don't want to pick up variables } @@ -1597,8 +1601,8 @@ class LinkDotScopeVisitor final : public AstNVisitor { // Track aliases created by V3Inline; if we get a VARXREF(aliased_from) // we'll need to replace it with a VARXREF(aliased_to) if (debug() >= 9) nodep->dumpTree(cout, "- alias: "); - AstVarScope* fromVscp = VN_AS(nodep->lhsp(), VarRef)->varScopep(); - AstVarScope* toVscp = VN_AS(nodep->rhsp(), VarRef)->varScopep(); + AstVarScope* const fromVscp = VN_AS(nodep->lhsp(), VarRef)->varScopep(); + AstVarScope* const toVscp = VN_AS(nodep->rhsp(), VarRef)->varScopep(); UASSERT_OBJ(fromVscp && toVscp, nodep, "Bad alias scopes"); fromVscp->user2p(toVscp); iterateChildren(nodep); @@ -1608,8 +1612,8 @@ class LinkDotScopeVisitor final : public AstNVisitor { if (debug() >= 9) nodep->dumpTree(cout, "- avs: "); VSymEnt* rhsSymp; { - AstVarRef* refp = VN_CAST(nodep->rhsp(), VarRef); - AstVarXRef* xrefp = VN_CAST(nodep->rhsp(), VarXRef); + AstVarRef* const refp = VN_CAST(nodep->rhsp(), VarRef); + AstVarXRef* const xrefp = VN_CAST(nodep->rhsp(), VarXRef); UASSERT_OBJ(refp || xrefp, nodep, "Unsupported: Non Var(X)Ref attached to interface pin"); string inl @@ -1638,8 +1642,8 @@ class LinkDotScopeVisitor final : public AstNVisitor { } VSymEnt* lhsSymp; { - const AstVarXRef* xrefp = VN_CAST(nodep->lhsp(), VarXRef); - const AstVarRef* refp = VN_CAST(nodep->lhsp(), VarRef); + const AstVarXRef* const xrefp = VN_CAST(nodep->lhsp(), VarXRef); + const AstVarRef* const refp = VN_CAST(nodep->lhsp(), VarRef); UASSERT_OBJ(refp || xrefp, nodep, "Unsupported: Non Var(X)Ref attached to interface pin"); @@ -1647,8 +1651,8 @@ class LinkDotScopeVisitor final : public AstNVisitor { = refp ? refp->varp()->name() : xrefp->dotted() + "." + xrefp->name(); string baddot; VSymEnt* okSymp; - VSymEnt* symp = m_statep->findDotted(nodep->lhsp()->fileline(), m_modSymp, scopename, - baddot, okSymp); + VSymEnt* const symp = m_statep->findDotted(nodep->lhsp()->fileline(), m_modSymp, + scopename, baddot, okSymp); UASSERT_OBJ(symp, nodep, "No symbol for interface alias lhs"); UINFO(5, " Found a linked scope LHS: " << scopename << " se" << cvtToHex(symp) << " " << symp->nodep() << endl); @@ -1705,13 +1709,13 @@ class LinkDotIfaceVisitor final : public AstNVisitor { UINFO(5, " fif: " << nodep << endl); iterateChildren(nodep); if (nodep->isExport()) nodep->v3warn(E_UNSUPPORTED, "Unsupported: modport export"); - VSymEnt* symp = m_curSymp->findIdFallback(nodep->name()); + VSymEnt* const symp = m_curSymp->findIdFallback(nodep->name()); if (!symp) { nodep->v3error("Modport item not found: " << nodep->prettyNameQ()); - } else if (AstNodeFTask* ftaskp = VN_CAST(symp->nodep(), NodeFTask)) { + } else if (AstNodeFTask* const ftaskp = VN_CAST(symp->nodep(), NodeFTask)) { // Make symbol under modport that points at the _interface_'s var, not the modport. nodep->ftaskp(ftaskp); - VSymEnt* subSymp + VSymEnt* const subSymp = m_statep->insertSym(m_curSymp, nodep->name(), ftaskp, nullptr /*package*/); m_statep->insertScopeAlias(LinkDotState::SAMN_MODPORT, subSymp, symp); } else { @@ -1727,15 +1731,15 @@ class LinkDotIfaceVisitor final : public AstNVisitor { virtual void visit(AstModportVarRef* nodep) override { UINFO(5, " fiv: " << nodep << endl); iterateChildren(nodep); - VSymEnt* symp = m_curSymp->findIdFallback(nodep->name()); + VSymEnt* const symp = m_curSymp->findIdFallback(nodep->name()); if (!symp) { nodep->v3error("Modport item not found: " << nodep->prettyNameQ()); - } else if (AstVar* varp = VN_CAST(symp->nodep(), Var)) { + } else if (AstVar* const varp = VN_CAST(symp->nodep(), Var)) { // Make symbol under modport that points at the _interface_'s var via the modport. // (Need modport still to test input/output markings) nodep->varp(varp); m_statep->insertSym(m_curSymp, nodep->name(), nodep, nullptr /*package*/); - } else if (AstVarScope* vscp = VN_CAST(symp->nodep(), VarScope)) { + } else if (AstVarScope* const vscp = VN_CAST(symp->nodep(), VarScope)) { // Make symbol under modport that points at the _interface_'s var, not the modport. nodep->varp(vscp->varp()); m_statep->insertSym(m_curSymp, nodep->name(), vscp, nullptr /*package*/); @@ -1764,8 +1768,8 @@ public: void LinkDotState::computeIfaceModSyms() { for (const auto& itr : m_ifaceModSyms) { - AstIface* nodep = itr.first; - VSymEnt* symp = itr.second; + AstIface* const nodep = itr.first; + VSymEnt* const symp = itr.second; LinkDotIfaceVisitor{nodep, symp, this}; } m_ifaceModSyms.clear(); @@ -1796,19 +1800,19 @@ private: }; // DOT {member-name} [DOT...] // STATE - LinkDotState* m_statep; // State, including dotted symbol table + LinkDotState* const m_statep; // State, including dotted symbol table VSymEnt* m_curSymp = nullptr; // SymEnt for current lookup point VSymEnt* m_modSymp = nullptr; // SymEnt for current module VSymEnt* m_pinSymp = nullptr; // SymEnt for pin lookups - AstCell* m_cellp = nullptr; // Current cell + const AstCell* m_cellp = nullptr; // Current cell AstNodeModule* m_modp = nullptr; // Current module - AstNodeFTask* m_ftaskp = nullptr; // Current function/task + const AstNodeFTask* m_ftaskp = nullptr; // Current function/task int m_modportNum = 0; // Uniqueify modport numbers struct DotStates { DotPosition m_dotPos; // Scope part of dotted resolution VSymEnt* m_dotSymp; // SymEnt for dotted AstParse lookup - AstDot* m_dotp; // Current dot + const AstDot* m_dotp; // Current dot bool m_unresolved; // Unresolved, needs help from V3Param AstNode* m_unlinkedScopep; // Unresolved scope, needs corresponding VarXRef bool m_dotErr; // Error found in dotted resolution, ignore upwards @@ -1863,8 +1867,8 @@ private: << (suggest.empty() ? "" : nodep->warnMore() + suggest)); } } - AstVar* newp = new AstVar(nodep->fileline(), AstVarType::WIRE, nodep->name(), - VFlagLogicPacked(), 1); + AstVar* const newp = new AstVar(nodep->fileline(), AstVarType::WIRE, nodep->name(), + VFlagLogicPacked(), 1); newp->trace(modp->modTrace()); nodep->varp(newp); modp->addStmtp(newp); @@ -1880,8 +1884,8 @@ private: } else if (VN_IS(symp->nodep(), Var)) { return VN_AS(symp->nodep(), Var); } else if (VN_IS(symp->nodep(), ModportVarRef)) { - AstModportVarRef* snodep = VN_AS(symp->nodep(), ModportVarRef); - AstVar* varp = snodep->varp(); + AstModportVarRef* const snodep = VN_AS(symp->nodep(), ModportVarRef); + AstVar* const varp = snodep->varp(); if (access.isWriteOrRW() && snodep->direction().isReadOnly()) { nodep->v3error("Attempt to drive input-only modport: " << nodep->prettyNameQ()); } // else other simulators don't warn about reading, and IEEE doesn't say illegal @@ -1906,8 +1910,8 @@ private: } AstVar* findIfaceTopVarp(AstNode* nodep, VSymEnt* parentEntp, const string& name) { const string findName = name + "__Viftop"; - VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName); - AstVar* ifaceTopVarp = ifaceSymp ? VN_AS(ifaceSymp->nodep(), Var) : nullptr; + VSymEnt* const ifaceSymp = parentEntp->findIdFallback(findName); + AstVar* const ifaceTopVarp = ifaceSymp ? VN_AS(ifaceSymp->nodep(), Var) : nullptr; UASSERT_OBJ(ifaceTopVarp, nodep, "Can't find interface var ref: " << findName); return ifaceTopVarp; } @@ -2014,8 +2018,8 @@ private: iterateChildren(nodep); if (!nodep->modVarp()) { UASSERT_OBJ(m_pinSymp, nodep, "Pin not under instance?"); - VSymEnt* foundp = m_pinSymp->findIdFlat(nodep->name()); - const char* whatp = nodep->param() ? "parameter pin" : "pin"; + VSymEnt* const foundp = m_pinSymp->findIdFlat(nodep->name()); + const char* const whatp = nodep->param() ? "parameter pin" : "pin"; if (!foundp) { if (nodep->name() == "__paramNumber1" && m_cellp && VN_IS(m_cellp->modp(), Primitive)) { @@ -2023,7 +2027,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; } - string suggest + const string suggest = (nodep->param() ? m_statep->suggestSymFlat(m_pinSymp, nodep->name(), LinkNodeMatcherVarParam()) : m_statep->suggestSymFlat(m_pinSymp, nodep->name(), @@ -2032,7 +2036,7 @@ private: ucfirst(whatp) << " not found: " << nodep->prettyNameQ() << '\n' << (suggest.empty() ? "" : nodep->warnMore() + suggest)); - } else if (AstVar* refp = VN_CAST(foundp->nodep(), Var)) { + } else if (AstVar* const refp = VN_CAST(foundp->nodep(), Var)) { if (!refp->isIO() && !refp->isParam() && !refp->isIfaceRef()) { nodep->v3error(ucfirst(whatp) << " is not an in/out/inout/param/interface: " << nodep->prettyNameQ()); @@ -2040,7 +2044,7 @@ private: nodep->modVarp(refp); markAndCheckPinDup(nodep, refp, whatp); } - } else if (AstParamTypeDType* refp = VN_CAST(foundp->nodep(), ParamTypeDType)) { + } else if (AstParamTypeDType* const refp = VN_CAST(foundp->nodep(), ParamTypeDType)) { nodep->modPTypep(refp); markAndCheckPinDup(nodep, refp, whatp); } else { @@ -2080,7 +2084,7 @@ private: UINFO(8, " this. " << m_ds.ascii() << endl); } } else if (VN_IS(nodep->lhsp(), ParseRef) && nodep->lhsp()->name() == "super") { - VSymEnt* classSymp = m_ds.m_dotSymp; + const VSymEnt* classSymp = m_ds.m_dotSymp; do { classSymp = classSymp->parentp(); } while (classSymp && !VN_IS(classSymp->nodep(), Class)); @@ -2137,8 +2141,8 @@ private: } else { // Dot midpoint AstNode* newp = nodep->rhsp()->unlinkFrBack(); if (m_ds.m_unresolved) { - AstCellRef* crp = new AstCellRef(nodep->fileline(), nodep->name(), - nodep->lhsp()->unlinkFrBack(), newp); + AstCellRef* const crp = new AstCellRef(nodep->fileline(), nodep->name(), + nodep->lhsp()->unlinkFrBack(), newp); newp = crp; } nodep->replaceWith(newp); @@ -2182,8 +2186,8 @@ private: return; } else if (m_ds.m_dotPos == DP_MEMBER) { // Found a Var, everything following is membership. {scope}.{var}.HERE {member} - AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); - AstNode* newp + AstNode* const varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); + AstNode* const newp = new AstMemberSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name()); if (m_ds.m_dotErr) { nodep->unlinkFrBack(); // Avoid circular node loop on errors @@ -2204,7 +2208,8 @@ private: allowVar = true; UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(), "Bad package link"); - AstClassOrPackageRef* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); + AstClassOrPackageRef* const cpackagerefp + = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); classOrPackagep = cpackagerefp->classOrPackagep(); UASSERT_OBJ(classOrPackagep, m_ds.m_dotp->lhsp(), "Bad package link"); m_ds.m_dotSymp = m_statep->getNodeSym(classOrPackagep); @@ -2249,22 +2254,23 @@ private: m_ds.m_dotPos = DP_SCOPE; // Upper AstDot visitor will handle it from here } else if (VN_IS(foundp->nodep(), Cell) && allowVar && m_cellp) { - AstCell* cellp = VN_AS(foundp->nodep(), Cell); + AstCell* const cellp = VN_AS(foundp->nodep(), Cell); if (VN_IS(cellp->modp(), Iface)) { // Interfaces can be referenced like a variable for interconnect - VSymEnt* cellEntp = m_statep->getNodeSym(cellp); + VSymEnt* const cellEntp = m_statep->getNodeSym(cellp); UASSERT_OBJ(cellEntp, nodep, "No interface sym entry"); - VSymEnt* parentEntp + VSymEnt* const parentEntp = cellEntp->parentp(); // Container of the var; probably a module or // generate begin - AstVar* ifaceRefVarp = findIfaceTopVarp(nodep, parentEntp, nodep->name()); + AstVar* const ifaceRefVarp + = findIfaceTopVarp(nodep, parentEntp, nodep->name()); // ok = true; m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name()); m_ds.m_dotSymp = foundp; m_ds.m_dotPos = DP_SCOPE; UINFO(9, " cell -> iface varref " << foundp->nodep() << endl); - AstNode* newp + AstNode* const newp = new AstVarRef(ifaceRefVarp->fileline(), ifaceRefVarp, VAccess::READ); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -2273,8 +2279,9 @@ private: << cellp->modp()->prettyNameQ()); } } - } else if (AstVar* varp = foundToVarp(foundp, nodep, VAccess::READ)) { - AstIfaceRefDType* ifacerefp = LinkDotState::ifaceRefFromArray(varp->subDTypep()); + } else if (AstVar* const varp = foundToVarp(foundp, nodep, VAccess::READ)) { + AstIfaceRefDType* const ifacerefp + = LinkDotState::ifaceRefFromArray(varp->subDTypep()); if (ifacerefp) { UASSERT_OBJ(ifacerefp->ifaceViaCellp(), ifacerefp, "Unlinked interface"); // Really this is a scope reference into an interface @@ -2283,13 +2290,13 @@ private: m_ds.m_dotSymp = m_statep->getNodeSym(ifacerefp->ifaceViaCellp()); m_ds.m_dotPos = DP_SCOPE; ok = true; - AstNode* newp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); + AstNode* const newp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (allowVar) { AstNode* newp; if (m_ds.m_dotText != "") { - AstVarXRef* refp + AstVarXRef* const refp = new AstVarXRef(nodep->fileline(), nodep->name(), m_ds.m_dotText, VAccess::READ); // lvalue'ness computed later refp->varp(varp); @@ -2320,7 +2327,7 @@ private: newp = refp; } } else { - AstVarRef* refp + AstVarRef* const refp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); // lvalue'ness computed later refp->classOrPackagep(foundp->classOrPackagep()); @@ -2332,7 +2339,7 @@ private: m_ds.m_dotPos = DP_MEMBER; ok = true; } - } else if (AstModport* modportp = VN_CAST(foundp->nodep(), Modport)) { + } else if (const AstModport* const modportp = VN_CAST(foundp->nodep(), Modport)) { // A scope reference into an interface's modport (not // necessarily at a pin connection) UINFO(9, "cell-ref-to-modport " << m_ds.m_dotText << " " << nodep << endl); @@ -2349,14 +2356,16 @@ private: nodep->v3error("Modport not referenced from underneath an interface: " << modportp->prettyNameQ()); } else { - AstCell* cellp = VN_AS(m_ds.m_dotSymp->nodep(), Cell); + AstCell* const cellp = VN_AS(m_ds.m_dotSymp->nodep(), Cell); UASSERT_OBJ(cellp, nodep, "Modport not referenced from an instance"); - VSymEnt* cellEntp = m_statep->getNodeSym(cellp); + VSymEnt* const cellEntp = m_statep->getNodeSym(cellp); UASSERT_OBJ(cellEntp, nodep, "No interface sym entry"); - VSymEnt* parentEntp = cellEntp->parentp(); // Container of the var; probably a - // module or generate begin + VSymEnt* const parentEntp + = cellEntp->parentp(); // Container of the var; probably a + // module or generate begin // We drop __BRA__??__KET__ as cells don't have that naming yet - AstVar* ifaceRefVarp = findIfaceTopVarp(nodep, parentEntp, cellp->name()); + AstVar* const ifaceRefVarp + = findIfaceTopVarp(nodep, parentEntp, cellp->name()); // ok = true; m_ds.m_dotText = VString::dot(m_ds.m_dotText, ".", nodep->name()); @@ -2365,7 +2374,7 @@ private: UINFO(9, " cell -> iface varref " << foundp->nodep() << endl); AstNode* newp = new AstVarRef(ifaceRefVarp->fileline(), ifaceRefVarp, VAccess::READ); - auto* cellarrayrefp = VN_CAST(m_ds.m_unlinkedScopep, CellArrayRef); + auto* const cellarrayrefp = VN_CAST(m_ds.m_unlinkedScopep, CellArrayRef); if (cellarrayrefp) { // iface[vec].modport became CellArrayRef(iface, lsb) // Convert back to SelBit(iface, lsb) @@ -2379,18 +2388,20 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - } else if (AstEnumItem* valuep = VN_CAST(foundp->nodep(), EnumItem)) { + } else if (AstEnumItem* const valuep = VN_CAST(foundp->nodep(), EnumItem)) { if (allowVar) { - AstNode* newp + AstNode* const newp = new AstEnumItemRef(nodep->fileline(), valuep, foundp->classOrPackagep()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); ok = true; m_ds.m_dotText = ""; } - } else if (AstLambdaArgRef* argrefp = VN_CAST(foundp->nodep(), LambdaArgRef)) { + } else if (const AstLambdaArgRef* const argrefp + = VN_CAST(foundp->nodep(), LambdaArgRef)) { if (allowVar) { - AstNode* newp = new AstLambdaArgRef(nodep->fileline(), argrefp->name(), false); + AstNode* const newp + = new AstLambdaArgRef(nodep->fileline(), argrefp->name(), false); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); ok = true; @@ -2433,7 +2444,7 @@ private: if (checkImplicit) { // Create if implicit, and also if error (so only complain once) // Else if a scope is allowed, making a signal won't help error cascade - AstVarRef* newp + AstVarRef* const newp = new AstVarRef(nodep->fileline(), nodep->name(), VAccess::READ); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -2452,8 +2463,9 @@ private: if (!nodep->varp()) { UINFO(9, " linkVarRef se" << cvtToHex(m_curSymp) << " n=" << nodep << endl); UASSERT_OBJ(m_curSymp, nodep, "nullptr lookup symbol table"); - VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); - if (AstVar* varp = foundp ? foundToVarp(foundp, nodep, nodep->access()) : nullptr) { + VSymEnt* const foundp = m_curSymp->findIdFallback(nodep->name()); + if (AstVar* const varp + = foundp ? foundToVarp(foundp, nodep, nodep->access()) : nullptr) { nodep->varp(varp); // Generally set by parse, but might be an import nodep->classOrPackagep(foundp->classOrPackagep()); @@ -2493,8 +2505,9 @@ private: dotSymp = m_statep->findDotted(nodep->fileline(), dotSymp, nodep->dotted(), baddot, okSymp); // Maybe nullptr if (!m_statep->forScopeCreation()) { - VSymEnt* foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); - AstVar* varp = foundp ? foundToVarp(foundp, nodep, nodep->access()) : nullptr; + VSymEnt* const foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); + AstVar* const varp + = foundp ? foundToVarp(foundp, nodep, nodep->access()) : nullptr; nodep->varp(varp); UINFO(7, " Resolved " << nodep << endl); // Also prints varp if (!nodep->varp()) { @@ -2509,14 +2522,14 @@ private: // this and convert to normal VarRefs if (!m_statep->forPrearray() && !m_statep->forScopeCreation()) { if (VN_IS(nodep->dtypep(), IfaceRefDType)) { - AstVarRef* newrefp + AstVarRef* const newrefp = new AstVarRef(nodep->fileline(), nodep->varp(), nodep->access()); nodep->replaceWith(newrefp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } } } else { - VSymEnt* foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); + VSymEnt* const foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); AstVarScope* vscp = foundp ? VN_AS(foundp->nodep(), VarScope) : nullptr; if (!vscp) { nodep->v3error("Can't find varpin scope of " @@ -2534,7 +2547,8 @@ private: nodep->varp(vscp->varp()); nodep->varScopep(vscp); UINFO(7, " Resolved " << nodep << endl); // Also prints taskp - AstVarRef* newvscp = new AstVarRef(nodep->fileline(), vscp, nodep->access()); + AstVarRef* const newvscp + = new AstVarRef(nodep->fileline(), vscp, nodep->access()); nodep->replaceWith(newvscp); VL_DO_DANGLING(nodep->deleteTree(), nodep); UINFO(9, " new " << newvscp << endl); // Also prints taskp @@ -2544,7 +2558,7 @@ private: } virtual void visit(AstEnumDType* nodep) override { iterateChildren(nodep); - AstRefDType* refdtypep = VN_CAST(nodep->subDTypep(), RefDType); + AstRefDType* const refdtypep = VN_CAST(nodep->subDTypep(), RefDType); if (refdtypep && (nodep == refdtypep->subDTypep())) { refdtypep->v3error("Self-referential enumerated type definition"); } @@ -2576,7 +2590,8 @@ private: if (m_ds.m_dotp && m_ds.m_dotPos == DP_PACKAGE) { UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(), "Bad package link"); - AstClassOrPackageRef* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); + AstClassOrPackageRef* const cpackagerefp + = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); if (cpackagerefp->name() == "process" || cpackagerefp->name() == "local") { nodep->v3warn(E_UNSUPPORTED, "Unsupported: " << AstNode::prettyNameQ(cpackagerefp->name())); @@ -2587,10 +2602,11 @@ private: m_ds.m_dotp = nullptr; } else if (m_ds.m_dotp && m_ds.m_dotPos == DP_FINAL) { if (m_ds.m_unresolved && m_ds.m_unlinkedScopep) { - AstNodeFTaskRef* newftaskp = nodep->cloneTree(false); + AstNodeFTaskRef* const newftaskp = nodep->cloneTree(false); newftaskp->dotted(m_ds.m_dotText); - AstNode* newp = new AstUnlinkedRef(nodep->fileline(), newftaskp, nodep->name(), - m_ds.m_unlinkedScopep->unlinkFrBack()); + AstNode* const newp + = new AstUnlinkedRef(nodep->fileline(), newftaskp, nodep->name(), + m_ds.m_unlinkedScopep->unlinkFrBack()); m_ds.m_unlinkedScopep = nullptr; m_ds.m_unresolved = false; nodep->replaceWith(newp); @@ -2601,11 +2617,11 @@ private: } else if (m_ds.m_dotp && m_ds.m_dotPos == DP_MEMBER) { // Found a Var, everything following is method call. // {scope}.{var}.HERE {method} ( ARGS ) - AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); + AstNode* const varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack(); AstNode* argsp = nullptr; if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext(); - AstNode* newp = new AstMethodCall(nodep->fileline(), varEtcp, VFlagChildDType(), - nodep->name(), argsp); + AstNode* const newp = new AstMethodCall(nodep->fileline(), varEtcp, VFlagChildDType(), + nodep->name(), argsp); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); return; @@ -2653,8 +2669,8 @@ private: dotSymp = m_statep->findDotted(nodep->fileline(), dotSymp, nodep->dotted(), baddot, okSymp); // Maybe nullptr } - VSymEnt* foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); - AstNodeFTask* taskp + VSymEnt* const foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot); + AstNodeFTask* const taskp = foundp ? VN_CAST(foundp->nodep(), NodeFTask) : nullptr; // Maybe nullptr if (taskp) { nodep->taskp(taskp); @@ -2688,9 +2704,9 @@ private: } else { AstNode* outp = nullptr; while (nodep->pinsp()) { - AstNode* pinp = nodep->pinsp()->unlinkFrBack(); + AstNode* const pinp = nodep->pinsp()->unlinkFrBack(); AstNode* addp = pinp; - if (AstArg* argp = VN_CAST(pinp, Arg)) { + if (AstArg* const argp = VN_CAST(pinp, Arg)) { addp = argp->exprp()->unlinkFrBack(); VL_DO_DANGLING(pinp->deleteTree(), pinp); } @@ -2751,8 +2767,8 @@ private: } } if (m_ds.m_unresolved && m_ds.m_dotPos == DP_SCOPE) { - AstNode* exprp = nodep->bitp()->unlinkFrBack(); - AstCellArrayRef* newp + AstNode* const exprp = nodep->bitp()->unlinkFrBack(); + AstCellArrayRef* const newp = new AstCellArrayRef(nodep->fileline(), nodep->fromp()->name(), exprp); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); @@ -2784,7 +2800,7 @@ private: virtual void visit(AstNodeBlock* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); - VSymEnt* oldCurSymp = m_curSymp; + VSymEnt* const oldCurSymp = m_curSymp; { if (nodep->name() != "") { m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep); @@ -2808,7 +2824,7 @@ private: nodep->v3error("definition not found for extern " + nodep->prettyNameQ()); } } - VSymEnt* oldCurSymp = m_curSymp; + VSymEnt* const oldCurSymp = m_curSymp; { m_ftaskp = nodep; m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep); @@ -2820,7 +2836,7 @@ private: virtual void visit(AstWith* nodep) override { UINFO(5, " " << nodep << endl); checkNoDot(nodep); - VSymEnt* oldCurSymp = m_curSymp; + VSymEnt* const oldCurSymp = m_curSymp; { m_ds.m_dotSymp = m_curSymp = m_statep->getNodeSym(nodep); iterateChildren(nodep); @@ -2843,19 +2859,19 @@ private: m_ds.m_dotSymp = m_curSymp = m_modSymp = m_statep->getNodeSym(nodep); m_modp = nodep; for (AstNode* itemp = nodep->extendsp(); itemp; itemp = itemp->nextp()) { - if (AstClassExtends* cextp = VN_CAST(itemp, ClassExtends)) { + if (AstClassExtends* const cextp = VN_CAST(itemp, ClassExtends)) { // Replace abstract reference with hard pointer // Will need later resolution when deal with parameters if (cextp->childDTypep() || cextp->dtypep()) continue; // Already converted - AstClassOrPackageRef* cpackagerefp + AstClassOrPackageRef* const cpackagerefp = VN_CAST(cextp->classOrPkgsp(), ClassOrPackageRef); if (!cpackagerefp) { cextp->v3error("Attempting to extend using a non-class "); } else { - VSymEnt* foundp = m_curSymp->findIdFallback(cpackagerefp->name()); + VSymEnt* const foundp = m_curSymp->findIdFallback(cpackagerefp->name()); bool ok = false; if (foundp) { - if (AstClass* classp = VN_CAST(foundp->nodep(), Class)) { + if (AstClass* const classp = VN_CAST(foundp->nodep(), Class)) { UINFO(8, "Import to " << nodep << " from export class " << classp << endl); if (classp == nodep) { @@ -2869,7 +2885,7 @@ private: cextp->childDTypep(newp); classp->isExtended(true); nodep->isExtended(true); - VSymEnt* srcp = m_statep->getNodeSym(classp); + VSymEnt* const srcp = m_statep->getNodeSym(classp); m_curSymp->importFromClass(m_statep->symsp(), srcp); VL_DO_DANGLING(cpackagerefp->unlinkFrBack()->deleteTree(), cpackagerefp); @@ -2895,11 +2911,11 @@ private: { nodep->repairCache(); for (VSymEnt::const_iterator it = m_curSymp->begin(); it != m_curSymp->end(); ++it) { - AstNode* itemp = it->second->nodep(); + AstNode* const itemp = it->second->nodep(); if (!nodep->findMember(it->first)) { - if (AstEnumItem* aitemp = VN_CAST(itemp, EnumItem)) { - AstEnumItemRef* newp = new AstEnumItemRef(aitemp->fileline(), aitemp, - it->second->classOrPackagep()); + if (AstEnumItem* const aitemp = VN_CAST(itemp, EnumItem)) { + AstEnumItemRef* const newp = new AstEnumItemRef( + aitemp->fileline(), aitemp, it->second->classOrPackagep()); UINFO(8, "Class import noderef '" << it->first << "' " << newp << endl); nodep->addMembersp(newp); } @@ -2910,8 +2926,8 @@ private: virtual void visit(AstRefDType* nodep) override { // Resolve its reference if (nodep->user3SetOnce()) return; - if (AstNode* cpackagep = nodep->classOrPackageOpp()) { - if (AstClassOrPackageRef* cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) { + if (AstNode* const cpackagep = nodep->classOrPackageOpp()) { + if (AstClassOrPackageRef* const cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) { nodep->classOrPackagep(cpackagerefp->classOrPackagep()); if (!VN_IS(nodep->classOrPackagep(), Class) && !VN_IS(nodep->classOrPackagep(), Package)) { @@ -2931,7 +2947,7 @@ private: if (m_ds.m_dotp && m_ds.m_dotPos == DP_PACKAGE) { UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(), "Bad package link"); - auto* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); + auto* const cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef); UASSERT_OBJ(cpackagerefp->classOrPackagep(), m_ds.m_dotp->lhsp(), "Bad package link"); nodep->classOrPackagep(cpackagerefp->classOrPackagep()); m_ds.m_dotPos = DP_SCOPE; @@ -2941,16 +2957,16 @@ private: } if (nodep->typeofp()) { // Really is a typeof not a reference } else if (!nodep->typedefp() && !nodep->subDTypep()) { - VSymEnt* foundp; + const VSymEnt* foundp; if (nodep->classOrPackagep()) { foundp = m_statep->getNodeSym(nodep->classOrPackagep())->findIdFlat(nodep->name()); } else { foundp = m_curSymp->findIdFallback(nodep->name()); } - if (AstTypedef* defp = foundp ? VN_CAST(foundp->nodep(), Typedef) : nullptr) { + if (AstTypedef* const defp = foundp ? VN_CAST(foundp->nodep(), Typedef) : nullptr) { nodep->typedefp(defp); nodep->classOrPackagep(foundp->classOrPackagep()); - } else if (AstParamTypeDType* defp + } else if (AstParamTypeDType* const defp = foundp ? VN_CAST(foundp->nodep(), ParamTypeDType) : nullptr) { if (defp == nodep->backp()) { // Where backp is typically typedef nodep->v3error("Reference to '" << m_ds.m_dotText @@ -2962,10 +2978,11 @@ private: nodep->refDTypep(defp); nodep->classOrPackagep(foundp->classOrPackagep()); } - } else if (AstClass* defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) { - AstNode* paramsp = nodep->paramsp(); + } else if (AstClass* const defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) { + AstNode* const paramsp = nodep->paramsp(); if (paramsp) paramsp->unlinkFrBackWithNext(); - AstClassRefDType* newp = new AstClassRefDType{nodep->fileline(), defp, paramsp}; + AstClassRefDType* const newp + = new AstClassRefDType{nodep->fileline(), defp, paramsp}; newp->classOrPackagep(foundp->classOrPackagep()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); @@ -2981,8 +2998,8 @@ private: // AstDpiExport: Make sure the function referenced exists, then dump it iterateChildren(nodep); checkNoDot(nodep); - VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name()); - AstNodeFTask* taskp = foundp ? VN_AS(foundp->nodep(), NodeFTask) : nullptr; + VSymEnt* const foundp = m_curSymp->findIdFallback(nodep->name()); + AstNodeFTask* const taskp = foundp ? VN_AS(foundp->nodep(), NodeFTask) : nullptr; if (!taskp) { nodep->v3error( "Can't find definition of exported task/function: " << nodep->prettyNameQ()); @@ -3048,13 +3065,13 @@ void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot.tree")); } LinkDotState state(rootp, step); - LinkDotFindVisitor visitor{rootp, &state}; + const LinkDotFindVisitor visitor{rootp, &state}; if (LinkDotState::debug() >= 5 || v3Global.opt.dumpTree() >= 9) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-find.tree")); } if (step == LDS_PRIMARY || step == LDS_PARAMED) { // Initial link stage, resolve parameters - LinkDotParamVisitor visitors{rootp, &state}; + const LinkDotParamVisitor visitors{rootp, &state}; if (LinkDotState::debug() >= 5 || v3Global.opt.dumpTree() >= 9) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-param.tree")); } @@ -3062,7 +3079,7 @@ void V3LinkDot::linkDotGuts(AstNetlist* rootp, VLinkDotStep step) { } else if (step == LDS_SCOPED) { // Well after the initial link when we're ready to operate on the flat design, // process AstScope's. This needs to be separate pass after whole hierarchy graph created. - LinkDotScopeVisitor visitors{rootp, &state}; + const LinkDotScopeVisitor visitors{rootp, &state}; v3Global.assertScoped(true); if (LinkDotState::debug() >= 5 || v3Global.opt.dumpTree() >= 9) { v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("prelinkdot-scoped.tree")); diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index a2626bc03..2e11f72c4 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -259,7 +259,7 @@ private: // if (debug() >= 9) { UINFO(0, "\n"); blockp->dumpTree(cout, " labeli: "); } if (!blockp) { nodep->v3error("disable isn't underneath a begin with name: " << nodep->prettyNameQ()); - } else if (AstBegin* beginp = VN_CAST(blockp, Begin)) { + } else if (AstBegin* const beginp = VN_CAST(blockp, Begin)) { // Jump to the end of the named block AstJumpLabel* const labelp = findAddLabel(beginp, false); nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp)); diff --git a/src/V3LinkLevel.cpp b/src/V3LinkLevel.cpp index 9868b04f4..d0d344908 100644 --- a/src/V3LinkLevel.cpp +++ b/src/V3LinkLevel.cpp @@ -142,13 +142,13 @@ void V3LinkLevel::timescaling(const ModVec& mods) { void V3LinkLevel::wrapTop(AstNetlist* rootp) { UINFO(2, __FUNCTION__ << ": " << endl); // We do ONLY the top module - AstNodeModule* oldmodp = rootp->modulesp(); + AstNodeModule* const oldmodp = rootp->modulesp(); if (!oldmodp) { // Later V3LinkDot will warn UINFO(1, "No module found to wrap\n"); return; } - AstNodeModule* newmodp = new AstModule(oldmodp->fileline(), "$root"); + AstNodeModule* const newmodp = new AstModule(oldmodp->fileline(), "$root"); newmodp->name(AstNode::encodeName(newmodp->name())); // so origName is nice // Make the new module first in the list oldmodp->unlinkFrBackWithNext(); @@ -167,10 +167,11 @@ void V3LinkLevel::wrapTop(AstNetlist* rootp) { // This way all later SCOPE based optimizations can ignore packages for (AstNodeModule* modp = rootp->modulesp(); modp; modp = VN_AS(modp->nextp(), NodeModule)) { if (VN_IS(modp, Package)) { - AstCell* cellp = new AstCell(modp->fileline(), modp->fileline(), - // Could add __03a__03a="::" to prevent conflict - // with module names/"v" - modp->name(), modp->name(), nullptr, nullptr, nullptr); + AstCell* const cellp + = new AstCell(modp->fileline(), modp->fileline(), + // Could add __03a__03a="::" to prevent conflict + // with module names/"v" + modp->name(), modp->name(), nullptr, nullptr, nullptr); cellp->modp(modp); newmodp->addStmtp(cellp); } @@ -180,7 +181,7 @@ void V3LinkLevel::wrapTop(AstNetlist* rootp) { } void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { - AstNodeModule* newmodp = rootp->modulesp(); + AstNodeModule* const newmodp = rootp->modulesp(); UASSERT_OBJ(newmodp && newmodp->isTop(), rootp, "No TOP module found to insert under"); // Find all duplicate signal names (if multitop) @@ -191,7 +192,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { for (AstNodeModule* oldmodp = VN_AS(rootp->modulesp()->nextp(), NodeModule); oldmodp && oldmodp->level() <= 2; oldmodp = VN_AS(oldmodp->nextp(), NodeModule)) { for (AstNode* subnodep = oldmodp->stmtsp(); subnodep; subnodep = subnodep->nextp()) { - if (AstVar* oldvarp = VN_CAST(subnodep, Var)) { + if (AstVar* const oldvarp = VN_CAST(subnodep, Var)) { if (oldvarp->isIO()) { if (ioNames.find(oldvarp->name()) != ioNames.end()) { // UINFO(8, "Multitop dup I/O found: " << oldvarp << endl); @@ -210,7 +211,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { if (VN_IS(oldmodp, Package)) continue; // Add instance UINFO(5, "LOOP " << oldmodp << endl); - AstCell* cellp = new AstCell( + AstCell* const cellp = new AstCell( newmodp->fileline(), newmodp->fileline(), (!v3Global.opt.l2Name().empty() ? v3Global.opt.l2Name() : oldmodp->name()), oldmodp->name(), nullptr, nullptr, nullptr); @@ -219,7 +220,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { // Add pins for (AstNode* subnodep = oldmodp->stmtsp(); subnodep; subnodep = subnodep->nextp()) { - if (AstVar* oldvarp = VN_CAST(subnodep, Var)) { + if (AstVar* const oldvarp = VN_CAST(subnodep, Var)) { UINFO(8, "VARWRAP " << oldvarp << endl); if (oldvarp->isIO()) { string name = oldvarp->name(); @@ -228,7 +229,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { name = oldmodp->name() + "__02E" + name; } - AstVar* varp = oldvarp->cloneTree(false); + AstVar* const varp = oldvarp->cloneTree(false); varp->name(name); varp->protect(false); newmodp->addStmtp(varp); @@ -249,7 +250,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) { varp->trace(false); } - AstPin* pinp = new AstPin( + AstPin* const pinp = new AstPin( oldvarp->fileline(), 0, varp->name(), new AstVarRef(varp->fileline(), varp, oldvarp->isWritable() ? VAccess::WRITE : VAccess::READ)); diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 5952ea46f..45ffd1aec 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -185,7 +185,7 @@ private: nodep->fileline(), nodep->valuep()->cloneTree(true), new AstConst(nodep->fileline(), AstConst::Unsized32(), offset_from_init)); } - AstNode* newp = new AstEnumItem(nodep->fileline(), name, nullptr, valuep); + AstNode* const newp = new AstEnumItem(nodep->fileline(), name, nullptr, valuep); if (addp) { addp = addp->addNextNull(newp); } else { @@ -212,15 +212,15 @@ private: } if (VN_IS(nodep->subDTypep(), ParseTypeDType)) { // It's a parameter type. Use a different node type for this. - AstNodeDType* dtypep = VN_CAST(nodep->valuep(), NodeDType); + AstNodeDType* const dtypep = VN_CAST(nodep->valuep(), NodeDType); if (!dtypep) { nodep->v3error( "Parameter type's initial value isn't a type: " << nodep->prettyNameQ()); nodep->unlinkFrBack(); } else { dtypep->unlinkFrBack(); - AstNode* newp = new AstParamTypeDType(nodep->fileline(), nodep->varType(), - nodep->name(), VFlagChildDType(), dtypep); + AstNode* const newp = new AstParamTypeDType( + nodep->fileline(), nodep->varType(), nodep->name(), VFlagChildDType(), dtypep); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -256,7 +256,7 @@ private: if (m_inAlways) nodep->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); if (nodep->valuep()) { // A variable with an = value can be three things: - FileLine* fl = nodep->valuep()->fileline(); + FileLine* const fl = nodep->valuep()->fileline(); if (nodep->isParam() || (m_ftaskp && nodep->isNonOutput())) { // 1. Parameters and function inputs: It's a default to use if not overridden } else if (!m_ftaskp && !VN_IS(m_modp, Class) && nodep->isNonOutput()) { @@ -267,9 +267,9 @@ private: // AstInitial else if (m_valueModp) { // Making an AstAssign (vs AstAssignW) to a wire is an error, suppress it - FileLine* newfl = new FileLine(fl); + FileLine* const newfl = new FileLine(fl); newfl->warnOff(V3ErrorCode::PROCASSWIRE, true); - auto* assp + auto* const assp = new AstAssign(newfl, new AstVarRef(newfl, nodep->name(), VAccess::WRITE), nodep->valuep()->unlinkFrBack()); nodep->addNextHere(new AstInitial(newfl, assp)); @@ -295,7 +295,7 @@ private: cleanFileline(nodep); iterateChildren(nodep); if (nodep->attrType() == AstAttrType::DT_PUBLIC) { - AstTypedef* typep = VN_AS(nodep->backp(), Typedef); + AstTypedef* const typep = VN_AS(nodep->backp(), Typedef); UASSERT_OBJ(typep, nodep, "Attribute not attached to typedef"); typep->attrPublic(true); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); @@ -379,7 +379,7 @@ private: // Unique name space under each containerp() so that an addition of // a new type won't change every verilated module. AstTypedef* defp = nullptr; - ImplTypedefMap::iterator it + const ImplTypedefMap::iterator it = m_implTypedef.find(std::make_pair(nodep->containerp(), nodep->name())); if (it != m_implTypedef.end()) { defp = it->second; @@ -392,7 +392,7 @@ private: } UASSERT_OBJ(backp, nodep, "Implicit enum/struct type created under unexpected node type"); - AstNodeDType* dtypep = nodep->childDTypep(); + AstNodeDType* const dtypep = nodep->childDTypep(); dtypep->unlinkFrBack(); if (VN_IS(backp, Typedef)) { // A typedef doesn't need us to make yet another level of typedefing @@ -435,11 +435,11 @@ private: AstNode* bracketp = nodep->arrayp(); AstNode* firstVarsp = nullptr; while (AstDot* dotp = VN_CAST(bracketp, Dot)) { bracketp = dotp->rhsp(); } - if (AstSelBit* selp = VN_CAST(bracketp, SelBit)) { + if (AstSelBit* const selp = VN_CAST(bracketp, SelBit)) { firstVarsp = selp->rhsp()->unlinkFrBackWithNext(); selp->replaceWith(selp->fromp()->unlinkFrBack()); VL_DO_DANGLING(selp->deleteTree(), selp); - } else if (AstSelLoopVars* selp = VN_CAST(bracketp, SelLoopVars)) { + } else if (AstSelLoopVars* const selp = VN_CAST(bracketp, SelLoopVars)) { firstVarsp = selp->elementsp()->unlinkFrBackWithNext(); selp->replaceWith(selp->fromp()->unlinkFrBack()); VL_DO_DANGLING(selp->deleteTree(), selp); @@ -449,7 +449,7 @@ private: VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; } - AstNode* arrayp = nodep->arrayp(); // Maybe different node since bracketp looked + AstNode* const arrayp = nodep->arrayp(); // Maybe different node since bracketp looked if (!VN_IS(arrayp, ParseRef) && !VN_IS(arrayp, Dot)) { // Code below needs to use other then attributes to figure out the bounds // Also need to deal with queues, etc @@ -467,26 +467,27 @@ private: } for (AstNode* varsp = lastVarsp; varsp; varsp = varsp->backp()) { UINFO(9, "foreachVar " << varsp << endl); - FileLine* fl = varsp->fileline(); - AstNode* varp + FileLine* const fl = varsp->fileline(); + AstNode* const varp = new AstVar(fl, AstVarType::BLOCKTEMP, varsp->name(), nodep->findSigned32DType()); // These will be the left and right dimensions and size of the array: - AstNode* leftp = new AstAttrOf(fl, AstAttrType::DIM_LEFT, arrayp->cloneTree(false), - new AstConst(fl, dimension)); - AstNode* rightp = new AstAttrOf(fl, AstAttrType::DIM_RIGHT, arrayp->cloneTree(false), - new AstConst(fl, dimension)); - AstNode* sizep = new AstAttrOf(fl, AstAttrType::DIM_SIZE, arrayp->cloneTree(false), - new AstConst(fl, dimension)); - AstNode* stmtsp = varp; + AstNode* const leftp = new AstAttrOf( + fl, AstAttrType::DIM_LEFT, arrayp->cloneTree(false), new AstConst(fl, dimension)); + AstNode* const rightp = new AstAttrOf( + fl, AstAttrType::DIM_RIGHT, arrayp->cloneTree(false), new AstConst(fl, dimension)); + AstNode* const sizep = new AstAttrOf( + fl, AstAttrType::DIM_SIZE, arrayp->cloneTree(false), new AstConst(fl, dimension)); + AstNode* const stmtsp = varp; // Assign left-dimension into the loop var: stmtsp->addNext( new AstAssign(fl, new AstVarRef(fl, varp->name(), VAccess::WRITE), leftp)); // This will turn into a constant bool for static arrays - AstNode* notemptyp = new AstGt(fl, sizep, new AstConst(fl, 0)); + AstNode* const notemptyp = new AstGt(fl, sizep, new AstConst(fl, 0)); // This will turn into a bool constant, indicating whether // we count the loop variable up or down: - AstNode* countupp = new AstLte(fl, leftp->cloneTree(true), rightp->cloneTree(true)); - AstNode* comparep = new AstCond( + AstNode* const countupp + = new AstLte(fl, leftp->cloneTree(true), rightp->cloneTree(true)); + AstNode* const comparep = new AstCond( fl, countupp->cloneTree(true), // Left increments up to right new AstLte(fl, new AstVarRef(fl, varp->name(), VAccess::READ), @@ -494,8 +495,8 @@ private: // Left decrements down to right new AstGte(fl, new AstVarRef(fl, varp->name(), VAccess::READ), rightp)); // This will reduce to comparep for static arrays - AstNode* condp = new AstAnd(fl, notemptyp, comparep); - AstNode* incp = new AstAssign( + AstNode* const condp = new AstAnd(fl, notemptyp, comparep); + AstNode* const incp = new AstAssign( fl, new AstVarRef(fl, varp->name(), VAccess::WRITE), new AstAdd(fl, new AstVarRef(fl, varp->name(), VAccess::READ), new AstCond(fl, countupp, new AstConst(fl, 1), new AstConst(fl, -1)))); @@ -590,7 +591,7 @@ private: } virtual void visit(AstGenIf* nodep) override { cleanFileline(nodep); - bool nestedIf + const bool nestedIf = (VN_IS(nodep->backp(), Begin) && nestedIfBegin(VN_CAST(nodep->backp(), Begin))); if (nestedIf) { iterateChildren(nodep); @@ -638,7 +639,7 @@ private: virtual void visit(AstTimingControl* nodep) override { cleanFileline(nodep); iterateChildren(nodep); - AstAlways* alwaysp = VN_CAST(nodep->backp(), Always); + AstAlways* const alwaysp = VN_CAST(nodep->backp(), Always); if (alwaysp && alwaysp->keyword() == VAlwaysKwd::ALWAYS_COMB) { alwaysp->v3error("Timing control statements not legal under always_comb " "(IEEE 1800-2017 9.2.2.2.2)\n" @@ -648,7 +649,7 @@ private: // Verilator is still ony supporting SenTrees under an always, // so allow the parser to handle everything and shim to // historical AST here - if (AstSenTree* sensesp = nodep->sensesp()) { + if (AstSenTree* const sensesp = nodep->sensesp()) { sensesp->unlinkFrBackWithNext(); alwaysp->sensesp(sensesp); } diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index a570bfec6..ed7cc4db3 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -225,17 +225,17 @@ private: = VN_CAST(basefromp, NodeVarRef)) { // Maybe varxref - so need to clone nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::VAR_BASE, varrefp->cloneTree(false))); - } else if (AstUnlinkedRef* uvxrp + } else if (AstUnlinkedRef* const uvxrp = VN_CAST(basefromp, UnlinkedRef)) { // Maybe unlinked - so need to clone nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::VAR_BASE, uvxrp->cloneTree(false))); - } else if (auto* fromp = VN_CAST(basefromp, LambdaArgRef)) { + } else if (auto* const fromp = VN_CAST(basefromp, LambdaArgRef)) { nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::VAR_BASE, fromp->cloneTree(false))); - } else if (AstMemberSel* fromp = VN_CAST(basefromp, MemberSel)) { + } else if (AstMemberSel* const fromp = VN_CAST(basefromp, MemberSel)) { nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::MEMBER_BASE, fromp->cloneTree(false))); - } else if (AstEnumItemRef* fromp = VN_CAST(basefromp, EnumItemRef)) { + } else if (AstEnumItemRef* const fromp = VN_CAST(basefromp, EnumItemRef)) { nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::ENUM_BASE, fromp->cloneTree(false))); } else if (VN_IS(basefromp, Replicate)) { @@ -364,7 +364,7 @@ private: bool inpercent = false; for (int i = 0; i < numchars; i++) { const int ii = numchars - i - 1; - char c = constp->num().dataByte(ii); + const char c = constp->num().dataByte(ii); str[i] = c; if (!inpercent && c == '%') { inpercent = true; @@ -584,7 +584,7 @@ public: void V3LinkResolve::linkResolve(AstNetlist* rootp) { UINFO(4, __FUNCTION__ << ": " << endl); { - LinkResolveVisitor visitor{rootp}; + const LinkResolveVisitor visitor{rootp}; LinkBotupVisitor{rootp}; } // Destruct before checking V3Global::dumpCheckGlobalTree("linkresolve", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 6); diff --git a/src/V3MergeCond.cpp b/src/V3MergeCond.cpp index 8172aeff4..11b712adb 100644 --- a/src/V3MergeCond.cpp +++ b/src/V3MergeCond.cpp @@ -141,7 +141,7 @@ private: AstNode* m_mgFirstp = nullptr; // First node in merged sequence AstNode* m_mgCondp = nullptr; // The condition of the first node - AstNode* m_mgLastp = nullptr; // Last node in merged sequence + const AstNode* m_mgLastp = nullptr; // Last node in merged sequence const AstNode* m_mgNextp = nullptr; // Next node in list being examined uint32_t m_listLenght = 0; // Length of current list @@ -158,7 +158,7 @@ private: static AstNodeCond* extractCond(AstNode* rhsp) { if (AstNodeCond* const condp = VN_CAST(rhsp, NodeCond)) { return condp; - } else if (AstAnd* const andp = VN_CAST(rhsp, And)) { + } else if (const AstAnd* const andp = VN_CAST(rhsp, And)) { if (AstNodeCond* const condp = VN_CAST(andp->rhsp(), NodeCond)) { if (VN_IS(andp->lhsp(), Const)) return condp; } @@ -173,7 +173,7 @@ private: return constp->num().toUQuad() <= 1; } if (const AstVarRef* const vrefp = VN_CAST(nodep, VarRef)) { - AstVar* const varp = vrefp->varp(); + const AstVar* const varp = vrefp->varp(); return varp->widthMin() == 1 && !varp->dtypep()->isSigned(); } if (const AstShiftR* const shiftp = VN_CAST(nodep, ShiftR)) { @@ -225,17 +225,17 @@ private: AstNode* foldAndUnlink(AstNode* rhsp, bool condTrue) { if (rhsp->sameTree(m_mgCondp)) { return new AstConst(rhsp->fileline(), AstConst::BitTrue{}, condTrue); - } else if (AstNodeCond* const condp = extractCond(rhsp)) { + } else if (const AstNodeCond* const condp = extractCond(rhsp)) { AstNode* const resp = condTrue ? condp->expr1p()->unlinkFrBack() : condp->expr2p()->unlinkFrBack(); if (condp == rhsp) { // return resp; } - if (AstAnd* const andp = VN_CAST(rhsp, And)) { + if (const AstAnd* const andp = VN_CAST(rhsp, And)) { UASSERT_OBJ(andp->rhsp() == condp, rhsp, "Should not try to fold this"); return new AstAnd{andp->fileline(), andp->lhsp()->cloneTree(false), resp}; } - } else if (AstAnd* const andp = VN_CAST(rhsp, And)) { + } else if (const AstAnd* const andp = VN_CAST(rhsp, And)) { if (andp->lhsp()->sameTree(m_mgCondp)) { return condTrue ? maskLsb(andp->rhsp()->unlinkFrBack()) : new AstConst{rhsp->fileline(), AstConst::BitFalse()}; @@ -255,11 +255,11 @@ private: void mergeEnd(int lineno) { UASSERT(m_mgFirstp, "mergeEnd without list " << lineno); // We might want to recursively merge an AstIf. We stash it in this variable. - AstNodeIf* recursivep = nullptr; + const AstNodeIf* recursivep = nullptr; // Drop leading cheap nodes. These were only added in the hope of finding // an earlier reduced form, but we failed to do so. while (m_mgFirstp->user2() && m_mgFirstp != m_mgLastp) { - AstNode* const backp = m_mgFirstp; + const AstNode* const backp = m_mgFirstp; m_mgFirstp = m_mgFirstp->nextp(); --m_listLenght; UASSERT_OBJ(m_mgFirstp && m_mgFirstp->backp() == backp, m_mgLastp, @@ -268,7 +268,7 @@ private: // Drop trailing cheap nodes. These were only added in the hope of finding // a later conditional to merge, but we failed to do so. while (m_mgLastp->user2() && m_mgFirstp != m_mgLastp) { - AstNode* const nextp = m_mgLastp; + const AstNode* const nextp = m_mgLastp; m_mgLastp = m_mgLastp->backp(); --m_listLenght; UASSERT_OBJ(m_mgLastp && m_mgLastp->nextp() == nextp, m_mgFirstp, @@ -328,7 +328,7 @@ private: } while (nextp); // Recursively merge the resulting AstIf recursivep = resultp; - } else if (AstNodeIf* const ifp = VN_CAST(m_mgFirstp, NodeIf)) { + } else if (const AstNodeIf* const ifp = VN_CAST(m_mgFirstp, NodeIf)) { // There was nothing to merge this AstNodeIf with, but try to merge it's branches recursivep = ifp; } @@ -353,11 +353,11 @@ private: // Check if the node can be simplified if included under the if bool isSimplifiableNode(AstNode* nodep) { UASSERT_OBJ(m_mgFirstp, nodep, "Cannot check with empty list"); - if (AstNodeAssign* const assignp = VN_CAST(nodep, NodeAssign)) { + if (const AstNodeAssign* const assignp = VN_CAST(nodep, NodeAssign)) { // If it's an assignment to a 1-bit signal, try reduced forms if (assignp->lhsp()->widthMin() == 1) { // Is it a 'lhs = cond & value' or 'lhs = value & cond'? - if (AstAnd* const andp = VN_CAST(assignp->rhsp(), And)) { + if (const AstAnd* const andp = VN_CAST(assignp->rhsp(), And)) { if (andp->lhsp()->sameTree(m_mgCondp) || andp->rhsp()->sameTree(m_mgCondp)) { return true; } @@ -373,7 +373,7 @@ private: // AstIf and is hence not likely to cause a performance degradation if doing so. bool isCheapNode(AstNode* nodep) const { if (VN_IS(nodep, Comment)) return true; - if (AstNodeAssign* const assignp = VN_CAST(nodep, NodeAssign)) { + if (const AstNodeAssign* const assignp = VN_CAST(nodep, NodeAssign)) { // Check LHS AstNode* lhsp = assignp->lhsp(); while (AstWordSel* const wselp = VN_CAST(lhsp, WordSel)) { @@ -479,7 +479,7 @@ private: // VISITORS virtual void visit(AstNodeAssign* nodep) override { AstNode* const rhsp = nodep->rhsp(); - if (AstNodeCond* const condp = extractCond(rhsp)) { + if (const AstNodeCond* const condp = extractCond(rhsp)) { // Check if mergeable if (!checkOrMakeMergeable(nodep)) return; // Close potentially incompatible pending merge diff --git a/src/V3Name.cpp b/src/V3Name.cpp index 5e1c13239..6d743dbf5 100644 --- a/src/V3Name.cpp +++ b/src/V3Name.cpp @@ -40,7 +40,7 @@ private: const AstUser1InUse m_inuser1; // STATE - AstNodeModule* m_modp = nullptr; + const AstNodeModule* m_modp = nullptr; // METHODS VL_DEBUG_FUNC; // Declare debug() diff --git a/src/V3Number.cpp b/src/V3Number.cpp index e4ea84f22..a476ab179 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -220,8 +220,8 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl) // this = (this * 10)/*product*/ + (*cp-'0')/*addend*/ // Assumed rare; lots of optimizations are possible here V3Number product(this, width() + 4); // +4 for overflow detection - V3Number ten(this, width() + 4, 10); - V3Number addend(this, width(), (*cp - '0')); + const V3Number ten(this, width() + 4, 10); + const V3Number addend(this, width(), (*cp - '0')); product.opMul(*this, ten); this->opAdd(product, addend); if (product.bitsValue(width(), 4)) { // Overflowed @@ -623,7 +623,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const { str += 'Z'; continue; } - int v = bitsValue(bit - 2, 3); + const int v = bitsValue(bit - 2, 3); str += static_cast('0' + v); } return str; @@ -653,7 +653,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const { str += 'Z'; continue; } - int v = bitsValue(bit - 3, 4); + const int v = bitsValue(bit - 3, 4); if (v >= 10) { str += static_cast('a' + v - 10); } else { @@ -664,7 +664,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const { } case 'c': { if (width() > 8) fl->v3warn(WIDTH, "$display-like format of %c format of > 8 bit value"); - unsigned int v = bitsValue(0, 8); + const unsigned int v = bitsValue(0, 8); char strc[2]; strc[0] = v & 0xff; strc[1] = '\0'; @@ -677,7 +677,7 @@ string V3Number::displayed(FileLine* fl, const string& vformat) const { bool start = true; while ((bit % 8) != 7) bit++; for (; bit >= 0; bit -= 8) { - int v = bitsValue(bit - 7, 8); + const int v = bitsValue(bit - 7, 8); if (!start || v) { str += static_cast((v == 0) ? ' ' : v); start = false; // Drop leading 0s @@ -880,9 +880,9 @@ double V3Number::toDouble() const { vlsint32_t V3Number::toSInt() const { if (isSigned()) { - uint32_t v = toUInt(); - uint32_t signExtend = (-(v & (1UL << (width() - 1)))); - uint32_t extended = v | signExtend; + const uint32_t v = toUInt(); + const uint32_t signExtend = (-(v & (1UL << (width() - 1)))); + const uint32_t extended = v | signExtend; return static_cast(extended); } else { // Where we use this (widths, etc) and care about signedness, @@ -908,9 +908,9 @@ vluint64_t V3Number::toUQuad() const { vlsint64_t V3Number::toSQuad() const { if (isDouble()) return static_cast(toDouble()); - vluint64_t v = toUQuad(); - vluint64_t signExtend = (-(v & (1ULL << (width() - 1)))); - vluint64_t extended = v | signExtend; + const vluint64_t v = toUQuad(); + const vluint64_t signExtend = (-(v & (1ULL << (width() - 1)))); + const vluint64_t extended = v | signExtend; return static_cast(extended); } @@ -923,7 +923,7 @@ string V3Number::toString() const { while ((bit % 8) != 7) bit++; string str; for (; bit >= 0; bit -= 8) { - int v = bitsValue(bit - 7, 8); + const int v = bitsValue(bit - 7, 8); if (!start || v) { str += static_cast((v == 0) ? ' ' : v); start = false; // Drop leading 0s @@ -1745,7 +1745,7 @@ V3Number& V3Number::opShiftR(const V3Number& lhs, const V3Number& rhs) { for (int bit = 32; bit < rhs.width(); bit++) { if (rhs.bitIs1(bit)) return *this; // shift of over 2^32 must be zero } - uint32_t rhsval = rhs.toUInt(); + const uint32_t rhsval = rhs.toUInt(); if (rhsval < static_cast(lhs.width())) { for (int bit = 0; bit < this->width(); bit++) setBit(bit, lhs.bitIs(bit + rhsval)); } @@ -1767,7 +1767,7 @@ V3Number& V3Number::opShiftRS(const V3Number& lhs, const V3Number& rhs, uint32_t if (rhs.bitIs1(lbits - 1)) setAllBits1(); // -1 else 0 return *this; // shift of over 2^32 must be -1/0 } - uint32_t rhsval = rhs.toUInt(); + const uint32_t rhsval = rhs.toUInt(); if (rhsval < static_cast(lhs.width())) { for (int bit = 0; bit < this->width(); bit++) { setBit(bit, lhs.bitIsExtend(bit + rhsval, lbits)); @@ -1789,7 +1789,7 @@ V3Number& V3Number::opShiftL(const V3Number& lhs, const V3Number& rhs) { for (int bit = 32; bit < rhs.width(); bit++) { if (rhs.bitIs1(bit)) return *this; // shift of over 2^32 must be zero } - uint32_t rhsval = rhs.toUInt(); + const uint32_t rhsval = rhs.toUInt(); for (int bit = 0; bit < this->width(); bit++) { if (bit >= static_cast(rhsval)) setBit(bit, lhs.bitIs(bit - rhsval)); } @@ -1806,7 +1806,7 @@ V3Number& V3Number::opNegate(const V3Number& lhs) { if (lhs.isFourState()) return setAllBitsX(); V3Number notlhs(&lhs, width()); notlhs.opNot(lhs); - V3Number one(&lhs, width(), 1); + const V3Number one(&lhs, width(), 1); opAdd(notlhs, one); return *this; } @@ -1872,7 +1872,7 @@ V3Number& V3Number::opMulS(const V3Number& lhs, const V3Number& rhs) { if (lhs.isNegative()) lhsNoSign.opNegate(lhs); V3Number rhsNoSign = rhs; if (rhs.isNegative()) rhsNoSign.opNegate(rhs); - V3Number qNoSign = opMul(lhsNoSign, rhsNoSign); + const V3Number qNoSign = opMul(lhsNoSign, rhsNoSign); if ((lhs.isNegative() && !rhs.isNegative()) || (!lhs.isNegative() && rhs.isNegative())) { opNegate(qNoSign); } else { @@ -1906,7 +1906,7 @@ V3Number& V3Number::opDivS(const V3Number& lhs, const V3Number& rhs) { if (lhs.isNegative()) lhsNoSign.opNegate(lhs); V3Number rhsNoSign = rhs; if (rhs.isNegative()) rhsNoSign.opNegate(rhs); - V3Number qNoSign = opDiv(lhsNoSign, rhsNoSign); + const V3Number qNoSign = opDiv(lhsNoSign, rhsNoSign); // UINFO(9, " >divs-mid "<= 0; bit--) { @@ -2271,14 +2272,14 @@ V3Number& V3Number::opIToRD(const V3Number& lhs, bool isSigned) { V3Number& V3Number::opRToIS(const V3Number& lhs) { NUM_ASSERT_OP_ARGS1(lhs); NUM_ASSERT_DOUBLE_ARGS1(lhs); - double v = VL_TRUNC(lhs.toDouble()); - vlsint32_t i = static_cast(v); // C converts from double to vlsint32 + const double v = VL_TRUNC(lhs.toDouble()); + const vlsint32_t i = static_cast(v); // C converts from double to vlsint32 return setLongS(i); } V3Number& V3Number::opRToIRoundS(const V3Number& lhs) { NUM_ASSERT_OP_ARGS1(lhs); NUM_ASSERT_DOUBLE_ARGS1(lhs); - double v = VL_ROUND(lhs.toDouble()); + const double v = VL_ROUND(lhs.toDouble()); setZero(); union { double d; @@ -2289,7 +2290,7 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) { const int exp = static_cast((u.q >> 52ULL) & VL_MASK_Q(11)) - 1023; const int lsb = exp - 52; - vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (1ULL << 52); + const vluint64_t mantissa = (u.q & VL_MASK_Q(52)) | (1ULL << 52); if (v != 0) { // IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa // This does not need to support subnormals as they are sub-integral @@ -2300,7 +2301,7 @@ V3Number& V3Number::opRToIRoundS(const V3Number& lhs) { } } if (v < 0) { - V3Number noSign = *this; + const V3Number noSign = *this; opNegate(noSign); } } diff --git a/src/V3Number.h b/src/V3Number.h index e62ad8562..b0b1debe0 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -116,7 +116,7 @@ public: V3Number& setDouble(double value); void setBit(int bit, char value) { // Note must be pre-zeroed! if (bit >= m_width) return; - uint32_t mask = (1UL << (bit & 31)); + const uint32_t mask = (1UL << (bit & 31)); ValueAndX& v = m_value[bit / 32]; if (value == '0' || value == 0) { v.m_value &= ~mask; diff --git a/src/V3OptionParser.cpp b/src/V3OptionParser.cpp index c5eee01d2..3192fac4a 100644 --- a/src/V3OptionParser.cpp +++ b/src/V3OptionParser.cpp @@ -153,7 +153,7 @@ int V3OptionParser::parse(int idx, int argc, char* argv[]) { UASSERT(m_pimpl->m_isFinalized, "finalize() must be called before parse()"); const char* optp = argv[idx]; if (optp[0] == '-' && optp[1] == '-') ++optp; - ActionIfs* actp = find(optp); + ActionIfs* const actp = find(optp); if (!actp) return 0; if (!actp->isValueNeeded()) { actp->exec(optp, nullptr); @@ -224,7 +224,7 @@ V3OptionParser::ActionIfs& V3OptionParser::AppendHelper::operator()(const char* optp, CbPartialMatchVal, Impl::ActionCbPartialMatchVal::CbType cb) const { const size_t prefixLen = std::strlen(optp); - auto wrap + const auto wrap = [prefixLen, cb](const char* optp, const char* argp) { cb(optp + prefixLen, argp); }; return m_parser.add(optp, std::move(wrap)); } diff --git a/src/V3OptionParser.h b/src/V3OptionParser.h index a42c5fca2..ab5d1ddc3 100644 --- a/src/V3OptionParser.h +++ b/src/V3OptionParser.h @@ -61,7 +61,7 @@ public: private: // MEMBERS - std::unique_ptr m_pimpl; + const std::unique_ptr m_pimpl; // METHODS ActionIfs* find(const char* optp); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index c9cfcbbe5..d0068f95d 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -111,7 +111,7 @@ public: V3LangCode::V3LangCode(const char* textp) { // Return code for given string, or ERROR, which is a bad code for (int codei = V3LangCode::L_ERROR; codei < V3LangCode::_ENUM_END; ++codei) { - V3LangCode code = V3LangCode(codei); + const V3LangCode code = V3LangCode(codei); if (0 == VL_STRCASECMP(textp, code.ascii())) { m_e = code; return; @@ -128,7 +128,7 @@ VTimescale::VTimescale(const string& value, bool& badr) badr = true; const string spaceless = VString::removeWhitespace(value); for (int i = TS_100S; i < _ENUM_END; ++i) { - VTimescale ts(i); + const VTimescale ts(i); if (spaceless == ts.ascii()) { badr = false; m_e = ts.m_e; @@ -236,7 +236,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr for (; isspace(*cp); ++cp) {} const char* const unitp = cp; for (; *cp && *cp != '/'; ++cp) {} - string unitStr(unitp, cp - unitp); + const string unitStr(unitp, cp - unitp); for (; isspace(*cp); ++cp) {} string precStr; if (*cp == '/') { @@ -253,7 +253,7 @@ void VTimescale::parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr } bool unitbad; - VTimescale unit(unitStr, unitbad /*ref*/); + const VTimescale unit(unitStr, unitbad /*ref*/); if (unitbad && !(unitStr.empty() && allowEmpty)) { fl->v3error("`timescale timeunit syntax error: '" << unitStr << "'"); return; @@ -471,7 +471,7 @@ string V3Options::fileExists(const string& filename) { } } // Find it - std::set* filesetp = &(diriter->second); + const std::set* filesetp = &(diriter->second); const auto fileiter = filesetp->find(basename); if (fileiter == filesetp->end()) { return ""; // Not found @@ -894,7 +894,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char } V3OptionParser parser; - V3OptionParser::AppendHelper DECL_OPTION{parser}; + const V3OptionParser::AppendHelper DECL_OPTION{parser}; V3OPTION_PARSER_DECL_TAGS; const auto callStrSetter = [this](void (V3Options::*cbStr)(const string&)) { @@ -1086,7 +1086,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-hierarchical", OnOff, &m_hierarchical); DECL_OPTION("-hierarchical-block", CbVal, [this](const char* valp) { - V3HierarchicalBlockOption opt(valp); + const V3HierarchicalBlockOption opt(valp); m_hierBlocks.emplace(opt.mangledName(), opt); }); DECL_OPTION("-hierarchical-child", OnOff, &m_hierChild); @@ -1103,7 +1103,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char DECL_OPTION("-LDFLAGS", CbVal, callStrSetter(&V3Options::addLdLibs)); const auto setLang = [this, fl](const char* valp) { - V3LangCode optval = V3LangCode(valp); + const V3LangCode optval = V3LangCode(valp); if (optval.legal()) { m_defaultLanguage = optval; } else { @@ -1367,7 +1367,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char FileLine::globalWarnStyleOff(false); }); DECL_OPTION("-Werror-", CbPartialMatch, [this, fl](const char* optp) { - V3ErrorCode code(optp); + const V3ErrorCode code(optp); if (code == V3ErrorCode::EC_ERROR) { if (!isFuture(optp)) fl->v3fatal("Unknown warning specified: -Werror-" << optp); } else { diff --git a/src/V3Order.cpp b/src/V3Order.cpp index 42c6765cb..aa90bf2a3 100644 --- a/src/V3Order.cpp +++ b/src/V3Order.cpp @@ -179,11 +179,11 @@ static bool isClockerAssignment(AstNodeAssign* nodep) { void OrderGraph::loopsVertexCb(V3GraphVertex* vertexp) { if (debug()) cout << "-Info-Loop: " << vertexp << "\n"; - if (OrderLogicVertex* vvertexp = dynamic_cast(vertexp)) { + if (OrderLogicVertex* const vvertexp = dynamic_cast(vertexp)) { std::cerr << vvertexp->nodep()->fileline()->warnOther() << " Example path: " << vvertexp->nodep()->typeName() << endl; } - if (OrderVarVertex* vvertexp = dynamic_cast(vertexp)) { + if (OrderVarVertex* const vvertexp = dynamic_cast(vertexp)) { std::cerr << vvertexp->varScp()->fileline()->warnOther() << " Example path: " << vvertexp->varScp()->prettyName() << endl; } @@ -229,7 +229,7 @@ class OrderClkMarkVisitor final : public AstNVisitor { return; // skip the marking } - const AstVarRef* lhsp = VN_CAST(nodep->lhsp(), VarRef); + const AstVarRef* const lhsp = VN_CAST(nodep->lhsp(), VarRef); if (lhsp && (lhsp->varp()->attrClocker() == VVarAttrClocker::CLOCKER_UNKNOWN)) { lhsp->varp()->attrClocker(VVarAttrClocker::CLOCKER_YES); // mark as clocker m_newClkMarked = true; // enable a further run since new clocker is marked @@ -724,7 +724,7 @@ class OrderBuildVisitor final : public AstNVisitor { for (AstVarScope* vscp = nodep->topScopep()->scopep()->varsp(); vscp; vscp = VN_AS(vscp->nextp(), VarScope)) { if (vscp->varp()->isNonOutput()) { - OrderVarVertex* varVxp = getVarVertex(vscp, VarVertexType::STD); + OrderVarVertex* const varVxp = getVarVertex(vscp, VarVertexType::STD); new OrderEdge(m_graphp, m_inputsVxp, varVxp, WEIGHT_INPUT); } } @@ -753,8 +753,8 @@ public: V3List m_readyVertices; // Ready vertices with same domain & scope private: bool m_onReadyList = false; // True if DomScope is already on list of ready dom/scopes - const AstSenTree* m_domainp; // Domain all vertices belong to - const AstScope* m_scopep; // Scope all vertices belong to + const AstSenTree* const m_domainp; // Domain all vertices belong to + const AstScope* const m_scopep; // Scope all vertices belong to using DomScopeKey = std::pair; using DomScopeMap = std::map; @@ -840,7 +840,7 @@ private: // MEMBERS const V3Graph* m_graphp; // Input graph of OrderLogicVertex's etc V3Graph* m_outGraphp; // Output graph of T_MoveVertex's - MoveVertexMaker* m_vxMakerp; // Factory class for T_MoveVertex's + MoveVertexMaker* const m_vxMakerp; // Factory class for T_MoveVertex's Logic2Move m_logic2move; // Map Logic to Vertex // Maps an (original graph vertex, domain) pair to a T_MoveVertex // Not std::unordered_map, because std::pair doesn't provide std::hash @@ -872,8 +872,8 @@ public: // For each logic node, make a T_MoveVertex for (V3GraphVertex* itp = m_graphp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (OrderLogicVertex* lvertexp = dynamic_cast(itp)) { - T_MoveVertex* moveVxp = m_vxMakerp->makeVertexp( + if (OrderLogicVertex* const lvertexp = dynamic_cast(itp)) { + T_MoveVertex* const moveVxp = m_vxMakerp->makeVertexp( lvertexp, nullptr, lvertexp->scopep(), lvertexp->domainp()); if (moveVxp) { // Cross link so we can find it later @@ -883,8 +883,8 @@ public: } // Build edges between logic vertices for (V3GraphVertex* itp = m_graphp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (OrderLogicVertex* lvertexp = dynamic_cast(itp)) { - T_MoveVertex* moveVxp = m_logic2move[lvertexp]; + if (OrderLogicVertex* const lvertexp = dynamic_cast(itp)) { + T_MoveVertex* const moveVxp = m_logic2move[lvertexp]; if (moveVxp) iterate(moveVxp, lvertexp, lvertexp->domainp()); } } @@ -901,7 +901,7 @@ private: continue; } const int weight = edgep->weight(); - if (const OrderLogicVertex* toLVertexp + if (const OrderLogicVertex* const toLVertexp = dynamic_cast(edgep->top())) { // Do not construct dependencies across exclusive domains. @@ -916,11 +916,11 @@ private: // This is an OrderVarVertex or other vertex representing // data. (Could be var, settle, or input type vertex.) const V3GraphVertex* nonLogicVxp = edgep->top(); - VxDomPair key(nonLogicVxp, domainp); + const VxDomPair key(nonLogicVxp, domainp); if (!m_var2move[key]) { - const OrderEitherVertex* eithp + const OrderEitherVertex* const eithp = dynamic_cast(nonLogicVxp); - T_MoveVertex* newMoveVxp + T_MoveVertex* const newMoveVxp = m_vxMakerp->makeVertexp(nullptr, eithp, eithp->scopep(), domainp); m_var2move[key] = newMoveVxp; @@ -962,7 +962,7 @@ public: virtual OrderMoveVertex* makeVertexp(OrderLogicVertex* lvertexp, const OrderEitherVertex*, const AstScope* scopep, const AstSenTree* domainp) override { - OrderMoveVertex* resultp = new OrderMoveVertex(m_pomGraphp, lvertexp); + OrderMoveVertex* const resultp = new OrderMoveVertex(m_pomGraphp, lvertexp); resultp->domScopep(OrderMoveDomScope::findCreate(domainp, scopep)); resultp->m_pomWaitingE.pushBack(*m_pomWaitingp, resultp); return resultp; @@ -1005,8 +1005,8 @@ class OrderVerticesByDomainThenScope final { public: virtual bool operator()(const V3GraphVertex* lhsp, const V3GraphVertex* rhsp) const { - const MTaskMoveVertex* l_vxp = dynamic_cast(lhsp); - const MTaskMoveVertex* r_vxp = dynamic_cast(rhsp); + const MTaskMoveVertex* const l_vxp = dynamic_cast(lhsp); + const MTaskMoveVertex* const r_vxp = dynamic_cast(rhsp); vluint64_t l_id = m_ids.findId(l_vxp->domainp()); vluint64_t r_id = m_ids.findId(r_vxp->domainp()); if (l_id < r_id) return true; @@ -1025,8 +1025,8 @@ public: // Sort vertex's, which must be AbstractMTask's, into a deterministic // order by comparing their serial IDs. virtual bool operator()(const V3GraphVertex* lhsp, const V3GraphVertex* rhsp) const { - const AbstractMTask* lmtaskp = dynamic_cast(lhsp); - const AbstractMTask* rmtaskp = dynamic_cast(rhsp); + const AbstractMTask* const lmtaskp = dynamic_cast(lhsp); + const AbstractMTask* const rmtaskp = dynamic_cast(rhsp); return lmtaskp->id() < rmtaskp->id(); } }; @@ -1119,8 +1119,8 @@ class OrderProcess final : AstNDeleter { AstVarScope* const nodep = vertexp->varScp(); UASSERT(nodep != v3Global.rootp()->dpiExportTriggerp(), "DPI export trigger should not be marked circular"); - OrderLogicVertex* fromLVtxp = nullptr; - OrderLogicVertex* toLVtxp = nullptr; + const OrderLogicVertex* fromLVtxp = nullptr; + const OrderLogicVertex* toLVtxp = nullptr; if (edgep) { fromLVtxp = dynamic_cast(edgep->fromp()); toLVtxp = dynamic_cast(edgep->top()); @@ -1217,8 +1217,8 @@ class OrderProcess final : AstNDeleter { std::unordered_set canSplitList; int lim = m_unoptflatVars.size() < 10 ? m_unoptflatVars.size() : 10; for (int i = 0; i < lim; i++) { - OrderVarStdVertex* vsvertexp = m_unoptflatVars[i]; - AstVar* varp = vsvertexp->varScp()->varp(); + OrderVarStdVertex* const vsvertexp = m_unoptflatVars[i]; + AstVar* const varp = vsvertexp->varScp()->varp(); const bool canSplit = V3SplitVar::canSplitVar(varp); std::cerr << V3Error::warnMore() << " " << varp->fileline() << " " << varp->prettyName() << std::dec << ", width " << varp->width() @@ -1237,8 +1237,8 @@ class OrderProcess final : AstNDeleter { }); lim = m_unoptflatVars.size() < 10 ? m_unoptflatVars.size() : 10; for (int i = 0; i < lim; i++) { - OrderVarStdVertex* vsvertexp = m_unoptflatVars[i]; - AstVar* varp = vsvertexp->varScp()->varp(); + OrderVarStdVertex* const vsvertexp = m_unoptflatVars[i]; + AstVar* const varp = vsvertexp->varScp()->varp(); const bool canSplit = V3SplitVar::canSplitVar(varp); std::cerr << V3Error::warnMore() << " " << varp->fileline() << " " << varp->prettyName() << ", width " << std::dec << varp->width() @@ -1261,9 +1261,9 @@ class OrderProcess final : AstNDeleter { void reportLoopVarsIterate(V3GraphVertex* vertexp, uint32_t color) { if (vertexp->user()) return; // Already done vertexp->user(1); - if (OrderVarStdVertex* vsvertexp = dynamic_cast(vertexp)) { + if (OrderVarStdVertex* const vsvertexp = dynamic_cast(vertexp)) { // Only reporting on standard variable vertices - AstVar* varp = vsvertexp->varScp()->varp(); + AstVar* const varp = vsvertexp->varScp()->varp(); if (!varp->user3()) { const string name = varp->prettyName(); if ((varp->width() != 1) && (name.find("__Vdly") == string::npos) @@ -1286,7 +1286,7 @@ class OrderProcess final : AstNDeleter { // Only for member initialization in constructor static OrderInputsVertex& findInputVertex(OrderGraph& graph) { for (V3GraphVertex* vtxp = graph.verticesBeginp(); vtxp; vtxp = vtxp->verticesNextp()) { - if (auto* ivtxp = dynamic_cast(vtxp)) return *ivtxp; + if (auto* const ivtxp = dynamic_cast(vtxp)) return *ivtxp; } VL_UNREACHABLE } @@ -1357,7 +1357,7 @@ void OrderProcess::processInputs() { todoVec.push_front(&m_inputsVtx); m_inputsVtx.isFromInput(true); // By definition while (!todoVec.empty()) { - OrderEitherVertex* vertexp = todoVec.back(); + OrderEitherVertex* const vertexp = todoVec.back(); todoVec.pop_back(); processInputsOutIterate(vertexp, todoVec); } @@ -1368,7 +1368,7 @@ void OrderProcess::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& if (vertexp->user()) return; // Already processed if (false && debug() >= 9) { UINFO(9, " InIIter " << vertexp << endl); - if (OrderLogicVertex* vvertexp = dynamic_cast(vertexp)) { + if (OrderLogicVertex* const vvertexp = dynamic_cast(vertexp)) { vvertexp->nodep()->dumpTree(cout, "- TT: "); } } @@ -1377,7 +1377,7 @@ void OrderProcess::processInputsInIterate(OrderEitherVertex* vertexp, VertexVec& // Also, determine if this vertex is an input int inonly = 1; // 0=no, 1=maybe, 2=yes until a no for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - OrderEitherVertex* frVertexp = static_cast(edgep->fromp()); + OrderEitherVertex* const frVertexp = static_cast(edgep->fromp()); processInputsInIterate(frVertexp, todoVec); if (frVertexp->isFromInput()) { if (inonly == 1) inonly = 2; @@ -1416,11 +1416,11 @@ void OrderProcess::processInputsOutIterate(OrderEitherVertex* vertexp, VertexVec { // Propagate PrimaryIn through simple assignments, following target of vertex for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - OrderEitherVertex* toVertexp = static_cast(edgep->top()); - if (OrderVarStdVertex* vvertexp = dynamic_cast(toVertexp)) { + OrderEitherVertex* const toVertexp = static_cast(edgep->top()); + if (OrderVarStdVertex* const vvertexp = dynamic_cast(toVertexp)) { processInputsInIterate(vvertexp, todoVec); } - if (OrderLogicVertex* vvertexp = dynamic_cast(toVertexp)) { + if (OrderLogicVertex* const vvertexp = dynamic_cast(toVertexp)) { if (VN_IS(vvertexp->nodep(), NodeAssign)) { processInputsInIterate(vvertexp, todoVec); } @@ -1436,7 +1436,7 @@ void OrderProcess::processCircular() { // Take broken edges and add circular flags // The change detect code will use this to force changedets for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (OrderVarStdVertex* vvertexp = dynamic_cast(itp)) { + if (OrderVarStdVertex* const vvertexp = dynamic_cast(itp)) { if (vvertexp->isClock() && !vvertexp->isFromInput()) { // If a clock is generated internally, we need to do another // loop through the entire evaluation. This fixes races; see @@ -1459,7 +1459,7 @@ void OrderProcess::processCircular() { // Also mark any cut edges for (V3GraphEdge* edgep = vvertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { if (edgep->weight() == 0) { // was cut - OrderEdge* oedgep = dynamic_cast(edgep); + OrderEdge* const oedgep = dynamic_cast(edgep); UASSERT_OBJ(oedgep, vvertexp->varScp(), "Cutable edge not of proper type"); UINFO(6, " CutCircularO: " << vvertexp->name() << endl); nodeMarkCircular(vvertexp, oedgep); @@ -1467,7 +1467,7 @@ void OrderProcess::processCircular() { } for (V3GraphEdge* edgep = vvertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { if (edgep->weight() == 0) { // was cut - OrderEdge* oedgep = dynamic_cast(edgep); + OrderEdge* const oedgep = dynamic_cast(edgep); UASSERT_OBJ(oedgep, vvertexp->varScp(), "Cutable edge not of proper type"); UINFO(6, " CutCircularI: " << vvertexp->name() << endl); nodeMarkCircular(vvertexp, oedgep); @@ -1481,12 +1481,12 @@ void OrderProcess::processSensitive() { // Sc sensitives are required on all inputs that go to a combo // block. (Not inputs that go only to clocked blocks.) for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (OrderVarStdVertex* vvertexp = dynamic_cast(itp)) { + if (OrderVarStdVertex* const vvertexp = dynamic_cast(itp)) { if (vvertexp->varScp()->varp()->isNonOutput()) { // UINFO(0, " scsen " << vvertexp << endl); for (V3GraphEdge* edgep = vvertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - if (OrderEitherVertex* toVertexp + if (OrderEitherVertex* const toVertexp = dynamic_cast(edgep->top())) { if (edgep->weight() && toVertexp->domainp()) { // UINFO(0, " " << toVertexp->domainp() << endl); @@ -1503,7 +1503,7 @@ void OrderProcess::processSensitive() { void OrderProcess::processDomains() { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - OrderEitherVertex* vertexp = dynamic_cast(itp); + OrderEitherVertex* const vertexp = dynamic_cast(itp); UASSERT(vertexp, "Null or vertex not derived from EitherVertex"); processDomainsIterate(vertexp); } @@ -1518,13 +1518,13 @@ void OrderProcess::processDomainsIterate(OrderEitherVertex* vertexp) { // else, it's full combo code if (vertexp->domainp()) return; // Already processed, or sequential logic UINFO(5, " pdi: " << vertexp << endl); - OrderVarVertex* vvertexp = dynamic_cast(vertexp); + OrderVarVertex* const vvertexp = dynamic_cast(vertexp); AstSenTree* domainp = nullptr; if (vvertexp && vvertexp->varScp()->varp()->isNonOutput()) domainp = m_comboDomainp; if (vvertexp && vvertexp->varScp()->isCircular()) domainp = m_comboDomainp; if (!domainp) { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { - OrderEitherVertex* fromVertexp = static_cast(edgep->fromp()); + OrderEitherVertex* const fromVertexp = static_cast(edgep->fromp()); if (edgep->weight() && fromVertexp->domainMatters()) { UINFO(9, " from d=" << cvtToHex(fromVertexp->domainp()) << " " << fromVertexp << endl); @@ -1553,7 +1553,7 @@ void OrderProcess::processDomainsIterate(OrderEitherVertex* vertexp) { UINFO(0, " d2 =" << fromVertexp->domainp() << endl); fromVertexp->domainp()->dumpTree(cout); } // LCOV_EXCL_STOP - AstSenTree* newtreep = domainp->cloneTree(false); + AstSenTree* const newtreep = domainp->cloneTree(false); AstSenItem* newtree2p = fromVertexp->domainp()->sensesp()->cloneTree(true); UASSERT_OBJ(newtree2p, fromVertexp->domainp(), "No senitem found under clocked domain"); @@ -1602,7 +1602,7 @@ void OrderProcess::processEdgeReport() { std::deque report; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - if (OrderVarVertex* vvertexp = dynamic_cast(itp)) { + if (OrderVarVertex* const vvertexp = dynamic_cast(itp)) { string name(vvertexp->varScp()->prettyName()); if (dynamic_cast(itp)) { name += " {PRE}"; @@ -1614,7 +1614,7 @@ void OrderProcess::processEdgeReport() { std::ostringstream os; os.setf(std::ios::left); os << " " << cvtToHex(vvertexp->varScp()) << " " << std::setw(50) << name << " "; - AstSenTree* sentreep = vvertexp->domainp(); + AstSenTree* const sentreep = vvertexp->domainp(); if (sentreep) V3EmitV::verilogForTree(sentreep, os); report.push_back(os.str()); } @@ -1668,7 +1668,8 @@ void OrderProcess::processMove() { while (!m_pomReadyDomScope.empty()) { // Start with top node on ready list's domain & scope OrderMoveDomScope* domScopep = m_pomReadyDomScope.begin(); - OrderMoveVertex* topVertexp = domScopep->readyVertices().begin(); // lintok-begin-on-ref + OrderMoveVertex* const topVertexp + = domScopep->readyVertices().begin(); // lintok-begin-on-ref UASSERT(topVertexp, "domScope on ready list without any nodes ready under it"); // Work on all scopes ready inside this domain while (domScopep) { @@ -1702,7 +1703,7 @@ void OrderProcess::processMovePrepReady() { // Make list of ready nodes UINFO(5, " MovePrepReady\n"); for (OrderMoveVertex* vertexp = m_pomWaiting.begin(); vertexp;) { - OrderMoveVertex* nextp = vertexp->pomWaitingNextp(); + OrderMoveVertex* const nextp = vertexp->pomWaitingNextp(); if (vertexp->isWait() && vertexp->inEmpty()) processMoveReadyOne(vertexp); vertexp = nextp; } @@ -1737,7 +1738,7 @@ void OrderProcess::processMoveDoneOne(OrderMoveVertex* vertexp) { // Mark our outputs as one closer to ready for (V3GraphEdge *edgep = vertexp->outBeginp(), *nextp; edgep; edgep = nextp) { nextp = edgep->outNextp(); - OrderMoveVertex* toVertexp = static_cast(edgep->top()); + OrderMoveVertex* const toVertexp = static_cast(edgep->top()); UINFO(9, " Clear to " << (toVertexp->inEmpty() ? "[EMP] " : " ") << toVertexp << endl); // Delete this edge @@ -1754,11 +1755,11 @@ void OrderProcess::processMoveDoneOne(OrderMoveVertex* vertexp) { void OrderProcess::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* domScopep, int level) { UASSERT_OBJ(vertexp->domScopep() == domScopep, vertexp, "Domain mismatch; list misbuilt?"); - const OrderLogicVertex* lvertexp = vertexp->logicp(); - const AstScope* scopep = lvertexp->scopep(); + const OrderLogicVertex* const lvertexp = vertexp->logicp(); + const AstScope* const scopep = lvertexp->scopep(); UINFO(5, " POSmove l" << std::setw(3) << level << " d=" << cvtToHex(lvertexp->domainp()) << " s=" << cvtToHex(scopep) << " " << lvertexp << endl); - AstActive* newActivep + AstActive* const newActivep = processMoveOneLogic(lvertexp, m_pomNewFuncp /*ref*/, m_pomNewStmts /*ref*/); if (newActivep) m_scopetop.addActivep(newActivep); processMoveDoneOne(vertexp); @@ -1827,7 +1828,7 @@ AstActive* OrderProcess::processMoveOneLogic(const OrderLogicVertex* lvertexp, newFuncpr->addStmtsp(nodep); if (v3Global.opt.outputSplitCFuncs()) { // Add in the number of nodes we're adding - EmitCBaseCounterVisitor visitor{nodep}; + const EmitCBaseCounterVisitor visitor{nodep}; newStmtsr += visitor.count(); } } @@ -1844,10 +1845,10 @@ void OrderProcess::processMTasksInitial(InitialLogicE logic_type) { // int initStmts = 0; AstCFunc* initCFunc = nullptr; - AstScope* lastScopep = nullptr; + const AstScope* lastScopep = nullptr; for (V3GraphVertex* initVxp = m_graph.verticesBeginp(); initVxp; initVxp = initVxp->verticesNextp()) { - OrderLogicVertex* initp = dynamic_cast(initVxp); + OrderLogicVertex* const initp = dynamic_cast(initVxp); if (!initp) continue; if ((logic_type == LOGIC_INITIAL) && !initp->domainp()->hasInitial()) continue; if ((logic_type == LOGIC_SETTLE) && !initp->domainp()->hasSettle()) continue; @@ -1856,7 +1857,8 @@ void OrderProcess::processMTasksInitial(InitialLogicE logic_type) { initCFunc = nullptr; lastScopep = initp->scopep(); } - AstActive* newActivep = processMoveOneLogic(initp, initCFunc /*ref*/, initStmts /*ref*/); + AstActive* const newActivep + = processMoveOneLogic(initp, initCFunc /*ref*/, initStmts /*ref*/); if (newActivep) m_scopetop.addActivep(newActivep); } } @@ -1899,7 +1901,7 @@ void OrderProcess::processMTasks() { GraphStream emit_logic(&logicGraph); const V3GraphVertex* moveVxp; while ((moveVxp = emit_logic.nextp())) { - const MTaskMoveVertex* movep = dynamic_cast(moveVxp); + const MTaskMoveVertex* const movep = dynamic_cast(moveVxp); const unsigned mtaskId = movep->color(); UASSERT(mtaskId > 0, "Every MTaskMoveVertex should have an mtask assignment >0"); if (movep->logicp()) { @@ -1910,22 +1912,22 @@ void OrderProcess::processMTasks() { // take this opportunity to annotate each AstVar with the id's // of mtasks that consume it and produce it. We'll use this // information in V3EmitC when we lay out var's in memory. - const OrderLogicVertex* logicp = movep->logicp(); + const OrderLogicVertex* const logicp = movep->logicp(); for (const V3GraphEdge* edgep = logicp->inBeginp(); edgep; edgep = edgep->inNextp()) { - const OrderVarVertex* pre_varp + const OrderVarVertex* const pre_varp = dynamic_cast(edgep->fromp()); if (!pre_varp) continue; - AstVar* varp = pre_varp->varScp()->varp(); + AstVar* const varp = pre_varp->varScp()->varp(); // varp depends on logicp, so logicp produces varp, // and vice-versa below varp->addProducingMTaskId(mtaskId); } for (const V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) { - const OrderVarVertex* post_varp + const OrderVarVertex* const post_varp = dynamic_cast(edgep->top()); if (!post_varp) continue; - AstVar* varp = post_varp->varScp()->varp(); + AstVar* const varp = post_varp->varScp()->varp(); varp->addConsumingMTaskId(mtaskId); } // TODO? We ignore IO vars here, so those will have empty mtask @@ -1935,8 +1937,8 @@ void OrderProcess::processMTasks() { // Create the AstExecGraph node which represents the execution // of the MTask graph. - FileLine* rootFlp = v3Global.rootp()->fileline(); - AstExecGraph* execGraphp = new AstExecGraph(rootFlp); + FileLine* const rootFlp = v3Global.rootp()->fileline(); + AstExecGraph* const execGraphp = new AstExecGraph(rootFlp); m_scopetop.addActivep(execGraphp); v3Global.rootp()->execGraphp(execGraphp); @@ -1944,10 +1946,10 @@ void OrderProcess::processMTasks() { GraphStream emit_mtasks(&mtasks); const V3GraphVertex* mtaskVxp; while ((mtaskVxp = emit_mtasks.nextp())) { - const AbstractLogicMTask* mtaskp = dynamic_cast(mtaskVxp); + const AbstractLogicMTask* const mtaskp = dynamic_cast(mtaskVxp); // Create a body for this mtask - AstMTaskBody* bodyp = new AstMTaskBody(rootFlp); + AstMTaskBody* const bodyp = new AstMTaskBody(rootFlp); MTaskState& state = mtaskStates[mtaskp->id()]; state.m_mtaskBodyp = bodyp; @@ -1964,7 +1966,7 @@ void OrderProcess::processMTasks() { } last_domainp = logicp->domainp(); - AstActive* newActivep + AstActive* const newActivep = processMoveOneLogic(logicp, leafCFuncp /*ref*/, leafStmts /*ref*/); if (newActivep) bodyp->addStmtsp(newActivep); } @@ -1984,8 +1986,9 @@ void OrderProcess::processMTasks() { state.m_mtaskBodyp->execMTaskp(state.m_execMTaskp); for (V3GraphEdge* inp = mtaskp->inBeginp(); inp; inp = inp->inNextp()) { const V3GraphVertex* fromVxp = inp->fromp(); - const AbstractLogicMTask* fromp = dynamic_cast(fromVxp); - MTaskState& fromState = mtaskStates[fromp->id()]; + const AbstractLogicMTask* const fromp + = dynamic_cast(fromVxp); + const MTaskState& fromState = mtaskStates[fromp->id()]; new V3GraphEdge(execGraphp->mutableDepGraphp(), fromState.m_execMTaskp, state.m_execMTaskp, 1); } diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index 963aa0415..d60951ff8 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -121,7 +121,7 @@ public: // Vertex types class OrderEitherVertex VL_NOT_FINAL : public V3GraphVertex { - AstScope* m_scopep; // Scope the vertex is in + AstScope* const m_scopep; // Scope the vertex is in AstSenTree* m_domainp; // Clock domain (nullptr = to be computed as we iterate) bool m_isFromInput = false; // From input, or derived therefrom (conservatively false) protected: @@ -172,7 +172,7 @@ public: }; class OrderLogicVertex final : public OrderEitherVertex { - AstNode* m_nodep; + AstNode* const m_nodep; protected: OrderLogicVertex(V3Graph* graphp, const OrderLogicVertex& old) @@ -200,7 +200,7 @@ public: }; class OrderVarVertex VL_NOT_FINAL : public OrderEitherVertex { - AstVarScope* m_varScp; + AstVarScope* const m_varScp; bool m_isClock = false; // Used as clock bool m_isDelayed = false; // Set in a delayed assignment protected: @@ -306,7 +306,7 @@ public: class OrderMoveVertex final : public V3GraphVertex { enum OrderMState : uint8_t { POM_WAIT, POM_READY, POM_MOVED }; - OrderLogicVertex* m_logicp; + OrderLogicVertex* const m_logicp; OrderMState m_state; // Movement state OrderMoveDomScope* m_domScopep; // Domain/scope list information @@ -376,10 +376,10 @@ class MTaskMoveVertex final : public V3GraphVertex { // This could be more compact, since we know m_varp and m_logicp // cannot both be set. Each MTaskMoveVertex represents a logic node // or a var node, it can't be both. - OrderLogicVertex* m_logicp; // Logic represented by this vertex - const OrderEitherVertex* m_varp; // Var represented by this vertex - const AstScope* m_scopep; - const AstSenTree* m_domainp; + OrderLogicVertex* const m_logicp; // Logic represented by this vertex + const OrderEitherVertex* const m_varp; // Var represented by this vertex + const AstScope* const m_scopep; + const AstSenTree* const m_domainp; protected: friend class OrderVisitor; @@ -449,7 +449,7 @@ public: // involving pre/pos variables virtual bool followComboConnected() const { return true; } static bool followComboConnected(const V3GraphEdge* edgep) { - const OrderEdge* oedgep = dynamic_cast(edgep); + const OrderEdge* const oedgep = dynamic_cast(edgep); if (!oedgep) v3fatalSrc("Following edge of non-OrderEdge type"); return (oedgep->followComboConnected()); } diff --git a/src/V3Os.cpp b/src/V3Os.cpp index d3b5e30b6..6e1417e4c 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -256,7 +256,7 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) { vluint64_t V3Os::rand64(std::array& stater) { // Xoroshiro128+ algorithm - vluint64_t result = stater[0] + stater[1]; + const vluint64_t result = stater[0] + stater[1]; stater[1] ^= stater[0]; stater[0] = (((stater[0] << 55) | (stater[0] >> 9)) ^ stater[1] ^ (stater[1] << 14)); stater[1] = (stater[1] << 36) | (stater[1] >> 28); diff --git a/src/V3Param.cpp b/src/V3Param.cpp index 4583c32c0..936720932 100644 --- a/src/V3Param.cpp +++ b/src/V3Param.cpp @@ -142,7 +142,7 @@ public: if (!pinp->exprp()) continue; UASSERT_OBJ(!pinp->modPTypep(), pinp, "module with type parameter must not be a hierarchical block"); - if (const AstVar* modvarp = pinp->modVarp()) { + if (const AstVar* const modvarp = pinp->modVarp()) { AstConst* const constp = VN_AS(pinp->exprp(), Const); UASSERT_OBJ(constp, pinp, "parameter for a hierarchical block must have been constified"); @@ -237,7 +237,7 @@ class ParamProcessor final { // STATE using CloneMap = std::unordered_map; struct ModInfo { - AstNodeModule* m_modp; // Module with specified name + AstNodeModule* const m_modp; // Module with specified name CloneMap m_cloneMap; // Map of old-varp -> new cloned varp explicit ModInfo(AstNodeModule* modp) : m_modp{modp} {} @@ -256,7 +256,7 @@ class ParamProcessor final { std::map m_valueMap; // Hash of node hash to (param value, name) int m_nextValue = 1; // Next value to use in m_valueMap - AstNodeModule* m_modp = nullptr; // Current module being processed + const AstNodeModule* m_modp = nullptr; // Current module being processed // Database to get lib-create wrapper that matches parameters in hierarchical Verilation ParameterizedHierBlocks m_hierBlocks; @@ -386,14 +386,14 @@ class ParamProcessor final { if (AstVar* const varp = VN_CAST(stmtp, Var)) { if (varp->isIO() || varp->isGParam() || varp->isIfaceRef()) { // Cloning saved a pointer to the new node for us, so just follow that link. - AstVar* const oldvarp = varp->clonep(); + const AstVar* const oldvarp = varp->clonep(); // UINFO(8,"Clone list 0x"< 0x"<<(uint32_t)varp<emplace(oldvarp, varp); } - } else if (AstParamTypeDType* ptp = VN_CAST(stmtp, ParamTypeDType)) { + } else if (AstParamTypeDType* const ptp = VN_CAST(stmtp, ParamTypeDType)) { if (ptp->isGParam()) { - AstParamTypeDType* const oldptp = ptp->clonep(); + const AstParamTypeDType* const oldptp = ptp->clonep(); clonemapp->emplace(oldptp, ptp); } } @@ -428,7 +428,7 @@ class ParamProcessor final { } } for (AstPin* pinp = startpinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { - if (AstVar* const varp = pinp->modVarp()) { + if (const AstVar* const varp = pinp->modVarp()) { const auto varIt = vlstd::as_const(nameToPin).find(varp->name()); UASSERT_OBJ(varIt != nameToPin.end(), varp, "Not found in " << modp->prettyNameQ()); @@ -471,10 +471,10 @@ class ParamProcessor final { std::map pins; for (AstPin* pinp = paramPinsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { checkSupportedParam(modp, pinp); - if (AstVar* const varp = pinp->modVarp()) { + if (const AstVar* const varp = pinp->modVarp()) { if (!pinp->exprp()) continue; if (varp->isGParam()) { - AstConst* constp = VN_CAST(pinp->exprp(), Const); + AstConst* const constp = VN_CAST(pinp->exprp(), Const); pins.emplace(varp->name(), constp); } } @@ -575,8 +575,8 @@ class ParamProcessor final { relinkPins(clonemapp, paramsp); // Fix any interface references for (auto it = ifaceRefRefs.cbegin(); it != ifaceRefRefs.cend(); ++it) { - AstIfaceRefDType* const portIrefp = it->first; - AstIfaceRefDType* const pinIrefp = it->second; + const AstIfaceRefDType* const portIrefp = it->first; + const AstIfaceRefDType* const pinIrefp = it->second; AstIfaceRefDType* const cloneIrefp = portIrefp->clonep(); UINFO(8, " IfaceOld " << portIrefp << endl); UINFO(8, " IfaceTo " << pinIrefp << endl); @@ -589,7 +589,7 @@ class ParamProcessor final { // DOES clone() so must be finished with module clonep() before here for (AstPin* pinp = paramsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) { if (pinp->exprp()) { - if (AstVar* modvarp = pinp->modVarp()) { + if (AstVar* const modvarp = pinp->modVarp()) { AstNode* const newp = pinp->exprp(); // Const or InitArray AstConst* const exprp = VN_CAST(newp, Const); AstConst* const origp = VN_CAST(modvarp->valuep(), Const); @@ -694,15 +694,15 @@ class ParamProcessor final { void cellInterfaceCleanup(AstCell* nodep, AstNodeModule* srcModp, string& longnamer, bool& any_overridesr, IfaceRefRefs& ifaceRefRefs) { for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) { - AstVar* const modvarp = pinp->modVarp(); + const AstVar* const modvarp = pinp->modVarp(); if (modvarp->isIfaceRef()) { AstIfaceRefDType* portIrefp = VN_CAST(modvarp->subDTypep(), IfaceRefDType); if (!portIrefp && arraySubDTypep(modvarp->subDTypep())) { portIrefp = VN_CAST(arraySubDTypep(modvarp->subDTypep()), IfaceRefDType); } AstIfaceRefDType* pinIrefp = nullptr; - AstNode* const exprp = pinp->exprp(); - AstVar* const varp + const AstNode* const exprp = pinp->exprp(); + const AstVar* const varp = (exprp && VN_IS(exprp, VarRef)) ? VN_AS(exprp, VarRef)->varp() : nullptr; if (varp && varp->subDTypep() && VN_IS(varp->subDTypep(), IfaceRefDType)) { pinIrefp = VN_AS(varp->subDTypep(), IfaceRefDType); @@ -974,7 +974,7 @@ class ParamVisitor final : public AstNVisitor { UINFO(9, "Found interface parameter: " << varp << endl); nodep->varp(varp); return true; - } else if (AstPin* const pinp = VN_CAST(candp, Pin)) { + } else if (const AstPin* const pinp = VN_CAST(candp, Pin)) { UINFO(9, "Found interface parameter: " << pinp << endl); UASSERT_OBJ(pinp->exprp(), pinp, "Interface parameter pin missing expression"); VL_DO_DANGLING(nodep->replaceWith(pinp->exprp()->cloneTree(false)), nodep); @@ -988,7 +988,7 @@ class ParamVisitor final : public AstNVisitor { // Check to see if the scope is just an interface because interfaces are special const string dotted = nodep->dotted(); if (!dotted.empty() && nodep->varp() && nodep->varp()->isParam()) { - AstNode* backp = nodep; + const AstNode* backp = nodep; while ((backp = backp->backp())) { if (VN_IS(backp, NodeModule)) { UINFO(9, "Hit module boundary, done looking for interface" << endl); @@ -1000,14 +1000,14 @@ class ParamVisitor final : public AstNVisitor { || (VN_CAST(VN_CAST(backp, Var)->childDTypep(), UnpackArrayDType) && VN_CAST(VN_CAST(backp, Var)->childDTypep()->getChildDTypep(), IfaceRefDType)))) { - AstIfaceRefDType* ifacerefp + const AstIfaceRefDType* ifacerefp = VN_CAST(VN_CAST(backp, Var)->childDTypep(), IfaceRefDType); if (!ifacerefp) { ifacerefp = VN_CAST(VN_CAST(backp, Var)->childDTypep()->getChildDTypep(), IfaceRefDType); } // Interfaces passed in on the port map have ifaces - if (AstIface* const ifacep = ifacerefp->ifacep()) { + if (const AstIface* const ifacep = ifacerefp->ifacep()) { if (dotted == backp->name()) { UINFO(9, "Iface matching scope: " << ifacep << endl); if (ifaceParamReplace(nodep, ifacep->stmtsp())) { // @@ -1016,7 +1016,7 @@ class ParamVisitor final : public AstNVisitor { } } // Interfaces declared in this module have cells - else if (AstCell* const cellp = ifacerefp->cellp()) { + else if (const AstCell* const cellp = ifacerefp->cellp()) { if (dotted == cellp->name()) { UINFO(9, "Iface matching scope: " << cellp << endl); if (ifaceParamReplace(nodep, cellp->paramsp())) { // @@ -1140,7 +1140,7 @@ class ParamVisitor final : public AstNVisitor { V3Width::widthParamsEdit(nodep); // Param typed widthing will NOT recurse the body, // don't trigger errors yet. V3Const::constifyParamsEdit(nodep->exprp()); // exprp may change - AstConst* const exprp = VN_AS(nodep->exprp(), Const); + const AstConst* const exprp = VN_AS(nodep->exprp(), Const); // Constify for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), CaseItem)) { diff --git a/src/V3ParseImp.cpp b/src/V3ParseImp.cpp index 22793e5ca..ef3f69d63 100644 --- a/src/V3ParseImp.cpp +++ b/src/V3ParseImp.cpp @@ -193,8 +193,8 @@ double V3ParseImp::lexParseTimenum(const char* textp) { if (*sp != '_') *dp++ = *sp; } *dp++ = '\0'; - double d = strtod(strgp, nullptr); - string suffix(sp); + const double d = strtod(strgp, nullptr); + const string suffix(sp); double divisor = 1; if (suffix == "s") { @@ -288,7 +288,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i if (v3Global.opt.preprocOnly() || v3Global.opt.keepTempFiles()) { // Create output file with all the preprocessor output we buffered up - string vppfilename + const string vppfilename = v3Global.opt.hierTopDataDir() + "/" + v3Global.opt.prefix() + "_" + modname + ".vpp"; std::ofstream* ofp = nullptr; std::ostream* osp; @@ -392,7 +392,7 @@ void V3ParseImp::tokenPipeline() { if (debugFlex() >= 6) { cout << " tokenPipeline: reading ahead to find possible strength" << endl; } - V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead + const V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead const V3ParseBisonYYSType* nexttokp = tokenPeekp(0); const int nexttok = nexttokp->token; yylval = curValue; @@ -467,7 +467,8 @@ void V3ParseImp::tokenPipeline() { if (nexttok == yP_COLONCOLON) { token = yaID__CC; } else if (nexttok == '#') { - V3ParseBisonYYSType curValue = yylval; // Remember value, as about to read ahead + const V3ParseBisonYYSType curValue + = yylval; // Remember value, as about to read ahead { const size_t depth = tokenPipeScanParam(0); if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC; @@ -487,8 +488,8 @@ void V3ParseImp::tokenPipelineSym() { tokenPipeline(); // sets yylval int token = yylval.token; if (token == yaID__LEX || token == yaID__CC) { - VSymEnt* foundp; - if (VSymEnt* const look_underp = V3ParseImp::parsep()->symp()->nextId()) { + const VSymEnt* foundp; + if (const VSymEnt* const look_underp = V3ParseImp::parsep()->symp()->nextId()) { UINFO(7, " tokenPipelineSym: next id lookup forced under " << look_underp << endl); // if (debug() >= 7) V3ParseImp::parsep()->symp()->dump(cout, " -symtree: "); foundp = look_underp->findIdFallback(*(yylval.strp)); diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index 38949ddc5..3d6dae636 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -133,8 +133,8 @@ std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs); class V3ParseImp final { // MEMBERS - AstNetlist* m_rootp; // Root of the design - VInFilter* m_filterp; // Reading filter + AstNetlist* const m_rootp; // Root of the design + VInFilter* const m_filterp; // Reading filter V3ParseSym* m_symp; // Symbol table V3Lexer* m_lexerp; // Current FlexLexer @@ -229,18 +229,18 @@ public: // These can be called by either parser or lexer, as not lex/parser-position aware string* newString(const string& text) { // Allocate a string, remembering it so we can reclaim storage at lex end - string* strp = new string(text); + string* const strp = new string(text); m_stringps.push_back(strp); return strp; } string* newString(const char* text) { // Allocate a string, remembering it so we can reclaim storage at lex end - string* strp = new string(text); + string* const strp = new string(text); m_stringps.push_back(strp); return strp; } string* newString(const char* text, size_t length) { - string* strp = new string(text, length); + string* const strp = new string(text, length); m_stringps.push_back(strp); return strp; } @@ -275,7 +275,8 @@ public: V3ParseSym* symp() { return m_symp; } AstPackage* unitPackage(FileLine* fl) { // Find one made earlier? - VSymEnt* const rootSymp = symp()->symRootp()->findIdFlat(AstPackage::dollarUnitName()); + const VSymEnt* const rootSymp + = symp()->symRootp()->findIdFlat(AstPackage::dollarUnitName()); AstPackage* pkgp; if (!rootSymp) { pkgp = parsep()->rootp()->dollarUnitPkgAddp(); diff --git a/src/V3ParseSym.h b/src/V3ParseSym.h index e73ede79f..f6291fb58 100644 --- a/src/V3ParseSym.h +++ b/src/V3ParseSym.h @@ -66,7 +66,7 @@ public: VSymEnt* findNewTable(AstNode* nodep) { if (!nodep->user4p()) { - VSymEnt* symsp = new VSymEnt(&m_syms, nodep); + VSymEnt* const symsp = new VSymEnt(&m_syms, nodep); nodep->user4p(symsp); } return getTable(nodep); @@ -93,7 +93,7 @@ public: void pushNew(AstNode* nodep) { pushNewUnder(nodep, nullptr); } void pushNewUnder(AstNode* nodep, VSymEnt* parentp) { if (!parentp) parentp = symCurrentp(); - VSymEnt* symp + VSymEnt* const symp = findNewTable(nodep); // Will set user4p, which is how we connect table to node symp->fallbackp(parentp); reinsert(nodep, parentp); @@ -128,7 +128,7 @@ public: void showUpward() { // LCOV_EXCL_START UINFO(1, "ParseSym Stack:\n"); for (auto it = m_sympStack.rbegin(); it != m_sympStack.rend(); ++it) { - VSymEnt* symp = *it; + VSymEnt* const symp = *it; UINFO(1, " " << symp->nodep() << endl); } UINFO(1, "ParseSym Current: " << symCurrentp()->nodep() << endl); @@ -136,7 +136,7 @@ public: void dump(std::ostream& os, const string& indent = "") { m_syms.dump(os, indent); } AstNode* findEntUpward(const string& name) const { // Lookup the given string as an identifier, return type of the id, scanning upward - VSymEnt* foundp = symCurrentp()->findIdFallback(name); + VSymEnt* const foundp = symCurrentp()->findIdFallback(name); if (foundp) { return foundp->nodep(); } else { @@ -145,7 +145,7 @@ public: } void importExtends(AstNode* classp) { // Import from package::id_or_star to this - VSymEnt* symp = getTable(classp); + VSymEnt* const symp = getTable(classp); UASSERT_OBJ(symp, classp, // Internal problem, because we earlier found it "Extends class package not found"); // Walk old sym table and reinsert into current table @@ -154,7 +154,7 @@ public: } void importItem(AstNode* packagep, const string& id_or_star) { // Import from package::id_or_star to this - VSymEnt* symp = getTable(packagep); + VSymEnt* const symp = getTable(packagep); UASSERT_OBJ(symp, packagep, // Internal problem, because we earlier found it "Import package not found"); // Walk old sym table and reinsert into current table @@ -163,7 +163,7 @@ public: } void exportItem(AstNode* packagep, const string& id_or_star) { // Export from this the remote package::id_or_star - VSymEnt* symp = getTable(packagep); + VSymEnt* const symp = getTable(packagep); UASSERT_OBJ(symp, packagep, // Internal problem, because we earlier found it "Export package not found"); symCurrentp()->exportFromPackage(&m_syms, symp, id_or_star); diff --git a/src/V3Partition.cpp b/src/V3Partition.cpp index de8f72e91..8895c6cd8 100644 --- a/src/V3Partition.cpp +++ b/src/V3Partition.cpp @@ -162,12 +162,12 @@ static void partCheckCachedScoreVsActual(uint32_t cached, uint32_t actual) { template class PartPropagateCp : GraphAlg<> { private: // MEMBERS - GraphWay m_way; // CPs oriented in this direction: either FORWARD + const GraphWay m_way; // CPs oriented in this direction: either FORWARD // // from graph-start to current node, or REVERSE // // from graph-end to current node. T_CostAccessor* const m_accessp; // Access cost and CPs on V3GraphVertex's. // // confirm we only process each vertex once. - bool m_slowAsserts; // Enable nontrivial asserts + const bool m_slowAsserts; // Enable nontrivial asserts SortByValueMap m_pending; // Pending rescores public: @@ -291,7 +291,7 @@ private: // direction, it assumes REVERSE is symmetrical and would be // redundant to test. GraphStreamUnordered order(&m_graph); - while (const V3GraphVertex* cvxp = order.nextp()) { + while (const V3GraphVertex* const cvxp = order.nextp()) { V3GraphVertex* const vxp = const_cast(cvxp); uint32_t cpCost = 0; for (V3GraphEdge* edgep = vxp->inBeginp(); edgep; edgep = edgep->inNextp()) { @@ -401,7 +401,7 @@ public: // Check that CP matches that of the longest edge wayward of vxp. void checkNewCpVersusEdges(V3GraphVertex* vxp, GraphWay way, uint32_t cp) const { LogicMTask* const mtaskp = dynamic_cast(vxp); - EdgeSet& edges = mtaskp->m_edges[way.invert()]; + const EdgeSet& edges = mtaskp->m_edges[way.invert()]; // This is mtaskp's relative with longest !wayward inclusive CP: const auto edgeIt = edges.rbegin(); const uint32_t edgeCp = (*edgeIt).value(); @@ -454,7 +454,7 @@ public: for (unsigned int& i : m_critPathCost) i = 0; if (mtmvVxp) { // Else null for test m_vertices.push_back(mtmvVxp); - if (OrderLogicVertex* const olvp = mtmvVxp->logicp()) { + if (const OrderLogicVertex* const olvp = mtmvVxp->logicp()) { m_cost += V3InstrCount::count(olvp->nodep(), true); } } @@ -527,7 +527,7 @@ public: void checkRelativesCp(GraphWay way) const { const EdgeSet& edges = m_edges[way]; for (EdgeSet::const_reverse_iterator it = edges.rbegin(); it != edges.rend(); ++it) { - LogicMTask* const relativep = (*it).key(); + const LogicMTask* const relativep = (*it).key(); const uint32_t cachedCp = (*it).value(); partCheckCachedScoreVsActual(cachedCp, relativep->critPathCost(way.invert()) + relativep->stepCost()); @@ -625,7 +625,7 @@ public: static void dumpCpFilePrefixed(const V3Graph* graphp, const string& nameComment) { const string filename = v3Global.debugFilename(nameComment) + ".txt"; UINFO(1, "Writing " << filename << endl); - std::unique_ptr ofp{V3File::new_ofstream(filename)}; + const std::unique_ptr ofp{V3File::new_ofstream(filename)}; std::ostream* const osp = &(*ofp); // &* needed to deref unique_ptr if (osp->fail()) v3fatalStatic("Can't write " << filename); @@ -652,7 +652,7 @@ public: totalCost += nextp->cost(); const EdgeSet& children = nextp->m_edges[GraphWay::FORWARD]; - EdgeSet::const_reverse_iterator it = children.rbegin(); + const EdgeSet::const_reverse_iterator it = children.rbegin(); if (it == children.rend()) { nextp = nullptr; } else { @@ -976,7 +976,7 @@ static void partInitHalfCriticalPaths(GraphWay way, V3Graph* mtasksp, bool check "Should be no redundant edges in mtasks graph"); relatives.insert(edgep->furtherp(rev)); #endif - LogicMTask* const relativep = dynamic_cast(edgep->furtherp(rev)); + const LogicMTask* const relativep = dynamic_cast(edgep->furtherp(rev)); cpCost = std::max(cpCost, (relativep->critPathCost(way) + static_cast(relativep->stepCost()))); } @@ -1009,7 +1009,7 @@ static void partCheckCriticalPaths(V3Graph* mtasksp) { partInitHalfCriticalPaths(GraphWay::FORWARD, mtasksp, true); partInitHalfCriticalPaths(GraphWay::REVERSE, mtasksp, true); for (V3GraphVertex* vxp = mtasksp->verticesBeginp(); vxp; vxp = vxp->verticesNextp()) { - LogicMTask* const mtaskp = dynamic_cast(vxp); + const LogicMTask* const mtaskp = dynamic_cast(vxp); mtaskp->checkRelativesCp(GraphWay::FORWARD); mtaskp->checkRelativesCp(GraphWay::REVERSE); } @@ -1059,12 +1059,12 @@ static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMT V3Scoreboard* sbp) { for (const auto& way : {GraphWay::FORWARD, GraphWay::REVERSE}) { for (V3GraphEdge* edgep = donorp->beginp(way); edgep; edgep = partBlastEdgep(way, edgep)) { - MTaskEdge* const tedgep = MTaskEdge::cast(edgep); + const MTaskEdge* const tedgep = MTaskEdge::cast(edgep); if (sbp && !tedgep->removedFromSb()) sbp->removeElem(tedgep); // Existing edge; mark it in need of a rescore if (recipientp->hasRelative(way, tedgep->furtherMTaskp(way))) { if (sbp) { - MTaskEdge* const existMTaskEdgep = MTaskEdge::cast( + const MTaskEdge* const existMTaskEdgep = MTaskEdge::cast( recipientp->findConnectingEdgep(way, tedgep->furtherMTaskp(way))); UASSERT(existMTaskEdgep, "findConnectingEdge didn't find edge"); if (!existMTaskEdgep->removedFromSb()) { @@ -1073,7 +1073,7 @@ static void partMergeEdgesFrom(V3Graph* mtasksp, LogicMTask* recipientp, LogicMT } } else { // No existing edge into *this, make one. - MTaskEdge* newEdgep; + const MTaskEdge* newEdgep; if (way == GraphWay::REVERSE) { newEdgep = new MTaskEdge(mtasksp, tedgep->fromMTaskp(), recipientp, 1); } else { @@ -1112,7 +1112,7 @@ private: uint32_t m_scoreLimit; // Sloppy score allowed when picking merges uint32_t m_scoreLimitBeforeRescore = 0xffffffff; // Next score rescore at unsigned m_mergesSinceRescore = 0; // Merges since last rescore - bool m_slowAsserts; // Take extra time to validate algorithm + const bool m_slowAsserts; // Take extra time to validate algorithm V3Scoreboard m_sb; // Scoreboard SibSet m_pairs; // Storage for each SiblingMC MTask2Sibs m_mtask2sibs; // SiblingMC set for each mtask @@ -1210,7 +1210,7 @@ public: ++mtaskCount; } if (mtaskCount > maxMTasks) { - uint32_t oldLimit = m_scoreLimit; + const uint32_t oldLimit = m_scoreLimit; m_scoreLimit = (m_scoreLimit * 120) / 100; v3Global.rootp()->fileline()->v3warn( UNOPTTHREADS, "Thread scheduler is unable to provide requested " @@ -1309,7 +1309,7 @@ private: ++it) { const SiblingMC* const pairp = *it; if (!pairp->removedFromSb()) m_sb.removeElem(pairp); - LogicMTask* const otherp = (pairp->bp() == mtaskp) ? pairp->ap() : pairp->bp(); + const LogicMTask* const otherp = (pairp->bp() == mtaskp) ? pairp->ap() : pairp->bp(); size_t erased = m_mtask2sibs[otherp].erase(pairp); UASSERT_OBJ(erased > 0, otherp, "Expected existing mtask"); erased = m_pairs.erase(*pairp); @@ -1323,7 +1323,7 @@ private: LogicMTask* top = nullptr; LogicMTask* fromp = nullptr; MTaskEdge* mergeEdgep = mergeCanp->toMTaskEdge(); - SiblingMC* mergeSibsp = nullptr; + const SiblingMC* mergeSibsp = nullptr; if (mergeEdgep) { top = dynamic_cast(mergeEdgep->top()); fromp = dynamic_cast(mergeEdgep->fromp()); @@ -1490,8 +1490,8 @@ private: // Score this edge. Lower is better. The score is the new local CP // length if we merge these mtasks. ("Local" means the longest // critical path running through the merged node.) - LogicMTask* const top = dynamic_cast(edgep->top()); - LogicMTask* const fromp = dynamic_cast(edgep->fromp()); + const LogicMTask* const top = dynamic_cast(edgep->top()); + const LogicMTask* const fromp = dynamic_cast(edgep->fromp()); const uint32_t mergedCpCostFwd = std::max(fromp->critPathCost(GraphWay::FORWARD), top->critPathCostWithout(GraphWay::FORWARD, edgep)); @@ -1503,8 +1503,8 @@ private: } void makeSiblingMC(LogicMTask* ap, LogicMTask* bp) { - SiblingMC newSibs(ap, bp); - std::pair insertResult = m_pairs.insert(newSibs); + const SiblingMC newSibs(ap, bp); + const std::pair insertResult = m_pairs.insert(newSibs); if (insertResult.second) { const SiblingMC* const newSibsp = &(*insertResult.first); m_mtask2sibs[ap].insert(newSibsp); @@ -1592,7 +1592,7 @@ private: static vluint64_t partitionChainUsecs(unsigned chain_len) { // NOTE: To get a dot file run with --debugi-V3Partition 4 or more. - vluint64_t startUsecs = V3Os::timeUsecs(); + const vluint64_t startUsecs = V3Os::timeUsecs(); V3Graph mtasks; LogicMTask* lastp = nullptr; for (unsigned i = 0; i < chain_len; ++i) { @@ -1839,7 +1839,7 @@ private: void findAdjacentTasks(OvvSet::iterator ovvIt, TasksByRank* tasksByRankp) { // Find all writer tasks for this variable, group by rank. for (V3GraphEdge* edgep = (*ovvIt)->inBeginp(); edgep; edgep = edgep->inNextp()) { - OrderLogicVertex* const logicp = dynamic_cast(edgep->fromp()); + const OrderLogicVertex* const logicp = dynamic_cast(edgep->fromp()); if (!logicp) continue; if (logicp->domainp()->hasInitial() || logicp->domainp()->hasSettle()) continue; LogicMTask* const writerMtaskp = m_olv2mtask.at(logicp); @@ -1847,7 +1847,7 @@ private: } // Find all reader tasks for this variable, group by rank. for (V3GraphEdge* edgep = (*ovvIt)->outBeginp(); edgep; edgep = edgep->outNextp()) { - OrderLogicVertex* const logicp = dynamic_cast(edgep->fromp()); + const OrderLogicVertex* const logicp = dynamic_cast(edgep->fromp()); if (!logicp) continue; if (logicp->domainp()->hasInitial() || logicp->domainp()->hasSettle()) continue; LogicMTask* const readerMtaskp = m_olv2mtask.at(logicp); @@ -1882,8 +1882,8 @@ private: // Fix up the map, so donor's OLVs map to mergedp for (LogicMTask::VxList::const_iterator tmvit = donorp->vertexListp()->begin(); tmvit != donorp->vertexListp()->end(); ++tmvit) { - MTaskMoveVertex* const tmvp = *tmvit; - OrderLogicVertex* const logicp = tmvp->logicp(); + const MTaskMoveVertex* const tmvp = *tmvit; + const OrderLogicVertex* const logicp = tmvp->logicp(); if (logicp) m_olv2mtask[logicp] = mergedp; } // Move all vertices from donorp to mergedp @@ -1942,15 +1942,15 @@ public: // stage, but whatever, write it as a loop: for (LogicMTask::VxList::const_iterator it = mtaskp->vertexListp()->begin(); it != mtaskp->vertexListp()->end(); ++it) { - MTaskMoveVertex* const tmvp = *it; - if (OrderLogicVertex* const logicp = tmvp->logicp()) { + const MTaskMoveVertex* const tmvp = *it; + if (const OrderLogicVertex* const logicp = tmvp->logicp()) { m_olv2mtask[logicp] = mtaskp; // Look at downstream vars. for (V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) { // Only consider OrderVarStdVertex which reflects // an actual lvalue assignment; the others do not. - OrderVarStdVertex* const ovvp + const OrderVarStdVertex* const ovvp = dynamic_cast(edgep->top()); if (!ovvp) continue; if (ovvp->varScp()->varp()->isSc()) { @@ -2145,7 +2145,7 @@ void ThreadSchedule::dumpDotFile(const string& filename) const { // This generates a file used by graphviz, https://www.graphviz.org const std::unique_ptr logp{V3File::new_ofstream(filename)}; if (logp->fail()) v3fatal("Can't write " << filename); - auto* depGraph = v3Global.rootp()->execGraphp()->depGraphp(); + auto* const depGraph = v3Global.rootp()->execGraphp()->depGraphp(); // Header *logp << "digraph v3graph {\n"; @@ -2172,18 +2172,18 @@ void ThreadSchedule::dumpDotFile(const string& filename) const { } } const double minWidth = 2.0; - auto mtaskXPos = [&](const ExecMTask* mtaskp, const double nodeWidth) { + const auto mtaskXPos = [&](const ExecMTask* mtaskp, const double nodeWidth) { const double startPosX = (minWidth * startTime(mtaskp)) / minCost; return nodeWidth / minWidth + startPosX; }; - auto emitMTask = [&](const ExecMTask* mtaskp) { + const auto emitMTask = [&](const ExecMTask* mtaskp) { const int thread = threadId(mtaskp); const double nodeWidth = minWidth * (static_cast(mtaskp->cost()) / minCost); const double x = mtaskXPos(mtaskp, nodeWidth); const int y = -thread; - string label = "label=\"" + mtaskp->name() + " (" + cvtToStr(startTime(mtaskp)) + ":" - + std::to_string(endTime(mtaskp)) + ")" + "\""; + const string label = "label=\"" + mtaskp->name() + " (" + cvtToStr(startTime(mtaskp)) + ":" + + std::to_string(endTime(mtaskp)) + ")" + "\""; *logp << " " << mtaskp->name() << " [" << label << " width=" << nodeWidth << " pos=\"" << x << "," << y << "!\"]\n"; }; @@ -2625,7 +2625,8 @@ void V3Partition::go(V3Graph* mtasksp) { // when scheduling them. const unsigned fudgeNumerator = 3; const unsigned fudgeDenominator = 5; - uint32_t cpLimit = ((totalGraphCost * fudgeNumerator) / (targetParFactor * fudgeDenominator)); + const uint32_t cpLimit + = ((totalGraphCost * fudgeNumerator) / (targetParFactor * fudgeDenominator)); UINFO(4, "V3Partition set cpLimit = " << cpLimit << endl); // Merge MTask nodes together, repeatedly, until the CP budget is @@ -2672,7 +2673,7 @@ void V3Partition::go(V3Graph* mtasksp) { // Set color to indicate an mtaskId on every underlying MTaskMoveVertex. for (V3GraphVertex* itp = mtasksp->verticesBeginp(); itp; itp = itp->verticesNextp()) { - LogicMTask* const mtaskp = dynamic_cast(itp); + const LogicMTask* const mtaskp = dynamic_cast(itp); for (LogicMTask::VxList::const_iterator it = mtaskp->vertexListp()->begin(); it != mtaskp->vertexListp()->end(); ++it) { MTaskMoveVertex* const mvertexp = *it; @@ -2728,7 +2729,7 @@ static void normalizeCosts(Costs& costs) { UINFO(9, "Post uint scale: ce = " << est.second.first << " cp=" << est.second.second << endl); } - vluint64_t scaleDownTo = 10000000; // Extra room for future algorithms to add costs + const vluint64_t scaleDownTo = 10000000; // Extra room for future algorithms to add costs if (maxCost > scaleDownTo) { const double scaleup = static_cast(scaleDownTo) / static_cast(maxCost); UINFO(5, "Scaling data to within 32-bits by multiply by=" << scaleup << ", maxCost=" @@ -2826,7 +2827,7 @@ static void fillinCosts(V3Graph* execMTaskGraphp) { static void finalizeCosts(V3Graph* execMTaskGraphp) { GraphStreamUnordered ser(execMTaskGraphp, GraphWay::REVERSE); - while (const V3GraphVertex* vxp = ser.nextp()) { + while (const V3GraphVertex* const vxp = ser.nextp()) { ExecMTask* const mtp = dynamic_cast(const_cast(vxp)); // "Priority" is the critical path from the start of the mtask, to // the end of the graph reachable from this mtask. Given the @@ -2834,7 +2835,7 @@ static void finalizeCosts(V3Graph* execMTaskGraphp) { // highest priority one first, so we're always working on the "long // pole" for (V3GraphEdge* edgep = mtp->outBeginp(); edgep; edgep = edgep->outNextp()) { - ExecMTask* const followp = dynamic_cast(edgep->top()); + const ExecMTask* const followp = dynamic_cast(edgep->top()); if ((followp->priority() + mtp->cost()) > mtp->priority()) { mtp->priority(followp->priority() + mtp->cost()); } diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index bcfa9af8f..d1786aecb 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -47,9 +47,9 @@ class VDefine final { // Define class. One for each define. // string m_name; // Name of the define (list is keyed by this) FileLine* const m_fileline; // Where it was declared - string m_value; // Value of define - string m_params; // Parameters - bool m_cmdline; // Set on command line, don't `undefineall + const string m_value; // Value of define + const string m_params; // Parameters + const bool m_cmdline; // Set on command line, don't `undefineall public: VDefine(FileLine* fl, const string& value, const string& params, bool cmdline) : m_fileline{fl} @@ -66,8 +66,8 @@ public: class VDefineRef final { // One for each pending define substitution - string m_name; // Define last name being defined - string m_params; // Define parameter list for next expansion + const string m_name; // Define last name being defined + const string m_params; // Define parameter list for next expansion string m_nextarg; // String being built for next argument int m_parenLevel = 0; // Parenthesis counting inside def args (for PARENT not child) @@ -91,8 +91,8 @@ public: class VPreIfEntry final { // One for each pending ifdef/ifndef - bool m_on; // Current parse for this ifdef level is "on" - bool m_everOn; // Some if term in elsif tree has been on + const bool m_on; // Current parse for this ifdef level is "on" + const bool m_everOn; // Some if term in elsif tree has been on public: bool on() const { return m_on; } bool everOn() const { return m_everOn; } @@ -117,7 +117,7 @@ public: DefinesMap m_defines; ///< Map of defines // STATE - V3PreProc* m_preprocp = nullptr; ///< Object we're holding data for + const V3PreProc* m_preprocp = nullptr; ///< Object we're holding data for V3PreLex* m_lexp = nullptr; ///< Current lexer state (nullptr = closed) std::stack m_includeStack; ///< Stack of includers above current m_lexp int m_lastLineno = 0; // Last line number (stall detection) @@ -496,7 +496,7 @@ void V3PreProc::debug(int level) { } FileLine* V3PreProc::fileline() { - V3PreProcImp* idatap = static_cast(this); + const V3PreProcImp* idatap = static_cast(this); return idatap->m_lexp->m_tokFilelinep; } @@ -1180,7 +1180,7 @@ int V3PreProcImp::getStateToken() { if (VL_UNCOVERABLE(m_defRefs.empty())) { fatalSrc("Shouldn't be in DEFPAREN w/o active defref"); } - VDefineRef* const refp = &(m_defRefs.top()); + const VDefineRef* const refp = &(m_defRefs.top()); error(string("Expecting ( to begin argument list for define reference `") + refp->name() + "\n"); statePop(); @@ -1612,7 +1612,7 @@ string V3PreProcImp::getline() { // Make new string with data up to the newline. const int len = rtnp - m_lineChars.c_str() + 1; - string theLine(m_lineChars, 0, len); + const string theLine(m_lineChars, 0, len); m_lineChars = m_lineChars.erase(0, len); // Remove returned characters if (debug() >= 4) { const string lncln = V3PreLex::cleanDbgStrg(theLine); diff --git a/src/V3Premit.cpp b/src/V3Premit.cpp index 24babc53c..68cad721f 100644 --- a/src/V3Premit.cpp +++ b/src/V3Premit.cpp @@ -266,7 +266,7 @@ private: // Shifts of > 32/64 bits in C++ will wrap-around and generate non-0s if (!nodep->user2SetOnce()) { UINFO(4, " ShiftFix " << nodep << endl); - const AstConst* shiftp = VN_CAST(nodep->rhsp(), Const); + const AstConst* const shiftp = VN_CAST(nodep->rhsp(), Const); if (shiftp && shiftp->num().mostSetBitP1() > 32) { shiftp->v3error( "Unsupported: Shifting of by over 32-bit number isn't supported." @@ -279,7 +279,7 @@ private: AstNRelinker replaceHandle; nodep->unlinkFrBack(&replaceHandle); AstNode* constzerop; - int m1value + const int m1value = nodep->widthMin() - 1; // Constant of width-1; not changing dtype width if (nodep->signedFlavor()) { // Then over shifting gives the sign bit, not all zeros @@ -295,10 +295,11 @@ private: } constzerop->dtypeFrom(nodep); // unsigned - AstNode* constwidthp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), - nodep->rhsp()->widthMin(), m1value); + AstNode* const constwidthp + = new AstConst(nodep->fileline(), AstConst::WidthedValue(), + nodep->rhsp()->widthMin(), m1value); constwidthp->dtypeFrom(nodep->rhsp()); // unsigned - AstCond* newp = new AstCond( + AstCond* const newp = new AstCond( nodep->fileline(), new AstGte(nodep->fileline(), constwidthp, nodep->rhsp()->cloneTree(false)), nodep, constzerop); @@ -381,7 +382,7 @@ private: iterateChildren(nodep); m_stmtp = nullptr; if (v3Global.opt.autoflush()) { - AstNode* searchp = nodep->nextp(); + const AstNode* searchp = nodep->nextp(); while (searchp && VN_IS(searchp, Comment)) searchp = searchp->nextp(); if (searchp && VN_IS(searchp, Display) && nodep->filep()->sameGateTree(VN_AS(searchp, Display)->filep())) { diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index b79fe56df..aa8f7230f 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -87,7 +87,7 @@ private: iterateChildren(nodep); - V3Hash hash = V3Hasher::uncachedHash(m_cfilep); + const V3Hash hash = V3Hasher::uncachedHash(m_cfilep); m_hashValuep->addText(fl, cvtToStr(hash.value()) + ";\n"); m_cHashValuep->addText(fl, cvtToStr(hash.value()) + "U;\n"); m_foundTop = true; diff --git a/src/V3Randomize.cpp b/src/V3Randomize.cpp index d1241cf08..c4821b87e 100644 --- a/src/V3Randomize.cpp +++ b/src/V3Randomize.cpp @@ -217,7 +217,7 @@ private: = new AstVarRef(nodep->fileline(), memberVarp, VAccess::WRITE); auto* const stmtp = newRandStmtsp(nodep->fileline(), refp); funcp->addStmtsp(stmtp); - } else if (auto* classRefp = VN_CAST(dtypep, ClassRefDType)) { + } else if (const auto* const classRefp = VN_CAST(dtypep, ClassRefDType)) { auto* const refp = new AstVarRef(nodep->fileline(), memberVarp, VAccess::WRITE); auto* const memberFuncp = V3Randomize::newRandomizeFunc(classRefp->classp()); @@ -253,7 +253,7 @@ public: void V3Randomize::randomizeNetlist(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - RandomizeMarkVisitor markVisitor{nodep}; + const RandomizeMarkVisitor markVisitor{nodep}; RandomizeVisitor{nodep}; } V3Global::dumpCheckGlobalTree("randomize", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); diff --git a/src/V3Reloop.cpp b/src/V3Reloop.cpp index 77508429d..edf144d16 100644 --- a/src/V3Reloop.cpp +++ b/src/V3Reloop.cpp @@ -54,13 +54,13 @@ private: std::vector m_mgAssignps; // List of assignments merging AstCFunc* m_mgCfuncp = nullptr; // Parent C function - AstNode* m_mgNextp = nullptr; // Next node - AstNodeSel* m_mgSelLp = nullptr; // Parent select, nullptr = idle - AstNodeSel* m_mgSelRp = nullptr; // Parent select, nullptr = constant - AstNodeVarRef* m_mgVarrefLp = nullptr; // Parent varref - AstNodeVarRef* m_mgVarrefRp = nullptr; // Parent varref, nullptr = constant + const AstNode* m_mgNextp = nullptr; // Next node + const AstNodeSel* m_mgSelLp = nullptr; // Parent select, nullptr = idle + const AstNodeSel* m_mgSelRp = nullptr; // Parent select, nullptr = constant + const AstNodeVarRef* m_mgVarrefLp = nullptr; // Parent varref + const AstNodeVarRef* m_mgVarrefRp = nullptr; // Parent varref, nullptr = constant int64_t m_mgOffset = 0; // Index offset - AstConst* m_mgConstRp = nullptr; // Parent RHS constant, nullptr = sel + const AstConst* m_mgConstRp = nullptr; // Parent RHS constant, nullptr = sel uint32_t m_mgIndexLo = 0; // Merge range uint32_t m_mgIndexHi = 0; // Merge range @@ -80,7 +80,7 @@ private: } void mergeEnd() { if (!m_mgAssignps.empty()) { - uint32_t items = m_mgIndexHi - m_mgIndexLo + 1; + const uint32_t items = m_mgIndexHi - m_mgIndexLo + 1; UINFO(9, "End merge iter=" << items << " " << m_mgIndexHi << ":" << m_mgIndexLo << " " << m_mgOffset << " " << m_mgAssignps[0] << endl); if (items >= static_cast(v3Global.opt.reloopLimit())) { @@ -162,7 +162,7 @@ private: if (!m_cfuncp) return; // Left select WordSel or ArraySel - AstNodeSel* lselp = VN_CAST(nodep->lhsp(), NodeSel); + AstNodeSel* const lselp = VN_CAST(nodep->lhsp(), NodeSel); if (!lselp) { // Not ever merged mergeEnd(); return; @@ -179,16 +179,16 @@ private: } const uint32_t lindex = lbitp->toUInt(); // Of variable - AstNodeVarRef* const lvarrefp = VN_CAST(lselp->fromp(), NodeVarRef); + const AstNodeVarRef* const lvarrefp = VN_CAST(lselp->fromp(), NodeVarRef); if (!lvarrefp) { mergeEnd(); return; } // RHS is a constant or a select - AstConst* const rconstp = VN_CAST(nodep->rhsp(), Const); - AstNodeSel* const rselp = VN_CAST(nodep->rhsp(), NodeSel); - AstNodeVarRef* rvarrefp = nullptr; + const AstConst* const rconstp = VN_CAST(nodep->rhsp(), Const); + const AstNodeSel* const rselp = VN_CAST(nodep->rhsp(), NodeSel); + const AstNodeVarRef* rvarrefp = nullptr; uint32_t rindex = lindex; if (rconstp) { // Ok } else if (rselp) { diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 6b31c84c9..5a288cde2 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -401,7 +401,7 @@ public: void V3Scope::scopeAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { - ScopeVisitor visitor{nodep}; + const ScopeVisitor visitor{nodep}; ScopeCleanupVisitor{nodep}; } // Destruct before checking V3Global::dumpCheckGlobalTree("scope", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); diff --git a/src/V3Scoreboard.h b/src/V3Scoreboard.h index edb2165de..4e68d9f8c 100644 --- a/src/V3Scoreboard.h +++ b/src/V3Scoreboard.h @@ -355,7 +355,7 @@ private: class CmpElems final { public: bool operator()(const T_Elem* const& ap, const T_Elem* const& bp) const { - T_ElemCompare cmp; + const T_ElemCompare cmp; return cmp.operator()(*ap, *bp); } }; @@ -369,8 +369,8 @@ private: // set members, set is better performant. std::set m_unknown; // Elements with unknown scores SortedMap m_sorted; // Set of elements with known scores - UserScoreFnp m_scoreFnp; // Scoring function - bool m_slowAsserts; // Do some asserts that require extra lookups + const UserScoreFnp m_scoreFnp; // Scoring function + const bool m_slowAsserts; // Do some asserts that require extra lookups public: // CONSTRUCTORS diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 8b96b97a6..d4afec168 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -115,10 +115,10 @@ private: // Potentially very slow, intended for debugging string prettyNumber(const V3Number* nump, AstNodeDType* dtypep) { - if (AstRefDType* refdtypep = VN_CAST(dtypep, RefDType)) { // + if (AstRefDType* const refdtypep = VN_CAST(dtypep, RefDType)) { // dtypep = refdtypep->skipRefp(); } - if (AstStructDType* stp = VN_CAST(dtypep, StructDType)) { + if (AstStructDType* const stp = VN_CAST(dtypep, StructDType)) { if (stp->packed()) { std::ostringstream out; out << "'{"; @@ -130,7 +130,7 @@ private: V3Number fieldNum(nump, width); fieldNum.opSel(*nump, msb, lsb); out << itemp->name() << ": "; - if (AstNodeDType* childTypep = itemp->subDTypep()) { + if (AstNodeDType* const childTypep = itemp->subDTypep()) { out << prettyNumber(&fieldNum, childTypep); } else { out << fieldNum; @@ -140,8 +140,8 @@ private: out << "}"; return out.str(); } - } else if (AstPackArrayDType* arrayp = VN_CAST(dtypep, PackArrayDType)) { - if (AstNodeDType* childTypep = arrayp->subDTypep()) { + } else if (const AstPackArrayDType* const arrayp = VN_CAST(dtypep, PackArrayDType)) { + if (AstNodeDType* const childTypep = arrayp->subDTypep()) { std::ostringstream out; out << "["; const int arrayElements = arrayp->elementsConst(); @@ -180,16 +180,16 @@ public: m_whyNotOptimizable = why; std::ostringstream stack; for (auto it = m_callStack.rbegin(); it != m_callStack.rend(); ++it) { - AstFuncRef* funcp = (*it)->m_funcp; + AstFuncRef* const funcp = (*it)->m_funcp; stack << "\n " << funcp->fileline() << "... Called from " << funcp->prettyName() << "() with parameters:"; V3TaskConnects* tconnects = (*it)->m_tconnects; for (V3TaskConnects::iterator conIt = tconnects->begin(); conIt != tconnects->end(); ++conIt) { - AstVar* portp = conIt->first; - AstNode* pinp = conIt->second->exprp(); - AstNodeDType* dtypep = pinp->dtypep(); - if (AstConst* valp = fetchConstNull(pinp)) + AstVar* const portp = conIt->first; + AstNode* const pinp = conIt->second->exprp(); + AstNodeDType* const dtypep = pinp->dtypep(); + if (AstConst* const valp = fetchConstNull(pinp)) stack << "\n " << portp->prettyName() << " = " << prettyNumber(&valp->num(), dtypep); } @@ -245,7 +245,7 @@ private: public: void newValue(AstNode* nodep, const AstNode* valuep) { - if (const AstConst* constp = VN_CAST(valuep, Const)) { + if (const AstConst* const constp = VN_CAST(valuep, Const)) { newConst(nodep)->num().opAssign(constp->num()); } else if (fetchValueNull(nodep) != valuep) { // const_cast, as clonep() is set on valuep, but nothing should care @@ -253,7 +253,7 @@ public: } } void newOutValue(AstNode* nodep, const AstNode* valuep) { - if (const AstConst* constp = VN_CAST(valuep, Const)) { + if (const AstConst* const constp = VN_CAST(valuep, Const)) { newOutConst(nodep)->num().opAssign(constp->num()); } else if (fetchOutValueNull(nodep) != valuep) { // const_cast, as clonep() is set on valuep, but nothing should care @@ -263,14 +263,14 @@ public: private: AstNode* newTrackedClone(AstNode* nodep) { - AstNode* newp = nodep->cloneTree(false); + AstNode* const newp = nodep->cloneTree(false); m_reclaimValuesp.push_back(newp); return newp; } AstConst* newConst(AstNode* nodep) { // Set a constant value for this node if (!VN_IS(nodep->user3p(), Const)) { - AstConst* constp = allocConst(nodep); + AstConst* const constp = allocConst(nodep); setValue(nodep, constp); return constp; } else { @@ -280,7 +280,7 @@ private: AstConst* newOutConst(AstNode* nodep) { // Set a var-output constant value for this node if (!VN_IS(nodep->user2p(), Const)) { - AstConst* constp = allocConst(nodep); + AstConst* const constp = allocConst(nodep); setOutValue(nodep, constp); return constp; } else { @@ -298,31 +298,31 @@ private: return VN_CAST(fetchOutValueNull(nodep), Const); } AstNode* fetchValue(AstNode* nodep) { - AstNode* valuep = fetchValueNull(nodep); + AstNode* const valuep = fetchValueNull(nodep); UASSERT_OBJ(valuep, nodep, "No value found for node."); // UINFO(9, " fetch val " << *valuep << " on " << nodep << endl); return valuep; } AstConst* fetchConst(AstNode* nodep) { - AstConst* constp = fetchConstNull(nodep); + AstConst* const constp = fetchConstNull(nodep); UASSERT_OBJ(constp, nodep, "No value found for node."); // UINFO(9, " fetch num " << *constp << " on " << nodep << endl); return constp; } AstConst* fetchOutConst(AstNode* nodep) { - AstConst* constp = fetchOutConstNull(nodep); + AstConst* const constp = fetchOutConstNull(nodep); UASSERT_OBJ(constp, nodep, "No value found for node."); return constp; } public: V3Number* fetchNumberNull(AstNode* nodep) { - AstConst* constp = fetchConstNull(nodep); + AstConst* const constp = fetchConstNull(nodep); if (constp) return &constp->num(); return nullptr; } V3Number* fetchOutNumberNull(AstNode* nodep) { - AstConst* constp = fetchOutConstNull(nodep); + AstConst* const constp = fetchOutConstNull(nodep); if (constp) return &constp->num(); return nullptr; } @@ -405,7 +405,7 @@ private: if (!optimizable()) return; // Accelerate UASSERT_OBJ(nodep->varp(), nodep, "Unlinked"); iterateChildren(nodep->varp()); - AstNode* vscp = varOrScope(nodep); + AstNode* const vscp = varOrScope(nodep); // We can't have non-delayed assignments with same value on LHS and RHS // as we don't figure out variable ordering. @@ -438,7 +438,8 @@ private: } vscp->user1(vscp->user1() | VU_RV); const bool isConst = nodep->varp()->isParam() && nodep->varp()->valuep(); - AstNode* valuep = isConst ? fetchValueNull(nodep->varp()->valuep()) : nullptr; + AstNode* const valuep + = isConst ? fetchValueNull(nodep->varp()->valuep()) : nullptr; if (isConst && valuep) { // Propagate PARAM constants for constant function analysis if (!m_checkOnly && optimizable()) newValue(vscp, valuep); @@ -526,7 +527,7 @@ private: checkNodeInfo(nodep); UASSERT_OBJ(nodep->itemp(), nodep, "Not linked"); if (!m_checkOnly && optimizable()) { - AstNode* valuep = nodep->itemp()->valuep(); + AstNode* const valuep = nodep->itemp()->valuep(); if (valuep) { iterateAndNextNull(valuep); if (optimizable()) newValue(nodep, fetchValue(valuep)); @@ -619,7 +620,8 @@ private: iterate(nodep->lhsp()); if (optimizable()) { if (fetchConst(nodep->lhsp())->num().isEqZero()) { - AstConst cnst(nodep->fileline(), AstConst::WidthedValue(), 1, 1); // a one + const AstConst cnst(nodep->fileline(), AstConst::WidthedValue(), 1, + 1); // a one newValue(nodep, &cnst); // a one } else { iterate(nodep->rhsp()); @@ -656,29 +658,30 @@ private: // To do better, we need the concept of lvalues, or similar, to know where/how to insert checkNodeInfo(selp); iterateAndNextNull(selp->bitp()); // Bit index - AstVarRef* varrefp = VN_CAST(selp->fromp(), VarRef); + AstVarRef* const varrefp = VN_CAST(selp->fromp(), VarRef); if (!varrefp) { clearOptimizable(nodep, "Array select LHS isn't simple variable"); return; } - AstUnpackArrayDType* arrayp = VN_AS(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType); + AstUnpackArrayDType* const arrayp + = VN_AS(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType); UASSERT_OBJ(arrayp, nodep, "Array select of non-array dtype"); - AstBasicDType* basicp = VN_CAST(arrayp->subDTypep()->skipRefp(), BasicDType); + AstBasicDType* const basicp = VN_CAST(arrayp->subDTypep()->skipRefp(), BasicDType); if (!basicp) { clearOptimizable(nodep, "Array of non-basic dtype (e.g. array-of-array)"); return; } if (!m_checkOnly && optimizable()) { - AstNode* vscp = varOrScope(varrefp); + AstNode* const vscp = varOrScope(varrefp); AstInitArray* initp = nullptr; - if (AstInitArray* vscpnump = VN_CAST(fetchOutValueNull(vscp), InitArray)) { + if (AstInitArray* const vscpnump = VN_CAST(fetchOutValueNull(vscp), InitArray)) { initp = vscpnump; - } else if (AstInitArray* vscpnump = VN_CAST(fetchValueNull(vscp), InitArray)) { + } else if (AstInitArray* const vscpnump = VN_CAST(fetchValueNull(vscp), InitArray)) { initp = vscpnump; } else { // Assignment to unassigned variable, all bits are X // TODO generic initialization which builds X/arrays by recursion - AstConst* outconstp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), - basicp->widthMin(), 0); + AstConst* const outconstp = new AstConst( + nodep->fileline(), AstConst::WidthedValue(), basicp->widthMin(), 0); if (basicp->isZeroInit()) { outconstp->num().setAllBits0(); } else { @@ -688,8 +691,8 @@ private: initp = new AstInitArray(nodep->fileline(), arrayp, outconstp); m_reclaimValuesp.push_back(initp); } - uint32_t index = fetchConst(selp->bitp())->toUInt(); - AstNode* valuep = newTrackedClone(fetchValue(nodep->rhsp())); + const uint32_t index = fetchConst(selp->bitp())->toUInt(); + AstNode* const valuep = newTrackedClone(fetchValue(nodep->rhsp())); UINFO(9, " set val[" << index << "] = " << valuep << endl); // Values are in the "real" tree under the InitArray so can eventually extract it, // Not in the usual setValue (pointed to by user2/3p) @@ -706,11 +709,11 @@ private: if (!m_checkOnly && optimizable()) { UASSERT_OBJ(varrefp, nodep, "Indicated optimizable, but no variable found on RHS of select"); - AstNode* vscp = varOrScope(varrefp); + AstNode* const vscp = varOrScope(varrefp); AstConst* outconstp = nullptr; - if (AstConst* vscpnump = fetchOutConstNull(vscp)) { + if (AstConst* const vscpnump = fetchOutConstNull(vscp)) { outconstp = vscpnump; - } else if (AstConst* vscpnump = fetchConstNull(vscp)) { + } else if (AstConst* const vscpnump = fetchConstNull(vscp)) { outconstp = vscpnump; } else { // Assignment to unassigned variable, all bits are X or 0 outconstp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), @@ -731,11 +734,11 @@ private: // lsb to be eventually set on lsbRef checkNodeInfo(selp); iterateAndNextNull(selp->lsbp()); // Bit index - if (AstVarRef* varrefp = VN_CAST(selp->fromp(), VarRef)) { + if (AstVarRef* const varrefp = VN_CAST(selp->fromp(), VarRef)) { outVarrefpRef = varrefp; lsbRef = fetchConst(selp->lsbp())->num(); return; // And presumably still optimizable() - } else if (AstSel* subselp = VN_CAST(selp->lhsp(), Sel)) { + } else if (AstSel* const subselp = VN_CAST(selp->lhsp(), Sel)) { V3Number sublsb(nodep); handleAssignSelRecurse(nodep, subselp, outVarrefpRef, sublsb /*ref*/, depth + 1); if (optimizable()) { @@ -759,13 +762,13 @@ private: m_anyAssignComb = true; } - if (AstSel* selp = VN_CAST(nodep->lhsp(), Sel)) { + if (AstSel* const selp = VN_CAST(nodep->lhsp(), Sel)) { if (!m_params) { clearOptimizable(nodep, "LHS has select"); return; } handleAssignSel(nodep, selp); - } else if (AstArraySel* selp = VN_CAST(nodep->lhsp(), ArraySel)) { + } else if (AstArraySel* const selp = VN_CAST(nodep->lhsp(), ArraySel)) { if (!m_params) { clearOptimizable(nodep, "LHS has select"); return; @@ -778,7 +781,7 @@ private: } else if (optimizable()) { iterateAndNextNull(nodep->rhsp()); if (optimizable()) { - AstNode* vscp = varOrScope(VN_CAST(nodep->lhsp(), VarRef)); + AstNode* const vscp = varOrScope(VN_CAST(nodep->lhsp(), VarRef)); assignOutValue(nodep, vscp, fetchValue(nodep->rhsp())); } } @@ -787,10 +790,10 @@ private: virtual void visit(AstArraySel* nodep) override { checkNodeInfo(nodep); iterateChildren(nodep); - if (AstInitArray* initp = VN_CAST(fetchValueNull(nodep->fromp()), InitArray)) { - AstConst* indexp = fetchConst(nodep->bitp()); - uint32_t offset = indexp->num().toUInt(); - AstNode* itemp = initp->getIndexDefaultedValuep(offset); + if (AstInitArray* const initp = VN_CAST(fetchValueNull(nodep->fromp()), InitArray)) { + AstConst* const indexp = fetchConst(nodep->bitp()); + const uint32_t offset = indexp->num().toUInt(); + AstNode* const itemp = initp->getIndexDefaultedValuep(offset); if (!itemp) { clearOptimizable(nodep, "Array initialization has too few elements, need element " + cvtToStr(offset)); @@ -977,8 +980,8 @@ private: // Must do this in two steps, eval all params, then apply them // Otherwise chained functions may have the wrong results for (V3TaskConnects::iterator it = tconnects.begin(); it != tconnects.end(); ++it) { - AstVar* portp = it->first; - AstNode* pinp = it->second->exprp(); + AstVar* const portp = it->first; + AstNode* const pinp = it->second->exprp(); if (pinp) { // Else too few arguments in function call - ignore it if (portp->isWritable()) { clearOptimizable( @@ -991,8 +994,8 @@ private: } } for (V3TaskConnects::iterator it = tconnects.begin(); it != tconnects.end(); ++it) { - AstVar* portp = it->first; - AstNode* pinp = it->second->exprp(); + AstVar* const portp = it->first; + AstNode* const pinp = it->second->exprp(); if (pinp) { // Else too few arguments in function call - ignore it // Apply value to the function if (!m_checkOnly && optimizable()) newValue(portp, fetchValue(pinp)); @@ -1002,7 +1005,7 @@ private: // cppcheck-suppress danglingLifetime m_callStack.push_back(&stackNode); // Clear output variable - if (auto* const basicp = VN_CAST(funcp->fvarp(), Var)->basicp()) { + if (const auto* const basicp = VN_CAST(funcp->fvarp(), Var)->basicp()) { AstConst cnst(funcp->fvarp()->fileline(), AstConst::WidthedValue(), basicp->widthMin(), 0); if (basicp->isZeroInit()) { @@ -1055,9 +1058,9 @@ private: inPct = false; if (V3Number::displayedFmtLegal(tolower(pos[0]), false)) { - AstNode* argp = nextArgp; + AstNode* const argp = nextArgp; nextArgp = nextArgp->nextp(); - AstConst* constp = fetchConstNull(argp); + AstConst* const constp = fetchConstNull(argp); if (!constp) { clearOptimizable( nodep, "Argument for $display like statement is not constant"); @@ -1081,7 +1084,8 @@ private: } } - AstConst* resultConstp = new AstConst(nodep->fileline(), AstConst::String(), result); + AstConst* const resultConstp + = new AstConst(nodep->fileline(), AstConst::String(), result); setValue(nodep, resultConstp); m_reclaimValuesp.push_back(resultConstp); } @@ -1092,7 +1096,7 @@ private: if (!optimizable()) return; // Accelerate iterateChildren(nodep); if (m_params) { - AstConst* textp = fetchConst(nodep->fmtp()); + AstConst* const textp = fetchConst(nodep->fmtp()); switch (nodep->displayType()) { case AstDisplayType::DT_DISPLAY: // FALLTHRU case AstDisplayType::DT_INFO: v3warn(USERINFO, textp->name()); break; diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index 1c220d4fa..bd2c9c2a9 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -97,12 +97,12 @@ class SliceVisitor final : public AstNVisitor { itemp = initp->initsp(); } newp = itemp->cloneTree(false); - } else if (AstNodeCond* snodep = VN_CAST(nodep, NodeCond)) { + } else if (AstNodeCond* const snodep = VN_CAST(nodep, NodeCond)) { UINFO(9, " cloneCond(" << elements << "," << offset << ") " << nodep << endl); return snodep->cloneType(snodep->condp()->cloneTree(false), cloneAndSel(snodep->expr1p(), elements, offset), cloneAndSel(snodep->expr2p(), elements, offset)); - } else if (AstSliceSel* snodep = VN_CAST(nodep, SliceSel)) { + } else if (const AstSliceSel* const snodep = VN_CAST(nodep, SliceSel)) { UINFO(9, " cloneSliceSel(" << elements << "," << offset << ") " << nodep << endl); const int leOffset = (snodep->declRange().lo() + (!snodep->declRange().littleEndian() diff --git a/src/V3Split.cpp b/src/V3Split.cpp index b4e59315b..e8140ebf9 100644 --- a/src/V3Split.cpp +++ b/src/V3Split.cpp @@ -322,7 +322,7 @@ protected: vertexp = vertexp->verticesNextp()) { if (!vertexp->outBeginp() && dynamic_cast(vertexp)) { if (debug() >= 9) { - SplitVarStdVertex* const stdp = static_cast(vertexp); + const SplitVarStdVertex* const stdp = static_cast(vertexp); UINFO(0, "Will prune deps on var " << stdp->nodep() << endl); stdp->nodep()->dumpTree(cout, "- "); } @@ -477,7 +477,8 @@ protected: // vertexes not involved with this step as unimportant for (V3GraphVertex* vertexp = m_graph.verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - if (SplitLogicVertex* const vvertexp = dynamic_cast(vertexp)) { + if (const SplitLogicVertex* const vvertexp + = dynamic_cast(vertexp)) { if (!vvertexp->user()) { for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep = edgep->inNextp()) { @@ -502,7 +503,7 @@ protected: for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) { SplitLogicVertex* const vvertexp = reinterpret_cast(nextp->user3p()); - uint32_t color = vvertexp->color(); + const uint32_t color = vvertexp->color(); UASSERT_OBJ(color, nextp, "No node color assigned"); if (lastOfColor[color]) { new SplitStrictEdge(&m_graph, lastOfColor[color], vvertexp); @@ -526,7 +527,7 @@ protected: std::multimap rankMap; int currOrder = 0; // Existing sequence number of assignment for (AstNode* nextp = nodep; nextp; nextp = nextp->nextp()) { - SplitLogicVertex* const vvertexp + const SplitLogicVertex* const vvertexp = reinterpret_cast(nextp->user3p()); rankMap.emplace(vvertexp->rank(), nextp); nextp->user4(++currOrder); // Record current ordering @@ -536,7 +537,7 @@ protected: bool leaveAlone = true; int newOrder = 0; // New sequence number of assignment for (auto it = rankMap.cbegin(); it != rankMap.cend(); ++it) { - AstNode* const nextp = it->second; + const AstNode* const nextp = it->second; if (++newOrder != nextp->user4()) leaveAlone = false; } if (leaveAlone) { @@ -650,8 +651,9 @@ public: private: void trackNode(AstNode* nodep) { if (nodep->user3p()) { - SplitLogicVertex* const vertexp = reinterpret_cast(nodep->user3p()); - uint32_t color = vertexp->color(); + const SplitLogicVertex* const vertexp + = reinterpret_cast(nodep->user3p()); + const uint32_t color = vertexp->color(); m_colors.insert(color); UINFO(8, " SVL " << vertexp << " has color " << color << "\n"); @@ -681,7 +683,7 @@ private: class EmitSplitVisitor final : public AstNVisitor { // MEMBERS - AstAlways* const m_origAlwaysp; // Block that *this will split + const AstAlways* const m_origAlwaysp; // Block that *this will split const IfColorVisitor* const m_ifColorp; // Digest of results of prior coloring // Map each color to our current place within the color's new always @@ -747,8 +749,8 @@ protected: UASSERT_OBJ(nodep->user3p(), nodep, "null user3p in V3Split leaf"); // Clone the leaf into its new always block - SplitLogicVertex* const vxp = reinterpret_cast(nodep->user3p()); - uint32_t color = vxp->color(); + const SplitLogicVertex* const vxp = reinterpret_cast(nodep->user3p()); + const uint32_t color = vxp->color(); AstNode* const clonedp = nodep->cloneTree(false); m_addAfter[color]->addNextHere(clonedp); m_addAfter[color] = clonedp; @@ -765,7 +767,7 @@ protected: AstSplitPlaceholder* const else_placeholderp = makePlaceholderp(); AstIf* const clonep = new AstIf(nodep->fileline(), nodep->condp()->cloneTree(true), if_placeholderp, else_placeholderp); - AstIf* const origp = VN_CAST(nodep, If); + const AstIf* const origp = VN_CAST(nodep, If); if (origp) { // Preserve pragmas from unique if's // so assertions work properly @@ -817,7 +819,7 @@ private: std::unordered_map m_replaceBlocks; // AstNodeIf* whose condition we're currently visiting - AstNode* m_curIfConditional = nullptr; + const AstNode* m_curIfConditional = nullptr; // CONSTRUCTORS public: @@ -832,7 +834,7 @@ public: for (AlwaysVec::iterator addme = it->second.begin(); addme != it->second.end(); ++addme) { origp->addNextHere(*addme); - RemovePlaceholdersVisitor removePlaceholders(*addme); + RemovePlaceholdersVisitor{*addme}; } origp->unlinkFrBack(); // Without next VL_DO_DANGLING(origp->deleteTree(), origp); @@ -847,7 +849,7 @@ protected: // Each 'if' depends on rvalues in its own conditional ONLY, // not rvalues in the if/else bodies. for (auto it = m_stmtStackps.cbegin(); it != m_stmtStackps.cend(); ++it) { - AstNodeIf* const ifNodep = VN_CAST((*it)->nodep(), NodeIf); + const AstNodeIf* const ifNodep = VN_CAST((*it)->nodep(), NodeIf); if (ifNodep && (m_curIfConditional != ifNodep)) continue; new SplitRVEdge(&m_graph, *it, vstdp); } @@ -871,15 +873,15 @@ protected: // inputs) prune all edges that depend on the 'if'. for (V3GraphVertex* vertexp = m_graph.verticesBeginp(); vertexp; vertexp = vertexp->verticesNextp()) { - SplitLogicVertex* const logicp = dynamic_cast(vertexp); + const SplitLogicVertex* const logicp = dynamic_cast(vertexp); if (!logicp) continue; - AstNodeIf* const ifNodep = VN_CAST(logicp->nodep(), NodeIf); + const AstNodeIf* const ifNodep = VN_CAST(logicp->nodep(), NodeIf); if (!ifNodep) continue; bool pruneMe = true; for (V3GraphEdge* edgep = logicp->outBeginp(); edgep; edgep = edgep->outNextp()) { - SplitEdge* const oedgep = dynamic_cast(edgep); + const SplitEdge* const oedgep = dynamic_cast(edgep); if (!oedgep->ignoreThisStep()) { // This if conditional depends on something we can't // prune -- a variable generated in the current block. @@ -889,7 +891,7 @@ protected: // give a hint about why... if (debug() >= 9) { V3GraphVertex* vxp = oedgep->top(); - SplitNodeVertex* const nvxp = dynamic_cast(vxp); + const SplitNodeVertex* const nvxp = dynamic_cast(vxp); UINFO(0, "Cannot prune if-node due to edge " << oedgep << " pointing to node " << nvxp->nodep() << endl); nvxp->nodep()->dumpTree(cout, "- "); @@ -936,7 +938,7 @@ protected: // Map each AstNodeIf to the set of colors (split always blocks) // it must participate in. Also find the whole set of colors. - IfColorVisitor ifColor{nodep}; + const IfColorVisitor ifColor{nodep}; if (ifColor.colors().size() > 1) { // Counting original always blocks rather than newly-split diff --git a/src/V3SplitAs.cpp b/src/V3SplitAs.cpp index b87e3bcb1..1ff583f70 100644 --- a/src/V3SplitAs.cpp +++ b/src/V3SplitAs.cpp @@ -70,7 +70,7 @@ class SplitAsCleanVisitor final : public SplitAsBaseVisitor { private: // STATE AstVarScope* const m_splitVscp; // Variable we want to split - bool m_modeMatch; // Remove matching Vscp, else non-matching + const bool m_modeMatch; // Remove matching Vscp, else non-matching bool m_keepStmt = false; // Current Statement must be preserved bool m_matches = false; // Statement below has matching lvalue reference @@ -144,11 +144,11 @@ private: newp->user1(true); // So we don't clone it again nodep->addNextHere(newp); { // Delete stuff we don't want in old - SplitAsCleanVisitor visitor{nodep, m_splitVscp, false}; + const SplitAsCleanVisitor visitor{nodep, m_splitVscp, false}; if (debug() >= 9) nodep->dumpTree(cout, "-out0: "); } { // Delete stuff we don't want in new - SplitAsCleanVisitor visitor{newp, m_splitVscp, true}; + const SplitAsCleanVisitor visitor{newp, m_splitVscp, true}; if (debug() >= 9) newp->dumpTree(cout, "-out1: "); } } @@ -159,7 +159,7 @@ private: const AstVarScope* lastSplitVscp = nullptr; while (!nodep->user1()) { // Find any splittable variables - SplitAsFindVisitor visitor{nodep}; + const SplitAsFindVisitor visitor{nodep}; m_splitVscp = visitor.splitVscp(); if (m_splitVscp && m_splitVscp == lastSplitVscp) { // We did this last time! Something's stuck! diff --git a/src/V3SplitVar.cpp b/src/V3SplitVar.cpp index 38c32fc4f..4697a6dda 100644 --- a/src/V3SplitVar.cpp +++ b/src/V3SplitVar.cpp @@ -249,13 +249,13 @@ struct AstNodeComparator { class UnpackRef final { // m_nodep is called in this context (AstNodeStmt, AstCell, AstNodeFTask, or AstAlways) - AstNode* m_contextp; - AstNode* m_nodep; // ArraySel, SliceSel, ArrayVarRef (entire value) - int m_index; // for ArraySel - int m_msb; // for SliceSel - int m_lsb; // for SliceSel - VAccess m_access; - bool m_ftask; // true if the reference is in function/task. false if in module. + AstNode* const m_contextp; + AstNode* const m_nodep; // ArraySel, SliceSel, ArrayVarRef (entire value) + const int m_index; // for ArraySel + const int m_msb; // for SliceSel + const int m_lsb; // for SliceSel + const VAccess m_access; + const bool m_ftask; // true if the reference is in function/task. false if in module. public: UnpackRef(AstNode* stmtp, AstVarRef* nodep, bool ftask) : m_contextp{stmtp} @@ -402,7 +402,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { AstNodeModule* m_modp = nullptr; // AstNodeStmt, AstCell, AstNodeFTaskRef, or AstAlways(Public) for sensitivity AstNode* m_contextp = nullptr; - AstNodeFTask* m_inFTask = nullptr; + const AstNodeFTask* m_inFTask = nullptr; size_t m_numSplit = 0; // List for SplitPackedVarVisitor SplitVarRefsMap m_refsForPackedSplit; @@ -490,13 +490,13 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { VL_RESTORER(m_contextp); { m_contextp = nodep; - AstNodeFTask* const ftaskp = nodep->taskp(); + const AstNodeFTask* const ftaskp = nodep->taskp(); UASSERT_OBJ(ftaskp, nodep, "Unlinked"); // Iterate arguments of a function/task. for (AstNode *argp = nodep->pinsp(), *paramp = ftaskp->stmtsp(); argp; argp = argp->nextp(), paramp = paramp ? paramp->nextp() : nullptr) { const char* reason = nullptr; - AstVar* vparamp = nullptr; + const AstVar* vparamp = nullptr; while (paramp) { vparamp = VN_CAST(paramp, Var); if (vparamp && vparamp->isIO()) { @@ -527,7 +527,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { if (!exprp) return; // Not connected pin m_foundTargetVar.clear(); iterate(exprp); - if (const char* reason = cannotSplitConnectedPortReason(nodep)) { + if (const char* const reason = cannotSplitConnectedPortReason(nodep)) { for (AstVar* const varp : m_foundTargetVar) { warnNoSplit(varp, nodep, reason); m_refs.remove(varp); @@ -564,7 +564,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { } virtual void visit(AstArraySel* nodep) override { if (AstVarRef* const refp = isTargetVref(nodep->fromp())) { - AstConst* const indexp = VN_CAST(nodep->bitp(), Const); + const AstConst* const indexp = VN_CAST(nodep->bitp(), Const); if (indexp) { // OK UINFO(4, "add " << nodep << " for " << refp->varp()->prettyName() << "\n"); if (indexp->toSInt() < outerMostSizeOfUnpackedArray(refp->varp())) { @@ -601,7 +601,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { } } AstNode* toInsertPoint(AstNode* insertp) { - if (AstNodeStmt* const stmtp = VN_CAST(insertp, NodeStmt)) { + if (const AstNodeStmt* const stmtp = VN_CAST(insertp, NodeStmt)) { if (!stmtp->isStatement()) insertp = stmtp->backp(); } return insertp; @@ -630,7 +630,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { = newVarRef(fl, vars.at(start_idx + i), lvalue ? VAccess::WRITE : VAccess::READ); AstNode* rhsp = new AstArraySel{ fl, newVarRef(fl, varp, !lvalue ? VAccess::WRITE : VAccess::READ), i}; - AstNode* refp = lhsp; + AstNode* const refp = lhsp; UINFO(9, "Creating assign idx:" << i << " + " << start_idx << "\n"); if (!lvalue) std::swap(lhsp, rhsp); AstNode* newassignp; @@ -699,7 +699,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { // Unpacked array is traced as var(idx), not var[idx]. const std::string name = varp->name() + AstNode::encodeName('(' + cvtToStr(i + dtypep->lo()) + ')'); - AstVar* newp = newVar(varp->fileline(), AstVarType::VAR, name, subTypep); + AstVar* const newp = newVar(varp->fileline(), AstVarType::VAR, name, subTypep); newp->propagateAttrFrom(varp); // If varp is an IO, varp will remain and will be traced. newp->trace(!varp->isIO() && varp->isTrace()); @@ -721,7 +721,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl { if (refp) { adtypep = VN_AS(refp->dtypep()->skipRefp(), UnpackArrayDType); } else { - AstSliceSel* selp = VN_AS(ref.nodep(), SliceSel); + AstSliceSel* const selp = VN_AS(ref.nodep(), SliceSel); UASSERT_OBJ(selp, ref.nodep(), "Unexpected op is registered"); refp = VN_AS(selp->fromp(), VarRef); UASSERT_OBJ(refp, selp, "Unexpected op is registered"); @@ -809,8 +809,8 @@ public: // Split variable class SplitNewVar final { - int m_lsb; // LSB in the original bitvector - int m_bitwidth; + const int m_lsb; // LSB in the original bitvector + const int m_bitwidth; AstVar* m_varp; // The LSB of this variable is always 0, not m_lsb public: SplitNewVar(int lsb, int bitwidth, AstVar* varp = nullptr) @@ -835,9 +835,9 @@ public: // One Entry instance for an AstVarRef instance class PackedVarRefEntry final { - AstNode* m_nodep; // Either AstSel or AstVarRef is expected. - int m_lsb; - int m_bitwidth; + AstNode* const m_nodep; // Either AstSel or AstVarRef is expected. + const int m_lsb; + const int m_bitwidth; public: PackedVarRefEntry(AstSel* selp, int lsb, int bitwidth) @@ -859,7 +859,7 @@ public: // If this is AstVarRef and referred in the sensitivity list of always@, // return the sensitivity item AstSenItem* backSenItemp() const { - if (AstVarRef* const refp = VN_CAST(m_nodep, VarRef)) { + if (const AstVarRef* const refp = VN_CAST(m_nodep, VarRef)) { return VN_CAST(refp->backp(), SenItem); } return nullptr; @@ -875,7 +875,7 @@ class PackedVarRef final { } }; std::vector m_lhs, m_rhs; - AstBasicDType* m_basicp; // Cache the ptr since varp->dtypep()->basicp() is expensive + AstBasicDType* const m_basicp; // Cache the ptr since varp->dtypep()->basicp() is expensive bool m_dedupDone = false; static void dedupRefs(std::vector& refs) { // Use raw pointer to dedup @@ -959,8 +959,8 @@ public: }; class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl { - AstNetlist* m_netp; - AstNodeModule* m_modp = nullptr; // Current module (just for log) + AstNetlist* const m_netp; + const AstNodeModule* m_modp = nullptr; // Current module (just for log) int m_numSplit = 0; // Total number of split variables // key:variable to be split. value:location where the variable is referenced. std::map m_refs; @@ -985,14 +985,14 @@ class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl { UASSERT_OBJ(varp->attrSplitVar(), varp, "split_var attribute must be attached"); UASSERT_OBJ(!nodep->classOrPackagep(), nodep, "variable in package must have been dropped beforehand."); - const AstBasicDType* basicp = refit->second.basicp(); + const AstBasicDType* const basicp = refit->second.basicp(); refit->second.append(PackedVarRefEntry(nodep, basicp->lo(), varp->width()), nodep->access()); UINFO(5, varp->prettyName() << " Entire bit of [" << basicp->lo() << "+:" << varp->width() << "] \n"); } virtual void visit(AstSel* nodep) override { - AstVarRef* const vrefp = VN_CAST(nodep->fromp(), VarRef); + const AstVarRef* const vrefp = VN_CAST(nodep->fromp(), VarRef); if (!vrefp) { iterateChildren(nodep); return; @@ -1006,7 +1006,7 @@ class SplitPackedVarVisitor final : public AstNVisitor, public SplitVarImpl { } UASSERT_OBJ(varp->attrSplitVar(), varp, "split_var attribute must be attached"); - std::array consts + const std::array consts = {{VN_CAST(nodep->lsbp(), Const), VN_CAST(nodep->widthp(), Const)}}; // GCC 3.8.0 wants {{}} if (consts[0] && consts[1]) { // OK @@ -1224,7 +1224,7 @@ public: // when the access to the variable cannot be determined statically. static const char* cannotSplitReason(const AstVar* nodep, bool checkUnpacked) { const char* reason = nullptr; - if (AstBasicDType* const basicp = nodep->dtypep()->basicp()) { + if (const AstBasicDType* const basicp = nodep->dtypep()->basicp()) { const std::pair dim = nodep->dtypep()->dimensions(false); // Unpacked array will be split in SplitUnpackedVarVisitor() beforehand if (!((!checkUnpacked || dim.second == 0) && nodep->dtypep()->widthMin() > 1)) @@ -1255,7 +1255,7 @@ void V3SplitVar::splitVariable(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); SplitVarRefsMap refs; { - SplitUnpackedVarVisitor visitor{nodep}; + const SplitUnpackedVarVisitor visitor{nodep}; refs = visitor.getPackedVarRefs(); } V3Global::dumpCheckGlobalTree("split_var", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 9); diff --git a/src/V3Stats.cpp b/src/V3Stats.cpp index 7bfada996..172c1b642 100644 --- a/src/V3Stats.cpp +++ b/src/V3Stats.cpp @@ -37,12 +37,12 @@ private: using NameMap = std::map; // Number of times a name appears // STATE - string m_stage; // Name of the stage we are scanning + const string m_stage; // Name of the stage we are scanning /// m_fast = true: Counting only critical branch of fastpath /// m_fast = false: Counting every node, ignoring structure of program - bool m_fast; + const bool m_fast; - AstCFunc* m_cfuncp; // Current CFUNC + const AstCFunc* m_cfuncp; // Current CFUNC bool m_counting; // Currently counting double m_instrs; // Current instr count (for determining branch direction) bool m_tracingCall; // Iterating into a CCall to a CFunc @@ -233,7 +233,7 @@ public: const double count = double(m_statVarWidths.at(i)); if (count != 0.0) { if (v3Global.opt.statsVars()) { - NameMap& nameMapr = m_statVarWidthNames.at(i); + const NameMap& nameMapr = m_statVarWidthNames.at(i); for (const auto& itr : nameMapr) { std::ostringstream os; os << "Vars, width " << std::setw(5) << std::dec << i << " " << itr.first; diff --git a/src/V3Stats.h b/src/V3Stats.h index b340cf0a9..77831e151 100644 --- a/src/V3Stats.h +++ b/src/V3Stats.h @@ -67,11 +67,11 @@ public: class V3Statistic final { // A statistical entry we want published into the database - string m_name; ///< Nameiption of this statistic + const string m_name; ///< Name of this statistic double m_count; ///< Count of occurrences/ value - string m_stage; ///< Runtime stage - bool m_sumit; ///< Do summation of similar stats - bool m_perf; ///< Performance section + const string m_stage; ///< Runtime stage + const bool m_sumit; ///< Do summation of similar stats + const bool m_perf; ///< Performance section bool m_printit = true; ///< Print the results public: // METHODS diff --git a/src/V3StatsReport.cpp b/src/V3StatsReport.cpp index 5833f8db6..2a7a66987 100644 --- a/src/V3StatsReport.cpp +++ b/src/V3StatsReport.cpp @@ -225,7 +225,7 @@ void V3Stats::statsReport() { std::ofstream* ofp{V3File::new_ofstream(filename)}; if (ofp->fail()) v3fatal("Can't write " << filename); - StatsReport reporter(ofp); + const StatsReport reporter(ofp); // Cleanup ofp->close(); diff --git a/src/V3String.cpp b/src/V3String.cpp index 76798e8d5..b76043fd4 100644 --- a/src/V3String.cpp +++ b/src/V3String.cpp @@ -148,7 +148,7 @@ double VString::parseDouble(const string& str, bool* successp) { } *dp++ = '\0'; char* endp = strgp; - double d = strtod(strgp, &endp); + const double d = strtod(strgp, &endp); const size_t parsed_len = endp - strgp; if (parsed_len != strlen(strgp)) { if (successp) *successp = false; @@ -321,7 +321,7 @@ uint64_t VHashSha256::digestUInt64() { const string& binhash = digestBinary(); uint64_t out = 0; for (size_t byte = 0; byte < sizeof(uint64_t); ++byte) { - unsigned char c = binhash[byte]; + const unsigned char c = binhash[byte]; out = (out << 8) | c; } return out; @@ -411,14 +411,14 @@ string VName::dehash(const string& in) { const string::size_type next_dot_pos = in.find("__DOT__", last_dot_pos); // Two iterators defining the range between the last and next dots. const auto search_begin = std::begin(in) + last_dot_pos; - auto search_end + const auto search_end = next_dot_pos == string::npos ? std::end(in) : std::begin(in) + next_dot_pos; // Search for __Vhsh between the two dots. - auto begin_vhsh + const auto begin_vhsh = std::search(search_begin, search_end, std::begin(VHSH), std::end(VHSH) - 1); if (begin_vhsh != search_end) { - std::string vhsh(begin_vhsh, search_end); + const std::string vhsh(begin_vhsh, search_end); const auto& it = s_dehashMap.find(vhsh); UASSERT(it != s_dehashMap.end(), "String not in reverse hash map '" << vhsh << "'"); // Is this not the first component, but the first to require dehashing? @@ -582,7 +582,7 @@ void VSpellCheck::selfTest() { selfTestSuggestOne(false, "sqrt", "assert", 3); } { - VSpellCheck speller; + const VSpellCheck speller; UASSERT_SELFTEST(string, "", speller.bestCandidate("")); } { diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 19e44e3c7..0c8c426a9 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -180,7 +180,7 @@ private: // See SubstVisitor // // STATE - int m_origStep; // Step number where subst was recorded + const int m_origStep; // Step number where subst was recorded bool m_ok = true; // No misassignments found // METHODS @@ -274,7 +274,7 @@ private: entryp->assignWhole(m_assignStep, nodep); } } - } else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) { + } else if (const AstWordSel* const wordp = VN_CAST(nodep->lhsp(), WordSel)) { if (AstVarRef* const varrefp = VN_CAST(wordp->lhsp(), VarRef)) { if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) { const int word = VN_AS(wordp->rhsp(), Const)->toUInt(); @@ -315,7 +315,7 @@ private: SubstVarEntry* const entryp = getEntryp(varrefp); if (AstNode* const substp = entryp->substWord(nodep, word)) { // Check that the RHS hasn't changed value since we recorded it. - SubstUseVisitor visitor{substp, entryp->getWordStep(word)}; + const SubstUseVisitor visitor{substp, entryp->getWordStep(word)}; if (visitor.ok()) { VL_DO_DANGLING(replaceSubstEtc(nodep, substp), nodep); } else { @@ -340,9 +340,9 @@ private: if (nodep->access().isWriteOrRW()) { UINFO(8, " ASSIGNcpx " << nodep << endl); entryp->assignComplex(); - } else if (AstNode* substp = entryp->substWhole(nodep)) { + } else if (AstNode* const substp = entryp->substWhole(nodep)) { // Check that the RHS hasn't changed value since we recorded it. - SubstUseVisitor visitor{substp, entryp->getWholeStep()}; + const SubstUseVisitor visitor{substp, entryp->getWholeStep()}; if (visitor.ok()) { UINFO(8, " USEwhole " << nodep << endl); VL_DO_DANGLING(replaceSubstEtc(nodep, substp), nodep); diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 653db2332..160e9cc57 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -158,7 +158,7 @@ public: VSymEnt* findIdFallback(const string& name) const { // Find identifier looking upward through symbol hierarchy // First, scan this begin/end block or module for the name - if (VSymEnt* entp = findIdFlat(name)) return entp; + if (VSymEnt* const entp = findIdFlat(name)) return entp; // Then scan the upper begin/end block or module for the name if (m_fallbackp) return m_fallbackp->findIdFallback(name); return nullptr; @@ -166,7 +166,7 @@ public: void candidateIdFlat(VSpellCheck* spellerp, const VNodeMatcher* matcherp) const { // Suggest alternative symbol candidates without looking upward through symbol hierarchy for (IdNameMap::const_iterator it = m_idNameMap.begin(); it != m_idNameMap.end(); ++it) { - const AstNode* itemp = it->second->nodep(); + const AstNode* const itemp = it->second->nodep(); if (itemp && (!matcherp || matcherp->nodeMatch(itemp))) { spellerp->pushCandidate(itemp->prettyName()); } @@ -185,7 +185,7 @@ private: bool honorExport) { if ((!honorExport || srcp->exported()) && !findIdFlat(name)) { // Don't insert over existing entry - VSymEnt* symp = new VSymEnt(graphp, srcp); + VSymEnt* const symp = new VSymEnt(graphp, srcp); symp->exported(false); // Can't reimport an import without an export symp->imported(true); reinsert(name, symp); @@ -193,7 +193,7 @@ private: } void exportOneSymbol(VSymGraph* graphp, const string& name, const VSymEnt* srcp) const { if (srcp->exported()) { - if (VSymEnt* symp = findIdFlat(name)) { // Should already exist in current table + if (VSymEnt* const symp = findIdFlat(name)) { // Should already exist in current table if (!symp->exported()) symp->exported(true); } } @@ -237,7 +237,7 @@ public: void exportStarStar(VSymGraph* graphp) { // Export *:*: Export all tokens from imported packages for (IdNameMap::const_iterator it = m_idNameMap.begin(); it != m_idNameMap.end(); ++it) { - VSymEnt* symp = it->second; + VSymEnt* const symp = it->second; if (!symp->exported()) symp->exported(true); } } @@ -247,10 +247,10 @@ public: for (IdNameMap::const_iterator it = srcp->m_idNameMap.begin(); it != srcp->m_idNameMap.end(); ++it) { const string& name = it->first; - VSymEnt* subSrcp = it->second; - const AstVar* varp = VN_CAST(subSrcp->nodep(), Var); + VSymEnt* const subSrcp = it->second; + const AstVar* const varp = VN_CAST(subSrcp->nodep(), Var); if (!onlyUnmodportable || (varp && varp->isParam())) { - VSymEnt* subSymp = new VSymEnt(graphp, subSrcp); + VSymEnt* const subSymp = new VSymEnt(graphp, subSrcp); reinsert(name, subSymp); // And recurse to create children subSymp->importFromIface(graphp, subSrcp); @@ -261,7 +261,7 @@ public: if (prettyName == "") prettyName = lookp->prettyName(); string scopes; for (IdNameMap::iterator it = m_idNameMap.begin(); it != m_idNameMap.end(); ++it) { - AstNode* itemp = it->second->nodep(); + AstNode* const itemp = it->second->nodep(); if (VN_IS(itemp, Cell) || (VN_IS(itemp, Module) && VN_AS(itemp, Module)->isTop())) { if (scopes != "") scopes += ", "; scopes += AstNode::prettyName(it->first); diff --git a/src/V3TSP.cpp b/src/V3TSP.cpp index 54fd9395f..465d53fdc 100644 --- a/src/V3TSP.cpp +++ b/src/V3TSP.cpp @@ -53,7 +53,7 @@ VL_DEBUG_FUNC; // Declare debug() // Vertex that tracks a per-vertex key template class TspVertexTmpl : public V3GraphVertex { private: - T_Key m_key; + const T_Key m_key; public: TspVertexTmpl(V3Graph* graphp, const T_Key& k) @@ -112,7 +112,7 @@ public: bool empty() const { return m_vertices.empty(); } - std::list keysToVertexList(const std::vector& odds) { + const std::list keysToVertexList(const std::vector& odds) { std::list vertices; for (unsigned i = 0; i < odds.size(); ++i) { vertices.push_back(findVertex(odds.at(i))); } return vertices; @@ -177,7 +177,7 @@ public: unsigned edges_made = 0; while (!pendingEdges.empty()) { const auto firstIt = pendingEdges.cbegin(); - V3GraphEdge* bestEdgep = *firstIt; + const V3GraphEdge* bestEdgep = *firstIt; pendingEdges.erase(firstIt); // bestEdgep->fromp() should be already seen @@ -298,7 +298,7 @@ public: // Look for an arbitrary edge we've not yet marked for (V3GraphEdge* edgep = cur_vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) { - vluint32_t edgeId = edgep->user(); + const vluint32_t edgeId = edgep->user(); if (markedEdgesp->end() == markedEdgesp->find(edgeId)) { // This edge is not yet marked, so follow it. markedEdgesp->insert(edgeId); @@ -322,7 +322,7 @@ public: recursed = false; // Look for an arbitrary edge at vxp we've not yet marked for (V3GraphEdge* edgep = vxp->outBeginp(); edgep; edgep = edgep->outNextp()) { - vluint32_t edgeId = edgep->user(); + const vluint32_t edgeId = edgep->user(); if (markedEdgesp->end() == markedEdgesp->find(edgeId)) { UINFO(6, "Recursing.\n"); findEulerTourRecurse(markedEdgesp, vxp, sortedOutp); @@ -423,7 +423,7 @@ void V3TSP::tspSort(const V3TSP::StateVec& states, V3TSP::StateVec* resultp) { graph.makeMinSpanningTree(&minGraph); if (debug() >= 6) minGraph.dumpGraphFilePrefixed("minGraph"); - std::vector oddDegree = minGraph.getOddDegreeKeys(); + const std::vector oddDegree = minGraph.getOddDegreeKeys(); Graph matching; graph.perfectMatching(oddDegree, &matching); if (debug() >= 6) matching.dumpGraphFilePrefixed("matching"); @@ -526,9 +526,9 @@ public: bool operator<(const TspTestState& other) const { return m_serial < other.m_serial; } private: - unsigned m_xpos; - unsigned m_ypos; - unsigned m_serial; + const unsigned m_xpos; + const unsigned m_ypos; + const unsigned m_serial; static unsigned s_serialNext; }; @@ -538,11 +538,11 @@ void V3TSP::selfTestStates() { // Linear test -- coords all along the x-axis { V3TSP::StateVec states; - TspTestState s10(10, 0); - TspTestState s60(60, 0); - TspTestState s20(20, 0); - TspTestState s100(100, 0); - TspTestState s5(5, 0); + const TspTestState s10(10, 0); + const TspTestState s60(60, 0); + const TspTestState s20(20, 0); + const TspTestState s100(100, 0); + const TspTestState s5(5, 0); states.push_back(&s10); states.push_back(&s60); states.push_back(&s20); @@ -572,13 +572,13 @@ void V3TSP::selfTestStates() { // Test that tspSort() will rotate the list for minimum cost. { V3TSP::StateVec states; - TspTestState a(0, 0); - TspTestState b(100, 0); - TspTestState c(200, 0); - TspTestState d(200, 100); - TspTestState e(150, 150); - TspTestState f(0, 150); - TspTestState g(0, 100); + const TspTestState a(0, 0); + const TspTestState b(100, 0); + const TspTestState c(200, 0); + const TspTestState d(200, 100); + const TspTestState e(150, 150); + const TspTestState f(0, 150); + const TspTestState g(0, 100); states.push_back(&a); states.push_back(&b); @@ -631,7 +631,7 @@ void V3TSP::selfTestString() { graph.makeMinSpanningTree(&minGraph); if (debug() >= 6) minGraph.dumpGraphFilePrefixed("minGraph"); - std::vector oddDegree = minGraph.getOddDegreeKeys(); + const std::vector oddDegree = minGraph.getOddDegreeKeys(); Graph matching; graph.perfectMatching(oddDegree, &matching); if (debug() >= 6) matching.dumpGraphFilePrefixed("matching"); diff --git a/src/V3Table.cpp b/src/V3Table.cpp index 85e179be6..95aaa2390 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -174,7 +174,7 @@ public: void simulateVarRefCb(AstVarRef* nodep) { // Called by TableSimulateVisitor on each unique varref encountered UINFO(9, " SimVARREF " << nodep << endl); - AstVarScope* vscp = nodep->varScopep(); + AstVarScope* const vscp = nodep->varScopep(); if (nodep->access().isWriteOrRW()) { // We'll make the table with a separate natural alignment for each output var, so // always have 8, 16 or 32 bit widths, so use widthTotalBytes @@ -265,7 +265,7 @@ private: // Populate the tables createTables(nodep, outputAssignedTableBuilder); - AstNode* stmtsp = createLookupInput(fl, indexVscp); + AstNode* const stmtsp = createLookupInput(fl, indexVscp); createOutputAssigns(nodep, stmtsp, indexVscp, outputAssignedTableBuilder.varScopep()); // Link it in. @@ -333,7 +333,7 @@ private: // First var in inVars becomes the LSB of the concat AstNode* concatp = nullptr; for (AstVarScope* invscp : m_inVarps) { - AstVarRef* refp = new AstVarRef(fl, invscp, VAccess::READ); + AstVarRef* const refp = new AstVarRef(fl, invscp, VAccess::READ); if (concatp) { concatp = new AstConcat(fl, refp, concatp); } else { diff --git a/src/V3Task.cpp b/src/V3Task.cpp index c60db1737..3b6177bcc 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -391,7 +391,7 @@ class TaskGatherWrittenVisitor final : public AstNVisitor { public: // Gather all written non-local variables static const std::vector gather(AstCFunc* funcp) { - TaskGatherWrittenVisitor visitor{funcp}; + const TaskGatherWrittenVisitor visitor{funcp}; return std::move(visitor.m_writtenVariables); } }; @@ -419,7 +419,7 @@ private: using DpiCFuncs = std::map>; // STATE - TaskStateVisitor* m_statep; // Common state between visitors + TaskStateVisitor* const m_statep; // Common state between visitors AstNodeModule* m_modp = nullptr; // Current module AstTopScope* const m_topScopep = v3Global.rootp()->topScopep(); // The AstTopScope AstScope* m_scopep = nullptr; // Current scope @@ -432,20 +432,21 @@ private: VL_DEBUG_FUNC; // Declare debug() AstVarScope* createFuncVar(AstCFunc* funcp, const string& name, AstVar* examplep) { - AstVar* newvarp = new AstVar(funcp->fileline(), AstVarType::BLOCKTEMP, name, examplep); + AstVar* const newvarp + = new AstVar(funcp->fileline(), AstVarType::BLOCKTEMP, name, examplep); newvarp->funcLocal(true); funcp->addInitsp(newvarp); - AstVarScope* newvscp = new AstVarScope(funcp->fileline(), m_scopep, newvarp); + AstVarScope* const newvscp = new AstVarScope(funcp->fileline(), m_scopep, newvarp); m_scopep->addVarp(newvscp); return newvscp; } AstVarScope* createInputVar(AstCFunc* funcp, const string& name, AstBasicDTypeKwd kwd) { - AstVar* newvarp = new AstVar(funcp->fileline(), AstVarType::BLOCKTEMP, name, - funcp->findBasicDType(kwd)); + AstVar* const newvarp = new AstVar(funcp->fileline(), AstVarType::BLOCKTEMP, name, + funcp->findBasicDType(kwd)); newvarp->funcLocal(true); newvarp->direction(VDirection::INPUT); funcp->addArgsp(newvarp); - AstVarScope* newvscp = new AstVarScope(funcp->fileline(), m_scopep, newvarp); + AstVarScope* const newvscp = new AstVarScope(funcp->fileline(), m_scopep, newvarp); m_scopep->addVarp(newvscp); return newvscp; } @@ -458,11 +459,12 @@ private: // It shouldn't matter, as they are only local variables. // We choose to do it under whichever called this function, which results // in more cache locality. - AstVar* newvarp = new AstVar{invarp->fileline(), AstVarType::BLOCKTEMP, name, invarp}; + AstVar* const newvarp + = new AstVar{invarp->fileline(), AstVarType::BLOCKTEMP, name, invarp}; newvarp->funcLocal(false); newvarp->propagateAttrFrom(invarp); m_modp->addStmtp(newvarp); - AstVarScope* newvscp = new AstVarScope{newvarp->fileline(), m_scopep, newvarp}; + AstVarScope* const newvscp = new AstVarScope{newvarp->fileline(), m_scopep, newvarp}; m_scopep->addVarp(newvscp); return newvscp; } @@ -472,20 +474,20 @@ private: AstVarScope* outvscp) { // outvscp is the variable for functions only, if nullptr, it's a task UASSERT_OBJ(refp->taskp(), refp, "Unlinked?"); - AstNode* newbodysp + AstNode* const newbodysp = AstNode::cloneTreeNull(refp->taskp()->stmtsp(), true); // Maybe nullptr - AstNode* beginp + AstNode* const beginp = new AstComment(refp->fileline(), string("Function: ") + refp->name(), true); if (newbodysp) beginp->addNext(newbodysp); if (debug() >= 9) beginp->dumpTreeAndNext(cout, "-newbegi:"); // // Create input variables AstNode::user2ClearTree(); - V3TaskConnects tconnects = V3Task::taskConnects(refp, beginp); + const V3TaskConnects tconnects = V3Task::taskConnects(refp, beginp); for (const auto& itr : tconnects) { - AstVar* portp = itr.first; - AstArg* argp = itr.second; - AstNode* pinp = argp->exprp(); + AstVar* const portp = itr.first; + AstArg* const argp = itr.second; + AstNode* const pinp = argp->exprp(); portp->unlinkFrBack(); pushDeletep(portp); // Remove it from the clone (not original) if (!pinp) { @@ -504,9 +506,9 @@ private: // Correct lvalue; see comments below V3LinkLValue::linkLValueSet(pinp); - if (AstVarRef* varrefp = VN_CAST(pinp, VarRef)) { + if (AstVarRef* const varrefp = VN_CAST(pinp, VarRef)) { // Connect to this exact variable - AstVarScope* localVscp = varrefp->varScopep(); + AstVarScope* const localVscp = varrefp->varScopep(); UASSERT_OBJ(localVscp, varrefp, "Null var scope"); portp->user2p(localVscp); pushDeletep(pinp); @@ -525,10 +527,10 @@ private: // Even if it's referencing a varref, we still make a temporary // Else task(x,x,x) might produce incorrect results - AstVarScope* tempvscp + AstVarScope* const tempvscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(tempvscp); - AstAssign* assp = new AstAssign( + AstAssign* const assp = new AstAssign( pinp->fileline(), pinp, new AstVarRef(tempvscp->fileline(), tempvscp, VAccess::READ)); assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, @@ -537,16 +539,16 @@ private: beginp->addNext(assp); } else if (portp->isNonOutput()) { // Make input variable - AstVarScope* inVscp + AstVarScope* const inVscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(inVscp); - AstAssign* assp = new AstAssign( + AstAssign* const assp = new AstAssign( pinp->fileline(), new AstVarRef(inVscp->fileline(), inVscp, VAccess::WRITE), pinp); assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, true); // Ok if in <= block // Put assignment in FRONT of all other statements - if (AstNode* afterp = beginp->nextp()) { + if (AstNode* const afterp = beginp->nextp()) { afterp->unlinkFrBackWithNext(); assp->addNext(afterp); } @@ -559,13 +561,13 @@ private: AstNode* nextstmtp; for (AstNode* stmtp = beginp; stmtp; stmtp = nextstmtp) { nextstmtp = stmtp->nextp(); - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { // Any I/O variables that fell out of above loop were already linked if (!portp->user2p()) { // Move it to a new localized variable portp->unlinkFrBack(); pushDeletep(portp); // Remove it from the clone (not original) - AstVarScope* localVscp + AstVarScope* const localVscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(localVscp); } @@ -580,8 +582,8 @@ private: // Replace variable refs // Iteration requires a back, so put under temporary node { - AstBegin* tempp = new AstBegin(beginp->fileline(), "[EditWrapper]", beginp); - TaskRelinkVisitor visitor{tempp}; + AstBegin* const tempp = new AstBegin(beginp->fileline(), "[EditWrapper]", beginp); + const TaskRelinkVisitor visitor{tempp}; tempp->stmtsp()->unlinkFrBackWithNext(); VL_DO_DANGLING(tempp->deleteTree(), tempp); } @@ -594,19 +596,19 @@ private: AstVarScope* outvscp, AstCNew*& cnewpr) { // outvscp is the variable for functions only, if nullptr, it's a task UASSERT_OBJ(refp->taskp(), refp, "Unlinked?"); - AstCFunc* cfuncp = m_statep->ftaskCFuncp(refp->taskp()); + AstCFunc* const cfuncp = m_statep->ftaskCFuncp(refp->taskp()); UASSERT_OBJ(cfuncp, refp, "No non-inline task associated with this task call?"); // - AstNode* beginp + AstNode* const beginp = new AstComment(refp->fileline(), string("Function: ") + refp->name(), true); AstNodeCCall* ccallp; if (VN_IS(refp, New)) { - AstCNew* cnewp = new AstCNew(refp->fileline(), cfuncp); + AstCNew* const cnewp = new AstCNew(refp->fileline(), cfuncp); cnewp->dtypep(refp->dtypep()); ccallp = cnewp; // Parent AstNew will replace with this CNew cnewpr = cnewp; - } else if (AstMethodCall* mrefp = VN_CAST(refp, MethodCall)) { + } else if (const AstMethodCall* const mrefp = VN_CAST(refp, MethodCall)) { ccallp = new AstCMethodCall(refp->fileline(), mrefp->fromp()->unlinkFrBack(), cfuncp); beginp->addNext(ccallp); } else { @@ -615,10 +617,10 @@ private: } // Convert complicated outputs to temp signals - V3TaskConnects tconnects = V3Task::taskConnects(refp, refp->taskp()->stmtsp()); + const V3TaskConnects tconnects = V3Task::taskConnects(refp, refp->taskp()->stmtsp()); for (const auto& itr : tconnects) { - AstVar* portp = itr.first; - AstNode* pinp = itr.second->exprp(); + AstVar* const portp = itr.first; + AstNode* const pinp = itr.second->exprp(); if (!pinp) { // Too few arguments in function call } else { @@ -649,11 +651,11 @@ private: // Even if it's referencing a varref, we still make a temporary // Else task(x,x,x) might produce incorrect results - AstVarScope* newvscp + AstVarScope* const newvscp = createVarScope(portp, namePrefix + "__" + portp->shortName()); portp->user2p(newvscp); pinp->replaceWith(new AstVarRef(newvscp->fileline(), newvscp, VAccess::WRITE)); - AstAssign* assp = new AstAssign( + AstAssign* const assp = new AstAssign( pinp->fileline(), pinp, new AstVarRef(newvscp->fileline(), newvscp, VAccess::READ)); assp->fileline()->modifyWarnOff(V3ErrorCode::BLKSEQ, @@ -669,7 +671,7 @@ private: if (refp->taskp()->dpiContext()) { // __Vscopep - AstNode* snp = refp->scopeNamep()->unlinkFrBack(); + AstNode* const snp = refp->scopeNamep()->unlinkFrBack(); UASSERT_OBJ(snp, refp, "Missing scoping context"); ccallp->addArgsp(snp); // __Vfilenamep @@ -684,7 +686,7 @@ private: for (AstNode* pinp = refp->pinsp(); pinp; pinp = nextpinp) { nextpinp = pinp->nextp(); // Move pin to the CCall, removing all Arg's - AstNode* exprp = VN_AS(pinp, Arg)->exprp(); + AstNode* const exprp = VN_AS(pinp, Arg)->exprp(); exprp->unlinkFrBack(); ccallp->addArgsp(exprp); } @@ -705,7 +707,7 @@ private: dpiproto += " " + nodep->cname() + " ("; string args; for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (const AstVar* portp = VN_CAST(stmtp, Var)) { + if (const AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn() && portp != rtnvarp) { if (args != "") { args += ", "; @@ -735,7 +737,7 @@ private: // Create assignment from DPI temporary into internal format // DPI temporary is scalar or 1D array (if unpacked array) // Internal representation is scalar, 1D, or multi-dimensional array (similar to SV) - AstVar* portp = portvscp->varp(); + AstVar* const portp = portvscp->varp(); string frstmt; string ket; const bool useSetWSvlv = TaskDpiUtils::dpiToInternalFrStmt(portp, frName, frstmt, ket); @@ -766,7 +768,7 @@ private: AstNode* stmtp = nullptr; // extract a scalar from DPI temporary var that is scalar or 1D array if (useSetWSvlv) { - AstNode* linesp = new AstText(portvscp->fileline(), frstmt + ket); + AstNode* const linesp = new AstText(portvscp->fileline(), frstmt + ket); linesp->addNext(srcp); linesp->addNext( new AstText(portvscp->fileline(), @@ -780,9 +782,9 @@ private: from += "[" + cvtToStr(i * coef) + "]"; } from += ket; - AstNode* rhsp = new AstSel(portp->fileline(), - new AstCMath(portp->fileline(), from, cwidth, false), 0, - portp->width()); + AstNode* const rhsp = new AstSel( + portp->fileline(), new AstCMath(portp->fileline(), from, cwidth, false), 0, + portp->width()); stmtp = new AstAssign(portp->fileline(), srcp, rhsp); } if (i > 0) { @@ -827,7 +829,7 @@ private: // If the find fails, it will throw an error stmt += "const VerilatedScope* __Vscopep = Verilated::dpiScope();\n"; // If dpiScope is fails and is null; the exportFind function throws and error - string cbtype + const string cbtype = VIdProtect::protect(v3Global.opt.prefix() + "__Vcb_" + nodep->cname() + "_t"); stmt += cbtype + " __Vcb = (" + cbtype + ")(VerilatedScope::exportFind(__Vscopep, __Vfuncnum));\n"; // Can't use @@ -842,7 +844,7 @@ private: + "*)(__Vscopep->symsp())"); // Upcast w/o overhead AstNode* argnodesp = nullptr; for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && !portp->isFuncReturn() && portp != rtnvarp) { // No createDpiTemp; we make a real internal variable instead // SAME CODE BELOW @@ -851,11 +853,12 @@ private: argnodesp = argnodesp->addNext(new AstText(portp->fileline(), args, true)); args = ""; } - AstVarScope* outvscp = createFuncVar(funcp, portp->name() + tmpSuffixp, portp); + AstVarScope* const outvscp + = createFuncVar(funcp, portp->name() + tmpSuffixp, portp); // No information exposure; is already visible in import/export func template outvscp->varp()->protect(false); portp->protect(false); - AstVarRef* refp + AstVarRef* const refp = new AstVarRef(portp->fileline(), outvscp, portp->isWritable() ? VAccess::WRITE : VAccess::READ); argnodesp = argnodesp->addNextNull(refp); @@ -874,18 +877,18 @@ private: } if (rtnvarp) { - AstVar* portp = rtnvarp; + AstVar* const portp = rtnvarp; // SAME CODE ABOVE args += ", "; if (args != "") { argnodesp = argnodesp->addNext(new AstText(portp->fileline(), args, true)); args = ""; } - AstVarScope* outvscp = createFuncVar(funcp, portp->name() + tmpSuffixp, portp); + AstVarScope* const outvscp = createFuncVar(funcp, portp->name() + tmpSuffixp, portp); // No information exposure; is already visible in import/export func template outvscp->varp()->protect(false); - AstVarRef* refp = new AstVarRef(portp->fileline(), outvscp, - portp->isWritable() ? VAccess::WRITE : VAccess::READ); + AstVarRef* const refp = new AstVarRef( + portp->fileline(), outvscp, portp->isWritable() ? VAccess::WRITE : VAccess::READ); argnodesp = argnodesp->addNextNull(refp); } @@ -893,7 +896,7 @@ private: // Add the variables referenced as VarRef's so that lifetime analysis // doesn't rip up the variables on us args += ");\n"; - AstCStmt* newp = new AstCStmt(nodep->fileline(), "(*__Vcb)("); + AstCStmt* const newp = new AstCStmt(nodep->fileline(), "(*__Vcb)("); newp->addBodysp(argnodesp); VL_DANGLING(argnodesp); newp->addBodysp(new AstText(nodep->fileline(), args, true)); @@ -902,7 +905,7 @@ private: // Convert output/inout arguments back to internal type for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO() && portp->isWritable() && !portp->isFuncReturn()) { funcp->addStmtsp(createAssignInternalToDpi(portp, true, tmpSuffixp, "")); } @@ -984,10 +987,10 @@ private: static void makePortList(AstNodeFTask* nodep, AstCFunc* dpip) { // Copy nodep's list of function I/O to the new dpip c function for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO()) { // Move it to new function - AstVar* newPortp = portp->cloneTree(false); + AstVar* const newPortp = portp->cloneTree(false); newPortp->funcLocal(true); dpip->addArgsp(newPortp); if (!portp->basicp()) { @@ -1011,8 +1014,8 @@ private: // Convert input/inout arguments to DPI types string args; for (AstNode* stmtp = cfuncp->argsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { - AstVarScope* portvscp + if (AstVar* const portp = VN_CAST(stmtp, Var)) { + AstVarScope* const portvscp = VN_AS(portp->user2p(), VarScope); // Remembered when we created it earlier if (portp->isIO() && !portp->isFuncReturn() && portvscp != rtnvscp && portp->name() != "__Vscopep" // Passed to dpiContext, not callee @@ -1021,7 +1024,7 @@ private: if (args != "") args += ", "; if (portp->isDpiOpenArray()) { - AstNodeDType* dtypep = portp->dtypep()->skipRefp(); + AstNodeDType* const dtypep = portp->dtypep()->skipRefp(); if (VN_IS(dtypep, DynArrayDType) || VN_IS(dtypep, QueueDType)) { v3fatalSrc("Passing dynamic array or queue as actual argument to DPI " "open array is not yet supported"); @@ -1038,7 +1041,7 @@ private: // point to this task & thread's data, in addition // to static info about the variable const string name = portp->name() + "__Vopenarray"; - string varCode + const string varCode = ("VerilatedDpiOpenVar " // NOLINTNEXTLINE(performance-inefficient-string-concatenation) + name + " (&" + propName + ", &" + portp->name() + ");\n"); @@ -1082,11 +1085,11 @@ private: // Convert output/inout arguments back to internal type for (AstNode* stmtp = cfuncp->argsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { portp->protect(false); // No additional exposure - already part of shown proto if (portp->isIO() && (portp->isWritable() || portp->isFuncReturn()) && !portp->isDpiOpenArray()) { - AstVarScope* portvscp = VN_AS( + AstVarScope* const portvscp = VN_AS( portp->user2p(), VarScope); // Remembered when we created it earlier cfuncp->addStmtsp( createAssignDpiToInternal(portvscp, portp->name() + tmpSuffixp)); @@ -1118,11 +1121,11 @@ private: AstNode::user2ClearTree(); AstVar* rtnvarp = nullptr; if (nodep->isFunction()) { - AstVar* portp = VN_AS(nodep->fvarp(), Var); + AstVar* const portp = VN_AS(nodep->fvarp(), Var); UASSERT_OBJ(portp, nodep, "function without function output variable"); if (!portp->isFuncReturn()) nodep->v3error("Not marked as function return var"); if (nodep->dpiImport() || nodep->dpiExport()) { - AstBasicDType* bdtypep = portp->dtypep()->basicp(); + AstBasicDType* const bdtypep = portp->dtypep()->basicp(); if (!bdtypep->isDpiPrimitive()) { if (bdtypep->isDpiBitVec() && portp->width() > 32) { portp->v3error("DPI function may not return a > 32 bits wide type " @@ -1190,7 +1193,7 @@ private: string suffix; // So, make them unique if (!nodep->taskPublic() && !nodep->classMethod()) suffix = "_" + m_scopep->nameDotless(); const string name = ((nodep->name() == "new") ? "new" : prefix + nodep->name() + suffix); - AstCFunc* cfuncp = new AstCFunc( + AstCFunc* const cfuncp = new AstCFunc( nodep->fileline(), name, m_scopep, ((nodep->taskPublic() && rtnvarp) ? rtnvarp->cPubArgType(true, true) : "")); // It's ok to combine imports because this is just a wrapper; @@ -1211,7 +1214,7 @@ private: cfuncp->pure(nodep->pure()); if (nodep->name() == "new") { cfuncp->isConstructor(true); - AstClass* classp = m_statep->getClassp(nodep); + AstClass* const classp = m_statep->getClassp(nodep); if (classp->extendsp()) { cfuncp->ctorInits(EmitCBaseVisitor::prefixNameProtect(classp->extendsp()->classp()) + "(vlSymsp)"); @@ -1235,7 +1238,7 @@ private: } if (nodep->dpiExport()) { - AstScopeName* snp = nodep->scopeNamep(); + AstScopeName* const snp = nodep->scopeNamep(); UASSERT_OBJ(snp, nodep, "Missing scoping context"); snp->dpiExport( true); // The AstScopeName is really a statement(ish) for tracking, not a function @@ -1246,7 +1249,7 @@ private: // Create list of arguments and move to function for (AstNode *nextp, *stmtp = nodep->stmtsp(); stmtp; stmtp = nextp) { nextp = stmtp->nextp(); - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isParam() && VN_IS(portp->valuep(), InitArray)) { // Move array parameters in functions into constant pool portp->unlinkFrBack(); @@ -1264,7 +1267,8 @@ private: // "Normal" variable, mark inside function portp->funcLocal(true); } - AstVarScope* newvscp = new AstVarScope{portp->fileline(), m_scopep, portp}; + AstVarScope* const newvscp + = new AstVarScope{portp->fileline(), m_scopep, portp}; m_scopep->addVarp(newvscp); portp->user2p(newvscp); } @@ -1278,7 +1282,7 @@ private: if (rtnvarp) cfuncp->addArgsp(rtnvarp); // Move body - AstNode* bodysp = nodep->stmtsp(); + AstNode* const bodysp = nodep->stmtsp(); if (bodysp) { bodysp->unlinkFrBackWithNext(); cfuncp->addStmtsp(bodysp); @@ -1293,8 +1297,8 @@ private: // Replace variable refs // Iteration requires a back, so put under temporary node { - AstBegin* tempp = new AstBegin(cfuncp->fileline(), "[EditWrapper]", cfuncp); - TaskRelinkVisitor visitor{tempp}; + AstBegin* const tempp = new AstBegin(cfuncp->fileline(), "[EditWrapper]", cfuncp); + const TaskRelinkVisitor visitor{tempp}; tempp->stmtsp()->unlinkFrBackWithNext(); VL_DO_DANGLING(tempp->deleteTree(), tempp); } @@ -1367,7 +1371,7 @@ private: m_insStmtp->addNextHere(newp); } else if (m_insMode == IM_WHILE_PRECOND) { UINFO(5, " IM_While_Precond " << m_insStmtp << endl); - AstWhile* whilep = VN_AS(m_insStmtp, While); + AstWhile* const whilep = VN_AS(m_insStmtp, While); UASSERT_OBJ(whilep, nodep, "Insert should be under WHILE"); whilep->addPrecondsp(newp); visitp = newp; @@ -1430,7 +1434,7 @@ private: visitp = insertBeforeStmt(nodep, beginp); } else if (!nodep->isStatement()) { UASSERT_OBJ(nodep->taskp()->isFunction(), nodep, "func reference to non-function"); - AstVarRef* outrefp = new AstVarRef(nodep->fileline(), outvscp, VAccess::READ); + AstVarRef* const outrefp = new AstVarRef(nodep->fileline(), outvscp, VAccess::READ); nodep->replaceWith(outrefp); // Insert new statements visitp = insertBeforeStmt(nodep, beginp); @@ -1482,10 +1486,10 @@ private: if (m_statep->ftaskNoInline(nodep) && !nodep->classMethod()) { m_statep->checkPurity(nodep); } - AstNodeFTask* clonedFuncp = nodep->cloneTree(false); + AstNodeFTask* const clonedFuncp = nodep->cloneTree(false); if (nodep->isConstructor()) m_statep->remapFuncClassp(nodep, clonedFuncp); - AstCFunc* cfuncp = makeUserFunc(clonedFuncp, m_statep->ftaskNoInline(nodep)); + AstCFunc* const cfuncp = makeUserFunc(clonedFuncp, m_statep->ftaskNoInline(nodep)); if (cfuncp) { nodep->addNextHere(cfuncp); if (nodep->dpiImport() || m_statep->ftaskNoInline(nodep)) { @@ -1498,16 +1502,16 @@ private: // Any variables inside the function still have varscopes pointing to them. // We're going to delete the vars, so delete the varscopes. if (nodep->isFunction()) { - if (AstVar* portp = VN_CAST(nodep->fvarp(), Var)) { - AstVarScope* vscp = m_statep->findVarScope(m_scopep, portp); + if (AstVar* const portp = VN_CAST(nodep->fvarp(), Var)) { + AstVarScope* const vscp = m_statep->findVarScope(m_scopep, portp); UINFO(9, " funcremovevsc " << vscp << endl); VL_DO_DANGLING(pushDeletep(vscp->unlinkFrBack()), vscp); } } for (AstNode *nextp, *stmtp = nodep->stmtsp(); stmtp; stmtp = nextp) { nextp = stmtp->nextp(); - if (AstVar* portp = VN_CAST(stmtp, Var)) { - AstVarScope* vscp = m_statep->findVarScope(m_scopep, portp); + if (AstVar* const portp = VN_CAST(stmtp, Var)) { + AstVarScope* const vscp = m_statep->findVarScope(m_scopep, portp); UINFO(9, " funcremovevsc " << vscp << endl); VL_DO_DANGLING(pushDeletep(vscp->unlinkFrBack()), vscp); } @@ -1578,7 +1582,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) int tpinnum = 0; AstVar* sformatp = nullptr; for (AstNode* stmtp = taskStmtsp; stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isIO()) { tconnects.push_back(std::make_pair(portp, static_cast(nullptr))); nameToIndex.insert( @@ -1599,7 +1603,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) bool reorganize = false; for (AstNode *nextp, *pinp = nodep->pinsp(); pinp; pinp = nextp) { nextp = pinp->nextp(); - AstArg* argp = VN_AS(pinp, Arg); + AstArg* const argp = VN_AS(pinp, Arg); UASSERT_OBJ(argp, pinp, "Non-arg under ftask reference"); if (argp->name() != "") { // By name @@ -1640,7 +1644,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) // Connect missing ones for (int i = 0; i < tpinnum; ++i) { - AstVar* portp = tconnects[i].first; + AstVar* const portp = tconnects[i].first; if (!tconnects[i].second || !tconnects[i].second->exprp()) { AstNode* newvaluep = nullptr; if (!portp->valuep()) { @@ -1671,7 +1675,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) // To avoid problems with callee needing to know to deleteTree // or not, we make this into a pin UINFO(9, "Default pin for " << portp << endl); - AstArg* newp = new AstArg(nodep->fileline(), portp->name(), newvaluep); + AstArg* const newp = new AstArg(nodep->fileline(), portp->name(), newvaluep); if (tconnects[i].second) { // Have a "nullptr" pin already defined for it VL_DO_CLEAR(tconnects[i].second->unlinkFrBack()->deleteTree(), tconnects[i].second = nullptr); @@ -1693,7 +1697,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp) nodep->pinsp()->unlinkFrBack(); } for (int i = 0; i < tpinnum; ++i) { - AstArg* argp = tconnects[i].second; + AstArg* const argp = tconnects[i].second; UASSERT_OBJ(argp, nodep, "Lost argument in func conversion"); nodep->addPinsp(argp); } @@ -1721,7 +1725,8 @@ string V3Task::assignInternalToDpi(AstVar* portp, bool isPtr, const string& frSu const string toName = portp->name() + toSuffix; size_t unpackSize = 1; // non-unpacked array is treated as size 1 int unpackDim = 0; - if (AstUnpackArrayDType* unpackp = VN_CAST(portp->dtypep()->skipRefp(), UnpackArrayDType)) { + if (AstUnpackArrayDType* const unpackp + = VN_CAST(portp->dtypep()->skipRefp(), UnpackArrayDType)) { unpackSize = unpackp->arrayUnpackedElements(); unpackDim = unpackp->dimensions(false).second; if (unpackDim > 0) UASSERT_OBJ(unpackSize > 0, portp, "size must be greater than 0"); @@ -1825,7 +1830,7 @@ void V3Task::taskAll(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { TaskStateVisitor visitors{nodep}; - TaskVisitor visitor{nodep, &visitors}; + const TaskVisitor visitor{nodep, &visitors}; } // Destruct before checking V3Global::dumpCheckGlobalTree("task", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); } diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 26fcdd4b7..4c1ade6c0 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -215,7 +215,7 @@ private: // Find if there are any duplicates for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { if (TraceTraceVertex* const vvertexp = dynamic_cast(itp)) { - AstTraceDecl* const nodep = vvertexp->nodep(); + const AstTraceDecl* const nodep = vvertexp->nodep(); if (nodep->valuep() && !vvertexp->duplicatep()) { const auto dupit = dupFinder.findDuplicate(nodep->valuep()); if (dupit != dupFinder.end()) { @@ -387,7 +387,7 @@ private: for (; it != end && it->first == actSet; ++it) { if (!it->second->duplicatep()) { uint32_t cost = 0; - AstTraceDecl* const declp = it->second->nodep(); + const AstTraceDecl* const declp = it->second->nodep(); // The number of comparisons required by tracep->chg* cost += declp->isWide() ? declp->codeInc() : 1; // Arrays are traced by element @@ -532,7 +532,7 @@ private: } } // Add call to top function - AstCCall* callp = new AstCCall(funcp->fileline(), funcp); + AstCCall* const callp = new AstCCall(funcp->fileline(), funcp); callp->argTypes("tracep"); topFuncp->addStmtsp(callp); } @@ -562,7 +562,7 @@ private: // This is a duplicate trace node. We will assign the signal // number to the canonical node, and emit this as an alias, so // no need to create a TraceInc node. - AstTraceDecl* const canonDeclp = canonVtxp->nodep(); + const AstTraceDecl* const canonDeclp = canonVtxp->nodep(); UASSERT_OBJ(!canonVtxp->duplicatep(), canonDeclp, "Canonical node is a duplicate"); UASSERT_OBJ(canonDeclp->code() != 0, canonDeclp, diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 51535a3d1..db1d60667 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -42,7 +42,7 @@ private: AstCFunc* m_initSubFuncp = nullptr; // Trace function being built (under m_init) int m_initSubStmts = 0; // Number of statements in function int m_funcNum = 0; // Function number being built - AstVarScope* m_traVscp = nullptr; // Signal being trace constructed + const AstVarScope* m_traVscp = nullptr; // Signal being trace constructed AstNode* m_traValuep = nullptr; // Signal being traced's value to trace in it string m_traShowname; // Signal being traced's component name bool m_interface = false; // Currently tracing an interface @@ -84,7 +84,7 @@ private: return funcp; } void callCFuncSub(AstCFunc* basep, AstCFunc* funcp, AstIntfRef* irp) { - AstCCall* callp = new AstCCall(funcp->fileline(), funcp); + AstCCall* const callp = new AstCCall(funcp->fileline(), funcp); if (irp) { callp->argTypes("tracep, VLT_TRACE_SCOPE_INTERFACE"); callp->addArgsp(irp->unlinkFrBack()); @@ -144,7 +144,7 @@ private: iterateChildren(nodep); } virtual void visit(AstScope* nodep) override { - AstCell* const cellp = nodep->aboveCellp(); + const AstCell* const cellp = nodep->aboveCellp(); if (cellp && VN_IS(cellp->modp(), Iface)) { AstCFunc* const origSubFunc = m_initSubFuncp; int origSubStmts = m_initSubStmts; diff --git a/src/V3Tristate.cpp b/src/V3Tristate.cpp index 64b8d5e45..d57adf971 100644 --- a/src/V3Tristate.cpp +++ b/src/V3Tristate.cpp @@ -213,7 +213,7 @@ public: bool empty() const { return m_graph.empty(); } void clear() { for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - TristateVertex* const vvertexp = static_cast(itp); + const TristateVertex* const vvertexp = static_cast(itp); if (vvertexp->isTristate() && !vvertexp->processed()) { // Not v3errorSrc as no reason to stop the world vvertexp->nodep()->v3error("Unsupported tristate construct" @@ -240,11 +240,11 @@ public: new V3GraphEdge(&m_graph, makeVertex(fromp), makeVertex(top), 1); } bool isTristate(AstNode* nodep) { - TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); + const TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); return vertexp && vertexp->isTristate(); } bool feedsTri(AstNode* nodep) { - TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); + const TristateVertex* const vertexp = reinterpret_cast(nodep->user5p()); return vertexp && vertexp->feedsTri(); } void didProcess(AstNode* nodep) { @@ -264,7 +264,7 @@ public: // Return all tristate variables VarVec v; for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp = itp->verticesNextp()) { - TristateVertex* const vvertexp = static_cast(itp); + const TristateVertex* const vvertexp = static_cast(itp); if (vvertexp->isTristate()) { if (AstVar* const nodep = VN_CAST(vvertexp->nodep(), Var)) v.push_back(nodep); } @@ -279,7 +279,7 @@ public: class TristatePinVisitor final : public TristateBaseVisitor { TristateGraph& m_tgraph; - bool m_lvalue; // Flip to be an LVALUE + const bool m_lvalue; // Flip to be an LVALUE // VISITORS virtual void visit(AstVarRef* nodep) override { UASSERT_OBJ(!nodep->access().isRW(), nodep, "Tristate unexpected on R/W access flip"); @@ -350,7 +350,7 @@ class TristateVisitor final : public TristateBaseVisitor { VarMap m_lhsmap; // LHS driver map int m_unique = 0; bool m_alhs = false; // On LHS of assignment - AstNode* m_logicp = nullptr; // Current logic being built + const AstNode* m_logicp = nullptr; // Current logic being built TristateGraph m_tgraph; // Logic graph // STATS @@ -449,7 +449,7 @@ class TristateVisitor final : public TristateBaseVisitor { } void setPullDirection(AstVar* varp, AstPull* pullp) { - AstPull* const oldpullp = static_cast(varp->user3p()); + const AstPull* const oldpullp = static_cast(varp->user3p()); if (!oldpullp) { varp->user3p(pullp); // save off to indicate the pull direction } else { @@ -485,7 +485,7 @@ class TristateVisitor final : public TristateBaseVisitor { // Go through all the vars and find any that are outputs without drivers // or inouts without high-Z logic and put a 1'bz driver on them and add // them to the lhs map so they get expanded correctly. - TristateGraph::VarVec vars = m_tgraph.tristateVars(); + const TristateGraph::VarVec vars = m_tgraph.tristateVars(); for (auto varp : vars) { if (m_tgraph.isTristate(varp)) { const auto it = m_lhsmap.find(varp); @@ -515,7 +515,7 @@ class TristateVisitor final : public TristateBaseVisitor { nextit = it; ++nextit; AstVar* const invarp = it->first; - RefVec* const refsp = it->second; + const RefVec* const refsp = it->second; // Figure out if this var needs tristate expanded. if (!m_tgraph.isTristate(invarp)) { @@ -564,7 +564,7 @@ class TristateVisitor final : public TristateBaseVisitor { // loop through the lhs drivers to build the driver resolution logic for (auto refp : *refsp) { - int w = lhsp->width(); + const int w = lhsp->width(); // create the new lhs driver for this var AstVar* const newlhsp = new AstVar(lhsp->fileline(), AstVarType::MODULETEMP, @@ -613,7 +613,7 @@ class TristateVisitor final : public TristateBaseVisitor { // This is the final resolution of the tristate, so we apply // the pull direction to any undriven pins. V3Number pull(invarp, lhsp->width()); - AstPull* const pullp = static_cast(lhsp->user3p()); + const AstPull* const pullp = static_cast(lhsp->user3p()); if (pullp && pullp->direction() == 1) { pull.setAllBits1(); UINFO(9, "Has pullup " << pullp << endl); @@ -950,8 +950,9 @@ class TristateVisitor final : public TristateBaseVisitor { // 3'b1z0 -> ((3'b101 == in__en) && (3'b100 == in)) varrefp->unlinkFrBack(); FileLine* const fl = nodep->fileline(); - V3Number oneIfEn = VN_AS(constp->user1p(), Const) - ->num(); // visit(AstConst) already split into en/ones + const V3Number oneIfEn + = VN_AS(constp->user1p(), Const) + ->num(); // visit(AstConst) already split into en/ones const V3Number& oneIfEnOne = constp->num(); AstVar* const envarp = getCreateEnVarp(varrefp->varp()); AstNode* newp @@ -995,7 +996,7 @@ class TristateVisitor final : public TristateBaseVisitor { dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyZ(); dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_AS(nodep->fhsp(), Const)->num().isAnyZ(); UINFO(4, " COUNTBITS(" << dropop[0] << dropop[1] << dropop[2] << " " << nodep << endl); - AstVarRef* const varrefp = VN_AS(nodep->lhsp(), VarRef); // Input variable + const AstVarRef* const varrefp = VN_AS(nodep->lhsp(), VarRef); // Input variable if (m_graphing) { iterateAndNextNull(nodep->lhsp()); if (!dropop[0]) iterateAndNextNull(nodep->rhsp()); @@ -1160,7 +1161,7 @@ class TristateVisitor final : public TristateBaseVisitor { } else if (inDeclProcessing) { // Not an input that was a converted tristate // Input only may have driver in underneath module which would stomp // the input value. So make a temporary connection. - AstAssignW* const reAssignp + const AstAssignW* const reAssignp = V3Inst::pinReconnectSimple(nodep, m_cellp, true, true); UINFO(5, "Input pin buffering: " << reAssignp << endl); m_tgraph.setTristate(reAssignp->lhsp()); @@ -1191,7 +1192,7 @@ class TristateVisitor final : public TristateBaseVisitor { if (debug() >= 9) enpinp->dumpTree(cout, "-pin-ena: "); } // Create new output pin - AstAssignW* outAssignp = nullptr; // If reconnected, the related assignment + const AstAssignW* outAssignp = nullptr; // If reconnected, the related assignment AstPin* outpinp = nullptr; AstVar* const outModVarp = static_cast(nodep->modVarp()->user4p()); if (!outModVarp) { @@ -1228,8 +1229,8 @@ class TristateVisitor final : public TristateBaseVisitor { } // Existing pin becomes an input, and we mark each resulting signal as tristate - TristatePinVisitor visitor{nodep->exprp(), m_tgraph, false}; - AstNode* const inAssignp = V3Inst::pinReconnectSimple( + const TristatePinVisitor visitor{nodep->exprp(), m_tgraph, false}; + const AstNode* const inAssignp = V3Inst::pinReconnectSimple( nodep, m_cellp, true); // Note may change nodep->exprp() if (debug() >= 9) nodep->dumpTree(cout, "-pin-in: "); if (debug() >= 9 && inAssignp) inAssignp->dumpTree(cout, "-pin-as: "); diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index b601b8563..9ff4fa592 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -250,15 +250,15 @@ private: bool m_inBBox = false; // In black box; mark as driven+used bool m_inContAssign = false; // In continuous assignment bool m_inProcAssign = false; // In procedural assignment - AstNodeFTask* m_taskp = nullptr; // Current task - AstAlways* m_alwaysCombp = nullptr; // Current always if combo, otherwise nullptr + const AstNodeFTask* m_taskp = nullptr; // Current task + const AstAlways* m_alwaysCombp = nullptr; // Current always if combo, otherwise nullptr // METHODS VL_DEBUG_FUNC; // Declare debug() UndrivenVarEntry* getEntryp(AstVar* nodep, int which_user) { if (!(which_user == 1 ? nodep->user1p() : nodep->user2p())) { - UndrivenVarEntry* entryp = new UndrivenVarEntry(nodep); + UndrivenVarEntry* const entryp = new UndrivenVarEntry(nodep); // UINFO(9," Associate u="<name()<( + UndrivenVarEntry* const entryp = reinterpret_cast( which_user == 1 ? nodep->user1p() : nodep->user2p()); return entryp; } } void warnAlwCombOrder(AstNodeVarRef* nodep) { - AstVar* varp = nodep->varp(); + AstVar* const varp = nodep->varp(); if (!varp->isParam() && !varp->isGenVar() && !varp->isUsedLoopIdx() && !m_inBBox // We may have falsely considered a SysIgnore as a driver && !VN_IS(nodep, VarXRef) // Xrefs might point at two different instances @@ -297,7 +297,7 @@ private: // for module-wide undriven etc. // For non-combo always, run both usr==1 for above, and also // usr==2 for always-only checks. - UndrivenVarEntry* entryp = getEntryp(nodep, usr); + UndrivenVarEntry* const entryp = getEntryp(nodep, usr); if (nodep->isNonOutput() || nodep->isSigPublic() || nodep->isSigUserRWPublic() || (m_taskp && (m_taskp->dpiImport() || m_taskp->dpiExport()))) { entryp->drivenWhole(); @@ -321,11 +321,11 @@ private: iterateChildren(nodep); } virtual void visit(AstSel* nodep) override { - AstNodeVarRef* varrefp = VN_CAST(nodep->fromp(), NodeVarRef); - AstConst* constp = VN_CAST(nodep->lsbp(), Const); + AstNodeVarRef* const varrefp = VN_CAST(nodep->fromp(), NodeVarRef); + AstConst* const constp = VN_CAST(nodep->lsbp(), Const); if (varrefp && constp && !constp->num().isFourState()) { for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) { - UndrivenVarEntry* entryp = getEntryp(varrefp->varp(), usr); + UndrivenVarEntry* const entryp = getEntryp(varrefp->varp(), usr); const int lsb = constp->toUInt(); if (m_inBBox || varrefp->access().isWriteOrRW()) { // Don't warn if already driven earlier as "a=0; if(a) a=1;" is fine. @@ -364,7 +364,7 @@ private: } } for (int usr = 1; usr < (m_alwaysCombp ? 3 : 2); ++usr) { - UndrivenVarEntry* entryp = getEntryp(nodep->varp(), usr); + UndrivenVarEntry* const entryp = getEntryp(nodep->varp(), usr); const bool fdrv = nodep->access().isWriteOrRW() && nodep->varp()->attrFileDescr(); // FD's are also being read from if (m_inBBox || nodep->access().isWriteOrRW()) { diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index f45b9dfec..59b9ac0d0 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -121,7 +121,7 @@ private: m_modp->addStmtp(varp); AstNode* const abovep = prep->backp(); // Grab above point before we replace 'prep' prep->replaceWith(new AstVarRef(fl, varp, VAccess::WRITE)); - AstIf* newp = new AstIf( + AstIf* const newp = new AstIf( fl, condp, (needDly ? static_cast( new AstAssignDly(fl, prep, new AstVarRef(fl, varp, VAccess::READ))) @@ -188,8 +188,8 @@ private: VL_DO_DANGLING(V3Const::constifyEdit(nodep), nodep); return; } else { - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* newp; // If we got ==1'bx it can never be true (but 1'bx==1'bx can be!) if (((VN_IS(lhsp, Const) && VN_AS(lhsp, Const)->num().isFourState()) @@ -220,8 +220,8 @@ private: VL_DO_DANGLING(V3Const::constifyEdit(nodep), nodep); return; } else { - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNode* newp; if (!VN_IS(rhsp, Const)) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: RHS of ==? or !=? must be " @@ -234,9 +234,9 @@ private: nummask.opBitsNonX(VN_AS(rhsp, Const)->num()); V3Number numval(rhsp, rhsp->width()); numval.opBitsOne(VN_AS(rhsp, Const)->num()); - AstNode* and1p = new AstAnd(nodep->fileline(), lhsp, - new AstConst(nodep->fileline(), nummask)); - AstNode* and2p = new AstConst(nodep->fileline(), numval); + AstNode* const and1p = new AstAnd(nodep->fileline(), lhsp, + new AstConst(nodep->fileline(), nummask)); + AstNode* const and2p = new AstConst(nodep->fileline(), numval); if (VN_IS(nodep, EqWild)) { newp = new AstEq(nodep->fileline(), and1p, and2p); } else { @@ -259,7 +259,7 @@ private: iterateChildren(nodep); // Ahh, we're two state, so this is easy UINFO(4, " ISUNKNOWN->0 " << nodep << endl); - AstConst* newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + AstConst* const newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } @@ -280,7 +280,7 @@ private: nonXp = nodep->fhsp(); else { // Was all X-s UINFO(4, " COUNTBITS('x)->0 " << nodep << endl); - AstConst* newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); + AstConst* const newp = new AstConst(nodep->fileline(), AstConst::BitFalse()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); return; @@ -318,7 +318,7 @@ private: } else { numnew.opAssign(numb1); } - AstConst* newp = new AstConst(nodep->fileline(), numnew); + AstConst* const newp = new AstConst(nodep->fileline(), numnew); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); UINFO(4, " -> " << newp << endl); @@ -363,9 +363,9 @@ private: iterateChildren(nodep); if (!nodep->user1SetOnce()) { // Guard against reading/writing past end of bit vector array - const AstNode* basefromp = AstArraySel::baseFromp(nodep, true); + const AstNode* const basefromp = AstArraySel::baseFromp(nodep, true); bool lvalue = false; - if (const AstNodeVarRef* varrefp = VN_CAST(basefromp, NodeVarRef)) { + if (const AstNodeVarRef* const varrefp = VN_CAST(basefromp, NodeVarRef)) { lvalue = varrefp->access().isWriteOrRW(); } // Find range of dtype we are selecting from @@ -390,8 +390,8 @@ private: nodep->unlinkFrBack(&replaceHandle); V3Number xnum(nodep, nodep->width()); xnum.setAllBitsX(); - AstNode* newp = new AstCondBound(nodep->fileline(), condp, nodep, - new AstConst(nodep->fileline(), xnum)); + AstNode* const newp = new AstCondBound(nodep->fileline(), condp, nodep, + new AstConst(nodep->fileline(), xnum)); if (debug() >= 9) newp->dumpTree(cout, " _new: "); // Link in conditional replaceHandle.relink(newp); @@ -411,9 +411,9 @@ private: if (!nodep->user1SetOnce()) { if (debug() == 9) nodep->dumpTree(cout, "-in: "); // Guard against reading/writing past end of arrays - AstNode* basefromp = AstArraySel::baseFromp(nodep->fromp(), true); + AstNode* const basefromp = AstArraySel::baseFromp(nodep->fromp(), true); bool lvalue = false; - if (const AstNodeVarRef* varrefp = VN_CAST(basefromp, NodeVarRef)) { + if (const AstNodeVarRef* const varrefp = VN_CAST(basefromp, NodeVarRef)) { lvalue = varrefp->access().isWriteOrRW(); } else if (VN_IS(basefromp, Const)) { // If it's a PARAMETER[bit], then basefromp may be a constant instead of a varrefp @@ -422,9 +422,9 @@ private: } // Find range of dtype we are selecting from int declElements = -1; - AstNodeDType* dtypep = nodep->fromp()->dtypep()->skipRefp(); + AstNodeDType* const dtypep = nodep->fromp()->dtypep()->skipRefp(); UASSERT_OBJ(dtypep, nodep, "Select of non-selectable type"); - if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) { + if (const AstNodeArrayDType* const adtypep = VN_CAST(dtypep, NodeArrayDType)) { declElements = adtypep->elementsConst(); } else { nodep->v3error("Select from non-array " << dtypep->prettyTypeName()); @@ -453,8 +453,8 @@ private: } else { xnum.setAllBitsX(); } - AstNode* newp = new AstCondBound(nodep->fileline(), condp, nodep, - new AstConst(nodep->fileline(), xnum)); + AstNode* const newp = new AstCondBound(nodep->fileline(), condp, nodep, + new AstConst(nodep->fileline(), xnum)); if (debug() >= 9) newp->dumpTree(cout, " _new: "); // Link in conditional, can blow away temp xor replaceHandle.relink(newp); @@ -463,8 +463,8 @@ private: } else if (!lvalue) { // Mid-multidimension read, just use zero // ARRAYSEL(...) -> ARRAYSEL(COND(LT(bitbitp()->unlinkFrBack(&replaceHandle); - AstNode* newp = new AstCondBound( + AstNode* const bitp = nodep->bitp()->unlinkFrBack(&replaceHandle); + AstNode* const newp = new AstCondBound( bitp->fileline(), condp, bitp, new AstConst(bitp->fileline(), AstConst::WidthedValue(), bitp->width(), 0)); // Added X's, tristate them too diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index e63eb1e0c..22b14570f 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -43,9 +43,9 @@ class UnrollVisitor final : public AstNVisitor { private: // STATE AstVar* m_forVarp; // Iterator variable - AstVarScope* m_forVscp; // Iterator variable scope (nullptr for generate pass) + const AstVarScope* m_forVscp; // Iterator variable scope (nullptr for generate pass) AstConst* m_varValuep; // Current value of loop - AstNode* m_ignoreIncp; // Increment node to ignore + const AstNode* m_ignoreIncp; // Increment node to ignore bool m_varModeCheck; // Just checking RHS assignments bool m_varModeReplace; // Replacing varrefs bool m_varAssignHit; // Assign var hit diff --git a/src/V3Unroll.h b/src/V3Unroll.h index 710c292f4..91776df3e 100644 --- a/src/V3Unroll.h +++ b/src/V3Unroll.h @@ -30,7 +30,7 @@ class UnrollVisitor; class UnrollStateful final { // MEMBERS - UnrollVisitor* m_unrollerp; + UnrollVisitor* const m_unrollerp; VL_UNCOPYABLE(UnrollStateful); public: diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 494d3aa28..bffbeb9d8 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -113,7 +113,7 @@ std::ostream& operator<<(std::ostream& str, const Castable& rhs) { class WidthVP final { // Parameters to pass down hierarchy with visit functions. AstNodeDType* const m_dtypep; // Parent's data type to resolve to - Stage m_stage; // If true, report errors + const Stage m_stage; // If true, report errors public: WidthVP(AstNodeDType* dtypep, Stage stage) : m_dtypep{dtypep} @@ -203,14 +203,14 @@ private: // STATE WidthVP* m_vup = nullptr; // Current node state - bool m_paramsOnly; // Computing parameter value; limit operation - AstCell* m_cellp = nullptr; // Current cell for arrayed instantiations - AstNodeFTask* m_ftaskp = nullptr; // Current function/task - AstNodeProcedure* m_procedurep = nullptr; // Current final/always - AstWith* m_withp = nullptr; // Current 'with' statement - AstFunc* m_funcp = nullptr; // Current function - AstAttrOf* m_attrp = nullptr; // Current attribute - bool m_doGenerate; // Do errors later inside generate statement + const AstCell* m_cellp = nullptr; // Current cell for arrayed instantiations + const AstNodeFTask* m_ftaskp = nullptr; // Current function/task + const AstNodeProcedure* m_procedurep = nullptr; // Current final/always + const AstWith* m_withp = nullptr; // Current 'with' statement + const AstFunc* m_funcp = nullptr; // Current function + const AstAttrOf* m_attrp = nullptr; // Current attribute + const bool m_paramsOnly; // Computing parameter value; limit operation + const bool m_doGenerate; // Do errors later inside generate statement int m_dtTables = 0; // Number of created data type tables TableMap m_tableMap; // Created tables so can remove duplicates std::map @@ -700,7 +700,7 @@ private: nodep->v3error("Replication value isn't a constant."); return; } - uint32_t times = constp->toUInt(); + const uint32_t times = constp->toUInt(); if (times == 0 && !VN_IS(nodep->backp(), Concat)) { // Concat Visitor will clean it up. nodep->v3error("Replication value of 0 is only legal under a concatenation (IEEE " @@ -732,7 +732,7 @@ private: nodep->rhsp()->replaceWith(newp); pushDeletep(basicp); } else { - uint32_t sliceSize = constp->toUInt(); + const uint32_t sliceSize = constp->toUInt(); if (!sliceSize) { nodep->v3error("Slice size cannot be zero."); return; @@ -789,7 +789,7 @@ private: iterateCheckSizedSelf(nodep, "Select Width", nodep->widthp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "Select LHS", nodep->lhsp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->widthp()); // widthp may change - AstConst* const widthConstp = VN_CAST(nodep->widthp(), Const); + const AstConst* const widthConstp = VN_CAST(nodep->widthp(), Const); if (!widthConstp) { nodep->v3error("Width of bit extract isn't a constant"); nodep->dtypeSetBit(); @@ -892,12 +892,12 @@ private: // int frommsb; int fromlsb; - AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); + const AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); if (const AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { frommsb = adtypep->hi(); fromlsb = adtypep->lo(); if (fromlsb > frommsb) { - int t = frommsb; + const int t = frommsb; frommsb = fromlsb; fromlsb = t; } @@ -947,8 +947,8 @@ private: virtual void visit(AstAssocSel* nodep) override { // Signed/Real: Output type based on array-declared type; binary operator if (m_vup->prelim()) { - AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); - AstAssocArrayDType* const adtypep = VN_CAST(fromDtp, AssocArrayDType); + const AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); + const AstAssocArrayDType* const adtypep = VN_CAST(fromDtp, AssocArrayDType); if (!adtypep) { UINFO(1, " Related dtype: " << fromDtp << endl); nodep->v3fatalSrc("Associative array reference is not to associative array"); @@ -965,8 +965,8 @@ private: userIterateAndNext(nodep->fromp(), WidthVP(SELF, BOTH).p()); // // Array indices are always constant - AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); - AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType); + const AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefp(); + const AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType); if (!adtypep) { UINFO(1, " Related dtype: " << fromDtp << endl); nodep->v3fatalSrc("Packed array reference exceeds dimension of array"); @@ -1169,11 +1169,11 @@ private: nodep->dtypeSetSigned32(); // Used in int context if (VN_IS(nodep->backp(), IsUnbounded)) return; // Ok, leave if (VN_IS(nodep->backp(), BracketArrayDType)) return; // Ok, leave - if (auto* const varp = VN_CAST(nodep->backp(), Var)) { + if (const auto* const varp = VN_CAST(nodep->backp(), Var)) { if (varp->isParam()) return; // Ok, leave } // queue_slice[#:$] - if (auto* const selp = VN_CAST(nodep->backp(), SelExtract)) { + if (const auto* const selp = VN_CAST(nodep->backp(), SelExtract)) { if (VN_IS(selp->fromp()->dtypep(), QueueDType)) { nodep->replaceWith( new AstConst(nodep->fileline(), AstConst::Signed32(), 0x7FFFFFFF)); @@ -1302,7 +1302,7 @@ private: // LHS is a real number in seconds // Need to round to time units and precision userIterateAndNext(nodep->lhsp(), WidthVP(SELF, BOTH).p()); - AstConst* const constp = VN_CAST(nodep->lhsp(), Const); + const AstConst* const constp = VN_CAST(nodep->lhsp(), Const); if (!constp || !constp->isDouble()) nodep->v3fatalSrc("Times should be doubles"); if (nodep->timeunit().isNone()) nodep->v3fatalSrc("$time import no units"); double time = constp->num().toDouble(); @@ -1335,7 +1335,7 @@ private: case AstAttrType::DIM_DIMENSIONS: case AstAttrType::DIM_UNPK_DIMENSIONS: { UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression"); - std::pair dim = nodep->fromp()->dtypep()->dimensions(true); + const std::pair dim = nodep->fromp()->dtypep()->dimensions(true); const int val = (nodep->attrType() == AstAttrType::DIM_UNPK_DIMENSIONS ? dim.second : (dim.first + dim.second)); @@ -1516,7 +1516,7 @@ private: if (VN_IS(elementsp, Unbounded)) { newp = new AstQueueDType(nodep->fileline(), VFlagChildDType(), childp, nullptr); VL_DO_DANGLING(elementsp->deleteTree(), elementsp); - } else if (AstNodeDType* keyp = VN_CAST(elementsp, NodeDType)) { + } else if (AstNodeDType* const keyp = VN_CAST(elementsp, NodeDType)) { newp = new AstAssocArrayDType(nodep->fileline(), VFlagChildDType(), childp, keyp); } else { // Must be expression that is constant, but we'll determine that later @@ -1672,7 +1672,7 @@ private: // ? ExprStmt(ExprAssign(out, Cast(v, type)), 1) : 0)" auto* const enumDtp = VN_AS(toDtp, EnumDType); UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type"); - uint64_t maxval = enumMaxValue(nodep, enumDtp); + const uint64_t maxval = enumMaxValue(nodep, enumDtp); const int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit AstVar* const varp = enumVarp(enumDtp, AstAttrType::ENUM_VALID, (1ULL << selwidth) - 1); @@ -1774,7 +1774,7 @@ private: // Note we don't sign fromp() that would make the algorithm O(n^2) if lots of casting. AstNode* newp = nullptr; if (bad) { - } else if (AstBasicDType* basicp = toDtp->basicp()) { + } else if (const AstBasicDType* const basicp = toDtp->basicp()) { if (!basicp->isDouble() && !fromDtp->isDouble()) { const int width = toDtp->width(); castSized(nodep, nodep->fromp(), width); @@ -1849,7 +1849,7 @@ private: // if (debug()) nodep->dumpTree(cout, " CastSizeOut: "); } void castSized(AstNode* nodep, AstNode* underp, int width) { - AstBasicDType* underDtp = VN_CAST(underp->dtypep(), BasicDType); + const AstBasicDType* underDtp = VN_CAST(underp->dtypep(), BasicDType); if (!underDtp) underDtp = underp->dtypep()->basicp(); if (!underDtp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: Size-changing cast on non-basic data type"); @@ -1904,7 +1904,7 @@ private: // Make sure dtype is sized nodep->dtypep(iterateEditMoveDTypep(nodep, nodep->subDTypep())); UASSERT_OBJ(nodep->dtypep(), nodep, "No dtype determined for var"); - if (AstUnsizedArrayDType* const unsizedp + if (const AstUnsizedArrayDType* const unsizedp = VN_CAST(nodep->dtypeSkipRefp(), UnsizedArrayDType)) { if (!(m_ftaskp && m_ftaskp->dpiImport())) { UINFO(9, "Unsized becomes dynamic array " << nodep << endl); @@ -1916,7 +1916,7 @@ private: } if (VN_IS(nodep->dtypep()->skipRefToConstp(), ConstDType)) nodep->isConst(true); // Parameters if implicit untyped inherit from what they are assigned to - AstBasicDType* const bdtypep = VN_CAST(nodep->dtypep(), BasicDType); + const AstBasicDType* const bdtypep = VN_CAST(nodep->dtypep(), BasicDType); bool didchk = false; const bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit(); if (implicitParam) { @@ -1932,7 +1932,7 @@ private: VL_DANGLING(bdtypep); } else { int width = 0; - AstBasicDType* const valueBdtypep = nodep->valuep()->dtypep()->basicp(); + const AstBasicDType* const valueBdtypep = nodep->valuep()->dtypep()->basicp(); bool issigned = false; if (bdtypep->isNosign()) { if (valueBdtypep && valueBdtypep->isSigned()) issigned = true; @@ -2043,7 +2043,7 @@ private: userIterateAndNext(nodep->itemsp(), WidthVP(nodep->dtypep(), BOTH).p()); // Assign missing values V3Number num(nodep, nodep->width(), 0); - V3Number one(nodep, nodep->width(), 1); + const V3Number one{nodep, nodep->width(), 1}; std::map inits; for (AstEnumItem* itemp = nodep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), EnumItem)) { @@ -2076,7 +2076,7 @@ private: itemp->valuep(new AstConst(itemp->fileline(), num)); } - AstConst* const constp = VN_AS(itemp->valuep(), Const); + const AstConst* const constp = VN_AS(itemp->valuep(), Const); if (constp->num().isFourState() && nodep->dtypep()->basicp() && !nodep->dtypep()->basicp()->isFourstate()) { itemp->v3error("Enum value with X/Zs cannot be assigned to non-fourstate type " @@ -2085,7 +2085,7 @@ private: num.opAssign(constp->num()); // Look for duplicates if (inits.find(num) != inits.end()) { // IEEE says illegal - AstNode* const otherp = inits.find(num)->second; + const AstNode* const otherp = inits.find(num)->second; itemp->v3error("Overlapping enumeration value: " << itemp->prettyNameQ() << '\n' << itemp->warnContextPrimary() << '\n' @@ -2222,7 +2222,8 @@ private: AstNodeDType* const vdtypep = m_vup->dtypeNullp(); UASSERT_OBJ(vdtypep, nodep, "InitArray type not assigned by AstPattern/Var visitor"); nodep->dtypep(vdtypep); - if (AstNodeArrayDType* const arrayp = VN_CAST(vdtypep->skipRefp(), NodeArrayDType)) { + if (const AstNodeArrayDType* const arrayp + = VN_CAST(vdtypep->skipRefp(), NodeArrayDType)) { userIterateChildren(nodep, WidthVP(arrayp->subDTypep(), BOTH).p()); } else { UINFO(1, "dtype object " << vdtypep->skipRefp() << endl); @@ -2239,12 +2240,12 @@ private: // Take width as maximum across all items int width = nodep->exprp()->width(); int mwidth = nodep->exprp()->widthMin(); - for (AstNode* itemp = nodep->itemsp(); itemp; itemp = itemp->nextp()) { + for (const AstNode* itemp = nodep->itemsp(); itemp; itemp = itemp->nextp()) { width = std::max(width, itemp->width()); mwidth = std::max(mwidth, itemp->widthMin()); } // Apply width - AstNodeDType* subDTypep + AstNodeDType* const subDTypep = nodep->findLogicDType(width, mwidth, nodep->exprp()->dtypep()->numeric()); iterateCheck(nodep, "Inside expression", nodep->exprp(), CONTEXT, FINAL, subDTypep, EXTEND_EXP); @@ -2258,8 +2259,8 @@ private: for (AstNode *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) { nextip = itemp->nextp(); // Will be unlinking AstNode* inewp; - AstNodeDType* itemDtp = itemp->dtypep()->skipRefp(); - if (AstInsideRange* irangep = VN_CAST(itemp, InsideRange)) { + const AstNodeDType* const itemDtp = itemp->dtypep()->skipRefp(); + if (AstInsideRange* const irangep = VN_CAST(itemp, InsideRange)) { // Similar logic in V3Case inewp = irangep->newAndFromInside(nodep->exprp(), irangep->lhsp()->unlinkFrBack(), irangep->rhsp()->unlinkFrBack()); @@ -2373,18 +2374,18 @@ private: if (debug() >= 9) nodep->dumpTree("-mbs-ic: "); // Find the fromp dtype - should be a class if (!nodep->fromp()->dtypep()) nodep->fromp()->v3fatalSrc("Unlinked data type"); - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); UINFO(9, " from dt " << fromDtp << endl); - if (AstNodeUOrStructDType* adtypep = VN_CAST(fromDtp, NodeUOrStructDType)) { + if (AstNodeUOrStructDType* const adtypep = VN_CAST(fromDtp, NodeUOrStructDType)) { if (memberSelStruct(nodep, adtypep)) return; - } else if (AstClassRefDType* adtypep = VN_CAST(fromDtp, ClassRefDType)) { - if (AstNode* foundp = memberSelClass(nodep, adtypep)) { - if (AstVar* varp = VN_CAST(foundp, Var)) { + } else if (AstClassRefDType* const adtypep = VN_CAST(fromDtp, ClassRefDType)) { + if (AstNode* const foundp = memberSelClass(nodep, adtypep)) { + if (AstVar* const varp = VN_CAST(foundp, Var)) { nodep->dtypep(foundp->dtypep()); nodep->varp(varp); return; } - if (AstEnumItemRef* adfoundp = VN_CAST(foundp, EnumItemRef)) { + if (AstEnumItemRef* const adfoundp = VN_CAST(foundp, EnumItemRef)) { nodep->replaceWith(adfoundp->cloneTree(false)); return; } @@ -2402,8 +2403,8 @@ private: || VN_IS(fromDtp, BasicDType)) { // Method call on enum without following parenthesis, e.g. "ENUM.next" // Convert this into a method call, and let that visitor figure out what to do next - AstNode* newp = new AstMethodCall(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - nodep->name(), nullptr); + AstNode* const newp = new AstMethodCall( + nodep->fileline(), nodep->fromp()->unlinkFrBack(), nodep->name(), nullptr); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); userIterate(newp, m_vup); @@ -2420,10 +2421,10 @@ private: AstNode* memberSelClass(AstMemberSel* nodep, AstClassRefDType* adtypep) { // Returns node if ok // No need to width-resolve the class, as it was done when we did the child - AstClass* first_classp = adtypep->classp(); + AstClass* const first_classp = adtypep->classp(); UASSERT_OBJ(first_classp, nodep, "Unlinked"); for (AstClass* classp = first_classp; classp;) { - if (AstNode* foundp = classp->findMember(nodep->name())) return foundp; + if (AstNode* const foundp = classp->findMember(nodep->name())) return foundp; classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr; } VSpellCheck speller; @@ -2444,14 +2445,14 @@ private: } bool memberSelStruct(AstMemberSel* nodep, AstNodeUOrStructDType* adtypep) { // Returns true if ok - if (AstMemberDType* memberp = adtypep->findMember(nodep->name())) { + if (AstMemberDType* const memberp = adtypep->findMember(nodep->name())) { if (m_attrp) { // Looking for the base of the attribute nodep->dtypep(memberp); UINFO(9, " MEMBERSEL(attr) -> " << nodep << endl); UINFO(9, " dt-> " << nodep->dtypep() << endl); } else { - AstSel* newp = new AstSel(nodep->fileline(), nodep->fromp()->unlinkFrBack(), - memberp->lsb(), memberp->width()); + AstSel* const newp = new AstSel(nodep->fileline(), nodep->fromp()->unlinkFrBack(), + memberp->lsb(), memberp->width()); // Must skip over the member to find the union; as the member may disappear later newp->dtypep(memberp->subDTypep()->skipRefToEnump()); newp->didWidth(true); // Don't replace dtype with basic type @@ -2485,21 +2486,21 @@ private: } // Find the fromp dtype - should be a class UASSERT_OBJ(nodep->fromp() && nodep->fromp()->dtypep(), nodep, "Unsized expression"); - AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); - AstBasicDType* basicp = fromDtp ? fromDtp->basicp() : nullptr; + AstNodeDType* const fromDtp = nodep->fromp()->dtypep()->skipRefToEnump(); + AstBasicDType* const basicp = fromDtp ? fromDtp->basicp() : nullptr; UINFO(9, " from dt " << fromDtp << endl); userIterate(fromDtp, WidthVP(SELF, BOTH).p()); - if (AstEnumDType* adtypep = VN_CAST(fromDtp, EnumDType)) { + if (AstEnumDType* const adtypep = VN_CAST(fromDtp, EnumDType)) { methodCallEnum(nodep, adtypep); - } else if (AstAssocArrayDType* adtypep = VN_CAST(fromDtp, AssocArrayDType)) { + } else if (AstAssocArrayDType* const adtypep = VN_CAST(fromDtp, AssocArrayDType)) { methodCallAssoc(nodep, adtypep); - } else if (AstDynArrayDType* adtypep = VN_CAST(fromDtp, DynArrayDType)) { + } else if (AstDynArrayDType* const adtypep = VN_CAST(fromDtp, DynArrayDType)) { methodCallDyn(nodep, adtypep); - } else if (AstQueueDType* adtypep = VN_CAST(fromDtp, QueueDType)) { + } else if (AstQueueDType* const adtypep = VN_CAST(fromDtp, QueueDType)) { methodCallQueue(nodep, adtypep); - } else if (AstClassRefDType* adtypep = VN_CAST(fromDtp, ClassRefDType)) { + } else if (AstClassRefDType* const adtypep = VN_CAST(fromDtp, ClassRefDType)) { methodCallClass(nodep, adtypep); - } else if (AstUnpackArrayDType* adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { + } else if (AstUnpackArrayDType* const adtypep = VN_CAST(fromDtp, UnpackArrayDType)) { methodCallUnpack(nodep, adtypep); } else if (basicp && basicp->isEventValue()) { methodCallEvent(nodep, basicp); @@ -2516,7 +2517,7 @@ private: AstNodeDType* returnDtp, AstNodeDType* indexDtp, AstNodeDType* valueDtp) { UASSERT_OBJ(arbReturn || returnDtp, nodep, "Null return type"); - if (AstWith* withp = VN_CAST(nodep->pinsp(), With)) { + if (AstWith* const withp = VN_CAST(nodep->pinsp(), With)) { withp->indexArgRefp()->dtypep(indexDtp); withp->valueArgRefp()->dtypep(valueDtp); userIterate(withp, WidthVP(returnDtp, BOTH).p()); @@ -2575,7 +2576,7 @@ private: for (AstNode* itemp = adtypep->itemsp(); itemp; itemp = itemp->nextp()) ++items; newp = new AstConst(nodep->fileline(), AstConst::Signed32(), items); } else if (nodep->name() == "first") { - AstEnumItem* itemp = adtypep->itemsp(); + const AstEnumItem* itemp = adtypep->itemsp(); if (!itemp) { newp = new AstConst(nodep->fileline(), AstConst::Signed32(), 0); // Spec doesn't say what to do @@ -2583,7 +2584,7 @@ private: newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const } } else if (nodep->name() == "last") { - AstEnumItem* itemp = adtypep->itemsp(); + const AstEnumItem* itemp = adtypep->itemsp(); while (itemp && itemp->nextp()) itemp = VN_AS(itemp->nextp(), EnumItem); if (!itemp) { newp = new AstConst(nodep->fileline(), AstConst::Signed32(), @@ -2618,24 +2619,25 @@ private: && VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt() == 1 && !nodep->pinsp()->nextp())) { // Unroll of enumVar.next(k) to enumVar.next(1).next(k - 1) - AstMethodCall* clonep = nodep->cloneTree(false); + AstMethodCall* const clonep = nodep->cloneTree(false); VN_AS(VN_AS(clonep->pinsp(), Arg)->exprp(), Const)->num().setLong(1); - uint32_t stepWidth = VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt(); - AstConst* constp = new AstConst(nodep->fileline(), stepWidth - 1); - AstArg* argp = new AstArg(nodep->fileline(), "", constp); - AstMethodCall* newp + const uint32_t stepWidth + = VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt(); + AstConst* const constp = new AstConst(nodep->fileline(), stepWidth - 1); + AstArg* const argp = new AstArg(nodep->fileline(), "", constp); + AstMethodCall* const newp = new AstMethodCall(nodep->fileline(), clonep, nodep->name(), argp); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); return; } // Need a runtime lookup table. Yuk. - uint64_t msbdim = enumMaxValue(nodep, adtypep); + const uint64_t msbdim = enumMaxValue(nodep, adtypep); const int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit - AstVar* varp = enumVarp(adtypep, attrType, (1ULL << selwidth) - 1); - AstVarRef* varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); + AstVar* const varp = enumVarp(adtypep, attrType, (1ULL << selwidth) - 1); + AstVarRef* const varrefp = new AstVarRef(nodep->fileline(), varp, VAccess::READ); varrefp->classOrPackagep(v3Global.rootp()->dollarUnitPkgAddp()); - AstNode* newp = new AstArraySel( + AstNode* const newp = new AstArraySel( nodep->fileline(), varrefp, // Select in case widths are off due to msblen!=width // We return "random" values if outside the range, which is fine @@ -2660,7 +2662,7 @@ private: || nodep->name() == "next" // || nodep->name() == "prev") { methodOkArguments(nodep, 1, 1); - AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep); + AstNode* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), nodep->name(), // first/last/next/prev index_exprp->unlinkFrBack()); @@ -2668,7 +2670,7 @@ private: } else if (nodep->name() == "exists") { // function int exists(input index) // IEEE really should have made this a "bit" return methodOkArguments(nodep, 1, 1); - AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep); + AstNode* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "exists", index_exprp->unlinkFrBack()); newp->dtypeSetSigned32(); @@ -2681,7 +2683,7 @@ private: "clear", nullptr); newp->makeStatement(); } else { - AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep); + AstNode* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "erase", index_exprp->unlinkFrBack()); newp->makeStatement(); @@ -2693,8 +2695,8 @@ private: } else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor" || nodep->name() == "sum" || nodep->name() == "product") { // All value return - AstWith* withp = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - adtypep->keyDTypep(), adtypep->subDTypep()); + AstWith* const withp = methodWithArgument(nodep, false, false, adtypep->subDTypep(), + adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2715,8 +2717,8 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - adtypep->keyDTypep(), adtypep->subDTypep()); + AstWith* const withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), + adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2725,8 +2727,8 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - adtypep->keyDTypep(), adtypep->subDTypep()); + AstWith* const withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), + adtypep->keyDTypep(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2745,18 +2747,18 @@ private: } } AstNode* methodCallAssocIndexExpr(AstMethodCall* nodep, AstAssocArrayDType* adtypep) { - AstNode* index_exprp = VN_CAST(nodep->pinsp(), Arg)->exprp(); + AstNode* const index_exprp = VN_CAST(nodep->pinsp(), Arg)->exprp(); iterateCheck(nodep, "index", index_exprp, CONTEXT, FINAL, adtypep->keyDTypep(), EXTEND_EXP); VL_DANGLING(index_exprp); // May have been edited return VN_AS(nodep->pinsp(), Arg)->exprp(); } void methodCallLValueRecurse(AstMethodCall* nodep, AstNode* childp, const VAccess& access) { - if (AstNodeVarRef* varrefp = VN_CAST(childp, NodeVarRef)) { + if (AstNodeVarRef* const varrefp = VN_CAST(childp, NodeVarRef)) { varrefp->access(access); - } else if (AstMemberSel* ichildp = VN_CAST(childp, MemberSel)) { + } else if (const AstMemberSel* const ichildp = VN_CAST(childp, MemberSel)) { methodCallLValueRecurse(nodep, ichildp->fromp(), access); - } else if (AstNodeSel* ichildp = VN_CAST(childp, NodeSel)) { + } else if (const AstNodeSel* const ichildp = VN_CAST(childp, NodeSel)) { methodCallLValueRecurse(nodep, ichildp->fromp(), access); } else { UINFO(1, " Related node: " << childp << endl); @@ -2786,8 +2788,9 @@ private: } else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor" || nodep->name() == "sum" || nodep->name() == "product") { // All value return - AstWith* withp = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - nodep->findUInt32DType(), adtypep->subDTypep()); + AstWith* const withp + = methodWithArgument(nodep, false, false, adtypep->subDTypep(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2820,8 +2823,9 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last" || nodep->name() == "find_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - nodep->findUInt32DType(), adtypep->subDTypep()); + AstWith* const withp + = methodWithArgument(nodep, true, false, nodep->findBitDType(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2830,8 +2834,9 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - nodep->findUInt32DType(), adtypep->subDTypep()); + AstWith* const withp + = methodWithArgument(nodep, true, false, nodep->findBitDType(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2872,7 +2877,7 @@ private: "clear", nullptr); newp->makeStatement(); } else { - AstNode* index_exprp = methodCallQueueIndexExpr(nodep); + AstNode* const index_exprp = methodCallQueueIndexExpr(nodep); if (index_exprp->isZero()) { // delete(0) is a pop_front newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), "pop_front", nullptr); @@ -2887,8 +2892,8 @@ private: } else if (nodep->name() == "insert") { methodOkArguments(nodep, 2, 2); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); - AstNode* index_exprp = methodCallQueueIndexExpr(nodep); - AstArg* argp = VN_AS(nodep->pinsp()->nextp(), Arg); + AstNode* const index_exprp = methodCallQueueIndexExpr(nodep); + AstArg* const argp = VN_AS(nodep->pinsp()->nextp(), Arg); iterateCheckTyped(nodep, "insert value", argp->exprp(), adtypep->subDTypep(), BOTH); if (index_exprp->isZero()) { // insert(0, ...) is a push_front newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2911,15 +2916,16 @@ private: } else if (nodep->name() == "push_back" || nodep->name() == "push_front") { methodOkArguments(nodep, 1, 1); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE); - AstArg* argp = VN_AS(nodep->pinsp(), Arg); + AstArg* const argp = VN_AS(nodep->pinsp(), Arg); iterateCheckTyped(nodep, "push value", argp->exprp(), adtypep->subDTypep(), BOTH); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), nodep->name(), argp->exprp()->unlinkFrBack()); newp->makeStatement(); } else if (nodep->name() == "and" || nodep->name() == "or" || nodep->name() == "xor" || nodep->name() == "sum" || nodep->name() == "product") { - AstWith* withp = methodWithArgument(nodep, false, false, adtypep->subDTypep(), - nodep->findUInt32DType(), adtypep->subDTypep()); + AstWith* const withp + = methodWithArgument(nodep, false, false, adtypep->subDTypep(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2952,8 +2958,9 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find" || nodep->name() == "find_first" || nodep->name() == "find_last") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - nodep->findUInt32DType(), adtypep->subDTypep()); + AstWith* const withp + = methodWithArgument(nodep, true, false, nodep->findBitDType(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2962,8 +2969,9 @@ private: if (!nodep->firstAbovep()) newp->makeStatement(); } else if (nodep->name() == "find_index" || nodep->name() == "find_first_index" || nodep->name() == "find_last_index") { - AstWith* withp = methodWithArgument(nodep, true, false, nodep->findBitDType(), - nodep->findUInt32DType(), adtypep->subDTypep()); + AstWith* const withp + = methodWithArgument(nodep, true, false, nodep->findBitDType(), + nodep->findUInt32DType(), adtypep->subDTypep()); methodOkArguments(nodep, 0, 0); methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ); newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(), @@ -2983,21 +2991,22 @@ private: } } AstNode* methodCallQueueIndexExpr(AstMethodCall* nodep) { - AstNode* index_exprp = VN_AS(nodep->pinsp(), Arg)->exprp(); + AstNode* const index_exprp = VN_AS(nodep->pinsp(), Arg)->exprp(); iterateCheckSigned32(nodep, "index", index_exprp, BOTH); VL_DANGLING(index_exprp); // May have been edited return VN_AS(nodep->pinsp(), Arg)->exprp(); } void methodCallClass(AstMethodCall* nodep, AstClassRefDType* adtypep) { // No need to width-resolve the class, as it was done when we did the child - AstClass* first_classp = adtypep->classp(); + AstClass* const first_classp = adtypep->classp(); if (nodep->name() == "randomize") { v3Global.useRandomizeMethods(true); V3Randomize::newRandomizeFunc(first_classp); } UASSERT_OBJ(first_classp, nodep, "Unlinked"); for (AstClass* classp = first_classp; classp;) { - if (AstNodeFTask* ftaskp = VN_CAST(classp->findMember(nodep->name()), NodeFTask)) { + if (AstNodeFTask* const ftaskp + = VN_CAST(classp->findMember(nodep->name()), NodeFTask)) { userIterate(ftaskp, nullptr); if (ftaskp->lifetime().isStatic()) { AstNode* argsp = nullptr; @@ -3063,11 +3072,11 @@ private: if (methodId) { methodOkArguments(nodep, 0, 0); - FileLine* fl = nodep->fileline(); + FileLine* const fl = nodep->fileline(); AstNode* newp = nullptr; for (int i = 0; i < adtypep->elementsConst(); ++i) { - AstNode* arrayRef = nodep->fromp()->cloneTree(false); - AstNode* selector = new AstArraySel(fl, arrayRef, i); + AstNode* const arrayRef = nodep->fromp()->cloneTree(false); + AstNode* const selector = new AstArraySel(fl, arrayRef, i); if (!newp) { newp = selector; } else { @@ -3093,7 +3102,7 @@ private: if (nodep->name() == "triggered") { // We represent events as numbers, so can just return number methodOkArguments(nodep, 0, 0); - AstNode* newp = nodep->fromp()->unlinkFrBack(); + AstNode* const newp = nodep->fromp()->unlinkFrBack(); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else { @@ -3105,7 +3114,7 @@ private: if (nodep->name() == "len") { // Constant value methodOkArguments(nodep, 0, 0); - AstNode* newp = new AstLenN(nodep->fileline(), nodep->fromp()->unlinkFrBack()); + AstNode* const newp = new AstLenN(nodep->fileline(), nodep->fromp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (nodep->name() == "itoa") { @@ -3125,52 +3134,55 @@ private: VL_DO_DANGLING(replaceWithSFormat(nodep, "%g"), nodep); } else if (nodep->name() == "tolower") { methodOkArguments(nodep, 0, 0); - AstNode* newp = new AstToLowerN(nodep->fileline(), nodep->fromp()->unlinkFrBack()); + AstNode* const newp + = new AstToLowerN(nodep->fileline(), nodep->fromp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "toupper") { methodOkArguments(nodep, 0, 0); - AstNode* newp = new AstToUpperN(nodep->fileline(), nodep->fromp()->unlinkFrBack()); + AstNode* const newp + = new AstToUpperN(nodep->fileline(), nodep->fromp()->unlinkFrBack()); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "compare" || nodep->name() == "icompare") { const bool ignoreCase = nodep->name()[0] == 'i'; methodOkArguments(nodep, 1, 1); - AstArg* argp = VN_AS(nodep->pinsp(), Arg); - AstNode* lhs = nodep->fromp()->unlinkFrBack(); - AstNode* rhs = argp->exprp()->unlinkFrBack(); - AstNode* newp = new AstCompareNN(nodep->fileline(), lhs, rhs, ignoreCase); + AstArg* const argp = VN_AS(nodep->pinsp(), Arg); + AstNode* const lhs = nodep->fromp()->unlinkFrBack(); + AstNode* const rhs = argp->exprp()->unlinkFrBack(); + AstNode* const newp = new AstCompareNN(nodep->fileline(), lhs, rhs, ignoreCase); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "putc") { methodOkArguments(nodep, 2, 2); - AstArg* arg0p = VN_AS(nodep->pinsp(), Arg); - AstArg* arg1p = VN_AS(arg0p->nextp(), Arg); - AstNodeVarRef* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef); - AstNode* rhsp = arg0p->exprp()->unlinkFrBack(); - AstNode* thsp = arg1p->exprp()->unlinkFrBack(); - AstVarRef* varrefp = new AstVarRef(nodep->fileline(), fromp->varp(), VAccess::READ); - AstNode* newp = new AstAssign(nodep->fileline(), fromp, - new AstPutcN(nodep->fileline(), varrefp, rhsp, thsp)); + AstArg* const arg0p = VN_AS(nodep->pinsp(), Arg); + AstArg* const arg1p = VN_AS(arg0p->nextp(), Arg); + AstNodeVarRef* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef); + AstNode* const rhsp = arg0p->exprp()->unlinkFrBack(); + AstNode* const thsp = arg1p->exprp()->unlinkFrBack(); + AstVarRef* const varrefp + = new AstVarRef(nodep->fileline(), fromp->varp(), VAccess::READ); + AstNode* const newp = new AstAssign( + nodep->fileline(), fromp, new AstPutcN(nodep->fileline(), varrefp, rhsp, thsp)); fromp->access(VAccess::WRITE); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "getc") { methodOkArguments(nodep, 1, 1); - AstArg* arg0p = VN_AS(nodep->pinsp(), Arg); - AstNode* lhsp = nodep->fromp()->unlinkFrBack(); - AstNode* rhsp = arg0p->exprp()->unlinkFrBack(); - AstNode* newp = new AstGetcN(nodep->fileline(), lhsp, rhsp); + AstArg* const arg0p = VN_AS(nodep->pinsp(), Arg); + AstNode* const lhsp = nodep->fromp()->unlinkFrBack(); + AstNode* const rhsp = arg0p->exprp()->unlinkFrBack(); + AstNode* const newp = new AstGetcN(nodep->fileline(), lhsp, rhsp); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "substr") { methodOkArguments(nodep, 2, 2); - AstArg* arg0p = VN_AS(nodep->pinsp(), Arg); - AstArg* arg1p = VN_AS(arg0p->nextp(), Arg); - AstNode* lhsp = nodep->fromp()->unlinkFrBack(); - AstNode* rhsp = arg0p->exprp()->unlinkFrBack(); - AstNode* thsp = arg1p->exprp()->unlinkFrBack(); - AstNode* newp = new AstSubstrN(nodep->fileline(), lhsp, rhsp, thsp); + AstArg* const arg0p = VN_AS(nodep->pinsp(), Arg); + AstArg* const arg1p = VN_AS(arg0p->nextp(), Arg); + AstNode* const lhsp = nodep->fromp()->unlinkFrBack(); + AstNode* const rhsp = arg0p->exprp()->unlinkFrBack(); + AstNode* const thsp = arg1p->exprp()->unlinkFrBack(); + AstNode* const newp = new AstSubstrN(nodep->fileline(), lhsp, rhsp, thsp); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else if (nodep->name() == "atobin" || nodep->name() == "atohex" @@ -3192,7 +3204,8 @@ private: fmt = AstAtoN::ATOI; } // dummy assignment to suppress compiler warning methodOkArguments(nodep, 0, 0); - AstNode* newp = new AstAtoN(nodep->fileline(), nodep->fromp()->unlinkFrBack(), fmt); + AstNode* const newp + = new AstAtoN(nodep->fileline(), nodep->fromp()->unlinkFrBack(), fmt); nodep->replaceWith(newp); VL_DO_DANGLING(nodep->deleteTree(), nodep); } else { @@ -3202,10 +3215,10 @@ private: AstQueueDType* queueDTypeIndexedBy(AstNodeDType* indexDTypep) { // Return a Queue data type with the specified index, remembering so can use again if // needed - if (AstQueueDType* queuep = m_queueDTypeIndexed[indexDTypep]) { + if (AstQueueDType* const queuep = m_queueDTypeIndexed[indexDTypep]) { return queuep; } else { - auto* newp = new AstQueueDType(indexDTypep->fileline(), indexDTypep, nullptr); + auto* const newp = new AstQueueDType(indexDTypep->fileline(), indexDTypep, nullptr); v3Global.rootp()->typeTablep()->addTypesp(newp); m_queueDTypeIndexed[indexDTypep] = newp; return newp; @@ -3214,7 +3227,7 @@ private: virtual void visit(AstNew* nodep) override { if (nodep->didWidth()) return; - AstClassRefDType* refp + AstClassRefDType* const refp = m_vup ? VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType) : nullptr; if (!refp) { // e.g. int a = new; nodep->v3error("new() not expected in this context"); @@ -3222,9 +3235,9 @@ private: } nodep->dtypep(refp); - AstClass* classp = refp->classp(); + AstClass* const classp = refp->classp(); UASSERT_OBJ(classp, nodep, "Unlinked"); - if (AstNodeFTask* ftaskp = VN_CAST(classp->findMember("new"), Func)) { + if (AstNodeFTask* const ftaskp = VN_CAST(classp->findMember("new"), Func)) { nodep->taskp(ftaskp); nodep->classOrPackagep(classp); } else { @@ -3240,7 +3253,7 @@ private: } virtual void visit(AstNewCopy* nodep) override { if (nodep->didWidthAndSet()) return; - AstClassRefDType* refp = VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType); + AstClassRefDType* const refp = VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType); if (!refp) { // e.g. int a = new; nodep->v3error("new() not expected in this context"); return; @@ -3255,7 +3268,7 @@ private: } virtual void visit(AstNewDynamic* nodep) override { if (nodep->didWidthAndSet()) return; - AstDynArrayDType* adtypep = VN_CAST(m_vup->dtypeNullSkipRefp(), DynArrayDType); + AstDynArrayDType* const adtypep = VN_CAST(m_vup->dtypeNullSkipRefp(), DynArrayDType); if (!adtypep) { // e.g. int a = new; nodep->v3error( "dynamic new() not expected in this context (data type must be dynamic array)"); @@ -3304,7 +3317,7 @@ private: patp = VN_AS(patp->nextp(), PatMember)) { const int times = visitPatMemberRep(patp); for (int i = 1; i < times; i++) { - AstNode* newp = patp->cloneTree(false); + AstNode* const newp = patp->cloneTree(false); patp->addNextHere(newp); // This loop will see the new elements as part of nextp() } @@ -3317,11 +3330,11 @@ private: // So detach, add next and reattach AstNRelinker relinkHandle; patp->unlinkFrBack(&relinkHandle); - while (AstNode* movep = patp->lhssp()->nextp()) { + while (AstNode* const movep = patp->lhssp()->nextp()) { movep->unlinkFrBack(); // Not unlinkFrBackWithNext, just one AstNode* newkeyp = nullptr; if (patp->keyp()) newkeyp = patp->keyp()->cloneTree(true); - AstPatMember* newp + AstPatMember* const newp = new AstPatMember(patp->fileline(), movep, newkeyp, nullptr); patp->addNext(newp); } @@ -3337,21 +3350,21 @@ private: patp->unlinkFrBack(); } } - while (const AstConstDType* vdtypep = VN_CAST(dtypep, ConstDType)) { + while (const AstConstDType* const vdtypep = VN_CAST(dtypep, ConstDType)) { dtypep = vdtypep->subDTypep()->skipRefp(); } userIterate(dtypep, WidthVP(SELF, BOTH).p()); - if (auto* vdtypep = VN_CAST(dtypep, NodeUOrStructDType)) { + if (auto* const vdtypep = VN_CAST(dtypep, NodeUOrStructDType)) { VL_DO_DANGLING(patternUOrStruct(nodep, vdtypep, defaultp), nodep); - } else if (auto* vdtypep = VN_CAST(dtypep, NodeArrayDType)) { + } else if (auto* const vdtypep = VN_CAST(dtypep, NodeArrayDType)) { VL_DO_DANGLING(patternArray(nodep, vdtypep, defaultp), nodep); - } else if (auto* vdtypep = VN_CAST(dtypep, AssocArrayDType)) { + } else if (auto* const vdtypep = VN_CAST(dtypep, AssocArrayDType)) { VL_DO_DANGLING(patternAssoc(nodep, vdtypep, defaultp), nodep); - } else if (auto* vdtypep = VN_CAST(dtypep, DynArrayDType)) { + } else if (auto* const vdtypep = VN_CAST(dtypep, DynArrayDType)) { VL_DO_DANGLING(patternDynArray(nodep, vdtypep, defaultp), nodep); - } else if (auto* vdtypep = VN_CAST(dtypep, QueueDType)) { + } else if (auto* const vdtypep = VN_CAST(dtypep, QueueDType)) { VL_DO_DANGLING(patternQueue(nodep, vdtypep, defaultp), nodep); } else if (VN_IS(dtypep, BasicDType) && VN_AS(dtypep, BasicDType)->isRanged()) { VL_DO_DANGLING(patternBasic(nodep, dtypep, defaultp), nodep); @@ -3372,13 +3385,13 @@ private: using PatMap = std::map; PatMap patmap; { - AstMemberDType* memp = vdtypep->membersp(); + const AstMemberDType* memp = vdtypep->membersp(); AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); for (; memp || patp;) { do { if (patp) { if (patp->keyp()) { - if (AstText* textp = VN_CAST(patp->keyp(), Text)) { + if (const AstText* textp = VN_CAST(patp->keyp(), Text)) { memp = vdtypep->findMember(textp->text()); if (!memp) { patp->keyp()->v3error("Assignment pattern key '" @@ -3404,7 +3417,7 @@ private: patp = nullptr; break; } else { - std::pair ret = patmap.emplace(memp, patp); + const std::pair ret = patmap.emplace(memp, patp); if (!ret.second) { patp->v3error("Assignment pattern contains duplicate entry: " << VN_AS(patp->keyp(), Text)->text()); @@ -3438,11 +3451,11 @@ private: if (patp) { // Determine initial values patp->dtypep(memp); - AstNode* valuep = patternMemberValueIterate(patp); + AstNode* const valuep = patternMemberValueIterate(patp); if (!newp) { newp = valuep; } else { - AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); + AstConcat* const concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; newp->dtypeSetLogicSized(concatp->lhsp()->width() + concatp->rhsp()->width(), nodep->dtypep()->numeric()); @@ -3482,10 +3495,10 @@ private: if (patp) { // Don't want the RHS an array patp->dtypep(arrayDtp->subDTypep()); - AstNode* valuep = patternMemberValueIterate(patp); + AstNode* const valuep = patternMemberValueIterate(patp); if (VN_IS(arrayDtp, UnpackArrayDType)) { if (!newp) { - AstInitArray* newap + AstInitArray* const newap = new AstInitArray(nodep->fileline(), arrayDtp, nullptr); newp = newap; } @@ -3494,7 +3507,7 @@ private: if (!newp) { newp = valuep; } else { - AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); + AstConcat* const concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; newp->dtypeSetLogicSized(concatp->lhsp()->width() + concatp->rhsp()->width(), @@ -3521,9 +3534,10 @@ private: for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; patp = VN_AS(patp->nextp(), PatMember)) { patp->dtypep(arrayDtp->subDTypep()); - AstNode* valuep = patternMemberValueIterate(patp); - AstNode* keyp = patp->keyp(); - auto* newap = new AstSetAssoc(nodep->fileline(), newp, keyp->unlinkFrBack(), valuep); + AstNode* const valuep = patternMemberValueIterate(patp); + AstNode* const keyp = patp->keyp(); + auto* const newap + = new AstSetAssoc(nodep->fileline(), newp, keyp->unlinkFrBack(), valuep); newap->dtypeFrom(arrayDtp); newp = newap; } @@ -3537,8 +3551,8 @@ private: for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; patp = VN_AS(patp->nextp(), PatMember)) { patp->dtypep(arrayp->subDTypep()); - AstNode* valuep = patternMemberValueIterate(patp); - auto* newap = new AstConsDynArray(nodep->fileline(), valuep, newp); + AstNode* const valuep = patternMemberValueIterate(patp); + auto* const newap = new AstConsDynArray(nodep->fileline(), valuep, newp); newap->dtypeFrom(arrayp); newp = newap; } @@ -3552,8 +3566,8 @@ private: for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; patp = VN_AS(patp->nextp(), PatMember)) { patp->dtypep(arrayp->subDTypep()); - AstNode* valuep = patternMemberValueIterate(patp); - auto* newap = new AstConsQueue(nodep->fileline(), valuep, newp); + AstNode* const valuep = patternMemberValueIterate(patp); + auto* const newap = new AstConsQueue(nodep->fileline(), valuep, newp); newap->dtypeFrom(arrayp); newp = newap; } @@ -3562,7 +3576,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); // Deletes defaultp also, if present } void patternBasic(AstPattern* nodep, AstNodeDType* vdtypep, AstPatMember* defaultp) { - AstBasicDType* bdtypep = VN_AS(vdtypep, BasicDType); + const AstBasicDType* bdtypep = VN_AS(vdtypep, BasicDType); const VNumRange range = bdtypep->declRange(); PatVecMap patmap = patVectorMap(nodep, range); UINFO(9, "ent " << range.hi() << " to " << range.lo() << endl); @@ -3586,12 +3600,12 @@ private: // Determine initial values vdtypep = nodep->findBitDType(); patp->dtypep(vdtypep); - AstNode* valuep = patternMemberValueIterate(patp); + AstNode* const valuep = patternMemberValueIterate(patp); { // Packed. Convert to concat for now. if (!newp) { newp = valuep; } else { - AstConcat* concatp = new AstConcat(patp->fileline(), newp, valuep); + AstConcat* const concatp = new AstConcat(patp->fileline(), newp, valuep); newp = concatp; newp->dtypeSetLogicSized(concatp->lhsp()->width() + concatp->rhsp()->width(), @@ -3618,7 +3632,8 @@ private: if (VN_IS(valuep, Const)) { // Forming a AstConcat will cause problems with // unsized (uncommitted sized) constants - if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(VN_AS(valuep, Const))) { + if (AstNode* const newp + = WidthCommitVisitor::newIfConstCommitSize(VN_AS(valuep, Const))) { VL_DO_DANGLING(pushDeletep(valuep), valuep); valuep = newp; } @@ -3627,7 +3642,7 @@ private: } virtual void visit(AstPatMember* nodep) override { - AstNodeDType* vdtypep = m_vup->dtypeNullp(); + AstNodeDType* const vdtypep = m_vup->dtypeNullp(); UASSERT_OBJ(vdtypep, nodep, "Pattern member type not assigned by AstPattern visitor"); nodep->dtypep(vdtypep); UINFO(9, " PATMEMBER " << nodep << endl); @@ -3642,7 +3657,7 @@ private: if (nodep->repp()) { // else repp()==nullptr shorthand for rep count 1 iterateCheckSizedSelf(nodep, "LHS", nodep->repp(), SELF, BOTH); V3Const::constifyParamsEdit(nodep->repp()); // repp may change - const AstConst* constp = VN_CAST(nodep->repp(), Const); + const AstConst* const constp = VN_CAST(nodep->repp(), Const); if (!constp) { nodep->v3error("Replication value isn't a constant."); times = 0; @@ -3778,12 +3793,12 @@ private: userIterateAndNext(nodep->rhsp(), WidthVP(nodep->dtypep(), PRELIM).p()); // // if (debug()) nodep->dumpTree(cout, "- assign: "); - AstNodeDType* lhsDTypep + AstNodeDType* const lhsDTypep = nodep->lhsp()->dtypep(); // Note we use rhsp for context determined iterateCheckAssign(nodep, "Assign RHS", nodep->rhsp(), FINAL, lhsDTypep); // if (debug()) nodep->dumpTree(cout, " AssignOut: "); } - if (AstBasicDType* basicp = nodep->rhsp()->dtypep()->basicp()) { + if (const AstBasicDType* const basicp = nodep->rhsp()->dtypep()->basicp()) { if (basicp->isEventValue()) { // see t_event_copy.v for commentary on the mess involved nodep->v3warn(E_UNSUPPORTED, "Unsupported: assignment of event data type"); @@ -3806,7 +3821,7 @@ private: visit(newp); return; } - if (AstNewDynamic* dynp = VN_CAST(nodep->rhsp(), NewDynamic)) { + if (const AstNewDynamic* const dynp = VN_CAST(nodep->rhsp(), NewDynamic)) { UINFO(9, "= new[] -> .resize(): " << nodep); AstCMethodHard* newp; if (!dynp->rhsp()) { @@ -3853,7 +3868,7 @@ private: case 'l': break; // %m - auto insert "library" case 'd': { // Convert decimal to either 'd' or '#' if (argp) { - AstNode* nextp = argp->nextp(); + AstNode* const nextp = argp->nextp(); if (argp->isDouble()) { spliceCvtS(argp, true, 64); ch = '~'; @@ -3865,8 +3880,8 @@ private: break; } case 'p': { // Pattern - AstNodeDType* dtypep = argp ? argp->dtypep()->skipRefp() : nullptr; - AstBasicDType* basicp = dtypep ? dtypep->basicp() : nullptr; + const AstNodeDType* const dtypep = argp ? argp->dtypep()->skipRefp() : nullptr; + const AstBasicDType* const basicp = dtypep ? dtypep->basicp() : nullptr; if (basicp && basicp->isString()) { added = true; newFormat += "\"%@\""; @@ -3881,7 +3896,8 @@ private: newFormat += "%@"; AstNRelinker handle; argp->unlinkFrBack(&handle); - AstCMath* newp = new AstCMath(nodep->fileline(), "VL_TO_STRING(", 0, true); + AstCMath* const newp + = new AstCMath(nodep->fileline(), "VL_TO_STRING(", 0, true); newp->addBodysp(argp); newp->addBodysp(new AstText(nodep->fileline(), ")", true)); newp->dtypeSetString(); @@ -3908,7 +3924,7 @@ private: } case 't': { // Convert decimal time to realtime if (argp) { - AstNode* nextp = argp->nextp(); + AstNode* const nextp = argp->nextp(); if (argp->isDouble()) ch = '^'; // Convert it if (nodep->timeunit().isNone()) { nodep->v3fatalSrc("display %t has no time units"); @@ -3920,7 +3936,7 @@ private: case 'f': // FALLTHRU case 'g': { if (argp) { - AstNode* nextp = argp->nextp(); + AstNode* const nextp = argp->nextp(); if (!argp->isDouble()) { iterateCheckReal(nodep, "Display argument", argp, BOTH); } @@ -4102,8 +4118,8 @@ private: assertAtStatement(nodep); userIterateAndNext(nodep->filenamep(), WidthVP(SELF, BOTH).p()); userIterateAndNext(nodep->memp(), WidthVP(SELF, BOTH).p()); - AstNodeDType* subp = nullptr; - if (AstAssocArrayDType* adtypep + const AstNodeDType* subp = nullptr; + if (const AstAssocArrayDType* adtypep = VN_CAST(nodep->memp()->dtypep()->skipRefp(), AssocArrayDType)) { subp = adtypep->subDTypep(); if (!adtypep->keyDTypep()->skipRefp()->basicp() @@ -4111,7 +4127,7 @@ private: nodep->memp()->v3error(nodep->verilogKwd() << " address/key must be integral (IEEE 1800-2017 21.4.1)"); } - } else if (AstUnpackArrayDType* adtypep + } else if (const AstUnpackArrayDType* const adtypep = VN_CAST(nodep->memp()->dtypep()->skipRefp(), UnpackArrayDType)) { subp = adtypep->subDTypep(); } else { @@ -4175,8 +4191,8 @@ private: // TOP LEVEL NODE if (nodep->modVarp() && nodep->modVarp()->isGParam()) { // Widthing handled as special init() case - if (auto* patternp = VN_CAST(nodep->exprp(), Pattern)) - if (auto* modVarp = nodep->modVarp()) + if (auto* const patternp = VN_CAST(nodep->exprp(), Pattern)) + if (const auto* modVarp = nodep->modVarp()) patternp->childDTypep(modVarp->childDTypep()->cloneTree(false)); userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); } else if (!m_paramsOnly) { @@ -4264,8 +4280,8 @@ private: } // TODO Simple dtype checking, should be a more general check - AstNodeArrayDType* exprArrayp = VN_CAST(conDTypep, UnpackArrayDType); - AstNodeArrayDType* modArrayp = VN_CAST(modDTypep, UnpackArrayDType); + const AstNodeArrayDType* const exprArrayp = VN_CAST(conDTypep, UnpackArrayDType); + const AstNodeArrayDType* const modArrayp = VN_CAST(modDTypep, UnpackArrayDType); if (exprArrayp && modArrayp && VN_IS(exprArrayp->subDTypep(), IfaceRefDType) && exprArrayp->declRange().elements() != modArrayp->declRange().elements()) { const int exprSize = exprArrayp->declRange().elements(); @@ -4316,15 +4332,15 @@ private: userIterateAndNext(nodep->exprp(), WidthVP(CONTEXT, PRELIM).p()); nodep->dtypeFrom(nodep->rangep()); // Very much like like an pin - AstNodeDType* conDTypep = nodep->exprp()->dtypep(); + const AstNodeDType* const conDTypep = nodep->exprp()->dtypep(); const int numInsts = nodep->rangep()->elementsConst(); const int pinwidth = numInsts; const int conwidth = conDTypep->width(); if (conwidth == 1 && pinwidth > 1) { // Multiple connections - AstNodeDType* subDTypep = nodep->findLogicDType(1, 1, conDTypep->numeric()); + AstNodeDType* const subDTypep = nodep->findLogicDType(1, 1, conDTypep->numeric()); userIterateAndNext(nodep->exprp(), WidthVP(subDTypep, FINAL).p()); - AstNode* newp = new AstReplicate(nodep->fileline(), nodep->exprp()->unlinkFrBack(), - numInsts); + AstNode* const newp = new AstReplicate(nodep->fileline(), + nodep->exprp()->unlinkFrBack(), numInsts); nodep->replaceWith(newp); } else { // Eliminating so pass down all of vup @@ -4407,9 +4423,9 @@ private: } // Makes sure that port and pin have same size and same datatype void checkUnpackedArrayArgs(AstVar* portp, AstNode* pinp) { - if (AstUnpackArrayDType* portDtypep + if (AstUnpackArrayDType* const portDtypep = VN_CAST(portp->dtypep()->skipRefp(), UnpackArrayDType)) { - if (AstUnpackArrayDType* pinDtypep + if (AstUnpackArrayDType* const pinDtypep = VN_CAST(pinp->dtypep()->skipRefp(), UnpackArrayDType)) { if (!areSameSize(portDtypep, pinDtypep)) { pinp->v3warn(E_UNSUPPORTED, @@ -4446,10 +4462,10 @@ private: // And do the arguments to the task/function too do { reloop: - V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); + const V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); for (const auto& tconnect : tconnects) { - AstVar* portp = tconnect.first; - AstArg* argp = tconnect.second; + const AstVar* const portp = tconnect.first; + AstArg* const argp = tconnect.second; AstNode* pinp = argp->exprp(); if (!pinp) continue; // Argument error we'll find later // Prelim may cause the node to get replaced; we've lost our @@ -4460,7 +4476,7 @@ private: AstNRelinker handle; argp->unlinkFrBackWithNext(&handle); // Format + additional args, if any AstNode* argsp = nullptr; - while (AstArg* nextargp = VN_AS(argp->nextp(), Arg)) { + while (AstArg* const nextargp = VN_AS(argp->nextp(), Arg)) { argsp = AstNode::addNext( argsp, nextargp->exprp() ->unlinkFrBackWithNext()); // Expression goes to SFormatF @@ -4474,7 +4490,8 @@ private: "Format to $display-like function must have constant format string"); } VL_DO_DANGLING(pushDeletep(argp), argp); - AstSFormatF* newp = new AstSFormatF(nodep->fileline(), format, false, argsp); + AstSFormatF* const newp + = new AstSFormatF(nodep->fileline(), format, false, argsp); if (!newp->scopeNamep() && newp->formatScopeTracking()) { newp->scopeNamep(new AstScopeName(newp->fileline())); } @@ -4492,7 +4509,7 @@ private: UINFO(4, " Add CvtPackString: " << pinp << endl); AstNRelinker handle; pinp->unlinkFrBack(&handle); // No next, that's the next pin - AstNode* newp = new AstCvtPackString(pinp->fileline(), pinp); + AstNode* const newp = new AstCvtPackString(pinp->fileline(), pinp); handle.relink(newp); pinp = newp; } @@ -4502,11 +4519,11 @@ private: } while (false); // Stage 2 { - V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); + const V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); for (const auto& tconnect : tconnects) { - AstVar* portp = tconnect.first; - AstArg* argp = tconnect.second; - AstNode* pinp = argp->exprp(); + AstVar* const portp = tconnect.first; + const AstArg* const argp = tconnect.second; + AstNode* const pinp = argp->exprp(); if (!pinp) continue; // Argument error we'll find later // Change data types based on above accept completion if (nodep->taskp()->dpiImport()) checkUnpackedArrayArgs(portp, pinp); @@ -4515,11 +4532,11 @@ private: } // Stage 3 { - V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); + const V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); for (const auto& tconnect : tconnects) { - AstVar* portp = tconnect.first; - AstArg* argp = tconnect.second; - AstNode* pinp = argp->exprp(); + const AstVar* const portp = tconnect.first; + const AstArg* const argp = tconnect.second; + AstNode* const pinp = argp->exprp(); if (!pinp) continue; // Argument error we'll find later // Do PRELIM again, because above accept may have exited early // due to node replacement @@ -4530,11 +4547,11 @@ private: if (markHasOpenArray(nodep->taskp())) makeOpenArrayShell(nodep); // Stage 4 { - V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); + const V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); for (const auto& tconnect : tconnects) { - AstVar* portp = tconnect.first; - AstArg* argp = tconnect.second; - AstNode* pinp = argp->exprp(); + const AstVar* const portp = tconnect.first; + const AstArg* const argp = tconnect.second; + AstNode* const pinp = argp->exprp(); if (!pinp) continue; // Argument error we'll find later if (portp->direction() == VDirection::REF && !similarDTypeRecurse(portp->dtypep(), pinp->dtypep())) { @@ -4578,7 +4595,7 @@ private: } virtual void visit(AstWith* nodep) override { // Should otherwise be underneath a method call - AstNodeDType* vdtypep = m_vup->dtypeNullSkipRefp(); + AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp(); { VL_RESTORER(m_withp); m_withp = nodep; @@ -4632,7 +4649,7 @@ private: // LHS presumed self-determined, then coerced to real if (m_vup->prelim()) { // First stage evaluation nodep->dtypeSetDouble(); - AstNodeDType* subDTypep = nodep->findLogicDType(64, 64, VSigning::UNSIGNED); + AstNodeDType* const subDTypep = nodep->findLogicDType(64, 64, VSigning::UNSIGNED); // Self-determined operand userIterateAndNext(nodep->lhsp(), WidthVP(SELF, PRELIM).p()); iterateCheck(nodep, "LHS", nodep->lhsp(), SELF, FINAL, subDTypep, EXTEND_EXP); @@ -4752,14 +4769,14 @@ private: userIterateAndNext(nodep->rhsp(), WidthVP(CONTEXT, PRELIM).p()); if (nodep->lhsp()->isDouble() || nodep->rhsp()->isDouble()) { if (!realok) nodep->v3error("Real not allowed as operand to in ?== operator"); - if (AstNodeBiop* newp = replaceWithDVersion(nodep)) { + if (AstNodeBiop* const newp = replaceWithDVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead iterateCheckReal(nodep, "LHS", nodep->lhsp(), FINAL); iterateCheckReal(nodep, "RHS", nodep->rhsp(), FINAL); } } else if (nodep->lhsp()->isString() || nodep->rhsp()->isString()) { - if (AstNodeBiop* newp = replaceWithNVersion(nodep)) { + if (AstNodeBiop* const newp = replaceWithNVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead iterateCheckString(nodep, "LHS", nodep->lhsp(), FINAL); @@ -4767,13 +4784,13 @@ private: } } else { const bool signedFl = nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned(); - if (AstNodeBiop* newp = replaceWithUOrSVersion(nodep, signedFl)) { + if (AstNodeBiop* const newp = replaceWithUOrSVersion(nodep, signedFl)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } const int width = std::max(nodep->lhsp()->width(), nodep->rhsp()->width()); const int ewidth = std::max(nodep->lhsp()->widthMin(), nodep->rhsp()->widthMin()); - AstNodeDType* subDTypep + AstNodeDType* const subDTypep = nodep->findLogicDType(width, ewidth, VSigning::fromBool(signedFl)); bool warnOn = true; if (!signedFl && width == 32) { @@ -4849,7 +4866,7 @@ private: } if (real_ok && nodep->lhsp()->isDouble()) { spliceCvtD(nodep->lhsp()); - if (AstNodeUniop* newp = replaceWithDVersion(nodep)) { + if (AstNodeUniop* const newp = replaceWithDVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead iterateCheckReal(nodep, "LHS", nodep->lhsp(), BOTH); @@ -4862,9 +4879,9 @@ private: } if (m_vup->prelim()) nodep->dtypeFrom(nodep->lhsp()); if (m_vup->final()) { - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); nodep->dtypep(expDTypep); // Propagate expression type to negation - AstNodeDType* subDTypep = expDTypep; + AstNodeDType* const subDTypep = expDTypep; iterateCheck(nodep, "LHS", nodep->lhsp(), CONTEXT, FINAL, subDTypep, EXTEND_EXP); } } @@ -4881,9 +4898,9 @@ private: userIterateAndNext(nodep->lhsp(), WidthVP(SELF, PRELIM).p()); checkCvtUS(nodep->lhsp()); const int width = nodep->lhsp()->width(); - AstNodeDType* expDTypep = nodep->findLogicDType(width, width, rs_out); + AstNodeDType* const expDTypep = nodep->findLogicDType(width, width, rs_out); nodep->dtypep(expDTypep); - AstNodeDType* subDTypep = expDTypep; + AstNodeDType* const subDTypep = expDTypep; // The child's width is self determined iterateCheck(nodep, "LHS", nodep->lhsp(), SELF, FINAL, subDTypep, EXTEND_EXP); } @@ -4897,7 +4914,7 @@ private: // RHS is self-determined. RHS is always treated as unsigned, has no effect on result. iterate_shift_prelim(nodep); nodep->dtypeChgSigned(nodep->lhsp()->isSigned()); - AstNodeBiop* newp = iterate_shift_final(nodep); + const AstNodeBiop* const newp = iterate_shift_final(nodep); VL_DANGLING(nodep); if (newp) {} // Ununused } @@ -4915,12 +4932,12 @@ private: AstNodeBiop* iterate_shift_final(AstNodeBiop* nodep) { // Nodep maybe edited if (m_vup->final()) { - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); - AstNodeDType* subDTypep = expDTypep; + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const subDTypep = expDTypep; nodep->dtypeFrom(expDTypep); // ShiftRS converts to ShiftR, but not vice-versa if (VN_IS(nodep, ShiftRS)) { - if (AstNodeBiop* newp = replaceWithUOrSVersion(nodep, nodep->isSigned())) { + if (AstNodeBiop* const newp = replaceWithUOrSVersion(nodep, nodep->isSigned())) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } @@ -4931,12 +4948,12 @@ private: iterateCheck(nodep, "LHS", nodep->lhsp(), CONTEXT, FINAL, subDTypep, EXTEND_EXP, warnOn); if (nodep->rhsp()->width() > 32) { - AstConst* shiftp = VN_CAST(nodep->rhsp(), Const); + AstConst* const shiftp = VN_CAST(nodep->rhsp(), Const); if (shiftp && shiftp->num().mostSetBitP1() <= 32) { // If (number)<<96'h1, then make it into (number)<<32'h1 V3Number num(shiftp, 32, 0); num.opAssign(shiftp->num()); - AstNode* shiftrhsp = nodep->rhsp(); + AstNode* const shiftrhsp = nodep->rhsp(); nodep->rhsp()->replaceWith(new AstConst(shiftrhsp->fileline(), num)); VL_DO_DANGLING(shiftrhsp->deleteTree(), shiftrhsp); } @@ -4967,8 +4984,8 @@ private: nodep->dtypeChgWidthSigned(width, mwidth, VSigning::fromBool(expSigned)); } if (m_vup->final()) { - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); - AstNodeDType* subDTypep = expDTypep; + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const subDTypep = expDTypep; nodep->dtypeFrom(expDTypep); // Error report and change sizes for suboperands of this node. iterateCheck(nodep, "LHS", nodep->lhsp(), CONTEXT, FINAL, subDTypep, EXTEND_EXP); @@ -5000,7 +5017,7 @@ private: if (nodep->lhsp()->isDouble() || nodep->rhsp()->isDouble()) { spliceCvtD(nodep->lhsp()); spliceCvtD(nodep->rhsp()); - if (AstNodeBiop* newp = replaceWithDVersion(nodep)) { + if (AstNodeBiop* const newp = replaceWithDVersion(nodep)) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } @@ -5017,12 +5034,12 @@ private: } if (m_vup->final()) { // Parent's data type was computed using the max(upper, nodep->dtype) - AstNodeDType* expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); - AstNodeDType* subDTypep = expDTypep; + AstNodeDType* const expDTypep = m_vup->dtypeOverridep(nodep->dtypep()); + AstNodeDType* const subDTypep = expDTypep; nodep->dtypeFrom(expDTypep); // We don't use LHS && RHS -- unspecified language corner, see t_math_signed5 test // bool expSigned = (nodep->lhsp()->isSigned() && nodep->rhsp()->isSigned()); - if (AstNodeBiop* newp = replaceWithUOrSVersion(nodep, expDTypep->isSigned())) { + if (AstNodeBiop* const newp = replaceWithUOrSVersion(nodep, expDTypep->isSigned())) { VL_DANGLING(nodep); nodep = newp; // Process new node instead } @@ -5099,14 +5116,14 @@ private: // for example $unsigned(a)+$signed(b), the SIGNED(B) will be unsigned dtype out UINFO(4, " widthExtend_(r=" << extendRule << ") old: " << nodep << endl); if (extendRule == EXTEND_OFF) return; - AstConst* constp = VN_CAST(nodep, Const); + AstConst* const constp = VN_CAST(nodep, Const); const int expWidth = expDTypep->width(); if (constp && !constp->num().isNegative()) { // Save later constant propagation work, just right-size it. V3Number num(nodep, expWidth); num.opAssign(constp->num()); num.isSigned(false); - AstNode* newp = new AstConst(nodep->fileline(), num); + AstNode* const newp = new AstConst(nodep->fileline(), num); constp->replaceWith(newp); VL_DO_DANGLING(pushDeletep(constp), constp); VL_DANGLING(nodep); @@ -5115,7 +5132,7 @@ private: // Trunc - Extract AstNRelinker linker; nodep->unlinkFrBack(&linker); - AstNode* newp = new AstSel(nodep->fileline(), nodep, 0, expWidth); + AstNode* const newp = new AstSel(nodep->fileline(), nodep, 0, expWidth); newp->didWidth(true); // Don't replace dtype with unsigned linker.relink(newp); nodep = newp; @@ -5140,7 +5157,7 @@ private: // For AstVar init() among others // TODO do all to-real and to-integer conversions in this function // rather than in callers - AstNode* newp = spliceCvtD(nodep); + AstNode* const newp = spliceCvtD(nodep); nodep = newp; } nodep->dtypeFrom(expDTypep); @@ -5155,12 +5172,12 @@ private: const int expWidth = 1; const int expSigned = false; UINFO(4, " widthReduce_old: " << nodep << endl); - AstConst* constp = VN_CAST(nodep, Const); + AstConst* const constp = VN_CAST(nodep, Const); if (constp) { V3Number num(nodep, expWidth); num.opRedOr(constp->num()); num.isSigned(expSigned); - AstNode* newp = new AstConst(nodep->fileline(), num); + AstNode* const newp = new AstConst(nodep->fileline(), num); constp->replaceWith(newp); VL_DO_DANGLING(constp->deleteTree(), constp); VL_DANGLING(nodep); @@ -5168,7 +5185,7 @@ private: } else { AstNRelinker linker; nodep->unlinkFrBack(&linker); - AstNode* newp = new AstRedOr(nodep->fileline(), nodep); + AstNode* const newp = new AstRedOr(nodep->fileline(), nodep); linker.relink(newp); nodep = newp; } @@ -5178,12 +5195,12 @@ private: bool fixAutoExtend(AstNode*& nodepr, int expWidth) { // For SystemVerilog '0,'1,'x,'z, autoextend and don't warn - if (AstConst* constp = VN_CAST(nodepr, Const)) { + if (AstConst* const constp = VN_CAST(nodepr, Const)) { if (constp->num().autoExtend() && !constp->num().sized() && constp->width() == 1) { // Make it the proper size. Careful of proper extension of 0's/1's V3Number num(constp, expWidth); num.opRepl(constp->num(), expWidth); // {width{'1}} - AstNode* newp = new AstConst(constp->fileline(), num); + AstNode* const newp = new AstConst(constp->fileline(), num); // Spec says always unsigned with proper width if (debug() > 4) constp->dumpTree(cout, " fixAutoExtend_old: "); if (debug() > 4) newp->dumpTree(cout, " _new: "); @@ -5201,7 +5218,7 @@ private: << expWidth << " bits: " << constp->prettyName()); V3Number num(constp, expWidth); num.opExtendXZ(constp->num(), constp->width()); - AstNode* newp = new AstConst(constp->fileline(), num); + AstNode* const newp = new AstConst(constp->fileline(), num); // Spec says always unsigned with proper width if (debug() > 4) constp->dumpTree(cout, " fixUnszExtend_old: "); if (debug() > 4) newp->dumpTree(cout, " _new: "); @@ -5222,7 +5239,7 @@ private: UASSERT_OBJ(stage == BOTH, nodep, "Bad call"); // underp may change as a result of replacement underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, PRELIM).p()); - AstNodeDType* expDTypep = underp->findUInt32DType(); + AstNodeDType* const expDTypep = underp->findUInt32DType(); underp = iterateCheck(nodep, "file_descriptor", underp, SELF, FINAL, expDTypep, EXTEND_EXP); if (underp) {} // cppcheck @@ -5234,7 +5251,7 @@ private: underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, PRELIM).p()); } if (stage & FINAL) { - AstNodeDType* expDTypep = nodep->findSigned32DType(); + AstNodeDType* const expDTypep = nodep->findSigned32DType(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } if (underp) {} // cppcheck @@ -5250,7 +5267,7 @@ private: underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, PRELIM).p()); } if (stage & FINAL) { - AstNodeDType* expDTypep = nodep->findDoubleDType(); + AstNodeDType* const expDTypep = nodep->findDoubleDType(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } if (underp) {} // cppcheck @@ -5260,7 +5277,7 @@ private: underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, PRELIM).p()); } if (stage & FINAL) { - AstNodeDType* expDTypep = nodep->findStringDType(); + AstNodeDType* const expDTypep = nodep->findStringDType(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); } if (underp) {} // cppcheck @@ -5287,7 +5304,7 @@ private: underp = userIterateSubtreeReturnEdits(underp, WidthVP(SELF, PRELIM).p()); } underp = checkCvtUS(underp); - AstNodeDType* expDTypep = underp->dtypep(); + AstNodeDType* const expDTypep = underp->dtypep(); underp = iterateCheck(nodep, side, underp, SELF, FINAL, expDTypep, EXTEND_EXP); if (underp) {} // cppcheck } @@ -5297,7 +5314,7 @@ private: // if (debug()) nodep->dumpTree(cout, "-checkass: "); UASSERT_OBJ(stage == FINAL, nodep, "Bad width call"); // We iterate and size the RHS based on the result of RHS evaluation - bool lhsStream + const bool lhsStream = (VN_IS(nodep, NodeAssign) && VN_IS(VN_AS(nodep, NodeAssign)->lhsp(), NodeStream)); rhsp = iterateCheck(nodep, side, rhsp, ASSIGN, FINAL, lhsDTypep, lhsStream ? EXTEND_OFF : EXTEND_LHS); @@ -5322,7 +5339,7 @@ private: UINFO(6, " spliceCvtCmpD0: " << underp << endl); AstNRelinker linker; underp->unlinkFrBack(&linker); - AstNode* newp + AstNode* const newp = new AstNeqD(nodep->fileline(), underp, new AstConst(nodep->fileline(), AstConst::RealDouble(), 0.0)); linker.relink(newp); @@ -5377,20 +5394,23 @@ private: } else if (expDTypep->isDouble() && underp->isDouble()) { // Also good underp = userIterateSubtreeReturnEdits(underp, WidthVP(expDTypep, FINAL).p()); } else if (expDTypep->isDouble() && !underp->isDouble()) { - AstNode* oldp = underp; // Need FINAL on children; otherwise splice would block it + AstNode* const oldp + = underp; // Need FINAL on children; otherwise splice would block it underp = spliceCvtD(underp); underp = userIterateSubtreeReturnEdits(oldp, WidthVP(SELF, FINAL).p()); } else if (!expDTypep->isDouble() && underp->isDouble()) { - AstNode* oldp = underp; // Need FINAL on children; otherwise splice would block it + AstNode* const oldp + = underp; // Need FINAL on children; otherwise splice would block it underp = spliceCvtS(underp, true, expDTypep->width()); // Round RHS underp = userIterateSubtreeReturnEdits(oldp, WidthVP(SELF, FINAL).p()); } else if (expDTypep->isString() && !underp->dtypep()->isString()) { - AstNode* oldp = underp; // Need FINAL on children; otherwise splice would block it + AstNode* const oldp + = underp; // Need FINAL on children; otherwise splice would block it underp = spliceCvtString(underp); underp = userIterateSubtreeReturnEdits(oldp, WidthVP(SELF, FINAL).p()); } else { - AstBasicDType* expBasicp = expDTypep->basicp(); - AstBasicDType* underBasicp = underp->dtypep()->basicp(); + const AstBasicDType* const expBasicp = expDTypep->basicp(); + const AstBasicDType* const underBasicp = underp->dtypep()->basicp(); if (expBasicp && underBasicp) { AstNodeDType* subDTypep = expDTypep; // We then iterate FINAL before width fixes, as if the under-operation @@ -5436,8 +5456,8 @@ private: // Generally iterateCheck is what is wanted instead of this // UINFO(9,"wchk "<basicp(); - AstBasicDType* underBasicp = underp->dtypep()->basicp(); + const AstBasicDType* const expBasicp = expDTypep->basicp(); + const AstBasicDType* const underBasicp = underp->dtypep()->basicp(); if (expDTypep == underp->dtypep()) { return; // Same type must match } else if (!expBasicp || expBasicp->isDouble() || !underBasicp @@ -5492,8 +5512,8 @@ private: // If we're in an NodeAssign, don't truncate the RHS if the LHS is // a NodeStream. The streaming operator changes the rules regarding // which bits to truncate. - AstNodeAssign* assignp = VN_CAST(nodep, NodeAssign); - AstPin* pinp = VN_CAST(nodep, Pin); + const AstNodeAssign* assignp = VN_CAST(nodep, NodeAssign); + const AstPin* pinp = VN_CAST(nodep, Pin); if (assignp && VN_IS(assignp->lhsp(), NodeStream)) { } else if (pinp && pinp->modVarp()->direction() != VDirection::INPUT) { // V3Inst::pinReconnectSimple must deal @@ -5544,7 +5564,7 @@ private: UINFO(6, " spliceCvtS: " << nodep << endl); AstNRelinker linker; nodep->unlinkFrBack(&linker); - if (AstConst* constp = VN_CAST(nodep, Const)) { + if (const AstConst* const constp = VN_CAST(nodep, Const)) { // We convert to/from vlsint32 rather than use floor() as want to make sure is // representable in integer's number of bits if (constp->isDouble() @@ -5555,7 +5575,7 @@ private: } } if (warnOn) nodep->v3warn(REALCVT, "Implicit conversion of real to integer"); - AstNode* newp = new AstRToIRoundS(nodep->fileline(), nodep); + AstNode* const newp = new AstRToIRoundS(nodep->fileline(), nodep); linker.relink(newp); newp->dtypeSetBitSized(width, VSigning::SIGNED); return newp; @@ -5570,7 +5590,7 @@ private: UINFO(6, " spliceCvtString: " << nodep << endl); AstNRelinker linker; nodep->unlinkFrBack(&linker); - AstNode* newp = new AstCvtPackString(nodep->fileline(), nodep); + AstNode* const newp = new AstCvtPackString(nodep->fileline(), nodep); linker.relink(newp); return newp; } else { @@ -5595,9 +5615,9 @@ private: case AstType::atShiftL: nodep->dtypeChgSigned(signedFlavorNeeded); return nullptr; default: break; } - FileLine* fl = nodep->fileline(); - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + FileLine* const fl = nodep->fileline(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNodeBiop* newp = nullptr; switch (nodep->type()) { case AstType::atGt: newp = new AstGtS(fl, lhsp, rhsp); break; @@ -5630,9 +5650,9 @@ private: // Given a signed/unsigned node type, create the opposite type // Return new node or nullptr if nothing if (nodep->doubleFlavor()) return nullptr; - FileLine* fl = nodep->fileline(); - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + FileLine* const fl = nodep->fileline(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNodeBiop* newp = nullptr; // No width change on output;... // All below have bool or double outputs switch (nodep->type()) { @@ -5669,9 +5689,9 @@ private: // Given a signed/unsigned node type, replace with string version // Return new node or nullptr if nothing if (nodep->stringFlavor()) return nullptr; - FileLine* fl = nodep->fileline(); - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); - AstNode* rhsp = nodep->rhsp()->unlinkFrBack(); + FileLine* const fl = nodep->fileline(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); + AstNode* const rhsp = nodep->rhsp()->unlinkFrBack(); AstNodeBiop* newp = nullptr; // No width change on output;... // All below have bool or double outputs switch (nodep->type()) { @@ -5701,8 +5721,8 @@ private: // Given a signed/unsigned node type, create the opposite type // Return new node or nullptr if nothing if (nodep->doubleFlavor()) return nullptr; - FileLine* fl = nodep->fileline(); - AstNode* lhsp = nodep->lhsp()->unlinkFrBack(); + FileLine* const fl = nodep->fileline(); + AstNode* const lhsp = nodep->lhsp()->unlinkFrBack(); AstNodeUniop* newp = nullptr; switch (nodep->type()) { case AstType::atNegate: newp = new AstNegateD(fl, lhsp); break; @@ -5722,13 +5742,13 @@ private: void replaceWithSFormat(AstMethodCall* nodep, const string& format) { // For string.itoa and similar, replace with SFormatF - AstArg* argp = VN_CAST(nodep->pinsp(), Arg); + const AstArg* argp = VN_CAST(nodep->pinsp(), Arg); if (!argp) { nodep->v3error("Argument needed for string." + nodep->prettyName() + " method"); return; } - AstNodeVarRef* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef); - AstNode* newp = new AstAssign( + AstNodeVarRef* const fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef); + AstNode* const newp = new AstAssign( nodep->fileline(), fromp, new AstSFormatF(nodep->fileline(), format, false, argp->exprp()->unlinkFrBack())); fromp->access(VAccess::WRITE); @@ -5753,8 +5773,8 @@ private: // so removing/changing a variable won't lose the dtype // Case #1 above applies? - bool child1 = (parentp->getChildDTypep() == dtnodep); - bool child2 = (parentp->getChild2DTypep() == dtnodep); + const bool child1 = (parentp->getChildDTypep() == dtnodep); + const bool child2 = (parentp->getChild2DTypep() == dtnodep); if (child1 || child2) { UINFO(9, "iterateEditMoveDTypep child iterating " << dtnodep << endl); // Iterate, this might edit the dtypes which means dtnodep now lost @@ -5790,14 +5810,15 @@ private: for (int i = 1; i <= dim; ++i) { // UINFO(9, " dim at "<declRange(); if (i < dim) dtypep = adtypep->subDTypep()->skipRefp(); continue; - } else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) { + } else if (const AstNodeUOrStructDType* const adtypep + = VN_CAST(dtypep, NodeUOrStructDType)) { declRange = adtypep->declRange(); break; // Sub elements don't look like arrays and can't iterate into - } else if (AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) { + } else if (const AstBasicDType* const adtypep = VN_CAST(dtypep, BasicDType)) { if (adtypep->isRanged()) declRange = adtypep->declRange(); break; } @@ -5810,14 +5831,15 @@ private: int bits = 1; while (dtypep) { // UINFO(9, " bits at "<declRange().elements(); dtypep = adtypep->subDTypep()->skipRefp(); continue; - } else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) { + } else if (const AstNodeUOrStructDType* const adtypep + = VN_CAST(dtypep, NodeUOrStructDType)) { bits *= adtypep->width(); break; - } else if (AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) { + } else if (const AstBasicDType* const adtypep = VN_CAST(dtypep, BasicDType)) { bits *= adtypep->width(); break; } @@ -5852,15 +5874,15 @@ private: // Return a variable table which has specified dimension properties for this variable const auto pos = m_tableMap.find(std::make_pair(nodep, attrType)); if (pos != m_tableMap.end()) return pos->second; - AstNodeArrayDType* vardtypep + AstNodeArrayDType* const vardtypep = new AstUnpackArrayDType(nodep->fileline(), nodep->findSigned32DType(), new AstRange(nodep->fileline(), msbdim, 0)); - AstInitArray* initp = new AstInitArray(nodep->fileline(), vardtypep, nullptr); + AstInitArray* const initp = new AstInitArray(nodep->fileline(), vardtypep, nullptr); v3Global.rootp()->typeTablep()->addTypesp(vardtypep); - AstVar* varp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, - "__Vdimtab_" + VString::downcase(attrType.ascii()) - + cvtToStr(m_dtTables++), - vardtypep); + AstVar* const varp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, + "__Vdimtab_" + VString::downcase(attrType.ascii()) + + cvtToStr(m_dtTables++), + vardtypep); varp->isConst(true); varp->isStatic(true); varp->valuep(initp); @@ -5884,7 +5906,7 @@ private: uint64_t maxval = 0; for (const AstEnumItem* itemp = adtypep->itemsp(); itemp; itemp = VN_AS(itemp->nextp(), EnumItem)) { - const AstConst* vconstp = VN_AS(itemp->valuep(), Const); + const AstConst* const vconstp = VN_AS(itemp->valuep(), Const); UASSERT_OBJ(vconstp, errNodep, "Enum item without constified value"); if (vconstp->toUQuad() >= maxval) maxval = vconstp->toUQuad(); } @@ -5913,14 +5935,14 @@ private: } else { basep = nodep->dtypep(); } - AstNodeArrayDType* vardtypep = new AstUnpackArrayDType( + AstNodeArrayDType* const vardtypep = new AstUnpackArrayDType( nodep->fileline(), basep, new AstRange(nodep->fileline(), msbdim, 0)); - AstInitArray* initp = new AstInitArray(nodep->fileline(), vardtypep, nullptr); + AstInitArray* const initp = new AstInitArray(nodep->fileline(), vardtypep, nullptr); v3Global.rootp()->typeTablep()->addTypesp(vardtypep); - AstVar* varp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, - "__Venumtab_" + VString::downcase(attrType.ascii()) - + cvtToStr(m_dtTables++), - vardtypep); + AstVar* const varp = new AstVar(nodep->fileline(), AstVarType::MODULETEMP, + "__Venumtab_" + VString::downcase(attrType.ascii()) + + cvtToStr(m_dtTables++), + vardtypep); varp->isConst(true); varp->isStatic(true); varp->valuep(initp); @@ -5944,14 +5966,14 @@ private: values.resize(msbdim + 1); for (unsigned i = 0; i < (msbdim + 1); ++i) values[i] = nullptr; { - AstEnumItem* firstp = nodep->itemsp(); - AstEnumItem* prevp = firstp; // Prev must start with last item + AstEnumItem* const firstp = nodep->itemsp(); + const AstEnumItem* prevp = firstp; // Prev must start with last item while (prevp->nextp()) prevp = VN_AS(prevp->nextp(), EnumItem); for (AstEnumItem* itemp = firstp; itemp;) { - AstEnumItem* nextp = VN_AS(itemp->nextp(), EnumItem); - const AstConst* vconstp = VN_AS(itemp->valuep(), Const); + AstEnumItem* const nextp = VN_AS(itemp->nextp(), EnumItem); + const AstConst* const vconstp = VN_AS(itemp->valuep(), Const); UASSERT_OBJ(vconstp, nodep, "Enum item without constified value"); - uint32_t i = vconstp->toUInt(); + const uint32_t i = vconstp->toUInt(); if (attrType == AstAttrType::ENUM_NAME) { values[i] = new AstConst(nodep->fileline(), AstConst::String(), itemp->name()); } else if (attrType == AstAttrType::ENUM_NEXT) { @@ -5982,7 +6004,7 @@ private: for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp; patp = VN_AS(patp->nextp(), PatMember)) { if (patp->keyp()) { - if (const AstConst* constp = VN_CAST(patp->keyp(), Const)) { + if (const AstConst* const constp = VN_CAST(patp->keyp(), Const)) { element = constp->toSInt(); } else { patp->keyp()->v3error("Assignment pattern key not supported/understood: " @@ -6001,11 +6023,11 @@ private: void makeOpenArrayShell(AstNodeFTaskRef* nodep) { UINFO(4, "Replicate openarray function " << nodep->taskp() << endl); - AstNodeFTask* oldTaskp = nodep->taskp(); + AstNodeFTask* const oldTaskp = nodep->taskp(); oldTaskp->dpiOpenParentInc(); UASSERT_OBJ(!oldTaskp->dpiOpenChild(), oldTaskp, "DPI task should be parent or child, not both"); - AstNodeFTask* newTaskp = oldTaskp->cloneTree(false); + AstNodeFTask* const newTaskp = oldTaskp->cloneTree(false); newTaskp->dpiOpenChild(true); newTaskp->dpiOpenParentClear(); newTaskp->name(newTaskp->name() + "__Vdpioc" + cvtToStr(oldTaskp->dpiOpenParent())); @@ -6014,11 +6036,11 @@ private: nodep->taskp(newTaskp); nodep->name(nodep->taskp()->name()); // Replace open array arguments with the callee's task - V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); + const V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp()); for (const auto& tconnect : tconnects) { - AstVar* portp = tconnect.first; - AstArg* argp = tconnect.second; - AstNode* pinp = argp->exprp(); + AstVar* const portp = tconnect.first; + const AstArg* const argp = tconnect.second; + const AstNode* const pinp = argp->exprp(); if (!pinp) continue; // Argument error we'll find later if (hasOpenArrayIterateDType(portp->dtypep())) portp->dtypep(pinp->dtypep()); } @@ -6027,7 +6049,7 @@ private: bool markHasOpenArray(AstNodeFTask* nodep) { bool hasOpen = false; for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) { - if (AstVar* portp = VN_CAST(stmtp, Var)) { + if (AstVar* const portp = VN_CAST(stmtp, Var)) { if (portp->isDpiOpenArray() || hasOpenArrayIterateDType(portp->dtypep())) { portp->isDpiOpenArray(true); hasOpen = true; @@ -6045,24 +6067,24 @@ private: //---------------------------------------------------------------------- // METHODS - casting - static Castable computeCastable(AstNodeDType* toDtp, AstNodeDType* fromDtp, - AstNode* fromConstp) { + static Castable computeCastable(const AstNodeDType* toDtp, const AstNodeDType* fromDtp, + const AstNode* fromConstp) { const auto castable = computeCastableImp(toDtp, fromDtp, fromConstp); UINFO(9, " castable=" << castable << " for " << toDtp << endl); UINFO(9, " =?= " << fromDtp << endl); UINFO(9, " const= " << fromConstp << endl); return castable; } - static Castable computeCastableImp(AstNodeDType* toDtp, AstNodeDType* fromDtp, - AstNode* fromConstp) { + static Castable computeCastableImp(const AstNodeDType* toDtp, const AstNodeDType* fromDtp, + const AstNode* fromConstp) { const Castable castable = UNSUPPORTED; toDtp = toDtp->skipRefToEnump(); fromDtp = fromDtp->skipRefToEnump(); if (toDtp == fromDtp) return COMPATIBLE; - AstNodeDType* fromBaseDtp = fromDtp; - while (AstPackArrayDType* packp = VN_CAST(fromBaseDtp, PackArrayDType)) { + const AstNodeDType* fromBaseDtp = fromDtp; + while (const AstPackArrayDType* const packp = VN_CAST(fromBaseDtp, PackArrayDType)) { fromBaseDtp = packp->subDTypep(); - while (AstRefDType* refp = VN_CAST(fromBaseDtp, RefDType)) { + while (const AstRefDType* const refp = VN_CAST(fromBaseDtp, RefDType)) { fromBaseDtp = refp->refDTypep(); } } @@ -6125,13 +6147,13 @@ private: // This avoids iterateEditMoveDTypep going into a hard to resolve loop // Only call once for any given typedef, or will become O(n^2) if (VL_LIKELY(!nodep)) return nullptr; - if (auto* refp = VN_CAST(nodep, RefDType)) { + if (auto* const refp = VN_CAST(nodep, RefDType)) { if (refp->typedefp() == typedefp) return refp; } - if (auto* refp = checkRefToTypedefRecurse(nodep->op1p(), typedefp)) return refp; - if (auto* refp = checkRefToTypedefRecurse(nodep->op2p(), typedefp)) return refp; - if (auto* refp = checkRefToTypedefRecurse(nodep->op3p(), typedefp)) return refp; - if (auto* refp = checkRefToTypedefRecurse(nodep->op4p(), typedefp)) return refp; + if (auto* const refp = checkRefToTypedefRecurse(nodep->op1p(), typedefp)) return refp; + if (auto* const refp = checkRefToTypedefRecurse(nodep->op2p(), typedefp)) return refp; + if (auto* const refp = checkRefToTypedefRecurse(nodep->op3p(), typedefp)) return refp; + if (auto* const refp = checkRefToTypedefRecurse(nodep->op4p(), typedefp)) return refp; return nullptr; } @@ -6209,7 +6231,7 @@ void V3Width::width(AstNetlist* nodep) { UINFO(2, __FUNCTION__ << ": " << endl); { // We should do it in bottom-up module order, but it works in any order. - WidthClearVisitor cvisitor{nodep}; + const WidthClearVisitor cvisitor{nodep}; WidthVisitor visitor{false, false}; (void)visitor.mainAcceptEdit(nodep); WidthRemoveVisitor rvisitor; diff --git a/src/V3WidthCommit.h b/src/V3WidthCommit.h index 5dc34c028..eb7ba7409 100644 --- a/src/V3WidthCommit.h +++ b/src/V3WidthCommit.h @@ -80,7 +80,7 @@ public: V3Number num(nodep, nodep->dtypep()->width()); num.opAssign(nodep->num()); num.isSigned(nodep->isSigned()); - AstConst* newp = new AstConst(nodep->fileline(), num); + AstConst* const newp = new AstConst(nodep->fileline(), num); newp->dtypeFrom(nodep); return newp; } else { @@ -102,8 +102,8 @@ private: // Recurse to handle the data type, as may change the size etc of this type if (!nodep->user1()) iterate(nodep); // Look for duplicate - if (AstBasicDType* bdtypep = VN_CAST(nodep, BasicDType)) { - AstBasicDType* newp = nodep->findInsertSameDType(bdtypep); + if (AstBasicDType* const bdtypep = VN_CAST(nodep, BasicDType)) { + AstBasicDType* const newp = nodep->findInsertSameDType(bdtypep); if (newp != bdtypep && debug() >= 9) { UINFO(9, "dtype replacement "); nodep->dumpSmall(cout); @@ -162,9 +162,9 @@ private: virtual void visit(AstConst* nodep) override { UASSERT_OBJ(nodep->dtypep(), nodep, "No dtype"); iterate(nodep->dtypep()); // Do datatype first - if (AstConst* newp = newIfConstCommitSize(nodep)) { + if (AstConst* const newp = newIfConstCommitSize(nodep)) { nodep->replaceWith(newp); - AstNode* oldp = nodep; + AstNode* const oldp = nodep; nodep = newp; // if (debug() > 4) oldp->dumpTree(cout, " fixConstSize_old: "); // if (debug() > 4) newp->dumpTree(cout, " _new: "); @@ -221,7 +221,7 @@ private: virtual void visit(AstMemberSel* nodep) override { iterateChildren(nodep); editDType(nodep); - if (auto* classrefp = VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) { + if (auto* const classrefp = VN_CAST(nodep->fromp()->dtypep(), ClassRefDType)) { classEncapCheck(nodep, nodep->varp(), classrefp->classp()); } // else might be struct, etc } diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index ca2523f96..e1f1c9427 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -89,9 +89,10 @@ private: } else if (VN_IS(ddtypep, AssocArrayDType)) { } else if (VN_IS(ddtypep, DynArrayDType)) { } else if (VN_IS(ddtypep, QueueDType)) { - } else if (const AstNodeUOrStructDType* adtypep = VN_CAST(ddtypep, NodeUOrStructDType)) { + } else if (const AstNodeUOrStructDType* const adtypep + = VN_CAST(ddtypep, NodeUOrStructDType)) { fromRange = adtypep->declRange(); - } else if (AstBasicDType* adtypep = VN_CAST(ddtypep, BasicDType)) { + } else if (const AstBasicDType* const adtypep = VN_CAST(ddtypep, BasicDType)) { if (adtypep->isString() && VN_IS(nodep, SelBit)) { } else if (adtypep->isRanged()) { UASSERT_OBJ( @@ -179,7 +180,7 @@ private: } else { // Need a slice data type, which is an array of the extracted // type, but with (presumably) different size - VNumRange newRange(msb, lsb, nodep->declRange().littleEndian()); + const VNumRange newRange(msb, lsb, nodep->declRange().littleEndian()); AstNodeDType* const vardtypep = new AstPackArrayDType(nodep->fileline(), nodep->subDTypep(), // Need to strip off array reference @@ -212,7 +213,7 @@ private: AstNodeDType* const ddtypep = fromdata.m_dtypep; const VNumRange fromRange = fromdata.m_fromRange; UINFO(6, " ddtypep " << ddtypep << endl); - if (AstUnpackArrayDType* const adtypep = VN_CAST(ddtypep, UnpackArrayDType)) { + if (const AstUnpackArrayDType* const adtypep = VN_CAST(ddtypep, UnpackArrayDType)) { // SELBIT(array, index) -> ARRAYSEL(array, index) AstNode* subp = rhsp; if (fromRange.lo() != 0 || fromRange.hi() < 0) { @@ -223,7 +224,7 @@ private: if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); - } else if (AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) { + } else if (const AstPackArrayDType* const adtypep = VN_CAST(ddtypep, PackArrayDType)) { // SELBIT(array, index) -> SEL(array, index*width-of-subindex, width-of-subindex) AstNode* subp = rhsp; if (fromRange.littleEndian()) { @@ -247,7 +248,7 @@ private: if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); - } else if (AstAssocArrayDType* adtypep = VN_CAST(ddtypep, AssocArrayDType)) { + } else if (const AstAssocArrayDType* const adtypep = VN_CAST(ddtypep, AssocArrayDType)) { // SELBIT(array, index) -> ASSOCSEL(array, index) AstNode* const subp = rhsp; AstAssocSel* const newp = new AstAssocSel(nodep->fileline(), fromp, subp); @@ -255,7 +256,7 @@ private: if (debug() >= 9) newp->dumpTree(cout, "--SELBTn: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); - } else if (AstDynArrayDType* adtypep = VN_CAST(ddtypep, DynArrayDType)) { + } else if (const AstDynArrayDType* const adtypep = VN_CAST(ddtypep, DynArrayDType)) { // SELBIT(array, index) -> CMETHODCALL(queue, "at", index) AstNode* const subp = rhsp; AstCMethodHard* const newp = new AstCMethodHard(nodep->fileline(), fromp, "at", subp); @@ -263,7 +264,7 @@ private: if (debug() >= 9) newp->dumpTree(cout, "--SELBTq: "); nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); - } else if (AstQueueDType* adtypep = VN_CAST(ddtypep, QueueDType)) { + } else if (const AstQueueDType* const adtypep = VN_CAST(ddtypep, QueueDType)) { // SELBIT(array, index) -> CMETHODCALL(queue, "at", index) AstNode* const subp = rhsp; AstCMethodHard* const newp = new AstCMethodHard(nodep->fileline(), fromp, "at", subp); @@ -273,7 +274,7 @@ private: VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(ddtypep, BasicDType) && ddtypep->isString()) { // SELBIT(string, index) -> GETC(string, index) - AstNodeVarRef* const varrefp = VN_CAST(fromp, NodeVarRef); + const AstNodeVarRef* const varrefp = VN_CAST(fromp, NodeVarRef); if (!varrefp) { nodep->v3warn(E_UNSUPPORTED, "Unsupported: String array operation on non-variable"); @@ -337,7 +338,7 @@ private: AstNode* const lsbp = nodep->thsp()->unlinkFrBack(); vlsint32_t msb = VN_AS(msbp, Const)->toSInt(); vlsint32_t lsb = VN_AS(lsbp, Const)->toSInt(); - vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1); + const vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1); const FromData fromdata = fromDataForArray(nodep, fromp); AstNodeDType* const ddtypep = fromdata.m_dtypep; const VNumRange fromRange = fromdata.m_fromRange; @@ -358,7 +359,7 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } - } else if (AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) { + } else if (AstPackArrayDType* const adtypep = VN_CAST(ddtypep, PackArrayDType)) { // SELEXTRACT(array, msb, lsb) -> SEL(array, // lsb*width-of-subindex, width-of-subindex*(msb-lsb)) UASSERT_OBJ(!(!fromRange.elements() || (adtypep->width() % fromRange.elements()) != 0), @@ -367,7 +368,7 @@ private: << fromRange.elements()); if (fromRange.littleEndian()) { // Below code assumes big bit endian; just works out if we swap - int x = msb; + const int x = msb; msb = lsb; lsb = x; } @@ -377,7 +378,7 @@ private: "[" << msb << ":" << lsb << "] Range extract has backward bit ordering, perhaps you wanted [" << lsb << ":" << msb << "]"); - int x = msb; + const int x = msb; msb = lsb; lsb = x; } @@ -397,7 +398,7 @@ private: } else if (VN_IS(ddtypep, BasicDType)) { if (fromRange.littleEndian()) { // Below code assumes big bit endian; just works out if we swap - int x = msb; + const int x = msb; msb = lsb; lsb = x; } @@ -407,7 +408,7 @@ private: "[" << msb << ":" << lsb << "] Range extract has backward bit ordering, perhaps you wanted [" << lsb << ":" << msb << "]"); - int x = msb; + const int x = msb; msb = lsb; lsb = x; } @@ -430,7 +431,7 @@ private: "[" << msb << ":" << lsb << "] Range extract has backward bit ordering, perhaps you wanted [" << lsb << ":" << msb << "]"); - int x = msb; + const int x = msb; msb = lsb; lsb = x; } @@ -491,7 +492,7 @@ private: } if (width < 0) nodep->v3error("Width of :+ or :- is < 0: " << widthp->prettyName()); const FromData fromdata = fromDataForArray(nodep, fromp); - AstNodeDType* const ddtypep = fromdata.m_dtypep; + const AstNodeDType* const ddtypep = fromdata.m_dtypep; const VNumRange fromRange = fromdata.m_fromRange; if (VN_IS(ddtypep, UnpackArrayDType)) { // Slice +: and -: extraction @@ -505,13 +506,13 @@ private: nodep->replaceWith(newp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } else if (VN_IS(rhsp, Const)) { // Slice - vlsint32_t rhs = VN_AS(rhsp, Const)->toSInt(); + const vlsint32_t rhs = VN_AS(rhsp, Const)->toSInt(); // down array: lsb/lo +: width // down array: msb/hi -: width // up array: msb/lo +: width // up array: lsb/hi -: width - vlsint32_t msb = VN_IS(nodep, SelPlus) ? rhs + width - 1 : rhs; - vlsint32_t lsb = VN_IS(nodep, SelPlus) ? rhs : rhs - width + 1; + const vlsint32_t msb = VN_IS(nodep, SelPlus) ? rhs + width - 1 : rhs; + const vlsint32_t lsb = VN_IS(nodep, SelPlus) ? rhs : rhs - width + 1; AstSliceSel* const newp = new AstSliceSel( nodep->fileline(), fromp, VNumRange(msb, lsb, fromRange.littleEndian())); nodep->replaceWith(newp); diff --git a/src/VlcBucket.h b/src/VlcBucket.h index 89e758c45..efaf1413a 100644 --- a/src/VlcBucket.h +++ b/src/VlcBucket.h @@ -35,7 +35,7 @@ private: static vluint64_t covBit(vluint64_t point) { return 1ULL << (point & 63); } vluint64_t allocSize() const { return sizeof(vluint64_t) * m_dataSize / 64; } void allocate(vluint64_t point) { - vluint64_t oldsize = m_dataSize; + const vluint64_t oldsize = m_dataSize; if (m_dataSize < point) m_dataSize = (point + 64) & ~63ULL; // Keep power of two m_dataSize *= 2; // UINFO(9, "Realloc "< Date: Fri, 26 Nov 2021 20:38:48 -0500 Subject: [PATCH 67/79] Support task name in $display %m (#3211). --- Changes | 1 + src/V3Assert.cpp | 2 +- src/V3AstNodes.cpp | 5 +++++ src/V3AstNodes.h | 12 +++++++--- src/V3Begin.cpp | 15 ++++++++++--- src/V3LinkResolve.cpp | 6 ++--- src/V3Width.cpp | 2 +- test_regress/t/t_class_name.v | 27 ++++++++--------------- test_regress/t/t_display.out | 8 +++---- test_regress/t/t_dpi_qw_c.cpp | 11 ++++++++- test_regress/t/t_var_nonamebegin__log.out | 4 ++-- 11 files changed, 57 insertions(+), 36 deletions(-) diff --git a/Changes b/Changes index ba85d7c42..186505ec4 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ Verilator 4.215 devel * Internal code cleanups and improvements. [Geza Lore] * Improve --thread verilation-time performance. +* Support task name in $display %m (#3211). [Julie Schwartz] * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix nested generate if genblk naming (#3189). [yanx21] diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 9bb03a37b..59a675d0f 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -62,7 +62,7 @@ private: } nodep->fmtp()->addExprsp(timenewp); if (!nodep->fmtp()->scopeNamep() && nodep->fmtp()->formatScopeTracking()) { - nodep->fmtp()->scopeNamep(new AstScopeName(nodep->fileline())); + nodep->fmtp()->scopeNamep(new AstScopeName{nodep->fileline(), true}); } } AstVarRef* newMonitorNumVarRefp(AstNode* nodep, VAccess access) { diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 9235cb14e..a1f2ad2d0 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -1700,6 +1700,11 @@ void AstScope::dump(std::ostream& str) const { str << " [cellp=" << reinterpret_cast(aboveCellp()) << "]"; str << " [modp=" << reinterpret_cast(modp()) << "]"; } +void AstScopeName::dump(std::ostream& str) const { + this->AstNode::dump(str); + if (dpiExport()) str << " [DPIEX]"; + if (forFormat()) str << " [FMT]"; +} void AstSenTree::dump(std::ostream& str) const { this->AstNode::dump(str); if (isMulti()) str << " [MULTI]"; diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index b116d72c9..e6f028df6 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -5379,21 +5379,26 @@ class AstScopeName final : public AstNodeMath { // Children: TEXT private: bool m_dpiExport = false; // Is for dpiExport + const bool m_forFormat = false; // Is for a format %m string scopeNameFormatter(AstText* scopeTextp) const; string scopePrettyNameFormatter(AstText* scopeTextp) const; public: - explicit AstScopeName(FileLine* fl) - : ASTGEN_SUPER_ScopeName(fl) { + class ForFormat {}; + AstScopeName(FileLine* fl, bool forFormat) + : ASTGEN_SUPER_ScopeName(fl) + , m_forFormat{forFormat} { dtypeSetUInt64(); } ASTNODE_NODE_FUNCS(ScopeName) virtual bool same(const AstNode* samep) const override { - return m_dpiExport == static_cast(samep)->m_dpiExport; + return (m_dpiExport == static_cast(samep)->m_dpiExport + && m_forFormat == static_cast(samep)->m_forFormat); } virtual string emitVerilog() override { return ""; } virtual string emitC() override { V3ERROR_NA_RETURN(""); } virtual bool cleanOut() const override { return true; } + virtual void dump(std::ostream& str = std::cout) const override; AstText* scopeAttrp() const { return VN_AS(op1p(), Text); } void scopeAttrp(AstNode* nodep) { addOp1p(nodep); } AstText* scopeEntrp() const { return VN_AS(op2p(), Text); } @@ -5412,6 +5417,7 @@ public: } bool dpiExport() const { return m_dpiExport; } void dpiExport(bool flag) { m_dpiExport = flag; } + bool forFormat() const { return m_forFormat; } }; class AstUdpTable final : public AstNode { diff --git a/src/V3Begin.cpp b/src/V3Begin.cpp index 05ab4072c..76e540747 100644 --- a/src/V3Begin.cpp +++ b/src/V3Begin.cpp @@ -63,6 +63,7 @@ private: AstNodeModule* m_modp = nullptr; // Current module const AstNodeFTask* m_ftaskp = nullptr; // Current function/task AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp + string m_displayScope; // Name of %m in $display/AstScopeName string m_namedScope; // Name of begin blocks above us string m_unnamedScope; // Name of begin blocks, including unnamed blocks int m_ifDepth = 0; // Current if depth @@ -111,9 +112,11 @@ private: // naming; so that any begin's inside the function will rename // inside the function. // Process children + VL_RESTORER(m_displayScope); VL_RESTORER(m_namedScope); VL_RESTORER(m_unnamedScope); { + m_displayScope = dot(m_displayScope, nodep->name()); m_namedScope = ""; m_unnamedScope = ""; m_ftaskp = nodep; @@ -134,6 +137,7 @@ private: virtual void visit(AstBegin* nodep) override { // Begin blocks were only useful in variable creation, change names and delete UINFO(8, " " << nodep << endl); + VL_RESTORER(m_displayScope); VL_RESTORER(m_namedScope); VL_RESTORER(m_unnamedScope); { @@ -145,7 +149,10 @@ private: while ((pos = dottedname.find("__DOT__")) != string::npos) { const string ident = dottedname.substr(0, pos); dottedname = dottedname.substr(pos + strlen("__DOT__")); - if (nodep->name() != "") m_namedScope = dot(m_namedScope, ident); + if (nodep->name() != "") { + m_displayScope = dot(m_displayScope, ident); + m_namedScope = dot(m_namedScope, ident); + } m_unnamedScope = dot(m_unnamedScope, ident); // Create CellInline for dotted var resolution if (!m_ftaskp) { @@ -220,11 +227,13 @@ private: // If there's a %m in the display text, we add a special node that will contain the name() // Similar code in V3Inline if (nodep->user1SetOnce()) return; // Don't double-add text's - if (m_namedScope != "") { + // DPI svGetScope doesn't include function name, but %m does + const string scname = nodep->forFormat() ? m_displayScope : m_namedScope; + if (!scname.empty()) { // To keep correct visual order, must add before other Text's AstNode* const afterp = nodep->scopeAttrp(); if (afterp) afterp->unlinkFrBackWithNext(); - nodep->scopeAttrp(new AstText(nodep->fileline(), string("__DOT__") + m_namedScope)); + nodep->scopeAttrp(new AstText{nodep->fileline(), string("__DOT__") + scname}); if (afterp) nodep->scopeAttrp(afterp); } iterateChildren(nodep); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index ed7cc4db3..434baf566 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -136,12 +136,12 @@ private: iterateChildren(nodep); } m_ftaskp = nullptr; - if (nodep->dpiExport()) nodep->scopeNamep(new AstScopeName(nodep->fileline())); + if (nodep->dpiExport()) nodep->scopeNamep(new AstScopeName{nodep->fileline(), false}); } virtual void visit(AstNodeFTaskRef* nodep) override { iterateChildren(nodep); if (nodep->taskp() && (nodep->taskp()->dpiContext() || nodep->taskp()->dpiExport())) { - nodep->scopeNamep(new AstScopeName(nodep->fileline())); + nodep->scopeNamep(new AstScopeName{nodep->fileline(), false}); } } @@ -459,7 +459,7 @@ private: if ((VN_IS(nodep->backp(), Display) && VN_AS(nodep->backp(), Display)->displayType().needScopeTracking()) || nodep->formatScopeTracking()) { - nodep->scopeNamep(new AstScopeName(nodep->fileline())); + nodep->scopeNamep(new AstScopeName{nodep->fileline(), true}); } } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index bffbeb9d8..0fcb1d7d3 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -4493,7 +4493,7 @@ private: AstSFormatF* const newp = new AstSFormatF(nodep->fileline(), format, false, argsp); if (!newp->scopeNamep() && newp->formatScopeTracking()) { - newp->scopeNamep(new AstScopeName(newp->fileline())); + newp->scopeNamep(new AstScopeName{newp->fileline(), true}); } handle.relink(new AstArg(newp->fileline(), "", newp)); // Connection list is now incorrect (has extra args in it). diff --git a/test_regress/t/t_class_name.v b/test_regress/t/t_class_name.v index 0be89d598..cece02916 100644 --- a/test_regress/t/t_class_name.v +++ b/test_regress/t/t_class_name.v @@ -92,12 +92,10 @@ module t (/*AUTOARG*/); c = new; s = mod_func_name(); - `checks(s, "tmf top.t"); - // UNSUP `checks(s, "tmf top.t.mod_func_name"); + `checks(s, "tmf top.t.mod_func_name"); s = unit_name(); - `checks(s, "u top.$unit"); - // UNSUP `checks(s, "u top.$unit.unit_name"); + `checks(s, "u top.$unit.unit_name"); // Others: "u $unit_????::unit_name // Others: "u $unit::unit_name // Others: "u \\package UnitScopePackage_1\ .UnitScopePackage_1.unit_name @@ -105,14 +103,12 @@ module t (/*AUTOARG*/); // *** Below results vary with simulator. s = Cls::static_name(); - `checks(s, "c top.$unit.Cls"); - // UNSUP `checks(s, "c top.$unit.Cls.static_name"); + `checks(s, "c top.$unit.Cls.static_name"); // Others: "c $unit_????.Cls.static_name // Others: "c $unit::\Cls::static_name // Others: "c Cls.static_name s = c.c_auto_name(); - `checks(s, "c top.$unit.Cls"); - // UNSUP `checks(s, "c top.$unit.Cls.c_auto_name"); + `checks(s, "c top.$unit.Cls.c_auto_name"); // Others: "c $unit_????.Cls.c_auto_name // Others: "c $unit::\Cls::c_auto_name // Others: "c Cls.c_auto_name @@ -126,33 +122,28 @@ module t (/*AUTOARG*/); // Others: "p \\package P\ .Cls.static_name s = p.p_auto_name(); - `checks(s, "p top.P.Cls"); - // UNSUP `checks(s, "p top.P.Cls.p_auto_name"); + `checks(s, "p top.P.Cls.p_auto_name"); // Others: "p P.Cls.p_auto_name // Others: "p P::Cls.p_auto_name // Others: "p P::\Cls::p_auto_name // Others: "p \\package P\ .Cls.p_auto_name s = m.cls_static_name(); - `checks(s, "m top.t.m.Cls"); - // UNSUP `checks(s, "m top.t.m.Cls.static_name"); + `checks(s, "m top.t.m.Cls.static_name"); // Others: "m top.t.m.Cls.static_name // Others: "m top.t.m.\Cls::static_name s = m.cls_auto_name(); - `checks(s, "m top.t.m.Cls"); - // UNSUP `checks(s, "m top.t.m.Cls.m_auto_name"); + `checks(s, "m top.t.m.Cls.m_auto_name"); // Others: "m top.t.m.Cls.m_auto_name // Others: "m top.t.m.\Cls::m_auto_name s = m.sub.cls_static_name(); - `checks(s, "ms top.t.m.sub.Cls"); - // UNSUP `checks(s, "ms top.t.m.sub.Cls.static_name"); + `checks(s, "ms top.t.m.sub.Cls.static_name"); // Others: "ms top.t.m.sub.Cls.static_name // Others: "ms top.t.m.sub.\Cls::static_name s = m.sub.cls_auto_name(); - `checks(s, "ms top.t.m.sub.Cls"); - // UNSUP `checks(s, "ms top.t.m.sub.Cls.ms_auto_name"); + `checks(s, "ms top.t.m.sub.Cls.ms_auto_name"); // Others: "ms top.t.m.sub.Cls.ms_auto_name // Others: "ms top.t.m.sub.\Cls::ms_auto_name diff --git a/test_regress/t/t_display.out b/test_regress/t/t_display.out index 7774e9e34..375c5dfc9 100644 --- a/test_regress/t/t_display.out +++ b/test_regress/t/t_display.out @@ -1,8 +1,8 @@ [0] In top.t: Hi -[0] In top.t.sub (sub) -[0] In top.t.sub.subblock (sub) -[0] In top.t.sub2 (sub2) -[0] In top.t.sub2.subblock2 (sub2) +[0] In top.t.sub.write_m (sub) +[0] In top.t.sub.write_m.subblock (sub) +[0] In top.t.sub2.write_m (sub2) +[0] In top.t.sub2.write_m.subblock2 (sub2) [0] Back \ Quote " [0] %b=000001100 %0b=1100 %b=00000101010111011101110111100110011001100 %0b=101010111011101110111100110011001100 %b=000001010101111000001001000110100010101100111100000010010001101000101011001111000 %0b=1010101111000001001000110100010101100111100000010010001101000101011001111000 [0] %B=000001100 %0B=1100 %B=00000101010111011101110111100110011001100 %0B=101010111011101110111100110011001100 %B=000001010101111000001001000110100010101100111100000010010001101000101011001111000 %0B=1010101111000001001000110100010101100111100000010010001101000101011001111000 diff --git a/test_regress/t/t_dpi_qw_c.cpp b/test_regress/t/t_dpi_qw_c.cpp index 01a927848..49e15cf0f 100644 --- a/test_regress/t/t_dpi_qw_c.cpp +++ b/test_regress/t/t_dpi_qw_c.cpp @@ -15,13 +15,22 @@ //====================================================================== +#ifdef VERILATOR #include "Vt_dpi_qw__Dpi.h" +#else +extern "C" { +extern void set_value(const svBitVecVal* v); +extern void poke_value(int i); +} +#endif //====================================================================== // Called from our Verilog code to run the tests void poke_value(int i) { printf("poke_value(%d)\n", i); + const char* const scopeNamep = svGetNameFromScope(svGetScope()); + printf("svGetNameFromScope=\"%s\"\n", scopeNamep); // clang-format off #ifdef VERILATOR @@ -34,7 +43,7 @@ void poke_value(int i) { #endif // clang-format on - svScope scope = svGetScopeFromName("top.t.a"); + const svScope scope = svGetScopeFromName("top.t.a"); if (scope == NULL) { printf("%%Error: null scope for top.t.a\n"); return; diff --git a/test_regress/t/t_var_nonamebegin__log.out b/test_regress/t/t_var_nonamebegin__log.out index 441195db4..8e4898268 100644 --- a/test_regress/t/t_var_nonamebegin__log.out +++ b/test_regress/t/t_var_nonamebegin__log.out @@ -4,6 +4,6 @@ b2: {mod} top.t.unnamedblk2 b3n: {mod}.b3named: top.t.unnamedblk2.b3named b3: {mod} top.t.unnamedblk2.unnamedblk3 b4: {mod} top.t.unnamedblk2.unnamedblk3.unnamedblk4 -t1 {mod}.tsk top.t -t2 {mod}.tsk top.t.unnamedblk7 +t1 {mod}.tsk top.t.tsk +t2 {mod}.tsk top.t.tsk.unnamedblk7 *-* All Finished *-* From 833686446c7c5d82eec99052fbb06ab8d523ae29 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 27 Nov 2021 09:05:51 -0500 Subject: [PATCH 68/79] Commentary, ChangeLog up to date --- Changes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changes b/Changes index 186505ec4..c8dcd808d 100644 --- a/Changes +++ b/Changes @@ -20,8 +20,11 @@ Verilator 4.215 devel * Internal code cleanups and improvements. [Geza Lore] * Improve --thread verilation-time performance. * Support task name in $display %m (#3211). [Julie Schwartz] +* Make 'bit', 'logic' and 'time' types unsigned by default. [Geza Lore] * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] +* Fix wrong bit op tree optimization (#3185). [Yutetsu TAKATSUKASA] +* Fix some SliceSels not being constants (#3186) (#3218). [Michaël Lefebvre] * Fix nested generate if genblk naming (#3189). [yanx21] * Fix hang on recursive definition error (#3199). [Jonathan Kimmitt] * Fix display of signed without format (#3204). [Julie Schwartz] From 04e0c7e4f17042da3a0b1a203dc6296dddc7f717 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 27 Nov 2021 17:07:27 -0500 Subject: [PATCH 69/79] Support tracing through --hierarchical/--lib-create libraries (#3200). --- Changes | 1 + docs/guide/extensions.rst | 7 + src/V3Ast.h | 4 + src/V3AstNodes.h | 12 +- src/V3EmitCModel.cpp | 62 +- src/V3ProtectLib.cpp | 29 + src/V3Task.cpp | 5 +- src/verilog.l | 1 + src/verilog.y | 29 +- test_regress/t/t_hier_block_trace.out | 6533 ++++++++++++++++++++++++- 10 files changed, 6654 insertions(+), 29 deletions(-) diff --git a/Changes b/Changes index c8dcd808d..3362d93e7 100644 --- a/Changes +++ b/Changes @@ -14,6 +14,7 @@ Verilator 4.215 devel **Major:** * Add --lib-create, similar to --protect-lib but without protections. +* Support tracing through --hierarchical/--lib-create libraries (#3200). **Minor:** diff --git a/docs/guide/extensions.rst b/docs/guide/extensions.rst index 0b17a725e..ff79df1f4 100644 --- a/docs/guide/extensions.rst +++ b/docs/guide/extensions.rst @@ -489,6 +489,13 @@ or "`ifdef`"'s may break other tools. Verilator) text that should be passed through to the XML output as a tag, for use by downstream applications. +.. option:: /*verilator&32;trace_init_task*/ + + Attached to a DPI import to indicate that function should be called when + initializing tracing. This attribute is indented only to be used + internally in code that Verilator generates when :vlopt:`--lib-create` + or :vlopt:`--hierarchical` is used along with :vlopt:`--trace`. + .. option:: /*verilator&32;tracing_off*/ Disable waveform tracing for all future signals that are declared in diff --git a/src/V3Ast.h b/src/V3Ast.h index 873ea632e..4f5d56651 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2737,6 +2737,7 @@ private: bool m_dpiContext : 1; // DPI import context bool m_dpiOpenChild : 1; // DPI import open array child wrapper bool m_dpiTask : 1; // DPI import task (vs. void function) + bool m_dpiTraceInit : 1; // DPI trace_init bool m_isConstructor : 1; // Class constructor bool m_isHideLocal : 1; // Verilog local bool m_isHideProtected : 1; // Verilog protected @@ -2760,6 +2761,7 @@ protected: , m_dpiContext{false} , m_dpiOpenChild{false} , m_dpiTask{false} + , m_dpiTraceInit{false} , m_isConstructor{false} , m_isHideLocal{false} , m_isHideProtected{false} @@ -2822,6 +2824,8 @@ public: bool dpiOpenChild() const { return m_dpiOpenChild; } void dpiTask(bool flag) { m_dpiTask = flag; } bool dpiTask() const { return m_dpiTask; } + void dpiTraceInit(bool flag) { m_dpiTraceInit = flag; } + bool dpiTraceInit() const { return m_dpiTraceInit; } void isConstructor(bool flag) { m_isConstructor = flag; } bool isConstructor() const { return m_isConstructor; } bool isHideLocal() const { return m_isHideLocal; } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index e6f028df6..88a5ed4c0 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -8781,11 +8781,12 @@ private: bool m_isVirtual : 1; // Virtual function bool m_entryPoint : 1; // User may call into this top level function bool m_pure : 1; // Pure function + bool m_dpiContext : 1; // Declared as 'context' DPI import/export function bool m_dpiExportDispatcher : 1; // This is the DPI export entry point (i.e.: called by user) bool m_dpiExportImpl : 1; // DPI export implementation (called from DPI dispatcher via lookup) bool m_dpiImportPrototype : 1; // This is the DPI import prototype (i.e.: provided by user) bool m_dpiImportWrapper : 1; // Wrapper for invoking DPI import prototype from generated code - bool m_dpiContext : 1; // Declared as 'context' DPI import/export function + bool m_dpiTraceInit : 1; // DPI trace_init public: AstCFunc(FileLine* fl, const string& name, AstScope* scopep, const string& rtnType = "") : ASTGEN_SUPER_CFunc(fl) { @@ -8808,11 +8809,12 @@ public: m_isVirtual = false; m_entryPoint = false; m_pure = false; + m_dpiContext = false; m_dpiExportDispatcher = false; m_dpiExportImpl = false; m_dpiImportPrototype = false; m_dpiImportWrapper = false; - m_dpiContext = false; + m_dpiTraceInit = false; } ASTNODE_NODE_FUNCS(CFunc) virtual string name() const override { return m_name; } @@ -8880,6 +8882,8 @@ public: void entryPoint(bool flag) { m_entryPoint = flag; } bool pure() const { return m_pure; } void pure(bool flag) { m_pure = flag; } + bool dpiContext() const { return m_dpiContext; } + void dpiContext(bool flag) { m_dpiContext = flag; } bool dpiExportDispatcher() const { return m_dpiExportDispatcher; } void dpiExportDispatcher(bool flag) { m_dpiExportDispatcher = flag; } bool dpiExportImpl() const { return m_dpiExportImpl; } @@ -8888,8 +8892,8 @@ public: void dpiImportPrototype(bool flag) { m_dpiImportPrototype = flag; } bool dpiImportWrapper() const { return m_dpiImportWrapper; } void dpiImportWrapper(bool flag) { m_dpiImportWrapper = flag; } - bool dpiContext() const { return m_dpiContext; } - void dpiContext(bool flag) { m_dpiContext = flag; } + void dpiTraceInit(bool flag) { m_dpiTraceInit = flag; } + bool dpiTraceInit() const { return m_dpiTraceInit; } // // If adding node accessors, see below emptyBody AstNode* argsp() const { return op1p(); } diff --git a/src/V3EmitCModel.cpp b/src/V3EmitCModel.cpp index 82ef2a97e..93d84d292 100644 --- a/src/V3EmitCModel.cpp +++ b/src/V3EmitCModel.cpp @@ -23,14 +23,31 @@ #include "V3UniqueNames.h" #include +#include #include class EmitCModel final : public EmitCFunc { + // TYPES + using CFuncVector = std::vector; + + // MEMBERS V3UniqueNames m_uniqueNames; // For generating unique file names // METHODS VL_DEBUG_FUNC; + CFuncVector findFuncps(std::function cb) { + CFuncVector funcps; + for (AstNode* nodep = m_modp->stmtsp(); nodep; nodep = nodep->nextp()) { + if (const AstCFunc* const funcp = VN_CAST(nodep, CFunc)) { + if (cb(funcp)) funcps.push_back(funcp); + } + } + stable_sort(funcps.begin(), funcps.end(), + [](const AstNode* ap, const AstNode* bp) { return ap->name() < bp->name(); }); + return funcps; + } + void putSectionDelimiter(const string& name) { puts("\n"); puts("//============================================================\n"); @@ -187,22 +204,11 @@ class EmitCModel final : public EmitCFunc { // Emit DPI export dispatcher declarations { - std::vector funcps; - - for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { - if (const AstCFunc* const funcp = VN_CAST(nodep, CFunc)) { - if (!funcp->dpiExportDispatcher()) continue; - funcps.push_back(funcp); - } - } - - stable_sort(funcps.begin(), funcps.end(), [](const AstNode* ap, const AstNode* bp) { - return ap->name() < bp->name(); - }); - + const CFuncVector funcps + = findFuncps([](const AstCFunc* nodep) { return nodep->dpiExportDispatcher(); }); if (!funcps.empty()) { puts("\n/// DPI Export functions\n"); - for (const AstCFunc* funcp : funcps) { emitCFuncDecl(funcp, modp); } + for (const AstCFunc* funcp : funcps) emitCFuncDecl(funcp, modp); } } @@ -568,12 +574,38 @@ class EmitCModel final : public EmitCFunc { + topModNameProtected + "* vlSelf, " + v3Global.opt.traceClassBase() + "* tracep);\n"); + const CFuncVector traceInitFuncps + = findFuncps([](const AstCFunc* nodep) { return nodep->dpiTraceInit(); }); + for (const AstCFunc* const funcp : traceInitFuncps) emitCFuncDecl(funcp, modp); + // ::trace puts("\nVL_ATTR_COLD void " + topClassName() + "::trace("); - puts(v3Global.opt.traceClassBase() + "C* tfp, int, int) {\n"); + puts(v3Global.opt.traceClassBase() + "C* tfp, int levels, int options) {\n"); + puts(/**/ "if (false && levels && options) {} // Prevent unused\n"); puts(/**/ "tfp->spTrace()->addInitCb(&" + protect("trace_init") + ", &(vlSymsp->TOP));\n"); puts(/**/ topModNameProtected + "__" + protect("trace_register") + "(&(vlSymsp->TOP), tfp->spTrace());\n"); + + if (!traceInitFuncps.empty()) { + puts(/**/ "if (levels > 0) {\n"); + puts(/****/ "const QData tfpq = reinterpret_cast(tfp);\n"); + for (const AstCFunc* const funcp : traceInitFuncps) { + // Some hackery to locate handle__V for trace_init_task + // Considered a pragma on the handle, but that still doesn't help us attach it here + string handle = funcp->name(); + const size_t wr_len = strlen("__Vdpiimwrap_"); + UASSERT_OBJ(handle.substr(0, wr_len) == "__Vdpiimwrap_", funcp, + "Strange trace_init_task function name"); + handle = "vlSymsp->TOP." + handle.substr(wr_len); + const string::size_type pos = handle.rfind("__DOT__"); + UASSERT_OBJ(pos != string::npos, funcp, "Strange trace_init_task function name"); + handle = handle.substr(0, pos) + "__DOT__handle___05FV"; + puts(funcNameProtect(funcp, modp) + "(" + handle + + ", tfpq, levels - 1, options);\n"); + } + puts(/**/ "}\n"); + } + puts("}\n"); } diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index aa8f7230f..67280e92c 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -124,6 +124,11 @@ private: addComment(txtp, fl, "Evaluates the library module's final process"); } + void traceComment(AstTextBlock* txtp, FileLine* fl) { + addComment(txtp, fl, "Enables the library module's tracing"); + addComment(txtp, fl, "Only usable when used with called from Verilator"); + } + void createSvFile(FileLine* fl, AstNodeModule* modp) { // Comments AstTextBlock* const txtp = new AstTextBlock(fl); @@ -197,6 +202,18 @@ private: txtp->addText(fl, "import \"DPI-C\" function void " + m_libName + "_protectlib_final(chandle handle__V);\n\n"); + if (v3Global.opt.trace() && !v3Global.opt.protectIds()) { + txtp->addText(fl, "`ifdef verilator\n"); + traceComment(txtp, fl); + txtp->addText(fl, "import \"DPI-C\" function void " + m_libName + + "_protectlib_trace(chandle handle__V, " + "chandle tfp, int levels, int options)" + + " /*verilator trace_init_task*/;\n"); + // Note V3EmitCModel.cpp requires the name "handle__V". + txtp->addText(fl, "`endif // verilator\n"); + txtp->addText(fl, "\n"); + } + // Local variables // Avoid tracing handle, as it is not a stable value, so breaks vcddiff // Likewise other internals aren't interesting to the user @@ -387,6 +404,18 @@ private: txtp->addText(fl, /**/ "delete handlep__V;\n"); txtp->addText(fl, "}\n\n"); + if (v3Global.opt.trace() && !v3Global.opt.protectIds()) { + traceComment(txtp, fl); + txtp->addText(fl, "void " + m_libName + + "_protectlib_trace(void* vhandlep__V, void* tfp, int levels, " + "int options) {\n"); + castPtr(fl, txtp); + txtp->addText( + fl, + /**/ "handlep__V->trace(static_cast(tfp), levels, options);\n"); + txtp->addText(fl, "}\n\n"); + } + txtp->addText(fl, "}\n"); m_cfilep->tblockp(txtp); } diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 3b6177bcc..b9aa8ebc7 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -933,8 +933,8 @@ private: : nodep->dpiTask() ? "int" : ""; AstCFunc* const funcp = new AstCFunc(nodep->fileline(), nodep->cname(), m_scopep, rtnType); - funcp->dpiImportPrototype(true); funcp->dpiContext(nodep->dpiContext()); + funcp->dpiImportPrototype(true); funcp->dontCombine(true); funcp->entryPoint(false); funcp->isMethod(false); @@ -1201,9 +1201,10 @@ private: cfuncp->dontCombine(!nodep->dpiImport()); cfuncp->entryPoint(!nodep->dpiImport()); cfuncp->funcPublic(nodep->taskPublic()); + cfuncp->dpiContext(nodep->dpiContext()); cfuncp->dpiExportImpl(nodep->dpiExport()); cfuncp->dpiImportWrapper(nodep->dpiImport()); - cfuncp->dpiContext(nodep->dpiContext()); + cfuncp->dpiTraceInit(nodep->dpiTraceInit()); if (nodep->dpiImport() || nodep->dpiExport()) { cfuncp->isStatic(true); cfuncp->isLoose(true); diff --git a/src/verilog.l b/src/verilog.l index 166d9b0f3..31cf6481f 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -745,6 +745,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5} "/*verilator split_var*/" { FL; return yVL_SPLIT_VAR; } "/*verilator tag"[^*]*"*/" { FL; yylval.strp = PARSEP->newString(V3ParseImp::lexParseTag(yytext)); return yVL_TAG; } + "/*verilator trace_init_task*/" { FL; return yVL_TRACE_INIT_TASK; } "/*verilator tracing_off*/" { FL_FWD; PARSEP->lexFileline()->tracingOn(false); FL_BRK; } "/*verilator tracing_on*/" { FL_FWD; PARSEP->lexFileline()->tracingOn(true); FL_BRK; } diff --git a/src/verilog.y b/src/verilog.y index 18779d05e..2238e184a 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -829,6 +829,7 @@ BISONPRE_VERSION(3.7,%define api.header.include {"V3ParseBison.h"}) %token yVL_SFORMAT "/*verilator sformat*/" %token yVL_SPLIT_VAR "/*verilator split_var*/" %token yVL_TAG "/*verilator tag*/" +%token yVL_TRACE_INIT_TASK "/*verilator trace_init_task*/" %token yP_TICK "'" %token yP_TICKBRA "'{" @@ -4125,16 +4126,24 @@ array_methodWith: ; dpi_import_export: // ==IEEE: dpi_import_export - yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE function_prototype ';' - { $$ = $5; if (*$4 != "") $5->cname(*$4); - $5->dpiContext($3==iprop_CONTEXT); $5->pure($3==iprop_PURE); - $5->dpiImport(true); GRAMMARP->checkDpiVer($1,*$2); v3Global.dpi(true); + yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE function_prototype dpi_tf_TraceInitE ';' + { $$ = $5; + if (*$4 != "") $5->cname(*$4); + $5->dpiContext($3 == iprop_CONTEXT); + $5->pure($3 == iprop_PURE); + $5->dpiImport(true); + $5->dpiTraceInit($6); + GRAMMARP->checkDpiVer($1, *$2); v3Global.dpi(true); if ($$->prettyName()[0]=='$') SYMP->reinsert($$,nullptr,$$->prettyName()); // For $SysTF overriding SYMP->reinsert($$); } | yIMPORT yaSTRING dpi_tf_import_propertyE dpi_importLabelE task_prototype ';' - { $$ = $5; if (*$4 != "") $5->cname(*$4); - $5->dpiContext($3==iprop_CONTEXT); $5->pure($3==iprop_PURE); - $5->dpiImport(true); $5->dpiTask(true); GRAMMARP->checkDpiVer($1,*$2); v3Global.dpi(true); + { $$ = $5; + if (*$4 != "") $5->cname(*$4); + $5->dpiContext($3 == iprop_CONTEXT); + $5->pure($3 == iprop_PURE); + $5->dpiImport(true); + $5->dpiTask(true); + GRAMMARP->checkDpiVer($1, *$2); v3Global.dpi(true); if ($$->prettyName()[0]=='$') SYMP->reinsert($$,nullptr,$$->prettyName()); // For $SysTF overriding SYMP->reinsert($$); } | yEXPORT yaSTRING dpi_importLabelE yFUNCTION idAny ';' @@ -4156,6 +4165,12 @@ dpi_tf_import_propertyE: // IEEE: [ dpi_function_import_property + dpi_ta | yPURE { $$ = iprop_PURE; } ; +dpi_tf_TraceInitE: // Verilator extension + /* empty */ { $$ = false; } + | yVL_TRACE_INIT_TASK { $$ = true; $$ = $1; } + ; + + //************************************************ // Expressions // diff --git a/test_regress/t/t_hier_block_trace.out b/test_regress/t/t_hier_block_trace.out index 91473c385..cd600aaa9 100644 --- a/test_regress/t/t_hier_block_trace.out +++ b/test_regress/t/t_hier_block_trace.out @@ -1,5 +1,5 @@ $version Generated by VerilatedVcd $end -$date Sun Nov 14 10:12:01 2021 $end +$date Sat Nov 27 16:51:43 2021 $end $timescale 1ps $end $scope module top $end @@ -56,6 +56,963 @@ $timescale 1ps $end $upscope $end $upscope $end $upscope $end + $scope module top.t.i_delay0 $end + $var wire 1 - clk $end + $var wire 8 . in [7:0] $end + $var wire 8 / out [7:0] $end + $scope module delay_2 $end + $var wire 32 2 WIDTH [31:0] $end + $var wire 1 - clk $end + $var wire 8 . in [7:0] $end + $var wire 8 / out [7:0] $end + $var wire 8 0 tmp [7:0] $end + $scope module genblk1 $end + $scope module i_delay $end + $var wire 32 3 N [31:0] $end + $var wire 32 2 WIDTH [31:0] $end + $var wire 1 - clk $end + $var wire 8 0 in [7:0] $end + $var wire 8 / out [7:0] $end + $var wire 8 1 tmp [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_delay1 $end + $var wire 1 8 clk $end + $var wire 8 9 in [7:0] $end + $var wire 8 : out [7:0] $end + $scope module delay_9 $end + $var wire 32 ; WIDTH [31:0] $end + $var wire 1 8 clk $end + $var wire 8 9 in [7:0] $end + $var wire 8 : out [7:0] $end + $var wire 8 5 tmp [7:0] $end + $scope module genblk1 $end + $scope module i_delay $end + $var wire 32 < N [31:0] $end + $var wire 32 ; WIDTH [31:0] $end + $var wire 1 8 clk $end + $var wire 8 5 in [7:0] $end + $var wire 8 : out [7:0] $end + $var wire 8 6 tmp [7:0] $end + $scope module genblk1 $end + $scope module i_delay $end + $var wire 32 = N [31:0] $end + $var wire 32 ; WIDTH [31:0] $end + $var wire 1 8 clk $end + $var wire 8 6 in [7:0] $end + $var wire 8 : out [7:0] $end + $var wire 8 7 tmp [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub0.i_sub0 $end + $var wire 1 ? clk $end + $var wire 8 @ in [7:0] $end + $var wire 8 A out [7:0] $end + $scope module sub0 $end + $var wire 1 ? clk $end + $var wire 8 B ff [7:0] $end + $var wire 8 @ in [7:0] $end + $var wire 8 A out [7:0] $end + $upscope $end + $upscope $end + $scope module top.t.i_sub1 $end + $var wire 1 D clk $end + $var wire 8 E in [7:0] $end + $var wire 8 F out [7:0] $end + $scope module sub1 $end + $var wire 1 D clk $end + $var wire 8 G ff [7:0] $end + $var wire 8 E in [7:0] $end + $var wire 8 F out [7:0] $end + $upscope $end + $upscope $end + $scope module top.t.i_sub2 $end + $var wire 1 I clk $end + $var wire 8 J in [7:0] $end + $var wire 8 K out [7:0] $end + $scope module sub2 $end + $var wire 1 I clk $end + $var wire 8 L ff [7:0] $end + $var wire 8 J in [7:0] $end + $var wire 8 K out [7:0] $end + $scope module i_sub3 $end + $var wire 8 L in_wire [7:0] $end + $var wire 8 M out_1 [7:0] $end + $var wire 8 N out_2 [7:0] $end + $scope module i_sub3 $end + $var wire 1 I clk $end + $var wire 8 L in [7:0] $end + $var wire 8 M out [7:0] $end + $upscope $end + $scope module i_sub3_2 $end + $var wire 1 I clk $end + $var wire 8 L in [7:0] $end + $var wire 8 N out [7:0] $end + $upscope $end + $scope interface in $end + $var wire 1 I clk $end + $var wire 8 L data [7:0] $end + $upscope $end + $scope interface out $end + $var wire 1 I clk $end + $var wire 8 M data [7:0] $end + $upscope $end + $upscope $end + $scope interface in_ifs $end + $var wire 1 I clk $end + $var wire 8 L data [7:0] $end + $upscope $end + $scope interface out_ifs $end + $var wire 1 I clk $end + $var wire 8 M data [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub2.sub2.i_sub3.i_sub3 $end + $var wire 1 P clk $end + $var wire 8 Q in [7:0] $end + $var wire 8 R out [7:0] $end + $scope module sub3_c $end + $var wire 32 V UNPACKED_ARRAY[0] [31:0] $end + $var wire 32 W UNPACKED_ARRAY[1] [31:0] $end + $var wire 1 P clk $end + $var wire 8 S ff [7:0] $end + $var wire 8 Q in [7:0] $end + $var wire 8 R out [7:0] $end + $var wire 8 T out4 [7:0] $end + $var wire 8 U out4_2 [7:0] $end + $scope module i_sub4_0 $end + $var wire 1 P clk $end + $var wire 8 S in [7:0] $end + $var wire 8 T out [7:0] $end + $upscope $end + $scope module i_sub4_1 $end + $var wire 1 P clk $end + $var wire 8 S in [7:0] $end + $var wire 8 U out [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub2.sub2.i_sub3.i_sub3.sub3_c.i_sub4_0 $end + $var wire 1 ! out [7:0] $end + $scope module sub4_2 $end + $var wire 1 ! out [7:0] $end + $var wire 128 Z sub5_in[0][0] [127:0] $end + $var wire 128 ^ sub5_in[0][1] [127:0] $end + $var wire 128 b sub5_in[0][2] [127:0] $end + $var wire 128 f sub5_in[1][0] [127:0] $end + $var wire 128 j sub5_in[1][1] [127:0] $end + $var wire 128 n sub5_in[1][2] [127:0] $end + $var wire 8 0! sub5_out[0][0] [7:0] $end + $var wire 8 1! sub5_out[0][1] [7:0] $end + $var wire 8 2! sub5_out[0][2] [7:0] $end + $var wire 8 3! sub5_out[1][0] [7:0] $end + $var wire 8 4! sub5_out[1][1] [7:0] $end + $var wire 8 5! sub5_out[1][2] [7:0] $end + $scope module i_sub5 $end + $var wire 1 & UNPACKED_ARRAY[1] [31:0] $end + $var wire 16 ?& UNUSED [15:0] $end + $var wire 1 7& clk $end + $var wire 8 :& ff [7:0] $end + $var wire 8 8& in [7:0] $end + $var wire 8 9& out [7:0] $end + $var wire 8 ;& out4 [7:0] $end + $var wire 8 <& out4_2 [7:0] $end + $scope module i_sub4_0 $end + $var wire 1 7& clk $end + $var wire 8 :& in [7:0] $end + $var wire 8 ;& out [7:0] $end + $upscope $end + $scope module i_sub4_1 $end + $var wire 1 7& clk $end + $var wire 8 :& in [7:0] $end + $var wire 8 <& out [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3.sub3_d.i_sub4_0 $end + $var wire 1 $' clk $end + $var wire 8 %' in [7:0] $end + $var wire 8 &' out [7:0] $end + $scope module sub4_2 $end + $var wire 1 $' clk $end + $var wire 32 Z& count [31:0] $end + $var wire 8 A& ff [7:0] $end + $var wire 8 %' in [7:0] $end + $var wire 8 &' out [7:0] $end + $var wire 128 B& sub5_in[0][0] [127:0] $end + $var wire 128 F& sub5_in[0][1] [127:0] $end + $var wire 128 J& sub5_in[0][2] [127:0] $end + $var wire 128 N& sub5_in[1][0] [127:0] $end + $var wire 128 R& sub5_in[1][1] [127:0] $end + $var wire 128 V& sub5_in[1][2] [127:0] $end + $var wire 8 v& sub5_out[0][0] [7:0] $end + $var wire 8 w& sub5_out[0][1] [7:0] $end + $var wire 8 x& sub5_out[0][2] [7:0] $end + $var wire 8 y& sub5_out[1][0] [7:0] $end + $var wire 8 z& sub5_out[1][1] [7:0] $end + $var wire 8 {& sub5_out[1][2] [7:0] $end + $scope module i_sub5 $end + $var wire 1 $' clk $end + $var wire 128 ^& in[0][0] [127:0] $end + $var wire 128 b& in[0][1] [127:0] $end + $var wire 128 f& in[0][2] [127:0] $end + $var wire 128 j& in[1][0] [127:0] $end + $var wire 128 n& in[1][1] [127:0] $end + $var wire 128 r& in[1][2] [127:0] $end + $var wire 8 |& out[0][0] [7:0] $end + $var wire 8 }& out[0][1] [7:0] $end + $var wire 8 ~& out[0][2] [7:0] $end + $var wire 8 !' out[1][0] [7:0] $end + $var wire 8 "' out[1][1] [7:0] $end + $var wire 8 #' out[1][2] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 [& i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 \& j [31:0] $end + $scope module unnamedblk3 $end + $var wire 8 ]& exp [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3.sub3_d.i_sub4_0.sub4_2.i_sub5 $end + $var wire 1 ?' clk $end + $var wire 128 @' in[0][0] [127:0] $end + $var wire 128 D' in[0][1] [127:0] $end + $var wire 128 H' in[0][2] [127:0] $end + $var wire 128 L' in[1][0] [127:0] $end + $var wire 128 P' in[1][1] [127:0] $end + $var wire 128 T' in[1][2] [127:0] $end + $var wire 8 X' out[0][0] [7:0] $end + $var wire 8 Y' out[0][1] [7:0] $end + $var wire 8 Z' out[0][2] [7:0] $end + $var wire 8 [' out[1][0] [7:0] $end + $var wire 8 \' out[1][1] [7:0] $end + $var wire 8 ]' out[1][2] [7:0] $end + $scope module sub5 $end + $var wire 1 ?' clk $end + $var wire 32 8' count [31:0] $end + $var wire 128 @' in[0][0] [127:0] $end + $var wire 128 D' in[0][1] [127:0] $end + $var wire 128 H' in[0][2] [127:0] $end + $var wire 128 L' in[1][0] [127:0] $end + $var wire 128 P' in[1][1] [127:0] $end + $var wire 128 T' in[1][2] [127:0] $end + $var wire 8 X' out[0][0] [7:0] $end + $var wire 8 Y' out[0][1] [7:0] $end + $var wire 8 Z' out[0][2] [7:0] $end + $var wire 8 [' out[1][0] [7:0] $end + $var wire 8 \' out[1][1] [7:0] $end + $var wire 8 ]' out[1][2] [7:0] $end + $var wire 8 (' val0[0] [7:0] $end + $var wire 8 )' val0[1] [7:0] $end + $var wire 8 *' val1[0] [7:0] $end + $var wire 8 +' val1[1] [7:0] $end + $var wire 8 ,' val2[0] [7:0] $end + $var wire 8 -' val2[1] [7:0] $end + $var wire 8 .' val3[0] [7:0] $end + $var wire 8 /' val3[1] [7:0] $end + $scope module i_sub0 $end + $var wire 32 ^' P0 [31:0] $end + $var wire 32 _' P1 [31:0] $end + $var wire 8 0' out[0] [7:0] $end + $var wire 8 1' out[1] [7:0] $end + $upscope $end + $scope module i_sub1 $end + $var wire 32 ^' P0 [31:0] $end + $var wire 32 _' P1 [31:0] $end + $var wire 8 2' out[0] [7:0] $end + $var wire 8 3' out[1] [7:0] $end + $upscope $end + $scope module i_sub2 $end + $var wire 32 ^' P0 [31:0] $end + $var wire 32 _' P1 [31:0] $end + $var wire 8 4' out[0] [7:0] $end + $var wire 8 5' out[1] [7:0] $end + $upscope $end + $scope module i_sub3 $end + $var wire 8 6' out[0] [7:0] $end + $var wire 8 7' out[1] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 9' i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 :' j [31:0] $end + $scope module unnamedblk3 $end + $var wire 128 ;' exp [127:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3.sub3_d.i_sub4_0.sub4_2.i_sub5.sub5.i_sub3 $end + $var wire 8 a' out[0] [7:0] $end + $var wire 8 b' out[1] [7:0] $end + $scope module sub6_9 $end + $var wire 32 c' P0 [31:0] $end + $var wire 8 a' out[0] [7:0] $end + $var wire 8 b' out[1] [7:0] $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3.sub3_d.i_sub4_1 $end + $var wire 1 H( clk $end + $var wire 8 I( in [7:0] $end + $var wire 8 J( out [7:0] $end + $scope module sub4_b $end + $var wire 1 H( clk $end + $var wire 32 ~' count [31:0] $end + $var wire 8 e' ff [7:0] $end + $var wire 8 I( in [7:0] $end + $var wire 8 J( out [7:0] $end + $var wire 128 f' sub5_in[0][0] [127:0] $end + $var wire 128 j' sub5_in[0][1] [127:0] $end + $var wire 128 n' sub5_in[0][2] [127:0] $end + $var wire 128 r' sub5_in[1][0] [127:0] $end + $var wire 128 v' sub5_in[1][1] [127:0] $end + $var wire 128 z' sub5_in[1][2] [127:0] $end + $var wire 8 <( sub5_out[0][0] [7:0] $end + $var wire 8 =( sub5_out[0][1] [7:0] $end + $var wire 8 >( sub5_out[0][2] [7:0] $end + $var wire 8 ?( sub5_out[1][0] [7:0] $end + $var wire 8 @( sub5_out[1][1] [7:0] $end + $var wire 8 A( sub5_out[1][2] [7:0] $end + $scope module i_sub5 $end + $var wire 1 H( clk $end + $var wire 128 $( in[0][0] [127:0] $end + $var wire 128 (( in[0][1] [127:0] $end + $var wire 128 ,( in[0][2] [127:0] $end + $var wire 128 0( in[1][0] [127:0] $end + $var wire 128 4( in[1][1] [127:0] $end + $var wire 128 8( in[1][2] [127:0] $end + $var wire 8 B( out[0][0] [7:0] $end + $var wire 8 C( out[0][1] [7:0] $end + $var wire 8 D( out[0][2] [7:0] $end + $var wire 8 E( out[1][0] [7:0] $end + $var wire 8 F( out[1][1] [7:0] $end + $var wire 8 G( out[1][2] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 !( i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 "( j [31:0] $end + $scope module unnamedblk3 $end + $var wire 8 #( exp [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3.sub3_d.i_sub4_1.sub4_b.i_sub5 $end + $var wire 1 c( clk $end + $var wire 128 d( in[0][0] [127:0] $end + $var wire 128 h( in[0][1] [127:0] $end + $var wire 128 l( in[0][2] [127:0] $end + $var wire 128 p( in[1][0] [127:0] $end + $var wire 128 t( in[1][1] [127:0] $end + $var wire 128 x( in[1][2] [127:0] $end + $var wire 8 |( out[0][0] [7:0] $end + $var wire 8 }( out[0][1] [7:0] $end + $var wire 8 ~( out[0][2] [7:0] $end + $var wire 8 !) out[1][0] [7:0] $end + $var wire 8 ") out[1][1] [7:0] $end + $var wire 8 #) out[1][2] [7:0] $end + $scope module sub5 $end + $var wire 1 c( clk $end + $var wire 32 \( count [31:0] $end + $var wire 128 d( in[0][0] [127:0] $end + $var wire 128 h( in[0][1] [127:0] $end + $var wire 128 l( in[0][2] [127:0] $end + $var wire 128 p( in[1][0] [127:0] $end + $var wire 128 t( in[1][1] [127:0] $end + $var wire 128 x( in[1][2] [127:0] $end + $var wire 8 |( out[0][0] [7:0] $end + $var wire 8 }( out[0][1] [7:0] $end + $var wire 8 ~( out[0][2] [7:0] $end + $var wire 8 !) out[1][0] [7:0] $end + $var wire 8 ") out[1][1] [7:0] $end + $var wire 8 #) out[1][2] [7:0] $end + $var wire 8 L( val0[0] [7:0] $end + $var wire 8 M( val0[1] [7:0] $end + $var wire 8 N( val1[0] [7:0] $end + $var wire 8 O( val1[1] [7:0] $end + $var wire 8 P( val2[0] [7:0] $end + $var wire 8 Q( val2[1] [7:0] $end + $var wire 8 R( val3[0] [7:0] $end + $var wire 8 S( val3[1] [7:0] $end + $scope module i_sub0 $end + $var wire 32 $) P0 [31:0] $end + $var wire 32 %) P1 [31:0] $end + $var wire 8 T( out[0] [7:0] $end + $var wire 8 U( out[1] [7:0] $end + $upscope $end + $scope module i_sub1 $end + $var wire 32 $) P0 [31:0] $end + $var wire 32 %) P1 [31:0] $end + $var wire 8 V( out[0] [7:0] $end + $var wire 8 W( out[1] [7:0] $end + $upscope $end + $scope module i_sub2 $end + $var wire 32 $) P0 [31:0] $end + $var wire 32 %) P1 [31:0] $end + $var wire 8 X( out[0] [7:0] $end + $var wire 8 Y( out[1] [7:0] $end + $upscope $end + $scope module i_sub3 $end + $var wire 8 Z( out[0] [7:0] $end + $var wire 8 [( out[1] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 ]( i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 ^( j [31:0] $end + $scope module unnamedblk3 $end + $var wire 128 _( exp [127:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3.sub3_d.i_sub4_1.sub4_b.i_sub5.sub5.i_sub3 $end + $var wire 8 ') out[0] [7:0] $end + $var wire 8 () out[1] [7:0] $end + $scope module sub6_9 $end + $var wire 32 )) P0 [31:0] $end + $var wire 8 ') out[0] [7:0] $end + $var wire 8 () out[1] [7:0] $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2 $end + $var wire 1 C# clk $end + $var wire 8 D# in [7:0] $end + $var wire 8 E# out [7:0] $end + $scope module sub3_2 $end + $var wire 32 I# UNPACKED_ARRAY[0] [31:0] $end + $var wire 32 J# UNPACKED_ARRAY[1] [31:0] $end + $var wire 16 K# UNUSED [15:0] $end + $var wire 1 C# clk $end + $var wire 8 F# ff [7:0] $end + $var wire 8 D# in [7:0] $end + $var wire 8 E# out [7:0] $end + $var wire 8 G# out4 [7:0] $end + $var wire 8 H# out4_2 [7:0] $end + $scope module i_sub4_0 $end + $var wire 1 C# clk $end + $var wire 8 F# in [7:0] $end + $var wire 8 G# out [7:0] $end + $upscope $end + $scope module i_sub4_1 $end + $var wire 1 C# clk $end + $var wire 8 F# in [7:0] $end + $var wire 8 H# out [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2.sub3_2.i_sub4_0 $end + $var wire 1 0$ clk $end + $var wire 8 1$ in [7:0] $end + $var wire 8 2$ out [7:0] $end + $scope module sub4_2 $end + $var wire 1 0$ clk $end + $var wire 32 f# count [31:0] $end + $var wire 8 M# ff [7:0] $end + $var wire 8 1$ in [7:0] $end + $var wire 8 2$ out [7:0] $end + $var wire 128 N# sub5_in[0][0] [127:0] $end + $var wire 128 R# sub5_in[0][1] [127:0] $end + $var wire 128 V# sub5_in[0][2] [127:0] $end + $var wire 128 Z# sub5_in[1][0] [127:0] $end + $var wire 128 ^# sub5_in[1][1] [127:0] $end + $var wire 128 b# sub5_in[1][2] [127:0] $end + $var wire 8 $$ sub5_out[0][0] [7:0] $end + $var wire 8 %$ sub5_out[0][1] [7:0] $end + $var wire 8 &$ sub5_out[0][2] [7:0] $end + $var wire 8 '$ sub5_out[1][0] [7:0] $end + $var wire 8 ($ sub5_out[1][1] [7:0] $end + $var wire 8 )$ sub5_out[1][2] [7:0] $end + $scope module i_sub5 $end + $var wire 1 0$ clk $end + $var wire 128 j# in[0][0] [127:0] $end + $var wire 128 n# in[0][1] [127:0] $end + $var wire 128 r# in[0][2] [127:0] $end + $var wire 128 v# in[1][0] [127:0] $end + $var wire 128 z# in[1][1] [127:0] $end + $var wire 128 ~# in[1][2] [127:0] $end + $var wire 8 *$ out[0][0] [7:0] $end + $var wire 8 +$ out[0][1] [7:0] $end + $var wire 8 ,$ out[0][2] [7:0] $end + $var wire 8 -$ out[1][0] [7:0] $end + $var wire 8 .$ out[1][1] [7:0] $end + $var wire 8 /$ out[1][2] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 g# i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 h# j [31:0] $end + $scope module unnamedblk3 $end + $var wire 8 i# exp [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2.sub3_2.i_sub4_0.sub4_2.i_sub5 $end + $var wire 1 K$ clk $end + $var wire 128 L$ in[0][0] [127:0] $end + $var wire 128 P$ in[0][1] [127:0] $end + $var wire 128 T$ in[0][2] [127:0] $end + $var wire 128 X$ in[1][0] [127:0] $end + $var wire 128 \$ in[1][1] [127:0] $end + $var wire 128 `$ in[1][2] [127:0] $end + $var wire 8 d$ out[0][0] [7:0] $end + $var wire 8 e$ out[0][1] [7:0] $end + $var wire 8 f$ out[0][2] [7:0] $end + $var wire 8 g$ out[1][0] [7:0] $end + $var wire 8 h$ out[1][1] [7:0] $end + $var wire 8 i$ out[1][2] [7:0] $end + $scope module sub5 $end + $var wire 1 K$ clk $end + $var wire 32 D$ count [31:0] $end + $var wire 128 L$ in[0][0] [127:0] $end + $var wire 128 P$ in[0][1] [127:0] $end + $var wire 128 T$ in[0][2] [127:0] $end + $var wire 128 X$ in[1][0] [127:0] $end + $var wire 128 \$ in[1][1] [127:0] $end + $var wire 128 `$ in[1][2] [127:0] $end + $var wire 8 d$ out[0][0] [7:0] $end + $var wire 8 e$ out[0][1] [7:0] $end + $var wire 8 f$ out[0][2] [7:0] $end + $var wire 8 g$ out[1][0] [7:0] $end + $var wire 8 h$ out[1][1] [7:0] $end + $var wire 8 i$ out[1][2] [7:0] $end + $var wire 8 4$ val0[0] [7:0] $end + $var wire 8 5$ val0[1] [7:0] $end + $var wire 8 6$ val1[0] [7:0] $end + $var wire 8 7$ val1[1] [7:0] $end + $var wire 8 8$ val2[0] [7:0] $end + $var wire 8 9$ val2[1] [7:0] $end + $var wire 8 :$ val3[0] [7:0] $end + $var wire 8 ;$ val3[1] [7:0] $end + $scope module i_sub0 $end + $var wire 32 j$ P0 [31:0] $end + $var wire 32 k$ P1 [31:0] $end + $var wire 8 <$ out[0] [7:0] $end + $var wire 8 =$ out[1] [7:0] $end + $upscope $end + $scope module i_sub1 $end + $var wire 32 j$ P0 [31:0] $end + $var wire 32 k$ P1 [31:0] $end + $var wire 8 >$ out[0] [7:0] $end + $var wire 8 ?$ out[1] [7:0] $end + $upscope $end + $scope module i_sub2 $end + $var wire 32 j$ P0 [31:0] $end + $var wire 32 k$ P1 [31:0] $end + $var wire 8 @$ out[0] [7:0] $end + $var wire 8 A$ out[1] [7:0] $end + $upscope $end + $scope module i_sub3 $end + $var wire 8 B$ out[0] [7:0] $end + $var wire 8 C$ out[1] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 E$ i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 F$ j [31:0] $end + $scope module unnamedblk3 $end + $var wire 128 G$ exp [127:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2.sub3_2.i_sub4_0.sub4_2.i_sub5.sub5.i_sub3 $end + $var wire 8 m$ out[0] [7:0] $end + $var wire 8 n$ out[1] [7:0] $end + $scope module sub6_9 $end + $var wire 32 o$ P0 [31:0] $end + $var wire 8 m$ out[0] [7:0] $end + $var wire 8 n$ out[1] [7:0] $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2.sub3_2.i_sub4_1 $end + $var wire 1 T% clk $end + $var wire 8 U% in [7:0] $end + $var wire 8 V% out [7:0] $end + $scope module sub4_b $end + $var wire 1 T% clk $end + $var wire 32 ,% count [31:0] $end + $var wire 8 q$ ff [7:0] $end + $var wire 8 U% in [7:0] $end + $var wire 8 V% out [7:0] $end + $var wire 128 r$ sub5_in[0][0] [127:0] $end + $var wire 128 v$ sub5_in[0][1] [127:0] $end + $var wire 128 z$ sub5_in[0][2] [127:0] $end + $var wire 128 ~$ sub5_in[1][0] [127:0] $end + $var wire 128 $% sub5_in[1][1] [127:0] $end + $var wire 128 (% sub5_in[1][2] [127:0] $end + $var wire 8 H% sub5_out[0][0] [7:0] $end + $var wire 8 I% sub5_out[0][1] [7:0] $end + $var wire 8 J% sub5_out[0][2] [7:0] $end + $var wire 8 K% sub5_out[1][0] [7:0] $end + $var wire 8 L% sub5_out[1][1] [7:0] $end + $var wire 8 M% sub5_out[1][2] [7:0] $end + $scope module i_sub5 $end + $var wire 1 T% clk $end + $var wire 128 0% in[0][0] [127:0] $end + $var wire 128 4% in[0][1] [127:0] $end + $var wire 128 8% in[0][2] [127:0] $end + $var wire 128 <% in[1][0] [127:0] $end + $var wire 128 @% in[1][1] [127:0] $end + $var wire 128 D% in[1][2] [127:0] $end + $var wire 8 N% out[0][0] [7:0] $end + $var wire 8 O% out[0][1] [7:0] $end + $var wire 8 P% out[0][2] [7:0] $end + $var wire 8 Q% out[1][0] [7:0] $end + $var wire 8 R% out[1][1] [7:0] $end + $var wire 8 S% out[1][2] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 -% i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 .% j [31:0] $end + $scope module unnamedblk3 $end + $var wire 8 /% exp [7:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2.sub3_2.i_sub4_1.sub4_b.i_sub5 $end + $var wire 1 o% clk $end + $var wire 128 p% in[0][0] [127:0] $end + $var wire 128 t% in[0][1] [127:0] $end + $var wire 128 x% in[0][2] [127:0] $end + $var wire 128 |% in[1][0] [127:0] $end + $var wire 128 "& in[1][1] [127:0] $end + $var wire 128 && in[1][2] [127:0] $end + $var wire 8 *& out[0][0] [7:0] $end + $var wire 8 +& out[0][1] [7:0] $end + $var wire 8 ,& out[0][2] [7:0] $end + $var wire 8 -& out[1][0] [7:0] $end + $var wire 8 .& out[1][1] [7:0] $end + $var wire 8 /& out[1][2] [7:0] $end + $scope module sub5 $end + $var wire 1 o% clk $end + $var wire 32 h% count [31:0] $end + $var wire 128 p% in[0][0] [127:0] $end + $var wire 128 t% in[0][1] [127:0] $end + $var wire 128 x% in[0][2] [127:0] $end + $var wire 128 |% in[1][0] [127:0] $end + $var wire 128 "& in[1][1] [127:0] $end + $var wire 128 && in[1][2] [127:0] $end + $var wire 8 *& out[0][0] [7:0] $end + $var wire 8 +& out[0][1] [7:0] $end + $var wire 8 ,& out[0][2] [7:0] $end + $var wire 8 -& out[1][0] [7:0] $end + $var wire 8 .& out[1][1] [7:0] $end + $var wire 8 /& out[1][2] [7:0] $end + $var wire 8 X% val0[0] [7:0] $end + $var wire 8 Y% val0[1] [7:0] $end + $var wire 8 Z% val1[0] [7:0] $end + $var wire 8 [% val1[1] [7:0] $end + $var wire 8 \% val2[0] [7:0] $end + $var wire 8 ]% val2[1] [7:0] $end + $var wire 8 ^% val3[0] [7:0] $end + $var wire 8 _% val3[1] [7:0] $end + $scope module i_sub0 $end + $var wire 32 0& P0 [31:0] $end + $var wire 32 1& P1 [31:0] $end + $var wire 8 `% out[0] [7:0] $end + $var wire 8 a% out[1] [7:0] $end + $upscope $end + $scope module i_sub1 $end + $var wire 32 0& P0 [31:0] $end + $var wire 32 1& P1 [31:0] $end + $var wire 8 b% out[0] [7:0] $end + $var wire 8 c% out[1] [7:0] $end + $upscope $end + $scope module i_sub2 $end + $var wire 32 0& P0 [31:0] $end + $var wire 32 1& P1 [31:0] $end + $var wire 8 d% out[0] [7:0] $end + $var wire 8 e% out[1] [7:0] $end + $upscope $end + $scope module i_sub3 $end + $var wire 8 f% out[0] [7:0] $end + $var wire 8 g% out[1] [7:0] $end + $upscope $end + $scope module unnamedblk1 $end + $var wire 32 i% i [31:0] $end + $scope module unnamedblk2 $end + $var wire 32 j% j [31:0] $end + $scope module unnamedblk3 $end + $var wire 128 k% exp [127:0] $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $upscope $end + $scope module top.t.i_sub3_2.sub3_2.i_sub4_1.sub4_b.i_sub5.sub5.i_sub3 $end + $var wire 8 3& out[0] [7:0] $end + $var wire 8 4& out[1] [7:0] $end + $scope module sub6_9 $end + $var wire 32 5& P0 [31:0] $end + $var wire 8 3& out[0] [7:0] $end + $var wire 8 4& out[1] [7:0] $end + $upscope $end + $upscope $end $enddefinitions $end @@ -69,6 +1026,482 @@ b00000000 ( 0) b00000000 * b00000000000000000000000000000000 + +0- +b00000000 . +b00000000 / +b00000000 0 +b00000000 1 +b00000000000000000000000000001000 2 +b00000000000000000000000000000001 3 +b00000000 5 +b00000000 6 +b00000000 7 +08 +b00000000 9 +b00000000 : +b00000000000000000000000000001000 ; +b00000000000000000000000000000010 < +b00000000000000000000000000000001 = +0? +b00000000 @ +b00000000 A +b00000000 B +0D +b00000000 E +b00000000 F +b00000000 G +0I +b00000000 J +b00000000 K +b00000000 L +b00000000 M +b00000000 N +0P +b00000000 Q +b00000000 R +b00000000 S +b00000000 T +b00000000 U +b00000000000000000000000000000000 V +b00000000000000000000000000000001 W +b00000000 Y +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n +b00000000000000000000000000000000 r +b00000000000000000000000000000000 s +b00000000000000000000000000000000 t +b00000000 u +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,! +b00000000 0! +b00000000 1! +b00000000 2! +b00000000 3! +b00000000 4! +b00000000 5! +b00000000 6! +b00000000 7! +b00000000 8! +b00000000 9! +b00000000 :! +b00000000 ;! +0! +b00000001 @! +b00000010 A! +b00000001 B! +b00000010 C! +b00000001 D! +b00000010 E! +b00000001 F! +b00000011 G! +b00000001 H! +b00000010 I! +b00000001 J! +b00000010 K! +b00000001 L! +b00000010 M! +b00000001 N! +b00000011 O! +b00000000000000000000000000000000 P! +b00000000000000000000000000000000 Q! +b00000000000000000000000000000000 R! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +0W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00000000000000000000000000000001 v! +b00000000000000000000000000000010 w! +b00000001 y! +b00000011 z! +b00000000000000000000000000000001 {! +b00000000 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000000000 8" +b00000000000000000000000000000000 9" +b00000000000000000000000000000000 :" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +0`" +b00000000 a" +b00000000 b" +b00000001 d" +b00000010 e" +b00000001 f" +b00000010 g" +b00000001 h" +b00000010 i" +b00000001 j" +b00000011 k" +b00000001 l" +b00000010 m" +b00000001 n" +b00000010 o" +b00000001 p" +b00000010 q" +b00000001 r" +b00000011 s" +b00000000000000000000000000000000 t" +b00000000000000000000000000000000 u" +b00000000000000000000000000000000 v" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +0{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +b00000000000000000000000000000001 <# +b00000000000000000000000000000010 =# +b00000001 ?# +b00000011 @# +b00000000000000000000000000000001 A# +0C# +b00000000 D# +b00000000 E# +b00000000 F# +b00000000 G# +b00000000 H# +b00000000000000000000000000000000 I# +b00000000000000000000000000000001 J# +b1111111111111101 K# +b00000000 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000000000 f# +b00000000000000000000000000000000 g# +b00000000000000000000000000000000 h# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +00$ +b00000000 1$ +b00000000 2$ +b00000001 4$ +b00000010 5$ +b00000001 6$ +b00000010 7$ +b00000001 8$ +b00000010 9$ +b00000001 :$ +b00000011 ;$ +b00000001 <$ +b00000010 =$ +b00000001 >$ +b00000010 ?$ +b00000001 @$ +b00000010 A$ +b00000001 B$ +b00000011 C$ +b00000000000000000000000000000000 D$ +b00000000000000000000000000000000 E$ +b00000000000000000000000000000000 F$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +0K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00000000000000000000000000000001 j$ +b00000000000000000000000000000010 k$ +b00000001 m$ +b00000011 n$ +b00000000000000000000000000000001 o$ +b00000000 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000000000 ,% +b00000000000000000000000000000000 -% +b00000000000000000000000000000000 .% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +0T% +b00000000 U% +b00000000 V% +b00000001 X% +b00000010 Y% +b00000001 Z% +b00000010 [% +b00000001 \% +b00000010 ]% +b00000001 ^% +b00000011 _% +b00000001 `% +b00000010 a% +b00000001 b% +b00000010 c% +b00000001 d% +b00000010 e% +b00000001 f% +b00000011 g% +b00000000000000000000000000000000 h% +b00000000000000000000000000000000 i% +b00000000000000000000000000000000 j% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +0o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +b00000000000000000000000000000001 0& +b00000000000000000000000000000010 1& +b00000001 3& +b00000011 4& +b00000000000000000000000000000001 5& +07& +b00000000 8& +b00000000 9& +b00000000 :& +b00000000 ;& +b00000000 <& +b00000000000000000000000000000000 =& +b00000000000000000000000000000001 >& +b1111111111111101 ?& +b00000000 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 B& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000000000 Z& +b00000000000000000000000000000000 [& +b00000000000000000000000000000000 \& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +0$' +b00000000 %' +b00000000 &' +b00000001 (' +b00000010 )' +b00000001 *' +b00000010 +' +b00000001 ,' +b00000010 -' +b00000001 .' +b00000011 /' +b00000001 0' +b00000010 1' +b00000001 2' +b00000010 3' +b00000001 4' +b00000010 5' +b00000001 6' +b00000011 7' +b00000000000000000000000000000000 8' +b00000000000000000000000000000000 9' +b00000000000000000000000000000000 :' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +0?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00000000000000000000000000000001 ^' +b00000000000000000000000000000010 _' +b00000001 a' +b00000011 b' +b00000000000000000000000000000001 c' +b00000000 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000000000 ~' +b00000000000000000000000000000000 !( +b00000000000000000000000000000000 "( +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +0H( +b00000000 I( +b00000000 J( +b00000001 L( +b00000010 M( +b00000001 N( +b00000010 O( +b00000001 P( +b00000010 Q( +b00000001 R( +b00000011 S( +b00000001 T( +b00000010 U( +b00000001 V( +b00000010 W( +b00000001 X( +b00000010 Y( +b00000001 Z( +b00000011 [( +b00000000000000000000000000000000 \( +b00000000000000000000000000000000 ]( +b00000000000000000000000000000000 ^( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +0c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) +b00000000000000000000000000000001 $) +b00000000000000000000000000000010 %) +b00000001 ') +b00000011 () +b00000000000000000000000000000001 )) #10 b00000001 $ b00000010 % @@ -76,8 +1509,192 @@ b00000010 & 1) b00000010 * b00000000000000000000000000000001 + +1- +b00000010 . +18 +1? +b00000010 @ +1D +b00000001 F +b00000001 G +1I +b00000001 J +b00000010 K +b00000010 L +b00000010 M +b00000010 N +1P +b00000010 Q +b00000010 R +b00000011 S +b00000010 T +b00000010 U +b00000010 Y +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 ^ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 b +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 f +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 j +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 n +b00000000000000000000000000000001 r +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 z +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ~ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 $! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 (! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ,! +1! +b00000000000000000000000000000001 P! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000010 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000000001 8" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +1`" +b00000011 a" +b00000010 b" +b00000000000000000000000000000001 t" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +1C# +b00000010 D# +b00000010 E# +b00000001 F# +b00000010 G# +b00000010 H# +b00000010 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000000001 f# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +10$ +b00000001 1$ +b00000010 2$ +b00000000000000000000000000000001 D$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000010 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000000001 ,% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +1T% +b00000001 U% +b00000010 V% +b00000000000000000000000000000001 h% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +17& +b00000010 8& +b00000010 9& +b00000001 :& +b00000010 ;& +b00000010 <& +b00000010 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000000001 Z& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +1$' +b00000001 %' +b00000010 &' +b00000000000000000000000000000001 8' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000010 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000000001 ~' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +1H( +b00000001 I( +b00000010 J( +b00000000000000000000000000000001 \( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( #15 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000000010 P! +b00000000000000000000000000000010 Q! +b00000000000000000000000000000011 R! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00000101 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000000010 8" +b00000000000000000000000000000010 9" +b00000000000000000000000000000011 :" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00000101 a" +b00000101 b" +b00000000000000000000000000000010 t" +b00000000000000000000000000000010 u" +b00000000000000000000000000000011 v" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00000101 D# +b00000011 E# +b00000011 F# +b00000011 G# +b00000011 H# +b00000011 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000000010 f# +b00000000000000000000000000000010 g# +b00000000000000000000000000000011 h# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00000011 1$ +b00000011 2$ +b00000000000000000000000000000010 D$ +b00000000000000000000000000000010 E$ +b00000000000000000000000000000011 F$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00000011 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000000010 ,% +b00000000000000000000000000000010 -% +b00000000000000000000000000000011 .% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00000011 U% +b00000011 V% +b00000000000000000000000000000010 h% +b00000000000000000000000000000010 i% +b00000000000000000000000000000011 j% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00000101 8& +b00000011 9& +b00000011 :& +b00000011 ;& +b00000011 <& +b00000011 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000000010 Z& +b00000000000000000000000000000010 [& +b00000000000000000000000000000011 \& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00000011 %' +b00000011 &' +b00000000000000000000000000000010 8' +b00000000000000000000000000000010 9' +b00000000000000000000000000000011 :' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00000011 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000000010 ~' +b00000000000000000000000000000010 !( +b00000000000000000000000000000011 "( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00000011 I( +b00000011 J( +b00000000000000000000000000000010 \( +b00000000000000000000000000000010 ]( +b00000000000000000000000000000011 ^( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #25 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000000011 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00000111 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000000011 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00000110 a" +b00000111 b" +b00000000000000000000000000000011 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00000111 D# +b00000101 E# +b00000110 F# +b00000101 G# +b00000101 H# +b00000101 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000000011 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00000110 1$ +b00000101 2$ +b00000000000000000000000000000011 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00000101 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000000011 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00000110 U% +b00000101 V% +b00000000000000000000000000000011 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00000111 8& +b00000101 9& +b00000110 :& +b00000101 ;& +b00000101 <& +b00000101 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000000011 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00000110 %' +b00000101 &' +b00000000000000000000000000000011 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00000101 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000000011 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00000110 I( +b00000101 J( +b00000000000000000000000000000011 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #35 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000000100 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00001000 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000000100 8" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00001000 b" +b00000000000000000000000000000100 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00001000 D# +b00001000 E# +b00001000 F# +b00001000 G# +b00001000 H# +b00001000 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000000100 f# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00001000 1$ +b00001000 2$ +b00000000000000000000000000000100 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00001000 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000000100 ,% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00001000 U% +b00001000 V% +b00000000000000000000000000000100 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00001000 8& +b00001000 9& +b00001000 :& +b00001000 ;& +b00001000 <& +b00001000 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000000100 Z& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00001000 %' +b00001000 &' +b00000000000000000000000000000100 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00001000 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000000100 ~' +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00001000 I( +b00001000 J( +b00000000000000000000000000000100 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #45 0) +0- +08 +0? +0D +0I +0P +0( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00001001 I( +b00001010 J( +b00000000000000000000000000000101 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #55 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000000110 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00001010 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000000110 8" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00001001 a" +b00001010 b" +b00000000000000000000000000000110 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00001010 D# +b00001011 E# +b00001011 G# +b00001011 H# +b00001011 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000000110 f# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00001011 2$ +b00000000000000000000000000000110 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00001011 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000000110 ,% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00001011 V% +b00000000000000000000000000000110 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00001010 8& +b00001011 9& +b00001011 ;& +b00001011 <& +b00001011 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000000110 Z& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00001011 &' +b00000000000000000000000000000110 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00001011 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000000110 ~' +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00001011 J( +b00000000000000000000000000000110 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #65 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000000111 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00001011 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000000111 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00001011 a" +b00001011 b" +b00000000000000000000000000000111 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00001011 D# +b00001011 F# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000000111 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00001011 1$ +b00000000000000000000000000000111 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000000111 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00001011 U% +b00000000000000000000000000000111 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00001011 8& +b00001011 :& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000000111 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00001011 %' +b00000000000000000000000000000111 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000000111 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00001011 I( +b00000000000000000000000000000111 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #75 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001000 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00001101 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000001000 8" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00001110 a" +b00001101 b" +b00000000000000000000000000001000 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00001101 D# +b00001101 E# +b00001100 F# +b00001101 G# +b00001101 H# +b00001101 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000001000 f# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00001100 1$ +b00001101 2$ +b00000000000000000000000000001000 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00001101 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000001000 ,% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00001100 U% +b00001101 V% +b00000000000000000000000000001000 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00001101 8& +b00001101 9& +b00001100 :& +b00001101 ;& +b00001101 <& +b00001101 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000001000 Z& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00001100 %' +b00001101 &' +b00000000000000000000000000001000 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00001101 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000001000 ~' +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00001100 I( +b00001101 J( +b00000000000000000000000000001000 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #85 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001001 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00010000 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000001001 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00010000 a" +b00010000 b" +b00000000000000000000000000001001 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00010000 D# +b00001110 E# +b00001110 F# +b00001110 G# +b00001110 H# +b00001110 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000001001 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00001110 1$ +b00001110 2$ +b00000000000000000000000000001001 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00001110 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000001001 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00001110 U% +b00001110 V% +b00000000000000000000000000001001 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00010000 8& +b00001110 9& +b00001110 :& +b00001110 ;& +b00001110 <& +b00001110 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000001001 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00001110 %' +b00001110 &' +b00000000000000000000000000001001 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00001110 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000001001 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00001110 I( +b00001110 J( +b00000000000000000000000000001001 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #95 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001010 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00010010 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000001010 8" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00010001 a" +b00010010 b" +b00000000000000000000000000001010 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00010010 D# +b00010000 E# +b00010001 F# +b00010000 G# +b00010000 H# +b00010000 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000001010 f# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00010001 1$ +b00010000 2$ +b00000000000000000000000000001010 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00010000 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000001010 ,% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00010001 U% +b00010000 V% +b00000000000000000000000000001010 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00010010 8& +b00010000 9& +b00010001 :& +b00010000 ;& +b00010000 <& +b00010000 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000001010 Z& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00010001 %' +b00010000 &' +b00000000000000000000000000001010 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00010000 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000001010 ~' +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00010001 I( +b00010000 J( +b00000000000000000000000000001010 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #105 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001011 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00010011 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000001011 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00010011 b" +b00000000000000000000000000001011 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00010011 D# +b00010011 E# +b00010011 F# +b00010011 G# +b00010011 H# +b00010011 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000001011 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00010011 1$ +b00010011 2$ +b00000000000000000000000000001011 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00010011 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000001011 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00010011 U% +b00010011 V% +b00000000000000000000000000001011 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00010011 8& +b00010011 9& +b00010011 :& +b00010011 ;& +b00010011 <& +b00010011 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000001011 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00010011 %' +b00010011 &' +b00000000000000000000000000001011 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00010011 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000001011 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00010011 I( +b00010011 J( +b00000000000000000000000000001011 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #115 0) +0- +08 +0? +0D +0I +0P +0( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00010100 I( +b00010101 J( +b00000000000000000000000000001100 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #125 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001101 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00010101 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000001101 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00010100 a" +b00010101 b" +b00000000000000000000000000001101 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00010101 D# +b00010110 E# +b00010110 G# +b00010110 H# +b00010110 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000001101 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00010110 2$ +b00000000000000000000000000001101 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00010110 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000001101 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00010110 V% +b00000000000000000000000000001101 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00010101 8& +b00010110 9& +b00010110 ;& +b00010110 <& +b00010110 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000001101 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00010110 &' +b00000000000000000000000000001101 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00010110 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000001101 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00010110 J( +b00000000000000000000000000001101 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #135 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001110 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00010110 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000001110 8" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00010110 a" +b00010110 b" +b00000000000000000000000000001110 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00010110 D# +b00010110 F# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000001110 f# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00010110 1$ +b00000000000000000000000000001110 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000001110 ,% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00010110 U% +b00000000000000000000000000001110 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00010110 8& +b00010110 :& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000001110 Z& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00010110 %' +b00000000000000000000000000001110 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000001110 ~' +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00010110 I( +b00000000000000000000000000001110 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #145 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000001111 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00011000 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000001111 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00011001 a" +b00011000 b" +b00000000000000000000000000001111 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00011000 D# +b00011000 E# +b00010111 F# +b00011000 G# +b00011000 H# +b00011000 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000001111 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00010111 1$ +b00011000 2$ +b00000000000000000000000000001111 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00011000 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000001111 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00010111 U% +b00011000 V% +b00000000000000000000000000001111 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00011000 8& +b00011000 9& +b00010111 :& +b00011000 ;& +b00011000 <& +b00011000 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000001111 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00010111 %' +b00011000 &' +b00000000000000000000000000001111 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00011000 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000001111 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00010111 I( +b00011000 J( +b00000000000000000000000000001111 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) #155 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000010000 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l! +b00000110 p! +b00000101 q! +b00000100 r! +b00000011 s! +b00000010 t! +b00000001 u! +b00011011 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4" +b00000000000000000000000000010000 8" +b00000000 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P" +b00000110 T" +b00000101 U" +b00000100 V" +b00000011 W" +b00000010 X" +b00000001 Y" +b00000110 Z" +b00000101 [" +b00000100 \" +b00000011 ]" +b00000010 ^" +b00000001 _" +1`" +b00011011 a" +b00011011 b" +b00000000000000000000000000010000 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 2# +b00000110 6# +b00000101 7# +b00000100 8# +b00000011 9# +b00000010 :# +b00000001 ;# +1C# +b00011011 D# +b00011001 E# +b00011001 F# +b00011001 G# +b00011001 H# +b00011001 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b# +b00000000000000000000000000010000 f# +b00000000 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~# +b00000110 $$ +b00000101 %$ +b00000100 &$ +b00000011 '$ +b00000010 ($ +b00000001 )$ +b00000110 *$ +b00000101 +$ +b00000100 ,$ +b00000011 -$ +b00000010 .$ +b00000001 /$ +10$ +b00011001 1$ +b00011001 2$ +b00000000000000000000000000010000 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 `$ +b00000110 d$ +b00000101 e$ +b00000100 f$ +b00000011 g$ +b00000010 h$ +b00000001 i$ +b00011001 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (% +b00000000000000000000000000010000 ,% +b00000000 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D% +b00000110 H% +b00000101 I% +b00000100 J% +b00000011 K% +b00000010 L% +b00000001 M% +b00000110 N% +b00000101 O% +b00000100 P% +b00000011 Q% +b00000010 R% +b00000001 S% +1T% +b00011001 U% +b00011001 V% +b00000000000000000000000000010000 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 && +b00000110 *& +b00000101 +& +b00000100 ,& +b00000011 -& +b00000010 .& +b00000001 /& +17& +b00011011 8& +b00011001 9& +b00011001 :& +b00011001 ;& +b00011001 <& +b00011001 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 V& +b00000000000000000000000000010000 Z& +b00000000 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r& +b00000110 v& +b00000101 w& +b00000100 x& +b00000011 y& +b00000010 z& +b00000001 {& +b00000110 |& +b00000101 }& +b00000100 ~& +b00000011 !' +b00000010 "' +b00000001 #' +1$' +b00011001 %' +b00011001 &' +b00000000000000000000000000010000 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 T' +b00000110 X' +b00000101 Y' +b00000100 Z' +b00000011 [' +b00000010 \' +b00000001 ]' +b00011001 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 z' +b00000000000000000000000000010000 ~' +b00000000 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8( +b00000110 <( +b00000101 =( +b00000100 >( +b00000011 ?( +b00000010 @( +b00000001 A( +b00000110 B( +b00000101 C( +b00000100 D( +b00000011 E( +b00000010 F( +b00000001 G( +1H( +b00011001 I( +b00011001 J( +b00000000000000000000000000010000 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 x( +b00000110 |( +b00000101 }( +b00000100 ~( +b00000011 !) +b00000010 ") +b00000001 #) #165 0) +0- +08 +0? +0D +0I +0P +0! +b00000000000000000000000000010001 P! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 S! +1W! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 \! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 `! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 d! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 h! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 l! +b00000000 p! +b00000000 q! +b00000000 r! +b00000000 s! +b00000000 t! +b00000000 u! +b00011101 }! +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 $" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 (" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ," +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 0" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 4" +b00000000000000000000000000010001 8" +b00000001 ;" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 @" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 D" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 H" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 L" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 P" +b00000000 T" +b00000000 U" +b00000000 V" +b00000000 W" +b00000000 X" +b00000000 Y" +b00000000 Z" +b00000000 [" +b00000000 \" +b00000000 ]" +b00000000 ^" +b00000000 _" +1`" +b00011100 a" +b00011101 b" +b00000000000000000000000000010001 t" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 w" +1{" +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 "# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 &# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 *# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 .# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 2# +b00000000 6# +b00000000 7# +b00000000 8# +b00000000 9# +b00000000 :# +b00000000 ;# +1C# +b00011101 D# +b00011011 E# +b00011100 F# +b00011011 G# +b00011011 H# +b00011011 M# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 R# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 V# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 Z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 ^# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 b# +b00000000000000000000000000010001 f# +b00000001 i# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 n# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 r# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 v# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 z# +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 ~# +b00000000 $$ +b00000000 %$ +b00000000 &$ +b00000000 '$ +b00000000 ($ +b00000000 )$ +b00000000 *$ +b00000000 +$ +b00000000 ,$ +b00000000 -$ +b00000000 .$ +b00000000 /$ +10$ +b00011100 1$ +b00011011 2$ +b00000000000000000000000000010001 D$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 G$ +1K$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 P$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 T$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 X$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 \$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 `$ +b00000000 d$ +b00000000 e$ +b00000000 f$ +b00000000 g$ +b00000000 h$ +b00000000 i$ +b00011011 q$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 v$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 z$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 ~$ +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 $% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 (% +b00000000000000000000000000010001 ,% +b00000001 /% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 4% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 8% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 <% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 @% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 D% +b00000000 H% +b00000000 I% +b00000000 J% +b00000000 K% +b00000000 L% +b00000000 M% +b00000000 N% +b00000000 O% +b00000000 P% +b00000000 Q% +b00000000 R% +b00000000 S% +1T% +b00011100 U% +b00011011 V% +b00000000000000000000000000010001 h% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 k% +1o% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 t% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 x% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 |% +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 "& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 && +b00000000 *& +b00000000 +& +b00000000 ,& +b00000000 -& +b00000000 .& +b00000000 /& +17& +b00011101 8& +b00011011 9& +b00011100 :& +b00011011 ;& +b00011011 <& +b00011011 A& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 F& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 J& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 N& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 R& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 V& +b00000000000000000000000000010001 Z& +b00000001 ]& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 b& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 f& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 j& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 n& +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 r& +b00000000 v& +b00000000 w& +b00000000 x& +b00000000 y& +b00000000 z& +b00000000 {& +b00000000 |& +b00000000 }& +b00000000 ~& +b00000000 !' +b00000000 "' +b00000000 #' +1$' +b00011100 %' +b00011011 &' +b00000000000000000000000000010001 8' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ;' +1?' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 D' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 H' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 L' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 P' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 T' +b00000000 X' +b00000000 Y' +b00000000 Z' +b00000000 [' +b00000000 \' +b00000000 ]' +b00011011 e' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 j' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 n' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 r' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 v' +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 z' +b00000000000000000000000000010001 ~' +b00000001 #( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 (( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 ,( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 0( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 4( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 8( +b00000000 <( +b00000000 =( +b00000000 >( +b00000000 ?( +b00000000 @( +b00000000 A( +b00000000 B( +b00000000 C( +b00000000 D( +b00000000 E( +b00000000 F( +b00000000 G( +1H( +b00011100 I( +b00011011 J( +b00000000000000000000000000010001 \( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 _( +1c( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 h( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 l( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 p( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100 t( +b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101 x( +b00000000 |( +b00000000 }( +b00000000 ~( +b00000000 !) +b00000000 ") +b00000000 #) From a1a186a86c94c9144fb2326308e0c47e127a7f2f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 12:47:46 -0500 Subject: [PATCH 70/79] Internals: Remove some unused arguments. --- include/verilated_funcs.h | 74 ++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index 6aa228ee1..5cba389f6 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -1221,31 +1221,27 @@ QData VL_POWSS_QQW(int obits, int, int rbits, QData lhs, WDataInP const rwp, boo // INTERNAL: Stuff LHS bit 0++ into OUTPUT at specified offset // ld may be "dirty", output is clean -static inline void _vl_insert_II(int, CData& lhsr, IData ld, int hbit, int lbit, - int rbits) VL_PURE { +static inline void _vl_insert_II(CData& lhsr, IData ld, int hbit, int lbit, int rbits) VL_PURE { const IData cleanmask = VL_MASK_I(rbits); const IData insmask = (VL_MASK_I(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _vl_insert_II(int, SData& lhsr, IData ld, int hbit, int lbit, - int rbits) VL_PURE { +static inline void _vl_insert_II(SData& lhsr, IData ld, int hbit, int lbit, int rbits) VL_PURE { const IData cleanmask = VL_MASK_I(rbits); const IData insmask = (VL_MASK_I(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _vl_insert_II(int, IData& lhsr, IData ld, int hbit, int lbit, - int rbits) VL_PURE { +static inline void _vl_insert_II(IData& lhsr, IData ld, int hbit, int lbit, int rbits) VL_PURE { const IData cleanmask = VL_MASK_I(rbits); const IData insmask = (VL_MASK_I(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _vl_insert_QQ(int, QData& lhsr, QData ld, int hbit, int lbit, - int rbits) VL_PURE { +static inline void _vl_insert_QQ(QData& lhsr, QData ld, int hbit, int lbit, int rbits) VL_PURE { const QData cleanmask = VL_MASK_Q(rbits); const QData insmask = (VL_MASK_Q(hbit - lbit + 1)) << lbit; lhsr = (lhsr & ~insmask) | ((ld << lbit) & (insmask & cleanmask)); } -static inline void _vl_insert_WI(int, WDataOutP owp, IData ld, int hbit, int lbit, +static inline void _vl_insert_WI(WDataOutP owp, IData ld, int hbit, int lbit, int rbits = 0) VL_MT_SAFE { const int hoffset = VL_BITBIT_E(hbit); const int loffset = VL_BITBIT_E(lbit); @@ -1278,7 +1274,7 @@ static inline void _vl_insert_WI(int, WDataOutP owp, IData ld, int hbit, int lbi // INTERNAL: Stuff large LHS bit 0++ into OUTPUT at specified offset // lwp may be "dirty" -static inline void _vl_insert_WW(int, WDataOutP owp, WDataInP const lwp, int hbit, int lbit, +static inline void _vl_insert_WW(WDataOutP owp, WDataInP const lwp, int hbit, int lbit, int rbits = 0) VL_MT_SAFE { const int hoffset = VL_BITBIT_E(hbit); const int loffset = VL_BITBIT_E(lbit); @@ -1334,11 +1330,11 @@ static inline void _vl_insert_WW(int, WDataOutP owp, WDataInP const lwp, int hbi } } -static inline void _vl_insert_WQ(int obits, WDataOutP owp, QData ld, int hbit, int lbit, +static inline void _vl_insert_WQ(WDataOutP owp, QData ld, int hbit, int lbit, int rbits = 0) VL_MT_SAFE { VlWide lwp; VL_SET_WQ(lwp, ld); - _vl_insert_WW(obits, owp, lwp, hbit, lbit, rbits); + _vl_insert_WW(owp, lwp, hbit, lbit, rbits); } // EMIT_RULE: VL_REPLICATE: oclean=clean>width32, dirty<=width32; lclean=clean; rclean==clean; @@ -1362,27 +1358,27 @@ static inline QData VL_REPLICATE_QII(int, int lbits, int, IData ld, IData rep) V } return returndata; } -static inline WDataOutP VL_REPLICATE_WII(int obits, int lbits, int, WDataOutP owp, IData ld, +static inline WDataOutP VL_REPLICATE_WII(int, int lbits, int, WDataOutP owp, IData ld, IData rep) VL_MT_SAFE { owp[0] = ld; for (unsigned i = 1; i < rep; ++i) { - _vl_insert_WI(obits, owp, ld, i * lbits + lbits - 1, i * lbits); + _vl_insert_WI(owp, ld, i * lbits + lbits - 1, i * lbits); } return owp; } -static inline WDataOutP VL_REPLICATE_WQI(int obits, int lbits, int, WDataOutP owp, QData ld, +static inline WDataOutP VL_REPLICATE_WQI(int, int lbits, int, WDataOutP owp, QData ld, IData rep) VL_MT_SAFE { VL_SET_WQ(owp, ld); for (unsigned i = 1; i < rep; ++i) { - _vl_insert_WQ(obits, owp, ld, i * lbits + lbits - 1, i * lbits); + _vl_insert_WQ(owp, ld, i * lbits + lbits - 1, i * lbits); } return owp; } -static inline WDataOutP VL_REPLICATE_WWI(int obits, int lbits, int, WDataOutP owp, - WDataInP const lwp, IData rep) VL_MT_SAFE { +static inline WDataOutP VL_REPLICATE_WWI(int, int lbits, int, WDataOutP owp, WDataInP const lwp, + IData rep) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(lbits); ++i) owp[i] = lwp[i]; for (unsigned i = 1; i < rep; ++i) { - _vl_insert_WW(obits, owp, lwp, i * lbits + lbits - 1, i * lbits); + _vl_insert_WW(owp, lwp, i * lbits + lbits - 1, i * lbits); } return owp; } @@ -1523,63 +1519,63 @@ static inline WDataOutP VL_CONCAT_WII(int obits, int lbits, int rbits, WDataOutP IData rd) VL_MT_SAFE { owp[0] = rd; for (int i = 1; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WI(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WI(owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WWI(int obits, int lbits, int rbits, WDataOutP owp, WDataInP const lwp, IData rd) VL_MT_SAFE { owp[0] = rd; for (int i = 1; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WW(obits, owp, lwp, rbits + lbits - 1, rbits); + _vl_insert_WW(owp, lwp, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WIW(int obits, int lbits, int rbits, WDataOutP owp, IData ld, WDataInP const rwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(rbits); ++i) owp[i] = rwp[i]; for (int i = VL_WORDS_I(rbits); i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WI(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WI(owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WIQ(int obits, int lbits, int rbits, WDataOutP owp, IData ld, QData rd) VL_MT_SAFE { VL_SET_WQ(owp, rd); for (int i = VL_WQ_WORDS_E; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WI(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WI(owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WQI(int obits, int lbits, int rbits, WDataOutP owp, QData ld, IData rd) VL_MT_SAFE { owp[0] = rd; for (int i = 1; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WQ(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WQ(owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WQQ(int obits, int lbits, int rbits, WDataOutP owp, QData ld, QData rd) VL_MT_SAFE { VL_SET_WQ(owp, rd); for (int i = VL_WQ_WORDS_E; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WQ(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WQ(owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WWQ(int obits, int lbits, int rbits, WDataOutP owp, WDataInP const lwp, QData rd) VL_MT_SAFE { VL_SET_WQ(owp, rd); for (int i = VL_WQ_WORDS_E; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WW(obits, owp, lwp, rbits + lbits - 1, rbits); + _vl_insert_WW(owp, lwp, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WQW(int obits, int lbits, int rbits, WDataOutP owp, QData ld, WDataInP const rwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(rbits); ++i) owp[i] = rwp[i]; for (int i = VL_WORDS_I(rbits); i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WQ(obits, owp, ld, rbits + lbits - 1, rbits); + _vl_insert_WQ(owp, ld, rbits + lbits - 1, rbits); return owp; } static inline WDataOutP VL_CONCAT_WWW(int obits, int lbits, int rbits, WDataOutP owp, WDataInP const lwp, WDataInP const rwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(rbits); ++i) owp[i] = rwp[i]; for (int i = VL_WORDS_I(rbits); i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WW(obits, owp, lwp, rbits + lbits - 1, rbits); + _vl_insert_WW(owp, lwp, rbits + lbits - 1, rbits); return owp; } @@ -1614,7 +1610,7 @@ static inline WDataOutP VL_SHIFTL_WWI(int obits, int, int, WDataOutP owp, WDataI for (int i = word_shift; i < VL_WORDS_I(obits); ++i) owp[i] = lwp[i - word_shift]; } else { for (int i = 0; i < VL_WORDS_I(obits); ++i) owp[i] = 0; - _vl_insert_WW(obits, owp, lwp, obits - 1, rd); + _vl_insert_WW(owp, lwp, obits - 1, rd); } return owp; } @@ -1961,7 +1957,7 @@ static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) V if (lsb < 0) { VL_SET_WQ(owp, mantissa >> -lsb); } else if (lsb < obits) { - _vl_insert_WQ(obits, owp, mantissa, lsb + 52, lsb); + _vl_insert_WQ(owp, mantissa, lsb + 52, lsb); } if (lhs < 0) VL_NEGATE_INPLACE_W(VL_WORDS_I(obits), owp); return owp; @@ -1973,41 +1969,41 @@ static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) V // EMIT_RULE: VL_ASSIGNRANGE: rclean=dirty; static inline void VL_ASSIGNSEL_IIII(int rbits, int obits, int lsb, CData& lhsr, IData rhs) VL_PURE { - _vl_insert_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_II(lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_IIII(int rbits, int obits, int lsb, SData& lhsr, IData rhs) VL_PURE { - _vl_insert_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_II(lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_IIII(int rbits, int obits, int lsb, IData& lhsr, IData rhs) VL_PURE { - _vl_insert_II(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_II(lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_QIII(int rbits, int obits, int lsb, QData& lhsr, IData rhs) VL_PURE { - _vl_insert_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_QQ(lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_QQII(int rbits, int obits, int lsb, QData& lhsr, QData rhs) VL_PURE { - _vl_insert_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_QQ(lhsr, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_QIIQ(int rbits, int obits, int lsb, QData& lhsr, QData rhs) VL_PURE { - _vl_insert_QQ(obits, lhsr, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_QQ(lhsr, rhs, lsb + obits - 1, lsb, rbits); } // static inline void VL_ASSIGNSEL_IIIW(int obits, int lsb, IData& lhsr, WDataInP const rwp) // VL_MT_SAFE { Illegal, as lhs width >= rhs width static inline void VL_ASSIGNSEL_WIII(int rbits, int obits, int lsb, WDataOutP owp, IData rhs) VL_MT_SAFE { - _vl_insert_WI(obits, owp, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_WI(owp, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_WIIQ(int rbits, int obits, int lsb, WDataOutP owp, QData rhs) VL_MT_SAFE { - _vl_insert_WQ(obits, owp, rhs, lsb + obits - 1, lsb, rbits); + _vl_insert_WQ(owp, rhs, lsb + obits - 1, lsb, rbits); } static inline void VL_ASSIGNSEL_WIIW(int rbits, int obits, int lsb, WDataOutP owp, WDataInP const rwp) VL_MT_SAFE { - _vl_insert_WW(obits, owp, rwp, lsb + obits - 1, lsb, rbits); + _vl_insert_WW(owp, rwp, lsb + obits - 1, lsb, rbits); } //====================================================================== From 61e353616388b564379e0974ba8881252d4f8cdc Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 13:44:16 -0500 Subject: [PATCH 71/79] Internals: Remove some unused arguments. --- include/verilated.cpp | 4 +- include/verilated_dpi.cpp | 2 +- include/verilated_funcs.h | 129 ++++++++++++++++++-------------------- src/V3Ast.h | 4 +- src/V3AstNodes.h | 27 ++++---- src/V3EmitCFunc.h | 21 +++---- 6 files changed, 89 insertions(+), 98 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 0320a8d86..b3cca5256 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1041,9 +1041,7 @@ static inline char* _vl_vsss_read_bin(FILE* fp, int& floc, const WDataInP fromp, } static inline void _vl_vsss_setbit(WDataOutP owp, int obits, int lsb, int nbits, IData ld) VL_MT_SAFE { - for (; nbits && lsb < obits; nbits--, lsb++, ld >>= 1) { - VL_ASSIGNBIT_WI(0, lsb, owp, ld & 1); - } + for (; nbits && lsb < obits; nbits--, lsb++, ld >>= 1) { VL_ASSIGNBIT_WI(lsb, owp, ld & 1); } } static inline void _vl_vsss_based(WDataOutP owp, int obits, int baseLog2, const char* strp, size_t posstart, size_t posend) VL_MT_SAFE { diff --git a/include/verilated_dpi.cpp b/include/verilated_dpi.cpp index d9c826481..429838cb3 100644 --- a/include/verilated_dpi.cpp +++ b/include/verilated_dpi.cpp @@ -68,7 +68,7 @@ svLogic svGetBitselLogic(const svLogicVecVal* sp, int bit) { | (((sp[VL_BITWORD_I(bit)].bval >> VL_BITBIT_I(bit)) & 1) << 1)); } -void svPutBitselBit(svBitVecVal* dp, int bit, svBit s) { VL_ASSIGNBIT_WI(32, bit, dp, s); } +void svPutBitselBit(svBitVecVal* dp, int bit, svBit s) { VL_ASSIGNBIT_WI(bit, dp, s); } void svPutBitselLogic(svLogicVecVal* dp, int bit, svLogic s) { // Verilator doesn't support X/Z so only aval dp[VL_BITWORD_I(bit)].aval = ((dp[VL_BITWORD_I(bit)].aval & ~(VL_UL(1) << VL_BITBIT_I(bit))) diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index 5cba389f6..a825163ea 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -363,13 +363,13 @@ vluint64_t vl_time_pow10(int n) VL_PURE; #define VL_CLEAN_QQ(obits, lbits, lhs) ((lhs)&VL_MASK_Q(obits)) // EMIT_RULE: VL_ASSIGNCLEAN: oclean=clean; obits==lbits; -#define VL_ASSIGNCLEAN_W(obits, owp, lwp) VL_CLEAN_WW((obits), (obits), (owp), (lwp)) +#define VL_ASSIGNCLEAN_W(obits, owp, lwp) VL_CLEAN_WW((obits), (owp), (lwp)) static inline WDataOutP _vl_clean_inplace_w(int obits, WDataOutP owp) VL_MT_SAFE { const int words = VL_WORDS_I(obits); owp[words - 1] &= VL_MASK_E(obits); return owp; } -static inline WDataOutP VL_CLEAN_WW(int obits, int, WDataOutP owp, WDataInP const lwp) VL_MT_SAFE { +static inline WDataOutP VL_CLEAN_WW(int obits, WDataOutP owp, WDataInP const lwp) VL_MT_SAFE { const int words = VL_WORDS_I(obits); for (int i = 0; (i < (words - 1)); ++i) owp[i] = lwp[i]; owp[words - 1] = lwp[words - 1] & VL_MASK_E(obits); @@ -397,37 +397,37 @@ static inline WDataOutP VL_ASSIGN_W(int obits, WDataOutP owp, WDataInP const lwp } // EMIT_RULE: VL_ASSIGNBIT: rclean=clean; -static inline void VL_ASSIGNBIT_II(int, int bit, CData& lhsr, IData rhs) VL_PURE { +static inline void VL_ASSIGNBIT_II(int bit, CData& lhsr, IData rhs) VL_PURE { lhsr = ((lhsr & ~(VL_UL(1) << VL_BITBIT_I(bit))) | (rhs << VL_BITBIT_I(bit))); } -static inline void VL_ASSIGNBIT_II(int, int bit, SData& lhsr, IData rhs) VL_PURE { +static inline void VL_ASSIGNBIT_II(int bit, SData& lhsr, IData rhs) VL_PURE { lhsr = ((lhsr & ~(VL_UL(1) << VL_BITBIT_I(bit))) | (rhs << VL_BITBIT_I(bit))); } -static inline void VL_ASSIGNBIT_II(int, int bit, IData& lhsr, IData rhs) VL_PURE { +static inline void VL_ASSIGNBIT_II(int bit, IData& lhsr, IData rhs) VL_PURE { lhsr = ((lhsr & ~(VL_UL(1) << VL_BITBIT_I(bit))) | (rhs << VL_BITBIT_I(bit))); } -static inline void VL_ASSIGNBIT_QI(int, int bit, QData& lhsr, QData rhs) VL_PURE { +static inline void VL_ASSIGNBIT_QI(int bit, QData& lhsr, QData rhs) VL_PURE { lhsr = ((lhsr & ~(1ULL << VL_BITBIT_Q(bit))) | (static_cast(rhs) << VL_BITBIT_Q(bit))); } -static inline void VL_ASSIGNBIT_WI(int, int bit, WDataOutP owp, IData rhs) VL_MT_SAFE { +static inline void VL_ASSIGNBIT_WI(int bit, WDataOutP owp, IData rhs) VL_MT_SAFE { const EData orig = owp[VL_BITWORD_E(bit)]; owp[VL_BITWORD_E(bit)] = ((orig & ~(VL_EUL(1) << VL_BITBIT_E(bit))) | (static_cast(rhs) << VL_BITBIT_E(bit))); } // Alternative form that is an instruction faster when rhs is constant one. -static inline void VL_ASSIGNBIT_IO(int, int bit, CData& lhsr, IData) VL_PURE { +static inline void VL_ASSIGNBIT_IO(int bit, CData& lhsr) VL_PURE { lhsr = (lhsr | (VL_UL(1) << VL_BITBIT_I(bit))); } -static inline void VL_ASSIGNBIT_IO(int, int bit, SData& lhsr, IData) VL_PURE { +static inline void VL_ASSIGNBIT_IO(int bit, SData& lhsr) VL_PURE { lhsr = (lhsr | (VL_UL(1) << VL_BITBIT_I(bit))); } -static inline void VL_ASSIGNBIT_IO(int, int bit, IData& lhsr, IData) VL_PURE { +static inline void VL_ASSIGNBIT_IO(int bit, IData& lhsr) VL_PURE { lhsr = (lhsr | (VL_UL(1) << VL_BITBIT_I(bit))); } -static inline void VL_ASSIGNBIT_QO(int, int bit, QData& lhsr, IData) VL_PURE { +static inline void VL_ASSIGNBIT_QO(int bit, QData& lhsr) VL_PURE { lhsr = (lhsr | (1ULL << VL_BITBIT_Q(bit))); } -static inline void VL_ASSIGNBIT_WO(int, int bit, WDataOutP owp, IData) VL_MT_SAFE { +static inline void VL_ASSIGNBIT_WO(int bit, WDataOutP owp) VL_MT_SAFE { const EData orig = owp[VL_BITWORD_E(bit)]; owp[VL_BITWORD_E(bit)] = (orig | (VL_EUL(1) << VL_BITBIT_E(bit))); } @@ -588,9 +588,9 @@ static inline WDataOutP VL_EXTENDS_WW(int obits, int lbits, WDataOutP owp, // REDUCTION OPERATORS // EMIT_RULE: VL_REDAND: oclean=clean; lclean==clean; obits=1; -#define VL_REDAND_II(obits, lbits, lhs) ((lhs) == VL_MASK_I(lbits)) -#define VL_REDAND_IQ(obits, lbits, lhs) ((lhs) == VL_MASK_Q(lbits)) -static inline IData VL_REDAND_IW(int, int lbits, WDataInP const lwp) VL_MT_SAFE { +#define VL_REDAND_II(lbits, lhs) ((lhs) == VL_MASK_I(lbits)) +#define VL_REDAND_IQ(lbits, lhs) ((lhs) == VL_MASK_Q(lbits)) +static inline IData VL_REDAND_IW(int lbits, WDataInP const lwp) VL_MT_SAFE { const int words = VL_WORDS_I(lbits); EData combine = lwp[0]; for (int i = 1; i < words - 1; ++i) combine &= lwp[i]; @@ -862,52 +862,52 @@ static inline int _vl_cmp_w(int words, WDataInP const lwp, WDataInP const rwp) V return 0; // == } -#define VL_LTS_IWW(obits, lbits, rbbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) < 0) -#define VL_LTES_IWW(obits, lbits, rbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) <= 0) -#define VL_GTS_IWW(obits, lbits, rbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) > 0) -#define VL_GTES_IWW(obits, lbits, rbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) >= 0) +#define VL_LTS_IWW(lbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) < 0) +#define VL_LTES_IWW(lbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) <= 0) +#define VL_GTS_IWW(lbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) > 0) +#define VL_GTES_IWW(lbits, lwp, rwp) (_vl_cmps_w(lbits, lwp, rwp) >= 0) -static inline IData VL_GTS_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { +static inline IData VL_GTS_III(int lbits, IData lhs, IData rhs) VL_PURE { // For lbits==32, this becomes just a single instruction, otherwise ~5. // GCC 3.3.4 sign extension bugs on AMD64 architecture force us to use quad logic const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed > rhs_signed; } -static inline IData VL_GTS_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { +static inline IData VL_GTS_IQQ(int lbits, QData lhs, QData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); return lhs_signed > rhs_signed; } -static inline IData VL_GTES_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { +static inline IData VL_GTES_III(int lbits, IData lhs, IData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed >= rhs_signed; } -static inline IData VL_GTES_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { +static inline IData VL_GTES_IQQ(int lbits, QData lhs, QData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); return lhs_signed >= rhs_signed; } -static inline IData VL_LTS_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { +static inline IData VL_LTS_III(int lbits, IData lhs, IData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed < rhs_signed; } -static inline IData VL_LTS_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { +static inline IData VL_LTS_IQQ(int lbits, QData lhs, QData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); return lhs_signed < rhs_signed; } -static inline IData VL_LTES_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { +static inline IData VL_LTES_III(int lbits, IData lhs, IData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); // Q for gcc const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); // Q for gcc return lhs_signed <= rhs_signed; } -static inline IData VL_LTES_IQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { +static inline IData VL_LTES_IQQ(int lbits, QData lhs, QData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); return lhs_signed <= rhs_signed; @@ -1002,18 +1002,18 @@ static inline WDataOutP VL_MUL_W(int words, WDataOutP owp, WDataInP const lwp, return owp; } -static inline IData VL_MULS_III(int, int lbits, int, IData lhs, IData rhs) VL_PURE { +static inline IData VL_MULS_III(int lbits, IData lhs, IData rhs) VL_PURE { const vlsint32_t lhs_signed = VL_EXTENDS_II(32, lbits, lhs); const vlsint32_t rhs_signed = VL_EXTENDS_II(32, lbits, rhs); return lhs_signed * rhs_signed; } -static inline QData VL_MULS_QQQ(int, int lbits, int, QData lhs, QData rhs) VL_PURE { +static inline QData VL_MULS_QQQ(int lbits, QData lhs, QData rhs) VL_PURE { const vlsint64_t lhs_signed = VL_EXTENDS_QQ(64, lbits, lhs); const vlsint64_t rhs_signed = VL_EXTENDS_QQ(64, lbits, rhs); return lhs_signed * rhs_signed; } -static inline WDataOutP VL_MULS_WWW(int, int lbits, int, WDataOutP owp, WDataInP const lwp, +static inline WDataOutP VL_MULS_WWW(int lbits, WDataOutP owp, WDataInP const lwp, WDataInP const rwp) VL_MT_SAFE { const int words = VL_WORDS_I(lbits); // cppcheck-suppress variableScope @@ -1339,10 +1339,10 @@ static inline void _vl_insert_WQ(WDataOutP owp, QData ld, int hbit, int lbit, // EMIT_RULE: VL_REPLICATE: oclean=clean>width32, dirty<=width32; lclean=clean; rclean==clean; // RHS MUST BE CLEAN CONSTANT. -#define VL_REPLICATE_IOI(obits, lbits, rbits, ld, rep) (-(ld)) // Iff lbits==1 -#define VL_REPLICATE_QOI(obits, lbits, rbits, ld, rep) (-(static_cast(ld))) // Iff lbits==1 +#define VL_REPLICATE_IOI(lbits, ld, rep) (-(ld)) // Iff lbits==1 +#define VL_REPLICATE_QOI(lbits, ld, rep) (-(static_cast(ld))) // Iff lbits==1 -static inline IData VL_REPLICATE_III(int, int lbits, int, IData ld, IData rep) VL_PURE { +static inline IData VL_REPLICATE_III(int lbits, IData ld, IData rep) VL_PURE { IData returndata = ld; for (unsigned i = 1; i < rep; ++i) { returndata = returndata << lbits; @@ -1350,7 +1350,7 @@ static inline IData VL_REPLICATE_III(int, int lbits, int, IData ld, IData rep) V } return returndata; } -static inline QData VL_REPLICATE_QII(int, int lbits, int, IData ld, IData rep) VL_PURE { +static inline QData VL_REPLICATE_QII(int lbits, IData ld, IData rep) VL_PURE { QData returndata = ld; for (unsigned i = 1; i < rep; ++i) { returndata = returndata << lbits; @@ -1358,7 +1358,7 @@ static inline QData VL_REPLICATE_QII(int, int lbits, int, IData ld, IData rep) V } return returndata; } -static inline WDataOutP VL_REPLICATE_WII(int, int lbits, int, WDataOutP owp, IData ld, +static inline WDataOutP VL_REPLICATE_WII(int lbits, WDataOutP owp, IData ld, IData rep) VL_MT_SAFE { owp[0] = ld; for (unsigned i = 1; i < rep; ++i) { @@ -1366,7 +1366,7 @@ static inline WDataOutP VL_REPLICATE_WII(int, int lbits, int, WDataOutP owp, IDa } return owp; } -static inline WDataOutP VL_REPLICATE_WQI(int, int lbits, int, WDataOutP owp, QData ld, +static inline WDataOutP VL_REPLICATE_WQI(int lbits, WDataOutP owp, QData ld, IData rep) VL_MT_SAFE { VL_SET_WQ(owp, ld); for (unsigned i = 1; i < rep; ++i) { @@ -1374,7 +1374,7 @@ static inline WDataOutP VL_REPLICATE_WQI(int, int lbits, int, WDataOutP owp, QDa } return owp; } -static inline WDataOutP VL_REPLICATE_WWI(int, int lbits, int, WDataOutP owp, WDataInP const lwp, +static inline WDataOutP VL_REPLICATE_WWI(int lbits, WDataOutP owp, WDataInP const lwp, IData rep) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(lbits); ++i) owp[i] = lwp[i]; for (unsigned i = 1; i < rep; ++i) { @@ -1387,7 +1387,7 @@ static inline WDataOutP VL_REPLICATE_WWI(int, int lbits, int, WDataOutP owp, WDa // Special "fast" versions for slice sizes that are a power of 2. These use // shifts and masks to execute faster than the slower for-loop approach where a // subset of bits is copied in during each iteration. -static inline IData VL_STREAML_FAST_III(int, int lbits, int, IData ld, IData rd_log2) VL_PURE { +static inline IData VL_STREAML_FAST_III(int lbits, IData ld, IData rd_log2) VL_PURE { // Pre-shift bits in most-significant slice: // // If lbits is not a multiple of the slice size (i.e., lbits % rd != 0), @@ -1425,7 +1425,7 @@ static inline IData VL_STREAML_FAST_III(int, int lbits, int, IData ld, IData rd_ return ret >> (VL_IDATASIZE - lbits); } -static inline QData VL_STREAML_FAST_QQI(int, int lbits, int, QData ld, IData rd_log2) VL_PURE { +static inline QData VL_STREAML_FAST_QQI(int lbits, QData ld, IData rd_log2) VL_PURE { // Pre-shift bits in most-significant slice (see comment in VL_STREAML_FAST_III) QData ret = ld; if (rd_log2) { @@ -1457,7 +1457,7 @@ static inline QData VL_STREAML_FAST_QQI(int, int lbits, int, QData ld, IData rd_ } // Regular "slow" streaming operators -static inline IData VL_STREAML_III(int, int lbits, int, IData ld, IData rd) VL_PURE { +static inline IData VL_STREAML_III(int lbits, IData ld, IData rd) VL_PURE { IData ret = 0; // Slice size should never exceed the lhs width const IData mask = VL_MASK_I(rd); @@ -1469,7 +1469,7 @@ static inline IData VL_STREAML_III(int, int lbits, int, IData ld, IData rd) VL_P return ret; } -static inline QData VL_STREAML_QQI(int, int lbits, int, QData ld, IData rd) VL_PURE { +static inline QData VL_STREAML_QQI(int lbits, QData ld, IData rd) VL_PURE { QData ret = 0; // Slice size should never exceed the lhs width const QData mask = VL_MASK_Q(rd); @@ -1481,7 +1481,7 @@ static inline QData VL_STREAML_QQI(int, int lbits, int, QData ld, IData rd) VL_P return ret; } -static inline WDataOutP VL_STREAML_WWI(int, int lbits, int, WDataOutP owp, WDataInP const lwp, +static inline WDataOutP VL_STREAML_WWI(int lbits, WDataOutP owp, WDataInP const lwp, IData rd) VL_MT_SAFE { VL_ZERO_W(lbits, owp); // Slice size should never exceed the lhs width @@ -1833,13 +1833,12 @@ static inline QData VL_SHIFTRS_QQQ(int obits, int lbits, int rbits, QData lhs, Q // Bit selection // EMIT_RULE: VL_BITSEL: oclean=dirty; rclean==clean; -#define VL_BITSEL_IIII(obits, lbits, rbits, zbits, lhs, rhs) ((lhs) >> (rhs)) -#define VL_BITSEL_QIII(obits, lbits, rbits, zbits, lhs, rhs) ((lhs) >> (rhs)) -#define VL_BITSEL_QQII(obits, lbits, rbits, zbits, lhs, rhs) ((lhs) >> (rhs)) -#define VL_BITSEL_IQII(obits, lbits, rbits, zbits, lhs, rhs) (static_cast((lhs) >> (rhs))) +#define VL_BITSEL_IIII(lbits, lhs, rhs) ((lhs) >> (rhs)) +#define VL_BITSEL_QIII(lbits, lhs, rhs) ((lhs) >> (rhs)) +#define VL_BITSEL_QQII(lbits, lhs, rhs) ((lhs) >> (rhs)) +#define VL_BITSEL_IQII(lbits, lhs, rhs) (static_cast((lhs) >> (rhs))) -static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP const lwp, - IData rd) VL_MT_SAFE { +static inline IData VL_BITSEL_IWII(int lbits, WDataInP const lwp, IData rd) VL_MT_SAFE { const int word = VL_BITWORD_E(rd); if (VL_UNLIKELY(rd > static_cast(lbits))) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. @@ -1851,13 +1850,11 @@ static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP const lwp, // EMIT_RULE: VL_RANGE: oclean=lclean; out=dirty // & MUST BE CLEAN (currently constant) -#define VL_SEL_IIII(obits, lbits, rbits, tbits, lhs, lsb, width) ((lhs) >> (lsb)) -#define VL_SEL_QQII(obits, lbits, rbits, tbits, lhs, lsb, width) ((lhs) >> (lsb)) -#define VL_SEL_IQII(obits, lbits, rbits, tbits, lhs, lsb, width) \ - (static_cast((lhs) >> (lsb))) +#define VL_SEL_IIII(lbits, lhs, lsb, width) ((lhs) >> (lsb)) +#define VL_SEL_QQII(lbits, lhs, lsb, width) ((lhs) >> (lsb)) +#define VL_SEL_IQII(lbits, lhs, lsb, width) (static_cast((lhs) >> (lsb))) -static inline IData VL_SEL_IWII(int, int lbits, int, int, WDataInP const lwp, IData lsb, - IData width) VL_MT_SAFE { +static inline IData VL_SEL_IWII(int lbits, WDataInP const lwp, IData lsb, IData width) VL_MT_SAFE { const int msb = lsb + width - 1; if (VL_UNLIKELY(msb >= lbits)) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. @@ -1870,8 +1867,7 @@ static inline IData VL_SEL_IWII(int, int lbits, int, int, WDataInP const lwp, ID } } -static inline QData VL_SEL_QWII(int, int lbits, int, int, WDataInP const lwp, IData lsb, - IData width) VL_MT_SAFE { +static inline QData VL_SEL_QWII(int lbits, WDataInP const lwp, IData lsb, IData width) VL_MT_SAFE { const int msb = lsb + width - 1; if (VL_UNLIKELY(msb > lbits)) { return ~0; // Spec says you can go outside the range of a array. Don't coredump if so. @@ -1892,8 +1888,8 @@ static inline QData VL_SEL_QWII(int, int lbits, int, int, WDataInP const lwp, ID } } -static inline WDataOutP VL_SEL_WWII(int obits, int lbits, int, int, WDataOutP owp, - WDataInP const lwp, IData lsb, IData width) VL_MT_SAFE { +static inline WDataOutP VL_SEL_WWII(int obits, int lbits, WDataOutP owp, WDataInP const lwp, + IData lsb, IData width) VL_MT_SAFE { const int msb = lsb + width - 1; const int word_shift = VL_BITWORD_E(lsb); if (VL_UNLIKELY(msb > lbits)) { // Outside bounds, @@ -1925,7 +1921,7 @@ static inline WDataOutP VL_SEL_WWII(int obits, int lbits, int, int, WDataOutP ow // Return QData from double (numeric) // EMIT_RULE: VL_RTOIROUND_Q_D: oclean=dirty; lclean==clean/real -static inline QData VL_RTOIROUND_Q_D(int, double lhs) VL_PURE { +static inline QData VL_RTOIROUND_Q_D(double lhs) VL_PURE { // IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa // This does not need to support subnormals as they are sub-integral lhs = VL_ROUND(lhs); @@ -1942,8 +1938,8 @@ static inline QData VL_RTOIROUND_Q_D(int, double lhs) VL_PURE { if (lhs < 0) out = -out; return out; } -static inline IData VL_RTOIROUND_I_D(int bits, double lhs) VL_PURE { - return static_cast(VL_RTOIROUND_Q_D(bits, lhs)); +static inline IData VL_RTOIROUND_I_D(double lhs) VL_PURE { + return static_cast(VL_RTOIROUND_Q_D(lhs)); } static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) VL_PURE { // IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa @@ -2009,8 +2005,8 @@ static inline void VL_ASSIGNSEL_WIIW(int rbits, int obits, int lsb, WDataOutP ow //====================================================================== // Triops -static inline WDataOutP VL_COND_WIWW(int obits, int, int, int, WDataOutP owp, int cond, - WDataInP const w1p, WDataInP const w2p) VL_MT_SAFE { +static inline WDataOutP VL_COND_WIWW(int obits, WDataOutP owp, int cond, WDataInP const w1p, + WDataInP const w2p) VL_MT_SAFE { const int words = VL_WORDS_I(obits); for (int i = 0; i < words; ++i) owp[i] = cond ? w1p[i] : w2p[i]; return owp; @@ -2185,15 +2181,14 @@ inline std::string VL_CVT_PACK_STR_NI(IData lhs) VL_PURE { inline std::string VL_CONCATN_NNN(const std::string& lhs, const std::string& rhs) VL_PURE { return lhs + rhs; } -inline std::string VL_REPLICATEN_NNQ(int, int, int, const std::string& lhs, IData rep) VL_PURE { +inline std::string VL_REPLICATEN_NNQ(const std::string& lhs, IData rep) VL_PURE { std::string out; out.reserve(lhs.length() * rep); for (unsigned times = 0; times < rep; ++times) out += lhs; return out; } -inline std::string VL_REPLICATEN_NNI(int obits, int lbits, int rbits, const std::string& lhs, - IData rep) VL_PURE { - return VL_REPLICATEN_NNQ(obits, lbits, rbits, lhs, rep); +inline std::string VL_REPLICATEN_NNI(const std::string& lhs, IData rep) VL_PURE { + return VL_REPLICATEN_NNQ(lhs, rep); } inline IData VL_LEN_IN(const std::string& ld) { return ld.length(); } diff --git a/src/V3Ast.h b/src/V3Ast.h index 4f5d56651..52429b154 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -2143,9 +2143,7 @@ public: AstNode* expr1p() const { return op2p(); } // op2 = If true... AstNode* expr2p() const { return op3p(); } // op3 = If false... virtual string emitVerilog() override { return "%k(%l %f? %r %k: %t)"; } - virtual string emitC() override { - return "VL_COND_%nq%lq%rq%tq(%nw,%lw,%rw,%tw, %P, %li, %ri, %ti)"; - } + virtual string emitC() override { return "VL_COND_%nq%lq%rq%tq(%nw, %P, %li, %ri, %ti)"; } virtual bool cleanOut() const override { return false; } // clean if e1 & e2 clean virtual bool cleanLhs() const override { return true; } virtual bool cleanRhs() const override { return false; } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 88a5ed4c0..dce0fa34e 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -1760,8 +1760,9 @@ public: } virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } virtual string emitC() override { - return this->widthp()->isOne() ? "VL_BITSEL_%nq%lq%rq%tq(%nw,%lw,%rw,%tw, %P, %li, %ri)" - : "VL_SEL_%nq%lq%rq%tq(%nw,%lw,%rw,%tw, %P, %li, %ri, %ti)"; + return widthp()->isOne() ? "VL_BITSEL_%nq%lq%rq%tq(%lw, %P, %li, %ri)" + : isWide() ? "VL_SEL_%nq%lq%rq%tq(%nw,%lw, %P, %li, %ri, %ti)" + : "VL_SEL_%nq%lq%rq%tq(%lw, %P, %li, %ri, %ti)"; } virtual bool cleanOut() const override { return false; } virtual bool cleanLhs() const override { return true; } @@ -5618,7 +5619,7 @@ public: ASTNODE_NODE_FUNCS(RedAnd) virtual void numberOperate(V3Number& out, const V3Number& lhs) override { out.opRedAnd(lhs); } virtual string emitVerilog() override { return "%f(& %l)"; } - virtual string emitC() override { return "VL_REDAND_%nq%lq(%nw,%lw, %P, %li)"; } + virtual string emitC() override { return "VL_REDAND_%nq%lq(%lw, %P, %li)"; } virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } virtual bool sizeMattersLhs() const override { return false; } @@ -5813,7 +5814,9 @@ public: out.opRToIRoundS(lhs); } virtual string emitVerilog() override { return "%f$rtoi_rounded(%l)"; } - virtual string emitC() override { return "VL_RTOIROUND_%nq_D(%nw, %P, %li)"; } + virtual string emitC() override { + return isWide() ? "VL_RTOIROUND_%nq_D(%nw, %P, %li)" : "VL_RTOIROUND_%nq_D(%li)"; + } virtual bool cleanOut() const override { return false; } virtual bool cleanLhs() const override { return false; } virtual bool sizeMattersLhs() const override { return false; } @@ -6935,7 +6938,7 @@ public: out.opLtS(lhs, rhs); } virtual string emitVerilog() override { return "%k(%l %f< %r)"; } - virtual string emitC() override { return "VL_LTS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_LTS_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual string emitSimpleOperator() override { return ""; } virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } @@ -7028,7 +7031,7 @@ public: out.opGtS(lhs, rhs); } virtual string emitVerilog() override { return "%k(%l %f> %r)"; } - virtual string emitC() override { return "VL_GTS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_GTS_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual string emitSimpleOperator() override { return ""; } virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } @@ -7121,7 +7124,7 @@ public: out.opGteS(lhs, rhs); } virtual string emitVerilog() override { return "%k(%l %f>= %r)"; } - virtual string emitC() override { return "VL_GTES_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_GTES_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual string emitSimpleOperator() override { return ""; } virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } @@ -7214,7 +7217,7 @@ public: out.opLteS(lhs, rhs); } virtual string emitVerilog() override { return "%k(%l %f<= %r)"; } - virtual string emitC() override { return "VL_LTES_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_LTES_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual string emitSimpleOperator() override { return ""; } virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } @@ -7475,7 +7478,7 @@ public: out.opMulS(lhs, rhs); } virtual string emitVerilog() override { return "%k(%l %f* %r)"; } - virtual string emitC() override { return "VL_MULS_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_MULS_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual string emitSimpleOperator() override { return ""; } virtual bool emitCheckMaxWords() override { return true; } virtual bool cleanOut() const override { return false; } @@ -7987,7 +7990,7 @@ public: out.opRepl(lhs, rhs); } virtual string emitVerilog() override { return "%f{%r{%k%l}}"; } - virtual string emitC() override { return "VL_REPLICATE_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_REPLICATE_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual bool cleanOut() const override { return false; } virtual bool cleanLhs() const override { return true; } virtual bool cleanRhs() const override { return true; } @@ -8012,7 +8015,7 @@ public: out.opReplN(lhs, rhs); } virtual string emitVerilog() override { return "%f{%r{%k%l}}"; } - virtual string emitC() override { return "VL_REPLICATEN_NN%rq(0,0,%rw, %li, %ri)"; } + virtual string emitC() override { return "VL_REPLICATEN_NN%rq(%li, %ri)"; } virtual bool cleanOut() const override { return false; } virtual bool cleanLhs() const override { return true; } virtual bool cleanRhs() const override { return true; } @@ -8034,7 +8037,7 @@ public: virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) override { out.opStreamL(lhs, rhs); } - virtual string emitC() override { return "VL_STREAML_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)"; } + virtual string emitC() override { return "VL_STREAML_%nq%lq%rq(%lw, %P, %li, %ri)"; } virtual bool cleanOut() const override { return true; } virtual bool cleanLhs() const override { return true; } virtual bool cleanRhs() const override { return true; } diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index 4fa90a942..a301e13cb 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -265,20 +265,21 @@ public: virtual void visit(AstNodeAssign* nodep) override { bool paren = true; bool decind = false; + bool rhs = true; if (AstSel* const selp = VN_CAST(nodep->lhsp(), Sel)) { if (selp->widthMin() == 1) { putbs("VL_ASSIGNBIT_"); emitIQW(selp->fromp()); if (nodep->rhsp()->isAllOnesV()) { puts("O("); + rhs = false; } else { puts("I("); } - puts(cvtToStr(nodep->widthMin()) + ","); iterateAndNextNull(selp->lsbp()); puts(", "); iterateAndNextNull(selp->fromp()); - puts(", "); + if (rhs) puts(", "); } else { putbs("VL_ASSIGNSEL_"); emitIQW(selp->fromp()); @@ -339,7 +340,7 @@ public: if (!VN_IS(nodep->rhsp(), Const)) ofp()->putBreak(); puts("= "); } - iterateAndNextNull(nodep->rhsp()); + if (rhs) iterateAndNextNull(nodep->rhsp()); if (paren) puts(")"); if (decind) ofp()->blockDec(); puts(";\n"); @@ -1049,9 +1050,7 @@ public: puts("VL_REPLICATE_"); emitIQW(nodep); puts("OI("); - puts(cvtToStr(nodep->widthMin())); - if (nodep->lhsp()) puts("," + cvtToStr(nodep->lhsp()->widthMin())); - if (nodep->rhsp()) puts("," + cvtToStr(nodep->rhsp()->widthMin())); + if (nodep->lhsp()) puts(cvtToStr(nodep->lhsp()->widthMin())); puts(","); iterateAndNextNull(nodep->lhsp()); puts(", "); @@ -1071,10 +1070,8 @@ public: emitIQW(nodep); emitIQW(nodep->lhsp()); puts("I("); - puts(cvtToStr(nodep->widthMin())); - puts("," + cvtToStr(nodep->lhsp()->widthMin())); - puts("," + cvtToStr(nodep->rhsp()->widthMin())); - puts(","); + puts(cvtToStr(nodep->lhsp()->widthMin())); + puts(", "); iterateAndNextNull(nodep->lhsp()); puts(", "); const uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt()); @@ -1082,8 +1079,8 @@ public: return; } } - emitOpName(nodep, "VL_STREAML_%nq%lq%rq(%nw,%lw,%rw, %P, %li, %ri)", nodep->lhsp(), - nodep->rhsp(), nullptr); + emitOpName(nodep, "VL_STREAML_%nq%lq%rq(%lw, %P, %li, %ri)", nodep->lhsp(), nodep->rhsp(), + nullptr); } virtual void visit(AstCastDynamic* nodep) override { putbs("VL_CAST_DYNAMIC("); From 98037cad56b67eac08982bc9af75cc5a24cfc3d4 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 14:00:19 -0500 Subject: [PATCH 72/79] Internals: Optimize VL_RANDOM to have unclean output --- include/verilated.cpp | 12 ++++++------ include/verilated_funcs.h | 7 ++++--- src/V3AstNodes.h | 9 +++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index b3cca5256..96ad788e4 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -312,23 +312,23 @@ vluint64_t vl_rand64() VL_MT_SAFE { // VL_RANDOM_W currently unused as $random always 32 bits, left for backwards compatibility // LCOV_EXCL_START WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp) VL_MT_SAFE { - for (int i = 0; i < VL_WORDS_I(obits) - 1; ++i) outwp[i] = vl_rand64(); - outwp[VL_WORDS_I(obits) - 1] = vl_rand64() & VL_MASK_E(obits); + for (int i = 0; i < VL_WORDS_I(obits); ++i) outwp[i] = vl_rand64(); + // Last word is unclean return outwp; } // LCOV_EXCL_STOP #endif -IData VL_RANDOM_SEEDED_II(int obits, IData seed) VL_MT_SAFE { +IData VL_RANDOM_SEEDED_II(IData seed) VL_MT_SAFE { Verilated::threadContextp()->randSeed(static_cast(seed)); - return VL_RANDOM_I(obits); + return VL_RANDOM_I(); } IData VL_RAND_RESET_I(int obits) VL_MT_SAFE { if (Verilated::threadContextp()->randReset() == 0) return 0; IData data = ~0; if (Verilated::threadContextp()->randReset() != 1) { // if 2, randomize - data = VL_RANDOM_I(obits); + data = VL_RANDOM_I(); } data &= VL_MASK_I(obits); return data; @@ -337,7 +337,7 @@ QData VL_RAND_RESET_Q(int obits) VL_MT_SAFE { if (Verilated::threadContextp()->randReset() == 0) return 0; QData data = ~0ULL; if (Verilated::threadContextp()->randReset() != 1) { // if 2, randomize - data = VL_RANDOM_Q(obits); + data = VL_RANDOM_Q(); } data &= VL_MASK_Q(obits); return data; diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index a825163ea..5442260cf 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -73,12 +73,13 @@ extern void VL_PRINTF_MT(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; /// Print a debug message from internals with standard prefix, with printf style format extern void VL_DBG_MSGF(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; -inline IData VL_RANDOM_I(int obits) VL_MT_SAFE { return vl_rand64() & VL_MASK_I(obits); } -inline QData VL_RANDOM_Q(int obits) VL_MT_SAFE { return vl_rand64() & VL_MASK_Q(obits); } +// EMIT_RULE: VL_RANDOM: oclean=dirty +inline IData VL_RANDOM_I() VL_MT_SAFE { return vl_rand64(); } +inline QData VL_RANDOM_Q() VL_MT_SAFE { return vl_rand64(); } #ifndef VL_NO_LEGACY extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); #endif -extern IData VL_RANDOM_SEEDED_II(int obits, IData seed) VL_MT_SAFE; +extern IData VL_RANDOM_SEEDED_II(IData seed) VL_MT_SAFE; inline IData VL_URANDOM_RANGE_I(IData hi, IData lo) { const vluint64_t rnd = vl_rand64(); if (VL_LIKELY(hi > lo)) { diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index dce0fa34e..3524454d4 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -5471,11 +5471,12 @@ public: : (m_urandom ? "%f$urandom()" : "%f$random()"); } virtual string emitC() override { - return m_reset ? "VL_RAND_RESET_%nq(%nw, %P)" - : seedp() ? "VL_RANDOM_SEEDED_%nq%lq(%nw, %P, %li)" - : "VL_RANDOM_%nq(%nw, %P)"; + return m_reset ? "VL_RAND_RESET_%nq(%nw, %P)" + : seedp() ? "VL_RANDOM_SEEDED_%nq%lq(%li)" + : isWide() ? "VL_RANDOM_%nq(%nw, %P)" // + : "VL_RANDOM_%nq()"; } - virtual bool cleanOut() const override { return true; } + virtual bool cleanOut() const override { return false; } virtual bool isGateOptimizable() const override { return false; } virtual bool isPredictOptimizable() const override { return false; } virtual int instrCount() const override { return INSTR_COUNT_PLI; } From ffdc0afe5ff020612d475dbdce501e3f5f176545 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 14:10:50 -0500 Subject: [PATCH 73/79] Disable unintended debug message --- src/V3Width.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 0fcb1d7d3..d8ab99fce 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1813,14 +1813,14 @@ private: } if (!newp) newp = nodep->fromp()->unlinkFrBack(); nodep->lhsp(newp); - if (debug()) nodep->dumpTree(cout, " CastOut: "); - if (debug()) nodep->backp()->dumpTree(cout, " CastOutUpUp: "); + // if (debug()) nodep->dumpTree(cout, " CastOut: "); + // if (debug()) nodep->backp()->dumpTree(cout, " CastOutUpUp: "); } if (m_vup->final()) { iterateCheck(nodep, "value", nodep->lhsp(), SELF, FINAL, nodep->lhsp()->dtypep(), EXTEND_EXP, false); AstNode* const underp = nodep->lhsp()->unlinkFrBack(); - if (debug()) underp->dumpTree(cout, " CastRep: "); + // if (debug()) underp->dumpTree(cout, " CastRep: "); nodep->replaceWith(underp); VL_DO_DANGLING(pushDeletep(nodep), nodep); } From 692306ef4425bed9aab5f808747e36bf975bcfa5 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 14:17:28 -0500 Subject: [PATCH 74/79] Optimize $random concatenates/selects (#3114). --- Changes | 1 + include/verilated.cpp | 5 --- include/verilated_funcs.h | 2 - src/V3AstNodes.h | 4 ++ src/V3Const.cpp | 25 ++++++++++++ test_regress/t/t_sys_rand_concat.pl | 23 +++++++++++ test_regress/t/t_sys_rand_concat.v | 60 +++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 7 deletions(-) create mode 100755 test_regress/t/t_sys_rand_concat.pl create mode 100644 test_regress/t/t_sys_rand_concat.v diff --git a/Changes b/Changes index 3362d93e7..467fb4ea0 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,7 @@ Verilator 4.215 devel * Improve --thread verilation-time performance. * Support task name in $display %m (#3211). [Julie Schwartz] * Make 'bit', 'logic' and 'time' types unsigned by default. [Geza Lore] +* Optimize $random concatenates/selects (#3114). * Fix array method names with parenthesis (#3181) (#3183). [Teng Huang] * Fix split_var assign merging (#3177) (#3179). [Yutetsu TAKATSUKASA] * Fix wrong bit op tree optimization (#3185). [Yutetsu TAKATSUKASA] diff --git a/include/verilated.cpp b/include/verilated.cpp index 96ad788e4..40c51f000 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -308,16 +308,11 @@ vluint64_t vl_rand64() VL_MT_SAFE { return result; } -#ifndef VL_NO_LEGACY -// VL_RANDOM_W currently unused as $random always 32 bits, left for backwards compatibility -// LCOV_EXCL_START WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp) VL_MT_SAFE { for (int i = 0; i < VL_WORDS_I(obits); ++i) outwp[i] = vl_rand64(); // Last word is unclean return outwp; } -// LCOV_EXCL_STOP -#endif IData VL_RANDOM_SEEDED_II(IData seed) VL_MT_SAFE { Verilated::threadContextp()->randSeed(static_cast(seed)); diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index 5442260cf..bd1369421 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -76,9 +76,7 @@ extern void VL_DBG_MSGF(const char* formatp, ...) VL_ATTR_PRINTF(1) VL_MT_SAFE; // EMIT_RULE: VL_RANDOM: oclean=dirty inline IData VL_RANDOM_I() VL_MT_SAFE { return vl_rand64(); } inline QData VL_RANDOM_Q() VL_MT_SAFE { return vl_rand64(); } -#ifndef VL_NO_LEGACY extern WDataOutP VL_RANDOM_W(int obits, WDataOutP outwp); -#endif extern IData VL_RANDOM_SEEDED_II(IData seed) VL_MT_SAFE; inline IData VL_URANDOM_RANGE_I(IData hi, IData lo) { const vluint64_t rnd = vl_rand64(); diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 3524454d4..fb598bfaf 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -5481,6 +5481,10 @@ public: virtual bool isPredictOptimizable() const override { return false; } virtual int instrCount() const override { return INSTR_COUNT_PLI; } virtual bool same(const AstNode* samep) const override { return true; } + bool combinable(const AstRand* samep) const { + return !seedp() && !samep->seedp() && reset() == samep->reset() + && urandom() == samep->urandom(); + } AstNode* seedp() const { return op1p(); } bool reset() const { return m_reset; } bool urandom() const { return m_urandom; } diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 62ef412c6..dedebfb2a 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -2229,6 +2229,29 @@ private: iterate(nodep); // Again? } + bool matchConcatRand(AstConcat* nodep) { + // CONCAT(RAND, RAND) - created by Chisel code + AstRand* const aRandp = VN_CAST(nodep->lhsp(), Rand); + AstRand* const bRandp = VN_CAST(nodep->rhsp(), Rand); + if (!aRandp || !bRandp) return false; + if (!aRandp->combinable(bRandp)) return false; + UINFO(4, "Concat(Rand,Rand) => Rand: " << nodep << endl); + aRandp->dtypeFrom(nodep); // I.e. the total width + nodep->replaceWith(aRandp->unlinkFrBack()); + VL_DO_DANGLING(nodep->deleteTree(), nodep); + return true; + } + bool matchSelRand(AstSel* nodep) { + // SEL(RAND) - created by Chisel code + AstRand* const aRandp = VN_CAST(nodep->fromp(), Rand); + if (!aRandp) return false; + if (aRandp->seedp()) return false; + UINFO(4, "Sel(Rand) => Rand: " << nodep << endl); + aRandp->dtypeFrom(nodep); // I.e. the total width + nodep->replaceWith(aRandp->unlinkFrBack()); + VL_DO_DANGLING(nodep->deleteTree(), nodep); + return true; + } int operandConcatMove(AstConcat* nodep) { // CONCAT under concat (See moveConcat) // Return value: true indicates to do it; 2 means move to LHS @@ -3364,6 +3387,7 @@ private: TREEOPV("AstLogNot{$lhsp.width1, isTPure($lhsp)}", "AstNot{$lhsp}"); // CONCAT(CONCAT({a},{b}),{c}) -> CONCAT({a},CONCAT({b},{c})) // CONCAT({const},CONCAT({const},{c})) -> CONCAT((constifiedCONC{const|const},{c})) + TREEOPV("AstConcat{matchConcatRand(nodep)}", "DONE"); TREEOPV("AstConcat{operandConcatMove(nodep)}", "moveConcat(nodep)"); TREEOPV("AstConcat{$lhsp.isZero, $rhsp}", "replaceExtend(nodep, nodep->rhsp())"); // CONCAT(a[1],a[0]) -> a[1:0] @@ -3392,6 +3416,7 @@ private: TREEOPV("AstConcat{operandConcatSame(nodep)}", "DONE"); // {a,a}->{2{a}}, {a,2{a}}->{3{a}, etc // Next rule because AUTOINST puts the width of bits in // to pins, even when the widths are exactly the same across the hierarchy. + TREEOPV("AstSel{matchSelRand(nodep)}", "DONE"); TREEOPV("AstSel{operandSelExtend(nodep)}", "DONE"); TREEOPV("AstSel{operandSelFull(nodep)}", "replaceWChild(nodep, nodep->fromp())"); TREEOPV("AstSel{$fromp.castSel}", "replaceSelSel(nodep)"); diff --git a/test_regress/t/t_sys_rand_concat.pl b/test_regress/t/t_sys_rand_concat.pl new file mode 100755 index 000000000..62d68c9f8 --- /dev/null +++ b/test_regress/t/t_sys_rand_concat.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +scenarios(simulator => 1); + +compile( + ); + +execute( + check_finished => 1, + ); + +file_grep_not(glob_one("$Self->{obj_dir}/Vt_sys_rand_concat___024root__DepSet_*__0__Slow.cpp"), qr/(<<|>>)/x); + +ok(1); +1; diff --git a/test_regress/t/t_sys_rand_concat.v b/test_regress/t/t_sys_rand_concat.v new file mode 100644 index 000000000..820834dc2 --- /dev/null +++ b/test_regress/t/t_sys_rand_concat.v @@ -0,0 +1,60 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain, for +// any use, without warranty, 2008 by Wilson Snyder. +// SPDX-License-Identifier: CC0-1.0 + +`define stop $stop +`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0) + +module t; + +`define TRIES 100 + + bit [6:0] b5a; // We use larger than [4:0] so make sure we truncate + bit [6:0] b5b; // We use larger than [4:0] so make sure we truncate + bit [6:0] b7c; + bit [6:0] b7d; + bit [59:0] b60c; + bit [89:0] b90c; + + bit [6:0] max_b5a; + bit [6:0] max_b5b; + bit [6:0] max_b7c; + bit [6:0] max_b7d; + bit [59:0] max_b60c; + bit [89:0] max_b90c; + + initial begin + for (int i = 0; i < `TRIES; ++i) begin + // verilator lint_off WIDTH + // Optimize away extracts + b5a = {$random}[4:0]; + b5b = {$random}[14:10]; + // Optimize away concats + b7c = {$random, $random, $random, $random, $random, $random, $random}; + b7d = {{{$random}[0]}, {{$random}[0]}, {{$random}[0]}, {{$random}[0]}, {{$random}[0]}}; + b60c = {$random, $random, $random, $random, $random, $random, $random}; + b90c = {$random, $random, $random, $random, $random, $random, $random}; + // verilator lint_on WIDTH + + max_b5a = max_b5a | b5a; + max_b5b = max_b5b | b5b; + max_b7c = max_b7c | b7c; + max_b7d = max_b7d | b7d; + max_b60c = max_b60c | b60c; + max_b90c = max_b90c | b90c; + end + + `checkh(max_b5a, 7'h1f); + `checkh(max_b5b, 7'h1f); + `checkh(max_b7c, 7'h7f); + `checkh(max_b7d, 7'h1f); + `checkh(max_b60c, ~ 60'h0); + `checkh(max_b90c, ~ 90'h0); + + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule From e814855357b0007cdadf748c33f149e5e1b36494 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 15:33:33 -0500 Subject: [PATCH 75/79] Tests: Skip gdb tests if no gdb --- test_regress/t/t_debug_fatalsrc_bad.pl | 16 ++++++++++------ test_regress/t/t_debug_fatalsrc_bt_bad.pl | 19 ++++++++++++------- test_regress/t/t_debug_sigsegv_bad.pl | 21 +++++++++++++-------- test_regress/t/t_debug_sigsegv_bt_bad.pl | 22 +++++++++++++--------- 4 files changed, 48 insertions(+), 30 deletions(-) diff --git a/test_regress/t/t_debug_fatalsrc_bad.pl b/test_regress/t/t_debug_fatalsrc_bad.pl index c11da33d9..a0cc619db 100755 --- a/test_regress/t/t_debug_fatalsrc_bad.pl +++ b/test_regress/t/t_debug_fatalsrc_bad.pl @@ -10,13 +10,17 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di scenarios(vlt => 1); -lint( - verilator_flags2 => ["--debug-fatalsrc"], - fails => $Self->{vlt_all}, - expect => +if (system("gdb --version")) { + skip("No gdb installed"); +} else { + lint( + verilator_flags2 => ["--debug-fatalsrc"], + fails => $Self->{vlt_all}, + expect => '%Error: Internal Error: .*: --debug-fatal-src .* See the manual .*', - ); + ); -ok(1); + ok(1); +} 1; diff --git a/test_regress/t/t_debug_fatalsrc_bt_bad.pl b/test_regress/t/t_debug_fatalsrc_bt_bad.pl index 8be054a7b..4471fbf46 100755 --- a/test_regress/t/t_debug_fatalsrc_bt_bad.pl +++ b/test_regress/t/t_debug_fatalsrc_bt_bad.pl @@ -9,17 +9,22 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 scenarios(vlt => 1); -$ENV{VERILATOR_TEST_NO_GDB} and skip("Skipping due to VERILATOR_TEST_NO_GDB"); -lint( - verilator_flags2 => ["--lint-only --debug --gdbbt --debug-fatalsrc"], - fails => 1, - expect => +if ($ENV{VERILATOR_TEST_NO_GDB}) { + skip("Skipping due to VERILATOR_TEST_NO_GDB"); +} elsif (system("gdb --version")) { + skip("No gdb installed"); +} else { + lint( + verilator_flags2 => ["--lint-only --debug --gdbbt --debug-fatalsrc"], + fails => 1, + expect => '%Error: Internal Error: .*: --debug-fatal-src .*See the manual .* .*in V3Options::.* .*%Error: Command Failed.*', - ); + ); + ok(1); +} -ok(1); 1; diff --git a/test_regress/t/t_debug_sigsegv_bad.pl b/test_regress/t/t_debug_sigsegv_bad.pl index 631892fd9..ad73ac6f9 100755 --- a/test_regress/t/t_debug_sigsegv_bad.pl +++ b/test_regress/t/t_debug_sigsegv_bad.pl @@ -9,16 +9,21 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 scenarios(vlt => 1); -$ENV{VERILATOR_TEST_NO_GDB} and skip("Skipping due to VERILATOR_TEST_NO_GDB"); -lint( - v_flags => ["--debug-sigsegv"], - fails => 1, - sanitize => 0, - expect => +if ($ENV{VERILATOR_TEST_NO_GDB}) { + skip("Skipping due to VERILATOR_TEST_NO_GDB"); +} elsif (system("gdb --version")) { + skip("No gdb installed"); +} else { + lint( + v_flags => ["--debug-sigsegv"], + fails => 1, + sanitize => 0, + expect => '%Error: Verilator internal fault, sorry. Suggest trying --debug --gdbbt %Error: Command Failed.*', - ); + ); -ok(1); + ok(1); +} 1; diff --git a/test_regress/t/t_debug_sigsegv_bt_bad.pl b/test_regress/t/t_debug_sigsegv_bt_bad.pl index fcee4ee37..c6dd7a9a4 100755 --- a/test_regress/t/t_debug_sigsegv_bt_bad.pl +++ b/test_regress/t/t_debug_sigsegv_bt_bad.pl @@ -9,18 +9,22 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 scenarios(vlt => 1); -$ENV{VERILATOR_TEST_NO_GDB} and skip("Skipping due to VERILATOR_TEST_NO_GDB"); - -lint( - verilator_flags2 => ["--lint-only --debug --gdbbt --debug-sigsegv"], - sanitize => 0, - fails => $Self->{vlt_all}, - expect => +if ($ENV{VERILATOR_TEST_NO_GDB}) { + skip("Skipping due to VERILATOR_TEST_NO_GDB"); +} elsif (system("gdb --version")) { + skip("No gdb installed"); +} else { + lint( + verilator_flags2 => ["--lint-only --debug --gdbbt --debug-sigsegv"], + sanitize => 0, + fails => $Self->{vlt_all}, + expect => '.* Program received signal SIGSEGV, Segmentation fault. .*in V3Options::.* .*%Error: Command Failed.*', - ); + ); -ok(1); + ok(1); +} 1; From ca09f73446f38a064093af6487f71edc723664ea Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 15:40:35 -0500 Subject: [PATCH 76/79] Tests: Fix open test on some automount cloud providers --- test_regress/t/t_savable_open_bad2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_regress/t/t_savable_open_bad2.cpp b/test_regress/t/t_savable_open_bad2.cpp index 61f04db42..f9faddd91 100644 --- a/test_regress/t/t_savable_open_bad2.cpp +++ b/test_regress/t/t_savable_open_bad2.cpp @@ -27,12 +27,12 @@ int main(int argc, char* argv[]) { Verilated::debug(0); { VerilatedSave os; - os.open("/No_such_file_as_this"); + os.open("/No/such_file_as_this"); TEST_CHECK_EQ(os.isOpen(), false); } { VerilatedRestore os; - os.open("/No_such_file_as_this"); + os.open("/No/such_file_as_this"); TEST_CHECK_EQ(os.isOpen(), false); } From 293a5f402b3f77759ecb7334db68ef0e24b75ad5 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 28 Nov 2021 15:47:19 -0500 Subject: [PATCH 77/79] Fix timescale portability on Arm64 (#3222). --- Changes | 1 + include/verilatedos.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 467fb4ea0..e928d1ea2 100644 --- a/Changes +++ b/Changes @@ -35,6 +35,7 @@ Verilator 4.215 devel * Fix $fopen etc on integer arrays (#3214). [adrienlemasle] * Fix $size on dynamic strings (#3216). * Fix %0 format on $value$plusargs (#3217). +* Fix timescale portability on Arm64 (#3222). Verilator 4.214 2021-10-17 diff --git a/include/verilatedos.h b/include/verilatedos.h index 9a1f50a75..b6a837663 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -333,7 +333,8 @@ typedef signed __int32 ssize_t; ///< signed size_t; returned from read() # include // Linux and most flavors # include // __WORDSIZE # include // ssize_t -typedef char vlsint8_t; ///< 8-bit signed type +// Arm64 gcc 9.3.0 defaults to unsigned char, not signed char +typedef signed char vlsint8_t; ///< 8-bit signed type typedef uint8_t vluint8_t; ///< 8-bit unsigned type typedef short vlsint16_t; ///< 16-bit signed type typedef uint16_t vluint16_t; ///< 16-bit unsigned type From 1160dddc6d54f40563afad20a7114fdeb3578ba0 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Tue, 30 Nov 2021 23:20:00 +0900 Subject: [PATCH 78/79] Fix bit op tree optimization (#3221) * Add a test to reproduce #3197 * Fix #3197. Optimize correctly even if a variable is >32 * Quick exit instead of continue. No functional change is intended. * Delete comment-out line. * update per review comment --- src/V3Const.cpp | 2 +- test_regress/t/t_const_opt.v | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/V3Const.cpp b/src/V3Const.cpp index dedebfb2a..5011b7711 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -572,7 +572,7 @@ class ConstBitOpTreeVisitor final : public AstNVisitor { incrOps(andp, __LINE__); // Mark all bits checked by this comparison - const int maxBitIdx = std::min(ref.m_lsb + compNum.width(), ref.width()); + const int maxBitIdx = std::min(ref.m_lsb + maskNum.width(), ref.width()); for (int bitIdx = ref.m_lsb; bitIdx < maxBitIdx; ++bitIdx) { const int maskIdx = bitIdx - ref.m_lsb; if (maskNum.bitIs0(maskIdx)) continue; diff --git a/test_regress/t/t_const_opt.v b/test_regress/t/t_const_opt.v index eb6097355..be1e49c03 100644 --- a/test_regress/t/t_const_opt.v +++ b/test_regress/t/t_const_opt.v @@ -57,7 +57,7 @@ module t(/*AUTOARG*/ $write("[%0t] cyc==%0d crc=%x sum=%x\n", $time, cyc, crc, sum); if (crc !== 64'hc77bb9b3784ea091) $stop; // What checksum will we end up with (above print should match) -`define EXPECTED_SUM 64'ha916d9291821c6e0 +`define EXPECTED_SUM 64'hcae926ece668f35d if (sum !== `EXPECTED_SUM) $stop; $write("*-* All Finished *-*\n"); $finish; @@ -78,10 +78,11 @@ module Test(/*AUTOARG*/ logic [31:0] d; logic d0, d1, d2, d3, d4, d5, d6, d7; logic bug3182_out; + logic bug3197_out; output logic o; - logic [5:0] tmp; + logic [6:0] tmp; assign o = ^tmp; always_ff @(posedge clk) begin @@ -103,9 +104,11 @@ module Test(/*AUTOARG*/ tmp[3] <= d0 <-> d1; // replaceLogEq() tmp[4] <= i[0] & (i[1] & (i[2] & (i[3] | d[4]))); // ConstBitOpTreeVisitor::m_frozenNodes tmp[5] <= bug3182_out; + tmp[6] <= bug3197_out; end bug3182 i_bug3182(.in(d[4:0]), .out(bug3182_out)); + bug3197 i_bug3197(.clk(clk), .in(d), .out(bug3197_out)); endmodule @@ -128,3 +131,12 @@ module bug3182(in, out); wire out = ~(tmp >> 5) & (bit_source == 5'd10); /* verilator lint_on WIDTH */ endmodule + +module bug3197(input wire clk, input wire [31:0] in, output out); + logic [63:0] d; + always_ff @(posedge clk) + d <= {d[31:0], in[0] ? in : 32'b0}; + + wire tmp0 = (|d[38:0]); + assign out = (d[39] | tmp0); +endmodule From 935032366fac113e2c760a8d6df8abf5662335fa Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 5 Dec 2021 11:10:19 -0500 Subject: [PATCH 79/79] Version bump --- Changes | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index e928d1ea2..5e63dfaec 100644 --- a/Changes +++ b/Changes @@ -8,7 +8,7 @@ The changes in each Verilator version are described below. The contributors that suggested a given feature are shown in []. Thanks! -Verilator 4.215 devel +Verilator 4.216 2021-12-05 ========================== **Major:** diff --git a/configure.ac b/configure.ac index 75f9a35d3..0b0ad9b3a 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ #AC_INIT([Verilator],[#.### YYYY-MM-DD]) #AC_INIT([Verilator],[#.### devel]) -AC_INIT([Verilator],[4.215 devel], +AC_INIT([Verilator],[4.216 2021-12-05], [https://verilator.org], [verilator],[https://verilator.org]) # When releasing, also update header of Changes file