2020-04-05 13:30:23 +00: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
|
|
|
|
|
|
|
|
class ClsNoArg;
|
2020-08-23 02:44:00 +00:00
|
|
|
const int imembera; // Ok for new() to assign to a const
|
2020-04-05 13:30:23 +00:00
|
|
|
function new();
|
2023-04-09 23:46:47 +00:00
|
|
|
int other = other_func();
|
2020-04-05 13:30:23 +00:00
|
|
|
imembera = 5;
|
2023-04-09 23:46:47 +00:00
|
|
|
if (other != 6) $stop;
|
2020-09-19 14:30:31 +00:00
|
|
|
endfunction : new
|
2023-04-09 23:46:47 +00:00
|
|
|
function int other_func();
|
|
|
|
return 6;
|
|
|
|
endfunction
|
2020-04-05 13:30:23 +00:00
|
|
|
endclass
|
|
|
|
|
|
|
|
class ClsArg;
|
|
|
|
int imembera;
|
|
|
|
function new(int i);
|
|
|
|
imembera = i + 1;
|
|
|
|
endfunction
|
2020-04-12 22:57:12 +00:00
|
|
|
function int geta;
|
|
|
|
return imembera;
|
|
|
|
endfunction
|
2020-11-28 17:43:13 +00:00
|
|
|
static function ClsArg create6;
|
|
|
|
ClsArg obj;
|
|
|
|
obj = new(6 - 1);
|
|
|
|
return obj;
|
|
|
|
endfunction
|
2020-04-05 13:30:23 +00:00
|
|
|
endclass
|
|
|
|
|
2021-10-09 23:19:31 +00:00
|
|
|
class Cls2Arg;
|
|
|
|
int imembera;
|
|
|
|
int imemberb;
|
|
|
|
function new(int i, int j);
|
|
|
|
imembera = i + 1;
|
|
|
|
imemberb = j + 2;
|
|
|
|
endfunction
|
2021-10-13 01:22:59 +00:00
|
|
|
|
|
|
|
function Cls2Arg clone();
|
|
|
|
Cls2Arg ret;
|
|
|
|
ret = new(imembera, imemberb);
|
|
|
|
return ret;
|
|
|
|
endfunction
|
2021-10-09 23:19:31 +00:00
|
|
|
endclass
|
|
|
|
|
2020-04-05 13:30:23 +00:00
|
|
|
module t (/*AUTOARG*/);
|
|
|
|
initial begin
|
|
|
|
ClsNoArg c1;
|
2021-10-09 23:19:31 +00:00
|
|
|
ClsArg c2;
|
|
|
|
Cls2Arg c3;
|
2021-10-13 01:22:59 +00:00
|
|
|
Cls2Arg c4;
|
2020-04-12 22:57:12 +00:00
|
|
|
|
2020-04-05 13:30:23 +00:00
|
|
|
c1 = new;
|
|
|
|
if (c1.imembera != 5) $stop;
|
2020-04-12 22:57:12 +00:00
|
|
|
|
2020-11-28 17:26:44 +00:00
|
|
|
c2 = new(3 - 1);
|
2020-04-05 13:30:23 +00:00
|
|
|
if (c2.imembera != 3) $stop;
|
2020-04-12 22:57:12 +00:00
|
|
|
if (c2.geta() != 3) $stop;
|
2020-04-05 13:30:23 +00:00
|
|
|
|
2020-11-28 17:43:13 +00:00
|
|
|
c2 = ClsArg::create6();
|
|
|
|
if (c2.imembera != 6) $stop;
|
|
|
|
if (c2.geta() != 6) $stop;
|
|
|
|
|
2021-10-09 23:19:31 +00:00
|
|
|
c3 = new(4, 5);
|
|
|
|
if (c3.imembera != 5) $stop;
|
|
|
|
if (c3.imemberb != 7) $stop;
|
|
|
|
|
2021-10-13 01:22:59 +00:00
|
|
|
c4 = c3.clone();
|
|
|
|
if (c4.imembera != 6) $stop;
|
|
|
|
if (c4.imemberb != 9) $stop;
|
|
|
|
|
2020-04-05 13:30:23 +00:00
|
|
|
$write("*-* All Finished *-*\n");
|
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
endmodule
|