Overriding Constraints

Hi Moderators,

I was trying a few variation of constraint override on edaplayground

There are 2 main scenarios.One without overriding the random property in extended class and the other with

[A] Without overriding the property

Due to constraint override the base class constraint doesn’t take effect and a is always 3 during R1

(Q1) In R2 why does b.V.constraint_mode(0) switch off the constraint in extended class ?

Doesn’t this violate the quote that base class handle can’t access extended class members ?

I observe that there is no constraint on a

(Q2) Using b.V.constraint_mode(1) followed by ext.V.constraint_mode(0) why doesn’t the base class constraint take effect in R3 ?

I expected R3 to behave as if there was no constraint override i.e a should always be 1

Based on output i.e a being unconstrained it’s as if constraint override still exists ::

constraint V { 1; } // In Ext class

[B] With +define+OP i.e we override property a

(Q3) Since there are two properties named a shouldn’t base::V constraint inherited a while Ext::V constraint overridden property a in R1?

I observe base::a is unconstrained while ext::a is constrained to 3

(Q4) Via R2 and R3 I observe both properties a are unconstrained. Why is it so ?

Thanks