RE: [sv-bc] Concat including enum as lvalue?

From: Rich, Dave <Dave_Rich_at_.....>
Date: Tue Jun 20 2006 - 07:45:41 PDT
Jonathon,

Enums are treated the same as unpacked structures for matching and
equivalence rules. See 6.9.1 d). Section 6.9.3 defines assignment
compatibility for those types that define an implicit cast, and an enum
type defines an implicit cast in *one direction* only. See 4.10.3.

Therefore,

{B2, E2} = B4;

would require an implicit cast from a packed integral type to an enum to
be legal - no implicit cast is defined.

{B2, E2} = {2'b0, E2};

Is also illegal because the RHS creates an integral type 4-bits wide. It
is not an assignment pattern.

Dave


BTW, I noticed that 6.9.2b is superfluous. It is covered by 6.9.1c
together with 6.9.2a.


> -----Original Message-----
> From: owner-sv-bc@server.eda-stds.org [mailto:owner-sv-bc@server.eda-
> stds.org] On Behalf Of Jonathan Bromley
> Sent: Tuesday, June 20, 2006 6:57 AM
> To: sv-bc@server.eda-stds.org
> Subject: [sv-bc] Concat including enum as lvalue?
> 
> 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 07:45:47 2006

This archive was generated by hypermail 2.1.8 : Tue Jun 20 2006 - 07:45:53 PDT