54 #ifndef __SYSTEMC_EXT_DT_FX_SCFX_IEEE_HH__ 55 #define __SYSTEMC_EXT_DT_FX_SCFX_IEEE_HH__ 57 #include "../../utils/endian.hh" 65 class scfx_ieee_double;
67 class scfx_ieee_float;
69 #define SCFX_MASK_(Size) ((1u << (Size))-1u) 83 #if defined(SC_BOOST_BIG_ENDIAN) 86 unsigned mantissa0:20;
87 unsigned mantissa1:32;
88 #elif defined(SC_BOOST_LITTLE_ENDIAN) 89 unsigned mantissa1:32;
90 unsigned mantissa0:20;
126 operator double()
const;
128 unsigned int negative()
const;
129 void negative(
unsigned int);
130 int exponent()
const;
132 unsigned int mantissa0()
const;
133 void mantissa0(
unsigned int);
134 unsigned int mantissa1()
const;
135 void mantissa1(
unsigned int);
137 bool is_zero()
const;
138 bool is_subnormal()
const;
139 bool is_normal()
const;
186 inline scfx_ieee_double::operator double()
const 194 return m_id.
s.negative;
212 m_id.
s.exponent = (SCFX_IEEE_DOUBLE_BIAS +
a)
219 return m_id.
s.mantissa0;
231 return m_id.
s.mantissa1;
243 return (
exponent() == SCFX_IEEE_DOUBLE_E_MIN - 1 &&
250 return (
exponent() == SCFX_IEEE_DOUBLE_E_MIN - 1 &&
257 return (
exponent() >= SCFX_IEEE_DOUBLE_E_MIN &&
258 exponent() <= SCFX_IEEE_DOUBLE_E_MAX);
264 return (
exponent() == SCFX_IEEE_DOUBLE_E_MAX + 1 &&
271 return (
exponent() == SCFX_IEEE_DOUBLE_E_MAX + 1 &&
278 exponent(SCFX_IEEE_DOUBLE_E_MAX + 1);
286 exponent(SCFX_IEEE_DOUBLE_E_MAX + 1);
291 #define MSB_STATEMENT(x,n) if ( x >> n ) { x >>= n; i += n; } 306 }
else if (m1 != 0) {
321 #define LSB_STATEMENT(x,n) if ( x << n ) { x <<= n; i -= n; } 336 }
else if (m0 != 0) {
379 #if defined(SC_BOOST_BIG_ENDIAN) 382 unsigned mantissa:23;
383 #elif defined(SC_BOOST_LITTLE_ENDIAN) 384 unsigned mantissa:23;
419 operator float()
const;
425 unsigned int mantissa()
const;
426 void mantissa(
unsigned int);
472 inline scfx_ieee_float::operator float()
const 480 return m_if.
s.negative;
498 m_if.
s.exponent = (SCFX_IEEE_FLOAT_BIAS +
a) &
505 return m_if.
s.mantissa;
530 return (
exponent() >= SCFX_IEEE_FLOAT_E_MIN &&
531 exponent() <= SCFX_IEEE_FLOAT_E_MAX);
549 exponent(SCFX_IEEE_FLOAT_E_MAX + 1);
556 exponent(SCFX_IEEE_FLOAT_E_MAX + 1);
571 if (exp < SCFX_IEEE_DOUBLE_E_MIN) {
575 if ((exp += 20) >= 0) {
577 }
else if ((exp += 32) >= 0) {
580 }
else if (exp > SCFX_IEEE_DOUBLE_E_MAX) {
600 #if defined(__clang__) 602 double tmp =
static_cast<double>(
static_cast<int64>(
a));
605 return static_cast<double>(
a);
613 #endif // __SYSTEMC_EXT_DT_FX_SCFX_IEEE_HH__ #define LSB_STATEMENT(x, n)
double scfx_pow2(int exp)
static const scfx_ieee_double inf(int)
static const scfx_ieee_double nan()
scfx_ieee_double & operator=(double)
unsigned int mantissa0() const
double uint64_to_double(uint64 a)
const int SCFX_IEEE_DOUBLE_E_MAX
const unsigned int SCFX_IEEE_FLOAT_E_SIZE
const unsigned int SCFX_IEEE_DOUBLE_BIAS
scfx_ieee_float & operator=(float)
struct sc_dt::ieee_double::@117 s
const int SCFX_IEEE_FLOAT_E_MAX
const unsigned int SCFX_IEEE_FLOAT_M_SIZE
bool is_subnormal() const
bool is_subnormal() const
struct sc_dt::ieee_float::@118 s
const unsigned int SCFX_IEEE_DOUBLE_M_SIZE
unsigned int negative() const
const unsigned int SCFX_IEEE_DOUBLE_M0_SIZE
const unsigned int SCFX_IEEE_FLOAT_BIAS
unsigned int mantissa() const
const unsigned int SCFX_IEEE_DOUBLE_M1_SIZE
const int SCFX_IEEE_DOUBLE_E_MIN
unsigned int negative() const
#define MSB_STATEMENT(x, n)
const int SCFX_IEEE_FLOAT_E_MIN
const unsigned int SCFX_IEEE_DOUBLE_E_SIZE
unsigned int mantissa1() const