Support simple disable within task (#6334)

This commit is contained in:
Ryszard Rozak 2025-08-26 16:39:24 +02:00 committed by GitHub
parent a841a962ce
commit ac21d25d43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 69 additions and 4 deletions

View File

@ -187,8 +187,12 @@ class LinkJumpVisitor final : public VNVisitor {
FileLine* const fl = nodep->fileline();
const std::string targetName = nodep->targetp()->name();
if (m_ftaskp) {
if (!m_ftaskp->exists([targetp = nodep->targetp()](const AstNodeBlock* blockp)
-> bool { return blockp == targetp; })) {
// Disabling a fork, which is within the same task, is not a problem
nodep->v3warn(E_UNSUPPORTED, "Unsupported: disabling fork from task / function");
}
}
AstPackage* const topPkgp = v3Global.rootp()->dollarUnitPkgAddp();
AstClass* const processClassp
= VN_AS(getMemberp(v3Global.rootp()->stdPackagep(), "process"), Class);

View File

@ -10,13 +10,11 @@ module t ( /*AUTOARG*/);
fork : fork_blk
begin
x = 1;
#2;
disable fork_blk;
x = 2;
end
join_none
#1;
disable fork_blk;
#2;
if (x != 1) $stop;
$write("*-* All Finished *-*\n");
$finish;

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 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(timing_loop=True, verilator_flags2=["--timing"])
test.execute()
test.passes()

View File

@ -0,0 +1,45 @@
// 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
class Cls;
int x = 0;
int y = 0;
task disable_outside_fork;
fork : fork_blk
begin
x = 1;
#2;
x = 2;
end
join_none
#1;
disable fork_blk;
endtask
task disable_inside_fork;
fork : fork_blk
begin
y = 1;
disable fork_blk;
y = 2;
end
join_none
endtask
endclass
module t ( /*AUTOARG*/);
initial begin
Cls c = new;
c.disable_outside_fork();
#2;
if (c.x != 1) $stop;
c.disable_inside_fork();
if (c.y != 1) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule