2021-03-13 18:47:19 +01: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: 2021 Wilson Snyder
2021-03-13 18:47:19 +01:00
// SPDX-License-Identifier: CC0-1.0
`ifdef verilator
`define stop $stop
`else
`define stop
`endif
`define checks(gotv,expv) do if ((gotv) != (expv)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
class Cls ;
bit b ;
int i ;
bit [ 15 : 0 ] carray4 [ 4 ] ;
2022-03-05 22:32:30 +01:00
bit [ 64 : 0 ] cwide [ 2 ] ;
2021-09-09 01:31:26 +02:00
string name ;
2025-01-04 01:15:03 +01:00
real r ;
2021-09-09 01:31:26 +02:00
task debug ( ) ;
$display ( " DEBUG: %s (@%0t) %s " , this . name , $realtime , " message " ) ;
endtask
2021-03-13 18:47:19 +01:00
endclass
2025-09-13 15:28:43 +02:00
module t ;
2021-03-13 18:47:19 +01:00
initial begin
Cls c ;
c = new ;
c . b = '1 ;
c . i = 42 ;
2025-01-04 01:15:03 +01:00
c . r = 2.2 ;
2021-09-09 01:31:26 +02:00
c . name = " object_name " ;
2021-03-13 19:04:13 +01:00
c . carray4 [ 0 ] = 16 'h11 ;
c . carray4 [ 1 ] = 16 'h22 ;
c . carray4 [ 2 ] = 16 'h33 ;
c . carray4 [ 3 ] = 16 'h44 ;
2021-03-13 18:47:19 +01:00
$display ( " '%p' " , c ) ;
2021-03-13 19:39:29 +01:00
c . carray4 = ' { 16 'h911 , 16 'h922 , 16 'h933 , 16 'h944 } ;
$display ( " '%p' " , c ) ;
2021-09-09 01:31:26 +02:00
c . debug ( ) ;
2021-03-13 18:47:19 +01:00
$write ( " *-* All Finished *-* \n " ) ;
$finish ;
end
endmodule