Case 4: Conditional RTP Ports - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
Release Date
2023.2 English

Last but not least, in this fourth testcase, a template parameter allows you to choose between a kernel that has RTP ports and another one which does not have these ports.

template<bool HAS_RTPS>
struct Sub0: public graph
    input_port _in0;
    output_port _out0;
    typename std::conditional< HAS_RTPS, input_port, std::tuple<>>::type _in1;
    typename std::conditional< HAS_RTPS, inout_port, std::tuple<>>::type _inout0;
    kernel _k;
        if constexpr (HAS_RTPS) {
            _k = kernel::create(f1);
        } else {
            _k = kernel::create(f0);
        runtime<ratio>(_k) = 0.9;
        source(_k) = "k0.cpp";
        connect(_k.out[0], _out0);

        if constexpr (HAS_RTPS) {
            connect(_k.inout[0], _inout0);

In the testcase, two of these graphs are instantiated: one without RTPs and another one with RTP ports. The resulting graph in the Vitis Analyzer is as follows:

No Image

Type make CASE=4 aie aieviz to visualize the resulting graph of this testcase.