By default, the coder obtains filter coefficients from a filter object and hardcodes them into the generated code. An HDL filter realization generated in this way cannot be used with a different set of coefficients.
For IIR filters, the coder provides GUI options and corresponding commandline properties that let you:
Generate an interface for loading coefficients from memory. Coefficients stored in memory are called programmable coefficients.
Test the interface.
To use programmable coefficients, a port interface (referred to as a processor interface) is generated for the filter entity or module. Coefficient loading is assumed to be under the control of a microprocessor that is external to the generated filter. The filter uses the loaded coefficients for processing input samples.
The following IIR filter types support programmable filter coefficients:
Secondorder section (SOS) infinite impulse response (IIR) Direct Form I
SOS IIR Direct Form I transposed
SOS IIR Direct Form II
SOS IIR Direct Form II transposed
Limitations

You can also generate a processor interface for loading FIR filter coefficients.Specifying Memory for Programmable Coefficients for further information.
You can specify a processor interface using the Coefficient source menu on the Generate HDL dialog box.
The Coefficient source list on
the Generate HDL dialog box lets you select whether coefficients are
obtained from the filter object and hardcoded (Internal
),
or from memory (Processor interface
). The default
is Internal
.
The corresponding commandline property is CoefficientSource
.
The Coefficient stimulus option on the Test Bench pane of the Generate HDL dialog box specifies how the test bench tests the generated memory interface.
The corresponding commandline property is TestBenchCoeffStimulus
.
This section describes how to use the TestBenchCoeffStimulus
property
to specify how the test bench drives the coefficient ports. You can
also use the Coefficient stimulus option for
this purpose.
When a coefficient memory interface has been generated for a
filter, the coefficient ports have associated test vectors. The TestbenchCoeffStimulus
property
determines how the test bench drives the coefficient ports.
The TestBenchStimulus
property determines
the filter input stimuli.
The TestbenchCoeffStimulus
specified the
source of coefficients used for the test bench. The valid values for TestbenchCoeffStimulus
are:
[]
: Empty vector. (default)
When the value of TestbenchCoeffStimulus
is
an empty vector, the test bench loads the coefficients from the filter
object, and then forces the input stimuli. This test shows the response
to the input stimuli and verifies that the interface writes one set
of coefficients into the memory without encountering an error.
A cell array containing the following elements:
New_Hd.ScaleValues
: column vector
of scale values for the IIR filter
New_Hd.sosMatrix
: secondorder
section (SOS) matrix for the IIR filter
You can specify the elements of the cell array in the following forms:
{New_Hd.ScaleValues,New_Hd.sosMatrix}
{New_Hd.ScaleValues;New_Hd.sosMatrix}
{New_Hd.sosMatrix,New_Hd.ScaleValues}
{New_Hd.sosMatrix;New_Hd.ScaleValues}
{New_Hd.ScaleValues}
{New_Hd.sosMatrix}
In this case, the filter processes the input stimuli twice.
First, the test bench loads the coefficients from the filter object
and forces the input stimuli to show the response. Then, the filter
loads the set of coefficients specified in the TestbenchCoeffStimulus
cell
array, and shows processes the same input stimuli again. The internal
states of the filter, as set by the first run of the input stimulus,
are retained. The test bench verifies that the interface writes two
different sets of coefficients into the register file. The test bench
also provides an example of how the memory interface can be used to
program the filter with different sets of coefficients.
If you omit New_Hd.ScaleValues
, the test
bench uses the scale values loaded from the filter object twice. Likewise,
if you omit New_Hd.sosMatrix
, the test bench uses
the SOS matrix loaded from the filter object twice.
The following table gives the address generation scheme for
the write_address
port when loading IIR coefficients
into memory. This addressing scheme allows the different types of
coefficients (scale values, numerator coefficients, and denominator
coefficients) to be loaded via a single port (coeffs_in
).
Each type of coefficient has the same word length, but can have different fractional lengths.
The address for each coefficient is divided into two fields:
Section address: Width is ceil(log_{2}N)
bits,
where N
is the number of sections.
Coefficient address: Width is three bits.
The total width of the write_address
port
is therefore ceil(log_{2}N) + 3
bits.
Section Address  Coefficient Address  Description 

S S ... S  000  Section scale value 
S S ... S  001  Numerator coefficient: b1 
S S ... S  011  Numerator coefficient: b2 
S S ... S  100  Numerator coefficient: b3 
S S ... S  101  Denominator coefficient: a2 
S S ... S  110  Denominator coefficient: a3 (if order =
2; otherwise unused) 
S S ... S  110  Unused 
0 0 ... 0  111  Last scale value 