verilator/test_regress/t/t_interface_virtual_param.v

51 lines
972 B
Systemverilog
Raw Normal View History

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2023 Antmicro Ltd
// SPDX-License-Identifier: CC0-1.0
2026-03-08 23:26:40 +01:00
interface Bus #(
parameter int W = 1,
X = 2
);
logic [W-1:0] data;
endinterface
2026-03-08 23:26:40 +01:00
interface BusTyped #(
parameter type T
);
T data;
endinterface
2026-03-08 23:26:40 +01:00
typedef struct packed {logic x;} my_logic_t;
module t;
2026-03-08 23:26:40 +01:00
Bus #(6, 3) intf1 ();
virtual Bus #(6, 3) vintf1 = intf1;
2026-03-08 23:26:40 +01:00
Bus intf2 ();
virtual Bus #(
.W(1),
.X(2)
) vintf2 = intf2;
2026-03-08 23:26:40 +01:00
BusTyped #(my_logic_t) intf3 ();
virtual BusTyped #(my_logic_t) vintf3 = intf3;
2026-03-08 23:26:40 +01:00
initial begin
intf1.data = '1;
if (vintf1.data != 6'b111111) $stop;
if (vintf1.X != 3) $stop;
2026-03-08 23:26:40 +01:00
intf2.data = '1;
if (vintf2.data != 1'b1) $stop;
if (vintf2.X != 2) $stop;
2026-03-08 23:26:40 +01:00
intf3.data.x = '1;
if (vintf3.data.x != 1'b1) $stop;
2026-03-08 23:26:40 +01:00
$write("*-* All Finished *-*\n");
$finish;
end
endmodule