1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
// 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
package Pkg;
class Base0;
class BaseInnerOnly;
int inneronly;
function new();
inneronly = 10;
if (inneronly != 10) $stop;
endfunction
endclass
class BaseInnerOver;
int innerover;
function new();
innerover = 10;
if (innerover != 10) $stop;
endfunction
endclass
int baseonly;
int baseover;
BaseInnerOnly inneronly = new;
BaseInnerOver innerover = new;
function void b_set_bo(int v); baseover = v; endfunction
function int b_get_bo(); return baseover; endfunction
function int get_bo(); return baseover; endfunction
function void b_set_io(int v); innerover.innerover = v; endfunction
function int b_get_io(); return innerover.innerover; endfunction
function int get_io(); return innerover.innerover; endfunction
endclass
endpackage
// We need to import Base0, as verilator currently doesn't support
// multiple `::` references, but we would need to do that to reference
// `BaseInnerOnly` class inside `Ext` class.
import Pkg::Base0;
class Ext extends Pkg::Base0;
class BaseInnerOver;
int innerover;
function new();
innerover = 20;
if (innerover != 20) $stop;
endfunction
endclass
int baseover;
int extonly;
BaseInnerOnly inneronly = new;
BaseInnerOver innerover = new;
function void e_set_bo(int v); baseover = v; endfunction
function int e_get_bo(); return baseover; endfunction
function int get_bo(); return baseover; endfunction
function void e_set_io(int v); innerover.innerover = v; endfunction
function int e_get_io(); return innerover.innerover; endfunction
function int get_io(); return innerover.innerover; endfunction
endclass
module t (/*AUTOARG*/);
initial begin
Ext c;
c = new;
c.baseonly = 10;
c.baseover = 20;
c.extonly = 30;
c.inneronly.inneronly = 40;
c.innerover.innerover = 50;
if (c.baseonly != 10) $stop;
if (c.baseover != 20) $stop;
if (c.extonly != 30) $stop;
if (c.inneronly.inneronly != 40) $stop;
if (c.innerover.innerover != 50) $stop;
c.b_set_bo(100);
c.e_set_bo(200);
c.b_set_io(300);
c.e_set_io(400);
if (c.b_get_bo() != 100) $stop;
if (c.e_get_bo() != 200) $stop;
if (c.get_bo() != 200) $stop;
if (c.b_get_io() != 300) $stop;
if (c.e_get_io() != 400) $stop;
if (c.get_io() != 400) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule
|