Re: Enumerated Types Proposals


Subject: Re: Enumerated Types Proposals
From: Peter Flake (flake@co-design.com)
Date: Mon Apr 08 2002 - 04:05:45 PDT


Kevin,

If a value is not specified, then the following from Cliff should apply:

Draft 4, Section 3.6 - page 8
Section 3.6 - Paragraph #2 Clarification Proposal
PROPOSAL: modify the second paragraph as follows:
The named values can be cast to integer types, and increment from an initial value of 0. This can be over-ridden. If integers are assigned to some but not all of the named values, unassigned named values are implicitly assigned an increment of the previous explicitly or implicitly assigned integer.
enum {bronze=3, silver, gold} medal; // silver=4, gold=5
enum (a=3, b=7, c) alphabet; // c=8

Peter.

At 10:30 AM 4/5/02 -0800, Kevin Cameron wrote:
 

Peter Flake wrote:
 Cliff,

We have considered your proposals, and we have a counter-proposal which we think should satisfy your requirements.

We propose an optional data type with the enum.  The default data type is int

enum [data_type] { enum_member {, enum_member} }

The data type is limited to integer data types, 2 state or 4 state. The 4 state data types can have constant values containing X or Z.
For example:
enum logic [1:0] { S0=2'b00, S1=2'b01, S2=2'b11, XX='x } state, next;

Peter.
What values get assigned if a value (or part of it) is not specified?

Maybe want a default:

    enum [data_type] [ = <default value>] { enum_member {, enum_member} }
 
  e.g.:
    enum logic [1:0] = 2'b00   { S0=1'b0, S1=1'b1, S2=2'b11, XX=2'bxx } state, next;

  which extends as:
    enum logic [2:0] = 3'b100 { S0=1'b0, S1=1'b1, S2=2'b11, XX=2'bxx, BAD } state, next;
                                                                                                  // BAD takes default ==3'b100

Note: since enums in C always allocate specific numbers (regardless of the compiler)
mixing code from different compilers does not cause a problem (wrt enums). The
same should (IMO) be true for SystemVerilog enums.

Kev.
 



This archive was generated by hypermail 2b28 : Mon Apr 08 2002 - 06:50:17 PDT