Re: Why is type for string parameters mandatory?

From: Geoffrey.Coram <Geoffrey.Coram_at_.....>
Date: Wed Nov 15 2006 - 05:10:22 PST
To Sri's question:

In AMS LRM 2.2, Section 3.2.1 page 27, it says "it shall be an error
to assign a numeric value to a parameter declared as string or to
assign a string value to an integer or real parameter, whether that
parameter was declared as integer or real or had its type derived
from the type of the value of the constant expression."


Back to Dave's question:

The trouble with 1364 was that variables' type and range were
determined not by the default expression but (per 4.10.1 in 1364-2005)

  - A parameter declaration with no type or range specification
    shall default to the type and range of the final value
    assigned to the parameter, after any value overrides have
    been applied.

We specifically wanted to rule out the possibility that a
parameter could switch between real/integer and string.

In 1800-2005, one has the statement (in 6.3.2):
  In an assignment to, or override of, a parameter without
  an explicit type declaration, the type of the right-hand
  expression shall be real or integral.

I believe that "an explicit type declaration" is one like
  parameter string mystr = "hi";
and that, therefore, 1800 has the same requirement on 
string parameters as was added in AMS LRM 2.2.  (I believe
that
  parameter mystr = "hi";
is an assignment as well as a declaration, and thus is 
illegal per the statement above.

It would be fine with me to remove "string_parameter_declaration"
as a separate syntax item and instead add the semantic restriction
from 1800.

(On an aside, I was a little confused by whether "explicit type
declaration" might instead refer to this sort of thing:
  parameter type p2 = shortint;
One then uses p2 to declare variables in the module
   p2 j = 0;
as shown in 6.3.3)

-Geoffrey



Sri Chandra wrote:
> 
> Actually i might be wrong in one thing that I mentioned. I think we took
> the string parameter definition from SystemVerilog. Need to check that
> and also verify whether it was compulsory to specify the type for string
> parameters.
> 
> Also, as i mentioned earlier its possible that we might have made it
> mandatory to specify the type for the syntax checker since this
> parameter declaration syntax was slightly different to integer and real
> parameters.
> 
> However i someone does
> 
> parameter myParam = "abc";
> 
> whether this would be treated as integer and what the value of the
> integer would be. I need to check this by running on the simulator.
> Probably an error?
> 
> cheers,
> Sri
Received on Wed Nov 15 05:10:28 2006

This archive was generated by hypermail 2.1.8 : Wed Nov 15 2006 - 05:10:30 PST