29 #ifndef _ROLE_MEMTEST_PATTERN_H_
30 #define _ROLE_MEMTEST_PATTERN_H_
32 #include "../include/memtest_library.hpp"
33 #include "../include/memtest_pattern_library.hpp"
35 #define FAULT_INJECTION
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
56 #define MEMTEST_ADDRESS_BITWIDTH 40
57 #define MEMTEST_ITERATION_BITWIDTH 16
58 #define MEMTEST_BURST_BITWIDTH 16
60 #define MEMTEST_ADDRESS_HIGH_BIT NETWORK_WORD_BIT_WIDTH-1
61 #define MEMTEST_ADDRESS_LOW_BIT NETWORK_WORD_BIT_WIDTH-MEMTEST_ADDRESS_BITWIDTH
63 #define MEMTEST_ITERATIONS_HIGH_BIT MEMTEST_ADDRESS_LOW_BIT-1
64 #define MEMTEST_ITERATIONS_LOW_BIT MEMTEST_ITERATIONS_HIGH_BIT+1-MEMTEST_ITERATION_BITWIDTH
66 #define MEMTEST_BURST_HIGH_BIT MEMTEST_BURST_BITWIDTH-1+MEMTEST_COMMANDS_BITWIDTH
67 #define MEMTEST_BURST_LOW_BIT MEMTEST_BURST_HIGH_BIT+1-MEMTEST_BURST_BITWIDTH
75 template <const
unsigned int maximum_number_of_beats=512>
79 ap_uint<64> * writing_cntr,
80 ap_uint<32> * testCounter,
81 unsigned int burst_size)
83 #pragma HLS INLINE off
84 static hls::stream<ap_uint<64>> sWritePrfCntr_cmd(
"sWritePrfCntr_cmd");
85 #pragma HLS STREAM variable=sWritePrfCntr_cmd depth=64 dim=1
86 static hls::stream<local_mem_word_t> generatedWriteData(
"generatedWriteData");
87 #pragma HLS STREAM variable=generatedWriteData depth=64 dim=1
90 #ifdef SIMPLER_BANDWIDTH_TEST
92 pWriteSimplerTestMemTest<ap_uint<64>>(sWritePrfCntr_cmd,
lcl_mem0, max_address_under_test, burst_size);
94 perfCounterProc2MemCountOnly<ap_uint<64>,ap_uint<64>,64>(sWritePrfCntr_cmd, writing_cntr);
97 pWRGenerateData2WriteOnStream<4000000>(generatedWriteData,testCounter,max_address_under_test);
99 pWRStream2WriteMainMemory<ap_uint<64>,4000000,maximum_number_of_beats>(sWritePrfCntr_cmd, generatedWriteData,
lcl_mem0, max_address_under_test, burst_size);
101 perfCounterMultipleCounts<ap_uint<64>,ap_uint<64>,64>(sWritePrfCntr_cmd, writing_cntr);
106 template <const
unsigned int maximum_number_of_beats=512>
110 ap_uint<64> * reading_cntr,
111 ap_uint<32> * faulty_addresses_cntr,
113 unsigned int burst_size)
115 #pragma HLS INLINE off
117 static hls::stream<ap_uint<64>> sReadPrfCntr_cmd(
"sReadPrfCntr_cmd");
118 #pragma HLS STREAM variable=sReadPrfCntr_cmd depth=maximum_number_of_beats dim=1
119 static hls::stream<local_mem_word_t> generatedReadData(
"generatedReadData");
120 #pragma HLS STREAM variable=generatedReadData depth=maximum_number_of_beats dim=1
121 static hls::stream<local_mem_word_t> sReadData(
"sReadData");
122 #pragma HLS STREAM variable=sReadData depth=maximum_number_of_beats dim=1
123 static hls::stream<local_mem_word_t> sGoldData(
"sGoldData");
124 #pragma HLS STREAM variable=sGoldData depth=maximum_number_of_beats dim=1
126 static hls::stream<ap_uint<64>> sComparisonData(
"sComparisonData");
127 #pragma HLS STREAM variable=sComparisonData depth=64 dim=1
134 #ifdef SIMPLER_BANDWIDTH_TEST
136 pReadSimplerTestMemTest<ap_uint<64>>(sReadPrfCntr_cmd,
lcl_mem1, max_address_under_test, burst_size, faulty_addresses_cntr, first_faulty_address);
138 perfCounterProc2MemCountOnly<ap_uint<64>,ap_uint<64>,64>(sReadPrfCntr_cmd, reading_cntr);
143 pRDRead2StreamDataVariableBurstNoMemCpy<ap_uint<64>,4000000,maximum_number_of_beats>( sReadPrfCntr_cmd, generatedReadData,
lcl_mem1, max_address_under_test,burst_size);
145 pRDReadDataStreamAndProduceGold<4000000>(generatedReadData, max_address_under_test, sReadData, sGoldData);
147 perfCounterMultipleCounts<ap_uint<64>,ap_uint<64>,64>(sReadPrfCntr_cmd, reading_cntr);
150 pRDCmpStreamsCntWordAligned<4000000,maximum_number_of_beats>(max_address_under_test,sReadData, sGoldData,faulty_addresses_cntr, first_faulty_address);
190 template<const
unsigned int counter_w
idth=64>
192 stream<NetworkWord> &sRxpToProcp_Data,
193 stream<NetworkWord> &sProcpToTxp_Data,
194 stream<NetworkMetaStream> &sRxtoProc_Meta,
195 stream<NetworkMetaStream> &sProctoTx_Meta,
207 #pragma HLS INLINE off
214 static ap_uint<16> max_iterations;
218 static ap_uint<32> faulty_addresses_cntr;
221 static size_t bytes_sent_for_tx =0;
223 #pragma HLS reset variable=processingFSM
224 #pragma HLS reset variable=outNetMeta
225 #pragma HLS reset variable=max_iterations
226 #pragma HLS reset variable=first_faulty_address
227 #pragma HLS reset variable=faulty_addresses_cntr
228 #pragma HLS reset variable=max_address_under_test
229 #pragma HLS reset variable=processingFSM
230 #pragma HLS reset variable=bytes_sent_for_tx
232 static ap_uint<32> testCounter;
233 static ap_uint<counter_width> reading_cntr = 0;
234 static ap_uint<counter_width> writing_cntr = 0;
235 static unsigned int burst_size=1;
237 static int emptycntr=0;
239 #pragma HLS reset variable=testCounter
240 #pragma HLS reset variable=tmp_wordaligned_address
241 #pragma HLS reset variable=burst_size
249 #if DEBUG_LEVEL == TRACE_ALL
250 printf(
"DEBUG proc FSM, I am in the WAIT_FOR_META state\n");
253 max_address_under_test = 0;
255 bytes_sent_for_tx = 0;
257 if ( !sRxtoProc_Meta.empty() && !sProctoTx_Meta.full())
259 outNetMeta = sRxtoProc_Meta.read();
260 sProctoTx_Meta.write(outNetMeta);
266 #if DEBUG_LEVEL == TRACE_ALL
267 printf(
"DEBUG proc FSM, I am in the PROCESSING_PCKT_PROC state\n");
270 if ( !sRxpToProcp_Data.empty() && !sProcpToTxp_Data.full())
272 netWord = sRxpToProcp_Data.read();
277 #if DEBUG_LEVEL == TRACE_ALL
278 printf(
"DEBUG processing the packet with invalid cmd\n");
280 sProcpToTxp_Data.write(netWord);
285 #if DEBUG_LEVEL == TRACE_ALL
286 printf(
"DEBUG processing the packet with stop cmd\n");
289 outNetWord.
tkeep = 0xFF;
290 outNetWord.
tlast = 1;
291 sProcpToTxp_Data.write(outNetWord);
296 #if DEBUG_LEVEL == TRACE_ALL
297 printf(
"DEBUG processing the packet with the address within cmd\n");
301 #if DEBUG_LEVEL == TRACE_ALL
302 #ifndef __SYNTHESIS__
303 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());
313 #if DEBUG_LEVEL == TRACE_ALL
314 printf(
"DEBUG proc FSM, I am in the FSM_PROCESSING_BURST_READING state\n");
317 if ( !sRxpToProcp_Data.empty())
319 netWord = sRxpToProcp_Data.read();
320 #if DEBUG_LEVEL == TRACE_ALL
321 std::cout << netWord.
tdata.to_string() << std::endl;
329 #if DEBUG_LEVEL == TRACE_ALL
330 printf(
"DEBUG processing the packet with burst cmd, and burst size=%u\n",burst_size);
338 #if DEBUG_LEVEL == TRACE_ALL
339 #ifndef __SYNTHESIS__
344 sProcpToTxp_Data.write(netWord);
354 #if DEBUG_LEVEL == TRACE_ALL
355 printf(
"DEBUG proc FSM, I am in the START state\n");
358 first_faulty_address = 0;
359 faulty_addresses_cntr = 0;
360 if(max_address_under_test%64==0){
361 tmp_wordaligned_address = max_address_under_test/64;
363 tmp_wordaligned_address = (max_address_under_test/64+1);
365 #if DEBUG_LEVEL == TRACE_ALL
366 #ifndef __SYNTHESIS__
367 std::cout <<
" testing the address word aligned" << tmp_wordaligned_address.to_string() << std::endl;
381 faulty_addresses_cntr = 0;
382 first_faulty_address = 0;
385 if(*start_stop && testCounter < max_iterations){
386 #if DEBUG_LEVEL == TRACE_ALL
387 #ifndef __SYNTHESIS__
388 printf(
"DEBUG processing continuous run (still run, iter %s) max iters: %s\n",testCounter.to_string().c_str(),max_iterations.to_string().c_str());
394 sProctoTx_Meta.write(outNetMeta);
395 #if DEBUG_LEVEL == TRACE_ALL
396 std::cout <<
"DEBUG: writing an additional meta with bytes sent equal to " << bytes_sent_for_tx << std::endl;
398 bytes_sent_for_tx = 0;
404 #if DEBUG_LEVEL == TRACE_ALL
405 #ifndef __SYNTHESIS__
406 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());
412 outNetWord.
tkeep = 0xFF;
413 outNetWord.
tlast = 1;
414 sProcpToTxp_Data.write(outNetWord);
426 #if DEBUG_LEVEL == TRACE_ALL
427 printf(
"DEBUG processing write dataflow\n");
429 pWriteDataflowMemTest<top_param_maximum_number_of_beats>(
lcl_mem0,
430 tmp_wordaligned_address , &writing_cntr,&testCounter,burst_size);
435 #if DEBUG_LEVEL == TRACE_ALL
436 printf(
"DEBUG processing the output of a run\n");
446 #if DEBUG_LEVEL == TRACE_ALL
447 printf(
"DEBUG processing read dataflow\n");
449 pReadDataflowMemTest<top_param_maximum_number_of_beats>(
lcl_mem1,
450 tmp_wordaligned_address ,&reading_cntr,&faulty_addresses_cntr, &first_faulty_address,burst_size);
460 #if DEBUG_LEVEL == TRACE_ALL
461 printf(
"DEBUG processing the output of a run\n");
463 if(!sProcpToTxp_Data.full()){
464 outNetWord.
tdata = max_address_under_test;
465 outNetWord.
tkeep = 0xFF;
466 outNetWord.
tlast = 0;
467 sProcpToTxp_Data.write(outNetWord);
468 bytes_sent_for_tx += 8;
474 #if DEBUG_LEVEL == TRACE_ALL
475 #ifndef __SYNTHESIS__
476 printf(
"DEBUG processing the output of a run part 2; faulty address cntr %s\n",faulty_addresses_cntr.to_string().c_str());
479 if(!sProcpToTxp_Data.full()){
480 outNetWord.
tdata=faulty_addresses_cntr;
481 outNetWord.
tkeep = 0xFF;
482 outNetWord.
tlast = 0;
483 sProcpToTxp_Data.write(outNetWord);
484 bytes_sent_for_tx += 8 ;
489 #if DEBUG_LEVEL == TRACE_ALL
490 #ifndef __SYNTHESIS__
491 printf(
"DEBUG processing the output of a run part 3: first faulty address %s\n",first_faulty_address.to_string().c_str());
494 if(!sProcpToTxp_Data.full()){
495 outNetWord.
tdata=first_faulty_address;
496 outNetWord.
tkeep = 0xFF;
497 outNetWord.
tlast = 0;
498 sProcpToTxp_Data.write(outNetWord);
499 bytes_sent_for_tx += 8;
504 #if DEBUG_LEVEL == TRACE_ALL
505 printf(
"DEBUG processing the output of a run part 4\n");
507 if(!sProcpToTxp_Data.full()){
508 outNetWord.
tdata = writing_cntr;
509 outNetWord.
tkeep = 0xFF;
510 outNetWord.
tlast = 0;
511 sProcpToTxp_Data.write(outNetWord);
512 bytes_sent_for_tx += 8;
517 #if DEBUG_LEVEL == TRACE_ALL
518 printf(
"DEBUG processing the output of a run part 4\n");
520 if(!sProcpToTxp_Data.full()){
521 outNetWord.
tdata= reading_cntr;
522 outNetWord.
tkeep = 0xFF;
523 outNetWord.
tlast = 0;
524 sProcpToTxp_Data.write(outNetWord);
525 bytes_sent_for_tx += 8;
#define FSM_PROCESSING_OUTPUT_2
#define FSM_PROCESSING_WAIT_FOR_META
#define MEMTEST_ADDRESS_HIGH_BIT
ap_uint< 40 > local_mem_addr_t
#define ProcessingFsmType
#define FSM_PROCESSING_OUTPUT_3
#define MEMTEST_COMMANDS_HIGH_BIT
#define FSM_PROCESSING_WAIT_FOR_DDR_CONTROLLER_EMPTYNESS
#define FSM_PROCESSING_OUTPUT
#define FSM_PROCESSING_CONTINUOUS_RUN
#define FSM_PROCESSING_DATAFLOW_WRITE
#define MEMTEST_ITERATIONS_HIGH_BIT
void pReadDataflowMemTest(membus_t *lcl_mem1, local_mem_addr_t max_address_under_test, ap_uint< 64 > *reading_cntr, ap_uint< 32 > *faulty_addresses_cntr, local_mem_addr_t *first_faulty_address, unsigned int burst_size)
#define FSM_PROCESSING_OUTPUT_4
#define MEMTEST_BURST_HIGH_BIT
#define FSM_PROCESSING_START
#define MEMTEST_BURST_LOW_BIT
const unsigned int top_param_maximum_number_of_beats
#define MEMTEST_ADDRESS_LOW_BIT
#define FSM_PROCESSING_DATAFLOW_READ
void pWriteDataflowMemTest(membus_t *lcl_mem0, local_mem_addr_t max_address_under_test, ap_uint< 64 > *writing_cntr, ap_uint< 32 > *testCounter, unsigned int burst_size)
#define FSM_PROCESSING_BURST_READING
#define MEMTEST_ITERATIONS_LOW_BIT
#define FSM_PROCESSING_OUTPUT_5
#define FSM_PROCESSING_PCKT_PROC
#define MEMTEST_COMMANDS_LOW_BIT
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.
#define NETWORK_WORD_BIT_WIDTH