RE: [sv-ec] Re: [sv-bc] Queries on enum name method

From: Jonathan Bromley <jonathan.bromley_at_.....>
Date: Fri Apr 04 2008 - 06:24:23 PDT
> it is not clear, how given value can be out side the member of enumeration.

It's perfectly clear.  Here are two possible ways to get that,
both explicitly legitimised by the LRM:

  typedef enum {A=1, B=2} E;
  E e;                  // (1) e initialises to zero
  initial begin
    $display(e.name);   // "" since e==0
    e = A;              // normal assignment
    $display(e.name);   // "A", OK
    e = E'(7);          // (2) unchecked cast
    $display(e.name);   // ""
    ...

The behaviour of the enum methods is well-defined
(though not always intuitive) in such situations.

> 'A' can't be assigned by '1' or '0'

Shalom wasn't suggesting *assigning* those values.
Continuing my previous example:
    
    if (e==7) ....

e "is" 7.  That's its underlying value, and I can test
for it if I wish.

With regards to your first question, the LRM is suffering
slightly because we don't have a neat terminology for
"the thing to which a method is applied" - for example,
"e" in "e.name".  I'm tempted to suggest calling it 
the subject of the method, but perhaps the analogy with
natural language syntax is too open to misinterpretation.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223                   Email: jonathan.bromley@doulos.com
Fax: +44 (0)1425 471573                           Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Apr 4 06:27:20 2008

This archive was generated by hypermail 2.1.8 : Fri Apr 04 2008 - 06:28:49 PDT