Skip to content

Commit

Permalink
Fix forks with jumpblocks and intra-assign delays
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bieganski <[email protected]>
  • Loading branch information
kbieganski committed Oct 17, 2023
1 parent 0c86de7 commit bd2983d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/V3SchedTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,15 @@ void transformForks(AstNetlist* const netlistp) {
// Pass it by value to the new function, as otherwise there are issues with
// -flocalize (see t_timing_intra_assign)
passByValue = true;
} else if (!varp->user1() || !varp->isFuncLocal()) {
// Not func local, or not declared before the fork. Their lifetime is longer
// than the forked process. Skip
return;
} else if (dtypep && dtypep->isForkSync()) {
// We can just pass it by value to the new function
passByValue = true;
}
if (!varp->user1() || !varp->isFuncLocal()) {
// Not func local, or not declared before the fork. Their lifetime is longer
// than the forked process. Skip
return;
}
// Remap the reference
AstVarScope* const vscp = refp->varScopep();
if (!vscp->user2p()) {
Expand Down
23 changes: 23 additions & 0 deletions test_regress/t/t_fork_jumpblock.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2019 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

scenarios(simulator => 1);

compile(
verilator_flags2 => ["--exe --main --timing"],
make_main => 0,
);

execute(
check_finished => 1,
);

ok(1);
1;
23 changes: 23 additions & 0 deletions test_regress/t/t_fork_jumpblock.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2023 by Antmicro Ltd.
// SPDX-License-Identifier: CC0-1.0

class bar;
task foo(logic r);
int a, b;
if (r) return;
fork a = #1 b; join_none
endtask
endclass

module t;
bar b = new;

initial begin
b.foo(0);
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

0 comments on commit bd2983d

Please sign in to comment.