2025-08-30 03:20:09 +02:00
|
|
|
// DESCRIPTION: Verilator: Verilog Test module
|
|
|
|
|
//
|
2026-01-27 02:24:34 +01:00
|
|
|
// This file ONLY is placed under the Creative Commons Public Domain
|
|
|
|
|
// SPDX-FileCopyrightText: 2025 Antmicro
|
2025-08-30 03:20:09 +02:00
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
|
2025-12-21 03:46:43 +01:00
|
|
|
class factory #(
|
|
|
|
|
type T
|
|
|
|
|
);
|
2025-08-30 03:20:09 +02:00
|
|
|
static function T create;
|
|
|
|
|
T obj = new;
|
|
|
|
|
return obj;
|
|
|
|
|
endfunction
|
|
|
|
|
endclass
|
|
|
|
|
|
|
|
|
|
class foo;
|
|
|
|
|
endclass
|
|
|
|
|
|
|
|
|
|
class bar extends foo;
|
|
|
|
|
static function bar create;
|
|
|
|
|
bar b = new;
|
|
|
|
|
return b;
|
|
|
|
|
endfunction
|
|
|
|
|
endclass
|
|
|
|
|
|
|
|
|
|
module t;
|
|
|
|
|
initial begin
|
|
|
|
|
foo f;
|
2025-12-21 03:46:43 +01:00
|
|
|
if (bit'($random)) f = bar::create;
|
|
|
|
|
else f = factory#(foo)::create();
|
2025-08-30 03:20:09 +02:00
|
|
|
$finish;
|
|
|
|
|
end
|
2025-12-21 03:46:43 +01:00
|
|
|
endmodule
|
|
|
|
|
;
|