Skip to content

Commit

Permalink
Minor cleanup of AstTraceDecl/AstTraceInc
Browse files Browse the repository at this point in the history
  • Loading branch information
gezalore committed Dec 12, 2023
1 parent 6012ec8 commit 7dfae6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
15 changes: 8 additions & 7 deletions src/V3AstNodeOther.h
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,6 @@ class AstTraceDecl final : public AstNodeStmt {
const string m_showname; // Name of variable
const VNumRange m_bitRange; // Property of var the trace details
const VNumRange m_arrayRange; // Property of var the trace details
const uint32_t m_codeInc; // Code increment
const VVarType m_varType; // Type of variable (for localparam vs. param)
const VDirection m_declDirection; // Declared direction input/output etc
public:
Expand All @@ -3224,9 +3223,6 @@ class AstTraceDecl final : public AstNodeStmt {
, m_showname{showname}
, m_bitRange{bitRange}
, m_arrayRange{arrayRange}
, m_codeInc(
((arrayRange.ranged() ? arrayRange.elements() : 1) * valuep->dtypep()->widthWords()
* (VL_EDATASIZE / 32))) // A code is always 32-bits
, m_varType{varp->varType()}
, m_declDirection{varp->declDirection()} {
dtypeFrom(valuep);
Expand All @@ -3245,7 +3241,11 @@ class AstTraceDecl final : public AstNodeStmt {
void code(uint32_t code) { m_code = code; }
uint32_t fidx() const { return m_fidx; }
void fidx(uint32_t fidx) { m_fidx = fidx; }
uint32_t codeInc() const { return m_codeInc; }
uint32_t codeInc() const {
return (m_arrayRange.ranged() ? m_arrayRange.elements() : 1)
* valuep()->dtypep()->widthWords()
* (VL_EDATASIZE / 32); // A code is always 32-bits
}
const VNumRange& bitRange() const { return m_bitRange; }
const VNumRange& arrayRange() const { return m_arrayRange; }
VVarType varType() const { return m_varType; }
Expand All @@ -3266,8 +3266,9 @@ class AstTraceInc final : public AstNodeStmt {
, m_traceType{traceType}
, m_declp{declp} {
dtypeFrom(declp);
this->valuep(
declp->valuep()->cloneTree(true)); // TODO: maybe use reference to TraceDecl instead?
// Note: A clone is necessary (instead of using declp()->valuep()),
// for insertion of local temporaries in V3Premit
valuep(declp->valuep()->cloneTree(true));
}
ASTGEN_MEMBERS_AstTraceInc;
void dump(std::ostream& str) const override;
Expand Down
5 changes: 1 addition & 4 deletions src/V3Clean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,7 @@ class CleanVisitor final : public VNVisitor {
if (AstNodeExpr* const exprp = VN_CAST(argp, NodeExpr)) ensureClean(exprp);
}
}
void visit(AstTraceDecl* nodep) override {
// No cleaning, or would loose pointer to enum
iterateChildren(nodep);
}
void visit(AstTraceDecl* nodep) override {} // Nothing to do here
void visit(AstTraceInc* nodep) override {
iterateChildren(nodep);
ensureCleanAndNext(nodep->valuep());
Expand Down
5 changes: 3 additions & 2 deletions src/V3Trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,9 @@ class TraceVisitor final : public VNVisitor {
UASSERT_OBJ(declp->code() == 0, declp,
"Canonical node should not have code assigned yet");
declp->code(m_code);
m_code += declp->codeInc();
m_statUniqCodes += declp->codeInc();
const uint32_t codeInc = declp->codeInc();
m_code += codeInc;
m_statUniqCodes += codeInc;
++m_statUniqSigs;

// If this is a const signal, add the AstTraceInc
Expand Down

0 comments on commit 7dfae6a

Please sign in to comment.