Fix inconsistent driver resolution with typedefs (#4917)

This commit is contained in:
Geza Lore 2024-02-22 18:33:23 +00:00 committed by GitHub
parent 2162a31d3a
commit 5964d5cf63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 65 additions and 5 deletions

View File

@ -521,13 +521,14 @@ public:
}
const AstVarRef* const connectRefp = VN_CAST(pinp->exprp(), VarRef);
const AstVarXRef* const connectXRefp = VN_CAST(pinp->exprp(), VarXRef);
const AstBasicDType* const pinBasicp
= VN_CAST(pinVarp->dtypep(), BasicDType); // Maybe nullptr
const AstBasicDType* connBasicp = nullptr;
const AstNodeDType* const pinDTypep = pinVarp->dtypep()->skipRefp();
const AstBasicDType* const pinBasicp = VN_CAST(pinDTypep, BasicDType);
const AstNodeDType* const connDTypep
= connectRefp ? connectRefp->varp()->dtypep()->skipRefp() : nullptr;
const AstBasicDType* const connBasicp = VN_CAST(connDTypep, BasicDType);
AstAssignW* assignp = nullptr;
if (connectRefp) connBasicp = VN_CAST(connectRefp->varp()->dtypep(), BasicDType);
//
if (!alwaysCvt && connectRefp && connectRefp->varp()->dtypep()->sameTree(pinVarp->dtypep())
if (!alwaysCvt && connectRefp && connDTypep->sameTree(pinDTypep)
&& !connectRefp->varp()->isSc()) { // Need the signal as a 'shell' to convert types
// Done. Same data type
} else if (!alwaysCvt && connectRefp && connectRefp->varp()->isIfaceRef()) {

View 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 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
scenarios(simulator => 1);
compile(
);
execute(
check_finished => 1,
);
ok(1);
1;

View File

@ -0,0 +1,38 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2024 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
package pkg;
typedef logic l;
endpackage
module t(/*AUTOARG*/
// Inputs
clk
);
input clk;
wire logic o_logic;
// Using 'pkg::l' instead of 'logic' should make no difference
wire pkg::l o_alias;
sub sub_logic(o_logic);
sub sub_alias(o_alias);
assign o_logic = clk;
assign o_alias = clk;
always @(posedge clk) begin
$display("o_logic: %b o_alias: %b", o_logic, o_alias);
// Whatever the answer is, it should be the same
if (o_logic !== o_alias) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule
module sub(output wire o);
endmodule