Skip to content

Commit

Permalink
Fix clocking tempvar lifetimes
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bieganski <[email protected]>
  • Loading branch information
kbieganski committed Oct 26, 2023
1 parent cf6e362 commit 7660043
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/V3AssertPre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class AssertPreVisitor final : public VNVisitor {
AstVar* const queueVarp = new AstVar{
flp, VVarType::MODULETEMP,
"__Vqueue__" + m_clockingp->name() + "__DOT__" + varp->name(), queueDtp};
queueVarp->lifetime(VLifetime::STATIC);
m_clockingp->addNextHere(queueVarp);
// Create a process like this:
// always queue.push(<sampled var>);
Expand Down Expand Up @@ -285,6 +286,8 @@ class AssertPreVisitor final : public VNVisitor {
const std::string delayName = m_cycleDlyNames.get(nodep);
AstVar* const cntVarp = new AstVar{flp, VVarType::BLOCKTEMP, delayName + "__counter",
nodep->findBasicDType(VBasicDTypeKwd::UINT32)};
cntVarp->lifetime(VLifetime::AUTOMATIC);
cntVarp->funcLocal(true);
AstBegin* const beginp = new AstBegin{flp, delayName + "__block", cntVarp, false, true};
beginp->addStmtsp(new AstAssign{flp, new AstVarRef{flp, cntVarp, VAccess::WRITE}, valuep});
beginp->addStmtsp(new AstWhile{
Expand Down
1 change: 1 addition & 0 deletions src/V3LinkDot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
AstVar* const eventp = new AstVar{
clockingp->fileline(), VVarType::MODULETEMP, clockingp->name(), VFlagChildDType{},
new AstBasicDType{clockingp->fileline(), VBasicDTypeKwd::EVENT}};
eventp->lifetime(VLifetime::STATIC);
clockingp->eventp(eventp);
// Trigger the clocking event in Observed (IEEE 1800-2017 14.13)
clockingp->addNextHere(new AstAlwaysObserved{
Expand Down

0 comments on commit 7660043

Please sign in to comment.