Skip to content

Commit

Permalink
Internals: Make AstAlwaysPost an AstNodeProcedure. (verilator#2959)
Browse files Browse the repository at this point in the history
This seems to belong there, eliminates some code duplication in V3Clock,
and also enables splitting AstAlwaysPost statements into different
functions in V3Order, but should otherwise have little effect.
  • Loading branch information
gezalore committed May 15, 2021
1 parent 88fed4b commit 5e95cc9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
25 changes: 11 additions & 14 deletions src/V3AstNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3349,6 +3349,7 @@ class AstAlways final : public AstNodeProcedure {
void sensesp(AstSenTree* nodep) { setOp1p(nodep); }
VAlwaysKwd keyword() const { return m_keyword; }
};

class AstAlwaysPostponed final : public AstNodeProcedure {
// Like always but postponement scheduling region

Expand All @@ -3358,6 +3359,16 @@ class AstAlwaysPostponed final : public AstNodeProcedure {
ASTNODE_NODE_FUNCS(AlwaysPostponed)
};

class AstAlwaysPost final : public AstNodeProcedure {
// Like always but post assignments for memory assignment IFs
public:
AstAlwaysPost(FileLine* fl, AstSenTree* sensesp, AstNode* bodysp)
: ASTGEN_SUPER(fl, bodysp) {
addNOp1p(sensesp);
}
ASTNODE_NODE_FUNCS(AlwaysPost)
};

class AstAlwaysPublic final : public AstNodeStmt {
// "Fake" sensitivity created by /*verilator public_flat_rw @(edgelist)*/
// Body statements are just AstVarRefs to the public signals
Expand All @@ -3378,20 +3389,6 @@ class AstAlwaysPublic final : public AstNodeStmt {
bool isJustOneBodyStmt() const { return bodysp() && !bodysp()->nextp(); }
};

class AstAlwaysPost final : public AstNode {
// Like always but post assignments for memory assignment IFs
public:
AstAlwaysPost(FileLine* fl, AstSenTree* sensesp, AstNode* bodysp)
: ASTGEN_SUPER(fl) {
addNOp1p(sensesp);
addNOp2p(bodysp);
}
ASTNODE_NODE_FUNCS(AlwaysPost)
//
AstNode* bodysp() const { return op2p(); } // op2 = Statements to evaluate
void addBodysp(AstNode* newp) { addOp2p(newp); }
};

class AstAssign final : public AstNodeAssign {
public:
AstAssign(FileLine* fl, AstNode* lhsp, AstNode* rhsp)
Expand Down
14 changes: 0 additions & 14 deletions src/V3Clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,6 @@ class ClockVisitor final : public AstNVisitor {
}
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
}
virtual void visit(AstAlwaysPost* nodep) override {
if (AstNode* stmtsp = nodep->bodysp()) {
stmtsp->unlinkFrBackWithNext();
nodep->addNextHere(stmtsp);
}
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
}
virtual void visit(AstAlwaysPostponed* nodep) override {
if (AstNode* stmtsp = nodep->bodysp()) {
stmtsp->unlinkFrBackWithNext();
nodep->addNextHere(stmtsp);
}
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
}
virtual void visit(AstCoverToggle* nodep) override {
// nodep->dumpTree(cout, "ct:");
// COVERTOGGLE(INC, ORIG, CHANGE) ->
Expand Down
2 changes: 1 addition & 1 deletion src/V3Delayed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class DelayedVisitor final : public AstNVisitor {
new AstVarRef(nodep->fileline(), setvscp, VAccess::READ),
nullptr, nullptr);
UINFO(9, " Created " << postLogicp << endl);
finalp->addBodysp(postLogicp);
finalp->addStmtp(postLogicp);
finalp->user3p(setvscp); // Remember IF's vset variable
finalp->user4p(postLogicp); // and the associated IF, as we may be able to reuse it
}
Expand Down

0 comments on commit 5e95cc9

Please sign in to comment.