verilator/test_regress/t/t_interface_hidden.v

76 lines
1.4 KiB
Systemverilog
Raw Normal View History

2024-12-03 00:31:46 +01:00
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2013 Wilson Snyder
2024-12-03 00:31:46 +01:00
// SPDX-License-Identifier: CC0-1.0
2026-03-08 23:26:40 +01:00
module t (
input clk
);
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
integer cyc = 1;
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
ifc ifc (); // Cell name hides interface's name
assign ifc.ifi = 55;
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
sub sub (.isub(ifc)); // Cell name hides module's name
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
int om;
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
mod_or_type mot (.*);
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
hides_with_type hides_type ();
hides_with_decl hides_decl ();
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
always @(posedge clk) begin
cyc <= cyc + 1;
if (cyc == 20) begin
if (om != 22) $stop;
if (mot.LOCAL != 22) $stop;
if (ifc.ifo != 55) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
end
2024-12-03 00:31:46 +01:00
endmodule
2026-03-08 23:26:40 +01:00
module sub (
ifc isub
);
always @* begin
isub.ifo = isub.ifi;
end
2024-12-03 00:31:46 +01:00
endmodule
2026-03-08 23:26:40 +01:00
module mod_or_type (
output int om
);
localparam LOCAL = 22;
initial om = 22;
2024-12-03 00:31:46 +01:00
endmodule
2026-03-08 23:26:40 +01:00
module hides_with_type ();
typedef int ifc; // Hides interface
typedef int mod_or_type; // Hides module
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
ifc /*=int*/ hides_ifc;
mod_or_type /*=int*/ hides_mod;
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
initial hides_ifc = 33;
initial hides_mod = 44;
2024-12-03 00:31:46 +01:00
endmodule
2026-03-08 23:26:40 +01:00
module hides_with_decl ();
int ifc; // Hides interface
int mod_or_type; // Hides module
2024-12-03 00:31:46 +01:00
2026-03-08 23:26:40 +01:00
initial ifc = 66;
initial mod_or_type = 77;
2024-12-03 00:31:46 +01:00
endmodule
interface ifc;
2026-03-08 23:26:40 +01:00
localparam LOCAL = 12;
int ifi;
int ifo;
2024-12-03 00:31:46 +01:00
endinterface