forked from github/verilator
Fix width mismatch on inside operator (#3714).
This commit is contained in:
parent
0ed7aaeabd
commit
5c658f8cd5
1
Changes
1
Changes
@ -51,6 +51,7 @@ Verilator 5.001 devel
|
||||
* Fix null access on optimized-out fork statements (#3658). [Krzysztof Bieganski, Antmicro Ltd]
|
||||
* Fix VPI inline module naming mismatch (#3690) (#3694). [Jiuyang Liu]
|
||||
* Fix deadlock in timeprecision when using systemC (#3707). [Kamil Rakoczy, Antmicro Ltd]
|
||||
* Fix width mismatch on inside operator (#3714). [Alex Torregrosa]
|
||||
|
||||
|
||||
Verilator 4.228 2022-10-01
|
||||
|
@ -2351,7 +2351,7 @@ private:
|
||||
void visit(AstInside* nodep) override {
|
||||
userIterateAndNext(nodep->exprp(), WidthVP(CONTEXT, PRELIM).p());
|
||||
for (AstNode *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) {
|
||||
nextip = itemp->nextp(); // Prelim may cause the node to get replaced
|
||||
nextip = itemp->nextp(); // iterate may cause the node to get replaced
|
||||
VL_DO_DANGLING(userIterate(itemp, WidthVP(CONTEXT, PRELIM).p()), itemp);
|
||||
}
|
||||
// Take width as maximum across all items
|
||||
@ -2366,7 +2366,8 @@ private:
|
||||
= nodep->findLogicDType(width, mwidth, nodep->exprp()->dtypep()->numeric());
|
||||
iterateCheck(nodep, "Inside expression", nodep->exprp(), CONTEXT, FINAL, subDTypep,
|
||||
EXTEND_EXP);
|
||||
for (AstNode* itemp = nodep->itemsp(); itemp; itemp = itemp->nextp()) {
|
||||
for (AstNode *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) {
|
||||
nextip = itemp->nextp(); // iterate may cause the node to get replaced
|
||||
iterateCheck(nodep, "Inside Item", itemp, CONTEXT, FINAL, subDTypep, EXTEND_EXP);
|
||||
}
|
||||
nodep->dtypeSetBit();
|
||||
@ -5741,7 +5742,8 @@ private:
|
||||
// node, while the output dtype is the *expected* sign.
|
||||
// It is reasonable to have sign extension with unsigned output,
|
||||
// for example $unsigned(a)+$signed(b), the SIGNED(B) will be unsigned dtype out
|
||||
UINFO(4, " widthExtend_(r=" << extendRule << ") old: " << nodep << endl);
|
||||
UINFO(4,
|
||||
" widthExtend_(r=" << static_cast<int>(extendRule) << ") old: " << nodep << endl);
|
||||
if (extendRule == EXTEND_OFF) return;
|
||||
AstConst* const constp = VN_CAST(nodep, Const);
|
||||
const int expWidth = expDTypep->width();
|
||||
|
17
test_regress/t/t_inside2.pl
Executable file
17
test_regress/t/t_inside2.pl
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
37
test_regress/t/t_inside2.v
Normal file
37
test_regress/t/t_inside2.v
Normal file
@ -0,0 +1,37 @@
|
||||
// DESCRIPTION::Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2022 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t(/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
|
||||
input clk;
|
||||
|
||||
typedef struct packed {
|
||||
logic signed [63:0] b;
|
||||
} a_t;
|
||||
|
||||
a_t a_r;
|
||||
a_t a_n;
|
||||
logic signed [63:0] b;
|
||||
logic res;
|
||||
|
||||
assign b = a_r.b;
|
||||
|
||||
always_comb begin
|
||||
a_n = a_r;
|
||||
res = '0;
|
||||
if (b inside {1, 2}) begin
|
||||
res = 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
always_ff @(posedge clk) begin
|
||||
a_r <= a_n;
|
||||
end
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user