5#ifndef GLOBALSIM_AP_FIXED_H
6#define GLOBALSIM_AP_FIXED_H
26 template<std::
size_t w
idth,
typename T>
29 static_assert(8*
sizeof(t) >=
width,
"ap_fixed underlying int to small");
30 for (std::size_t i = 0; i <=
sizeof(t)*8-
width; ++i){
39 template <std::size_t
width,
52 os << ap.m_value <<
' ' << double(ap);
58 ap_fixed(
const double d)
requires(std::is_same_v<S, Round>):
59 m_value(d * double (1<< dp) + (d >= 0 ? 0.5 : -0.5)){
63 ap_fixed(
const double d)
requires(std::is_same_v<S, XilDef>):
64 m_value(d * double (1<< dp) + (d >= 0 ? 0. : -1.0)){
69 operator double()
const{
70 return double(this->
m_value) / double(1 << dp);
75 ap_fixed k; k.m_value = v; k.test_overflow();
return k;
101 return form((WS(this->
m_value) * WS(f.m_value)) >> dp);
112 return form((WS(this->
m_value) << dp) / WS(f.m_value));
139 std::stringstream
ss;
142 ss <<
"ap_fixed overflow. val: "
143 <<
m_value <<
" abs(val): " << val
144 <<
' ' << std::hex << val
146 throw std::out_of_range(
ss.str());
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
constexpr T max_to_overflow()
friend std::ostream & operator<<(std::ostream &os, const ap_fixed< width, dp, S, T, WS > ap)
static ap_fixed form(T v)
static constexpr int16_t m_overflow_mask
ap_fixed operator-() const
ap_fixed operator/(const ap_fixed &f) const
const ap_fixed & operator+=(const ap_fixed &f)
const ap_fixed & operator*=(const ap_fixed &f)
const ap_fixed & operator-=(const ap_fixed &f)
const ap_fixed operator+(const ap_fixed &f) const
ap_fixed operator*(const ap_fixed &f) const
const ap_fixed & operator/=(const ap_fixed &f)