2025-09-29 14:20:54 +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-09-29 14:20:54 +02:00
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
|
|
|
|
|
class Foo;
|
|
|
|
|
bit [2:0] x = 0;
|
|
|
|
|
function int get();
|
|
|
|
|
x += 1;
|
|
|
|
|
return int'(x);
|
|
|
|
|
endfunction
|
|
|
|
|
function bit [2:0] get2();
|
|
|
|
|
x += 1;
|
|
|
|
|
return x;
|
|
|
|
|
endfunction
|
|
|
|
|
endclass
|
|
|
|
|
|
|
|
|
|
module t;
|
|
|
|
|
Foo foo;
|
|
|
|
|
int x[5] = {1, 2, 3, 4, 5};
|
|
|
|
|
initial begin
|
|
|
|
|
foo = new;
|
|
|
|
|
if (x[foo.get()] != 2) $stop;
|
2026-03-17 03:23:07 +01:00
|
|
|
if (x[foo.get2()] != 3) $stop;
|
2025-09-29 14:20:54 +02:00
|
|
|
$write("*-* All Finished *-*\n");
|
|
|
|
|
$finish;
|
|
|
|
|
end
|
|
|
|
|
final begin
|
|
|
|
|
if (x[foo.get()] != 4) $stop;
|
|
|
|
|
end
|
|
|
|
|
endmodule
|