FPGA Notes 1

1. Explanation of Other Settings on the IP Core Configuration Implementation Page:

1️⃣ Coefficient Fractional Bits

  • Function: Specifies the number of bits used for the fractional part of the FIR filter coefficients.

  • Significance: Vivado quantizes floating-point coefficients (e.g., 0.125) into fixed-point integers, calculated as follows:

    ActualValueIntegerRepresentationIndication

    Example:

    • If <span>Coefficient Width = 10</span>, <span>Coefficient Fractional Bits = 4</span>, the value range is ±(2⁹ – 1)/2⁴ = ±31.9375
    • If <span>Fractional Bits = 0</span> (as shown), it indicates that the coefficient is a pure integer without decimals.
  • General Settings:

    • If importing floating-point coefficients from MATLAB or <span>.coe</span> files, set according to actual scaling;
    • If the coefficients are integer-type filters, set to <span>0</span>.

2️⃣ Input Data Fractional Bits

  • Function: Defines the number of bits for the fractional part in the fixed-point format of the input data.

  • Significance: Determines the scaling ratio of the input signal values, and Vivado interprets the data according to this during calculations. It is used together with the coefficient fractional bits to calculate the fractional output values of the filter. This parameter is automatically set in the IP integrator but can also be overridden; this field is for reference only.

    Example:

    • For 8-bit input, <span>Input Fractional Bits = 3</span> indicates a format of Q4.3 (4 bits integer + 3 bits fractional), with an actual input range of approximately ±16.
    • If it is <span>0</span>, then the input is an integer signal.
  • Note: The input fractional bits and coefficient fractional bits together determine the filter output precision and overflow risk.

3️⃣ Output Rounding Mode

  • Function: Determines how Vivado rounds when the multiply-accumulate result is truncated to the specified output bit width.
  • Significance: Used to balance output precision and error distribution.
Mode Description
Full Precision No rounding or truncation, retains full precision (output may widen).
Truncate LSBs Directly truncates the lower bits (simple but error biased negatively).
Non Symmetric Rounding Down All values round down.
Non Symmetric Rounding Up All values round up.
Symmetric Rounding to Zero Positive numbers round down, negative numbers round up towards zero.
Symmetric Rounding to Infinity Positive numbers round up, negative numbers round down away from zero.
Convergent Rounding to Even Banker’s rounding, rounds to the nearest even number when the decimal is 0.5.
Convergent Rounding to Odd Rounds to the nearest odd number when the decimal is 0.5.
  • Recommended Settings:
    • Convergent Rounding to Even (default): Balances precision and error.
    • Full Precision: Pursues high precision output.
    • Truncate LSBs: Use when resources are tight or speed is prioritized.

✅ Parameter Summary Table

Parameter Function Common Settings Description
Coefficient Fractional Bits Coefficient Fractional Bits 0 or adjusted according to <span>.coe</span> file Controls coefficient quantization precision
Input Data Fractional Bits Input Fractional Bits 0-2 Controls input scaling ratio
Output Rounding Mode Output Rounding Method Convergent Rounding to Even Balances precision and error

Coefficient Structure

This option is used to specify the Coefficient Symmetry of the FIR filter, i.e., whether the filter coefficients are symmetric about the midpoint. Symmetry affects the implementation method, hardware resource usage, and performance of the filter.

The Vivado FIR Compiler IP provides three options:

1️⃣ Inferred

  • Meaning: Vivado automatically determines whether the filter coefficients are symmetric.
  • Function: After importing or specifying coefficients, Vivado checks for symmetry. If satisfied, symmetry will be enabled to save resources; if not, it will implement as asymmetric structure.
  • Advantages: Automatic optimization, no manual intervention required.
  • Recommended Usage Scenario: General usage scenarios, especially when generating coefficients through MATLAB or <span>.coe</span> files.

2️⃣ Non Symmetric

  • Meaning: Forces the filter to be non-symmetric. Vivado will not attempt to optimize the number of multipliers.
  • Function: Each filter coefficient undergoes multiplication separately.
  • Applicable Scenarios:
    • High-pass or band-pass filters (coefficients are usually asymmetric);
    • Complex filters;
    • Special custom filters.
  • Advantages: Suitable for any filter;
  • Disadvantages: Higher hardware resource usage (more multipliers).

3️⃣ Symmetric

  • Meaning: Forces Vivado to consider the filter coefficients symmetric about the midpoint.
  • Function: Vivado implements using a symmetric structure, reducing the number of multipliers.

✅ Usage Recommendations

