Re: [sv-ec] creating object in constant function call

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Thu Mar 19 2009 - 08:29:52 PDT
I have an indirect argument as to why this is illegal.  The LRM
says the following about constant function calls:

    Their execution has no effect on the initial values of the variables
    used either at simulation time or among multiple invocations of a
    function at elaboration time.

The intent is that constant function calls can be redundantly
evaluated an implementation-dependent number of times without
interfering with the results of elaboration.  That is a critical
property.

But that isn't true of object creation -- object creation always
has an impact on the random number generation and "redundant"
evaluation will impact object stability of the solver.

So I think that you can argue that "new" isn't constant even from
the current LRM.

Gord


Daniel Mlynek wrote:
> LRM is not explicit about creating an object in constant funcion call - 
> should it be allowed? Should it be forbidden - see below example:
>  
> 
>     module top;
>      parameter p=10;
>      
>      int j;     
>      
>      class C;
>       int i;
>       function new;
>        $display("constructor");
>       endfunction
>      endclass
>      
>      function int f7(int i);
>       C c = new;
>       return i;
>      endfunction
>      
>       
>      reg [f7(10):0] r7;
>      
>     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 email was Anti Virus checked by Astaro Security Gateway. http://www.astaro.com

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Mar 19 08:30:45 2009

This archive was generated by hypermail 2.1.8 : Thu Mar 19 2009 - 08:31:29 PDT