da4ml 0.2.1__py3-none-any.whl → 0.3.0.post1__py3-none-any.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.

Potentially problematic release.


This version of da4ml might be problematic. Click here for more details.

Files changed (55) hide show
  1. da4ml/_version.py +2 -2
  2. da4ml/cmvm/types.py +95 -15
  3. da4ml/codegen/__init__.py +5 -4
  4. da4ml/codegen/cpp/__init__.py +2 -1
  5. da4ml/codegen/cpp/cpp_codegen.py +56 -23
  6. da4ml/codegen/cpp/hls_model.py +252 -0
  7. da4ml/codegen/cpp/source/ap_types/ap_binary.h +78 -0
  8. da4ml/codegen/cpp/source/ap_types/ap_common.h +376 -0
  9. da4ml/codegen/cpp/source/ap_types/ap_decl.h +212 -0
  10. da4ml/codegen/cpp/source/ap_types/ap_fixed.h +360 -0
  11. da4ml/codegen/cpp/source/ap_types/ap_fixed_base.h +2354 -0
  12. da4ml/codegen/cpp/source/ap_types/ap_fixed_ref.h +718 -0
  13. da4ml/codegen/cpp/source/ap_types/ap_fixed_special.h +230 -0
  14. da4ml/codegen/cpp/source/ap_types/ap_int.h +330 -0
  15. da4ml/codegen/cpp/source/ap_types/ap_int_base.h +1885 -0
  16. da4ml/codegen/cpp/source/ap_types/ap_int_ref.h +1346 -0
  17. da4ml/codegen/cpp/source/ap_types/ap_int_special.h +223 -0
  18. da4ml/codegen/cpp/source/ap_types/ap_shift_reg.h +138 -0
  19. da4ml/codegen/cpp/source/ap_types/etc/ap_private.h +7199 -0
  20. da4ml/codegen/cpp/source/ap_types/hls_math.h +27 -0
  21. da4ml/codegen/cpp/source/ap_types/hls_stream.h +263 -0
  22. da4ml/codegen/cpp/source/ap_types/utils/x_hls_utils.h +80 -0
  23. da4ml/codegen/cpp/source/binder_util.hh +56 -0
  24. da4ml/codegen/cpp/source/build_binder.mk +24 -0
  25. da4ml/codegen/cpp/source/{vitis.h → vitis_bitshift.hh} +1 -1
  26. da4ml/codegen/verilog/__init__.py +2 -3
  27. da4ml/codegen/verilog/comb.py +65 -24
  28. da4ml/codegen/verilog/io_wrapper.py +36 -141
  29. da4ml/codegen/verilog/source/binder_util.hh +72 -0
  30. da4ml/codegen/verilog/source/mux.v +58 -0
  31. da4ml/codegen/verilog/source/negative.v +28 -0
  32. da4ml/codegen/verilog/source/shift_adder.v +4 -1
  33. da4ml/codegen/verilog/source/template.xdc +3 -0
  34. da4ml/codegen/verilog/verilog_model.py +36 -12
  35. da4ml/converter/__init__.py +0 -0
  36. da4ml/converter/hgq2/parser.py +105 -0
  37. da4ml/converter/hgq2/replica.py +383 -0
  38. da4ml/trace/__init__.py +2 -2
  39. da4ml/trace/fixed_variable.py +175 -16
  40. da4ml/trace/fixed_variable_array.py +109 -4
  41. da4ml/trace/ops/__init__.py +22 -6
  42. da4ml/trace/ops/conv_utils.py +147 -15
  43. da4ml/trace/ops/einsum_utils.py +9 -6
  44. da4ml/trace/ops/reduce_utils.py +103 -0
  45. da4ml/trace/pipeline.py +36 -34
  46. da4ml/trace/tracer.py +37 -7
  47. da4ml-0.3.0.post1.dist-info/METADATA +107 -0
  48. da4ml-0.3.0.post1.dist-info/RECORD +64 -0
  49. da4ml/codegen/cpp/source/vitis_bridge.h +0 -17
  50. da4ml-0.2.1.dist-info/METADATA +0 -65
  51. da4ml-0.2.1.dist-info/RECORD +0 -39
  52. /da4ml/codegen/verilog/source/{ioutils.hh → ioutil.hh} +0 -0
  53. {da4ml-0.2.1.dist-info → da4ml-0.3.0.post1.dist-info}/WHEEL +0 -0
  54. {da4ml-0.2.1.dist-info → da4ml-0.3.0.post1.dist-info}/licenses/LICENSE +0 -0
  55. {da4ml-0.2.1.dist-info → da4ml-0.3.0.post1.dist-info}/top_level.txt +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 -*-