constraint<T> - 2021.2 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
English (United States)
Release Date
2021.2 English

This template class is used to build scalar data constraints on kernels, connections, and ports.


A constraint must appear inside a user graph constructor.

Member Functions

constraint<T> operator=(T)

This overloaded equality operator allows you to assign a value to a scalar constraint.


The default constructor is not used. Instead the following special constructors are used with specific meaning.

void fabric<aiengine>(kernel&)

This constraint allows you to mark a kernel to be implemented on the AI Engine (default).

constraint<std::string>& initialization_function(kernel&)

This constraint allows you to set a specific initialization function for each kernel. The constraint expects a string denoting the name of the initialization function. Where multiple kernels are packed on a core, each initialization function packed on the core is called exactly once. No kernel functions are scheduled until all the initialization functions packed on a core are completed.

An initialization function cannot return a value and cannot have input/output arguments, that is, the function prototype must be as follows.

void init_function_name(void)
Note: The initialization function is called only once when the first graph::run API is called.

This function can be used to initialize global variables and set or clear rounding and saturation modes. It cannot use window or stream APIs to access memory or stream interfaces, but stream intrinsics (for example, get_ss()) can be used. See the AI Engine Kernel Coding Best Practices Guide (UG1079) for examples.

constraint<float>& runtime<ratio>(kernel&)

This constraint allows you to set a specific core usage fraction for a kernel. This is computed as a ratio of the number of cycles taken by one invocation of a kernel (processing one block of data) to the cycle budget. The cycle budget for an application is typically fixed according to the expected data throughput and the block size being processed.

constraint<std::string>& source(kernel&)

This constraint allows you to specify the source file containing the definition of each kernel function. A source constraint must be specified for each kernel.

constraint<int>& fifo_depth(connect&)=[<depth> | (depth)]

This constraint allows you to specify the amount of slack to be inserted on a streaming connection to allow deadlock free execution.

void single_buffer(port<T>&)

This constraint allows you to specify single buffer constraint on a window port. By default, a window port is double buffered.

void initial_value(async_AIE_RTP_port)

This constraint allows you to set the initial value for an asynchronous AI Engine input run-time parameter port. It allows the destination kernel to start asynchronously with the specified initial value. You can set both scalar and array run-time parameters using this constraint.

Example scalar: initial_value(6).

Example array: initial_value({1,2,3})

constraint<int> stack_size(adf::kernel& k);

This constraint allows you to set stack size for individual kernel.

constraint<int> heap_size(adf::kernel& k);

This constraint allows you to set heap size for individual kernel.