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::sr_asym::fir_sr_asym_graph< int16, //TT_DATA int32, //TT_COEFF 32, //TP_FIR_LEN 16, //TP_SHIFT 0, //TP_RND 256, //TP_INPUT_WINDOW_VSIZE 1, //TP_CASC_LEN 0, //TP_USE_COEFF_RELOAD 1, //TP_NUM_OUTPUTS 0, //TP_DUAL_IP 0, //TP_API 1, //TP_SSR 0 //TP_SAT > 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<int32> 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}; 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.