20 #include "../include/gammacorrection.hpp"
21 #include "../include/xf_gammacorrection_config.h"
23 #ifdef USE_HLSLIB_DATAFLOW
24 #include "../../../../../hlslib/include/hlslib/xilinx/Stream.h"
25 #include "../../../../../hlslib/include/hlslib/xilinx/Simulation.h"
28 #ifdef USE_HLSLIB_STREAM
35 #define Data_t ap_axiu<INPUT_PTR_WIDTH, 0, 0, 0>
48 unsigned int *processed_word,
unsigned int *image_loaded)
52 img[*processed_word] = (ap_uint<INPUT_PTR_WIDTH>)
input;
53 printf(
"DEBUG in storeWordToArray: input = %u = 0x%16.16llX \n",
input,
input);
54 printf(
"DEBUG in storeWordToArray: img[%u]= %u = 0x%16.16llX \n", *processed_word,
55 (uint64_t)
img[*processed_word], (uint64_t)
img[*processed_word]);
60 printf(
"DEBUG in storeWordToArray: WARNING - you've reached the max depth of img[%u]. Will put *processed_word = 0.\n", *processed_word);
74 stream<Data_t> &img_in_axi_stream,
75 unsigned int *processed_word_rx,
76 unsigned int *image_loaded)
88 img_in_axi_stream.write(v);
91 (*processed_word_rx)++;
94 printf(
"DEBUG in storeWordToAxiStream: WARNING - you've reached the max depth of img. Will put *processed_word_rx = 0.\n");
95 *processed_word_rx = 0;
116 stream<NetworkWord> &siSHL_This_Data,
117 stream<NetworkMetaStream> &siNrc_meta,
118 stream<NetworkMetaStream> &sRxtoTx_Meta,
120 stream<Data_t> &img_in_axi_stream,
122 unsigned int *processed_word_rx,
123 unsigned int *image_loaded
135 printf(
"DEBUG in pRXPath: enqueueFSM - WAIT_FOR_META, *processed_word_rx=%u\n",
137 if ( !siNrc_meta.empty() && !sRxtoTx_Meta.full() )
139 meta_tmp = siNrc_meta.read();
141 sRxtoTx_Meta.write(meta_tmp);
149 printf(
"DEBUG in pRXPath: enqueueFSM - PROCESSING_PACKET, *processed_word_rx=%u\n",
151 if ( !siSHL_This_Data.empty() && !img_in_axi_stream.full() )
154 udpWord = siSHL_This_Data.read();
156 if(udpWord.
tlast == 1)
180 stream<NetworkWord> &sRxpToTxp_Data,
183 stream<Data_t> &img_in_axi_stream,
184 stream<Data_t> &img_out_axi_stream,
185 unsigned int *processed_word_rx,
186 unsigned int *image_loaded
194 uint16_t Thresh = 442;
196 uint16_t k = K * (1 << 16);
202 printf(
"DEBUG in pProcPath: WAIT_FOR_META\n");
203 if ( (*image_loaded) == 1 )
206 *processed_word_rx = 0;
211 printf(
"DEBUG in pProcPath: PROCESSING_PACKET\n");
212 if ( !img_in_axi_stream.empty() && !img_out_axi_stream.full() )
215 if ( !img_out_axi_stream.empty() )
223 printf(
"DEBUG in pProcPath: GAMMACORRECTION_RETURN_RESULTS\n");
224 if ( !img_out_axi_stream.empty() && !sRxpToTxp_Data.full() )
227 Data_t temp = img_out_axi_stream.read();
228 if ( img_out_axi_stream.empty() )
239 newWord =
NetworkWord(temp.data, temp.keep, temp.last);
240 sRxpToTxp_Data.write(newWord);
263 stream<NetworkWord> &soTHIS_Shl_Data,
264 stream<NetworkMetaStream> &soNrc_meta,
265 stream<NetworkWord> &sRxpToTxp_Data,
266 stream<NetworkMetaStream> &sRxtoTx_Meta,
267 unsigned int *processed_word_tx,
268 ap_uint<32> *pi_rank,
282 printf(
"DEBUG in pTXPath: dequeueFSM=%d - WAIT_FOR_STREAM_PAIR, *processed_word_tx=%u\n",
285 *processed_word_tx = 0;
294 if (( !sRxpToTxp_Data.empty() && !sRxtoTx_Meta.empty()
295 && !soTHIS_Shl_Data.full() && !soNrc_meta.full() ))
297 udpWordTx = sRxpToTxp_Data.read();
304 soTHIS_Shl_Data.write(udpWordTx);
306 meta_in = sRxtoTx_Meta.read().tdata;
308 meta_out_stream.
tlast = 1;
309 meta_out_stream.
tkeep = 0xFF;
319 soNrc_meta.write(meta_out_stream);
321 (*processed_word_tx)++;
323 if(udpWordTx.
tlast != 1)
331 printf(
"DEBUG in pTXPath: dequeueFSM=%d - PROCESSING_PACKET, *processed_word_tx=%u\n",
333 if( !sRxpToTxp_Data.empty() && !soTHIS_Shl_Data.full())
335 udpWordTx = sRxpToTxp_Data.read();
338 if(udpWordTx.
tlast == 1)
346 (*processed_word_tx)++;
347 if (((*processed_word_tx)*8) %
PACK_SIZE == 0)
353 soTHIS_Shl_Data.write(udpWordTx);
368 ap_uint<32> *pi_rank,
369 ap_uint<32> *pi_size,
373 stream<NetworkWord> &siSHL_This_Data,
374 stream<NetworkWord> &soTHIS_Shl_Data,
375 stream<NetworkMetaStream> &siNrc_meta,
376 stream<NetworkMetaStream> &soNrc_meta,
377 ap_uint<32> *po_rx_ports
386 #pragma HLS INTERFACE axis register both port=siSHL_This_Data
387 #pragma HLS INTERFACE axis register both port=soTHIS_Shl_Data
389 #pragma HLS INTERFACE axis register both port=siNrc_meta
390 #pragma HLS INTERFACE axis register both port=soNrc_meta
392 #pragma HLS INTERFACE ap_ovld register port=po_rx_ports name=poROL_NRC_Rx_ports
393 #pragma HLS INTERFACE ap_stable register port=pi_rank name=piFMC_ROL_rank
394 #pragma HLS INTERFACE ap_stable register port=pi_size name=piFMC_ROL_size
399 static stream<NetworkWord> sRxpToTxp_Data(
"sRxpToTxP_Data");
400 static stream<NetworkMetaStream> sRxtoTx_Meta(
"sRxtoTx_Meta");
401 static unsigned int processed_word_rx;
402 static unsigned int processed_word_tx;
403 static unsigned int image_loaded;
406 static stream<Data_t> img_in_axi_stream (
"img_in_axi_stream" );
407 static stream<Data_t> img_out_axi_stream(
"img_out_axi_stream");
416 #pragma HLS stream variable=sRxtoTx_Meta depth=tot_transfers
417 #pragma HLS reset variable=enqueueFSM
418 #pragma HLS reset variable=dequeueFSM
419 #pragma HLS reset variable=GammacorrectionFSM
420 #pragma HLS reset variable=processed_word_rx
421 #pragma HLS reset variable=processed_word_tx
422 #pragma HLS reset variable=image_loaded
423 #pragma HLS stream variable=img_in_axi_stream depth=img_packets
424 #pragma HLS stream variable=img_out_axi_stream depth=img_packets
427 #ifdef USE_HLSLIB_DATAFLOW
437 HLSLIB_DATAFLOW_INIT();
439 HLSLIB_DATAFLOW_FUNCTION(
pRXPath,
455 HLSLIB_DATAFLOW_FUNCTION(
pTXPath,
464 HLSLIB_DATAFLOW_FINALIZE();
void pTXPath(stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &soNrc_meta, stream< NetworkWord > &sRxpToTxp_Data, stream< NetworkMetaStream > &sRxtoTx_Meta, unsigned int *processed_word_tx, ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size)
Transmit Path - From THIS to SHELL.
uint8_t GammacorrectionFSM
#define GAMMACORRECTION_RETURN_RESULTS
void storeWordToAxiStream(NetworkWord word, stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, unsigned int *processed_word_rx, unsigned int *image_loaded)
Store a word from ethernet to a local AXI stream.
void gammacorrection(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siSHL_This_Data, stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the Gammacorrection Application directives.
void pProcPath(stream< NetworkWord > &sRxpToTxp_Data, stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, stream< ap_axiu< 64, 0, 0, 0 > > &img_out_axi_stream, unsigned int *processed_word_rx, unsigned int *image_loaded)
Processing Path - Main processing FSM for Vitis kernels.
void storeWordToArray(uint64_t input, ap_uint< 64 > img[256 *256/(64/8)], unsigned int *processed_word, unsigned int *image_loaded)
Store a word from ethernet to local memory.
void pRXPath(stream< NetworkWord > &siSHL_This_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &sRxtoTx_Meta, stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, NetworkMetaStream meta_tmp, unsigned int *processed_word_rx, unsigned int *image_loaded)
Receive Path - From SHELL to THIS.
void GammacorrectionAccelStream(hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_in_axi_stream, hls::stream< ap_axiu< 64, 0, 0, 0 > > &img_out_axi_stream, int rows, int cols, int threshold, int k)
Top-level accelerated function of the Gammacorrection Application with array I/F.
#define PROCESSING_PACKET
#define WAIT_FOR_STREAM_PAIR