dsphdl.BiquadFilter
R2026bDescription
A biquad filter is a form of infinite-impulse response (IIR) filter that separates the numerator and denominator and implements each part as a series of second-order sections connected by scaling operations. This type of filter can replace a large FIR filter that uses an impractical amount of hardware resources. Designs often use biquad filters as DC blocking filters or to meet a specification originally implemented with an analog filter, such as a pre-emphasis filter.
The dsphdl.BiquadFilter object provides transposed architectures, a pipelined architecture to optimize throughput, or a serial minimum resource architecture that also supports multichannel input.
To filter input data with an HDL-optimized biquad filter:
Create the
dsphdl.BiquadFilterobject and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Note
You can also generate HDL code for this hardware-optimized algorithm, without creating a MATLAB® script, by using the DSP HDL IP Designer app. The app provides the same interface and configuration options as the System object™.
Creation
Description
creates an
HDL-optimized biquad filter. The default filter uses a direct form II architecture with
one section.myFilt = dsphdl.BiquadFilter
sets properties using one or more name-value arguments. For example,
myFilt = dsphdl.BiquadFilter(PropertyName=Value)
dsphdl.BiquadFilter(Structure='Direct form II transposed', ...
OutputDataType='Custom', ...
CustomOutputDataType=numerictype(1,16,14));Properties
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
Both the 'Direct form II' and 'Direct form II
transposed' architectures are pipelined and quantized to fit well into FPGA
DSP blocks. The output of these filters matches the output of the DSP System Toolbox™ System objects dsp.SOSFilter
and dsp.FourthOrderSectionFilter. These architectures minimize the number of
multipliers used by the filter but have a critical path through the feedback loop and
sometimes cannot achieve higher clock rates. These architectures do not support vector
input.
'Pipelined feedback form' implements a pipelined architecture
that uses more multipliers than either direct form II structure, but achieves higher
clock rates after synthesis. This architecture supports scalar or column vector
(frame-based) input and does not support row vector (multichannel) input. The output of
the pipelined filter is slightly different than the DSP System Toolbox functions dsp.SOSFilter
and dsp.FourthOrderSectionFilter because of the timing of data samples applied
in the pipelined filter stages.
'Direct form I fully serial' implements a fully serial
architecture that uses only one multiplier. This architecture supports scalar or row
vector (multichannel) input and does not support column vector (frame-based) input. When
you select this option, the object stores the numerator, denominator, and scale values
in the same ROM. You can control the data type of the ROM by using the
CoefficientDataType property. When you select this architecture,
the object has an output ready argument that indicates when the
object can accept new input data.
Specify the numerator coefficients as a matrix of NumSections-by-3 values, or for a multichannel filter as a NumSections-by-3-by NumChannels matrix. NumSections is the number of second-order filter sections. The object infers the number of filter sections from the size of the numerator and denominator coefficients. The numerator coefficient and denominator coefficient matrices must be the same size. The default filter has one section.
Dependencies
To specify multichannel coefficients, you must set the
Structure property to 'Direct form I fully
serial'.
Specify the denominator coefficients as a matrix of
NumSections-by-3 values, or for a multichannel filter as a
NumSections-by-3-by NumChannels matrix. The
object assumes the first denominator coefficient of each section is
1.0.NumSections is the number of second-order
filter sections. The object infers the number of sections from the size of the numerator
and denominator coefficients. The numerator coefficient and denominator coefficient
matrices must be the same size. The default filter has one section.
Dependencies
To specify multichannel coefficients, you must set the
Structure property to 'Direct form I fully
serial'.
Specify the gain values as a vector of up to NumSections+1 values, or for a multichannel filter as a matrix of up to (NumSections+1)-by-NumChannels values. NumSections is the number of second-order filter sections. The object infers the number of sections from the size of the numerator and denominator coefficients. If the vector has only one value, the object applies that gain before the first section. If you specify fewer values than there are filter sections, the object sets the remaining section gain values to one. The diagram shows a three-section filter and the locations of the four scale values before and after the sections.

