2023-03-14 03:03:53 +01:00
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2020 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
2024-02-09 00:39:13 +01:00
`define stop $stop
`define checkd(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%0d exp=%0d\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0);
2023-03-14 03:03:53 +01:00
2025-09-13 15:28:43 +02:00
module t ;
2023-03-14 03:03:53 +01:00
typedef struct {
int b [ $ ] ;
} st_t ;
2024-09-02 15:45:47 +02:00
typedef struct {
int v ;
} st_in_t ;
2023-03-14 03:03:53 +01:00
function automatic st_t bar ( ) ;
// verilator no_inline_task
for ( int i = 0 ; i < 4 ; + + i ) begin
bar . b . push_back ( i ) ;
end
endfunction // bar
st_t res ;
2024-09-02 15:45:47 +02:00
st_in_t q [ $ ] ;
2023-03-14 03:03:53 +01:00
initial begin
res = bar ( ) ;
`checkd ( res . b [ 0 ] , 0 ) ;
`checkd ( res . b [ 1 ] , 1 ) ;
`checkd ( res . b [ 2 ] , 2 ) ;
`checkd ( res . b [ 3 ] , 3 ) ;
2024-09-02 15:45:47 +02:00
q . push_back ( st_in_t ' { 15 } ) ;
q [ 0 ] . v + + ;
`checkd ( q [ 0 ] . v , 16 ) ;
2023-03-14 03:03:53 +01:00
$write ( " *-* All Finished *-* \n " ) ;
$finish ;
end
endmodule