Re: [sv-bc] Assignment compatibility of packed arrays of enums

From: <jonathan.bromley_at_.....>
Date: Fri Oct 02 2009 - 12:02:14 PDT
> 2009 makes it legal to create packed arrays of enums.  Is it legal 
> to assign a data object of such a type with a value that is not a 
> packed array of the same kind of enums?

On a previous occasion I have asked similar questions about
packed structs containing enums, which were already legal in 2005.
The consensus seems to be that it is legal:

  typedef enum bit {FALSE, TRUE} boolean;
  struct packed {
    bit [2:0] upper;
    boolean   mid;
    bit [3:0] lower;
  } tripartite = 8'b000_1_0000;
  // effectively copies tripartite.mid=1'b1 !!!!

This has obvious utility in synthesisable design (structured
description of control/status registers, etc) but breaks what
little type checking you otherwise get with enums.  If it's
legal for a packed struct, I can see no reason why it should
not be legal for a packed array.

I am fully aware that any practical language needs to 
have various implicit type coercions, but they sure make
it harder to define and reason about the language.
-- 
Jonathan Bromley
Consultant

Doulos - Developing Design Know-how
VHDL * Verilog * SystemVerilog * SystemC * PSL * 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                        http://www.doulos.com

--------------------------------------------------------------------------------
Doulos Ltd is registered in England and Wales with company no. 3723454
Its registered office is 4 Brackley Close, Bournemouth International 
Airport,
        Christchurch, BH23 6SE, UK. 

This message (and associated files) may contain information that is 
confidential, 
proprietary, privileged, or subject to copyright. It is intended solely 
for the use
of the individual to whom it is addressed and others authorised to receive 
it. If
you have received this email in error, please notify the sender and delete 
all
copies. This message may contain personal views which are not the views of
Doulos, unless specifically stated.


owner-sv-bc@server.eda.org wrote on 02/10/2009 11:17:27:

> From:
> 
> Brad Pierce <Brad.Pierce@synopsys.com>
> 
> To:
> 
> "sv-bc@eda.org" <sv-bc@server.eda.org>
> 
> Date:
> 
> 02/10/2009 11:21
> 
> Subject:
> 
> [sv-bc] Assignment compatibility of packed arrays of enums
> 
> Sent by:
> 
> owner-sv-bc@server.eda.org
> 
> 2009 makes it legal to create packed arrays of enums.  Is it legal 
> to assign a data object of such a type with a value that is not a 
> packed array of the same kind of enums?
> 
> In the following element-by-element assignment, the explicit cast is 
required
> 
> typedef enum logic {FALSE, TRUE} Boolean;
> 
> module test1
> (   input  logic   [5:0] in
> ,   output Boolean [5:0] out
> );
>   for (genvar I = 0; I < 6; I++) begin
>      assign out[I] = Boolean'(in[I]);
>   end
> endmodule
> 
> But are both of the following assignments legal?
> 
> typedef enum logic {STOP, GO} NotBoolean;
> 
> module test2
> (  input  logic      [5:0] in1
> ,  input  NotBoolean [5:0] in2
> ,  output Boolean    [5:0] out1, out2
> );
>   assign out1 = in1;
>   assign out2 = in2;
> endmodule
> 
> 
> -- Brad
> 
> 
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, 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 Fri Oct 2 12:03:34 2009

This archive was generated by hypermail 2.1.8 : Fri Oct 02 2009 - 12:04:15 PDT