ap_common.h: remove synthesis defines

This commit is contained in:
Yuanjie Huang 2019-01-29 13:00:40 +08:00
parent 577badfbb4
commit aae1cea3f5

View file

@ -192,360 +192,7 @@ struct remove_const<_Tp const> {
// Define ssdm_int and _ssdm_op.
#ifdef __SYNTHESIS__
#if ((__clang_major__ == 3) && (__clang_minor__ == 1))
/* HECTOR is a tool for formal system-level to RTL equivalence checking.
* https://www.research.ibm.com/haifa/conferences/hvc2008/present/CarlPixleyHVC08.pdf
* we used to used Hector.h here instead of following ssdm_int definition,
* but now it is deleted.
*/
template <int _AP_N, bool _AP_S>
struct ssdm_int;
#define AP_INT_BASE(_AP_N, mode) \
template <> \
struct ssdm_int<_AP_N + 1024 * mode, true> { \
int V __attribute__((bitwidth(_AP_N + 1024 * mode))); \
INLINE ssdm_int<_AP_N + 1024 * mode, true>(){}; \
}; \
template <> \
struct ssdm_int<_AP_N + 1024 * mode, false> { \
unsigned int V __attribute__((bitwidth(_AP_N + 1024 * mode))); \
INLINE ssdm_int<_AP_N + 1024 * mode, false>(){}; \
};
#if MAX_MODE(AP_INT_MAX_W) >= 1
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 0)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 2
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 1)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 3
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 2)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 4
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 3)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 5
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 4)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 6
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 5)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 7
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 6)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 8
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 7)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 9
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 8)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 10
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 9)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 11
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 10)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 12
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 11)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 13
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 12)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 14
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 13)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 15
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 14)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 16
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 15)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 17
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 16)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 18
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 17)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 19
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 18)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 20
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 19)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 21
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 20)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 22
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 21)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 23
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 22)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 24
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 23)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 25
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 24)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 26
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 25)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 27
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 26)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 28
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 27)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 29
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 28)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 30
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 29)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 31
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 30)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#if MAX_MODE(AP_INT_MAX_W) >= 32
#define HANDLE_BAT(TYPE, _AP_N) AP_INT_BASE(_AP_N, 31)
#define APINT_DEFINE_INT64
#include "etc/autopilot_dt.def"
#undef APINT_DEFINE_INT64
#undef HANDLE_BAT
#endif
#undef MAX_MODE
#undef AP_INT_BASE
#else // HLS clang of higher version than 3.1
template <int _AP_N, bool _AP_S>
struct ssdm_int;
template <int _AP_N>
struct ssdm_int<_AP_N, true> {
int V __attribute__((bitwidth(_AP_N)));
INLINE ssdm_int<_AP_N, true>(){};
};
template <int _AP_N>
struct ssdm_int<_AP_N, false> {
unsigned V __attribute__((bitwidth(_AP_N)));
INLINE ssdm_int<_AP_N, false>(){};
};
#endif // clang 3.1 test
// FIXME typeof is an compiler extension.
// FIXME use ({}) to return value is GCC extension.
#define _ssdm_op_concat(Ret, X, Y) \
({ \
typeof(Ret) __Result__ = 0; \
typeof(X) __X2__ = X; \
typeof(Y) __Y2__ = Y; \
__builtin_bit_concat((void*)(&__Result__), (void*)(&__X2__), \
(void*)(&__Y2__)); \
__Result__; \
})
#define _ssdm_op_get_bit(Val, Bit) \
({ \
typeof(Val) __Val2__ = Val; \
bool __Result__ = __builtin_bit_select((void*)(&__Val2__), Bit); \
__Result__; \
})
#define _ssdm_op_set_bit(Val, Bit, Repl) \
({ \
typename _ap_type::remove_const<typeof(Val)>::type __Result__ = 0; \
typeof(Val) __Val2__ = Val; \
typeof(Repl) __Repl2__ = !!Repl; \
__builtin_bit_part_set((void*)(&__Result__), (void*)(&__Val2__), \
(void*)(&__Repl2__), Bit, Bit); \
__Result__; \
})
#define _ssdm_op_get_range(Val, Lo, Hi) \
({ \
typename _ap_type::remove_const<typeof(Val)>::type __Result__ = 0; \
typeof(Val) __Val2__ = Val; \
__builtin_bit_part_select((void*)(&__Result__), (void*)(&__Val2__), Lo, \
Hi); \
__Result__; \
})
#define _ssdm_op_set_range(Val, Lo, Hi, Repl) \
({ \
typename _ap_type::remove_const<typeof(Val)>::type __Result__ = 0; \
typeof(Val) __Val2__ = Val; \
typeof(Repl) __Repl2__ = Repl; \
__builtin_bit_part_set((void*)(&__Result__), (void*)(&__Val2__), \
(void*)(&__Repl2__), Lo, Hi); \
__Result__; \
})
#include "etc/autopilot_ssdm_bits.h"
extern "C" void _ssdm_string2bits(...);
#error "This header does not sypport synthesis"
#endif // ifdef __SYNTHESIS__
#ifndef NON_C99STRING