Daniel,
It should behave like a virtual method - the constraint in the derived class overrides the one in the base class, regardless of the handle type used. This is described in section 18.5.2.
Arturo
From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Daniel Mlynek
Sent: Wednesday, September 08, 2010 1:10 AM
To: sv-ec@eda.org
Subject: [sv-ec] are constraints virtual like?
Please see the below code. I'm using constraints mode on a handle of base class type pointing to child class. (there are constraints with same name in base and child class)
My question is how it should behave.. Should it turn off only the constraint from base class or both constraints or should it behave virtual like and turn of child class constraint?
class C;
rand int a;
constraint con1{a==0;}
endclass
class D extends C;
constraint con1{a==10;}
endclass
module top;
C c;
D d = new;
initial begin
c = d;
c.con1.constraint_mode(0);
c.randomize();
$display(c.a);
d.randomize();
$display(c.a);
end
endmodule
DANiel
-- This message has been scanned for viruses and dangerous content by MailScanner<http://www.mailscanner.info/>, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Sep 8 09:02:19 2010
This archive was generated by hypermail 2.1.8 : Wed Sep 08 2010 - 09:02:36 PDT