User guide

24-47
SystemVerilog Testbench Constructs
class Xvdata_Class;
const int pi = 31412;//const variable
endclass
Xvdata_Class data;
initial begin
data = new();
data.pi = 42; //illegal and will generate
//compile time error
end
endprogram
The line, data.pi=42, is not valid and yields the following compile
time error message:
Error-[IUCV] Invalid use of 'const' variable
Variable 'pi' declared as 'const' cannot be used
in this context
"global_const.sv", 17: data.pi = 42;
Method Declarations: Out of Class Body Declarations
The following example demonstrates the usage of scope resolution
for:
Declaring class function outside class
Accessing class enum label in inline constraint block
Declaring constraint block out of class and also accessing class
enum label inside that block
program prog;
typedef enum {X, Y} A;
class C;
typedef enum {S1,S2,S3,S4} E; //enum declared inside class