Fix parameterized class nested in a parameterized interface (#8328) (#8329)

This commit is contained in:
Kristof Marien
2026-09-12 15:31:10 -04:00
committed by GitHub
parent 4fedb791ed
commit 298922d887
4 changed files with 49 additions and 0 deletions
+1
View File
@@ -183,6 +183,7 @@ Keith Colbert
Kevin Kiningham
Kevin Nygaard
Kornel Uriasz
Kristof Marien
Kritik Bhimani
Krzysztof Bieganski
Krzysztof Boronski
+6
View File
@@ -961,6 +961,12 @@ class ParamProcessor final {
} else {
newModp = srcModp->cloneTree(false);
}
// AstPin normally retains links to external module formals across cloning. For a cloned
// interface, relink pins whose formals were cloned with the interface while clonep() is
// still valid, so nested parameterized classes use the cloned interface parameters.
if (AstIface* const newIfacep = VN_CAST(newModp, Iface)) {
newIfacep->foreach([](AstPin* pinp) { pinp->cloneRelinkGen(); });
}
// Mark the source module as a parameterized template now that a specialized
// clone exists. This suppresses width/type errors on the unresolved template
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# 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-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('vlt_all')
test.compile()
test.execute()
test.passes()
@@ -0,0 +1,24 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2026 by Verilator Authors.
// SPDX-FileCopyrightText: 2026 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
// A parameterized class nested in a specialized parameterized interface must
// produce distinct, well-formed class-package names during C++ emission.
interface intf #(int P = 1);
class Cls #(int Q);
endclass
Cls #(P) obj;
endinterface
module t;
intf #(2) intf_i();
initial begin
$write("*-* All Finished *-*\n");
$finish;
end
endmodule