parent
2f9e1fa454
commit
7e67f73844
|
|
@ -475,6 +475,12 @@ public:
|
||||||
|
|
||||||
m_usevlSelfRef = false;
|
m_usevlSelfRef = false;
|
||||||
|
|
||||||
|
if (nodep->isCoroutine()) {
|
||||||
|
// Sometimes coroutines don't have co_awaits,
|
||||||
|
// so emit a co_return at the end to avoid compile errors.
|
||||||
|
puts("co_return;");
|
||||||
|
}
|
||||||
|
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
if (nodep->ifdef() != "") puts("#endif // " + nodep->ifdef() + "\n");
|
if (nodep->ifdef() != "") puts("#endif // " + nodep->ifdef() + "\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,6 @@ class TransformForksVisitor final : public VNVisitor {
|
||||||
// STATE
|
// STATE
|
||||||
bool m_inClass = false; // Are we in a class?
|
bool m_inClass = false; // Are we in a class?
|
||||||
bool m_beginHasAwaits = false; // Does the current begin have awaits?
|
bool m_beginHasAwaits = false; // Does the current begin have awaits?
|
||||||
bool m_awaitMoved = false; // Has the current function lost awaits?
|
|
||||||
AstFork* m_forkp = nullptr; // Current fork
|
AstFork* m_forkp = nullptr; // Current fork
|
||||||
AstCFunc* m_funcp = nullptr; // Current function
|
AstCFunc* m_funcp = nullptr; // Current function
|
||||||
|
|
||||||
|
|
@ -373,14 +372,7 @@ class TransformForksVisitor final : public VNVisitor {
|
||||||
void visit(AstCFunc* nodep) override {
|
void visit(AstCFunc* nodep) override {
|
||||||
VL_RESTORER(m_funcp);
|
VL_RESTORER(m_funcp);
|
||||||
m_funcp = nodep;
|
m_funcp = nodep;
|
||||||
m_awaitMoved = false;
|
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
// cppcheck-suppress knownConditionTrueFalse
|
|
||||||
if (nodep->isCoroutine() && m_awaitMoved
|
|
||||||
&& !nodep->stmtsp()->exists([](AstCAwait*) { return true; })) {
|
|
||||||
// co_return at the end (either that or a co_await is required in a coroutine
|
|
||||||
nodep->addStmtsp(new AstCStmt{nodep->fileline(), "co_return;"});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void visit(AstVar* nodep) override {
|
void visit(AstVar* nodep) override {
|
||||||
if (!m_forkp) nodep->user1(true);
|
if (!m_forkp) nodep->user1(true);
|
||||||
|
|
@ -459,12 +451,6 @@ class TransformForksVisitor final : public VNVisitor {
|
||||||
newfuncp->setNeedProcess();
|
newfuncp->setNeedProcess();
|
||||||
newfuncp->addStmtsp(new AstCStmt{flp, "vlProcess->state(VlProcess::FINISHED);"});
|
newfuncp->addStmtsp(new AstCStmt{flp, "vlProcess->state(VlProcess::FINISHED);"});
|
||||||
}
|
}
|
||||||
if (!m_beginHasAwaits) {
|
|
||||||
// co_return at the end (either that or a co_await is required in a coroutine
|
|
||||||
newfuncp->addStmtsp(new AstCStmt{flp, "co_return;"});
|
|
||||||
} else {
|
|
||||||
m_awaitMoved = true;
|
|
||||||
}
|
|
||||||
remapLocals(newfuncp, callp);
|
remapLocals(newfuncp, callp);
|
||||||
}
|
}
|
||||||
void visit(AstCAwait* nodep) override {
|
void visit(AstCAwait* nodep) override {
|
||||||
|
|
|
||||||
|
|
@ -859,21 +859,14 @@ class TimingControlVisitor final : public VNVisitor {
|
||||||
nodep->addStmtsp(cstmtp);
|
nodep->addStmtsp(cstmtp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AstNode* firstCoStmtp = nullptr; // First co_* statement in the function
|
|
||||||
nodep->exists([&](AstCAwait* const awaitp) -> bool { return (firstCoStmtp = awaitp); });
|
|
||||||
if (!firstCoStmtp) {
|
|
||||||
// It's a coroutine but has no awaits (a class method that overrides/is
|
|
||||||
// overridden by a suspendable, but doesn't have any awaits itself). Add a
|
|
||||||
// co_return at the end (either that or a co_await is required in a
|
|
||||||
// coroutine)
|
|
||||||
firstCoStmtp = new AstCStmt{nodep->fileline(), "co_return;"};
|
|
||||||
nodep->addStmtsp(firstCoStmtp);
|
|
||||||
}
|
|
||||||
if (nodep->dpiExportImpl()) {
|
if (nodep->dpiExportImpl()) {
|
||||||
// A DPI-exported coroutine won't be able to block the calling code
|
nodep->exists([](AstCAwait* const awaitp) -> bool {
|
||||||
// Error on the await node; fall back to the function node
|
// A DPI-exported coroutine won't be able to block the calling code
|
||||||
firstCoStmtp->v3warn(E_UNSUPPORTED,
|
// Error on the await node; fall back to the function node
|
||||||
"Unsupported: Timing controls inside DPI-exported tasks");
|
awaitp->v3warn(E_UNSUPPORTED,
|
||||||
|
"Unsupported: Timing controls inside DPI-exported tasks");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstNodeCCall* nodep) override {
|
void visit(AstNodeCCall* nodep) override {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2025 by Wilson Snyder. This program is free software; you
|
||||||
|
# can redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
|
import vltest_bootstrap
|
||||||
|
|
||||||
|
test.scenarios('simulator')
|
||||||
|
|
||||||
|
test.compile(verilator_flags2=["--binary"])
|
||||||
|
|
||||||
|
test.execute()
|
||||||
|
|
||||||
|
test.passes()
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||||
|
// any use, without warranty, 2025 by Antmicro.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
module t;
|
||||||
|
always something();
|
||||||
|
|
||||||
|
function void something();
|
||||||
|
void'(process::self());
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
endfunction
|
||||||
|
endmodule
|
||||||
Loading…
Reference in New Issue