34#include <itpp/itexports.h>
40template<
class Num_T>
class Vec;
41template<
class Num_T>
class Mat;
54 template<
int, e_mode, o_mode, q_mode>
friend class Fixed;
55 template<
int, e_mode, o_mode, q_mode>
friend class CFixed;
73 Fix& operator=(
const Fix &x);
75 Fix& operator=(
const int x);
77 Fix& operator+=(
const Fix &x);
79 Fix& operator+=(
const int x);
81 Fix& operator-=(
const Fix &x);
83 Fix& operator-=(
const int x);
85 Fix& operator*=(
const Fix &x);
87 Fix& operator*=(
const int x);
89 Fix& operator/=(
const Fix &x);
91 Fix& operator/=(
const int x);
95 Fix& operator<<=(
const int n);
97 Fix& operator>>=(
const int n);
100 void set(
double x,
int n);
102 void set(
double x,
int n,
q_mode q);
111 void rshift(
int n,
q_mode q);
114 virtual void print()
const;
118 double unfix()
const;
120#ifndef NO_IMPLICIT_FIX_CONVERSION
122 operator double()
const {
146ITPP_EXPORT std::istream &
operator>>(std::istream &is,
Fix &x);
148ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const Fix &x);
Complex fixed-point data type.
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.
fixrep apply_o_mode(fixrep x) const
Handle overflows using overflow mode omode and make call to statistics object (if any)
fixrep scale_and_apply_modes(double x) const
Convert from double to fixrep using shift and quantization mode qmode, then call limit()
e_mode emode
Sign encoding mode.
Stat * stat_ptr
Pointer to statistics object.
int shift
Accumulated bitshift (positive means left-shifted, negative means right-shifted)
q_mode qmode
Quantization mode.
o_mode omode
Overflow mode.
Class factory for fixed-point data types Fix and CFix.
Fix(double x=0.0, int s=0, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Default constructor.
fixrep re
Data representation.
Fix(const Fix_Factory &f)
Constructor.
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type)
Fix(fixrep r, int s, int, int)
Constructor for internal use. No restrictions are applied. The dummies help to avoid ambiguities.
Fix(const Fix &x, int w=MAX_WORDLEN, e_mode e=TC, o_mode o=WRAP, q_mode q=TRN, Stat *ptr=0)
Copy constructor.
void set_re(fixrep x)
Set data representation (mainly for internal use since it reveals the representation type)
virtual ~Fix()
Destructor.
void set(const std::string &str)
A class for sampling a signal and calculating statistics.
void set(const char *str)
Definitions of a base class for fixed-point data types.
Definitions of a class factory for fixed-point data types Fix and CFix.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
const int MAX_WORDLEN
Max word length.
o_mode
Overflow modes (aligned with SystemC)
const double DOUBLE_POW2[128]
Table for fast multiplication by 2^(n-64)
e_mode
Sign encoding modes (aligned with SystemC)
double unfix(const Fix &x)
Convert Fix to double by multiplying the bit representation with pow2(-shift)
int assert_shifts(const CFix &x, const CFix &y)
Check that x.shift==y.shift OR x==0 OR y==0 and return the shift (for the non-zero argument)
q_mode
Quantization modes (aligned with SystemC)
Mat< Fix > fixmat
Typedef for fixed-point matrix type.
int64_t fixrep
Representation for fixed-point data types.
Vec< Fix > fixvec
Typedef for fixed-point vector type.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Mat< Num_T > operator-(const Mat< Num_T > &m1, const Mat< Num_T > &m2)
Subtraction of two matrices.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.