diff --git a/src/V3Sched.cpp b/src/V3Sched.cpp index 39a6109e6..fb655e692 100644 --- a/src/V3Sched.cpp +++ b/src/V3Sched.cpp @@ -309,7 +309,8 @@ void orderSequentially(AstCFunc* funcp, const LogicByScope& lbs) { } subFuncp->addStmtsp(bodyp); if (procp->needProcess()) subFuncp->setNeedProcess(); - util::splitCheck(subFuncp); + // A coroutine holds a single process, so it is complete here + if (procp->isSuspendable()) util::splitCheck(subFuncp); } } else { logicp->unlinkFrBack(); @@ -319,6 +320,14 @@ void orderSequentially(AstCFunc* funcp, const LogicByScope& lbs) { if (activep->backp()) activep->unlinkFrBack(); VL_DO_DANGLING(activep->deleteTree(), activep); } + // Split sub-functions once complete + for (const auto& pair : lbs) { + AstScope* const scopep = pair.first; + if (AstCFunc* const subFuncp = VN_AS(scopep->user1p(), CFunc)) { + util::splitCheck(subFuncp); + scopep->user1p(nullptr); + } + } } //============================================================================