Fix method calls to package class functions (#2565). [Peter Monsson]

This commit is contained in:
Wilson Snyder 2020-09-22 09:09:10 -04:00
parent 0c49cca527
commit 6430743b6f
4 changed files with 96 additions and 0 deletions

View File

@ -13,6 +13,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix $urandom_range passed variable (#2563). [nanduraj1]
**** Fix method calls to package class functions (#2565). [Peter Monsson]
* Verilator 4.100 2020-09-07

View File

@ -2554,6 +2554,7 @@ private:
UASSERT_OBJ(first_classp, nodep, "Unlinked");
for (AstClass* classp = first_classp; classp;) {
if (AstNodeFTask* ftaskp = VN_CAST(classp->findMember(nodep->name()), NodeFTask)) {
userIterate(ftaskp, nullptr);
nodep->taskp(ftaskp);
nodep->dtypeFrom(ftaskp);
if (VN_IS(ftaskp, Task)) nodep->makeStatement();

View File

@ -0,0 +1,20 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 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.
scenarios(simulator => 1);
compile(
);
execute(
check_finished => 1,
);
ok(1);
1;

View File

@ -0,0 +1,73 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2020 by Peter Monsson.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc; initial cyc=1;
wire [31:0] in = cyc;
Test test (/*AUTOINST*/
// Inputs
.clk (clk),
.in (in[31:0]));
always @ (posedge clk) begin
if (cyc!=0) begin
cyc <= cyc + 1;
if (cyc==10) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
end
endmodule
package lpcm_pkg;
class lpcm_tr;
int latency;
int sample;
function new();
latency = 0;
sample = 0;
endfunction
function string convert2string();
return $sformatf("sample=0x%0h latency=%0d", sample, latency);
endfunction
endclass
endpackage
//internal error happens when lpcm_pkg is not imported
//import lpcm_pkg::*;
module Test (/*AUTOARG*/
// Inputs
clk, in
);
input clk;
input [31:0] in;
initial begin
string s;
lpcm_pkg::lpcm_tr tr; // internal error happens when lpcm_pkg is not imported
tr = new();
tr.sample = 1;
tr.latency = 2;
s = tr.convert2string();
$display("hello %s", tr.convert2string());
if (s != "sample=0x1 latency=2") $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule