An ease of use enhancements with update_rtp() method is available for each FIR graph class. Method simplifies the process of updating coefficients at runtime to a single method call.
The example below demonstrates how to use the update_rtp() method in the context of a FIR filter graph class.
The test_graph class contains a member firGraph, which is a parameterized fir_sr_asym_graph FIR filter graph. The test_graph class also contains an array of coefficient RTP ports. Size of the array is determined by the getTotalRtpPorts() method of the fir_sr_asym_graph class.
The main function of the host application initializes the graph, updates the RTP ports at runtime using update_rtp with coefficients values from the std::vector taps.
Next, the main function runs the filter for a specified number of iterations and properly ends the graph execution.
// This is a header file, e.g. "test.hpp" that is included in the corresponding cpp file. class test_graph : public adf::graph { public: xf::dsp::aie::fir::tdm::fir_tdm_graph< cint16, //TT_DATA int16, //TT_COEFF 4, //TP_FIR_LEN 10, //TP_SHIFT 0, //TP_RND 128, //TP_INPUT_WINDOW_VSIZE 32, //TP_TDM_CHANNELS 1, //TP_NUM_OUTPUTS 0, //TP_DUAL_IP // 0, //TP_API 1, //TP_SSR 0, //TP_SAT 1, //TP_CASC_LEN cint32 //TT_OUT_DATA > firGraph; static constexpr int rtpPortNumber = firGraph::getTotalRtpPorts(); port_array<input, rtpPortNumber> coeff;
#include "test.hpp" xf::dsp::aie::testcase::test_graph filter; int main(void) { filter.init(); std::vector<int16> taps = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}; filter.firGraph.update_rtp(filter, taps, filter.coeff); filter.run(4); filter.end(); return 0; }
The update_rtp is a simple to use method that abstracts the implementation details of updating RTP ports with new coefficient values. It performs the following steps:
- read total number of rtp ports, using
getTotalRtpPorts(). For details see Reloadable Coefficients - Number of ports. - for each port, read the size of the port, using
getRtpPortSize(int port). For details see Reloadable Coefficients - Array Size. - for each port, extract the corresponding taps using the
extractTaps()method. For details see Reloadable Coefficients - Array Contents. - for each port, update the RTP port with the new taps using the graphs
update()method. For details see UG1079 Run-Time Parameter Update/Read Mechanisms.