Importing Stream-Based Kernels - 2022.1 English

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2022-05-26
Version
2022.1 English
As explained in Data Accessing Mechanisms, stream-based kernels access data streams in a sample-by-sample fashion. Vitis Model Composer supports the following stream-based input and output data types as interfaces to the AIE Kernel block.
  • input_stream_<TYPE>
  • output_window_<TYPE>
<Type> Complexity Signedness
int8 Real Signed
int16 Real Signed
int32 Real Signed
int64 Real Signed
uint8 Real Unsigned
uint16 Real Unsigned
uint32 Real Unsigned
uint64 Real Unsigned
cint16 Complex Signed
cint32 Complex Signed
float Real N/A
cfloat Complex N/A
accfloat Real N/A
caccfloat Complex N/A

As an example, to import a simple kernel with a stream-based interface, the following simple.h header file declares the simple_comp function with one input stream and one output stream.

#ifndef __COMPLEX_KERNEL_H__
#define __COMPLEX_KERNEL_H__
#include <adf.h>
  void simple_comp(input_stream_cint16 * in, output_stream_cint16 * out);
#endif //__COMPLEX_KERNEL_H__

The function is defined in simple.cc.

#include "simple.h"
void simple_comp(input_stream_cint16 * in, output_stream_cint16 * out) {
  cint16 c1, c2;
 
  for (unsigned i=0; i<NUM_SAMPLES; i++) {
  c1 = readincr(in);
  c2.real = c1.real+c1.imag;
  c2.imag = c1.real-c1.imag;
  writeincr(out, c2);
}
}
Note: See the Versal ACAP AI Engine Programming Environment User Guide (UG1076) for details of the readincr() and writeincr() APIs.

Although, the function arguments for window-based and stream-based kernels are different, the procedure for importing the stream-based kernel is the same.

After a successful import, the Function tab GUI displays automatically. You can quickly review the function definition and ports as shown in the following figure.

Figure 1. Function Tab

The following table provides details on the parameters and a description for each parameter.

Table 1. Stream Port Parameters
Parameter Name Description
Signal size This parameter represents the size of the output signal and should be set to a value greater than or equal to the maximum nnumber of samples that are produced during any invocation of the kernel.

In the General tab, the Import button changes to Update, enabling further updates of block parameters.

Model Composer also supports cascade stream connections between two AI Engine processors.

An AI Engine kernel can use incoming stream connections as follows:

  • Input_stream_acc48
  • Input_stream_cacc48

Similarly, a kernel can use the outgoing cascade stream connections as follows:

  • output_stream_acc48
  • output_stream_cacc48

In Model Composer, a cascade stream port is represented as a 48-bit fixed point signal (x_sfix48) that can be either complex or real.

Consider the following example, where a cascade output stream of one kernel is connected to the cascade input stream of another kernel.

#ifndef __CASCADE_KERNELS_H__
#define __CASCADE_KERNELS_H__
void f_osacc48(input_window_int32 *i_hi, 
               input_window_int16 *i_lo, 
               output_stream_acc48 *o1);
#endif
The kernel function f_osacc48 has two input windows: i_hi and i_lo, and one cascade stream output: o1.
Note: This kernel function includes both window-based ports and stream-based ports.

After importing this kernel function, the AIE Kernel block is as shown in the following figure.

Figure 2. AIE Kernel after Import

Consider another kernel function f_isacc48, which has one cascade stream input: i1, and two output windows: o_hi and o_lo.


#ifndef __CASCADE_KERNELS_H__
#define __CASCADE_KERNELS_H__
void f_isacc48(input_stream_acc48 *i1,
               output_window_int32 *o_hi,
               output_window_int16 *o_lo);
#endif

After importing the second kernel function, the AIE Kernel block is as shown in the following figure.

Figure 3. AIE Kernel Block (Second Kernel Function)

Now the two kernels can be connected to form a cascade connection using the cascade stream output of block f_osacc48 and the cascade stream input of block f_isaccc48. This is shown in the following figure.

Figure 4. Connected Kernels (Cascade Connection)