Files
iverilog/ivtest/ivltests/case_mux_array_word.v
T
Lars-Peter Clausen 167a6bbcdb Add regression test for case muxes with array word inputs
Check that synthesized case statement muxes can use array words as inputs.
This used to generate invalid VVP because .array/port statements were emitted
in the middle of .functor statements.

Signed-off-by: Lars-Peter Clausen <[email protected]>
2026-06-21 11:44:15 -07:00

53 lines
895 B
Verilog

// Check that case statement muxes work with array word inputs.
module test;
reg [7:0] mem [0:3];
reg [1:0] sel;
reg [7:0] out;
reg failed;
`define check(val, exp) \
if (val !== exp) begin \
$display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \
`"val`", exp, val); \
failed = 1'b1; \
end
always @* begin
case (sel)
2'd0: out = mem[0];
2'd1: out = mem[1];
2'd2: out = mem[2];
2'd3: out = mem[3];
endcase
end
(* ivl_synthesis_off *)
initial begin
failed = 1'b0;
mem[0] = 8'h12;
mem[1] = 8'h34;
mem[2] = 8'h56;
mem[3] = 8'h78;
sel = 2'd0;
#1 `check(out, 8'h12);
sel = 2'd1;
#1 `check(out, 8'h34);
sel = 2'd2;
#1 `check(out, 8'h56);
sel = 2'd3;
#1 `check(out, 8'h78);
if (!failed) begin
$display("PASSED");
end
end
endmodule