Reading Data - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
XD100
Release Date
2023-11-29
Version
2023.2 English

The readIn_row function reads data for the fftRow functions. It is defined in the following example:

void readIn_row(hls::stream<qdma_axis<128, 0, 0, 0>> &strm_inp,
                cmpxDataIn in[MAT_COLS]
               )
{
   #if FFT_2D_DT == 0 // cint16 datatype
      LOOP_FFT_ROW_READ_INP:for(int j = 0; j < MAT_COLS; j += 4) {
         #pragma HLS PIPELINE II=1
         #pragma HLS loop_tripcount min=16 max=512
         
         qdma_axis<128, 0, 0, 0> qdma = strm_inp.read();
         qdma.keep_all();
         
         cmpxDataIn tmp_in;
         
         tmp_in.real().range(15, 0) = qdma.data.range( 15,   0);
         tmp_in.imag().range(15, 0) = qdma.data.range( 31,  16);
         in[j] = tmp_in;
         
         tmp_in.real().range(15, 0) = qdma.data.range( 47,  32);
         tmp_in.imag().range(15, 0) = qdma.data.range( 63,  48);
         in[j + 1] = tmp_in;
         
         tmp_in.real().range(15, 0) = qdma.data.range( 79,  64);
         tmp_in.imag().range(15, 0) = qdma.data.range( 95,  80);
         in[j + 2] = tmp_in;
         
         tmp_in.real().range(15, 0) = qdma.data.range(111,  96);
         tmp_in.imag().range(15, 0) = qdma.data.range(127, 112);
         in[j + 3] = tmp_in;
      }
   
   #else // cfloat datatype
      LOOP_FFT_ROW_READ_INP:for(int j = 0; j < MAT_COLS; j += 2) {
         #pragma HLS PIPELINE II=1
         #pragma HLS loop_tripcount min=32 max=1024
         
         qdma_axis<128, 0, 0, 0> qdma = strm_inp.read();
         qdma.keep_all();
         
         cmpxDataIn tmp_in;
         AXI_DATA rowInp;
         
         rowInp.data[0] = qdma.data.range( 63,  0);
         rowInp.data[1] = qdma.data.range(127, 64);
         
         tmp_in.real(rowInp.fl_data[0]);
         tmp_in.imag(rowInp.fl_data[1]);
         in[j] = tmp_in;
         
         tmp_in.real(rowInp.fl_data[2]);
         tmp_in.imag(rowInp.fl_data[3]);
         in[j + 1] = tmp_in;
      }
   
   #endif
}