The LRM says,
The real literal constant numbers shall be represented as described by IEEE Std 754, an IEEE standard for
double-precision floating-point numbers. (5.7.2)
10The real and shortreal types are represented as described by IEEE Std 754. (6.12)
NOTE-The real numbers accepted or generated by these functions shall conform to the IEEE 754 representation of the
single precision and double precision floating point numbers. The conversion shall round the result to the nearest valid
representation. (20.5)
("These functions" refers to $rtoi, etc.)
Shalom
From: owner-sv-dc@eda.org [mailto:owner-sv-dc@eda.org] On Behalf Of Steven Sharp
Sent: Monday, June 13, 2011 7:27 PM
To: Francoise Martinolle; Little Scott-B11206; sv-dc@eda.org
Subject: [sv-dc] RE: mantis 3398 updated
I expect that you meant to use $itor, not $bitstoreal. The $itor system function converts an integer to a real with truncation (or you could simply assign the value without a system function to get rounding). The $bitstoreal function treats the integer as the bits of the representation of a floating point number, so it makes no sense unless the bit vector is exactly 64 bits. The exact representation is not specified (e.g. even if it is assumed to use IEEE floating point format, ordering of the bits could vary with implementation) so it isn't guaranteed to make sense for any value not produced by $realtobits.
The revised example does make use of the parameterized data field, and it shows an example of a driven field (data) being used to compute a dependent value (r). However, it seems like a less realistic example than the previous one, and the name Tsum no longer seems appropriate. I would suggest that it go back to adding up the data values, rather than ORing them together. Then it would make more sense if the parameter value were larger than 2 in the first specialization.
From: owner-sv-dc@eda.org [mailto:owner-sv-dc@eda.org] On Behalf Of Francoise Martinolle
Sent: Monday, June 13, 2011 12:06 PM
To: Little Scott-B11206; sv-dc@eda.org
Subject: [sv-dc] RE: mantis 3398 updated
I changed the whole example.
How does this look like?
class Base #(parameter p = 1);
typedef struct {
real r;
bit[p-1:0] other_data;
} T;
static function T Tsum(input T driver[]);
Tsum.r= 0.0;
Tsum.data = 0;
foreach (driver[i])
Tsum.rdata +|= driver[i]. rdata;
Tsum.r = $bitstoreal(Tsum.data);
endfunction
endclass
typedef Base#(2) MyBaseT;
nettype MyBaseT::T narrowTsum with MyBaseT::Tsum;
typedef Base#(32) MyBaseType;
nettype MyBaseType::T wideTsum with MyBaseType::Tsum;
narrowTsum net1; // other_data is 2 bits wide
wideTsum net2; // other_data is 32 bits wide
-- This message has been scanned for viruses and dangerous content by MailScanner<http://www.mailscanner.info/>, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner<http://www.mailscanner.info/>, and is believed to be clean. --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Sun Jun 19 07:26:14 2011
This archive was generated by hypermail 2.1.8 : Sun Jun 19 2011 - 07:26:17 PDT