34 #ifndef _ROLE_SOBEL_PROCESSING_HPP_
35 #define _ROLE_SOBEL_PROCESSING_HPP_
38 #define FSM_PROCESSING_WAIT_FOR_META 0
39 #define FSM_PROCESSING_PCKT_PROC 1
40 #define FSM_PROCESSING_STOP 2
41 #define FSM_PROCESSING_START 3
42 #define FSM_PROCESSING_BURST_READING 4
43 #define FSM_PROCESSING_DATAFLOW_WRITE 5
44 #define FSM_PROCESSING_DATAFLOW_READ 6
45 #define FSM_PROCESSING_OUTPUT 7
46 #define FSM_PROCESSING_OUTPUT_2 8
47 #define FSM_PROCESSING_OUTPUT_3 9
48 #define FSM_PROCESSING_OUTPUT_4 10
49 #define FSM_PROCESSING_OUTPUT_5 11
50 #define FSM_PROCESSING_CONTINUOUS_RUN 12
51 #define FSM_PROCESSING_WAIT_FOR_DDR_CONTROLLER_EMPTYNESS 13
52 #define ProcessingFsmType uint8_t
91 template<const
unsigned int counter_w
idth=64>
93 stream<NetworkWord> &sRxpToProcp_Data,
94 stream<NetworkWord> &sProcpToTxp_Data,
95 stream<NetworkMetaStream> &sRxtoProc_Meta,
96 stream<NetworkMetaStream> &sProctoTx_Meta,
108 #pragma HLS INLINE off
115 static ap_uint<16> max_iterations;
119 static ap_uint<32> faulty_addresses_cntr;
122 static size_t bytes_sent_for_tx =0;
124 #pragma HLS reset variable=processingFSM
125 #pragma HLS reset variable=outNetMeta
126 #pragma HLS reset variable=max_iterations
127 #pragma HLS reset variable=first_faulty_address
128 #pragma HLS reset variable=faulty_addresses_cntr
129 #pragma HLS reset variable=max_address_under_test
130 #pragma HLS reset variable=processingFSM
131 #pragma HLS reset variable=bytes_sent_for_tx
133 static ap_uint<32> testCounter;
134 static ap_uint<counter_width> reading_cntr = 0;
135 static ap_uint<counter_width> writing_cntr = 0;
136 static unsigned int burst_size=1;
138 static int emptycntr=0;
140 #pragma HLS reset variable=testCounter
141 #pragma HLS reset variable=tmp_wordaligned_address
142 #pragma HLS reset variable=burst_size
150 #if DEBUG_LEVEL == TRACE_ALL
151 printf(
"DEBUG proc FSM, I am in the WAIT_FOR_META state\n");
154 max_address_under_test = 0;
156 bytes_sent_for_tx = 0;
158 if ( !sRxtoProc_Meta.empty() && !sProctoTx_Meta.full())
160 outNetMeta = sRxtoProc_Meta.read();
161 sProctoTx_Meta.write(outNetMeta);
167 #if DEBUG_LEVEL == TRACE_ALL
168 printf(
"DEBUG proc FSM, I am in the PROCESSING_PCKT_PROC state\n");
171 if ( !sRxpToProcp_Data.empty() && !sProcpToTxp_Data.full())
173 netWord = sRxpToProcp_Data.read();
178 #if DEBUG_LEVEL == TRACE_ALL
179 printf(
"DEBUG processing the packet with invalid cmd\n");
181 sProcpToTxp_Data.write(netWord);
186 #if DEBUG_LEVEL == TRACE_ALL
187 printf(
"DEBUG processing the packet with stop cmd\n");
190 outNetWord.
tkeep = 0xFF;
191 outNetWord.
tlast = 1;
192 sProcpToTxp_Data.write(outNetWord);
197 #if DEBUG_LEVEL == TRACE_ALL
198 printf(
"DEBUG processing the packet with the address within cmd\n");
202 #if DEBUG_LEVEL == TRACE_ALL
203 #ifndef __SYNTHESIS__
204 printf(
"DEBUG processing the packet with the address %s within cmd %s\n", max_address_under_test.to_string().c_str(), max_iterations.to_string().c_str());
214 #if DEBUG_LEVEL == TRACE_ALL
215 printf(
"DEBUG proc FSM, I am in the FSM_PROCESSING_BURST_READING state\n");
218 if ( !sRxpToProcp_Data.empty())
220 netWord = sRxpToProcp_Data.read();
221 #if DEBUG_LEVEL == TRACE_ALL
222 std::cout << netWord.
tdata.to_string() << std::endl;
230 #if DEBUG_LEVEL == TRACE_ALL
231 printf(
"DEBUG processing the packet with burst cmd, and burst size=%u\n",burst_size);
239 #if DEBUG_LEVEL == TRACE_ALL
240 #ifndef __SYNTHESIS__
245 sProcpToTxp_Data.write(netWord);
255 #if DEBUG_LEVEL == TRACE_ALL
256 printf(
"DEBUG proc FSM, I am in the START state\n");
259 first_faulty_address = 0;
260 faulty_addresses_cntr = 0;
261 if(max_address_under_test%64==0){
262 tmp_wordaligned_address = max_address_under_test/64;
264 tmp_wordaligned_address = (max_address_under_test/64+1);
266 #if DEBUG_LEVEL == TRACE_ALL
267 #ifndef __SYNTHESIS__
268 std::cout <<
" testing the address word aligned" << tmp_wordaligned_address.to_string() << std::endl;
282 faulty_addresses_cntr = 0;
283 first_faulty_address = 0;
286 if(*start_stop && testCounter < max_iterations){
287 #if DEBUG_LEVEL == TRACE_ALL
288 #ifndef __SYNTHESIS__
289 printf(
"DEBUG processing continuous run (still run, iter %s) max iters: %s\n",testCounter.to_string().c_str(),max_iterations.to_string().c_str());
295 sProctoTx_Meta.write(outNetMeta);
296 #if DEBUG_LEVEL == TRACE_ALL
297 std::cout <<
"DEBUG: writing an additional meta with bytes sent equal to " << bytes_sent_for_tx << std::endl;
299 bytes_sent_for_tx = 0;
305 #if DEBUG_LEVEL == TRACE_ALL
306 #ifndef __SYNTHESIS__
307 printf(
"DEBUG processing continuous run (stop the run at iter %s) max iters: %s \n",testCounter.to_string().c_str(),max_iterations.to_string().c_str());
313 outNetWord.
tkeep = 0xFF;
314 outNetWord.
tlast = 1;
315 sProcpToTxp_Data.write(outNetWord);
327 #if DEBUG_LEVEL == TRACE_ALL
328 printf(
"DEBUG processing write dataflow\n");
330 pWriteDataflowMemTest<top_param_maximum_number_of_beats>(
lcl_mem0,
331 tmp_wordaligned_address , &writing_cntr,&testCounter,burst_size);
336 #if DEBUG_LEVEL == TRACE_ALL
337 printf(
"DEBUG processing the output of a run\n");
347 #if DEBUG_LEVEL == TRACE_ALL
348 printf(
"DEBUG processing read dataflow\n");
350 pReadDataflowMemTest<top_param_maximum_number_of_beats>(
lcl_mem1,
351 tmp_wordaligned_address ,&reading_cntr,&faulty_addresses_cntr, &first_faulty_address,burst_size);
361 #if DEBUG_LEVEL == TRACE_ALL
362 printf(
"DEBUG processing the output of a run\n");
364 if(!sProcpToTxp_Data.full()){
365 outNetWord.
tdata = max_address_under_test;
366 outNetWord.
tkeep = 0xFF;
367 outNetWord.
tlast = 0;
368 sProcpToTxp_Data.write(outNetWord);
369 bytes_sent_for_tx += 8;
375 #if DEBUG_LEVEL == TRACE_ALL
376 #ifndef __SYNTHESIS__
377 printf(
"DEBUG processing the output of a run part 2; faulty address cntr %s\n",faulty_addresses_cntr.to_string().c_str());
380 if(!sProcpToTxp_Data.full()){
381 outNetWord.
tdata=faulty_addresses_cntr;
382 outNetWord.
tkeep = 0xFF;
383 outNetWord.
tlast = 0;
384 sProcpToTxp_Data.write(outNetWord);
385 bytes_sent_for_tx += 8 ;
390 #if DEBUG_LEVEL == TRACE_ALL
391 #ifndef __SYNTHESIS__
392 printf(
"DEBUG processing the output of a run part 3: first faulty address %s\n",first_faulty_address.to_string().c_str());
395 if(!sProcpToTxp_Data.full()){
396 outNetWord.
tdata=first_faulty_address;
397 outNetWord.
tkeep = 0xFF;
398 outNetWord.
tlast = 0;
399 sProcpToTxp_Data.write(outNetWord);
400 bytes_sent_for_tx += 8;
405 #if DEBUG_LEVEL == TRACE_ALL
406 printf(
"DEBUG processing the output of a run part 4\n");
408 if(!sProcpToTxp_Data.full()){
409 outNetWord.
tdata = writing_cntr;
410 outNetWord.
tkeep = 0xFF;
411 outNetWord.
tlast = 0;
412 sProcpToTxp_Data.write(outNetWord);
413 bytes_sent_for_tx += 8;
418 #if DEBUG_LEVEL == TRACE_ALL
419 printf(
"DEBUG processing the output of a run part 4\n");
421 if(!sProcpToTxp_Data.full()){
422 outNetWord.
tdata= reading_cntr;
423 outNetWord.
tkeep = 0xFF;
424 outNetWord.
tlast = 0;
425 sProcpToTxp_Data.write(outNetWord);
426 bytes_sent_for_tx += 8;
449 template <
typename TimgIn=ap_u
int<INPUT_PTR_WIDTH>,
typename TimgOut=ap_u
int<OUTPUT_PTR_WIDTH>>
452 stream<NetworkWord> &sRxpToTxp_Data,
458 stream<TimgIn> &img_in_axi_stream,
459 stream<TimgOut> &img_out_axi_stream,
461 stream<bool> &sImageLoaded
465 #pragma HLS INLINE off
466 #pragma HLS pipeline II=1
470 uint16_t Thresh = 442;
472 uint16_t k = K * (1 << 16);
473 static bool accel_called;
474 static unsigned int processed_word_proc;
475 static unsigned int timeoutCntAbs;
476 static unsigned int cnt_i;
483 static unsigned int ddr_addr_out;
484 #pragma HLS reset variable=ddr_addr_out
487 #pragma HLS reset variable=SobelFSM
489 #pragma HLS reset variable=accel_called
490 #pragma HLS reset variable=processed_word_proc
491 #pragma HLS reset variable=timeoutCntAbs
492 #pragma HLS reset variable=cnt_i
493 #pragma HLS reset variable=tmp
494 #pragma HLS reset variable=raw64
495 #pragma HLS reset variable=temp
500 printf(
"DEBUG in pProcPath: WAIT_FOR_META\n");
501 if (!sImageLoaded.empty())
503 if (sImageLoaded.read() ==
true) {
505 accel_called =
false;
506 processed_word_proc = 0;
517 printf(
"DEBUG in pProcPath: PROCESSING_PACKET\n");
519 if ( !img_in_axi_stream.empty() && !img_out_axi_stream.full() )
522 if (accel_called ==
false) {
542 printf(
"DEBUG in pProcPath: SOBEL_RETURN_RESULTS, ddr_addr_out=%u\n", ddr_addr_out);
543 if (accel_called ==
true) {
545 printf(
"DEBUG in pProcPath: Accumulated %u net words (%u B) to complete a single DDR word\n",
555 printf(
"DEBUG in pProcPath: SOBEL_RETURN_RESULTS_ABSORB_DDR_LAT [%u out of %u]\n", timeoutCntAbs,
DDR_LATENCY);
579 printf(
"DEBUG in pProcPath: SOBEL_RETURN_RESULTS_FWD\n");
594 newWord =
NetworkWord(temp.data, temp.keep, temp.last);
595 sRxpToTxp_Data.write(newWord);
606 printf(
"DEBUG in pProcPath: SOBEL_RETURN_RESULTS\n");
607 if ( !img_out_axi_stream.empty() && !sRxpToTxp_Data.full() )
610 temp.data = img_out_axi_stream.read();
611 if ( img_out_axi_stream.empty() )
616 accel_called =
false;
624 newWord =
NetworkWord(temp.data, temp.keep, temp.last);
625 sRxpToTxp_Data.write(newWord);
#define MEMTEST_ADDRESS_HIGH_BIT
ap_uint< 40 > local_mem_addr_t
#define MEMTEST_COMMANDS_HIGH_BIT
#define MEMTEST_ITERATIONS_HIGH_BIT
#define PROCESSING_PACKET
#define MEMTEST_BURST_HIGH_BIT
#define MEMTEST_BURST_LOW_BIT
#define MEMTEST_ADDRESS_LOW_BIT
#define MEMTEST_ITERATIONS_LOW_BIT
#define MEMTEST_COMMANDS_LOW_BIT
#define FSM_PROCESSING_OUTPUT_2
#define FSM_PROCESSING_WAIT_FOR_META
#define ProcessingFsmType
#define FSM_PROCESSING_OUTPUT_3
#define FSM_PROCESSING_WAIT_FOR_DDR_CONTROLLER_EMPTYNESS
#define FSM_PROCESSING_OUTPUT
#define FSM_PROCESSING_CONTINUOUS_RUN
#define FSM_PROCESSING_DATAFLOW_WRITE
void pProcPath(stream< NetworkWord > &sRxpToTxp_Data, stream< TimgIn > &img_in_axi_stream, stream< TimgOut > &img_out_axi_stream, stream< bool > &sImageLoaded)
Processing Path - Main processing FSM for Vitis kernels.
#define SOBEL_RETURN_RESULTS_ABSORB_DDR_LAT
#define SOBEL_RETURN_RESULTS
#define FSM_PROCESSING_OUTPUT_4
#define FSM_PROCESSING_START
#define FSM_PROCESSING_DATAFLOW_READ
#define SOBEL_RETURN_RESULTS_FWD
#define FSM_PROCESSING_BURST_READING
#define FSM_PROCESSING_OUTPUT_5
#define FSM_PROCESSING_PCKT_PROC
void pTHISProcessingData(stream< NetworkWord > &sRxpToProcp_Data, stream< NetworkWord > &sProcpToTxp_Data, stream< NetworkMetaStream > &sRxtoProc_Meta, stream< NetworkMetaStream > &sProctoTx_Meta, bool *start_stop)
THIS processing the data once recieved a start command Template function for custom processing.
void fakeSobelAccelStream(hls::stream< ap_axiu< 256, 0, 0, 0 > > &img_in_axi_stream, hls::stream< ap_axiu< 256, 0, 0, 0 > > &img_out_axi_stream, unsigned int min_rx_loops, unsigned int min_tx_loops)
#define NETWORK_WORD_BIT_WIDTH