19 #include "nvhls_int.h"
20 #include "nvhls_types.h"
77 template <
typename DataType,
unsigned NumInputLanes,
unsigned NumOutputLanes>
78 void crossbar(DataType data_in[NumInputLanes],
bool valid_in[NumInputLanes],
80 bool valid_source[NumOutputLanes],
81 DataType data_out[NumOutputLanes],
82 bool valid_out[NumOutputLanes]) {
88 #pragma hls_unroll yes
89 for (
unsigned dst = 0; dst < NumOutputLanes; dst++) {
90 source_tmp = source[dst];
91 if (!valid_source[dst]) {
94 valid_in_tmp = valid_in[source_tmp];
95 data_in_tmp = data_in[source_tmp];
97 if (valid_source[dst] && valid_in_tmp) {
98 data_out[dst] = data_in_tmp;
99 valid_out[dst] =
true;
101 data_out[dst] = zero_bits<DataType>();
102 valid_out[dst] =
false;
111 template <
typename DataType,
unsigned NumInputLanes,
unsigned NumOutputLanes>
112 void crossbar(DataType data_in[NumInputLanes],
bool valid_in[NumInputLanes],
114 DataType data_out[NumOutputLanes],
115 bool valid_out[NumOutputLanes]) {
117 bool valid_source[NumOutputLanes];
118 for (
unsigned i = 0; i < NumOutputLanes; ++i)
119 valid_source[i] =
true;
121 crossbar<DataType, NumInputLanes, NumOutputLanes>(
122 data_in, valid_in, source, valid_source, data_out, valid_out);
129 template <
typename DataType,
unsigned NumInputLanes,
unsigned NumOutputLanes>
132 DataType data_out[NumOutputLanes]) {
134 bool valid_out[NumOutputLanes];
135 bool valid_in[NumInputLanes];
136 for (
unsigned int i = 0; i < NumInputLanes; ++i)
139 crossbar<DataType, NumInputLanes, NumOutputLanes>(data_in, valid_in, source,
140 data_out, valid_out);
void crossbar(DataType data_in[NumInputLanes], bool valid_in[NumInputLanes], NVUINTW(nvhls::index_width< NumInputLanes >::val) source[NumOutputLanes], bool valid_source[NumOutputLanes], DataType data_out[NumOutputLanes], bool valid_out[NumOutputLanes])
Main entry point for crossbar - most generic implementation.
NVUINTW(Wrapped< T >::width) TypeToNVUINT(T in)
Convert Type to NVUINT.
Compute index width of a constant.