Internals: Move the eval loop into the runtime library (#8225)

The loops modelling the SystemVerilog scheduling regions are no longer
generated. They now live in 'VerilatedEvalLoop' in the runtime library.
The generated model holds one as a member, passing itself to it, and
exposes each evaluation entry point to it as a pure virtual method on
VerilatedModel. The model's 'eval' and 'eval_step' remain the top level
entry points, and are backward compatible.

V3Sched no longer emits '_eval' or '_eval_settle', etc.. Instead every
evaluation entry point called from the runtime is enumerated by 'VEval',

Scheduling creates all entry points, for all scheduling regions, even if
they are empty, and the runtime eval loop calls everything
unconditionally. If regions are empty, this is simply a call to an empty
function. This will hurt performance on very small models, but should
not be noticeable on anything meaningful, so it is likely best to keep
to reduce complexity.

A scheduling entry points evaluate a single iteration and returns
whether it did any work, they are effectively the previous
`_eval_phase_*` functions.
This commit is contained in:
Geza Lore
2026-08-27 07:53:02 -04:00
committed by GitHub
parent 59f221986c
commit 8546d5db06
44 changed files with 2204 additions and 1418 deletions
+5 -5
View File
@@ -130,8 +130,8 @@ class LifePostDlyVisitor final : public VNVisitorConst {
LocMap m_writes; // VarScope write locations
std::vector<Location<AstNodeAssign>> m_assigns; // Assignments considered for removal
std::vector<std::unique_ptr<GraphPathChecker>> m_checkers; // Storage for exec graph checkers
const AstCFunc* const m_evalNbap; // The _eval__nba function
bool m_inEvalNba = false; // Traversing under _eval__nba
const AstCFunc* const m_nbaFuncp; // The 'nba' region entry point
bool m_inEvalNba = false; // Traversing under the 'nba' region entry point
// METHODS
void squashAssignposts() {
@@ -187,7 +187,7 @@ class LifePostDlyVisitor final : public VNVisitorConst {
// Trace code in the given function
void trace(AstCFunc* nodep) {
VL_RESTORER(m_inEvalNba);
if (nodep == m_evalNbap) m_inEvalNba = true;
if (nodep == m_nbaFuncp) m_inEvalNba = true;
iterateChildrenConst(nodep);
}
@@ -232,7 +232,7 @@ class LifePostDlyVisitor final : public VNVisitorConst {
// We only try to optimize NBA shadow variables
if (!nodep->varScopep()->optimizeLifePost()) return;
// Mark variables referenced outside _eval__nba
// Mark variables referenced outside the 'nba' region
if (!m_inEvalNba) {
nodep->varScopep()->user1(true);
return;
@@ -303,7 +303,7 @@ class LifePostDlyVisitor final : public VNVisitorConst {
public:
// CONSTRUCTORS
explicit LifePostDlyVisitor(AstNetlist* netlistp)
: m_evalNbap{netlistp->evalNbap()} {
: m_nbaFuncp{netlistp->evalFuncp(VEval::NBA)} {
iterateConst(netlistp);
}
~LifePostDlyVisitor() override {