Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16925 Discussions

FIR II Decimation Frequency Response

JordanD
Beginner
3,640 Views

I'm designing a filter with the FIR II IP. Input data rate is 64 MHz and decimation factor is 8. I want the frequency response to be low pass cut off at 3.2 MHz.

The confusing thing is whether the IP interprets the coefficients at the input rate or the output decimated rate. I would think it is the input rate but the displayed frequency response on the wizard shows otherwise.

I ran the provided test bench ("do decim_fir_msim.tcl") with a sweep of input frequencies and it does not match the wizard plot. Is the frequency axis in the wizard plot wrong, or am I missing something? Reference the attached Octave/Matlab script "fir_inspect.m" for simulation stimulus generation and output analysis. Design files also attached.

JordanD_0-1626901014728.png

JordanD_1-1626901074898.png

 

 

 

0 Kudos
19 Replies
CheePin_C_Intel
Employee
3,632 Views

Hi,


As I understand it, you have some inquiries related to the FIR. Thanks for sharing the screenshot and design files. Please allow me some time to further look into it and get back to you. Thank you.


0 Kudos
CheePin_C_Intel
Employee
3,609 Views

Hi,


Sorry for the delay. Please allow me few more days to investigate on this and get back to you. Sorry for the inconvenience.


0 Kudos
CheePin_C_Intel
Employee
3,582 Views

Hi,


Sorry for the delay. As I understand it, you are observing different in the FIR IP frequency response vs the plot that you obtained from the simulation. You are expecting some plot with cutoff at 3.2MHz but from your plot, you are observing cutoff ~25MHz.


1. Mind share with me the detailed step to replicate your plots ie at both Matlab and Modelsim? This would be helpful for further debugging and to engage Factory if required.


2. Would you mind to share with me what are the changes to the default IP generated files if there is any?


3. Have you had a chance to cross check with Matlab FIR to serve as a golden reference?


Please let me know if there is any concern. Thank you.


0 Kudos
JordanD
Beginner
3,557 Views

Hello @CheePin_C_Intel 

Thank you for response. I will respond to each of your items. Refer to the zip file attached earlier.

  1. Detailed steps
    1. From Matlab/Octave, set the directory to /decim_fir_sim and run the file fir_inspect. This will generate file decim_fir_input.txt.
    2. From ModelSim, set the directory to /decim_fir_sim. Enter command "do decim_fir_msim.tcl". This tcl script is provided with the IP, so you don't need to change anything. The IP testbench is already set to look for "decim_fir_input.txt" so it all just works. The sim automatically generates file "decim_fir_output.txt".
    3. From Matlab/Octave, run the same script again fir_inspect.m. This will read decim_fir_output.txt and make the plot.
  2. There are no changes to the default IP generated files.
  3. The Matlab script provided with the IP, decim_fir_model.m, generates the same output as the simulation. Beyond that, there's no use to using Matlab because it all depends what the data rate is. For example, grab coef_matrix_in from file decim_fir_mlab.m, and then run freqz(coef_matrix_in). This plots the expected frequency response, but the x axis is "normalized frequency". How does that map to what the IP is doing? That's the whole question.

JordanD_0-1628293196265.png

 

0 Kudos
CheePin_C_Intel
Employee
3,538 Views

Hi,


Thanks for your help. By the way, as I run the fir_inspect.m in the Matlab 2018b, I encountered the following error:


Error: File: fir_inspect.m Line: 5 Column: 15

Invalid use of operator.


Not sure if I miss out anything.


0 Kudos
JordanD
Beginner
3,531 Views

Apologies, please change the ** operator to ^ (attached).

0 Kudos
CheePin_C_Intel
Employee
3,524 Views

Hi,


Thanks for sharing the new file. For your information, I still get into error in Matlab with the file which I believe is related to the +=, .*, /= operators in the file. I did a search in web and seems like these operators are not supported. Would you mind to help changing to the Matlab compatible operators? Thank you.


0 Kudos
JordanD
Beginner
3,504 Views

Apologies, attached I believe I have removed all such operators.

0 Kudos
CheePin_C_Intel
Employee
3,498 Views

Hi,


Thanks for your help. Sorry for the inconvenience. I still get into the following error:


Error using .* 

Matrix dimensions must agree.


Error in fir_inspect (line 5)

sinevector=(2^(inBits-1)-1)*sin(2*pi*clock.*freqsMhz'/smpRateMhz);


It seems like the clock dimension mismatches with freqsMhz. Also, I have tested manually change the clock to 1x65, it will prompt another error on " '/ " operator. I changed to " ./ " the file can run but the simulation output is a waveform like plot which I believe due to incorrect changes from my side.


Note that I have not run the Modelsim but just testing on the .m file since there is a decim_fir_output.txt available in your folder.


Please let me know if there is any concern. Thank you.


0 Kudos
JordanD
Beginner
3,485 Views

Thanks for your patience. I've never had so much trouble with matlab compatibility... Please try the attached.

0 Kudos
CheePin_C_Intel
Employee
3,474 Views

Hi,


Thanks for your help. Sorry for the inconvenience. I still get into the matrix dimension mismatch problem with your latest file. I am not sure why there are a number of compatibility problems arise. To facilitate replication, just would like to check with you which specific Matlab version that you are testing with your fir_inspect.m? I will try to search for the closest version to see if it works. Thank you very much.


0 Kudos
JordanD
Beginner
3,465 Views

I tested it with Matlab R2021a, no problem. I also ran codeCompatibilityReport and it found no problems. Also ran with Octave 6.1.0.

0 Kudos
CheePin_C_Intel
Employee
3,457 Views

Hi,


thanks for your update. I am using R2020a. Let me try to see if I can find the 2021a version. Thank you.


0 Kudos
CheePin_C_Intel
Employee
3,453 Views

Hi,


Thanks for your help. As I run your latest fir_inspect.m in R2021a, it is passing. However, I come across different observation with yours. As shown in the following screenshot, the left one is I run with your original decim_fir2.zip + latest fir_inspect.m in R2021a only. If I fir_inspect.m in R2021a -> run Modelsim to get new decim_fir_output.txt -> rerun fir_inspect.m in R2021a, I get the right hand side plot. Not sure if I have missed out anything? Thank you.



0 Kudos
JordanD
Beginner
3,434 Views

It appears the image is broken/blocked. Can you attach instead?

0 Kudos
JordanD
Beginner
3,393 Views

@CheePin_C_Intel  Please try the new file attached. There may have been a problem with the file write. This updated script has been expanded to run the IP matlab model of the filter. I tested the entire workflow using R2021a.

0 Kudos
CheePin_C_Intel
Employee
3,373 Views

Hi,


Thanks for your update. For your information, I am currently consulting Engineering on this to seek clarification. Will keep you posted once there is any valid response from them. Thank you.


0 Kudos
CheePin_C_Intel
Employee
3,309 Views

Hi,


Sorry for the delay. For your information, our Engineering has looked into your simulation and responded that the reason the plot appears to show the cut-off frequency at ~25 MHz is because the fir_inspect.m does not account for the decimation for freqsMhz, which is defined as 0 -> Fsinput/2. To use freqsMhz for plotting the output data, use freqsMhz ./ 8.


Hope this information is helpful.


Please let me know if there is any concern. Thank you.



Best regards,

Chee Pin


0 Kudos
CheePin_C_Intel
Employee
3,222 Views

Hi,


As I understand it, it has been some time since I last heard from you. This thread will be transitioned to community support. If you have a new question, feel free to open a new thread to get the support from Intel experts. Otherwise, the community users will continue to help you on this thread. Thank you.



0 Kudos
Reply