LDMX Software
ap_fixed_ref.h
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_REF_H__
18#define __AP_FIXED_REF_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 __cplusplus
25#error "C++ is required to include this header file"
26
27#else
28#ifndef __SYNTHESIS__
29#include <iostream>
30#endif
33template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O,
34 int _AP_N>
35struct af_bit_ref {
36#ifdef _MSC_VER
37#pragma warning(disable : 4521 4522)
38#endif
40 ref_type& d_bv;
41 int d_index;
42
43 public:
44 INLINE af_bit_ref(
46 : d_bv(ref.d_bv), d_index(ref.d_index) {
47#ifndef __SYNTHESIS__
48 _AP_WARNING(d_index < 0, "Index of bit vector (%d) cannot be negative.",
49 d_index);
50 _AP_WARNING(d_index >= _AP_W, "Index of bit vector (%d) out of range (%d).",
51 d_index, _AP_W);
52#endif
53 }
54
55 INLINE af_bit_ref(ref_type* bv, int index = 0) : d_bv(*bv), d_index(index) {}
56
57 INLINE af_bit_ref(const ref_type* bv, int index = 0)
58 : d_bv(*const_cast<ref_type*>(bv)), d_index(index) {}
59
61 INLINE operator bool() const { return _AP_ROOT_op_get_bit(d_bv.V, d_index); }
62
64 // @{
65 INLINE af_bit_ref& operator=(bool val) {
66 d_bv.V = _AP_ROOT_op_set_bit(d_bv.V, d_index, val);
67 return *this;
68 }
69
70 // Be explicit to prevent it from being deleted, as field d_bv
71 // is of reference type.
72 INLINE af_bit_ref& operator=(const af_bit_ref& val) {
73 return operator=(bool(val));
74 }
75
76 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
77 ap_o_mode _AP_O2, int _AP_N2>
78 INLINE af_bit_ref& operator=(
80 return operator=(bool(val));
81 }
82
83 template <int _AP_W2, bool _AP_S2>
84 INLINE af_bit_ref& operator=(const ap_bit_ref<_AP_W2, _AP_S2>& val) {
85 return operator=(bool(val));
86 }
87
88 template <int _AP_W2, bool _AP_S2>
89 INLINE af_bit_ref& operator=(const ap_int_base<_AP_W2, _AP_S2>& val) {
90 return operator=(val != 0);
91 }
92
93 template <int _AP_W2, bool _AP_S2>
94 INLINE af_bit_ref& operator=(const ap_range_ref<_AP_W2, _AP_S2>& val) {
95 return operator=(ap_int_base<_AP_W2, false>(val));
96 }
97
98 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
99 ap_o_mode _AP_O2, int _AP_N2>
100 INLINE af_bit_ref& operator=(
102 return operator=(ap_int_base<_AP_W2, false>(val));
103 }
104
105 template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3>
106 INLINE af_bit_ref& operator=(
108 return operator=(ap_int_base<_AP_W2 + _AP_W3, false>(val));
109 }
110 // @}
111
113 // @{
114 template <int _AP_W2, int _AP_S2>
116 operator,(ap_int_base<_AP_W2, _AP_S2>&op) {
118 *this, op);
119 }
120
121 template <int _AP_W2, int _AP_S2>
125 op);
126 }
127
128 template <int _AP_W2, int _AP_S2>
130 operator,(const ap_range_ref<_AP_W2, _AP_S2>&op) {
132 *this, op);
133 }
134
135 template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3>
136 INLINE ap_concat_ref<1, af_bit_ref, _AP_W2 + _AP_W3,
139 return ap_concat_ref<1, af_bit_ref, _AP_W2 + _AP_W3,
141 op);
142 }
143
144 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
145 ap_o_mode _AP_O2, int _AP_N2>
146 INLINE ap_concat_ref<
147 1, af_bit_ref, _AP_W2,
149 operator,(
151 return ap_concat_ref<
152 1, af_bit_ref, _AP_W2,
154 op);
155 }
156
157 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
158 ap_o_mode _AP_O2, int _AP_N2>
159 INLINE
162 operator,(
164 return ap_concat_ref<
165 1, af_bit_ref, 1,
167 *this,
169 op));
170 }
171 // @}
172
174 // @{
175 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
176 ap_o_mode _AP_O2, int _AP_N2>
177 INLINE bool operator==(
179 return get() == op.get();
180 }
181
182 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
183 ap_o_mode _AP_O2, int _AP_N2>
184 INLINE bool operator!=(
186 return get() != op.get();
187 }
188 // @}
189
190 INLINE bool operator~() const {
191 bool bit = _AP_ROOT_op_get_bit(d_bv.V, d_index);
192 return bit ? false : true;
193 }
194
195 INLINE bool get() const { return _AP_ROOT_op_get_bit(d_bv.V, d_index); }
196
197 INLINE int length() const { return 1; }
198
199#ifndef __SYNTHESIS__
200 std::string to_string() const { return get() ? "1" : "0"; }
201#else
202 // XXX HLS will delete this in synthesis
203 INLINE char* to_string() const { return 0; }
204#endif
205}; // struct af_bit_ref
206
207// XXX apcc cannot handle global std::ios_base::Init() brought in by <iostream>
208#ifndef AP_AUTOCC
209#ifndef __SYNTHESIS__
210template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O,
211 int _AP_N>
212INLINE std::ostream& operator<<(
213 std::ostream& os,
215 os << x.to_string();
216 return os;
217}
218#endif // ifndef __SYNTHESIS__
219#endif // ifndef AP_AUTOCC
220
222template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O,
223 int _AP_N>
224struct af_range_ref {
225#ifdef _MSC_VER
226#pragma warning(disable : 4521 4522)
227#endif
229 ref_type& d_bv;
230 int l_index;
231 int h_index;
232
233 public:
235 INLINE af_range_ref(
237 : d_bv(ref.d_bv), l_index(ref.l_index), h_index(ref.h_index) {}
238
240
242 INLINE af_range_ref(ref_type* bv, int h, int l)
243 : d_bv(*bv), l_index(l), h_index(h) {
244#ifndef __SYNTHESIS__
245 _AP_WARNING(h < 0 || l < 0,
246 "Higher bound(%d) and lower(%d) bound cannot be negative.", h,
247 l);
248 _AP_WARNING(h >= _AP_W || l >= _AP_W,
249 "Higher bound(%d) or lower(%d) bound out of range.", h, l);
250 _AP_WARNING(h < l, "The bits selected will be returned in reverse order.");
251#endif
252 }
253
254 INLINE af_range_ref(const ref_type* bv, int h, int l)
255 : d_bv(*const_cast<ref_type*>(bv)), l_index(l), h_index(h) {
256#ifndef __SYNTHESIS__
257 _AP_WARNING(h < 0 || l < 0,
258 "Higher bound(%d) and lower(%d) bound cannot be negative.", h,
259 l);
260 _AP_WARNING(h >= _AP_W || l >= _AP_W,
261 "Higher bound(%d) or lower(%d) bound out of range.", h, l);
262 _AP_WARNING(h < l, "The bits selected will be returned in reverse order.");
263#endif
264 }
265
267 // @{
268
269#define ASSIGN_CTYPE_TO_AF_RANGE(DATA_TYPE) \
270 INLINE af_range_ref& operator=(const DATA_TYPE val) { \
271 ap_int_base<_AP_W, false> loc(val); \
272 d_bv.V = _AP_ROOT_op_set_range(d_bv.V, l_index, h_index, loc.V); \
273 return *this; \
274 }
275
276 ASSIGN_CTYPE_TO_AF_RANGE(bool)
277 ASSIGN_CTYPE_TO_AF_RANGE(char)
278 ASSIGN_CTYPE_TO_AF_RANGE(signed char)
279 ASSIGN_CTYPE_TO_AF_RANGE(unsigned char)
280 ASSIGN_CTYPE_TO_AF_RANGE(short)
281 ASSIGN_CTYPE_TO_AF_RANGE(unsigned short)
282 ASSIGN_CTYPE_TO_AF_RANGE(int)
283 ASSIGN_CTYPE_TO_AF_RANGE(unsigned int)
284 ASSIGN_CTYPE_TO_AF_RANGE(long)
285 ASSIGN_CTYPE_TO_AF_RANGE(unsigned long)
286 ASSIGN_CTYPE_TO_AF_RANGE(ap_slong)
287 ASSIGN_CTYPE_TO_AF_RANGE(ap_ulong)
288#if _AP_ENABLE_HALF_ == 1
289 ASSIGN_CTYPE_TO_AF_RANGE(half)
290#endif
291 ASSIGN_CTYPE_TO_AF_RANGE(float)
292 ASSIGN_CTYPE_TO_AF_RANGE(double)
293#undef ASSIGN_CTYPE_TO_AF_RANGE
294
296 INLINE af_range_ref& operator=(const char* val) {
297 const ap_int_base<_AP_W, false> tmp(val); // XXX figure out radix
298 d_bv.V = _AP_ROOT_op_set_range(d_bv.V, l_index, h_index, tmp.V);
299 return *this;
300 }
301
303 // NOTE Base of other assgin operators.
304 template <int _AP_W3, bool _AP_S3>
305 INLINE af_range_ref& operator=(const ap_int_base<_AP_W3, _AP_S3>& val) {
306 d_bv.V = _AP_ROOT_op_set_range(d_bv.V, l_index, h_index, val.V);
307 return *this;
308 }
309
311 template <int _AP_W2, bool _AP_S2>
312 INLINE af_range_ref& operator=(const ap_range_ref<_AP_W2, _AP_S2>& val) {
313 const ap_int_base<_AP_W2, false> tmp(val);
314 return operator=(tmp);
315 }
316
318 template <int _AP_W2, bool _AP_S2>
319 INLINE af_range_ref& operator=(const ap_bit_ref<_AP_W2, _AP_S2>& val) {
320 const ap_int_base<1, false> tmp((bool)val);
321 return operator=(tmp);
322 }
323
325 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
326 ap_o_mode _AP_O2, int _AP_N2>
327 INLINE af_range_ref& operator=(
329 val) {
330 d_bv.V = _AP_ROOT_op_set_range(d_bv.V, l_index, h_index, val.V);
331 return *this;
332 }
333
335 // XXX This has to be explicit, otherwise it will be deleted, as d_bv is
336 // of reference type.
337 INLINE af_range_ref& operator=(const af_range_ref& val) {
339 return operator=(tmp);
340 }
341
343 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
344 ap_o_mode _AP_O2, int _AP_N2>
345 INLINE af_range_ref& operator=(
348 return operator=(tmp);
349 }
350
352 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
353 ap_o_mode _AP_O2, int _AP_N2>
354 INLINE af_range_ref& operator=(
356 ap_int_base<1, false> tmp((bool)val);
357 return operator=(tmp);
358 }
359
361 template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3>
362 INLINE af_range_ref& operator=(
365 return operator=(tmp);
366 }
367 // @}
368
370 // @{
371 template <int _AP_W2, bool _AP_S2>
372 INLINE bool operator==(const ap_range_ref<_AP_W2, _AP_S2>& op2) {
373 ap_int_base<_AP_W, false> lop(*this);
375 return lop == rop;
376 }
377
378 template <int _AP_W2, bool _AP_S2>
379 INLINE bool operator!=(const ap_range_ref<_AP_W2, _AP_S2>& op2) {
380 return !(operator==(op2));
381 }
382
383 template <int _AP_W2, bool _AP_S2>
384 INLINE bool operator<(const ap_range_ref<_AP_W2, _AP_S2>& op2) {
385 ap_int_base<_AP_W, false> lop(*this);
387 return lop < rop;
388 }
389
390 template <int _AP_W2, bool _AP_S2>
391 INLINE bool operator>(const ap_range_ref<_AP_W2, _AP_S2>& op2) {
392 ap_int_base<_AP_W, false> lop(*this);
394 return lop > rop;
395 }
396
397 template <int _AP_W2, bool _AP_S2>
398 INLINE bool operator<=(const ap_range_ref<_AP_W2, _AP_S2>& op2) {
399 return !(operator>(op2));
400 }
401
402 template <int _AP_W2, bool _AP_S2>
403 INLINE bool operator>=(const ap_range_ref<_AP_W2, _AP_S2>& op2) {
404 return !(operator<(op2));
405 }
406 // @}
407
409 // @{
410 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
411 ap_o_mode _AP_O2, int _AP_N2>
412 INLINE bool operator==(
414 ap_int_base<_AP_W, false> lop(*this);
416 return lop == rop;
417 }
418
419 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
420 ap_o_mode _AP_O2, int _AP_N2>
421 INLINE bool operator!=(
423 return !(operator==(op2));
424 }
425
426 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
427 ap_o_mode _AP_O2, int _AP_N2>
428 INLINE bool operator<(
430 ap_int_base<_AP_W, false> lop(*this);
432 return lop < rop;
433 }
434
435 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
436 ap_o_mode _AP_O2, int _AP_N2>
437 INLINE bool operator>(
439 ap_int_base<_AP_W, false> lop(*this);
441 return lop > rop;
442 }
443
444 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
445 ap_o_mode _AP_O2, int _AP_N2>
446 INLINE bool operator<=(
448 return !(operator>(op2));
449 }
450
451 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
452 ap_o_mode _AP_O2, int _AP_N2>
453 INLINE bool operator>=(
455 return !(operator<(op2));
456 }
457 // @}
458
462 template <int _AP_W2, int _AP_S2>
463 INLINE
465 operator,(ap_int_base<_AP_W2, _AP_S2>&op) {
466 return ap_concat_ref<_AP_W, af_range_ref, _AP_W2,
467 ap_int_base<_AP_W2, _AP_S2> >(*this, op);
468 }
469
471 template <int _AP_W2, int _AP_S2>
473 operator,(const ap_bit_ref<_AP_W2, _AP_S2>&op) {
475 *this, const_cast<ap_bit_ref<_AP_W2, _AP_S2>&>(op));
476 }
477
479 template <int _AP_W2, int _AP_S2>
480 INLINE
482 operator,(const ap_range_ref<_AP_W2, _AP_S2>&op) {
483 return ap_concat_ref<_AP_W, af_range_ref, _AP_W2,
485 *this, const_cast<ap_range_ref<_AP_W2, _AP_S2>&>(op));
486 }
487
489 template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3>
490 INLINE ap_concat_ref<_AP_W, af_range_ref, _AP_W2 + _AP_W3,
493 return ap_concat_ref<_AP_W, af_range_ref, _AP_W2 + _AP_W3,
495 *this, const_cast<ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>&>(op));
496 }
497
499 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
500 ap_o_mode _AP_O2, int _AP_N2>
501 INLINE ap_concat_ref<
502 _AP_W, af_range_ref, _AP_W2,
504 operator,(
506 return ap_concat_ref<
507 _AP_W, af_range_ref, _AP_W2,
509 *this,
510 const_cast<
512 }
513
515 template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2,
516 ap_o_mode _AP_O2, int _AP_N2>
517 INLINE
518 ap_concat_ref<_AP_W, af_range_ref, 1,
520 operator,(
522 return ap_concat_ref<
523 _AP_W, af_range_ref, 1,
525 *this,
527 op));
528 }
529 // @}
530
531 INLINE operator ap_ulong() const {
533 ret.V = _AP_ROOT_op_get_range(d_bv.V, l_index, h_index);
534 return ret.to_uint64();
535 }
536
537 INLINE operator ap_int_base<_AP_W, false>() const {
539 ret.V = _AP_ROOT_op_get_range(d_bv.V, l_index, h_index);
540 return ret;
541 }
542
543 INLINE ap_int_base<_AP_W, false> to_ap_int_base() const {
545 ret.V = _AP_ROOT_op_get_range(d_bv.V, l_index, h_index);
546 return ret;
547 }
548
549 // used in ap_fixed_base::to_string()
550 INLINE char to_char() const {
551 return (char)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
552 }
553
554 INLINE int to_int() const {
555 return (int)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
556 }
557
558 INLINE unsigned to_uint() const {
559 return (unsigned)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
560 }
561
562 INLINE long to_long() const {
563 return (long)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
564 }
565
566 INLINE unsigned long to_ulong() const {
567 return (unsigned long)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
568 }
569
570 INLINE ap_slong to_int64() const {
571 return (ap_slong)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
572 }
573
574 INLINE ap_ulong to_uint64() const {
575 return (ap_ulong)(_AP_ROOT_op_get_range(d_bv.V, l_index, h_index));
576 }
577
578 INLINE ap_int_base<_AP_W, false> get() const {
580 ret.V = _AP_ROOT_op_get_range(d_bv.V, l_index, h_index);
581 return ret;
582 }
583
584 template <int _AP_W2>
585 INLINE void set(const ap_int_base<_AP_W2, false>& val) {
586 d_bv.V = _AP_ROOT_op_set_range(d_bv.V, l_index, h_index, val.V);
587 }
588
589 INLINE int length() const {
590 return h_index >= l_index ? h_index - l_index + 1 : l_index - h_index + 1;
591 }
592
593#ifndef __SYNTHESIS__
594 std::string to_string(signed char rd = 2) const {
596 ret.V = _AP_ROOT_op_get_range(d_bv.V, l_index, h_index);
597 return ret.to_string(rd);
598 }
599#else
600 // XXX HLS will delete this in synthesis
601 INLINE char* to_string(signed char rd = 2) const { return 0; }
602#endif
603}; // struct af_range_ref
604
605// XXX apcc cannot handle global std::ios_base::Init() brought in by <iostream>
606#ifndef AP_AUTOCC
607#ifndef __SYNTHESIS__
608template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O,
609 int _AP_N>
610INLINE std::ostream& operator<<(
611 std::ostream& os,
613 os << x.to_string();
614 return os;
615}
616#endif
617#endif // ifndef AP_AUTOCC
618
619#define AF_REF_REL_OP_WITH_INT(REL_OP, C_TYPE, _AP_W2, _AP_S2) \
620 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
621 ap_o_mode _AP_O, int _AP_N> \
622 INLINE bool operator REL_OP( \
623 const af_range_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op, \
624 C_TYPE op2) { \
625 return ap_int_base<_AP_W, false>(op) \
626 REL_OP ap_int_base<_AP_W2, _AP_S2>(op2); \
627 } \
628 \
629 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
630 ap_o_mode _AP_O, int _AP_N> \
631 INLINE bool operator REL_OP( \
632 C_TYPE op2, \
633 const af_range_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op) { \
634 return ap_int_base<_AP_W2, _AP_S2>(op2) \
635 REL_OP ap_int_base<_AP_W, false>(op); \
636 } \
637 \
638 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
639 ap_o_mode _AP_O, int _AP_N> \
640 INLINE bool operator REL_OP( \
641 const af_bit_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op, \
642 C_TYPE op2) { \
643 return bool(op) REL_OP op2; \
644 } \
645 \
646 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
647 ap_o_mode _AP_O, int _AP_N> \
648 INLINE bool operator REL_OP( \
649 C_TYPE op2, \
650 const af_bit_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op) { \
651 return op2 REL_OP bool(op); \
652 }
653
654#define AF_REF_REL_OPS_WITH_INT(C_TYPE, _AP_W2, _AP_S2) \
655 AF_REF_REL_OP_WITH_INT(>, C_TYPE, (_AP_W2), (_AP_S2)) \
656 AF_REF_REL_OP_WITH_INT(<, C_TYPE, (_AP_W2), (_AP_S2)) \
657 AF_REF_REL_OP_WITH_INT(>=, C_TYPE, (_AP_W2), (_AP_S2)) \
658 AF_REF_REL_OP_WITH_INT(<=, C_TYPE, (_AP_W2), (_AP_S2)) \
659 AF_REF_REL_OP_WITH_INT(==, C_TYPE, (_AP_W2), (_AP_S2)) \
660 AF_REF_REL_OP_WITH_INT(!=, C_TYPE, (_AP_W2), (_AP_S2))
661
662AF_REF_REL_OPS_WITH_INT(bool, 1, false)
663AF_REF_REL_OPS_WITH_INT(char, 8, CHAR_IS_SIGNED)
664AF_REF_REL_OPS_WITH_INT(signed char, 8, true)
665AF_REF_REL_OPS_WITH_INT(unsigned char, 8, false)
666AF_REF_REL_OPS_WITH_INT(short, _AP_SIZE_short, true)
667AF_REF_REL_OPS_WITH_INT(unsigned short, _AP_SIZE_short, false)
668AF_REF_REL_OPS_WITH_INT(int, _AP_SIZE_int, true)
669AF_REF_REL_OPS_WITH_INT(unsigned int, _AP_SIZE_int, false)
670AF_REF_REL_OPS_WITH_INT(long, _AP_SIZE_long, true)
671AF_REF_REL_OPS_WITH_INT(unsigned long, _AP_SIZE_long, false)
672AF_REF_REL_OPS_WITH_INT(ap_slong, _AP_SIZE_ap_slong, true)
673AF_REF_REL_OPS_WITH_INT(ap_ulong, _AP_SIZE_ap_slong, false)
674
675#undef AF_REF_REL_OP_INT
676#undef AF_REF_REL_OPS_WITH_INT
677
678#define AF_REF_REL_OP_WITH_AP_INT(REL_OP) \
679 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
680 ap_o_mode _AP_O, int _AP_N, int _AP_W2, bool _AP_S2> \
681 INLINE bool operator REL_OP( \
682 const af_range_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op, \
683 const ap_int_base<_AP_W2, _AP_S>& op2) { \
684 return ap_int_base<_AP_W, false>(op) REL_OP op2; \
685 } \
686 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
687 ap_o_mode _AP_O, int _AP_N, int _AP_W2, bool _AP_S2> \
688 INLINE bool operator REL_OP( \
689 const ap_int_base<_AP_W2, _AP_S2>& op2, \
690 const af_range_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op) { \
691 return op2 REL_OP ap_int_base<_AP_W, false>(op); \
692 } \
693 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
694 ap_o_mode _AP_O, int _AP_N, int _AP_W2, bool _AP_S2> \
695 INLINE bool operator REL_OP( \
696 const af_bit_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op, \
697 const ap_int_base<_AP_W2, _AP_S2>& op2) { \
698 return ap_int_base<1, false>(op) REL_OP op2; \
699 } \
700 template <int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, \
701 ap_o_mode _AP_O, int _AP_N, int _AP_W2, bool _AP_S2> \
702 INLINE bool operator REL_OP( \
703 const ap_int_base<_AP_W2, _AP_S2>& op2, \
704 const af_bit_ref<_AP_W, _AP_I, _AP_S, _AP_Q, _AP_O, _AP_N>& op) { \
705 return op2 REL_OP ap_int_base<1, false>(op); \
706 }
707
708AF_REF_REL_OP_WITH_AP_INT(>)
709AF_REF_REL_OP_WITH_AP_INT(<)
710AF_REF_REL_OP_WITH_AP_INT(>=)
711AF_REF_REL_OP_WITH_AP_INT(<=)
712AF_REF_REL_OP_WITH_AP_INT(==)
713AF_REF_REL_OP_WITH_AP_INT(!=)
714
715#endif // ifndef __cplusplus
716
717#endif // ifndef __AP_FIXED_REF_H__
718
719// -*- cpp -*-