From 8f40d6617e300ed47cf3f4b94ad1ce2294fdab1b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 26 Jan 2012 08:29:55 -0500 Subject: [PATCH] For generated variables, opt towards 2-state so zero init --- src/V3Ast.h | 1 + src/V3AstNodes.h | 13 +++++++++++++ src/V3Delayed.cpp | 4 ++-- src/V3EmitC.cpp | 2 +- src/V3LinkJump.cpp | 2 +- src/V3Table.cpp | 4 ++-- src/V3Trace.cpp | 2 +- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index ef0444b7c..bc55221f9 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -36,6 +36,7 @@ // Hint class so we can choose constructors class AstLogicPacked {}; +class AstBitPacked {}; //###################################################################### diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 3314a2eea..c03d1f9b6 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -254,6 +254,11 @@ public: init(AstBasicDTypeKwd::LOGIC, signedst_NOP, ((wantwidth > 1) ? new AstRange(fl, wantwidth-1, 0) : NULL)); } + AstBasicDType(FileLine* fl, AstBitPacked, int wantwidth) + : AstNodeDType(fl) { + init(AstBasicDTypeKwd::BIT, signedst_NOP, + ((wantwidth > 1) ? new AstRange(fl, wantwidth-1, 0) : NULL)); + } // See also addRange in verilog.y private: void init(AstBasicDTypeKwd kwd, AstSignedState signst, AstRange* rangep) { @@ -626,6 +631,14 @@ public: setOp1p(new AstBasicDType(fl, AstLogicPacked(), wantwidth)); width(wantwidth,0); } + AstVar(FileLine* fl, AstVarType type, const string& name, AstBitPacked, int wantwidth) + :AstNode(fl) + , m_name(name) { + init(); + combineType(type); + setOp1p(new AstBasicDType(fl, AstBitPacked(), wantwidth)); + width(wantwidth,0); + } AstVar(FileLine* fl, AstVarType type, const string& name, AstVar* examplep) :AstNode(fl) , m_name(name) { diff --git a/src/V3Delayed.cpp b/src/V3Delayed.cpp index 5469e04fd..4abc458b3 100644 --- a/src/V3Delayed.cpp +++ b/src/V3Delayed.cpp @@ -133,8 +133,8 @@ private: if (width==0) { varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, oldvarscp->varp()); varp->widthSignedFrom(oldvarscp); - } else { - varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, AstLogicPacked(), width); + } else { // Used for vset and dimensions, so can zero init + varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, AstBitPacked(), width); } addmodp->addStmtp(varp); m_modVarMap.insert(make_pair(make_pair(addmodp, name), varp)); diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index dcde232c6..0c3bd55c6 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -1353,7 +1353,7 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) { puts(varp->name()); for (int v=0; vfileline(), AstVarType::BLOCKTEMP, name, - AstLogicPacked(), 32); + AstBitPacked(), 32); varp->numeric(AstNumeric::SIGNED); varp->dtypep()->numeric(AstNumeric::SIGNED); varp->usedLoopIdx(true); diff --git a/src/V3Table.cpp b/src/V3Table.cpp index a141743df..0be0a9b30 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -182,7 +182,7 @@ private: // Index into our table AstVar* indexVarp = new AstVar (nodep->fileline(), AstVarType::BLOCKTEMP, "__Vtableidx" + cvtToStr(m_modTables), - AstLogicPacked(), m_inWidth); + AstBitPacked(), m_inWidth); m_modp->addStmtp(indexVarp); AstVarScope* indexVscp = new AstVarScope (indexVarp->fileline(), m_scopep, indexVarp); m_scopep->addVarp(indexVscp); @@ -193,7 +193,7 @@ private: = new AstVar (fl, AstVarType::MODULETEMP, "__Vtablechg" + cvtToStr(m_modTables), new AstArrayDType (fl, - new AstBasicDType(fl, AstLogicPacked(), m_outVarps.size()), + new AstBasicDType(fl, AstBitPacked(), m_outVarps.size()), new AstRange (fl, VL_MASK_I(m_inWidth), 0))); chgVarp->isConst(true); chgVarp->valuep(new AstInitArray (nodep->fileline(), NULL)); diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 172e50a1d..19aad0900 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -313,7 +313,7 @@ private: if (!activityNumber) activityNumber++; // For simplicity, always create it int activityBits = VL_WORDS_I(activityNumber)*VL_WORDSIZE; // For tighter code; round to next 32 bit point. AstVar* newvarp = new AstVar (m_chgFuncp->fileline(), AstVarType::MODULETEMP, - "__Vm_traceActivity", AstLogicPacked(), activityBits); + "__Vm_traceActivity", AstBitPacked(), activityBits); m_topModp->addStmtp(newvarp); AstVarScope* newvscp = new AstVarScope(newvarp->fileline(), m_highScopep, newvarp); m_highScopep->addVarp(newvscp);