Skip to content

Commit

Permalink
Fix resolution of function args after package scope
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
  • Loading branch information
kbieganski committed Mar 3, 2025
1 parent faa1865 commit 600cb42
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/V3LinkDot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,9 @@ class LinkDotResolveVisitor final : public VNVisitor {
if (!lhsp->classOrPackageSkipp() && lhsp->name() != "local::") {
revisitLater(nodep);
m_ds = lastStates;
if (auto* ftaskrefp = VN_CAST(nodep->rhsp(), NodeFTaskRef)) {
iterateAndNextNull(ftaskrefp->pinsp());
}
return;
}
m_ds.m_dotPos = DP_PACKAGE;
Expand All @@ -2784,11 +2787,17 @@ class LinkDotResolveVisitor final : public VNVisitor {
if (!crefp->classOrPackageSkipp()) {
revisitLater(nodep);
m_ds = lastStates;
if (auto* ftaskrefp = VN_CAST(nodep->rhsp(), NodeFTaskRef)) {
iterateAndNextNull(ftaskrefp->pinsp());
}
return;
}
}
if (m_lastDeferredp == nodep->lhsp()) {
m_ds = lastStates;
if (auto* ftaskrefp = VN_CAST(nodep->rhsp(), NodeFTaskRef)) {
iterateAndNextNull(ftaskrefp->pinsp());
}
return;
}
UINFO(8, indent() << "iter.ldone " << m_ds.ascii() << " " << nodep << endl);
Expand Down
18 changes: 18 additions & 0 deletions test_regress/t/t_param_resolve_args.py
Original file line number Diff line number Diff line change
@@ -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()

test.execute()

test.passes()
31 changes: 31 additions & 0 deletions test_regress/t/t_param_resolve_args.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 Foo;
static function int get(int x);
return x;
endfunction
endclass

class Bar;
static function int get;
return 42;
endfunction
endclass

class Qux #(type Tfoo, type Tbar);
static function int get();
return Tfoo::get(Tbar::get());
endfunction
endclass

module t;
initial begin
if (Qux#(Foo, Bar)::get() != 42) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule

0 comments on commit 600cb42

Please sign in to comment.