programmable fir filter for fpga -凯发k8网页登录
this example shows how to implement a programmable fir filter for hardware. you can program the filter to the required response by loading the coefficients into internal registers using a memory-style interface.
this example implements a bank of two filters, each with a different response. both filters have the same length and symmetry of coefficients. this pattern of coefficients allows the block to share multipliers for symmetric coefficients in the same way for both filters. the same filter hardware can be programmed with new coefficients to obtain a different filter response.
model programmable fir filter
this example implements two fir filters, one with a lowpass response and the other with a highpass response. the coefficients are specified in the model properties>callbacks>initfcn function.
the programmable fir(memory interface) subsystem contains the discrete fir filter block, with the coefficients source parameter set to input port (memory interface)
. this configuration enables a memory-style set of ports where you can write the coefficients into the filter. first, the host behavioral model subsystem loads the lowpass coefficients to the fir filter. the model delays the input chirp samples until the first coefficient write is complete. then the host behavioral model subsystem loads the highpass coefficients.
while you write coefficients to the filter, the filter ignores any input data samples. this model stops sending input data while the coefficients are changing. you can also use the output valid signal to determine when the output data is valid.
the discrete fir filter block in this model is configured to use a fully parallel direct form systolic architecture. the block also supports using the memory-style programmable coefficients when the block uses the parallel transposed or serial architectures. the coefficient prototype parameter is set to one of the coefficient vectors. this setting enables the block to optimize hardware resources based on the symmetry and position of zero-valued coefficients. when you specify a prototype, all input coefficient sets must match the prototype in symmetry and location of zero-valued coefficients. for more detail about how to use the prototype to optimize filter resources, see (dsp hdl toolbox).
simulink simulation results
to view the input and output data and the signals of the coefficient interface, open the scope and run the example model.
using the logic analyzer
you can also view the signals from the model in the logic analyzer. the logic analyzer enables you to view multiple signals in one window and lets you find the transitions in the signals and measure the latency between signals.
launch the logic analyzer from the model's toolstrip.
the model already has some signals of interest (input coefficients, write address, write enable, write done, filter in, filter out, and valid signals) added to the logic analyzer for observation.
the logic analyzer display can also be controlled on a per-wave or per-divider basis. to modify an individual wave or divider, select a wave or divider and then click the waves tab. a useful mode of visualization in the logic analyzer is the analog
format.
for more information, see .
generate hdl code and test bench
you must have an hdl coder™ license to generate hdl code for this example model. use this command to generate hdl code.
systemname = [modelname '/programmable fir(memory interface)'];
makehdl(systemname);
use this command to generate a test bench that compares the results of an hdl simulation against the simulink simulation behavior.
makehdltb(systemname);
see also
| (dsp hdl toolbox)
related topics
- (dsp hdl toolbox)