[sv-bc] Concat including enum as lvalue?

From: Jonathan Bromley <jonathan.bromley_at_.....>
Date: Tue Jun 20 2006 - 06:56:47 PDT
Once again I beg a clarification, with the usual caveat that
the answer may already be in the LRM and I've just missed it.
If that's the case, feel free to slap my wrists.

Enum variables are strongly typed in the sense that if
used as the target of an assignment, the expression
forming the right-hand side of the assignment must be
of the same enum type.  So far, so good.

Whenever an enum appears as an expression, its numeric
value may be used without explicit casting.  Also OK,
if perhaps a little free-and-easy.

So, therefore, I think the following is OK:

  enum bit[1:0] {A, B, C, D} E2;
  bit [1:0] B2;
  bit [3:0] B4;
  ...
  B4 = {B2, E2};

because E2 is silently cast to "bit [1:0]" for 
use in the expression.  But what about

  {B2, E2} = B4;

??  The tools I've tried permit this, although at least
one of them can be persuaded to generate mysteriously
wrong answers.  I can see reasonable arguments both for
and against accepting such a construct, but I don't
see the LRM pronouncing on it.

If there *is* strong type checking in such a case, then
is the following OK?

  {B2, E2} = {2'b0, E2};  // component types match

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

This e-mail and any  attachments are  confidential and Doulos Ltd. reserves 
all rights of privilege in  respect thereof. It is intended for the use of 
the addressee only. If you are not the intended recipient please delete it 
from  your  system, any  use, disclosure, or copying  of this  document is 
unauthorised. The contents of this message may contain personal views which 
are not the views of Doulos Ltd., unless specifically stated.
Received on Tue Jun 20 06:57:06 2006

This archive was generated by hypermail 2.1.8 : Tue Jun 20 2006 - 06:57:13 PDT