34 #include <itpp/itexports.h> 890 uint64_t(1), uint64_t(1) << 1, uint64_t(1) << 2, uint64_t(1) << 3, uint64_t(1) << 4,
891 uint64_t(1) << 5, uint64_t(1) << 6, uint64_t(1) << 7, uint64_t(1) << 8, uint64_t(1) << 9,
892 uint64_t(1) << 10, uint64_t(1) << 11, uint64_t(1) << 12, uint64_t(1) << 13, uint64_t(1) << 14,
893 uint64_t(1) << 15, uint64_t(1) << 16, uint64_t(1) << 17, uint64_t(1) << 18, uint64_t(1) << 19,
894 uint64_t(1) << 20, uint64_t(1) << 21, uint64_t(1) << 22, uint64_t(1) << 23, uint64_t(1) << 24,
895 uint64_t(1) << 25, uint64_t(1) << 26, uint64_t(1) << 27, uint64_t(1) << 28, uint64_t(1) << 29,
896 uint64_t(1) << 30, uint64_t(1) << 31, uint64_t(1) << 32, uint64_t(1) << 33, uint64_t(1) << 34,
897 uint64_t(1) << 35, uint64_t(1) << 36, uint64_t(1) << 37, uint64_t(1) << 38, uint64_t(1) << 39,
898 uint64_t(1) << 40, uint64_t(1) << 41, uint64_t(1) << 42, uint64_t(1) << 43, uint64_t(1) << 44,
899 uint64_t(1) << 45, uint64_t(1) << 46, uint64_t(1) << 47, uint64_t(1) << 48, uint64_t(1) << 49,
900 uint64_t(1) << 50, uint64_t(1) << 51, uint64_t(1) << 52, uint64_t(1) << 53, uint64_t(1) << 54,
901 uint64_t(1) << 55, uint64_t(1) << 56, uint64_t(1) << 57, uint64_t(1) << 58, uint64_t(1) << 59,
902 uint64_t(1) << 60, uint64_t(1) << 61, uint64_t(1) << 62, uint64_t(1) << 63
907 0.5 / UINT64_POW2[63], 1.0 / UINT64_POW2[63], 1.0 / UINT64_POW2[62], 1.0 / UINT64_POW2[61],
908 1.0 / UINT64_POW2[60], 1.0 / UINT64_POW2[59], 1.0 / UINT64_POW2[58], 1.0 / UINT64_POW2[57],
909 1.0 / UINT64_POW2[56], 1.0 / UINT64_POW2[55], 1.0 / UINT64_POW2[54], 1.0 / UINT64_POW2[53],
910 1.0 / UINT64_POW2[52], 1.0 / UINT64_POW2[51], 1.0 / UINT64_POW2[50], 1.0 / UINT64_POW2[49],
911 1.0 / UINT64_POW2[48], 1.0 / UINT64_POW2[47], 1.0 / UINT64_POW2[46], 1.0 / UINT64_POW2[45],
912 1.0 / UINT64_POW2[44], 1.0 / UINT64_POW2[43], 1.0 / UINT64_POW2[42], 1.0 / UINT64_POW2[41],
913 1.0 / UINT64_POW2[40], 1.0 / UINT64_POW2[39], 1.0 / UINT64_POW2[38], 1.0 / UINT64_POW2[37],
914 1.0 / UINT64_POW2[36], 1.0 / UINT64_POW2[35], 1.0 / UINT64_POW2[34], 1.0 / UINT64_POW2[33],
915 1.0 / UINT64_POW2[32], 1.0 / UINT64_POW2[31], 1.0 / UINT64_POW2[30], 1.0 / UINT64_POW2[29],
916 1.0 / UINT64_POW2[28], 1.0 / UINT64_POW2[27], 1.0 / UINT64_POW2[26], 1.0 / UINT64_POW2[25],
917 1.0 / UINT64_POW2[24], 1.0 / UINT64_POW2[23], 1.0 / UINT64_POW2[22], 1.0 / UINT64_POW2[21],
918 1.0 / UINT64_POW2[20], 1.0 / UINT64_POW2[19], 1.0 / UINT64_POW2[18], 1.0 / UINT64_POW2[17],
919 1.0 / UINT64_POW2[16], 1.0 / UINT64_POW2[15], 1.0 / UINT64_POW2[14], 1.0 / UINT64_POW2[13],
920 1.0 / UINT64_POW2[12], 1.0 / UINT64_POW2[11], 1.0 / UINT64_POW2[10], 1.0 / UINT64_POW2[9],
921 1.0 / UINT64_POW2[8], 1.0 / UINT64_POW2[7], 1.0 / UINT64_POW2[6], 1.0 / UINT64_POW2[5],
922 1.0 / UINT64_POW2[4], 1.0 / UINT64_POW2[3], 1.0 / UINT64_POW2[2], 1.0 / UINT64_POW2[1],
923 1.0, 1.0*UINT64_POW2[1], 1.0*UINT64_POW2[2], 1.0*UINT64_POW2[3],
924 1.0*UINT64_POW2[4], 1.0*UINT64_POW2[5], 1.0*UINT64_POW2[6], 1.0*UINT64_POW2[7],
925 1.0*UINT64_POW2[8], 1.0*UINT64_POW2[9], 1.0*UINT64_POW2[10], 1.0*UINT64_POW2[11],
926 1.0*UINT64_POW2[12], 1.0*UINT64_POW2[13], 1.0*UINT64_POW2[14], 1.0*UINT64_POW2[15],
927 1.0*UINT64_POW2[16], 1.0*UINT64_POW2[17], 1.0*UINT64_POW2[18], 1.0*UINT64_POW2[19],
928 1.0*UINT64_POW2[20], 1.0*UINT64_POW2[21], 1.0*UINT64_POW2[22], 1.0*UINT64_POW2[23],
929 1.0*UINT64_POW2[24], 1.0*UINT64_POW2[25], 1.0*UINT64_POW2[26], 1.0*UINT64_POW2[27],
930 1.0*UINT64_POW2[28], 1.0*UINT64_POW2[29], 1.0*UINT64_POW2[30], 1.0*UINT64_POW2[31],
931 1.0*UINT64_POW2[32], 1.0*UINT64_POW2[33], 1.0*UINT64_POW2[34], 1.0*UINT64_POW2[35],
932 1.0*UINT64_POW2[36], 1.0*UINT64_POW2[37], 1.0*UINT64_POW2[38], 1.0*UINT64_POW2[39],
933 1.0*UINT64_POW2[40], 1.0*UINT64_POW2[41], 1.0*UINT64_POW2[42], 1.0*UINT64_POW2[43],
934 1.0*UINT64_POW2[44], 1.0*UINT64_POW2[45], 1.0*UINT64_POW2[46], 1.0*UINT64_POW2[47],
935 1.0*UINT64_POW2[48], 1.0*UINT64_POW2[49], 1.0*UINT64_POW2[50], 1.0*UINT64_POW2[51],
936 1.0*UINT64_POW2[52], 1.0*UINT64_POW2[53], 1.0*UINT64_POW2[54], 1.0*UINT64_POW2[55],
937 1.0*UINT64_POW2[56], 1.0*UINT64_POW2[57], 1.0*UINT64_POW2[58], 1.0*UINT64_POW2[59],
938 1.0*UINT64_POW2[60], 1.0*UINT64_POW2[61], 1.0*UINT64_POW2[62], 1.0*UINT64_POW2[63]
986 : shift(s), wordlen(w), emode(e), omode(o), qmode(q), stat_ptr(ptr) {init();}
989 : shift(x.shift), wordlen(MAX_WORDLEN), emode(
TC), omode(
WRAP), qmode(
TRN), stat_ptr(0) {init();}
998 static void set_output_mode(std::string o);
1017 virtual void print()
const;
1042 fixrep apply_o_mode(fixrep x)
const;
1046 fixrep scale_and_apply_modes(
double x,
q_mode q)
const;
1050 fixrep rshift_and_apply_q_mode(fixrep x,
int n,
q_mode q)
const;
1068 #endif // #ifndef FIX_BASE_H output_mode get_output_mode() const
Get output mode.
static void set_output_mode(output_mode o)
Set output mode to OUTPUT_FIX, OUTPUT_FIX_SHIFT, OUTPUT_FLOAT or OUTPUT_FLOAT_SHIFT. Static member function.
fixrep scale_and_apply_modes(double x) const
Convert from double to fixrep using shift and quantization mode qmode, then call limit() ...
Rounding to minus infinity.
q_mode get_q_mode() const
Get quantization mode.
Output floating-point value.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
const uint64_t UINT64_POW2[64]
Table for fast multiplication or division by 2^n.
void set_shift(int s)
Set shift (without shifting)
fixrep rshift_and_apply_q_mode(fixrep x, int n) const
Right shift n bits using quantization mode qmode and make call to statistics object (if any) ...
Stat * stat_ptr
Pointer to statistics object.
e_mode emode
Sign encoding mode.
e_mode get_e_mode() const
Get sign encoding mode.
virtual ~Fix_Base()
Destructor.
fixrep get_max() const
Get maximum value of data representation.
T min(const Vec< T > &in)
Minimum value of vector.
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
e_mode
Sign encoding modes (aligned with SystemC)
Output fixed-point representation only.
Fix_Base(const Fix_Base &x)
Copy constructor.
Rounding to plus infinity.
T max(const Vec< T > &v)
Maximum value of vector.
o_mode
Overflow modes (aligned with SystemC)
Convergent rounding with half-way value rounded to odd value (not defined in SystemC) ...
fixrep get_min() const
Get minimum value of data representation.
q_mode qmode
Quantization mode.
fixrep min
Minimum allowed value (help variable to speed up calculations)
int n_unused_bits
Number of unused (MSB) bits (help variable to speed up calculations)
o_mode omode
Overflow mode.
const int MAX_WORDLEN
Max word length.
Miscellaneous statistics functions and classes - header file.
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
Output floating-point value followed by <<shift.
Base class for fixed-point data types.
Fix_Base(int s=0, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Default constructor.
Symmetrical saturation (Not implemented)
o_mode get_o_mode() const
Get overflow mode.
int get_wordlen() const
Get word length.
Sign magnitued wrap-around (Not implemented)
int64_t fixrep
Representation for fixed-point data types.
Output fixed-point representation followed by <shift> (default)
A class for sampling a signal and calculating statistics.
Convergent rounding with half-way value rounded to even value.
Saturation to zero (Not implemented)
q_mode
Quantization modes (aligned with SystemC)
int get_shift() const
Get shift.
fixrep max
Maximum allowed value (help variable to speed up calculations)