Basics of Conditional Instantiation - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
Release Date
2023.2 English

conditional is a C++ feature belonging to the standard library. The format is:

typename std::conditional< BOOLEAN_CONDITION , TYPE_IF_TRUE , TYPE_IF_FALSE >::type VARIABLE;

If BOOLEAN_CONDITION is True, then VARIABLE is generated with type TYPE_IF_TRUE. If the condition is False, VARIABLE is also generated but with type TYPE_IF_FALSE.

For aiecompiler environment, the BOOLEAN_CONDITION will be generally passed through template parameter. Though VARIABLE is always created, the type is different depending on the condition. In the examples provided, TYPE_IF_TRUE is the port type, graph class name that is of interest, and TYPE_IF_FALSE is a dummy type like int or std::tuple<>.