Hi All,
According to systemverilog LRM,
An Instance constants do not include an initial value in their declaration, only the const qualifier. This type of constant can be assigned a value at run-time, but the assignment can only be done once in the corresponding class constructor.
class A ;
const int i ;
function new();
i = 20;
i++;
i = 40;
endfunction
endclass
In the above case , assignments to the constant variable is done more than one time and I am getting final output i=40 (questasim), which is wrong as per LRM.
Please clarify, if I have missed something .
Would you please provide a reference from SV LRM for “This type of constant can be assigned a value at run-time, but the assignment can only be done once in the corresponding class constructor”.
In reply to abhijeet Sahoo:
Would you please provide a reference from SV LRM for “This type of constant can be assigned a value at run-time, but the assignment can only be done once in the corresponding class constructor”.
Section 8.19 Constant class properties of the 1800-2012 LRM