Parameters in SV can be a fixed size array (I'm not sure how about
dynamic arrays etc if they can be parameters bcos their dynamic nature
is in contrast with parmeter constant nature).
From performance point of view It would be nice if we can pass such
array by reference instead making copy of it each time - this is my
motivation.
I think that internal details of implementation should not stop us from
extending the LRM in this case there will be no back-compatibility issue
- user will have more posssibilities.
DANiel
On 8/25/2011 2:29 AM, Steven Sharp wrote:
>
> It may not be clear from the LRM text, but the intent is that a const
> variable can be passed to a const ref argument. The only restriction
> on a const variable is that it cannot be written. Since you cannot
> write to a const ref argument, passing a const variable to a const ref
> argument cannot result in its being written, so it would be legal.
> One reason this might not have been explicitly specified is that the
> const qualifier was borrowed from C, and the authors of the LRM text
> may have automatically assumed the behavior from C without specifying
> it in the LRM.
>
> Parameters are another matter, as they are not just variables you
> aren't allowed to write to. An implementation may not keep a copy of
> the value available in the format that variables are stored in,
> suitable for passing to a ref argument. Doing so would only be a
> minor burden on the implementation. But it is also trivial for the
> user to set a const variable to the value of the parameter and pass
> that. I don't think we want to start down that slippery slope that
> leads to arbitrary expressions being passed to ref arguments.
>
> *From:*owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] *On Behalf Of
> *Daniel Mlynek
> *Sent:* Wednesday, August 24, 2011 8:31 AM
> *To:* sv-ec@eda.org
> *Subject:* [sv-ec] "const ref" for parameters and consts
>
> LRM about refs says:
>
> /Only the following shall be legal to pass by reference:/
>
> /--- a variable,/
>
> /--- a class property,/
>
> /--- a member of an unpacked structure, or/
>
> /--- an element of an unpacked array./
>
>
> So only variables are allowed for ref ports (no word about const,
> parameter)
> But then const ref was added to the standart.
> IMHO there is no sensible argument to forbid parameters to be passed
> by "const ref" like in below case.
>
> module top;
> parameter byte a = 1;
> task automatic t (const ref byte a);
> $display(a);
> endtask
> initial
> t(a);
> endmodule
>
>
> Maybe LRM should allow parameters and const explicitly for const ref only.
>
> Should I register a mantis - there is no similar yet?
>
>
> 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 Aug 24 23:08:56 2011
This archive was generated by hypermail 2.1.8 : Wed Aug 24 2011 - 23:09:00 PDT