Go to the documentation of this file.
42 if (o ==
"OUTPUT_FIX")
44 else if (o ==
"OUTPUT_FIX_SHIFT")
46 else if (o ==
"OUTPUT_FLOAT")
48 else if (o ==
"OUTPUT_FLOAT_SHIFT")
51 it_error(
"Fix_Base::set_output_mode: Illegal output mode!");
56 std::cout <<
"shift = " <<
shift << std::endl
57 <<
"wordlen = " <<
wordlen << std::endl
58 <<
"int(emode) = " << int(
emode) << std::endl
59 <<
"int(omode) = " << int(
omode) << std::endl
60 <<
"int(qmode) = " << int(
qmode) << std::endl
61 <<
"stat_ptr = " <<
stat_ptr << std::endl
62 <<
"min = " <<
min << std::endl
63 <<
"max = " <<
max << std::endl
81 it_error(
"Fix_Base::init: Illegal sign encoding mode!");
91 bool overflow =
false;
103 it_error(
"Fix_Base::apply_o_mode: Illegal overflow mode!");
107 else if (ret >
max) {
117 it_error(
"Fix_Base::apply_o_mode: Illegal overflow mode!");
154 if (scaled_value ==
std::floor(scaled_value) + 0.5)
160 if (scaled_value ==
std::floor(scaled_value) + 0.5)
161 if (scaled_value < 0)
175 it_error(
"Fix_Base::scale_and_apply_modes: Illegal quantization mode!");
184 it_assert_debug(n >= 0,
"Fix_Base::rshift_and_apply_q_mode: n cannot be negative!");
194 ret = ((x >> (n - 1)) + 1) >> 1;
200 if ((x & (
fixrep(1) << (n - 1))) && ((x < 0) || (x & ((
fixrep(1) << (n - 1)) - 1))))
209 if ((x & (
fixrep(1) << (n - 1))) && (x & ((
fixrep(1) << (n - 1)) - 1)))
218 if ((x & (
fixrep(1) << (n - 1))) && ((x >= 0) || (x & ((
fixrep(1) << (n - 1)) - 1))))
227 if ((x & (
fixrep(1) << (n - 1))) && ((x & (
fixrep(1) << n)) || (x & ((
fixrep(1) << (n - 1)) - 1))))
236 if ((x & (
fixrep(1) << (n - 1))) && (!(x & (
fixrep(1) << n)) || (x & ((
fixrep(1) << (n - 1)) - 1))))
249 if ((x < 0) && (x & ((
fixrep(1) << n) - 1)))
255 it_error(
"Fix_Base::rshift_and_apply_q_mode: Illegal quantization mode!");
fixrep scale_and_apply_modes(double x) const
Convert from double to fixrep using shift and quantization mode qmode, then call limit()
fixrep min
Minimum allowed value (help variable to speed up calculations)
fixrep apply_o_mode(fixrep x) const
Handle overflows using overflow mode omode and make call to statistics object (if any)
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
@ RND_ZERO
Rounding to zero.
@ OUTPUT_FIX
Output fixed-point representation only.
@ RND_INF
Rounding to infinity.
@ RND_MIN_INF
Rounding to minus infinity.
@ OUTPUT_FLOAT
Output floating-point value.
void init()
Calculate help variables min, max and n_unused_bits.
e_mode emode
Sign encoding mode.
virtual void print() const
Print restrictions.
@ TRN_ZERO
Truncation to zero.
Definitions of a base class for fixed-point data types.
virtual void sample(const double s, const bool overflow=false)
Register a sample and flag for overflow.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
@ OUTPUT_FLOAT_SHIFT
Output floating-point value followed by <<shift.
fixrep max
Maximum allowed value (help variable to speed up calculations)
const uint64_t UINT64_POW2[64]
Table for fast multiplication or division by 2^n.
int64_t fixrep
Representation for fixed-point data types.
static void set_output_mode(output_mode o)
Set output mode to OUTPUT_FIX, OUTPUT_FIX_SHIFT, OUTPUT_FLOAT or OUTPUT_FLOAT_SHIFT....
vec floor(const vec &x)
Round to nearest lower integer.
@ OUTPUT_FIX_SHIFT
Output fixed-point representation followed by <shift> (default)
@ RND
Rounding to plus infinity.
#define it_error(s)
Abort unconditionally.
@ RND_CONV_ODD
Convergent rounding with half-way value rounded to odd value (not defined in SystemC)
q_mode qmode
Quantization mode.
ITPP_EXPORT double round(double x)
Round to nearest integer, return result in double.
o_mode omode
Overflow mode.
@ RND_CONV
Convergent rounding with half-way value rounded to even value.
Stat * stat_ptr
Pointer to statistics object.
vec ceil(const vec &x)
Round to nearest upper integer.
q_mode
Quantization modes (aligned with SystemC)
int n_unused_bits
Number of unused (MSB) bits (help variable to speed up calculations)
const int MAX_WORDLEN
Max word length.
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)
Error handling functions - header file.
Generated on Mon Mar 23 2020 06:18:03 for IT++ by Doxygen 1.8.17