cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
mem_test_flash.hpp File Reference
#include <stdint.h>
#include <stdio.h>
#include <hls_stream.h>
#include "ap_int.h"
#include "dynamic.hpp"
Include dependency graph for mem_test_flash.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Axis< D >
 
struct  DmCmd
 
struct  DmSts
 

Macros

#define FSM_IDLE   0
 
#define FSM_WR_PAT_CMD   1
 
#define FSM_WR_PAT_DATA   2
 
#define FSM_WR_PAT_STS   3
 
#define FSM_RD_PAT_CMD   4
 
#define FSM_RD_PAT_DATA   5
 
#define FSM_RD_PAT_STS   6
 
#define FSM_WR_ANTI_CMD   7
 
#define FSM_WR_ANTI_DATA   8
 
#define FSM_WR_ANTI_STS   9
 
#define FSM_RD_ANTI_CMD   10
 
#define FSM_RD_ANTI_DATA   11
 
#define FSM_RD_ANTI_STS   12
 
#define PHASE_IDLE   0
 
#define PHASE_RAMP_WRITE   1
 
#define PHASE_RAMP_READ   2
 
#define PHASE_STRESS   3
 
#define MEM_START_ADDR   0x000000000
 
#define CHECK_CHUNK_SIZE   0x1000
 
#define BYTE_PER_MEM_WORD   64
 
#define TRANSFERS_PER_CHUNK   (CHECK_CHUNK_SIZE/BYTE_PER_MEM_WORD)
 
#define CYCLES_UNTIL_TIMEOUT   0x1000
 

Functions

void mem_test_flash_main (ap_uint< 1 > sys_reset, ap_uint< 2 > DIAG_CTRL_IN, ap_uint< 2 > *DIAG_STAT_OUT, ap_uint< 16 > *debug_out, stream< DmCmd > &soMemRdCmdP0, stream< DmSts > &siMemRdStsP0, stream< Axis< 512 > > &siMemReadP0, stream< DmCmd > &soMemWrCmdP0, stream< DmSts > &siMemWrStsP0, stream< Axis< 512 > > &soMemWriteP0)
 

Macro Definition Documentation

◆ BYTE_PER_MEM_WORD

#define BYTE_PER_MEM_WORD   64

Definition at line 70 of file mem_test_flash.hpp.

◆ CHECK_CHUNK_SIZE

#define CHECK_CHUNK_SIZE   0x1000

Definition at line 69 of file mem_test_flash.hpp.

◆ CYCLES_UNTIL_TIMEOUT

#define CYCLES_UNTIL_TIMEOUT   0x1000

Definition at line 75 of file mem_test_flash.hpp.

◆ FSM_IDLE

#define FSM_IDLE   0

Definition at line 33 of file mem_test_flash.hpp.

◆ FSM_RD_ANTI_CMD

#define FSM_RD_ANTI_CMD   10

Definition at line 43 of file mem_test_flash.hpp.

◆ FSM_RD_ANTI_DATA

#define FSM_RD_ANTI_DATA   11

Definition at line 44 of file mem_test_flash.hpp.

◆ FSM_RD_ANTI_STS

#define FSM_RD_ANTI_STS   12

Definition at line 45 of file mem_test_flash.hpp.

◆ FSM_RD_PAT_CMD

#define FSM_RD_PAT_CMD   4

Definition at line 37 of file mem_test_flash.hpp.

◆ FSM_RD_PAT_DATA

#define FSM_RD_PAT_DATA   5

Definition at line 38 of file mem_test_flash.hpp.

◆ FSM_RD_PAT_STS

#define FSM_RD_PAT_STS   6

Definition at line 39 of file mem_test_flash.hpp.

◆ FSM_WR_ANTI_CMD

#define FSM_WR_ANTI_CMD   7

Definition at line 40 of file mem_test_flash.hpp.

◆ FSM_WR_ANTI_DATA

#define FSM_WR_ANTI_DATA   8

Definition at line 41 of file mem_test_flash.hpp.

◆ FSM_WR_ANTI_STS

#define FSM_WR_ANTI_STS   9

Definition at line 42 of file mem_test_flash.hpp.

◆ FSM_WR_PAT_CMD

#define FSM_WR_PAT_CMD   1

Definition at line 34 of file mem_test_flash.hpp.

◆ FSM_WR_PAT_DATA

#define FSM_WR_PAT_DATA   2

Definition at line 35 of file mem_test_flash.hpp.

◆ FSM_WR_PAT_STS

#define FSM_WR_PAT_STS   3

Definition at line 36 of file mem_test_flash.hpp.

◆ MEM_START_ADDR

#define MEM_START_ADDR   0x000000000

Definition at line 55 of file mem_test_flash.hpp.

◆ PHASE_IDLE

