The reason is deep in the mists of time.
Scematic capture tools (valid) used to write out netlists and
always included a bit select of [0] with scalars; because of this,
early Verilog interpreters (Verilog-XL) accepted such references
without complaint; and 18 years later, here we are.
-- On Dec 9 2004 at 15:41, Maidment, Matthew R sent a message:
> To: fm@cadence.com, sv-bc@eda.org
> Subject: "RE: [sv-bc] enumeration types"
> I agree with your conclusions. It should not be legal to
> index into an enum if the base type is a scalar.
>
> Practically speaking, my experience is that various simulators
> consider it a "feature" to enable reference to a scalar with the index
> [0].
> Not all tools allow it and it's not in the standard AFAICT.
>
> Matt
>
>
> ________________________________
>
> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf
> Of Francoise Martinolle
> Sent: Thursday, December 09, 2004 1:50 PM
> To: sv-bc@eda.org
> Subject: [sv-bc] enumeration types
>
>
> I think that the following is legal:
> typedef enum bit {bit0, bit1} mybit;
>
> But can I use a bit select of a variable of that type when the
> base type of the enum is just bit or logic or alias
> thereof?
>
> mybit v;
>
> initial v[0] = 1'b0;
>
>
> I think that if I define:
> typedef enum bit[0:0] {bit0, bit1} mybitvec;
>
> v[0] is legal.
>
> Francoise
> '
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=Content-Type content="text/html; charset=us-ascii">
> <META content="MSHTML 6.00.2800.1476" name=GENERATOR></HEAD>
> <BODY>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2>I agree with your conclusions. It should not be legal
> to</FONT></SPAN></DIV>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2>index into an </FONT></SPAN><SPAN class=974333723-09122004><FONT
> face="Courier New" color=#800080 size=2>enum if the base type is a
> scalar.</FONT></SPAN></DIV>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2></FONT></SPAN> </DIV>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2>Practically speaking, my experience is that various simulators
> </FONT></SPAN></DIV>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2>consider it a "feature" to enable reference to </FONT></SPAN><SPAN
> class=974333723-09122004><FONT face="Courier New" color=#800080 size=2>a scalar
> with the index [0]. </FONT></SPAN></DIV>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2>Not all tools allow it and </FONT></SPAN><SPAN
> class=974333723-09122004><FONT face="Courier New" color=#800080 size=2>it's not
> in the standard AFAICT.</FONT></SPAN></DIV>
> <DIV><SPAN class=974333723-09122004></SPAN><SPAN class=974333723-09122004><FONT
> face="Courier New" color=#800080 size=2></FONT></SPAN> </DIV>
> <DIV><SPAN class=974333723-09122004><FONT face="Courier New" color=#800080
> size=2>Matt</FONT></SPAN></DIV><BR>
> <BLOCKQUOTE dir=ltr
> style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #800080 2px solid; MARGIN-RIGHT: 0px">
> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
> <HR tabIndex=-1>
> <FONT face=Tahoma size=2><B>From:</B> owner-sv-bc@eda.org
> [mailto:owner-sv-bc@eda.org] <B>On Behalf Of </B>Francoise
> Martinolle<BR><B>Sent:</B> Thursday, December 09, 2004 1:50 PM<BR><B>To:</B>
> sv-bc@eda.org<BR><B>Subject:</B> [sv-bc] enumeration
> types<BR></FONT><BR></DIV>
> <DIV></DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>I think that the
> following is legal:</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>typedef enum bit
> {bit0, bit1} mybit;</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>But can I use a
> bit select of a variable of that type when the base type of the enum is just
> bit or logic or alias</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004>thereof?</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>mybit
> v;</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>initial v[0] =
> 1'b0;</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>I think that if I
> define:</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>typedef enum
> bit[0:0] {bit0, bit1} mybitvec;</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN class=645404421-09122004>v[0] is
> legal.</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004></SPAN></FONT> </DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004>Francoise</SPAN></FONT></DIV>
> <DIV><FONT face=Arial size=2><SPAN
> class=645404421-09122004>
> '</SPAN></FONT></DIV></BLOCKQUOTE></BODY></HTML>
Received on Fri Dec 10 07:29:57 2004
This archive was generated by hypermail 2.1.8 : Fri Dec 10 2004 - 07:30:13 PST