Code Example - 2025.2 English

Vitis Libraries

Release Date
2025-12-17
Version
2025.2 English

The following code example shows how the widget_api_cast graph class can be used within a user super-graph, including how to set the runtime<ratio> of internal kernels. This example shows the widget configured to interlace two input streams on a sample-by-sample basis, with the output written to a window.

#include <adf.h>
#include "widget_api_cast_graph.hpp"

using namespace adf;
namespace widg1_example {
#define DATA_TYPE_WIDG1 cint16
#define IN_API 1
#define OUT_API 0
#define NUM_INPUTS 2
#define WINDOW_VSIZE_W 1024
#define NUM_OUTPUT_CLONES 1
#define PATTERN 1
class test_widg_api : public graph {
   public:
    xf::dsp::aie::port_array<input, NUM_INPUTS> in;
    xf::dsp::aie::port_array<output, NUM_OUTPUT_CLONES> out;
    xf::dsp::aie::widget::api_cast::
        widget_api_cast_graph<DATA_TYPE_WIDG1, IN_API, OUT_API, NUM_INPUTS, WINDOW_VSIZE_W, NUM_OUTPUT_CLONES, PATTERN>
            widget;
    test_widg_api() {
        for (int i = 0; i < NUM_INPUTS; i++) {
            connect<>(in[i], widget.in[i]);
        }
        for (int i = 0; i < NUM_OUTPUT_CLONES; i++) {
            connect<>(widget.out[i], out[i]);
        }
        kernel* kernels = widget.getKernels();
        runtime<ratio>(*kernels) = 0.5;
    };
};
};