mirror of
https://github.com/verilator/verilator.git
synced 2025-04-21 12:06:55 +00:00
For generated variables, opt towards 2-state so zero init
This commit is contained in:
parent
af9e85bda1
commit
8f40d6617e
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
// Hint class so we can choose constructors
|
// Hint class so we can choose constructors
|
||||||
class AstLogicPacked {};
|
class AstLogicPacked {};
|
||||||
|
class AstBitPacked {};
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
|
|
||||||
|
@ -254,6 +254,11 @@ public:
|
|||||||
init(AstBasicDTypeKwd::LOGIC, signedst_NOP,
|
init(AstBasicDTypeKwd::LOGIC, signedst_NOP,
|
||||||
((wantwidth > 1) ? new AstRange(fl, wantwidth-1, 0) : NULL));
|
((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
|
// See also addRange in verilog.y
|
||||||
private:
|
private:
|
||||||
void init(AstBasicDTypeKwd kwd, AstSignedState signst, AstRange* rangep) {
|
void init(AstBasicDTypeKwd kwd, AstSignedState signst, AstRange* rangep) {
|
||||||
@ -626,6 +631,14 @@ public:
|
|||||||
setOp1p(new AstBasicDType(fl, AstLogicPacked(), wantwidth));
|
setOp1p(new AstBasicDType(fl, AstLogicPacked(), wantwidth));
|
||||||
width(wantwidth,0);
|
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)
|
AstVar(FileLine* fl, AstVarType type, const string& name, AstVar* examplep)
|
||||||
:AstNode(fl)
|
:AstNode(fl)
|
||||||
, m_name(name) {
|
, m_name(name) {
|
||||||
|
@ -133,8 +133,8 @@ private:
|
|||||||
if (width==0) {
|
if (width==0) {
|
||||||
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, oldvarscp->varp());
|
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, oldvarscp->varp());
|
||||||
varp->widthSignedFrom(oldvarscp);
|
varp->widthSignedFrom(oldvarscp);
|
||||||
} else {
|
} else { // Used for vset and dimensions, so can zero init
|
||||||
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, AstLogicPacked(), width);
|
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, AstBitPacked(), width);
|
||||||
}
|
}
|
||||||
addmodp->addStmtp(varp);
|
addmodp->addStmtp(varp);
|
||||||
m_modVarMap.insert(make_pair(make_pair(addmodp, name), varp));
|
m_modVarMap.insert(make_pair(make_pair(addmodp, name), varp));
|
||||||
|
@ -1353,7 +1353,7 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) {
|
|||||||
puts(varp->name());
|
puts(varp->name());
|
||||||
for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
|
for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
|
||||||
if (zeroit) {
|
if (zeroit) {
|
||||||
puts("= 0;\n");
|
puts(" = 0;\n");
|
||||||
} else {
|
} else {
|
||||||
puts(" = VL_RAND_RESET_");
|
puts(" = VL_RAND_RESET_");
|
||||||
emitIQW(varp);
|
emitIQW(varp);
|
||||||
|
@ -139,7 +139,7 @@ private:
|
|||||||
string name = string("__Vrepeat")+cvtToStr(m_repeatNum++);
|
string name = string("__Vrepeat")+cvtToStr(m_repeatNum++);
|
||||||
// Spec says value is integral, if negative is ignored
|
// Spec says value is integral, if negative is ignored
|
||||||
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name,
|
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name,
|
||||||
AstLogicPacked(), 32);
|
AstBitPacked(), 32);
|
||||||
varp->numeric(AstNumeric::SIGNED);
|
varp->numeric(AstNumeric::SIGNED);
|
||||||
varp->dtypep()->numeric(AstNumeric::SIGNED);
|
varp->dtypep()->numeric(AstNumeric::SIGNED);
|
||||||
varp->usedLoopIdx(true);
|
varp->usedLoopIdx(true);
|
||||||
|
@ -182,7 +182,7 @@ private:
|
|||||||
// Index into our table
|
// Index into our table
|
||||||
AstVar* indexVarp = new AstVar (nodep->fileline(), AstVarType::BLOCKTEMP,
|
AstVar* indexVarp = new AstVar (nodep->fileline(), AstVarType::BLOCKTEMP,
|
||||||
"__Vtableidx" + cvtToStr(m_modTables),
|
"__Vtableidx" + cvtToStr(m_modTables),
|
||||||
AstLogicPacked(), m_inWidth);
|
AstBitPacked(), m_inWidth);
|
||||||
m_modp->addStmtp(indexVarp);
|
m_modp->addStmtp(indexVarp);
|
||||||
AstVarScope* indexVscp = new AstVarScope (indexVarp->fileline(), m_scopep, indexVarp);
|
AstVarScope* indexVscp = new AstVarScope (indexVarp->fileline(), m_scopep, indexVarp);
|
||||||
m_scopep->addVarp(indexVscp);
|
m_scopep->addVarp(indexVscp);
|
||||||
@ -193,7 +193,7 @@ private:
|
|||||||
= new AstVar (fl, AstVarType::MODULETEMP,
|
= new AstVar (fl, AstVarType::MODULETEMP,
|
||||||
"__Vtablechg" + cvtToStr(m_modTables),
|
"__Vtablechg" + cvtToStr(m_modTables),
|
||||||
new AstArrayDType (fl,
|
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)));
|
new AstRange (fl, VL_MASK_I(m_inWidth), 0)));
|
||||||
chgVarp->isConst(true);
|
chgVarp->isConst(true);
|
||||||
chgVarp->valuep(new AstInitArray (nodep->fileline(), NULL));
|
chgVarp->valuep(new AstInitArray (nodep->fileline(), NULL));
|
||||||
|
@ -313,7 +313,7 @@ private:
|
|||||||
if (!activityNumber) activityNumber++; // For simplicity, always create it
|
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.
|
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,
|
AstVar* newvarp = new AstVar (m_chgFuncp->fileline(), AstVarType::MODULETEMP,
|
||||||
"__Vm_traceActivity", AstLogicPacked(), activityBits);
|
"__Vm_traceActivity", AstBitPacked(), activityBits);
|
||||||
m_topModp->addStmtp(newvarp);
|
m_topModp->addStmtp(newvarp);
|
||||||
AstVarScope* newvscp = new AstVarScope(newvarp->fileline(), m_highScopep, newvarp);
|
AstVarScope* newvscp = new AstVarScope(newvarp->fileline(), m_highScopep, newvarp);
|
||||||
m_highScopep->addVarp(newvscp);
|
m_highScopep->addVarp(newvscp);
|
||||||
|
Loading…
Reference in New Issue
Block a user