verilator/test_regress/t/t_class_param_enum.v

32 lines
611 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
typedef enum bit {
A = 0,
B = 1
} enum_t;
2026-03-08 23:26:40 +01:00
class Converter #(
type T
);
function int toInt(T t);
return int'(t);
endfunction
endclass
module t;
2026-03-08 23:26:40 +01:00
initial begin
automatic Converter #(enum_t) conv1 = new;
automatic Converter #(bit) conv2 = new;
2026-03-08 23:26:40 +01:00
if (conv1.toInt(A) != 0) $stop;
if (conv2.toInt(1) != 1) $stop;
2026-03-08 23:26:40 +01:00
$write("*-* All Finished *-*\n");
$finish;
end
endmodule