RE: [sv-bc] query regarding casting

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Thu Jun 29 2006 - 23:51:14 PDT
Dave,

 

The part about "tagged" as part of the identifier is Mantis 1445.

 

Shalom

 

________________________________

From: owner-sv-bc@server.eda-stds.org
[mailto:owner-sv-bc@server.eda-stds.org] On Behalf Of Rich, Dave
Sent: Thursday, June 29, 2006 5:55 PM
To: subhamoy@cal.interrasystems.com; Brad Pierce
Cc: sv-bc@server.eda-stds.org
Subject: RE: [sv-bc] query regarding casting

 

This example came from Superlog, which had a different set of guarantees
about the size and layout of C compatible data types. The example should
be changed to remove the real and to not use 'tagged' as part of an
identifier because it has nothing to do with tagged unions.

 

Dave

 

 

________________________________

From: owner-sv-bc@server.eda-stds.org
[mailto:owner-sv-bc@server.eda-stds.org] On Behalf Of Subhamoy Pal
Sent: Wednesday, June 28, 2006 10:55 PM
To: Brad Pierce
Cc: sv-bc@server.eda-stds.org
Subject: Re: [sv-bc] query regarding casting

 

Brad,
then does it mean we can not cast an unpacked aggregate, containing
real/shortreal, to a bitstream type? If so, then the LRM example in
4.14,
 
tagbits t = tagbits'(a[3]); // convert structure to array of bits

is not correct because 'a[3]' can contain real type as a part of it.

-- Subhamoy


Brad Pierce wrote:

Subhamoy,

 

I think the only way to bit-stream reals or shortreals is with the
$realtobits(), $bitstoreal(), $shortrealtobits() and $bitstoshortreal()
system functions.  Reals and shortreals are not bit-stream types.

 

-- Brad

 

________________________________

From: owner-sv-bc@eda-stds.org [mailto:owner-sv-bc@eda-stds.org] On
Behalf Of Subhamoy Pal
Sent: Wednesday, June 28, 2006 5:32 AM
To: sv-bc@eda-stds.org
Subject: [sv-bc] query regarding casting

 

In SV LRM 4.14, I found the following example:

typedef struct {
bit isfloat;
union { int i; shortreal f; } n; // anonymous type
} tagged_st; // named structure

typedef bit [$bits(tagged_st) - 1 : 0] tagbits; // tagged_st defined
above

tagged_st a [7:0]; // unpacked array of structures

tagbits t = tagbits'(a[3]); // convert structure to array of bits

Here a[3] can be assigned with '{isfloat:1, n:'{f:2.5}}. Here the
problem is if we consider the 33 bits needed to represent value of a[3],
the least significant 32 bits will be a representation for
shortreal(i.e. the memory representation will be of C float type).
Treating this 32 bit representation as bitstream representation does not
mean anything significant.
In LRM, though I found how a real or shortreal data type can be casted
to a bit stream, but I can not find any LRM verse which specifies how to
cast an unpacked aggregate, containing real/shortreal data, to a packed
aggregate. Can anyone please specify any such LRM section and verse?

--Subhamoy

 
Received on Thu Jun 29 23:52:50 2006

This archive was generated by hypermail 2.1.8 : Thu Jun 29 2006 - 23:53:08 PDT