2025-08-18 14:51:25 +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-18 14:51:25 +02:00
// SPDX-License-Identifier: CC0-1.0
2025-12-21 03:46:43 +01:00
// verilog_format: off
2025-08-18 14:51:25 +02:00
`define stop $stop
`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
2025-12-21 03:46:43 +01:00
// verilog_format: on
2025-08-18 14:51:25 +02:00
2026-08-12 21:29:04 +02:00
interface class_if ;
class scoped_class ;
static function int fstatic ( ) ;
return 42 ;
endfunction
function int fnonstatic ( ) ;
return 43 ;
endfunction
endclass
scoped_class class_inst ;
initial begin
`checkh ( scoped_class : : fstatic ( ) , 42 ) ;
class_inst = new ( ) ;
`checkh ( class_inst . fnonstatic ( ) , 43 ) ;
end
endinterface
2025-12-21 03:46:43 +01:00
module m ( ) ;
2025-08-18 14:51:25 +02:00
class c ;
static function void fstatic ( ) ;
`checkh ( v , 42 ) ;
v + + ;
endfunction
function void fnonstatic ( ) ;
`checkh ( v , 43 ) ;
v + + ;
endfunction
endclass
c classinst ;
2026-08-12 21:29:04 +02:00
class_if class_if_inst ( ) ;
2025-08-18 14:51:25 +02:00
int v ;
initial begin
2025-12-21 03:46:43 +01:00
v = 42 ;
2025-08-18 14:51:25 +02:00
`checkh ( v , 42 ) ;
c : : fstatic ( ) ;
classinst = new ( ) ;
classinst . fnonstatic ( ) ;
`checkh ( v , 44 ) ;
2026-08-12 21:29:04 +02:00
`checkh ( class_if_inst . scoped_class . fstatic ( ) , 42 ) ;
2025-08-18 14:51:25 +02:00
$finish ;
end
endmodule