Applying these gain factors outside the filter sections reduces the multipliers needed to implement the numerator of the filter.
Dependencies
To use this parameter when you set the Structure property to
'Direct form I fully serial', set
HasScaleValues to true.
To specify multichannel scale values, you must set the
Structure property to 'Direct form I fully
serial'.
Since R2026b
When you clear this parameter, the filter assumes the scale values are all equal to 1 and reduces latency by omitting the scaling calculation.
When you set this property to false, the serial filter applies
the specified ScaleValues between each filter section. This
selection matches the filter implementation and latency before R2026b.
For more information about the latency of the serial filter, see the Algorithms > Serial section on the Biquad Filter block reference page.
Dependencies
This parameter applies only when you set the Structure
property to 'Direct form I fully serial'.
Data Types
Rounding mode for type-casting the output and accumulator values to the data types
specified by the OutputDataType and
AccumulatorDataType properties. When the input data type is
floating point, the object ignores this parameter. For more details, see Rounding Modes.
Overflow handling for type-casting the output and accumulator values to the data
types specified by the OutputDataType and
AccumulatorDataType properties. When the input data type is
floating point, the object ignores the OverflowAction property.
For more details, see Overflow Handling.
Data type of numerator coefficients, specified as 'Same word length as
input' or 'Custom'.
The object type-casts the numerator coefficients to the specified data type. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is floating point, the object ignores this property.
The object returns a warning if the data type of the coefficients does not have enough fractional length to represent the coefficients accurately.
If you specify an unsigned data type for this parameter, the filter uses the unsigned values and converts them to a signed data type. The signed data type is required to map the design onto DSP slices on an FPGA.
Dependencies
To enable this property, set the Structure property to
'Direct form II', 'Direct form II
transposed', or 'Pipelined feedback form'. When you
use the serial architecture, use the CoefficientDataType
property.
Data type of denominator coefficients, specified as 'Same word length
input' or 'Custom'.
The object type-casts the denominator coefficients to the specified data type. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is floating point, the object ignores this property.
The object returns a warning if the data type of the coefficients does not have enough fractional length to represent the coefficients accurately.
If you specify an unsigned data type for this parameter, the filter uses the unsigned values and converts them to a signed data type. The signed data type is required to map the design onto DSP slices on an FPGA.
Dependencies
To enable this property, set the Structure property to
'Direct form II', 'Direct form II
transposed', or 'Pipelined feedback form'. When you
use the serial architecture, use the CoefficientDataType
property.
Data type of the scale values, specified as 'Same word length as
input' or 'Custom'.
The object type-casts the scale values to the specified data type. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is floating point, the object ignores this property.
Dependencies
To enable this property, set the Structure property to
'Direct form II', 'Direct form II
transposed', or 'Pipelined feedback form'. When you
use the serial architecture, use the CoefficientDataType
property.
Data type of the scale values, specified as 'Same word length as
input' or 'Custom'.
The object casts the numerator, denominator, and scale values to this data type and stores them in an eight-element memory of this word length. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is floating point, the object ignores this property.
If you specify an unsigned data type for this parameter, the filter uses the unsigned values and converts them to a signed data type. The signed data type is required to map the design onto DSP slices on an FPGA.
Dependencies
To enable this property, set the Structure property to
'Direct form I fully serial'.
Data type of accumulator signals within each section (as indicated in the diagrams
in the Algorithms section),
specified as 'Same as first input', or
'Custom'.
The object type-casts the output of the filter to the specified data type. The
quantization uses the settings of the RoundingMethod and
OverflowAction properties. When the input data type is floating
point, the object ignores this property.
Data type of filter output, specified as 'Same as first input',
'Full precision', or 'Custom'.
The object type-casts the output of the filter to the specified data type. The
quantization uses the settings of the RoundingMethod and
OverflowAction properties. When the input data type is floating
point, the object ignores this property.
Data type of numerator coefficients, specified as a numerictype object. To specify a numerictype object,
call numerictype(s,w,f), where:
sis1for signed and0for unsigned.wis the word length in bits.fis the number of fractional bits.
The object type-casts the numerator coefficients to the specified data type. The quantization rounds to the nearest representable value and saturates on overflow. When the input data type is floating point, the object ignores this property.
The object returns a warning if the data type of the coefficients does not have enough fractional length to represent the coefficients accurately.
Dependencies
This property applies when you set the NumeratorDataType
property to 'Custom'.
Data type of denominator coefficients, specified as a numerictype object. To specify a numerictype object,
call numerictype(s,w,f), where:
sis1for signed and0for unsigned.wis the word length in bits.fis the number of fractional bits.
Dependencies
This property applies when you set the DenominatorDataType
property to 'Custom'.
Data type of the scale values, specified as 'Same word length as first
input' or a numerictype object. To specify a
numerictype object, call numerictype(s,w,f), where:
sis1for signed and0for unsigned.wis the word length in bits.fis the number of fractional bits.
Dependencies
This property applies when you set the ScaleValuesDataType
property to 'Custom'.
Data type of coefficient memory when using serial architecture, specified as a
numerictype object. To specify a
numerictype object, call numerictype(s,w,f), where:
sis1for signed and0for unsigned.wis the word length in bits.fis the number of fractional bits.
The object casts the numerator, denominator, and scale values to this data type and stores them in an eight-element memory of this word length.
Dependencies
This property applies when you set the CoefficientsDataType
property to 'Custom'.
Data type of accumulator signals within each section (as indicated in the diagrams
in the Algorithms section),
specified as a numerictype object. To specify a
numerictype object, call numerictype(s,w,f), where:
sis1for signed and0for unsigned.wis the word length in bits.fis the number of fractional bits.
Dependencies
This property applies when you set the AccumulatorDataType
property to 'Custom'.
Data type of filter output, specified as a numerictype object. To specify a numerictype object,
call numerictype(s,w,f), where:
sis1for signed and0for unsigned.wis the word length in bits.fis the number of fractional bits.
Dependencies
This property applies when you set the OutputDataType
property to 'Custom'.
Usage
Description
Input Arguments
Input data, specified as a scalar or vector of real values. When you provide a column vector, N-by-1, the filter interprets it as N data samples over time. When you provide a row vector, 1-by-K, the filter interprets it as K independent channels. When the input has an integer or fixed-point data type, the object uses fixed-point arithmetic for internal calculations.
Column vector, or frame-based, input is supported only when you set the
Structure property to 'Pipelined feedback
form'. The object accepts vectors of powers of two up to 64 samples, but
large vector sizes can make the calculation of internal data types challenging. Vector
sizes of up to 16 samples are practical for hardware implementation.
Row vector, or multichannel, input is supported only when you set the
Structure property to 'Direct form I fully
serial'.
When you set the Structure property to 'Direct form
I fully serial', the object returns the ready
argument that indicates when the object can accept new input. Your design can react to
the ready argument before providing the next input sample, or you
can space your input data with enough cycles in between to process each sample. For
more information, see Backpressure Signal.
The software supports double and
single data types for simulation, but not for HDL code generation.
Data Types: fi | single | double | int8 | int16 | int32 | uint8 | uint16 | uint32
Control signal that indicates if the input data is valid. When
validIn is 1 (true), the
object captures the values from the dataIn argument. When
validIn is 0 (false), the
object ignores the values from the dataIn argument.
Data Types: logical
Output Arguments
Filtered output data, returned as a scalar or vector of real values. For vector input, representing either frame-based (column vector) or multichannel (row vector) data, the output dimensions match the input dimensions.
When the input data is floating point, the output data inherits the data type of
the input data. When the input data is an integer type or fixed-point type, the
OutputDataType property determines the output data type.
Data Types: fi | single | double | int8 | int16 | int32 | uint8 | uint16 | uint32
Control signal that indicates if the output data is valid. When
validOut is 1 (true), the
object returns valid data from the dataOut argument. When
validOut is 0 (false),
values from the dataOut argument are not valid.
Data Types: logical
Control signal that indicates whether the object can accept new input data. The
object sets this output to 1 (true) when it can
accept data, and sets this output to 0 (false)
when it is processing and cannot accept more data. For more information, see Backpressure Signal.
Dependencies
To enable this argument, set the Structure property to
'Direct form I fully serial'.
Data Types: logical
Object Functions
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj, use
this syntax:
release(obj)
getLatency | Latency of biquad filter |
filterAnalyzer | Analyze filters with Filter Analyzer app |
Algorithms
This System object implements the algorithms described on the Biquad Filter block reference page.
Extended Capabilities
This System object supports C/C++ code generation for accelerating MATLAB simulations, and for DPI component generation.
The software supports double and
single data types for simulation, but not for HDL code generation.
To generate HDL code from predefined System objects, see Generate HDL Code for IIR Filter.
Version History
Introduced in R2022aThe object now supports multichannel input and reduced logic for scale values equal to
1. Both features are available only when you use the
Direct form I fully serial filter structure.
For a multichannel filter, supply input data as a 1-by-K row vector, where K is the number of channels. You can use the same coefficients for all channels or specify coefficients as a N-by-3-by-K matrix, where N is the number of sections. The filter coefficients for all channels must represent the same order filter.
When you set the new HasScaleValues property to
false, the filter assumes all scale values are 1.0
and reduces latency by omitting scale value multiplication cycles. If you set this property
to true, the filter latency is the same as previous releases.
You can import this filter System object into the Filter Analyzer app, or
use it as input to the filterAnalyzer
function.
The object now has the option to set the Structure property to
'Direct form I fully serial' to implement a fully serial architecture
that uses only one multiplier. When you select this option, the object stores the numerator,
denominator, and scale values in the same ROM, and you can control the data type of the ROM
by using the CoefficientsDataType property. When you select this
architecture, the object has an output ready argument that indicates
when the object is ready for new input.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)