forked from github/verilator
Fix missing error on negative replicate (#3963).
This commit is contained in:
parent
47a7e75841
commit
7559af5879
3
Changes
3
Changes
@ -47,7 +47,8 @@ Verilator 5.007 devel
|
||||
* Fix constant format field widths (#3946). [Todd Strader]
|
||||
* Fix class field linking when a super classes is a param (#3949). [Ryszard Rozak, Antmicro Ltd]
|
||||
* Fix CMake bad C identifiers (#3948) (#3951). [Zixi Li]
|
||||
* Fix build on HP PA architecture. (#3954) [John David Anglin]
|
||||
* Fix build on HP PA architecture (#3954). [John David Anglin]
|
||||
* Fix missing error on negative replicate (#3963). [Benjamin Menküc]
|
||||
* Fix packed array structure replication.
|
||||
|
||||
|
||||
|
@ -1435,15 +1435,19 @@ V3Number& V3Number::opRepl(const V3Number& lhs,
|
||||
// i op repl, L(i)*value(rhs) bit return
|
||||
NUM_ASSERT_OP_ARGS1(lhs);
|
||||
NUM_ASSERT_LOGIC_ARGS1(lhs);
|
||||
setZero();
|
||||
if (rhsval > 8192) {
|
||||
if (rhsval > (1UL << 24)) {
|
||||
v3error("More than a 16 Mbit replication, perhaps the replication factor"
|
||||
" was two's-complement negative: "
|
||||
<< rhsval);
|
||||
} else if (rhsval > 8192) {
|
||||
v3warn(WIDTHCONCAT, "More than a 8k bit replication is probably wrong: " << rhsval);
|
||||
}
|
||||
setZero();
|
||||
int obit = 0;
|
||||
for (unsigned times = 0; times < rhsval; times++) {
|
||||
for (int bit = 0; bit < lhs.width(); bit++) {
|
||||
for (unsigned times = 0; times < rhsval; ++times) {
|
||||
for (int bit = 0; bit < lhs.width(); ++bit) {
|
||||
setBit(obit, lhs.bitIs(bit));
|
||||
obit++;
|
||||
++obit;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
|
5
test_regress/t/t_math_repl2_bad.out
Normal file
5
test_regress/t/t_math_repl2_bad.out
Normal file
@ -0,0 +1,5 @@
|
||||
%Error: t/t_math_repl2_bad.v:28:30: More than a 16 Mbit replication, perhaps the replication factor was two's-complement negative: 4294967291
|
||||
: ... In instance t
|
||||
28 | out <= {{(P24 - P29){1'b0}}, in};
|
||||
| ^
|
||||
%Error: Internal Error: ../V3Number.h:#: `num` member accessed when data type is UNINITIALIZED
|
19
test_regress/t/t_math_repl2_bad.pl
Executable file
19
test_regress/t/t_math_repl2_bad.pl
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2010 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(linter => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
31
test_regress/t/t_math_repl2_bad.v
Normal file
31
test_regress/t/t_math_repl2_bad.v
Normal file
@ -0,0 +1,31 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2023 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t(/*AUTOARG*/
|
||||
// Outputs
|
||||
out,
|
||||
// Inputs
|
||||
clk, in
|
||||
);
|
||||
|
||||
parameter P32 = 32;
|
||||
parameter P24 = 24;
|
||||
localparam P29 = P24 + 5;
|
||||
|
||||
input clk;
|
||||
output reg [P24-1:0] out;
|
||||
|
||||
input [P29 - 1:0] in;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (P29 >= P24) begin
|
||||
out <= in[P29 - 1 -: P24];
|
||||
end
|
||||
else begin
|
||||
out <= {{(P24 - P29){1'b0}}, in};
|
||||
end
|
||||
end
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user