Filter Type Recommended Option Description
Low-pass / Band-stop Filter Symmetric or Inferred Coefficients are usually symmetric, saving resources
High-pass / Band-pass Filter Non Symmetric Coefficients are generally asymmetric
Custom Coefficients (Unknown) Inferred Automatic determination is the safest (recommended option)
Complex Filter Non Symmetric Not suitable for symmetric structure

2. Two Main Design Methods for FIR Filters: Window Method vs Equiripple Method

Common design methods for FIR (Finite Impulse Response) filters mainly fall into two categories:

  1. Window Method
  2. Equiripple Method

Both are used to design filters that meet specific frequency response requirements, but their principles, performance, and flexibility differ.

1. Window Method

🔹 Basic Principle

The idea of the window method is:

  1. First, design an ideal filter (such as the ideal low-pass sinc function).
  2. Then truncate it with a finite-length Window Function to make it finite-length, resulting in a realizable FIR filter.

Mathematical Form:

Where:

  • : Ideal filter (infinite-length sinc)
  • : Window function

🔹 Advantages

  • Simple principle, low computational load;
  • Good stability;
  • Suitable for quick design, teaching, or resource-limited scenarios.

🔹 Disadvantages

  • Difficult to precisely control passband and stopband specifications;
  • Stopband attenuation and transition bandwidth depend on the type of window function;
  • Lower design freedom.

🔹 Common Window Functions

Window Function Characteristics Stopband Attenuation (dB) Transition Bandwidth (Relative Width)
Rectangular Narrowest main lobe, but high side lobes, severe leakage ~21 Narrow
Hanning Smooth transition, lower side lobes ~44 Medium
Hamming Smaller passband ripple, suitable for audio ~53 Medium
Blackman Higher attenuation, wider transition bandwidth ~74 Wide
Kaiser Adjustable parameter β controls bandwidth and attenuation balance Adjustable Adjustable
Gaussian Smooth but slightly higher computational load Adjustable Adjustable
Chebyshev Minimum side lobe energy ~100 Wide

Common Recommendations:

  • Generally use Hamming (audio, general scenarios)
  • If higher stopband suppression or custom attenuation is needed, use Kaiser (with adjustable β parameter)

🧮 2. Equiripple Method

🔹 Basic Principle

The Equiripple Method (also known as the Parks-McClellan Algorithm) uses optimization algorithms to evenly distribute the errors (ripples) in the passband and stopband, hence “equiripple”.

The design goal is to minimize the maximum amplitude error (minimax optimization):

Where is the ideal frequency response.

🔹 Advantages

  • High accuracy: Can strictly control ,;
  • Uniform distribution of passband and stopband ripples, optimal performance;
  • Minimization of order (minimum length that meets specifications).

🔹 Disadvantages

  • High computational complexity;
  • Not suitable for dynamic real-time designs;
  • Longer design time (but MATLAB can automate).

🧾 Comparison Summary

Characteristic Window Method Equiripple Method
Design Principle Truncation of ideal filter Optimization of error distribution (Parks-McClellan)
Control Parameters Difficult to control ripples Can precisely control pass/stopband ripples
Order Determined by experience Automatically minimized
Complexity Low High
Typical Use Quick design, teaching, low-end hardware High-performance filters, strict specification applications
MATLAB Option “Window Method” “Equiripple Method”

💡 Practical Suggestions

  • If the goal is just to generate <span>.coe</span> files for import into Vivado or for simple filtering, choose Window Method (Hamming/Kaiser).
  • If strict filtering performance is required (e.g., specific passband/stopband ripple specifications), choose Equiripple Method.

🧰 Tips (in MATLAB FDATool)

  • Switch method location: Lower left corner of the Design Method.
  • Select window type: Right-side window under “Window” dropdown menu (as shown).
  • Kaiser window supports setting β parameter, used to balance bandwidth and stopband attenuation.

3. Density Factor Appearing in MATLAB Filter Tool

🔹 Parameter Location

Located in the “Options” area, the default value is usually 20.

🔹 Meaning

The density factor determines the density of sampling in the frequency domain during the filter design process. In other words, it controls how many frequency points are sampled in the range of 0 ~ π (or 0 ~ Fs/2) for error calculation and optimization.

🔹 Specific Effects

  • Higher density factor → more accurate frequency response fitting, but increased computation time;
  • Lower density factor → faster design speed, but may result in uneven ripples or larger response errors.

🔹 General Recommendations

Design Purpose Recommended Value Description
General FIR Filter 16 ~ 25 Balance between accuracy and speed
High Frequency Resolution Required 30 ~ 50 Improves transition band shape
Fast Preview / Preliminary Design Below 10 Faster computation but slightly larger errors

💡 Tip: The density factor does not change the filter order, it only affects the frequency sampling distribution during the optimization process.

Leave a Comment