cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using a Reloadable FIR IP in System Generator

Moderator
Moderator
1 2 1,159

This blog entry guides you through how to use the FIR filter feature of the Finite Impulse Response (FIR) compiler IP as a reloadable filter.

 

Prerequisites:

  • Basic understand of MATLAB.
  • Basic understanding of Sysgen blocks.
  • Awareness of Filter design.
  • Vivado 2018.3 and Matlab 2018a installed.

Below are the building blocks of the design:

1) Signal Generator

Signal Generator is used to generate the input signal for the FIR IP.

Signal generator can generate two types of signals:

  1. Sin tones of 1 Mhz and 16Mhz sampled at 40Mhz which are added together.
  2. A random signal over the complete frequency band.input signal.png
 

 The selection of input signal is based on a manual switch.

 

2) Reloadable Port

The timing diagram of the reloadable port is shown below:

timing.png

 

 

 

 

 

 

 

 

 

 

 

 

Note: The reload channel handles the coefficients as "UFix" type.

The reload coefficients needs to be provided as Unsigned fix type and the FIR compiler will treat them as per the "Coefficient type" in the FIR GUI.


For example if '-7' is the coefficient provided in the reload channel to the FIR, and the FIR has the Coefficient type set as Fix_16_0, then the reload coefficient value of -7 in Ufix_16_0 format will be "65529".

3) Filter Specification

This design uses two coefficient sets:

a)  Low Pass Filter (LPF) with the specifications shown below.

LPF_spec.png

b) High Pass Filter (HPF) with the specifications shown below.       

HPF_spec.png

Initially the LPF coefficients are added to FIR, then the HPF coefficients are reloaded.

Notes: 

1) Make sure that the filter coefficients are symmetric for both LPF and HPF.

It is possible for the HPF to have an asymmetric coefficient and the LPF to have a symmetric one.

In that scenario if we use the LPF in the FIR compiler with the inferred option, then we will get incorrect results.

If you have different kinds of symmetry, then use the 'non-symmetric' option in FIR.

2)  The order of both filters should be the same.

 

To run the design, please follow the steps below:

  • Download the design.
  • Invoke System Generator by selecting Start > All Programs > Xilinx Design Tools > Vivado 2018.3 >System Generator > System Generator 2018.3
  • Change the working directory to the location where Sysgen models are downloaded.
  • Open FIR_reload.slx.

       fir_reload.png

  • Click on FIR IP and run the following command in the MATLAB command window.
coeff2=xlfda_numerator('HPF');
Num = (xlGetReOrderedCoeff(coeff2,'coeff', gcbh))'; 

The command xlfda_numerator('HPF') is used to generate the coefficient for the HPF filter.

The command (xlGetReOrderedCoeff(coeff2,'coeff', gcbh))' is used to extract the coefficient which is given as input to the FIR Filter.

 matlab.png

  • Run the design and you should now observe the following:

 

Input signal: sin tone

fir_sin.png

Output signal:

fft_sin.png

sin.png

 

Input signal: Random 

random.png 

Output signal:

random_out.png

 

 

 

 

2 Comments
Observer
Observer

Hi, 

A) Inside the "Config" block you write : "Coeff Set (0: LPF, 1: HPS, 2: BPF)"  in the Signal generated as : [zeros(1,2000), zeros(1, length(Num)+1),1, zeros(1, 2000)], can you explain this part ? The number between  "...Num)+1),X,..."can be set the LPF (0) or HPF (1) ?

B) In order to Reload a new Filter ( the coefficient) , what we need to change in the Config Axis ? The number X ?

 

I have a group of 4 LPF with 30 coef each, i want to change between them.

 

Thank you so much for your example. Its really instesting and useful.


Best,
Franco

Observer
Observer

Hi Rahul 

I made  that you recommended and receive an error below after using coeff2=xlfda_numerator('HPF')

SYSGEN version 2020.1 and Matlab 2019.b 

Have you any idea what is a problem? 

Thanks

Michael

 

Num = (xlGetReOrderedCoeff(coeff2,'coeff', gcbh));
Expected coefficient length :
0

Ignoring extra coefficient values
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix
matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.

Error in xlGetReOrderedCoeff