cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
sobel.cpp
Go to the documentation of this file.
1 
17 
36 #include "../include/sobel.hpp"
37 #include "../include/xf_sobel_config.h"
38 #include "../include/sobel_network_library.hpp"
39 #include "../include/sobel_hw_common.hpp"
40 #include "../include/sobel_processing.hpp"
41 
42 using hls::stream;
43 
44 
45 
51 void sobel(
52 
53  ap_uint<32> *pi_rank,
54  ap_uint<32> *pi_size,
55  //------------------------------------------------------
56  //-- SHELL / This / UDP/TCP Interfaces
57  //------------------------------------------------------
58  stream<NetworkWord> &siSHL_This_Data,
59  stream<NetworkWord> &soTHIS_Shl_Data,
60  stream<NetworkMetaStream> &siNrc_meta,
61  stream<NetworkMetaStream> &soNrc_meta,
62  ap_uint<32> *po_rx_ports
63 
64  #ifdef ENABLE_DDR
65  ,
66  //------------------------------------------------------
67  //-- SHELL / Role / Mem / Mp0 Interface
68  //------------------------------------------------------
69  //---- Read Path (MM2S) ------------
70  // stream<DmCmd> &soMemRdCmdP0,
71  // stream<DmSts> &siMemRdStsP0,
72  // stream<Axis<MEMDW_512 > > &siMemReadP0,
73  //---- Write Path (S2MM) -----------
74  stream<DmCmd> &soMemWrCmdP0,
75  stream<DmSts> &siMemWrStsP0,
76  stream<Axis<MEMDW_512> > &soMemWriteP0,
77  //------------------------------------------------------
78  //-- SHELL / Role / Mem / Mp1 Interface
79  //------------------------------------------------------
82  #endif
83  )
84 {
85 
86 
87 //-- DIRECTIVES FOR THE BLOCK ---------------------------------------------
88 #pragma HLS INTERFACE axis register both port=siSHL_This_Data
89 #pragma HLS INTERFACE axis register both port=soTHIS_Shl_Data
90 
91 #pragma HLS INTERFACE axis register both port=siNrc_meta
92 #pragma HLS INTERFACE axis register both port=soNrc_meta
93 
94 #pragma HLS INTERFACE ap_ovld register port=po_rx_ports name=poROL_NRC_Rx_ports
95 
96 #if HLS_VERSION < 20211
97 #pragma HLS INTERFACE ap_stable register port=pi_rank name=piFMC_ROL_rank
98 #pragma HLS INTERFACE ap_stable register port=pi_size name=piFMC_ROL_size
99 #elif HLS_VERSION >= 20211
100  #pragma HLS stable variable=pi_rank
101  #pragma HLS stable variable=pi_size
102 #else
103  printf("ERROR: Invalid HLS_VERSION=%s\n", HLS_VERSION);
104  exit(-1);
105 #endif
106 
107 #ifdef ENABLE_DDR
108 
109 // Bundling: SHELL / Role / Mem / Mp0 / Write Interface
110 #pragma HLS INTERFACE axis register both port=soMemWrCmdP0
111 #pragma HLS INTERFACE axis register both port=siMemWrStsP0
112 #pragma HLS INTERFACE axis register both port=soMemWriteP0
113 
114 #if HLS_VERSION <= 20201
115 #pragma HLS DATA_PACK variable=soMemWrCmdP0 instance=soMemWrCmdP0
116 #pragma HLS DATA_PACK variable=siMemWrStsP0 instance=siMemWrStsP0
117 #elif HLS_VERSION >= 20211
118 #pragma HLS aggregate variable=soMemWrCmdP0 compact=bit
119 #pragma HLS aggregate variable=siMemWrStsP0 compact=bit
120 #else
121  printf("ERROR: Invalid HLS_VERSION=%s\n", HLS_VERSION);
122  exit(-1);
123 #endif
124 
125 const unsigned int ddr_mem_depth = TOTMEMDW_512;
126 const unsigned int ddr_latency = DDR_LATENCY;
127 
128 
129 // When max burst size is 1KB, with 512bit bus we get 16 burst transactions
130 // When max burst size is 4KB, with 512bit bus we get 64 burst transactions
131 const unsigned int max_axi_rw_burst_length = 64;
132 
133 // Mapping LCL_MEM0 interface to moMEM_Mp1 channel
134 #pragma HLS INTERFACE m_axi depth=ddr_mem_depth port=lcl_mem0 bundle=moMEM_Mp1\
135  max_read_burst_length=max_axi_rw_burst_length max_write_burst_length=max_axi_rw_burst_length offset=direct \
136  num_read_outstanding=16 num_write_outstanding=16 latency=ddr_latency
137 
138 // Mapping LCL_MEM1 interface to moMEM_Mp1 channel
139 #pragma HLS INTERFACE m_axi depth=ddr_mem_depth port=lcl_mem1 bundle=moMEM_Mp1 \
140  max_read_burst_length=max_axi_rw_burst_length max_write_burst_length=max_axi_rw_burst_length offset=direct \
141  num_read_outstanding=16 num_write_outstanding=16 latency=ddr_latency
142 
143 #endif
144 
145  #pragma HLS DATAFLOW
146 
147  //-- LOCAL VARIABLES ------------------------------------------------------
149  static stream<NetworkWord> sRxpToTxp_Data("sRxpToTxP_Data"); // FIXME: works even with no static
150  static stream<NetworkMetaStream> sRxtoTx_Meta("sRxtoTx_Meta");
151  static unsigned int processed_word_rx;
152  static unsigned int processed_bytes_rx;
153  static unsigned int processed_word_tx = 0;
154  static stream<bool> sImageLoaded("sImageLoaded");
155  static bool skip_read;
156  static bool write_chunk_to_ddr_pending;
157  static bool ready_to_accept_new_data;
158  static bool signal_init;
159  const int tot_transfers = TOT_TRANSFERS;
160 #ifdef ENABLE_DDR
161  static stream<ap_uint<MEMDW_512>> img_in_axi_stream ("img_in_axi_stream");
162  const unsigned int img_in_axi_stream_depth = TRANSFERS_PER_CHUNK; // the AXI burst size
163  static stream<bool> sMemBurstRx("sMemBurstRx");
164 
165 #else
166  const int img_in_axi_stream_depth = MIN_RX_LOOPS;
167  const int img_out_axi_stream_depth = MIN_TX_LOOPS;
168  static stream<ap_uint<INPUT_PTR_WIDTH>> img_in_axi_stream ("img_in_axi_stream");
169  static stream<ap_uint<OUTPUT_PTR_WIDTH>> img_out_axi_stream ("img_out_axi_stream");
170 #endif
171  static stream<NodeId> sDstNode_sig("sDstNode_sig");
172 
173 
174 //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
175 #pragma HLS stream variable=sRxtoTx_Meta depth=tot_transfers
176 #pragma HLS reset variable=processed_word_rx
177 #pragma HLS reset variable=processed_word_tx
178 #pragma HLS reset variable=processed_bytes_rx
179 //#pragma HLS reset variable=image_loaded
180 #pragma HLS stream variable=sImageLoaded depth=1
181 #pragma HLS reset variable=skip_read
182 #pragma HLS reset variable=write_chunk_to_ddr_pending
183 //#pragma HLS stream variable=sWriteChunkToDdrPending depth=2
184 #pragma HLS reset variable=ready_to_accept_new_data
185 #pragma HLS reset variable=signal_init
186 #pragma HLS STREAM variable=sDstNode_sig depth=1
187 
188 #ifdef ENABLE_DDR
189 #pragma HLS stream variable=img_in_axi_stream depth=img_in_axi_stream_depth
190 #pragma HLS stream variable=sProcessed_bytes_rx depth=img_in_axi_stream_depth
191 #else
192 #pragma HLS stream variable=img_in_axi_stream depth=img_in_axi_stream_depth
193 #pragma HLS stream variable=img_out_axi_stream depth=img_out_axi_stream_depth
194 #endif
195 
196 
197 
199  pi_rank,
200  pi_size,
201  sDstNode_sig,
202  po_rx_ports
203  );
204 
205 #ifdef ENABLE_DDR
206 
208  siSHL_This_Data,
209  siNrc_meta,
210  sRxtoTx_Meta,
211  img_in_axi_stream,
212  sMemBurstRx
213  );
214 
216  img_in_axi_stream,
217  sMemBurstRx,
218  //---- P0 Write Path (S2MM) -----------
219  soMemWrCmdP0,
220  siMemWrStsP0,
221  soMemWriteP0,
222  //---- P1 Memory mapped ---------------
223  //&processed_bytes_rx,
224  sImageLoaded
225  );
226 
227 
228 
229  #else // !ENABLE_DDR
230 
231  pRXPath(
232  siSHL_This_Data,
233  siNrc_meta,
234  sRxtoTx_Meta,
235  img_in_axi_stream,
236  meta_tmp,
237  &processed_word_rx,
238  &processed_bytes_rx,
239  sImageLoaded
240  );
241 
242 #endif // ENABLE_DDR
243 
244  pProcPath(
245  sRxpToTxp_Data,
246 #ifdef ENABLE_DDR
247  lcl_mem0,
248  lcl_mem1,
249 #else
250  img_in_axi_stream,
251  img_out_axi_stream,
252 #endif
253  sImageLoaded
254  );
255 
256  pTXPath(
257  soTHIS_Shl_Data,
258  soNrc_meta,
259  sRxpToTxp_Data,
260  sRxtoTx_Meta,
261  sDstNode_sig,
262  &processed_word_tx,
263  pi_rank,
264  pi_size
265  );
266 }
267 
268 
#define TRANSFERS_PER_CHUNK
Definition: harris.hpp:133
void pProcPath(stream< NetworkWord > &sRxpToTxp_Data, stream< NetworkMetaStream > &sRxtoTx_Meta, NetworkMetaStream meta_tmp, varin *instruct, double *out, unsigned int *processed_word_rx, unsigned int *processed_word_proc, unsigned int *struct_loaded)
Processing Path - Main processing FSM for Vitis kernels.
#define MIN_TX_LOOPS
#define MIN_RX_LOOPS
#define TOT_TRANSFERS
Definition: config.h:70
void pRXPathNetToStream(stream< NetworkWord > &siSHL_This_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &sRxtoTx_Meta, stream< ap_uint< 512 >> &img_in_axi_stream, stream< bool > &sMemBurstRx)
Receive Path - From SHELL to THIS.
void pRXPathStreamToDDR(stream< ap_uint< 512 >> &img_in_axi_stream, stream< bool > &sMemBurstRx, stream< DmCmd > &soMemWrCmdP0, stream< DmSts > &siMemWrStsP0, stream< Axis< 512 > > &soMemWriteP0, stream< bool > &sImageLoaded)
Receive Path - From SHELL to THIS.
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.
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 DDR_LATENCY
Definition: memtest.hpp:98
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 ENABLE_DDR
Definition: memtest.hpp:42
membus_512_t membus_t
Definition: memtest.hpp:92
#define TOTMEMDW_512
Definition: memtest.hpp:93
membus_t lcl_mem0[16384]
membus_t lcl_mem1[16384]
void sobel(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, stream< DmCmd > &soMemWrCmdP0, stream< DmSts > &siMemWrStsP0, stream< Axis< 512 > > &soMemWriteP0, membus_t *lcl_mem0, membus_t *lcl_mem1)
Main process of the Sobel Application directives.
Definition: sobel.cpp:51