mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
Internals: Refactor to create VCMethod (#3715). No functional change intended.
This commit is contained in:
+13
-12
@@ -543,7 +543,7 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
FileLine* const flp = m_scopeTopp->fileline();
|
||||
auto* const awaitingCurrentTimep
|
||||
= new AstCMethodHard{flp, new AstVarRef{flp, getCreateDelayScheduler(), VAccess::READ},
|
||||
"awaitingCurrentTime"};
|
||||
VCMethod::SCHED_AWAITING_CURRENT_TIME};
|
||||
awaitingCurrentTimep->dtypeSetBit();
|
||||
m_delaySensesp
|
||||
= new AstSenTree{flp, new AstSenItem{flp, VEdgeType::ET_TRUE, awaitingCurrentTimep}};
|
||||
@@ -566,7 +566,7 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
FileLine* const flp = m_scopeTopp->fileline();
|
||||
auto* const awaitingCurrentTimep = new AstCMethodHard{
|
||||
flp, new AstVarRef{flp, getCreateDynamicTriggerScheduler(), VAccess::READ},
|
||||
"evaluate"};
|
||||
VCMethod::SCHED_EVALUATE};
|
||||
awaitingCurrentTimep->dtypeSetBit();
|
||||
m_dynamicSensesp
|
||||
= new AstSenTree{flp, new AstSenItem{flp, VEdgeType::ET_TRUE, awaitingCurrentTimep}};
|
||||
@@ -712,7 +712,7 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
void addForkDone(AstBegin* const beginp, AstVarScope* const forkVscp) const {
|
||||
FileLine* const flp = beginp->fileline();
|
||||
auto* const donep = new AstCMethodHard{
|
||||
beginp->fileline(), new AstVarRef{flp, forkVscp, VAccess::WRITE}, "done"};
|
||||
beginp->fileline(), new AstVarRef{flp, forkVscp, VAccess::WRITE}, VCMethod::FORK_DONE};
|
||||
donep->dtypeSetVoid();
|
||||
addDebugInfo(donep);
|
||||
beginp->addStmtsp(donep->makeStmt());
|
||||
@@ -735,13 +735,13 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
if (forkp->joinType().joinAny()) joinCount = 1;
|
||||
// Set the join counter
|
||||
auto* const initp = new AstCMethodHard{flp, new AstVarRef{flp, forkVscp, VAccess::WRITE},
|
||||
"init", new AstConst{flp, joinCount}};
|
||||
VCMethod::FORK_INIT, new AstConst{flp, joinCount}};
|
||||
initp->dtypeSetVoid();
|
||||
addProcessInfo(initp);
|
||||
forkp->addHereThisAsNext(initp->makeStmt());
|
||||
// Await the join at the end
|
||||
auto* const joinp
|
||||
= new AstCMethodHard{flp, new AstVarRef{flp, forkVscp, VAccess::WRITE}, "join"};
|
||||
auto* const joinp = new AstCMethodHard{flp, new AstVarRef{flp, forkVscp, VAccess::WRITE},
|
||||
VCMethod::FORK_JOIN};
|
||||
joinp->dtypeSetVoid();
|
||||
addProcessInfo(joinp);
|
||||
addDebugInfo(joinp);
|
||||
@@ -884,7 +884,8 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
}
|
||||
// Replace self with a 'co_await dlySched.delay(<valuep>)'
|
||||
AstCMethodHard* const delayMethodp = new AstCMethodHard{
|
||||
flp, new AstVarRef{flp, getCreateDelayScheduler(), VAccess::WRITE}, "delay", valuep};
|
||||
flp, new AstVarRef{flp, getCreateDelayScheduler(), VAccess::WRITE},
|
||||
VCMethod::SCHED_DELAY, valuep};
|
||||
delayMethodp->dtypeSetVoid();
|
||||
addProcessInfo(delayMethodp);
|
||||
addDebugInfo(delayMethodp);
|
||||
@@ -922,7 +923,7 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
// call
|
||||
auto* const evalMethodp = new AstCMethodHard{
|
||||
flp, new AstVarRef{flp, getCreateDynamicTriggerScheduler(), VAccess::WRITE},
|
||||
"evaluation"};
|
||||
VCMethod::SCHED_EVALUATION};
|
||||
evalMethodp->dtypeSetVoid();
|
||||
addProcessInfo(evalMethodp);
|
||||
auto* const sentreep = nodep->sentreep();
|
||||
@@ -954,21 +955,21 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
// If it was, a call to the scheduler's evaluate() will return true
|
||||
AstCMethodHard* const anyTriggeredMethodp = new AstCMethodHard{
|
||||
flp, new AstVarRef{flp, getCreateDynamicTriggerScheduler(), VAccess::WRITE},
|
||||
"anyTriggered", new AstVarRef{flp, trigvscp, VAccess::READ}};
|
||||
VCMethod::SCHED_ANY_TRIGGERED, new AstVarRef{flp, trigvscp, VAccess::READ}};
|
||||
anyTriggeredMethodp->dtypeSetVoid();
|
||||
loopp->addStmtsp(anyTriggeredMethodp->makeStmt());
|
||||
// If the post update is destructive (e.g. event vars are cleared), create an await for
|
||||
// the post update step
|
||||
if (destructivePostUpdate(sentreep)) {
|
||||
AstCAwait* const awaitPostUpdatep = awaitEvalp->cloneTree(false);
|
||||
VN_AS(awaitPostUpdatep->exprp(), CMethodHard)->name("postUpdate");
|
||||
VN_AS(awaitPostUpdatep->exprp(), CMethodHard)->method(VCMethod::SCHED_POST_UPDATE);
|
||||
loopp->addStmtsp(awaitPostUpdatep->makeStmt());
|
||||
}
|
||||
// Put the post updates at the end of the loop
|
||||
for (AstNodeStmt* const stmtp : senResults.m_postUpdates) loopp->addStmtsp(stmtp);
|
||||
// Finally, await the resumption step in 'act'
|
||||
AstCAwait* const awaitResumep = awaitEvalp->cloneTree(false);
|
||||
VN_AS(awaitResumep->exprp(), CMethodHard)->name("resumption");
|
||||
VN_AS(awaitResumep->exprp(), CMethodHard)->method(VCMethod::SCHED_RESUMPTION);
|
||||
AstNode::addNext<AstNodeStmt, AstNodeStmt>(loopp, awaitResumep->makeStmt());
|
||||
// Replace the event control with the loop
|
||||
nodep->replaceWith(loopp);
|
||||
@@ -979,7 +980,7 @@ class TimingControlVisitor final : public VNVisitor {
|
||||
// Replace self with a 'co_await trigSched.trigger()'
|
||||
auto* const triggerMethodp = new AstCMethodHard{
|
||||
flp, new AstVarRef{flp, getCreateTriggerSchedulerp(sentreep), VAccess::WRITE},
|
||||
"trigger"};
|
||||
VCMethod::SCHED_TRIGGER};
|
||||
triggerMethodp->dtypeSetVoid();
|
||||
// If it should be committed immediately, pass true, otherwise false
|
||||
triggerMethodp->addPinsp(nodep->user2() ? new AstConst{flp, AstConst::BitTrue{}}
|
||||
|
||||
Reference in New Issue
Block a user