2020-12-08 02:30:16 +01:00
|
|
|
// DESCRIPTION: Verilator: Test of select from constant
|
|
|
|
|
//
|
|
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
|
|
|
|
// any use, without warranty, 2020 by Wilson Snyder.
|
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
|
|
|
|
|
module t (/*AUTOARG*/
|
|
|
|
|
// Outputs
|
|
|
|
|
o,
|
|
|
|
|
// Inputs
|
2025-03-09 15:31:01 +01:00
|
|
|
clk, i, idx
|
2020-12-08 02:30:16 +01:00
|
|
|
);
|
|
|
|
|
input clk;
|
|
|
|
|
input [3:0] i;
|
2025-03-09 15:31:01 +01:00
|
|
|
input idx;
|
2020-12-08 02:30:16 +01:00
|
|
|
output [3:0] o;
|
|
|
|
|
|
|
|
|
|
logic [1:0][3:0] array;
|
|
|
|
|
|
|
|
|
|
always_comb array[0] = i;
|
|
|
|
|
|
|
|
|
|
always @ (posedge clk)
|
2025-06-28 21:45:45 +02:00
|
|
|
array[0] <= array[0];
|
2020-12-08 02:30:16 +01:00
|
|
|
|
2025-06-28 21:45:45 +02:00
|
|
|
struct {
|
|
|
|
|
logic [3:0] a;
|
|
|
|
|
logic [3:0] b;
|
|
|
|
|
} unpacked;
|
|
|
|
|
|
|
|
|
|
always_comb unpacked.a = i;
|
|
|
|
|
|
|
|
|
|
always @ (posedge clk)
|
|
|
|
|
unpacked.b <= unpacked.a;
|
|
|
|
|
|
|
|
|
|
assign o = array[idx] + unpacked.a;
|
2020-12-08 02:30:16 +01:00
|
|
|
|
|
|
|
|
endmodule
|