2024-11-27 23:20:21 +01:00
|
|
|
// DESCRIPTION: Verilator: SystemVerilog interface test module
|
|
|
|
|
//
|
2026-01-27 02:24:34 +01:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain.
|
|
|
|
|
// SPDX-FileCopyrightText: 2012 Iztok Jeras
|
2024-11-27 23:20:21 +01:00
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
|
|
|
|
|
package Package_pkg;
|
2026-03-08 23:26:40 +01:00
|
|
|
typedef struct packed {
|
|
|
|
|
int bar;
|
|
|
|
|
int baz;
|
|
|
|
|
} pkg_struct_t;
|
2024-11-27 23:20:21 +01:00
|
|
|
endpackage
|
|
|
|
|
|
2026-03-08 23:26:40 +01:00
|
|
|
interface intf #(
|
|
|
|
|
parameter type data_type = bit
|
|
|
|
|
) (
|
|
|
|
|
input wire clk,
|
|
|
|
|
input wire rst
|
|
|
|
|
);
|
|
|
|
|
data_type data;
|
|
|
|
|
modport source(input clk, rst, output data);
|
2024-11-27 23:20:21 +01:00
|
|
|
endinterface
|
|
|
|
|
|
|
|
|
|
module sub (
|
|
|
|
|
intf.source bar,
|
|
|
|
|
input clk,
|
2026-03-08 23:26:40 +01:00
|
|
|
input rst
|
|
|
|
|
);
|
2024-11-27 23:20:21 +01:00
|
|
|
|
2026-03-08 23:26:40 +01:00
|
|
|
typedef struct packed {
|
|
|
|
|
int foo;
|
|
|
|
|
int baz;
|
|
|
|
|
} struct_t;
|
2024-11-27 23:20:21 +01:00
|
|
|
|
2026-03-08 23:26:40 +01:00
|
|
|
intf #(.data_type(struct_t)) the_intf (.*);
|
2024-11-27 23:20:21 +01:00
|
|
|
|
2026-03-08 23:26:40 +01:00
|
|
|
Package_pkg::pkg_struct_t output_bar = Package_pkg::pkg_struct_t
|
|
|
|
|
'{bar: the_intf.data.foo, baz: the_intf.data.baz};
|
2024-11-27 23:20:21 +01:00
|
|
|
endmodule
|
|
|
|
|
|
2026-03-08 23:26:40 +01:00
|
|
|
module t (
|
|
|
|
|
clk
|
|
|
|
|
);
|
|
|
|
|
input clk;
|
|
|
|
|
logic rst;
|
|
|
|
|
|
|
|
|
|
intf bar (.*);
|
|
|
|
|
sub the_sub (
|
|
|
|
|
.bar(bar),
|
|
|
|
|
.clk,
|
|
|
|
|
.rst
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// finish report
|
|
|
|
|
always @(posedge clk) begin
|
|
|
|
|
$write("*-* All Finished *-*\n");
|
|
|
|
|
$finish;
|
|
|
|
|
end
|
2024-11-27 23:20:21 +01:00
|
|
|
endmodule
|