Re: [sv-ec] Question about the definition of New for dynamic arrays.

From: Krishanu Debnath <krishanu_at_.....>
Date: Tue Apr 04 2006 - 22:54:15 PDT
Brad Pierce wrote:
> Maybe no restrictions are necessary.  How about the following?
> 
>  In 5.6.1, REPLACE
> 
>    "Must be a non-negative integral expression."
> 
>  WITH 
> 
>    "The type of this operand is longint unsigned."
> 
>  WHERE
> 
>    "longint unsigned" is in a boldface constant-width font.
> 
> -- Brad

I agree with this.

> 
> -----Original Message-----
> From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
> francoise martinolle
> Sent: Tuesday, April 04, 2006 8:21 PM
> To: sv-ec@eda.org
> Subject: [sv-ec] Question about the definition of New for dynamic
> arrays.
> 
>  
> Section 5.6.1 states that the expression inside the [] for a dynamic
> array
> allocation
> needs to be a non negative integral expression. This means that the
> expression can be 0
> and can contain x and z.
> This presumably makes the following legal:
> What is the value of v after each default pattern assignments?
> 
> 
> 
> module sample ();
> 
>   logic v[];
> 
>   initial begin
>     v = new[0];
>     v = '{default: 1'b0};
>     v = new [4'bxzxz]
>     v = '{default: 1'b0};
>     
>   end
> endmodule // sample
> 
> 
> Intuitively new[0] is like malloc(0) and I do agree that we should
> accept
> that.

But SV doesn't define the behavior when requested size is zero. C makes the
behavior implementation defined. But C also mention two options:

1> Return null pointer.

2> Return a non-zero value, but you can't used that value (returned by malloc)
    to access an object.

Most of the SV implementation behaves exactly like this, I believe. :-)
But Standard should mention the behavior.

> But why should we accept 4 state values? Shouldn't we change the
> definition
> that the expression
> inside the [] should be a non negative 2 state value? Another solution
> is to
> say that
> a 4 state valued expression is implicitly converted to a 2 state value
> x=>0,
> z=> 0
> hence any expression containing x and z is equivalent to 0.
> 
> 
> 
> Francoise
>     '
> 
> 
> 

Krishanu
Received on Tue Apr 4 22:53:24 2006

This archive was generated by hypermail 2.1.8 : Tue Apr 04 2006 - 22:53:34 PDT