I tend to agree with Gord. As the text is written today, it seems that the only plausible semantic model is to change the default value every time the default assignment pattern is used.
Arturo
From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Gordon Vreugdenhil
Sent: Monday, October 25, 2010 7:53 AM
To: Bresticker, Shalom
Cc: sv-ec@eda.org
Subject: Re: [sv-ec] Associative array default value
In terms of a specific example:
module top;
int words [int] = '{default: 1};
initial begin
words = '{default: 3};
$display("%d", words[1]);
end
endmodule
The question is whether the LRM is clear that "3" should be the expected output.
I don't think it directly addresses this but there is no restriction in the LRM that either the syntax or semantics is restricted to initialization. So I would not expect anyone to assume the "initialization only" semantics. I guess we could clarify this, but do we really need to? I'd prefer not since that continues to add text to describe what is a legal combination of semantics and that tends to be more fragile.
If there is wider confusion on this question, fine. Otherwise I think that we shouldn't directly address this in the LRM text.
Gord.
On 10/24/2010 2:07 AM, Bresticker, Shalom wrote:
Hi,
7.9.11 says,
"Associative array literals use the '{index:value} syntax with an optional default index. Like all other arrays, an associative array can be written one entry at a time, or the whole array contents can be replaced using an array literal.
For example:
// an associative array of strings indexed by 2-state integers,
// default is "hello".
string words [int] = '{default: "hello"};
// an associative array of 4-state integers indexed by strings, default is -1
integer tab [string] = '{"Peter":20, "Paul":22, "Mary":23, default:-1 };
If a default value is specified, then reading a nonexistent element shall yield the specified default value, and no warning shall be issued. Otherwise, the default initial value as described in Table 7-1 shall be returned.
Defining a default value shall not affect the operation of the associative array methods (see 7.9)"
Question: the examples only show the use of a default in an associative array initialization. If such an assignment is performed to an associative array later in the simulation, does it become a new default value, or does it have that effect only if specified at initialization?
In the implementations I tested, this assignment did change the default. I think the LRM should be explicit about this.
Thanks,
Shalom
Shalom Bresticker
Intel LAD DA, Jerusalem, Israel
+972 2 589 6582 (office)
+972 54 721 1033 (cell)
http://www.linkedin.com/in/shalombresticker
---------------------------------------------------------------------
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<http://www.mailscanner.info/>, and is believed to be clean. -- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.com<mailto:gordonv@model.com> -- 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 Mon Oct 25 09:53:39 2010
This archive was generated by hypermail 2.1.8 : Mon Oct 25 2010 - 09:53:45 PDT