Fix generate function(s) inside of generate blocks (#1011) (#6789)

This commit is contained in:
em2machine 2025-12-11 02:53:19 +01:00 committed by GitHub
parent f9f16b438f
commit afc4bed0f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 74 additions and 0 deletions

View File

@ -292,6 +292,14 @@ class BeginVisitor final : public VNVisitor {
UINFO(9, " rescope to " << nodep);
}
}
void visit(AstNodeFTaskRef* nodep) override {
UINFO(9, " FTASKREF " << nodep);
if (m_namedScope != "" && nodep->inlinedDots() == "" && !m_ftaskp) {
nodep->inlinedDots(m_namedScope);
UINFO(9, " rescope to " << nodep);
}
iterateChildren(nodep);
}
void visit(AstScopeName* nodep) override {
// If there's a %m in the display text, we add a special node that will contain the name()
// Similar code in V3Inline

View File

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

View File

@ -0,0 +1,48 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty.
// SPDX-License-Identifier: CC0-1.0
`define stop $stop
`define checkd(gotv,expv) \
do if ((gotv) !== (expv)) begin \
$write("%%Error: %s:%0d: got=%0d exp=%0d\n", \
`__FILE__,`__LINE__, (gotv), (expv)); \
`stop; \
end while(0);
interface a_if #(parameter int a_param=0)();
logic[a_param-1:0] x;
function void to_if(input logic[a_param-1:0] x_in);
x = x_in;
endfunction
function logic[a_param-1:0] from_if();
return x;
endfunction
endinterface
module tb();
genvar a;
generate
for (a=1; a<3; a++) begin : gen_a
a_if #(.a_param(a)) a_if_a();
initial begin
#1;
a_if_a.to_if(a);
end
end
endgenerate
initial begin
#1;
#1;
`checkd(gen_a[1].a_if_a.from_if(), 'h1);
`checkd(gen_a[2].a_if_a.from_if(), 'h2);
$write("*-* All Finished *-*\n");
$finish;
end
endmodule