Dataflow Using Array of HLS Stream

This is simple example of Multiple Stages Vector Addition to demonstrate Array of Stream usage in HLS C Kernel Code.

KEY CONCEPTS: Array of Stream

KEYWORDS: dataflow, hls::stream

This example demonstrates the use of an array of HLS streams in kernels, with different depth set for each of the streams.

static hls::stream<int> streamArray[STAGES + 1];
#pragma HLS STREAM variable=streamArray[0] depth=4
#pragma HLS STREAM variable=streamArray[1] depth=16
#pragma HLS STREAM variable=streamArray[2] depth=8

Kernel performs a number of vector additions. Initial vector is taken from the global memory and is written into a stream. Operator << is overloaded to perform a blocking write to a stream from a variable.

mem_rd:
   for (int i = 0; i < size; i++) {
      #pragma HLS LOOP_TRIPCOUNT min=c_size max=c_size
       inStream << input[i];
   }

Multiple additions are performed using the adder function which take the input from a stream and provide the output to another stream.

compute_loop:
    for (int i = 0; i < STAGES; i++) {
       #pragma HLS UNROLL
        adder(streamArray[i], streamArray[i + 1], incr, size);
    }

Finally, result is written back from stream to global memory buffer.

static void write_result(int *output, hls::stream<int> &outStream, int size) {
mem_wr:
    for (int i = 0; i < size; i++) {
       #pragma HLS LOOP_TRIPCOUNT min=c_size max=c_size
        output[i] = outStream.read();
    }
}

EXCLUDED PLATFORMS:

  • All NoDMA Platforms, i.e u50 nodma etc

  • Samsung U.2 SmartSSD

DESIGN FILES

Application code is located in the src directory. Accelerator binary files will be compiled to the xclbin directory. The xclbin directory is required by the Makefile and its contents will be filled during compilation. A listing of all the files in this example is shown below

src/N_stage_adders.cpp
src/host.cpp

Access these files in the github repo by clicking here.

COMMAND LINE ARGUMENTS

Once the environment has been configured, the application can be executed by

./dataflow_stream_array <N_stage_Adders XCLBIN>