RE: [sv-ec] FW: Can randomize() be called in a constraint

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Mon Nov 30 2009 - 10:01:41 PST
I brought up the ambiguous wording of the item you quoted in 18.5.11 with the editor a year ago. I understood the intent to be "shall", but he did not feel comfortable with changing it on his own. I don't think it ever came up before the committee.

Note that the sentence preceding the dashed list in which this appears is,
"To handle these common cases, SystemVerilog allows constraint expressions to include function calls, but it imposes certain semantic restrictions:".

If this item is just a recommendation ("should"), then it is not an imposed restriction.

Shalom

> -----Original Message-----
> From: Yum, Sunny [mailto:Sunny_Yum@mentor.com] 
> Sent: Monday, November 30, 2009 12:27 PM
> To: Bresticker, Shalom
> Subject: RE: [sv-ec] FW: Can randomize() be called in a constraint
> 
> Chris,
> 
> The LRM is worded in the following way regarding function calls in
> constraints (18.5.11):
> 
> "Functions that appear in constraint expressions should be 
> automatic (or
> preserve no state information)
> and have no side effects."
> 
> So the LRM is not so strict as to disallow calls to functions 
> that have
> side effects, but it is discouraged.
> 
> As far as Questa is concerned, calls to functions that have 
> side effects
> are allowed (although the result of which is not defined by 
> the LRM, but
> we try to do what makes the most sense), but we do not 
> currently allow a
> call to "randomize()" specifically from within a constraint.
> 
> Regards,
> Sunny
> 
> -----Original Message-----
> From: owner-sv-ec@server.eda.org 
> [mailto:owner-sv-ec@server.eda.org] On
> Behalf Of Bresticker, Shalom
> Sent: Thursday, November 26, 2009 10:51 AM
> To: SV_EC List
> Subject: [sv-ec] FW: Can randomize() be called in a constraint
> 
> 
>  
> 
> -----Original Message-----
> From: owner-sv-bc@server.eda.org 
> [mailto:owner-sv-bc@server.eda.org] On
> Behalf Of Chris Spear
> Sent: Thursday, November 26, 2009 12:44 PM
> To: sv-bc@server.eda.org
> Subject: [sv-bc] Can randomize() be called in a constraint
> 
> File this under "customers do the most amazing things". Is it legal to
> call the randomize function in a constraint? 
> 
> class A;
>   rand int i;
>   RandStuff stuff;
>   constraint c { i == stuff.randomize(); }
> endclass
> 
> This seems to violate the "no side effects" rule.  Not to mention that
> declaring "stuff" as rand would have done this automatically.
> 
> Thanks! 
> Chris Spear 
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Nov 30 10:03:56 2009

This archive was generated by hypermail 2.1.8 : Mon Nov 30 2009 - 10:04:57 PST