Skip to content

Commit b6abcba

Browse files
committed
Support named event locals
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
1 parent ffe7671 commit b6abcba

7 files changed

+59
-45
lines changed

src/V3Fork.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class ForkDynScopeFrame final {
173173
new AstVarRef{varp->fileline(), varp, VAccess::READ}};
174174
initsp = AstNode::addNext(initsp, initAsgnp);
175175
}
176+
177+
if (AstBasicDType* const dtypep = VN_CAST(varp->dtypep()->skipRefp(), BasicDType)) {
178+
v3Global.setAssignsEvents();
179+
if (dtypep->isEvent()) continue;
180+
}
181+
176182
if (varp->direction().isWritable()) {
177183
AstMemberSel* const memberselp = new AstMemberSel{
178184
varp->fileline(),
@@ -416,7 +422,12 @@ class DynScopeVisitor final : public VNVisitor {
416422
ForkDynScopeFrame* const framep = frameOf(nodep->varp());
417423
if (!framep) return;
418424
if (needsDynScope(nodep)) {
419-
if (m_afterTimingControl && nodep->varp()->isWritable()
425+
bool isEvent = false;
426+
if (AstBasicDType* const dtypep = VN_CAST(nodep->dtypep()->skipRefp(), BasicDType)) {
427+
v3Global.setAssignsEvents();
428+
isEvent = dtypep->isEvent();
429+
}
430+
if (!isEvent && m_afterTimingControl && nodep->varp()->isWritable()
420431
&& nodep->access().isWriteOrRW()) {
421432
// The output variable may not exist after a delay, so we can't just write to it
422433
nodep->v3warn(

src/V3Timing.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -925,12 +925,6 @@ class TimingControlVisitor final : public VNVisitor {
925925
// Do not allow waiting on local named events, as they get enqueued for clearing, but can
926926
// go out of scope before that happens
927927
if (!nodep->sensesp()) nodep->v3warn(E_UNSUPPORTED, "Unsupported: no sense equation (@*)");
928-
if (nodep->sensesp()->exists([](const AstNodeVarRef* refp) {
929-
AstBasicDType* const dtypep = refp->dtypep()->skipRefp()->basicp();
930-
return dtypep && dtypep->isEvent() && refp->varp()->isFuncLocal();
931-
})) {
932-
nodep->v3warn(E_UNSUPPORTED, "Unsupported: waiting on local event variables");
933-
}
934928
FileLine* const flp = nodep->fileline();
935929
// Relink child statements after the event control
936930
if (nodep->stmtsp()) nodep->addNextHere(nodep->stmtsp()->unlinkFrBackWithNext());

test_regress/t/t_timing_localevent_unsup.pl test_regress/t/t_timing_localevent.pl

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
33
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
44
#
5-
# Copyright 2022 by Antmicro Ltd. This program is free software; you
5+
# Copyright 2024 by Wilson Snyder. This program is free software; you
66
# can redistribute it and/or modify it under the terms of either the GNU
77
# Lesser General Public License Version 3 or the Perl Artistic License
88
# Version 2.0.
99
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
1010

1111
scenarios(linter => 1);
1212

13-
lint(
14-
verilator_flags2 => ["--timing"],
15-
fails => 1,
16-
expect_filename => $Self->{golden_filename},
13+
compile(
14+
verilator_flags2 => ["--exe --main --timing"],
15+
);
16+
17+
execute(
18+
check_finished => 1,
1719
);
1820

1921
ok(1);

test_regress/t/t_timing_localevent.v

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// DESCRIPTION: Verilator: Verilog Test module
2+
//
3+
// This file ONLY is placed under the Creative Commons Public Domain, for
4+
// any use, without warranty, 2024 by Antmicro.
5+
// SPDX-License-Identifier: CC0-1.0
6+
7+
module t;
8+
class Foo;
9+
task sleep;
10+
event e;
11+
fork
12+
@e;
13+
#1 ->e;
14+
join
15+
endtask
16+
task trigger_later1(event e);
17+
fork #2 ->e; join_none
18+
endtask
19+
task trigger_later2(ref event e);
20+
fork #3 ->e; join_none
21+
endtask
22+
task test;
23+
for (int i = 0; i < 10; i++) begin
24+
event e1, e2;
25+
trigger_later1(e1);
26+
trigger_later2(e2);
27+
sleep;
28+
@e1; @e2;
29+
end
30+
endtask
31+
endclass
32+
33+
initial begin
34+
Foo foo = new;
35+
foo.test;
36+
$write("*-* All Finished *-*\n");
37+
$finish;
38+
end
39+
endmodule

test_regress/t/t_timing_localevent_unsup.out

-6
This file was deleted.

test_regress/t/t_timing_localevent_unsup.v

-24
This file was deleted.

test_regress/t/t_uvm_pkg_todo.vh

+1-3
Original file line numberDiff line numberDiff line change
@@ -20256,9 +20256,7 @@ virtual class uvm_sequence_base extends uvm_sequence_item;
2025620256
if (is_rel_default != wait_rel_default)
2025720257
uvm_report_fatal("RELMSM",
2025820258
"is_relevant() was implemented without defining wait_for_relevant()", UVM_NONE);
20259-
//TODO issue #4495 - unsupported local event - may want to model the larger context where is used - might be case where edit upstream?
20260-
//TODO %Error-UNSUPPORTED: t/t_uvm_pkg_todo.vh:20247:5: Unsupported: waiting on local event variables
20261-
//TODO @e;
20259+
@e;
2026220260
endtask
2026320261
task lock(uvm_sequencer_base sequencer = null);
2026420262
if (sequencer == null)

0 commit comments

Comments
 (0)