19 #include <boost/preprocessor/arithmetic/add.hpp> 20 #include <boost/preprocessor/punctuation/comma_if.hpp> 21 #include <boost/preprocessor/control/if.hpp> 22 #include <boost/preprocessor/repetition/repeat.hpp> 23 #include <boost/preprocessor/repetition/enum_params.hpp> 24 #include <boost/preprocessor/iteration/local.hpp> 26 #include <nvhls_marshaller.h> 27 #include <nvhls_message.h> 28 #include <nvhls_module.h> 60 template <
typename Type,
unsigned int VectorLength>
65 template <
typename A,
unsigned int K>
68 #define ACCESSOR(Z, N, TEXT) \ 69 BOOST_PP_IF(N, else, ) if (idx == N) return data##N; 70 #define NMINIT(Z, N, TEXT) BOOST_PP_COMMA_IF(N) data##N(nvhls_concat(nm, #N)) 71 #define NMIDINIT(Z, N, TEXT) \ 72 BOOST_PP_COMMA_IF(N) data##N(nvhls_concat(nm, #N), N) 73 #define DECL(Z, N, TEXT) TEXT data##N; 75 #define SPECIALIZATION(Z, N, TEXT) \ 76 template <typename A> \ 79 BOOST_PP_REPEAT(BOOST_PP_ADD(N, 1), DECL, A) \ 81 NNode(sc_module_name nm) \ 82 : BOOST_PP_REPEAT(BOOST_PP_ADD(N, 1), NMINIT, BOOST_PP_EMPTY) {} \ 83 NNode(sc_module_name nm, const unsigned& id) \ 84 : BOOST_PP_REPEAT(BOOST_PP_ADD(N, 1), NMIDINIT, BOOST_PP_EMPTY) {} \ 85 A& Get(unsigned int idx) { \ 86 BOOST_PP_REPEAT(BOOST_PP_ADD(N, 1), ACCESSOR, BOOST_PP_EMPTY) \ 89 const A& Get(unsigned int idx) const { \ 90 BOOST_PP_REPEAT(BOOST_PP_ADD(N, 1), ACCESSOR, BOOST_PP_EMPTY) \ 95 #define MAX_SPECIALIZATIONS 256 97 BOOST_PP_REPEAT(MAX_SPECIALIZATIONS, SPECIALIZATION, BOOST_PP_EMPTY)
99 NNode<Type, VectorLength - 1> array_impl;
104 nv_array(
const char* prefix) : array_impl(prefix) {}
105 nv_array(sc_module_name prefix) : array_impl(prefix) {}
106 nv_array(sc_module_name prefix,
const unsigned int&
id)
107 : array_impl(prefix, id) {}
109 #pragma hls_unroll yes 110 for (
unsigned i = 0; i < VectorLength; i++)
111 array_impl.Get(i) = that.array_impl.Get(i);
113 nv_array(
const Type newdata[VectorLength]) {
114 #pragma hls_unroll yes 115 for (
unsigned i = 0; i < VectorLength; i++)
116 array_impl.Get(i) = newdata[i];
120 #pragma hls_unroll yes 121 for (
unsigned i = 0; i < VectorLength; i++)
122 array_impl.Get(i) = that.array_impl.Get(i);
126 #pragma hls_unroll yes 127 for (
unsigned i = 0; i < VectorLength; i++)
128 out.array_impl.Get(i) = array_impl.Get(i);
130 Type& operator[](
unsigned int i) {
132 return this->array_impl.Get(i);
134 const Type& operator[](
unsigned int i)
const {
136 return this->array_impl.Get(i);
138 static const unsigned int width = Wrapped<Type>::width * VectorLength;
139 template <
unsigned int Size>
140 void Marshall(Marshaller<Size>& m) {
141 for (
unsigned int x = 0; x < VectorLength; x++) {
142 m& array_impl.Get(x);
147 template <
typename Type>
153 nv_array(sc_module_name prefix,
const unsigned int&
id) {}
158 Type& operator[](
unsigned int i) {
162 const Type& operator[](
unsigned int i)
const {
return NULL; }
163 static const unsigned int width = 0;
164 template <
unsigned int Size>
165 void Marshall(Marshaller<Size>& m) {}
An implementation of array that declares VectorLength variables for array of size VectorLength...