[sv-bc] RE: enum name() method return value

From: Steven Sharp <sharp@cadence.com>
Date: Thu Mar 21 2013 - 12:00:17 PDT
Arturo, I assume you meant passing command.next() to "%s" is nonstandard, not command.name.

Note that passing command.next().name() is nonstandard, since I don't think chaining of method calls has been allowed yet.

And I had the same thought that $typename was available if the user really wanted to print out information about the type of the enum.  In general the type is known, and it is only the value the user is trying to get.


From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Arturo Salz
Sent: Thursday, March 21, 2013 2:42 PM
To: Bresticker, Shalom; Alsop, Thomas R; SV-BC
Cc: Janick Bergeron; Justin Refice
Subject: [sv-bc] RE: enum name() method return value

As Shalom wrote, returning  just the unadorned name of the enumeration is exactly the intent.
Note that passing command.name() as an argument to the "%s" format of $display is possibly a non-standard extension. You should use command.next().name();
To get the declaration scope you probably want to use $typename.
In order to implement a helper function that converts a string to an enum would require the helper function to unambiguously know the type of the destination enum so possibly a built-in method may be a better option.

                Arturo

From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Bresticker, Shalom
Sent: Thursday, March 21, 2013 10:59 AM
To: Alsop, Thomas R; SV-BC
Cc: Janick Bergeron; Justin Refice
Subject: [sv-bc] RE: enum name() method return value

I would expect 'READ WRITE'.

Shalom

From: owner-sv-bc@eda.org<mailto:owner-sv-bc@eda.org> [mailto:owner-sv-bc@eda.org] On Behalf Of Alsop, Thomas R
Sent: Thursday, March 21, 2013 18:53
To: SV-BC
Cc: Janick Bergeron; Justin Refice
Subject: [sv-bc] enum name() method return value

Hi,

The VIP-TSC committee (UVM) had a request come up to create a helper function which will take a string and convert it to enum.  Many users implement this themselves and we'd like to create a utility which does this in UVM.  See mantis  3693 for more details:

http://www.eda.org/svdb/view.php?id=3693

In the ticket there is an example that Justin Refice provided which uses the enum name() method to convert the string to enum.  Here is the LRM's description of this method:

6.19.5.6 Name()
The prototype for the name() method is as follows:
function string name();

The name() method returns the string representation of the given enumeration value. If the given value is
not a member of the enumeration, the name() method returns the empty string


The committee noted that this method may in fact produce different results depending on what the vendor chose to implement for name().  I wrote a simple SV example and I use name() and it simply prints out the strings:

class Xaction;

  enum {READ, WRITE} command;

  virtual function void printvirtual();
    $display("VIRTUAL command: %s %s", command.name(), command.next());
  endfunction

endclass

When this is run I see this print out:

VIRTUAL command: READ WRITE

However the committee noted that a vendor could chose to print this instead highlighting the composition:

VIRTUAL command: Xaction::READ Xaction::WRITE

We wanted to get clarification on whether or not this is correct, that what is printed can be vendor independent.

Thanks, -Tom



--
This message has been scanned for viruses and
dangerous content by MailScanner<http://www.mailscanner.info/>, and is
believed to be clean.

---------------------------------------------------------------------
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.

--
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 Thu Mar 21 12:01:09 2013

This archive was generated by hypermail 2.1.8 : Thu Mar 21 2013 - 12:01:17 PDT