cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
harris.hpp
Go to the documentation of this file.
1 
17 
38 #ifndef _ROLE_HARRIS_H_
39 #define _ROLE_HARRIS_H_
40 
41 #include <stdio.h>
42 #include <iostream>
43 #include <fstream>
44 #include <string>
45 #include <math.h>
46 #include <hls_stream.h>
47 #include "ap_int.h"
48 #include <stdint.h>
49 #include "network.hpp"
50 #include "memory_utils.hpp"
51 
52 using namespace hls;
53 
54 // Define this option to load data from network to DDR memory before calling the kernel.
55 // #define ENABLE_DDR
56 
57 
60 enum EchoCtrl {
63  ECHO_OFF = 2
64 };
65 
66 
67 #define ROLE_IS_HARRIS
68 
69 
70 #define WAIT_FOR_META 0
71 #define WAIT_FOR_STREAM_PAIR 1
72 #define PROCESSING_PACKET 2
73 #define LOAD_IN_STREAM 3
74 #define HARRIS_RETURN_RESULTS 4
75 #define HARRIS_RETURN_RESULTS_ABSORB_DDR_LAT 5
76 #define HARRIS_RETURN_RESULTS_UNPACK 6
77 #define HARRIS_RETURN_RESULTS_FWD 7
78 #define WAIT_FOR_TX 8
79 #define FSM_IDLE 9
80 #define FSM_CHK_SKIP 10
81 #define FSM_CHK_PROC_BYTES 11
82 #define FSM_CHK_WRT_CHNK_TO_DDR_PND 12
83 #define FSM_WR_PAT_CMD 13
84 #define FSM_WR_PAT_LOAD 14
85 #define FSM_WR_PAT_DATA 15
86 #define FSM_WR_PAT_STS_A 16
87 #define FSM_WR_PAT_STS_B 17
88 #define FSM_WR_PAT_STS_C 18
89 #define PacketFsmType uint8_t
90 
91 
92 #define FSM_WRITE_NEW_DATA 0
93 #define FSM_DONE 1
94 #define PortFsmType uint8_t
95 
96 #define DEFAULT_TX_PORT 2718
97 #define DEFAULT_RX_PORT 2718
98 
99 // Starting with 2718, this number corresponds to the extra opened ports of this role. Every bit set
100 // corresponds to one port.
101 // e.g. 0x1->2718, 0x2->2719, 0x3->[2718,2719], 0x7->[2718,2719,2720], 0x17->[2718-2722], etc.
102 #define PORTS_OPENED 0x1F
103 
104 #define Data_t_in ap_axiu<INPUT_PTR_WIDTH, 0, 0, 0>
105 #define Data_t_out ap_axiu<OUTPUT_PTR_WIDTH, 0, 0, 0>
106 
107 
108 #define MAX_NB_OF_ELMT_READ 16
109 typedef uint8_t mat_elmt_t; // change to float or double depending on your needs
110 
111 #define MAX_NB_OF_WORDS_READ (MAX_NB_OF_ELMT_READ*sizeof(mat_elmt_t)/BPERDW) // =2 if double =1 if float
112 #define MAX_NB_OF_ELMT_PERDW (BPERDW/sizeof(mat_elmt_t)) // =8 if double =16 if float
113 
114 
115 //------------------------------------ Declarations for DDR ----------------------------------------
116 
117 /* General memory Data Width is set as a parameter*/
118 /* 52-bit host AXI data width*/
119 #define MEMDW_512 512 // 512 Bus width in bits for cF DDR memory
120 #define BPERMDW_512 (MEMDW_512/8) // Bytes per DDR Memory Data Word, if MEMDW=512 => BPERMDW_512 = 64
121 #define KWPERMDW_512 (BPERMDW_512/sizeof(IN_TYPE)) // Number of Harris kernel words per DDR memory word
122 typedef ap_uint<MEMDW_512> membus_512_t; /* 512-bit ddr memory access */
124 #define TOTMEMDW_512 (1 + (IMGSIZE - 1) / BPERMDW_512)
125 
126 
131 #define CHECK_CHUNK_SIZE 0x400
132 #define BYTE_PER_MEM_WORD BPERMDW_512 // 64
133 #define TRANSFERS_PER_CHUNK (CHECK_CHUNK_SIZE/BYTE_PER_MEM_WORD) //64
134 #define TRANSFERS_PER_CHUNK_DIVEND (TOTMEMDW_512-(TOTMEMDW_512/TRANSFERS_PER_CHUNK)*TRANSFERS_PER_CHUNK)
135 
136 
137 //typedef enum fsmStateDDRenum {
138 // FSM_WR_PAT_CMD = 0,
139 // FSM_WR_PAT_DATA = 1,
140 // FSM_WR_PAT_STS = 2
141 //} fsmStateDDRdef;
142 //typedef enum fsmStateDDRenum fsmStateDDRdef;
143 
144 #define fsmStateDDRdef uint8_t
145 
146 // The maximum number of cycles allowed to acknowledge a write to DDR (i.e. read the status stream)
147 #define CYCLES_UNTIL_TIMEOUT 0x0100
148 #define TYPICAL_DDR_LATENCY 4
149 // The latency cycles of cF DDR. We've measured 52, but experimentally we take it if we divide by
150 // 4.769230769, taking into account the II=2 and the latency of the FSM
151 #define DDR_LATENCY (52/4)
152 #define EXTRA_DDR_LATENCY_DUE_II (64 + 8) // 8 is the write from input stream to local stream, 64 is read from local stream to DDR
153 /*
154  * A generic unsigned AXI4-Stream interface used all over the cloudFPGA place.
155  */
156 template<int D>
157 struct Axis {
158  ap_uint<D> tdata;
159  ap_uint<(D+7)/8> tkeep;
160  ap_uint<1> tlast;
161  Axis() {}
162  Axis(ap_uint<D> single_data) : tdata((ap_uint<D>)single_data), tkeep(1), tlast(1) {}
163 };
164 
165 
166 void harris(
167 
168  ap_uint<32> *pi_rank,
169  ap_uint<32> *pi_size,
170  //------------------------------------------------------
171  //-- SHELL / This / Udp/TCP Interfaces
172  //------------------------------------------------------
173  stream<NetworkWord> &siSHL_This_Data,
174  stream<NetworkWord> &soTHIS_Shl_Data,
175  stream<NetworkMetaStream> &siNrc_meta,
176  stream<NetworkMetaStream> &soNrc_meta,
177  ap_uint<32> *po_rx_ports
178 
179  #ifdef ENABLE_DDR
180  ,
181  //------------------------------------------------------
182  //-- SHELL / Role / Mem / Mp0 Interface
183  //------------------------------------------------------
184  //---- Read Path (MM2S) ------------
185  // stream<DmCmd> &soMemRdCmdP0,
186  // stream<DmSts> &siMemRdStsP0,
187  // stream<Axis<MEMDW_512 > > &siMemReadP0,
188  //---- Write Path (S2MM) -----------
189  stream<DmCmd> &soMemWrCmdP0,
190  stream<DmSts> &siMemWrStsP0,
191  stream<Axis<MEMDW_512> > &soMemWriteP0,
192  //------------------------------------------------------
193  //-- SHELL / Role / Mem / Mp1 Interface
194  //------------------------------------------------------
197  #endif
198 );
199 
200 
201 #endif
202 
203 
void harris(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siSHL_This_Data, stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the Harris Application directives.
Definition: harris.cpp:918
membus_512_t membus_t
Definition: harris.hpp:123
ap_uint< 512 > membus_512_t
Definition: harris.hpp:122
uint8_t mat_elmt_t
Definition: harris.hpp:109
#define ENABLE_DDR
Definition: memtest.hpp:42
membus_512_t membus_t
Definition: memtest.hpp:92
ap_uint< 512 > membus_512_t
Definition: memtest.hpp:91
EchoCtrl
Definition: memtest.hpp:49
membus_t lcl_mem0[16384]
membus_t lcl_mem1[16384]
@ ECHO_STORE_FWD
Definition: harris.hpp:62
@ ECHO_OFF
Definition: harris.hpp:63
@ ECHO_PATH_THRU
Definition: harris.hpp:61
Axis(ap_uint< D > single_data)
Definition: harris.hpp:162
Axis()
Definition: harris.hpp:161