Fix bounds check in VL_SEL_IWII (#2910)

This commit is contained in:
Krzysztof Bieganski 2021-05-03 23:59:41 +02:00 committed by GitHub
parent 53d9c30277
commit 5290062549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -2705,7 +2705,7 @@ static inline IData VL_BITSEL_IWII(int, int lbits, int, int, WDataInP lwp, IData
static inline IData VL_SEL_IWII(int, int lbits, int, int, WDataInP lwp, IData lsb,
IData width) VL_MT_SAFE {
int msb = lsb + width - 1;
if (VL_UNLIKELY(msb > lbits)) {
if (VL_UNLIKELY(msb >= lbits)) {
return ~0; // Spec says you can go outside the range of a array. Don't coredump if so.
} else if (VL_BITWORD_E(msb) == VL_BITWORD_E(static_cast<int>(lsb))) {
return VL_BITRSHIFT_W(lwp, lsb);

View File

@ -62,7 +62,7 @@ module t (/*AUTOARG*/
^ bytehash(w17));
// verilator lint_on WIDTH
`define EXPECTED_SUM 64'hb6fdb64085fc17f5
`define EXPECTED_SUM 64'h2bc7c2a98a302891
// Test loop
always @ (posedge clk) begin