User guide
24-46
SystemVerilog Testbench Constructs
initial begin
Parcel pk1 = new;
Parcel pk2 = new;
Parcel pk3 = new;
$display("%d Parcel", pk3.count);
$display("%d Parcel", pk2.count);
$display("%d Parcel", pk1.count);
end
endprogram
Output
5 Parcel
5 Parcel
5 Parcel
In the above example, every time an object of type Parcel is created,
the new() function is invoked and the static variable count is
incremented. The final value of count is “5.” If count is declared as
non-static, the output of the above program is:
3 Parcel
3 Parcel
3 Parcel
Global Constant Class Properties
The const keyword is used to designate a class property as
read-only. Class objects are dynamic objects, therefore either global
or instance properties can be designated “const.” At present, only
global constants are supported.
When declared, a global constant class property includes an initial
value. Consider the following example:
//global_const.sv
program test;