cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
mem_test_flash.hpp
Go to the documentation of this file.
1 
17 // *****************************************************************************
18 // *
19 // * cloudFPGA
20 // *
21 // *----------------------------------------------------------------------------
22 // *
23 // * Title : Memory test in HSL using AXI DataMover
24 // *
25 // * Created : Dec. 2018
26 // * Authors : Burkhard Ringlein (NGL@zurich.ibm.com)
27 // *
28 // * Devices : xcku060-ffva1156-2-i
29 // * Tools : Vivado v2017.4 (64-bit)
30 // * Depends : None
31 // *
32 // *
33 // *****************************************************************************
34 
35 #ifndef _MEM_TEST_H_
36 #define _MEM_TEST_H_
37 
38 
39 #include <stdint.h>
40 #include <stdio.h>
41 #include <hls_stream.h>
42 #include "ap_int.h"
43 
44 #define FSM_IDLE 0
45 #define FSM_WR_PAT_CMD 1
46 #define FSM_WR_PAT_DATA 2
47 #define FSM_WR_PAT_STS 3
48 #define FSM_RD_PAT_CMD 4
49 #define FSM_RD_PAT_DATA 5
50 #define FSM_RD_PAT_STS 6
51 #define FSM_WR_ANTI_CMD 7
52 #define FSM_WR_ANTI_DATA 8
53 #define FSM_WR_ANTI_STS 9
54 #define FSM_RD_ANTI_CMD 10
55 #define FSM_RD_ANTI_DATA 11
56 #define FSM_RD_ANTI_STS 12
57 //#define FsmState uint8_t
58 
59 
60 #define PHASE_IDLE 0
61 #define PHASE_RAMP_WRITE 1
62 #define PHASE_RAMP_READ 2
63 #define PHASE_STRESS 3
64 
65 
66 #define MEM_START_ADDR 0x000000000 // Start address of user space in DDR4
67 
68 //#ifdef DEBUG
69 //#define MEM_END_ADDR 0x2000 //DEBUG
70 //#else
71 
72 //8GB
73 //#define MEM_END_ADDR 0x1FFFFF000 // End address of user space in DDR4
74 //4GB
75 //#define MEM_END_ADDR 0xFFFFF000 // End address of user space in DDR4
76 
77 //#endif
78 #include "dynamic.hpp"
79 
80 #define CHECK_CHUNK_SIZE 0x1000 //4 KiB
81 #define BYTE_PER_MEM_WORD 64
82 #define TRANSFERS_PER_CHUNK (CHECK_CHUNK_SIZE/BYTE_PER_MEM_WORD) //64
83 
84 
85 //#define CYCLES_UNTIL_TIMEOUT 0xF4240
86 #define CYCLES_UNTIL_TIMEOUT 0x1000
87 
88 /*
89  * A generic unsigned AXI4-Stream interface used all over the cloudFPGA place.
90  */
91 template<int D>
92 struct Axis {
93  ap_uint<D> tdata;
94  ap_uint<(D+7)/8> tkeep;
95  ap_uint<1> tlast;
96  Axis() {}
97  Axis(ap_uint<D> single_data) : tdata((ap_uint<D>)single_data), tkeep(1), tlast(1) {}
98 };
99 
100 
101 // AXI DataMover - Format of the command word (c.f PG022)
102 struct DmCmd
103 {
104  ap_uint<23> btt;
105  ap_uint<1> type;
106  ap_uint<6> dsa;
107  ap_uint<1> eof;
108  ap_uint<1> drr;
109  ap_uint<40> saddr;
110  ap_uint<4> tag;
111  ap_uint<4> rsvd;
112  DmCmd() {}
113  DmCmd(ap_uint<40> addr, ap_uint<16> len) :
114  btt(len), type(1), dsa(0), eof(1), drr(0), saddr(addr), tag(0x7), rsvd(0) {}
115 };
116 
117 
118 // AXI DataMover - Format of the status word (c.f PG022)
119 struct DmSts
120 {
121  ap_uint<4> tag;
122  ap_uint<1> interr;
123  ap_uint<1> decerr;
124  ap_uint<1> slverr;
125  ap_uint<1> okay;
126  DmSts() {}
127 };
128 
129 
131  // ----- system reset ---
132  ap_uint<1> sys_reset,
133  // ----- MMIO ------
134  ap_uint<2> DIAG_CTRL_IN,
135  ap_uint<2> *DIAG_STAT_OUT,
136  // ---- add. Debug output ----
137  ap_uint<16> *debug_out,
138 
139  //------------------------------------------------------
140  //-- SHELL / Role / Mem / Mp0 Interface
141  //------------------------------------------------------
142  //---- Read Path (MM2S) ------------
143  hls::stream<DmCmd> &soMemRdCmdP0,
144  hls::stream<DmSts> &siMemRdStsP0,
145  hls::stream<Axis<512> > &siMemReadP0,
146  //---- Write Path (S2MM) -----------
147  hls::stream<DmCmd> &soMemWrCmdP0,
148  hls::stream<DmSts> &siMemWrStsP0,
149  hls::stream<Axis<512> > &soMemWriteP0
150 
151  //------------------------------------------------------
152  //-- SHELL / Role / Mem / Mp1 Interface
153  //------------------------------------------------------
154  //---- Read Path (MM2S) ------------
155  //stream<DmCmd> &soMemRdCmdP1,
156  //stream<DmSts> &siMemRdStsP1,
157  //stream<Axis<512> > &siMemReadP1,
158  //---- Write Path (S2MM) -----------
159  //stream<DmCmd> &soMemWrCmdP1,
160  //stream<DmSts> &siMemWrStsP1,
161  // stream<Axis<512> > &soMemWriteP1
162 );
163 
164 #endif
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)
ap_uint< 40 > saddr
DmCmd(ap_uint< 40 > addr, ap_uint< 16 > len)
ap_uint< 1 > drr
ap_uint< 1 > eof
ap_uint< 4 > tag
ap_uint< 6 > dsa
ap_uint< 4 > rsvd
ap_uint< 23 > btt
Definition: mem.hpp:85
ap_uint< 1 > type
ap_uint< 1 > okay
ap_uint< 1 > decerr
ap_uint< 1 > slverr
ap_uint< 4 > tag
ap_uint< 1 > interr
Axis(ap_uint< D > single_data)
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