2.4. Widget API Cast

The DSPLib contains a Widget API Cast solution, which provides flexibilty when connecting other kernels. This component is able to change the stream interface to window interface and vice-versa. It may be configured to read two input stream interfaces and interleave data onto an output window interface. In addition, multiple copies of output window may be configured to allow extra flexibility when connecting to further kernels.

2.4.1. Entry Point

The graph entry point is the following:

xf::dsp::aie::widget::api_cast::widget_api_cast_graph

2.4.2. Supported Types

The widget API cast supports int16, cint16, int32, cint32, float and cfloat types as selected by template parameter TT_DATA. This data type is used by both input and output ports.

2.4.3. Template Parameters

To see details on the template parameters for the Widget API Cast, see API Reference Overview.

2.4.4. Access functions

To see details on the access functions for the Widget API Cast, see API Reference Overview.

2.4.5. Ports

To see details on the ports for the Widget API Cast, see API Reference Overview.

2.4.6. Design Notes

The widget_api_cast library element serves multiple purposes. Firstly, it can convert from window to stream or vice versa. Secondly, it can perform limited broadcast of windows. Thirdly it can perform various patterns of interlace when there are 2 streams in or out.

2.4.7. Code Example including constraints

The following code example shows how the widget_api_cast graph class may 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"
#define DATA_TYPE cint16
#define IN_API 1
#define OUT_API 0
#define NUM_INPUTS 2
#define WINDOW_VSIZE 1024
#define NUM_OUTPUT_CLONES 1
#define PATTERN 1

class myWidget : public adf::graph
{
public:
  adf::port<input> in[NUM_INPUTS];
  adf::port<output> out[NUM_OUTPUT_CLONES];
  xf::dsp::aie::widget::api_cast::widget_api_cast_graph<DATA_TYPE, IN_API, OUT_API, NUM_INPUTS, WINDOW_VSIZE,
                                                        NUM_OUTPUT_CLONES, PATTERN>
                                                        widget();
  myWidget()
  {
    for(int i = 0; i<NUM_INPUTS; i++)
    {
      adf::connect<> net0(in[i] , widget.in[i]);
    }
    for(int i = 0; i<NUM_OUTPUT_CLONES; i++)
    {
      adf::connect<> net1(widget.out[i] , out[i]);
    }
    adf::kernel *kernels = widget.getKernels();
    adf::runtime<ratio>(*kernels) = 0.5;
  }
};