Synchronous Window Access - 2022.2 English

AI Engine Kernel and Graph Programming Guide (UG1079)

Document ID
UG1079
Release Date
2022-10-19
Version
2022.2 English

A kernel reads from its input windows and writes to its output windows. By default, the synchronization that is required to wait for an input window of data, or to provide an empty output window, is performed before entering the kernel. There is no synchronization needed within the kernel to read or write the individual elements of data after the kernel has started.

The size of the window (in bytes) is declared along with the connection declaration between a producer and a consumer port as shown in the following (see Connections for details). This establishes a window connection of 128 bytes between port in and the first input port of the kernel.

connect< window<128> > net0 (in, first.in[0]);

An optional second template parameter identifies the overlap (in bytes) from one block of data to the next, which is sometimes also referred to as the margin, as shown in the following. If a margin parameter is specified, the total memory allocated is window size + margin size.

connect< window<128, 32> net1 (in, first.in[0]);

These windows are designed to be accessed sequentially. The kernel programming reads the window type and starts from the first position. Therefore, a useful model is that of a current position, which can be advanced or rolled back on reads or writes. On starting a kernel, the current position is always in the correct position. For example, the current position for an input window for a filter is on the first sample to restore to the delay line. It could be an older sample in the case of filters requiring overlap of incoming data samples, in which case the connection needs to be declared using the overlap or margin as described above. Similarly, the current position for an output window is on the first sample to send to the next block, irrespective of whether that block requires a duplication of older samples. The kernel is free to manipulate this current position and it is not necessary that this position is at the end of the block when the kernel completes. Window data types are implemented as circular buffers.

Note: The minimum size for window allocation is 16 bytes. Window size allocation is rounded up to a multiple of 16 bytes. The minimum size for margin overlap is 32 bytes and must be a multiple of 32 bytes.