Fix WIDTHCONCAT on packed pattern assignment (#6045).

This commit is contained in:
Wilson Snyder 2025-05-31 07:38:15 -04:00
parent 8a8f04153a
commit 79de1ff507
3 changed files with 28 additions and 0 deletions

View File

@ -49,6 +49,7 @@ Verilator 5.037 devel
* Fix missing FreeBSD include (#6027) (#6028). [Joel Bodenmann]
* Fix associative arrays with enum keys (#6034) (#6035). [Petr Nohavica]
* Fix GCC 10 read-only linker error (#6040). [Todd Strader]
* Fix WIDTHCONCAT on packed pattern assignment (#6045). [Dan Petrisko]
* Fix V3OrderParallel scoring contraction hang (#6052). [Bartłomiej Chmiel, Antmicro Ltd.]

View File

@ -4722,6 +4722,9 @@ class WidthVisitor final : public VNVisitor {
newp = valuep;
} else {
AstConcat* const concatp = new AstConcat{patp->fileline(), newp, valuep};
// Have resolved widths, no reason to warn about widths on the concat itself
newp->fileline()->modifyWarnOff(V3ErrorCode::WIDTHCONCAT, true);
valuep->fileline()->modifyWarnOff(V3ErrorCode::WIDTHCONCAT, true);
newp = concatp;
newp->dtypeSetLogicSized(concatp->lhsp()->width() + concatp->rhsp()->width(),
nodep->dtypep()->numeric());

View File

@ -14,8 +14,32 @@ module t(
input [UADDR_WIDTH-1:0] mAddr,
output logic [UROM_WIDTH-1:0] mOutput);
// Issue #3959
reg [UROM_WIDTH-1:0] uRam[UROM_DEPTH];
always @(posedge clk) mOutput <= uRam[mAddr];
// Issue #6045
typedef enum logic [1:0] { e_0, e_1, e_2, e_3 } enum_e;
typedef struct packed {
integer unsigned x;
integer unsigned y;
} foo_s;
typedef struct packed {
integer unsigned y;
} bar_s;
// Warning due to concatenation, but this is actually a member assignment
localparam foo_s foo = '{
y: (1 << e_0) | (1 << e_3)
, default: '0
};
// No warning
localparam bar_s bar = '{
y: (1 << e_0) | (1 << e_3)
};
endmodule