#define PHASE_IDLE   0

Definition at line 49 of file mem_test_flash.hpp.

◆ PHASE_RAMP_READ

#define PHASE_RAMP_READ   2

Definition at line 51 of file mem_test_flash.hpp.

◆ PHASE_RAMP_WRITE

#define PHASE_RAMP_WRITE   1

Definition at line 50 of file mem_test_flash.hpp.

◆ PHASE_STRESS

#define PHASE_STRESS   3

Definition at line 52 of file mem_test_flash.hpp.

◆ TRANSFERS_PER_CHUNK

#define TRANSFERS_PER_CHUNK   (CHECK_CHUNK_SIZE/BYTE_PER_MEM_WORD)

Definition at line 71 of file mem_test_flash.hpp.

Function Documentation

◆ mem_test_flash_main()

void mem_test_flash_main ( ap_uint< 1 >  sys_reset,
ap_uint< 2 >  DIAG_CTRL_IN,
ap_uint< 2 > *  DIAG_STAT_OUT,
ap_uint< 16 > *  debug_out,
stream< DmCmd > &  soMemRdCmdP0,
stream< DmSts > &  siMemRdStsP0,
stream< Axis< 512 > > &  siMemReadP0,
stream< DmCmd > &  soMemWrCmdP0,
stream< DmSts > &  siMemWrStsP0,
stream< Axis< 512 > > &  soMemWriteP0 
)

Definition at line 48 of file mem_test_flash.cpp.

