43 #ifndef _ROLE_MEMTEST_LIBRARY_HPP_
44 #define _ROLE_MEMTEST_LIBRARY_HPP_
48 #include <hls_stream.h>
51 #include "../../../../../HOST/custom/memtest/languages/cplusplus/include/config.h"
74 stream<NodeId> &sDstNode_sig,
75 ap_uint<32> *po_rx_ports
79 #pragma HLS INLINE off
82 #pragma HLS reset variable=port_fsm
89 if(!sDstNode_sig.full())
91 NodeId dst_rank = (*pi_rank + 1) % *pi_size;
92 #if DEBUG_LEVEL == TRACE_ALL
93 printf(
"rank: %d; size: %d; \n", (
int) *pi_rank, (
int) *pi_size);
95 sDstNode_sig.write(dst_rank);
122 stream<NetworkWord> &siSHL_This_Data,
123 stream<NetworkMetaStream> &siNrc_meta,
124 stream<NetworkMetaStream> &sRxtoProc_Meta,
125 stream<NetworkWord> &sRxpToProcp_Data,
128 unsigned int *processed_word_rx,
129 unsigned int *processed_bytes_rx
133 #pragma HLS INLINE off
138 #pragma HLS reset variable=enqueueFSM
142 ap_uint<16> max_iterations;
143 static bool start_stop_local =
false;
144 static bool prev_was_start =
false;
145 #pragma HLS reset variable=start_stop_local
147 *start_stop = start_stop_local;
151 #if DEBUG_LEVEL == TRACE_ALL
152 printf(
"DEBUG in pRXPath: enqueueFSM - WAIT_FOR_META, *processed_word_rx=%u, *processed_bytes_rx=%u\n",
153 *processed_word_rx, *processed_bytes_rx);
155 if ( !siNrc_meta.empty() && !sRxtoProc_Meta.full() )
157 meta_tmp = siNrc_meta.read();
159 sRxtoProc_Meta.write(meta_tmp);
165 #if DEBUG_LEVEL == TRACE_ALL
166 printf(
"DEBUG in pRXPath: enqueueFSM - PROCESSING_PACKET, *processed_word_rx=%u, *processed_bytes_rx=%u\n",
167 *processed_word_rx, *processed_bytes_rx);
170 if ( !siSHL_This_Data.empty() && !sRxpToProcp_Data.full() )
173 netWord = siSHL_This_Data.read();
178 start_stop_local=
true;
180 sRxpToProcp_Data.write(netWord);
182 #if DEBUG_LEVEL == TRACE_ALL
183 printf(
"Hallo, I received a start command :D\n");
187 start_stop_local=
false;
191 sRxpToProcp_Data.write(netWord);
192 prev_was_start=
false;
193 #if DEBUG_LEVEL == TRACE_ALL
194 printf(
"Hallo, I received a stop command D:\n");
199 #if DEBUG_LEVEL == TRACE_ALL
200 printf(
"Hallo, I received a burst size command :), and prev_was_start=%u\n",prev_was_start);
204 sRxpToProcp_Data.write(netWord);
208 sRxpToProcp_Data.write(netWord);
210 prev_was_start=
false;
213 if (start_stop_local)
219 prev_was_start=
false;
220 sRxpToProcp_Data.write(netWord);
227 if(netWord.
tlast == 1)
252 stream<NetworkWord> &soTHIS_Shl_Data,
253 stream<NetworkMetaStream> &soNrc_meta,
254 stream<NetworkWord> &sProcpToTxp_Data,
255 stream<NetworkMetaStream> &sRxtoTx_Meta,
256 stream<NodeId> &sDstNode_sig,
257 unsigned int *processed_word_tx,
263 #pragma HLS INLINE off
269 #pragma HLS reset variable=dequeueFSM
274 if(!sDstNode_sig.empty())
276 dst_rank = sDstNode_sig.read();
282 #if DEBUG_LEVEL == TRACE_ALL
283 printf(
"DEBUG in pTXPath: dequeueFSM=%d - WAIT_FOR_STREAM_PAIR, *processed_word_tx=%u\n",
287 *processed_word_tx = 0;
289 if (( !sProcpToTxp_Data.empty() && !sRxtoTx_Meta.empty()
290 && !soTHIS_Shl_Data.full() && !soNrc_meta.full() ))
292 netWordTx = sProcpToTxp_Data.read();
299 soTHIS_Shl_Data.write(netWordTx);
301 meta_in = sRxtoTx_Meta.read().tdata;
303 meta_out_stream.
tlast = 1;
304 meta_out_stream.
tkeep = 0xFF;
311 soNrc_meta.write(meta_out_stream);
313 (*processed_word_tx)++;
315 if(netWordTx.
tlast != 1)
323 #if DEBUG_LEVEL == TRACE_ALL
324 printf(
"DEBUG in pTXPath: dequeueFSM=%d - PROCESSING_PACKET, *processed_word_tx=%u\n",
327 if( !sProcpToTxp_Data.empty() && !soTHIS_Shl_Data.full())
329 netWordTx = sProcpToTxp_Data.read();
332 if(netWordTx.
tlast == 1)
340 (*processed_word_tx)++;
341 if (((*processed_word_tx)*8) %
PACK_SIZE == 0)
347 soTHIS_Shl_Data.write(netWordTx);
372 template<
typename Tin,
typename Tout,
unsigned int arraysize>
375 for (
unsigned int i = 0; i < arraysize; i++)
377 #pragma HLS PIPELINE II=1
397 template<
typename Tin,
typename Tout, const
unsigned int arraysize>
401 circ_buff_loop:
for (
unsigned int i = 0; i < elems; i++)
403 #pragma HLS PIPELINE II=1
404 #pragma HLS LOOP_TRIPCOUNT min = 1 max = arraysize
405 if(offset_buff+j==arraysize)
409 out_mem[i] = buff[0];
411 out_mem[i] = buff[offset_buff+j];
431 template<
typename Tin,
typename Tout, const
unsigned int burstsize>
434 mmloop:
for (
unsigned int i = 0; i < elems; i++)
436 #pragma HLS PIPELINE II=1
437 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
438 Tout
tmp = main_mem[i];
460 template<
typename Tin,
typename Tout, const
unsigned int burstsize,
typename Tcntr>
464 mmloop:
for (
unsigned int i = 0; i < elems; i++)
466 #pragma HLS PIPELINE II=1
467 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
468 Tout
tmp = main_mem[i];
490 template<
typename Tin,
typename Tout, const
unsigned int burstsize,
typename Tcntr>
494 mmloop:
for (
unsigned int i = 0; i < elems; i++)
496 #pragma HLS PIPELINE II=1
497 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
498 Tout
tmp = main_mem[i];
519 template<
typename Tin,
typename Tout, const
unsigned int burstsize,
typename Tcntr>
522 cmd.write(activated);
523 mmloop:
for (
unsigned int i = 0; i < elems; i++)
525 #pragma HLS PIPELINE II=1
526 #pragma HLS LOOP_TRIPCOUNT min = 1 max = burstsize
527 Tout
tmp = main_mem[i];
545 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
546 void perfCounterProc(hls::stream<Tin>& cmd, hls::stream<Tout>&
out,
int direction,
int burst_length,
int nmbr_outstanding)
548 #pragma HLS INLINE off
552 ap_uint<counter_precision> cnt = cmd.read();
555 while (cmd.read_nb(input_cmd) ==
false) {
557 #if DEBUG_LEVEL == TRACE_ALL
558 #ifndef __SYNTHESIS__
559 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
580 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
585 ap_uint<counter_precision> cnt = cmd.read();
588 while (cmd.read_nb(input_cmd) ==
false) {
589 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
592 #if DEBUG_LEVEL == TRACE_ALL
593 #ifndef __SYNTHESIS__
594 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
614 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
619 ap_uint<counter_precision> cnt = cmd.read();
622 while (cmd.read_nb(input_cmd) ==
false) {
623 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
626 #if DEBUG_LEVEL == TRACE_ALL
627 #ifndef __SYNTHESIS__
628 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
650 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
655 ap_uint<counter_precision> cnt = cmd.read();
658 while (cmd.read_nb(input_cmd) ==
false) {
659 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
661 #if DEBUG_LEVEL == TRACE_ALL
662 #ifndef __SYNTHESIS__
663 printf(
"DEBUG perfCounterProc counter value = %s\n", cnt.to_string().c_str());
682 template<
typename Tin,
typename Tout,
unsigned int counter_precision=64>
684 #pragma HLS interface ap_ctrl_none port=return
688 ap_uint<counter_precision> cnt = cmd.read();
690 while (input_cmd != 0)
692 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
693 #if DEBUG_LEVEL == TRACE_ALL
694 #ifndef __SYNTHESIS__
700 while (cmd.read_nb(input_cmd) ==
false) {
701 #pragma HLS LOOP_TRIPCOUNT min = 1 max = max_counter_cc
702 #pragma HLS PIPELINE II=1
704 #if DEBUG_LEVEL == TRACE_ALL
705 #ifndef __SYNTHESIS__
710 input_cmd=cmd.read();
729 template<
typename Tevent=
bool, const
unsigned int counter_w
idth=32, const
unsigned int maximum_counter_value_before_reset=4000000>
731 hls::stream<Tevent> &sOfEnableCCIncrement,
732 hls::stream<Tevent> &sOfResetCounter,
733 hls::stream<Tevent> &sOfGetTheCounter,
734 hls::stream<ap_uint<counter_width> > &oSClockCounter)
737 static ap_uint<counter_width> internal_counter = 0;
738 static bool pop_the_counter =
false;
739 #pragma HLS reset variable=internal_counter
740 #pragma HLS reset variable=pop_the_counter
742 if(!sOfGetTheCounter.empty()){
743 pop_the_counter = sOfGetTheCounter.read();
745 if (pop_the_counter && !oSClockCounter.full())
747 oSClockCounter.write(internal_counter);
748 pop_the_counter=
false;
750 if(!sOfResetCounter.empty()){
751 bool reset_or_not = sOfResetCounter.read();
754 internal_counter = 0;
757 if(!sOfEnableCCIncrement.empty()){
758 bool increment = sOfEnableCCIncrement.read();
761 if(internal_counter==maximum_counter_value_before_reset){
766 #if DEBUG_LEVEL == TRACE_ALL
767 #ifndef __SYNTHESIS__
768 printf(
"DEBUG pCountClockCycles counter value = %s\n", internal_counter.to_string().c_str());
void pPortAndDestionation(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NodeId > &sDstNode_sig, ap_uint< 32 > *po_rx_ports)
pPortAndDestionation - Setup the port and the destination rank.
const unsigned long int max_counter_cc
#define FSM_WRITE_NEW_DATA
void pCountClockCycles(hls::stream< Tevent > &sOfEnableCCIncrement, hls::stream< Tevent > &sOfResetCounter, hls::stream< Tevent > &sOfGetTheCounter, hls::stream< ap_uint< counter_width > > &oSClockCounter)
Count Clock Cycles between two events first sketch TODO: make it working without counting with the st...
void pRXPath(stream< NetworkWord > &siSHL_This_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &sRxtoProc_Meta, stream< NetworkWord > &sRxpToProcp_Data, NetworkMetaStream meta_tmp, bool *start_stop, unsigned int *processed_word_rx, unsigned int *processed_bytes_rx)
Receive Path - From SHELL to THIS.
#define MEMTEST_COMMANDS_HIGH_BIT
void perfCounterProc2MemCountIncremental(hls::stream< Tin > &cmd, Tout *out)
Count Clock Cycles between two events, the first event init the counter the second stop the count and...
void perfCounterMultipleCounts(hls::stream< Tin > &cmd, Tout *out)
Count Clock Cycles between two events, the first event init the counter the second stop the count,...
void pTXPath(stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &soNrc_meta, stream< NetworkWord > &sProcpToTxp_Data, stream< NetworkMetaStream > &sRxtoTx_Meta, stream< NodeId > &sDstNode_sig, unsigned int *processed_word_tx, ap_uint< 32 > *pi_rank)
Transmit Path - From THIS to SHELL.
#define PROCESSING_PACKET
void perfCounterProc2Mem(hls::stream< Tin > &cmd, Tout *out, int direction, int burst_length, int nmbr_outstanding)
#define WAIT_FOR_STREAM_PAIR
void pReadAxiMemMapped2HlsStreamCountFirst(Tin *main_mem, hls::stream< Tout > &sOut, unsigned int elems, hls::stream< Tcntr > &cmd)
Copy a run-time variable amount of data to an hls stream with a given max it assumes also the initial...
void perfCounterProc2MemCountOnly(hls::stream< Tin > &cmd, Tout *out)
Count Clock Cycles between two events, the first event init the counter the second stop the count.
void pReadAxiMemMapped2HlsStream(Tin *main_mem, hls::stream< Tout > &sOut, unsigned int elems)
Copy a run-time variable amount of data to an hls stream with a given max.
void perfCounterProc(hls::stream< Tin > &cmd, hls::stream< Tout > &out, int direction, int burst_length, int nmbr_outstanding)
void pMyMemtestMemCpy(Tin *in, Tout *out)
Copy a fixed compile time amount of data to another array.
void pReadAxiMemMapped2HlsStreamCountActivated(Tin *main_mem, hls::stream< Tout > &sOut, unsigned int elems, hls::stream< Tcntr > &cmd)
Copy a run-time variable amount of data to an hls stream with a given max it assumes "perfCounterMult...
void pMemCpyCircularBuff(Tin *buff, Tout *out_mem, unsigned int elems, unsigned int offset_buff)
Copy a run-time variable amount of data to another array employing the src as circular buffer i....
void pReadAxiMemMapped2HlsStreamCountExtern(Tin *main_mem, hls::stream< Tout > &sOut, unsigned int elems, hls::stream< Tcntr > &cmd, bool activated)
Copy a run-time variable amount of data to an hls stream with a given max it assumes "perfCounterMult...
#define MEMTEST_COMMANDS_LOW_BIT