Internals: Use VNumRange for AstTraceDecl
This commit is contained in:
parent
23539eb55c
commit
c659940ea8
|
|
@ -2796,10 +2796,8 @@ struct AstTraceDecl : public AstNodeStmt {
|
||||||
private:
|
private:
|
||||||
string m_showname; // Name of variable
|
string m_showname; // Name of variable
|
||||||
uint32_t m_code; // Trace identifier code; converted to ASCII by trace routines
|
uint32_t m_code; // Trace identifier code; converted to ASCII by trace routines
|
||||||
int m_right; // Property of var the trace details
|
VNumRange m_bitRange; // Property of var the trace details
|
||||||
int m_left; // Property of var the trace details
|
VNumRange m_arrayRange; // Property of var the trace details
|
||||||
uint32_t m_arrayLsb; // Property of var the trace details
|
|
||||||
uint32_t m_arrayMsb; // Property of var the trace details
|
|
||||||
uint32_t m_codeInc; // Code increment
|
uint32_t m_codeInc; // Code increment
|
||||||
public:
|
public:
|
||||||
AstTraceDecl(FileLine* fl, const string& showname, AstVar* varp)
|
AstTraceDecl(FileLine* fl, const string& showname, AstVar* varp)
|
||||||
|
|
@ -2809,14 +2807,9 @@ public:
|
||||||
m_code = 0;
|
m_code = 0;
|
||||||
m_codeInc = varp->dtypep()->arrayUnpackedElements() * varp->dtypep()->widthWords();
|
m_codeInc = varp->dtypep()->arrayUnpackedElements() * varp->dtypep()->widthWords();
|
||||||
AstBasicDType* bdtypep = varp->basicp();
|
AstBasicDType* bdtypep = varp->basicp();
|
||||||
m_left = bdtypep ? bdtypep->left() : 0;
|
if (bdtypep) m_bitRange = bdtypep->nrange();
|
||||||
m_right = bdtypep ? bdtypep->right() : 0;
|
|
||||||
if (AstUnpackArrayDType* adtypep = varp->dtypeSkipRefp()->castUnpackArrayDType()) {
|
if (AstUnpackArrayDType* adtypep = varp->dtypeSkipRefp()->castUnpackArrayDType()) {
|
||||||
m_arrayLsb = adtypep->lsb();
|
m_arrayRange = adtypep->declRange();
|
||||||
m_arrayMsb = adtypep->msb();
|
|
||||||
} else {
|
|
||||||
m_arrayLsb = 0;
|
|
||||||
m_arrayMsb = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual int instrCount() const { return 100; } // Large...
|
virtual int instrCount() const { return 100; } // Large...
|
||||||
|
|
@ -2830,11 +2823,8 @@ public:
|
||||||
uint32_t code() const { return m_code; }
|
uint32_t code() const { return m_code; }
|
||||||
void code(uint32_t code) { m_code=code; }
|
void code(uint32_t code) { m_code=code; }
|
||||||
uint32_t codeInc() const { return m_codeInc; }
|
uint32_t codeInc() const { return m_codeInc; }
|
||||||
int left() const { return m_left; } // Note msb maybe < lsb if little endian
|
const VNumRange& bitRange() const { return m_bitRange; }
|
||||||
int right() const { return m_right; }
|
const VNumRange& arrayRange() const { return m_arrayRange; }
|
||||||
uint32_t arrayMsb() const { return m_arrayMsb; }
|
|
||||||
uint32_t arrayLsb() const { return m_arrayLsb; }
|
|
||||||
uint32_t arrayWidth() const { if (!arrayMsb()) return 0; return arrayMsb()-arrayLsb()+1; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AstTraceInc : public AstNodeStmt {
|
struct AstTraceInc : public AstNodeStmt {
|
||||||
|
|
|
||||||
|
|
@ -2190,23 +2190,23 @@ class EmitCTrace : EmitCStmts {
|
||||||
puts("vcdp->declArray");
|
puts("vcdp->declArray");
|
||||||
} else if (nodep->isQuad()) {
|
} else if (nodep->isQuad()) {
|
||||||
puts("vcdp->declQuad ");
|
puts("vcdp->declQuad ");
|
||||||
} else if (nodep->left() || nodep->right()) {
|
} else if (nodep->bitRange().ranged()) {
|
||||||
puts("vcdp->declBus ");
|
puts("vcdp->declBus ");
|
||||||
} else {
|
} else {
|
||||||
puts("vcdp->declBit ");
|
puts("vcdp->declBit ");
|
||||||
}
|
}
|
||||||
puts("(c+"+cvtToStr(nodep->code()));
|
puts("(c+"+cvtToStr(nodep->code()));
|
||||||
if (nodep->arrayWidth()) puts("+i*"+cvtToStr(nodep->widthWords()));
|
if (nodep->arrayRange().ranged()) puts("+i*"+cvtToStr(nodep->widthWords()));
|
||||||
puts(",");
|
puts(",");
|
||||||
putsQuoted(nodep->showname());
|
putsQuoted(nodep->showname());
|
||||||
if (nodep->arrayWidth()) {
|
if (nodep->arrayRange().ranged()) {
|
||||||
puts(",(i+"+cvtToStr(nodep->arrayLsb())+")");
|
puts(",(i+"+cvtToStr(nodep->arrayRange().lo())+")");
|
||||||
} else {
|
} else {
|
||||||
puts(",-1");
|
puts(",-1");
|
||||||
}
|
}
|
||||||
if (!nodep->isDouble() // When float/double no longer have widths this can go
|
if (!nodep->isDouble() // When float/double no longer have widths this can go
|
||||||
&& (nodep->left() || nodep->right())) {
|
&& nodep->bitRange().ranged()) {
|
||||||
puts(","+cvtToStr(nodep->left())+","+cvtToStr(nodep->right()));
|
puts(","+cvtToStr(nodep->bitRange().left())+","+cvtToStr(nodep->bitRange().right()));
|
||||||
}
|
}
|
||||||
puts(");");
|
puts(");");
|
||||||
}
|
}
|
||||||
|
|
@ -2222,7 +2222,7 @@ class EmitCTrace : EmitCStmts {
|
||||||
puts("vcdp->"+full+"Array");
|
puts("vcdp->"+full+"Array");
|
||||||
} else if (nodep->isQuad()) {
|
} else if (nodep->isQuad()) {
|
||||||
puts("vcdp->"+full+"Quad ");
|
puts("vcdp->"+full+"Quad ");
|
||||||
} else if (nodep->declp()->left() || nodep->declp()->right()) {
|
} else if (nodep->declp()->bitRange().ranged()) {
|
||||||
puts("vcdp->"+full+"Bus ");
|
puts("vcdp->"+full+"Bus ");
|
||||||
} else {
|
} else {
|
||||||
puts("vcdp->"+full+"Bit ");
|
puts("vcdp->"+full+"Bit ");
|
||||||
|
|
@ -2232,7 +2232,7 @@ class EmitCTrace : EmitCStmts {
|
||||||
puts(",");
|
puts(",");
|
||||||
emitTraceValue(nodep, arrayindex);
|
emitTraceValue(nodep, arrayindex);
|
||||||
if (!nodep->isDouble() // When float/double no longer have widths this can go
|
if (!nodep->isDouble() // When float/double no longer have widths this can go
|
||||||
&& (nodep->declp()->left() || nodep->declp()->right() || emitTraceIsScBv(nodep) || emitTraceIsScBigUint(nodep))) {
|
&& (nodep->declp()->bitRange().ranged() || emitTraceIsScBv(nodep) || emitTraceIsScBigUint(nodep))) {
|
||||||
puts(","+cvtToStr(nodep->declp()->widthMin()));
|
puts(","+cvtToStr(nodep->declp()->widthMin()));
|
||||||
}
|
}
|
||||||
puts(");\n");
|
puts(");\n");
|
||||||
|
|
@ -2319,8 +2319,8 @@ class EmitCTrace : EmitCStmts {
|
||||||
m_funcp = NULL;
|
m_funcp = NULL;
|
||||||
}
|
}
|
||||||
virtual void visit(AstTraceDecl* nodep, AstNUser*) {
|
virtual void visit(AstTraceDecl* nodep, AstNUser*) {
|
||||||
if (nodep->arrayWidth()) {
|
if (nodep->arrayRange().ranged()) {
|
||||||
puts("{int i; for (i=0; i<"+cvtToStr(nodep->arrayWidth())+"; i++) {\n");
|
puts("{int i; for (i=0; i<"+cvtToStr(nodep->arrayRange().elements())+"; i++) {\n");
|
||||||
emitTraceInitOne(nodep);
|
emitTraceInitOne(nodep);
|
||||||
puts("}}\n");
|
puts("}}\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2329,9 +2329,9 @@ class EmitCTrace : EmitCStmts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstTraceInc* nodep, AstNUser*) {
|
virtual void visit(AstTraceInc* nodep, AstNUser*) {
|
||||||
if (nodep->declp()->arrayWidth()) {
|
if (nodep->declp()->arrayRange().ranged()) {
|
||||||
// It traces faster if we unroll the loop
|
// It traces faster if we unroll the loop
|
||||||
for (unsigned i=0; i<nodep->declp()->arrayWidth(); i++) {
|
for (int i=0; i<nodep->declp()->arrayRange().elements(); i++) {
|
||||||
emitTraceChangeOne(nodep, i);
|
emitTraceChangeOne(nodep, i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue