Re: [sv-ec] Associative array default value

From: Gordon Vreugdenhil <gordonv@Model.com>
Date: Mon Oct 25 2010 - 07:52:49 PDT

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
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Oct 25 07:53:11 2010

This archive was generated by hypermail 2.1.8 : Mon Oct 25 2010 - 07:53:32 PDT