[sv-bc] Re: The Action item for you from the SV-BC


Subject: [sv-bc] Re: The Action item for you from the SV-BC
From: Kevin Cameron x3251 (Kevin.Cameron@nsc.com)
Date: Mon Jan 20 2003 - 15:43:37 PST


> From Karen.Pieper@synopsys.com Mon Jan 20 13:32:41 2003
> Subject: The Action item for you from the SV-BC
>
> Hi, Kevin,
>
> In the 7/22 minutes (message 0017 on the sv-bc website), In a section
> discussing Data alignment and data packing issues, the following quote exists:
>
> AI - Kevin - may make a clarification proposal concerning alignment of
> bytes on integers.
>
> Are you going to do that, or can I mark the issue as closed?
>
> Thanks,
>
> Karen

OK, the only reference to alignment I found is:

"Note that writing one member and reading another is independent of the byte ordering of the
machine, unlike a normal union of normal structures, which are C-compatible and have ascending
address order."

 - at the end of the 3.11

I'd like to replace that with something more verbose:
-----

Data Alignment

  The data in unpacked structs and unions with only C compatible data types is
  aligned in the same manner as would be used by a C compiler on the machine
  running the simulation, allowing the direct sharing of data with external
  code written in C. SystemVerilog native types (4-state) are not directly
  shareable with external code so have no specified alignment, however when
  an unpacked union is made of SystemVerilog native types, it will behave the
  same as the equivalent C union with respect to alignment. The following
  two definitions behave equivalently with respect to how their bits overlay:

     union { char b[4];
             int i;} C_union;

     typedef logic [7:0] charx;
     union { charx b[4];
             integer i;} SV_union;

  The value of 'b[0]' will be the same using either union definition when
  writing a value (with no X or Z bits) to the member 'i'.

  The members of packed unions overlay in a platform independent manner. Each
  member of the union is internally ordered by its declaration order and then
  it's bit order, scalar types like int and integer are considered as being
  vectors of bit or logic [n-1:0], and bit n is packed first (where n is the
  number of bits required to represent the type). The following example shows
  a union being used to swap the bit order of an 8-bit value:

    typedef packed struct {char b;} msb_1st;

    typedef packed struct {bit [0:7] b;} lsb_1st;
   
    packed union { msb_1st;
                   lsb_1st; } swap;

    ....

      swap.msb_1st.b = 8'b00001111;
      $display("%b",swap.lsb_1st.b); // prints 11110000

------------

Regards,
Kev.



This archive was generated by hypermail 2b28 : Mon Jan 20 2003 - 15:44:09 PST