verilator/test_regress/t/t_class_member_sens.v
Krzysztof Bieganski 9c2ead90d5
Add custom memory management for verilated classes (#3595)
This change introduces a custom reference-counting pointer class that
allows creating such pointers from 'this'. This lets us keep the
receiver object around even if all references to it outside of a class
method no longer exist. Useful for coroutine methods, which may outlive
all external references to the object.

The deletion of objects is deferred until the next time slot. This is to
make clearing the triggered flag on named events in classes safe
(otherwise freed memory could be accessed).
2022-09-28 18:54:18 -04:00

31 lines
611 B
Systemverilog

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2022 by Antmicro Ltd.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
class EventClass;
event e;
endclass
EventClass ec = new;
int cyc = 0;
always @ec.e ec = new;
always @(posedge clk) begin
cyc <= cyc + 1;
if (cyc == 1) ->ec.e;
else if (cyc == 2) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
endmodule