da4ml 0.5.1.post1__cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- da4ml/__init__.py +4 -0
- da4ml/_binary/__init__.py +15 -0
- da4ml/_binary/dais_bin.cpython-311-x86_64-linux-gnu.so +0 -0
- da4ml/_binary/dais_bin.pyi +5 -0
- da4ml/_cli/__init__.py +30 -0
- da4ml/_cli/convert.py +204 -0
- da4ml/_cli/report.py +295 -0
- da4ml/_version.py +32 -0
- da4ml/cmvm/__init__.py +4 -0
- da4ml/cmvm/api.py +264 -0
- da4ml/cmvm/core/__init__.py +221 -0
- da4ml/cmvm/core/indexers.py +83 -0
- da4ml/cmvm/core/state_opr.py +284 -0
- da4ml/cmvm/types.py +739 -0
- da4ml/cmvm/util/__init__.py +7 -0
- da4ml/cmvm/util/bit_decompose.py +86 -0
- da4ml/cmvm/util/mat_decompose.py +121 -0
- da4ml/codegen/__init__.py +9 -0
- da4ml/codegen/hls/__init__.py +4 -0
- da4ml/codegen/hls/hls_codegen.py +196 -0
- da4ml/codegen/hls/hls_model.py +255 -0
- da4ml/codegen/hls/source/ap_types/ap_binary.h +78 -0
- da4ml/codegen/hls/source/ap_types/ap_common.h +376 -0
- da4ml/codegen/hls/source/ap_types/ap_decl.h +212 -0
- da4ml/codegen/hls/source/ap_types/ap_fixed.h +360 -0
- da4ml/codegen/hls/source/ap_types/ap_fixed_base.h +2354 -0
- da4ml/codegen/hls/source/ap_types/ap_fixed_ref.h +718 -0
- da4ml/codegen/hls/source/ap_types/ap_fixed_special.h +230 -0
- da4ml/codegen/hls/source/ap_types/ap_int.h +330 -0
- da4ml/codegen/hls/source/ap_types/ap_int_base.h +1885 -0
- da4ml/codegen/hls/source/ap_types/ap_int_ref.h +1346 -0
- da4ml/codegen/hls/source/ap_types/ap_int_special.h +223 -0
- da4ml/codegen/hls/source/ap_types/ap_shift_reg.h +138 -0
- da4ml/codegen/hls/source/ap_types/etc/ap_private.h +7199 -0
- da4ml/codegen/hls/source/ap_types/hls_math.h +27 -0
- da4ml/codegen/hls/source/ap_types/hls_stream.h +263 -0
- da4ml/codegen/hls/source/ap_types/utils/x_hls_utils.h +80 -0
- da4ml/codegen/hls/source/binder_util.hh +71 -0
- da4ml/codegen/hls/source/build_binder.mk +22 -0
- da4ml/codegen/hls/source/vitis_bitshift.hh +32 -0
- da4ml/codegen/rtl/__init__.py +15 -0
- da4ml/codegen/rtl/common_source/binder_util.hh +99 -0
- da4ml/codegen/rtl/common_source/build_binder.mk +34 -0
- da4ml/codegen/rtl/common_source/build_quartus_prj.tcl +104 -0
- da4ml/codegen/rtl/common_source/build_vivado_prj.tcl +111 -0
- da4ml/codegen/rtl/common_source/ioutil.hh +124 -0
- da4ml/codegen/rtl/common_source/template.sdc +27 -0
- da4ml/codegen/rtl/common_source/template.xdc +30 -0
- da4ml/codegen/rtl/rtl_model.py +486 -0
- da4ml/codegen/rtl/verilog/__init__.py +10 -0
- da4ml/codegen/rtl/verilog/comb.py +239 -0
- da4ml/codegen/rtl/verilog/io_wrapper.py +113 -0
- da4ml/codegen/rtl/verilog/pipeline.py +67 -0
- da4ml/codegen/rtl/verilog/source/lookup_table.v +27 -0
- da4ml/codegen/rtl/verilog/source/multiplier.v +37 -0
- da4ml/codegen/rtl/verilog/source/mux.v +58 -0
- da4ml/codegen/rtl/verilog/source/negative.v +31 -0
- da4ml/codegen/rtl/verilog/source/shift_adder.v +59 -0
- da4ml/codegen/rtl/vhdl/__init__.py +9 -0
- da4ml/codegen/rtl/vhdl/comb.py +206 -0
- da4ml/codegen/rtl/vhdl/io_wrapper.py +120 -0
- da4ml/codegen/rtl/vhdl/pipeline.py +71 -0
- da4ml/codegen/rtl/vhdl/source/lookup_table.vhd +52 -0
- da4ml/codegen/rtl/vhdl/source/multiplier.vhd +40 -0
- da4ml/codegen/rtl/vhdl/source/mux.vhd +102 -0
- da4ml/codegen/rtl/vhdl/source/negative.vhd +35 -0
- da4ml/codegen/rtl/vhdl/source/shift_adder.vhd +101 -0
- da4ml/converter/__init__.py +63 -0
- da4ml/converter/hgq2/__init__.py +3 -0
- da4ml/converter/hgq2/layers/__init__.py +11 -0
- da4ml/converter/hgq2/layers/_base.py +132 -0
- da4ml/converter/hgq2/layers/activation.py +81 -0
- da4ml/converter/hgq2/layers/attn.py +148 -0
- da4ml/converter/hgq2/layers/batchnorm.py +15 -0
- da4ml/converter/hgq2/layers/conv.py +149 -0
- da4ml/converter/hgq2/layers/dense.py +39 -0
- da4ml/converter/hgq2/layers/ops.py +246 -0
- da4ml/converter/hgq2/layers/pool.py +107 -0
- da4ml/converter/hgq2/layers/table.py +176 -0
- da4ml/converter/hgq2/parser.py +161 -0
- da4ml/trace/__init__.py +6 -0
- da4ml/trace/fixed_variable.py +965 -0
- da4ml/trace/fixed_variable_array.py +600 -0
- da4ml/trace/ops/__init__.py +13 -0
- da4ml/trace/ops/einsum_utils.py +305 -0
- da4ml/trace/ops/quantization.py +74 -0
- da4ml/trace/ops/reduce_utils.py +105 -0
- da4ml/trace/pipeline.py +181 -0
- da4ml/trace/tracer.py +186 -0
- da4ml/typing/__init__.py +3 -0
- da4ml-0.5.1.post1.dist-info/METADATA +85 -0
- da4ml-0.5.1.post1.dist-info/RECORD +96 -0
- da4ml-0.5.1.post1.dist-info/WHEEL +6 -0
- da4ml-0.5.1.post1.dist-info/entry_points.txt +3 -0
- da4ml-0.5.1.post1.dist-info/sboms/auditwheel.cdx.json +1 -0
- da4ml.libs/libgomp-e985bcbb.so.1.0.0 +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2011-2019 Xilinx, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#ifndef __AP_FIXED_SPECIAL_H__
|
|
18
|
+
#define __AP_FIXED_SPECIAL_H__
|
|
19
|
+
|
|
20
|
+
#ifndef __AP_FIXED_H__
|
|
21
|
+
#error "Only ap_fixed.h and ap_int.h can be included directly in user code."
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#ifndef __SYNTHESIS__
|
|
25
|
+
#include <cstdio>
|
|
26
|
+
#include <cstdlib>
|
|
27
|
+
#endif
|
|
28
|
+
// FIXME AP_AUTOCC cannot handle many standard headers, so declare instead of
|
|
29
|
+
// include.
|
|
30
|
+
// #include <complex>
|
|
31
|
+
namespace std {
|
|
32
|
+
template<typename _Tp> class complex;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
TODO: Modernize the code using C++11/C++14
|
|
37
|
+
1. constexpr http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0415r0.html
|
|
38
|
+
2. move constructor
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
namespace std {
|
|
42
|
+
/*
|
|
43
|
+
Specialize std::complex<ap_fixed> to zero initialization ap_fixed.
|
|
44
|
+
|
|
45
|
+
To reduce the area cost, ap_fixed is not zero initialized, just like basic
|
|
46
|
+
types float or double. However, libstdc++ provides specialization for float,
|
|
47
|
+
double and long double, initializing image part to 0 when not specified.
|
|
48
|
+
|
|
49
|
+
This has become a difficulty in switching legacy code from these C types to
|
|
50
|
+
ap_fixed. To ease the tranform of legacy code, we have to implement
|
|
51
|
+
specialization of std::complex<> for our type.
|
|
52
|
+
|
|
53
|
+
As ap_fixed is a template, it is impossible to specialize only the methods
|
|
54
|
+
that causes default initialization of value type in std::complex<>. An
|
|
55
|
+
explicit full specialization of the template class has to be done, covering
|
|
56
|
+
all the member functions and operators of std::complex<> as specified
|
|
57
|
+
in standard 26.2.4 and 26.2.5.
|
|
58
|
+
*/
|
|
59
|
+
template <int _AP_W, int _AP_I, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N>
|
|
60
|
+
class complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > {
|
|
61
|
+
public:
|
|
62
|
+
typedef ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> _Tp;
|
|
63
|
+
typedef _Tp value_type;
|
|
64
|
+
|
|
65
|
+
// 26.2.4/1
|
|
66
|
+
// Constructor without argument
|
|
67
|
+
// Default initialize, so that in dataflow, the variable is only written once.
|
|
68
|
+
complex() : _M_real(_Tp()), _M_imag(_Tp()) {}
|
|
69
|
+
// Constructor with ap_fixed.
|
|
70
|
+
// Zero initialize image part when not specified, so that `C(1) == C(1,0)`
|
|
71
|
+
complex(const _Tp &__r, const _Tp &__i = _Tp(0))
|
|
72
|
+
: _M_real(__r), _M_imag(__i) {}
|
|
73
|
+
|
|
74
|
+
// Constructor with another complex number
|
|
75
|
+
template <typename _Up>
|
|
76
|
+
complex(const complex<_Up> &__z) : _M_real(__z.real()), _M_imag(__z.imag()) {}
|
|
77
|
+
|
|
78
|
+
#if __cplusplus >= 201103L
|
|
79
|
+
const _Tp& real() const { return _M_real; }
|
|
80
|
+
const _Tp& imag() const { return _M_imag; }
|
|
81
|
+
#else
|
|
82
|
+
_Tp& real() { return _M_real; }
|
|
83
|
+
const _Tp& real() const { return _M_real; }
|
|
84
|
+
_Tp& imag() { return _M_imag; }
|
|
85
|
+
const _Tp& imag() const { return _M_imag; }
|
|
86
|
+
#endif
|
|
87
|
+
|
|
88
|
+
void real(_Tp __val) { _M_real = __val; }
|
|
89
|
+
|
|
90
|
+
void imag(_Tp __val) { _M_imag = __val; }
|
|
91
|
+
|
|
92
|
+
// Assign this complex number with ap_fixed.
|
|
93
|
+
// Zero initialize image poarrt, so that `C c; c = 1; c == C(1,0);`
|
|
94
|
+
complex<_Tp> &operator=(const _Tp __t) {
|
|
95
|
+
_M_real = __t;
|
|
96
|
+
_M_imag = _Tp(0);
|
|
97
|
+
return *this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 26.2.5/1
|
|
101
|
+
// Add ap_fixed to this complex number.
|
|
102
|
+
complex<_Tp> &operator+=(const _Tp &__t) {
|
|
103
|
+
_M_real += __t;
|
|
104
|
+
return *this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 26.2.5/3
|
|
108
|
+
// Subtract ap_fixed from this complex number.
|
|
109
|
+
complex<_Tp> &operator-=(const _Tp &__t) {
|
|
110
|
+
_M_real -= __t;
|
|
111
|
+
return *this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 26.2.5/5
|
|
115
|
+
// Multiply this complex number by ap_fixed.
|
|
116
|
+
complex<_Tp> &operator*=(const _Tp &__t) {
|
|
117
|
+
_M_real *= __t;
|
|
118
|
+
_M_imag *= __t;
|
|
119
|
+
return *this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 26.2.5/7
|
|
123
|
+
// Divide this complex number by ap_fixed.
|
|
124
|
+
complex<_Tp> &operator/=(const _Tp &__t) {
|
|
125
|
+
_M_real /= __t;
|
|
126
|
+
_M_imag /= __t;
|
|
127
|
+
return *this;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Assign complex number to this complex number.
|
|
131
|
+
template <typename _Up>
|
|
132
|
+
complex<_Tp> &operator=(const complex<_Up> &__z) {
|
|
133
|
+
_M_real = __z.real();
|
|
134
|
+
_M_imag = __z.imag();
|
|
135
|
+
return *this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 26.2.5/9
|
|
139
|
+
// Add complex number to this.
|
|
140
|
+
template <typename _Up>
|
|
141
|
+
complex<_Tp> &operator+=(const complex<_Up> &__z) {
|
|
142
|
+
_M_real += __z.real();
|
|
143
|
+
_M_imag += __z.imag();
|
|
144
|
+
return *this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 26.2.5/11
|
|
148
|
+
// Subtract complex number from this.
|
|
149
|
+
template <typename _Up>
|
|
150
|
+
complex<_Tp> &operator-=(const complex<_Up> &__z) {
|
|
151
|
+
_M_real -= __z.real();
|
|
152
|
+
_M_imag -= __z.imag();
|
|
153
|
+
return *this;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 26.2.5/13
|
|
157
|
+
// Multiply this by complex number.
|
|
158
|
+
template <typename _Up>
|
|
159
|
+
complex<_Tp> &operator*=(const complex<_Up> &__z) {
|
|
160
|
+
const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
|
|
161
|
+
_M_imag = _M_real * __z.imag() + _M_imag * __z.real();
|
|
162
|
+
_M_real = __r;
|
|
163
|
+
return *this;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 26.2.5/15
|
|
167
|
+
// Divide this by complex number.
|
|
168
|
+
template <typename _Up>
|
|
169
|
+
complex<_Tp> &operator/=(const complex<_Up> &__z) {
|
|
170
|
+
complex<_Tp> cj (__z.real(), -__z.imag());
|
|
171
|
+
complex<_Tp> a = (*this) * cj;
|
|
172
|
+
complex<_Tp> b = cj * __z;
|
|
173
|
+
_M_real = a.real() / b.real();
|
|
174
|
+
_M_imag = a.imag() / b.real();
|
|
175
|
+
return *this;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private:
|
|
179
|
+
_Tp _M_real;
|
|
180
|
+
_Tp _M_imag;
|
|
181
|
+
|
|
182
|
+
}; // class complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> >
|
|
183
|
+
|
|
184
|
+
/*
|
|
185
|
+
Non-member operations
|
|
186
|
+
These operations are not required by standard in 26.2.6, but libstdc++
|
|
187
|
+
defines them for
|
|
188
|
+
float, double or long double's specialization.
|
|
189
|
+
*/
|
|
190
|
+
// Compare complex number with ap_fixed.
|
|
191
|
+
template <int _AP_W, int _AP_I, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N>
|
|
192
|
+
inline bool operator==(
|
|
193
|
+
const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__x,
|
|
194
|
+
const ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> &__y) {
|
|
195
|
+
return __x.real() == __y &&
|
|
196
|
+
__x.imag() == 0;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Compare ap_fixed with complex number.
|
|
200
|
+
template <int _AP_W, int _AP_I, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N>
|
|
201
|
+
inline bool operator==(
|
|
202
|
+
const ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> &__x,
|
|
203
|
+
const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__y) {
|
|
204
|
+
return __x == __y.real() &&
|
|
205
|
+
0 == __y.imag();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Compare complex number with ap_fixed.
|
|
209
|
+
template <int _AP_W, int _AP_I, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N>
|
|
210
|
+
inline bool operator!=(
|
|
211
|
+
const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__x,
|
|
212
|
+
const ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> &__y) {
|
|
213
|
+
return __x.real() != __y ||
|
|
214
|
+
__x.imag() != 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Compare ap_fixed with complex number.
|
|
218
|
+
template <int _AP_W, int _AP_I, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N>
|
|
219
|
+
inline bool operator!=(
|
|
220
|
+
const ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> &__x,
|
|
221
|
+
const complex<ap_fixed<_AP_W, _AP_I, _AP_Q, _AP_O, _AP_N> > &__y) {
|
|
222
|
+
return __x != __y.real() ||
|
|
223
|
+
0 != __y.imag();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
} // namespace std
|
|
227
|
+
|
|
228
|
+
#endif // ifndef __AP_FIXED_SPECIAL_H__
|
|
229
|
+
|
|
230
|
+
// -*- cpp -*-
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2011-2019 Xilinx, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#ifndef __AP_INT_H__
|
|
18
|
+
#define __AP_INT_H__
|
|
19
|
+
|
|
20
|
+
#include <ap_common.h>
|
|
21
|
+
#include <ap_int_base.h>
|
|
22
|
+
#include <ap_int_ref.h>
|
|
23
|
+
|
|
24
|
+
//---------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
/// Sign Arbitrary Precision Type.
|
|
27
|
+
template <int _AP_W>
|
|
28
|
+
struct ap_int : ap_int_base<_AP_W, true> {
|
|
29
|
+
typedef ap_int_base<_AP_W, true> Base;
|
|
30
|
+
// Constructor
|
|
31
|
+
INLINE ap_int() : Base() {}
|
|
32
|
+
|
|
33
|
+
// Copy ctor
|
|
34
|
+
INLINE ap_int(const ap_int& op) { Base::V = op.V; }
|
|
35
|
+
|
|
36
|
+
template <int _AP_W2>
|
|
37
|
+
INLINE ap_int(const ap_int<_AP_W2>& op) {
|
|
38
|
+
Base::V = op.V;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
template <int _AP_W2>
|
|
42
|
+
INLINE ap_int(const volatile ap_int<_AP_W2>& op) {
|
|
43
|
+
Base::V = op.V;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
template <int _AP_W2>
|
|
47
|
+
INLINE ap_int(const ap_uint<_AP_W2>& op) {
|
|
48
|
+
Base::V = op.V;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
template <int _AP_W2>
|
|
52
|
+
INLINE ap_int(const volatile ap_uint<_AP_W2>& op) {
|
|
53
|
+
Base::V = op.V;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
template <int _AP_W2, bool _AP_S2>
|
|
57
|
+
INLINE ap_int(const ap_range_ref<_AP_W2, _AP_S2>& ref) : Base(ref) {}
|
|
58
|
+
|
|
59
|
+
template <int _AP_W2, bool _AP_S2>
|
|
60
|
+
INLINE ap_int(const ap_bit_ref<_AP_W2, _AP_S2>& ref) : Base(ref) {}
|
|
61
|
+
|
|
62
|
+
template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3>
|
|
63
|
+
INLINE ap_int(const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& ref)
|
|
64
|
+
: Base(ref) {}
|
|
65
|
+
|
|
66
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
67
|
+
int _AP_N2>
|
|
68
|
+
INLINE ap_int(const ap_fixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
69
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, true, _AP_Q2, _AP_O2, _AP_N2>)op) {}
|
|
70
|
+
|
|
71
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
72
|
+
int _AP_N2>
|
|
73
|
+
INLINE ap_int(const ap_ufixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
74
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, false, _AP_Q2, _AP_O2, _AP_N2>)op) {
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
78
|
+
int _AP_N2>
|
|
79
|
+
INLINE ap_int(
|
|
80
|
+
const volatile ap_fixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
81
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, true, _AP_Q2, _AP_O2, _AP_N2>)op) {}
|
|
82
|
+
|
|
83
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
84
|
+
int _AP_N2>
|
|
85
|
+
INLINE ap_int(
|
|
86
|
+
const volatile ap_ufixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
87
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, false, _AP_Q2, _AP_O2, _AP_N2>)op) {
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
template <int _AP_W2, bool _AP_S2>
|
|
91
|
+
INLINE ap_int(const ap_int_base<_AP_W2, _AP_S2>& op) {
|
|
92
|
+
Base::V = op.V;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
|
|
96
|
+
ap_o_mode _AP_O2, int _AP_N2>
|
|
97
|
+
INLINE ap_int(
|
|
98
|
+
const af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
99
|
+
: Base(op) {}
|
|
100
|
+
|
|
101
|
+
template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
|
|
102
|
+
ap_o_mode _AP_O2, int _AP_N2>
|
|
103
|
+
INLINE ap_int(
|
|
104
|
+
const af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
105
|
+
: Base(op) {}
|
|
106
|
+
|
|
107
|
+
template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
|
|
108
|
+
ap_o_mode _AP_O2, int _AP_N2>
|
|
109
|
+
INLINE ap_int(
|
|
110
|
+
const ap_fixed_base<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
111
|
+
: Base(op) {}
|
|
112
|
+
|
|
113
|
+
#define CTOR(TYPE) \
|
|
114
|
+
INLINE ap_int(TYPE val) { Base::V = val; }
|
|
115
|
+
CTOR(bool)
|
|
116
|
+
CTOR(char)
|
|
117
|
+
CTOR(signed char)
|
|
118
|
+
CTOR(unsigned char)
|
|
119
|
+
CTOR(short)
|
|
120
|
+
CTOR(unsigned short)
|
|
121
|
+
CTOR(int)
|
|
122
|
+
CTOR(unsigned int)
|
|
123
|
+
CTOR(long)
|
|
124
|
+
CTOR(unsigned long)
|
|
125
|
+
CTOR(ap_slong)
|
|
126
|
+
CTOR(ap_ulong)
|
|
127
|
+
#undef CTOR
|
|
128
|
+
ap_int(double val) : Base(val) {}
|
|
129
|
+
ap_int(float val) : Base(val) {}
|
|
130
|
+
#if _AP_ENABLE_HALF_ == 1
|
|
131
|
+
ap_int(half val) : Base(val) {}
|
|
132
|
+
#endif
|
|
133
|
+
|
|
134
|
+
// ap_int_base will guess radix if radix is not provided.
|
|
135
|
+
INLINE ap_int(const char* s) : Base(s) {}
|
|
136
|
+
|
|
137
|
+
INLINE ap_int(const char* s, signed char rd) : Base(s, rd) {}
|
|
138
|
+
|
|
139
|
+
// Assignment
|
|
140
|
+
/* ctor will be used when right is not of proper type. */
|
|
141
|
+
|
|
142
|
+
INLINE ap_int& operator=(const ap_int<_AP_W>& op2) {
|
|
143
|
+
Base::V = op2.V;
|
|
144
|
+
return *this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* cannot bind volatile reference to non-volatile type. */
|
|
148
|
+
INLINE ap_int& operator=(const volatile ap_int<_AP_W>& op2) {
|
|
149
|
+
Base::V = op2.V;
|
|
150
|
+
return *this;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* cannot return volatile *this. */
|
|
154
|
+
INLINE void operator=(const ap_int<_AP_W>& op2) volatile { Base::V = op2.V; }
|
|
155
|
+
|
|
156
|
+
INLINE void operator=(const volatile ap_int<_AP_W>& op2) volatile {
|
|
157
|
+
Base::V = op2.V;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}; // struct ap_int.
|
|
161
|
+
|
|
162
|
+
//---------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
/// Unsigned Arbitrary Precision Type.
|
|
165
|
+
template <int _AP_W>
|
|
166
|
+
struct ap_uint : ap_int_base<_AP_W, false> {
|
|
167
|
+
typedef ap_int_base<_AP_W, false> Base;
|
|
168
|
+
// Constructor
|
|
169
|
+
INLINE ap_uint() : Base() {}
|
|
170
|
+
|
|
171
|
+
// Copy ctor
|
|
172
|
+
INLINE ap_uint(const ap_uint& op) { Base::V = op.V; }
|
|
173
|
+
|
|
174
|
+
template <int _AP_W2>
|
|
175
|
+
INLINE ap_uint(const ap_uint<_AP_W2>& op) {
|
|
176
|
+
Base::V = op.V;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
template <int _AP_W2>
|
|
180
|
+
INLINE ap_uint(const ap_int<_AP_W2>& op) {
|
|
181
|
+
Base::V = op.V;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
template <int _AP_W2>
|
|
185
|
+
INLINE ap_uint(const volatile ap_uint<_AP_W2>& op) {
|
|
186
|
+
Base::V = op.V;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
template <int _AP_W2>
|
|
190
|
+
INLINE ap_uint(const volatile ap_int<_AP_W2>& op) {
|
|
191
|
+
Base::V = op.V;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
template <int _AP_W2, bool _AP_S2>
|
|
195
|
+
INLINE ap_uint(const ap_range_ref<_AP_W2, _AP_S2>& ref) : Base(ref) {}
|
|
196
|
+
|
|
197
|
+
template <int _AP_W2, bool _AP_S2>
|
|
198
|
+
INLINE ap_uint(const ap_bit_ref<_AP_W2, _AP_S2>& ref) : Base(ref) {}
|
|
199
|
+
|
|
200
|
+
template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3>
|
|
201
|
+
INLINE ap_uint(const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& ref)
|
|
202
|
+
: Base(ref) {}
|
|
203
|
+
|
|
204
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
205
|
+
int _AP_N2>
|
|
206
|
+
INLINE ap_uint(const ap_fixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
207
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, true, _AP_Q2, _AP_O2, _AP_N2>)op) {}
|
|
208
|
+
|
|
209
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
210
|
+
int _AP_N2>
|
|
211
|
+
INLINE ap_uint(const ap_ufixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
212
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, false, _AP_Q2, _AP_O2, _AP_N2>)op) {
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
216
|
+
int _AP_N2>
|
|
217
|
+
INLINE ap_uint(
|
|
218
|
+
const volatile ap_fixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
219
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, true, _AP_Q2, _AP_O2, _AP_N2>)op) {}
|
|
220
|
+
|
|
221
|
+
template <int _AP_W2, int _AP_I2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2,
|
|
222
|
+
int _AP_N2>
|
|
223
|
+
INLINE ap_uint(
|
|
224
|
+
const volatile ap_ufixed<_AP_W2, _AP_I2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
225
|
+
: Base((ap_fixed_base<_AP_W2, _AP_I2, false, _AP_Q2, _AP_O2, _AP_N2>)op) {
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
template <int _AP_W2, bool _AP_S2>
|
|
229
|
+
INLINE ap_uint(const ap_int_base<_AP_W2, _AP_S2>& op) {
|
|
230
|
+
Base::V = op.V;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
|
|
234
|
+
ap_o_mode _AP_O2, int _AP_N2>
|
|
235
|
+
INLINE ap_uint(
|
|
236
|
+
const af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
237
|
+
: Base(op) {}
|
|
238
|
+
|
|
239
|
+
template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
|
|
240
|
+
ap_o_mode _AP_O2, int _AP_N2>
|
|
241
|
+
INLINE ap_uint(
|
|
242
|
+
const af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
243
|
+
: Base(op) {}
|
|
244
|
+
|
|
245
|
+
template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
|
|
246
|
+
ap_o_mode _AP_O2, int _AP_N2>
|
|
247
|
+
INLINE ap_uint(
|
|
248
|
+
const ap_fixed_base<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& op)
|
|
249
|
+
: Base(op) {}
|
|
250
|
+
|
|
251
|
+
#define CTOR(TYPE) \
|
|
252
|
+
INLINE ap_uint(TYPE val) { Base::V = val; }
|
|
253
|
+
CTOR(bool)
|
|
254
|
+
CTOR(char)
|
|
255
|
+
CTOR(signed char)
|
|
256
|
+
CTOR(unsigned char)
|
|
257
|
+
CTOR(short)
|
|
258
|
+
CTOR(unsigned short)
|
|
259
|
+
CTOR(int)
|
|
260
|
+
CTOR(unsigned int)
|
|
261
|
+
CTOR(long)
|
|
262
|
+
CTOR(unsigned long)
|
|
263
|
+
CTOR(ap_slong)
|
|
264
|
+
CTOR(ap_ulong)
|
|
265
|
+
#undef CTOR
|
|
266
|
+
ap_uint(double val) : Base(val) {}
|
|
267
|
+
ap_uint(float val) : Base(val) {}
|
|
268
|
+
#if _AP_ENABLE_HALF_ == 1
|
|
269
|
+
ap_uint(half val) : Base(val) {}
|
|
270
|
+
#endif
|
|
271
|
+
|
|
272
|
+
// ap_int_base will guess radix if radix is not provided.
|
|
273
|
+
INLINE ap_uint(const char* s) : Base(s) {}
|
|
274
|
+
|
|
275
|
+
INLINE ap_uint(const char* s, signed char rd) : Base(s, rd) {}
|
|
276
|
+
|
|
277
|
+
// Assignment
|
|
278
|
+
/* XXX ctor will be used when right is not of proper type. */
|
|
279
|
+
|
|
280
|
+
INLINE ap_uint& operator=(const ap_uint<_AP_W>& op2) {
|
|
281
|
+
Base::V = op2.V;
|
|
282
|
+
return *this;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/* cannot bind volatile reference to non-volatile type. */
|
|
286
|
+
INLINE ap_uint& operator=(const volatile ap_uint<_AP_W>& op2) {
|
|
287
|
+
Base::V = op2.V;
|
|
288
|
+
return *this;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/* cannot return volatile *this. */
|
|
292
|
+
INLINE void operator=(const ap_uint<_AP_W>& op2) volatile { Base::V = op2.V; }
|
|
293
|
+
|
|
294
|
+
INLINE void operator=(const volatile ap_uint<_AP_W>& op2) volatile {
|
|
295
|
+
Base::V = op2.V;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
}; // struct ap_uint.
|
|
299
|
+
|
|
300
|
+
#define ap_bigint ap_int
|
|
301
|
+
#define ap_biguint ap_uint
|
|
302
|
+
|
|
303
|
+
#if !defined(__SYNTHESIS__) && (defined(SYSTEMC_H) || defined(SYSTEMC_INCLUDED))
|
|
304
|
+
// XXX sc_trace overload for ap_fixed is already included in
|
|
305
|
+
// "ap_sysc/ap_sc_extras.h", so do not define in synthesis.
|
|
306
|
+
template <int _AP_W>
|
|
307
|
+
INLINE void sc_trace(sc_core::sc_trace_file* tf, const ap_int<_AP_W>& op,
|
|
308
|
+
const std::string& name) {
|
|
309
|
+
if (tf) tf->trace(sc_dt::sc_lv<_AP_W>(op.to_string(2).c_str()), name);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
template <int _AP_W>
|
|
313
|
+
INLINE void sc_trace(sc_core::sc_trace_file* tf, const ap_uint<_AP_W>& op,
|
|
314
|
+
const std::string& name) {
|
|
315
|
+
if (tf) tf->trace(sc_dt::sc_lv<_AP_W>(op.to_string(2).c_str()), name);
|
|
316
|
+
}
|
|
317
|
+
#endif // System C sim
|
|
318
|
+
|
|
319
|
+
#include <ap_int_special.h>
|
|
320
|
+
|
|
321
|
+
#endif // ifndef __AP_INT_H__ else
|
|
322
|
+
|
|
323
|
+
// FIXME user should include ap_fixed.h when using ap_fixed.
|
|
324
|
+
// to avoid circular inclusion, must check whether this is required by
|
|
325
|
+
// ap_fixed.h
|
|
326
|
+
#ifndef __AP_FIXED_H__
|
|
327
|
+
#include <ap_fixed.h>
|
|
328
|
+
#endif
|
|
329
|
+
|
|
330
|
+
// -*- cpp -*-
|