53 #ifndef _ROLE_WARPTRANSFORM_HW_COMMON_HPP_
54 #define _ROLE_WARPTRANSFORM_HW_COMMON_HPP_
58 #include <hls_stream.h>
61 #include "../../../../../HOST/vision/warp_transform/languages/cplusplus/include/config.h"
62 #include "memory_utils.hpp"
86 template<
typename Tin,
typename Tout,
unsigned int arraysize>
89 for (
unsigned int i = 0; i < arraysize; i++)
91 #pragma HLS PIPELINE II=1
111 template<
typename Tin,
typename Tout, const
unsigned int arraysize>
115 circ_buff_loop:
for (
unsigned int i = 0; i < elems; i++)
117 #pragma HLS PIPELINE II=1
118 #pragma HLS LOOP_TRIPCOUNT min = 1 max = arraysize
119 if(offset_buff+j==arraysize)
123 out_mem[i] = buff[0];
125 out_mem[i] = buff[offset_buff+j];
145 template<
typename Tin,
typename Tout, const
unsigned int burstsize>
148 mmloop:
for (
unsigned int i = 0; i < elems; i++)
150 #pragma HLS PIPELINE II=1
151 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
152 Tout
tmp = main_mem[i];
174 template<
typename Tin,
typename Tout, const
unsigned int burstsize,
typename Tcntr>
178 mmloop:
for (
unsigned int i = 0; i < elems; i++)
180 #pragma HLS PIPELINE II=1
181 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
182 Tout
tmp = main_mem[i];
204 template<
typename Tin,
typename Tout, const
unsigned int burstsize,
typename Tcntr>
208 mmloop:
for (
unsigned int i = 0; i < elems; i++)
210 #pragma HLS PIPELINE II=1
211 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
212 Tout
tmp = main_mem[i];
224 template<
typename Tin,
const unsigned int loop_cnt,
225 const unsigned int bytes_per_loop,
const unsigned int max_data_transfer>
229 Tin &img_in_axi_stream,
230 unsigned int *processed_word_rx,
231 unsigned int *processed_bytes_rx,
232 stream<bool> &sImageLoaded
239 unsigned int bytes_with_keep = 0;
240 for (
unsigned int i=0; i<loop_cnt; i++) {
241 if ((word.
tkeep >> i) == 0) {
242 printf(
"WARNING: value with tkeep=0 at i=%u\n", i);
245 v.data = (ap_uint<INPUT_PTR_WIDTH>)(word.
tdata >> i*8);
248 img_in_axi_stream.write(v.data);
249 bytes_with_keep += bytes_per_loop;
251 if (*processed_bytes_rx < max_data_transfer){
253 (*processed_bytes_rx) += bytes_with_keep;
254 if (!sImageLoaded.full()) {
255 sImageLoaded.write(
false);
259 printf(
"DEBUG in storeWordToAxiStream: WARNING - you've reached the max depth of img. Will put *processed_bytes_rx = 0.\n");
260 *processed_bytes_rx = 0;
261 if (!sImageLoaded.full()) {
262 sImageLoaded.write(
true);
271 template<
typename TInImg, const
unsigned int img_pckts>
274 unsigned int *processed_word,
unsigned int *image_loaded)
278 img[*processed_word] = (TInImg)
input;
279 printf(
"DEBUG in storeWordToArray: input = %u = 0x%16.16llX \n",
input,
input);
280 printf(
"DEBUG in storeWordToArray: img[%u]= %u = 0x%16.16llX \n", *processed_word,
281 (uint64_t)
img[*processed_word], (uint64_t)
img[*processed_word]);
282 if (*processed_word < img_pckts-1) {
286 printf(
"DEBUG in storeWordToArray: WARNING - you've reached the max depth of img[%u]. Will put *processed_word = 0.\n", *processed_word);
305 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
306 void perfCounterProc(hls::stream<Tin>& cmd, hls::stream<Tout>&
out,
int direction,
int burst_length,
int nmbr_outstanding)
308 #pragma HLS INLINE off
312 ap_uint<counter_precision> cnt = cmd.read();
315 while (cmd.read_nb(input_cmd) ==
false) {
317 #if DEBUG_LEVEL == TRACE_ALL
318 #ifndef __SYNTHESIS__
319 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
340 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
345 ap_uint<counter_precision> cnt = cmd.read();
348 while (cmd.read_nb(input_cmd) ==
false) {
349 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
352 #if DEBUG_LEVEL == TRACE_ALL
353 #ifndef __SYNTHESIS__
354 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
374 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
379 ap_uint<counter_precision> cnt = cmd.read();
382 while (cmd.read_nb(input_cmd) ==
false) {
383 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
386 #if DEBUG_LEVEL == TRACE_ALL
387 #ifndef __SYNTHESIS__
388 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
410 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
415 ap_uint<counter_precision> cnt = cmd.read();
418 while (cmd.read_nb(input_cmd) ==
false) {
419 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
421 #if DEBUG_LEVEL == TRACE_ALL
422 #ifndef __SYNTHESIS__
423 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
442 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
444 #pragma HLS interface ap_ctrl_none port=return
448 ap_uint<counter_precision> cnt = cmd.read();
450 while (input_cmd != 0)
452 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
453 #if DEBUG_LEVEL == TRACE_ALL
454 #ifndef __SYNTHESIS__
460 while (cmd.read_nb(input_cmd) ==
false) {
461 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
462 #pragma HLS PIPELINE II=1
464 #if DEBUG_LEVEL == TRACE_ALL
465 #ifndef __SYNTHESIS__
470 input_cmd=cmd.read();
489 template<
typename Tevent=
bool, const
unsigned int counter_w
idth=32, const
unsigned int maximum_counter_value_before_reset=4000000>
491 hls::stream<Tevent> &sOfEnableCCIncrement,
492 hls::stream<Tevent> &sOfResetCounter,
493 hls::stream<Tevent> &sOfGetTheCounter,
494 hls::stream<ap_uint<counter_width> > &oSClockCounter)
497 static ap_uint<counter_width> internal_counter = 0;
498 static bool pop_the_counter =
false;
499 #pragma HLS reset variable=internal_counter
500 #pragma HLS reset variable=pop_the_counter
502 if(!sOfGetTheCounter.empty()){
503 pop_the_counter = sOfGetTheCounter.read();
505 if (pop_the_counter && !oSClockCounter.full())
507 oSClockCounter.write(internal_counter);
508 pop_the_counter=
false;
510 if(!sOfResetCounter.empty()){
511 bool reset_or_not = sOfResetCounter.read();
514 internal_counter = 0;
517 if(!sOfEnableCCIncrement.empty()){
518 bool increment = sOfEnableCCIncrement.read();
521 if(internal_counter==maximum_counter_value_before_reset){
526 #if DEBUG_LEVEL == TRACE_ALL
527 #ifndef __SYNTHESIS__
528 printf(
"DEBUG pCountClockCycles counter value = %s\n", internal_counter.to_string().c_str());