72 {
73 
74 #pragma HLS INTERFACE ap_vld register port=sys_reset name=piSysReset
75 #pragma HLS INTERFACE ap_vld register port=DIAG_CTRL_IN name=piMMIO_diag_ctrl
76 #pragma HLS INTERFACE ap_ovld register port=DIAG_STAT_OUT name=poMMIO_diag_stat
77 #pragma HLS INTERFACE ap_ovld register port=debug_out name=poDebug
78 
79  // Bundling: SHELL / Role / Mem / Mp0 / Read Interface
80 #pragma HLS INTERFACE axis register both port=soMemRdCmdP0
81 #pragma HLS INTERFACE axis register both port=siMemRdStsP0
82 #pragma HLS INTERFACE axis register both port=siMemReadP0
83 
84 #pragma HLS DATA_PACK variable=soMemRdCmdP0 instance=soMemRdCmdP0
85 #pragma HLS DATA_PACK variable=siMemRdStsP0 instance=siMemRdStsP0
86 
87  // Bundling: SHELL / Role / Mem / Mp0 / Write Interface
88 #pragma HLS INTERFACE axis register both port=soMemWrCmdP0
89 #pragma HLS INTERFACE axis register both port=siMemWrStsP0
90 #pragma HLS INTERFACE axis register both port=soMemWriteP0
91 
92 #pragma HLS DATA_PACK variable=soMemWrCmdP0 instance=soMemWrCmdP0
93 #pragma HLS DATA_PACK variable=siMemWrStsP0 instance=siMemWrStsP0
94 
95 
96 
97  Axis<512> memP0;
98  DmSts memRdStsP0;
99  DmSts memWrStsP0;
100 
101  //initalize
102  memP0.tdata = 0;
103  memP0.tlast = 0;
104  memP0.tkeep = 0;
105 
106 
107  if(sys_reset == 1)
108  {
109  fsmState = FSM_IDLE;
110  runContiniously = false;
111  wasError = 0;
112  //lastCheckedAddress = 0;
113  lastCheckedAddress = MEM_END_ADDR + 1; //to stop the test
115  currentMemPattern = 0;
116  patternWriteNum = 0;
117  debugVec = 0;
119  timeoutCnt = 0;
120  return;
121  }
122 
123 
124  switch(fsmState) {
125 
126  case FSM_IDLE:
127  switch(DIAG_CTRL_IN) {
128  case 0x3: //reserved --> idle
129  case 0x0: //stay IDLE, stop test
130  *DIAG_STAT_OUT = (0 << 1) | wasError;
131  runContiniously = false;
133  break;
134  case 0x2:
135  runContiniously = true;
136  //NO break
137  case 0x1: //Run once
139  { // start new test
140  wasError = 0;
143  *DIAG_STAT_OUT = 0b10;
144  debugVec = 0;
146  currentMemPattern = 0;
147  } else if(lastCheckedAddress >= MEM_END_ADDR)
148  {//checked space completely once
149 
151  {
155  currentMemPattern = 0;
156  } else if(testPhase == PHASE_RAMP_READ)
157  {
161  currentMemPattern = 0;
162  } else if (runContiniously)
163  {
166  currentMemPattern = 0;
168  *DIAG_STAT_OUT = (1 << 1) | wasError;
169  } else { //stay here
170  fsmState = FSM_IDLE;
171  *DIAG_STAT_OUT = (0 << 1) | wasError;
172  }
173  } else { //continue current run
174 
176  {
178  } else {
180  }
181 
182  *DIAG_STAT_OUT = (1 << 1) | wasError;
183  if(testPhase == PHASE_STRESS)
184  {
185  currentMemPattern = 0;
186  }
187  }
188  break;
189  }
190 
191  //stop on error
192  if(wasError == 1)
193  {
194  fsmState = FSM_IDLE;
195  *DIAG_STAT_OUT = (0 << 1) | wasError;
196  }
197 
198  //set current address
200  {
202  } else {
204  }
205  break;
206 
207  case FSM_WR_PAT_CMD:
208  if (!soMemWrCmdP0.full()) {
209  //-- Post a memory write command to SHELL/Mem/Mp0
210  soMemWrCmdP0.write(DmCmd(currentPatternAdderss, CHECK_CHUNK_SIZE));
211  patternWriteNum = 0;
213  }
214  break;
215 
216  case FSM_WR_PAT_DATA:
217  if (!soMemWriteP0.full()) {
218  //-- Assemble a memory word and write it to DRAM
221  ap_uint<8> keepVal = 0xFF;
222  memP0.tkeep = (ap_uint<64>) (keepVal, keepVal, keepVal, keepVal, keepVal, keepVal, keepVal, keepVal);
223  //memP0.tkeep = (ap_uint<64>) (0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF);
224 
226  {
227  memP0.tlast = 1;
229  timeoutCnt = 0;
230  } else {
231  memP0.tlast = 0;
232  }
233  soMemWriteP0.write(memP0);
234  patternWriteNum++;
235  }
236  break;
237 
238  case FSM_WR_PAT_STS:
239  if (!siMemWrStsP0.empty()) {
240  //-- Get the memory write status for Mem/Mp0
241  siMemWrStsP0.read(memWrStsP0);
242  //latch errors
243  debugVec |= (ap_uint<16>) STS_to_Vector(memWrStsP0);
244 
246  {
247  fsmState = FSM_IDLE;
248  debugVec |= ((ap_uint<16>) STS_to_Vector(memRdStsP0) )<< 8;
250  } else {
252  currentMemPattern = 0;
253  }
254  } else {
255  timeoutCnt++;
257  {
258  wasError = 1;
259  fsmState = FSM_IDLE;
260  }
261  }
262 
263  break;
264 
265  case FSM_RD_PAT_CMD:
266  if (!soMemRdCmdP0.full()) {
267  //-- Post a memory read command to SHELL/Mem/Mp0
268  soMemRdCmdP0.write(DmCmd(currentPatternAdderss, CHECK_CHUNK_SIZE));
270  }
271  break;
272 
273  case FSM_RD_PAT_DATA:
274  if (!siMemReadP0.empty()) {
275  //-- Read a memory word from DRAM
276  siMemReadP0.read(memP0);
279  {
280  printf("error in pattern reading!\n");
281  wasError = 1;
282  }
283  /*if (memP0.tkeep != (0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF))
284  {
285  printf("error in tkeep\n");
286  }*/
287  //I trust that there will be a tlast (so no counting)
288  if (memP0.tlast == 1)
289  {
291  timeoutCnt = 0;
292  }
293  }
294  break;
295 
296  case FSM_RD_PAT_STS:
297  if (!siMemRdStsP0.empty()) {
298  //-- Get the memory read status for Mem/Mp0
299  siMemRdStsP0.read(memRdStsP0);
300  //latch errors
301  debugVec |= ((ap_uint<16>) STS_to_Vector(memRdStsP0) )<< 8;
302 
304  {
305  fsmState = FSM_IDLE;
306  debugVec |= ((ap_uint<16>) STS_to_Vector(memRdStsP0) )<< 8;
308  } else {
310  currentMemPattern = 0;
311  }
312  } else {
313  timeoutCnt++;
315  {
316  wasError = 1;
317  fsmState = FSM_IDLE;
318  }
319  }
320  break;
321 
322  case FSM_WR_ANTI_CMD:
323  if (!soMemWrCmdP0.full()) {
324  //-- Post a memory write command to SHELL/Mem/Mp0
325  soMemWrCmdP0.write(DmCmd(currentPatternAdderss, CHECK_CHUNK_SIZE));
326  currentMemPattern = 0;
327  patternWriteNum = 0;
329  }
330  break;
331 
332  case FSM_WR_ANTI_DATA:
333  if (!soMemWriteP0.full()) {
334  //-- Assemble a memory word and write it to DRAM
336  ap_uint<64> currentAntiPattern = ~currentMemPattern;
337  //debug
338  //printf("AntiPattern: 0x%llX\n", (uint64_t) currentAntiPattern);
339 
340  memP0.tdata = (currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern);
341  ap_uint<8> keepVal = 0xFF;
342  memP0.tkeep = (ap_uint<64>) (keepVal, keepVal, keepVal, keepVal, keepVal, keepVal, keepVal, keepVal);
343  //memP0.tkeep = (0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF);
344 
346  {
347  memP0.tlast = 1;
349  timeoutCnt = 0;
350  } else {
351  memP0.tlast = 0;
352  }
353  soMemWriteP0.write(memP0);
354  patternWriteNum++;
355  }
356  break;
357 
358  case FSM_WR_ANTI_STS:
359  if (!siMemWrStsP0.empty()) {
360  //-- Get the memory write status for Mem/Mp0
361  siMemWrStsP0.read(memWrStsP0);
362  //latch errors
363  debugVec |= (ap_uint<16>) STS_to_Vector(memWrStsP0);
365  } else {
366  timeoutCnt++;
368  {
369  wasError = 1;
370  fsmState = FSM_IDLE;
371  }
372  }
373  break;
374 
375  case FSM_RD_ANTI_CMD:
376  if (!soMemRdCmdP0.full()) {
377  //-- Post a memory read command to SHELL/Mem/Mp0
378  soMemRdCmdP0.write(DmCmd(currentPatternAdderss, CHECK_CHUNK_SIZE));
379  currentMemPattern = 0;
381  }
382  break;
383 
384  case FSM_RD_ANTI_DATA:
385  if (!siMemReadP0.empty()) {
386  //-- Read a memory word from DRAM
387  siMemReadP0.read(memP0);
389  ap_uint<64> currentAntiPattern = ~currentMemPattern;
390 
391  if (memP0.tdata != ((ap_uint<512>) (currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern,currentAntiPattern)) )
392  {
393  printf("error in antipattern reading!\n");
394  wasError = 1;
395  }
396  /*if (memP0.tkeep != (0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF))
397  {
398  printf("error in tkeep\n");
399  }*/
400  //I trust that there will be a tlast (so no counting)
401  if (memP0.tlast == 1)
402  {
404  timeoutCnt = 0;
405  }
406  }
407  break;
408 
409  case FSM_RD_ANTI_STS:
410  if (!siMemRdStsP0.empty()) {
411  //-- Get the memory read status for Mem/Mp0
412  siMemRdStsP0.read(memRdStsP0);
413  //latch errors
414  debugVec |= ((ap_uint<16>) STS_to_Vector(memRdStsP0) )<< 8;
416  fsmState = FSM_IDLE;
417  } else {
418  timeoutCnt++;
420  {
421  wasError = 1;
422  fsmState = FSM_IDLE;
423  }
424  }
425  break;
426 
427  } // End: switch
428 
429  *debug_out = debugVec;
430 
431  return;
432 }
ap_uint< 8 > testPhase
ap_uint< 8 > STS_to_Vector(DmSts sts)
ap_uint< 16 > debugVec
ap_uint< 1 > wasError
ap_uint< 33 > lastCheckedAddress
ap_uint< 32 > timeoutCnt
ap_uint< 32 > patternWriteNum
ap_uint< 64 > currentMemPattern
ap_uint< 8 > fsmState
ap_uint< 33 > currentPatternAdderss
bool runContiniously
#define FSM_RD_ANTI_CMD
#define FSM_RD_PAT_STS
#define PHASE_RAMP_WRITE
#define FSM_RD_ANTI_DATA
#define FSM_WR_PAT_STS
#define FSM_WR_ANTI_CMD
#define MEM_START_ADDR
#define FSM_WR_ANTI_STS
#define PHASE_RAMP_READ
#define FSM_RD_ANTI_STS
#define FSM_RD_PAT_CMD
#define PHASE_STRESS
#define PHASE_IDLE
#define FSM_RD_PAT_DATA
#define FSM_WR_ANTI_DATA
#define MEM_END_ADDR
#define CHECK_CHUNK_SIZE
This define configures tha AXI burst size of DDRM memory-mapped interfaces AXI4 allows 4KiB,...
Definition: harris.hpp:131
#define FSM_WR_PAT_CMD
Definition: harris.hpp:83
#define TRANSFERS_PER_CHUNK
Definition: harris.hpp:133
#define FSM_WR_PAT_DATA
Definition: harris.hpp:85
#define FSM_IDLE
Definition: harris.hpp:79
#define CYCLES_UNTIL_TIMEOUT
Definition: memtest.hpp:96
ap_uint<(D+7)/8 > tkeep
Definition: axi_utils.hpp:49
ap_uint< 1 > tlast
Definition: axi_utils.hpp:50
ap_uint< D > tdata
Definition: axi_utils.hpp:48