mirror of
https://github.com/verilator/verilator.git
synced 2025-01-08 15:47:36 +00:00
Fix hashes of instances of parameterized classes (#4182)
This commit is contained in:
parent
5aecfa98a1
commit
2267db093f
@ -307,7 +307,7 @@ private:
|
|||||||
}
|
}
|
||||||
void visit(AstNodeModule* nodep) override {
|
void visit(AstNodeModule* nodep) override {
|
||||||
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, false, [=]() { //
|
m_hash += hashNodeAndIterate(nodep, HASH_DTYPE, false, [=]() { //
|
||||||
m_hash += nodep->origName();
|
m_hash += nodep->name();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
void visit(AstNodePreSel* nodep) override {
|
void visit(AstNodePreSel* nodep) override {
|
||||||
|
21
test_regress/t/t_class_param_typedef.pl
Executable file
21
test_regress/t/t_class_param_typedef.pl
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2022 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
|
||||||
|
|
||||||
|
scenarios(simulator => 1);
|
||||||
|
|
||||||
|
compile(
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(
|
||||||
|
check_finished => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
47
test_regress/t/t_class_param_typedef.v
Normal file
47
test_regress/t/t_class_param_typedef.v
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||||
|
// any use, without warranty, 2023 by Antmicro Ltd.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
class Foo #(type T=int);
|
||||||
|
typedef Foo#(T) this_type;
|
||||||
|
function int get_x;
|
||||||
|
return T::get_s_x();
|
||||||
|
endfunction
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class Bar #(type S=int);
|
||||||
|
typedef Bar #(S) this_type;
|
||||||
|
typedef Foo#(this_type) foo_type;
|
||||||
|
function int get_x;
|
||||||
|
foo_type f = new;
|
||||||
|
return f.get_x();
|
||||||
|
endfunction
|
||||||
|
static function int get_s_x;
|
||||||
|
return S::x;
|
||||||
|
endfunction
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class Cls1;
|
||||||
|
static int x = 1;
|
||||||
|
typedef Bar#(Cls1) type_id;
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class Cls2;
|
||||||
|
static int x = 2;
|
||||||
|
typedef Bar#(Cls2) type_id;
|
||||||
|
endclass
|
||||||
|
|
||||||
|
module t;
|
||||||
|
initial begin
|
||||||
|
Cls1::type_id bar1 = new;
|
||||||
|
Cls2::type_id bar2 = new;
|
||||||
|
|
||||||
|
if (bar1.get_x() != 1) $stop;
|
||||||
|
if (bar2.get_x() != 2) $stop;
|
||||||
|
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
endmodule
|
Loading…
Reference in New Issue
Block a user