Implementingiir Firfilters
Implementingiir Firfilters
Rev. 2
Implementing
IIR/FIR Filters
with
Motorola's
DSP56000/SPS/DSP56001
Digital Signal
Processors
M o t o r o l a ’ s H i g h - P e r f o r m a n c e D S P T e c h n o l o g y
Motorola
Digital Signal
Processors
Implementing IIR/FIR
Filters with Motorola’s
DSP56000/DSP56001
by
John Lane and Garth Hillman
Digital Signal Processing Division
MOTOROLA APR 7
© Motorola Inc. 1993
Motorola reserves the right to make changes without further notice to any products here-
in. Motorola makes no warranty, representation or guarantee regarding the suitability of
its products for any particular purpose, nor does Motorola assume any liability arising out
of the application or use of any product or circuit, and specifically disclaims any and all
liability, including without limitation consequential or incidental damages. “Typical” pa-
rameters can and do vary in different applications. All operating parameters, including
“Typicals” must be validated for each customer application by customer’s technical ex-
perts. Motorola does not convey any license under its patent rights nor the rights of oth-
ers. Motorola products are not designed, intended, or authorized for use as components
in systems intended for surgical implant into the body, or other applications intended to
support or sustain life, or for any other application in which the failure of the Motorola
product could create a situation where personal injury or death may occur. Should Buyer
purchase or use Motorola products for any such unintended or unauthorized application,
Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affili-
ates, and distributors harmless against all claims, costs, damages, and expenses, and
reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury
or death associated with such unintended or unauthorized use, even if such claim alleg-
es that Motorola was negligent regarding the design or manufacture of the part. Motorola
and B are registered trademarks of Motorola, Inc. Motorola, Inc. is an Equal Opportunity/
Affirmative Action Employer.
Table
of Contents
SECTION 1 1.1 Analog RCL Filter Types 1-4
Introduction 1.2 Analog Lowpass Filter 1-5
1.3 Analog Highpass Filter 1-9
1.4 Analog Bandstop Filter 1-9
1.5 Analog Bandpass Filter 1-12
MOTOROLA iii
Table
of Contents
SECTION 6 6.1 Canonic Implementation 6-2
Filter Design 6.2 Transpose Implementation
and Analysis (Direct Form I) 6-14
System
REFERENCES Reference-1
iv MOTOROLA
Illustrations
Figure 1-1 s-Domain Analysis of Second-Order Lowpass
Analog Filter 1-6
MOTOROLA v
Illustrations
Figure 2-3 Gain and Phase Response of Second-Order
Lowpass IIR Filter 2-13
Figure 2-4 DSP56001 Code and Data Structures for
Second-Order Direct-Form Implementation
of a Lowpass IIR Filter 2-14
Figure 2-5 Direct-Form Implementation of Second Order
Highpass IIR Filter and Analytical Formulas
Relating Desired Response to Filter Coefficients 2-15
Figure 2-6 Gain and Phase Response of Second-Order
Highpass IIR Filter 2-16
Figure 2-7 DSP56001 Code and Data Structures for
Second-Order Direct-Form Implementation
of a Highpass IIR Filter 2-17
Figure 2-8 Direct-Form Implementation of Second-Order
Bandstop IIR Filter and Analytical Formulas
Relating Desired Response to Filter Coefficients 2-19
Figure 2-9 DSP56001 Code and Data Structures for
Second-Order Direct-Form Implementation
of a Bandstop IIR Filter 2-20
Figure 2-10 Gain and Phase Response of Second-Order
Bandstop IIR Filter 2-21
Figure 2-11 Direct-Form Implementation of Second-Order
Bandpass IIR Filter and Analytical Formulas
Relating Desired Response to Filter Coefficients 2-23
Figure 2-12 DSP56001 Code and Data Structures for
Second-Order Direct-Form Implementation
of a Bandpass IIR Filter 2-24
vi MOTOROLA
Illustrations
Figure 2-13 Gain and Phase Response of Second-Order
Bandpass IIR Filter 2-25
Figure 2-14 Summary of Digital Coefficients for the Four
Basic Filter Types 2-26
Figure 2-15 Pole Location and Analysis of Second-Order
Section 2-27
MOTOROLA vii
Illustrations
Figure 4-4 Total Gain and Gain at Internal Nodes of Lowpass
Transpose Filter Network Figure 4-1
for fs =1000Hz 4-6
Figure 4-5 DSP56001 Code and Data Structures for Single-
Section Second-Order Transpose Form 4-7
viii MOTOROLA
Illustrations
Figure 6-5 FDAS.OUT File of Example Filter for Cascaded
Canonic Implementation 6-7
Figure 6-6 COEFF.OUT File of Example Filter Design – Scaled
for Cascaded Canonic Implementation 6-9
Figure 6-7 COEFF.ASM File Generated by MGEN for Example
Design and Cascaded Canonic Implementation 6-10
Figure 6-8 FDAS.OUT File of Example Filter for Cascaded
Transpose – Form Implementation 6-15
Figure 6-9 COEFF.FLT File for Example Filer Design – Scaled
for Cascaded Transpose Form 6-17
Figure 6-10 COEFF.ASM File Generated by MGEN for Example
Design and Cascaded Transpose – Form
Implementation 6-18
MOTOROLA ix
Illustrations
Figure 7-9 Window Function Effects on Filter Example 7- 21
Figure 7-10 FDAS Output for FIR Bandpass Filter Example
with a Kaiser Window 7-23
Figure 7-11 FDAS Output for FIR Bandpass Filter Example
with Equiripple Design 7-28
Figure 7-12 FIR Filter Example 7-31
x MOTOROLA
SECTION 1
Introduction
“Two classes of SECTION 1
frequency-
selective digital
This application note considers the design of frequen-
cy-selective filters, which modify the frequency content
filters are
and phase of input signals according to some specifi-
considered:
cation. Two classes of frequency-selective digital filters
infinite impulse
are considered: infinite impulse response (IIR) and fi-
response (IIR)
nite impulse response (FIR) filters. The design process
and finite
consists of determining the coefficients of the IIR or FIR
impulse
filters, which results in the desired magnitude and
response (FIR)
phase response being closely approximated.
filters.”
Therefore, this application note has a two-fold purpose:
MOTOROLA 1-1
equivalent functions in the digital z-domain. In
keeping with this analog perspective, IIR filters will
be discussed first since the equivalent of FIR filters
are infrequently encountered in the analog world.
1-2 MOTOROLA
occurs when the accumulator width is insufficient to
represent all the bits resulting from many consecu-
tive additions. This condition is similar to the
condition in the analog world in which the signal out-
put is larger than the amplifier power supply so that
saturation occurs. A short analysis of the gain at
critical nodes in the filters is given in SECTION 3
and SECTION 4 to provide some insight into the
scaling requirements for different forms of IIR filters.
For this reason, the signal flow graphs developed
are centralized about the accumulator nodes.
MOTOROLA 1-3
is taken to calculating the filter coefficients by start-
ing from a desired arbitrary frequency response.
The importance of and constraint imposed by linear
phase is emphasized. Having developed an intuitive
appreciation of what FIR filter coefficients are, the use
of FDAS to accelerate the design process is de-
scribed. SECTION 7 concludes by showing how the
filter coefficients just determined can be used in
DSP56000 code to implement practical digital filters.
An example of a passband digital filter using a Kaiser-
window design approach is presented.
1-4 MOTOROLA
viation of the actual response from the predicted
response is small enough to neglect in most cases.
General analysis techniques consist of a linear
combination of steady-state and transient re-
sponse solutions to the differential equations
describing the network.
MOTOROLA 1-5
solving the differential equation is a common simpli-
fication used in this type of analysis.
1-6 MOTOROLA
V0 CX ||R Vi V0 Xc = 1/jΩC
----- = ------------
- L
Vi X L ||R C R
1
1/LC
= ------------------------------------------------- Ωc = -----------
LC
– Ω 2 + jΩ /RC + 1 / LC
Ω c2 L
= ------------------------------------------- d = ------------
– Ω 2 + jdΩ c Ω + Ω c2 R C
2
G(Ω) ≡ H ( s ) H∗ ( s )
s = jω
1
= ---------------------------------------------------------------
-
2 2 2 2
( 1 – Ω /Ω c ) + ( dΩ/Ω c )
where ∗ denotes complex conjugate.
The phase angle, φΩ, is the angle between the imaginary and
real components of H(s).
–1
φ ( Ω ) ≡ tan [ l { H ( s ) }/R { H ( s ) } ]
–1 d ( Ω/Ω c ) for Ω ≤ Ωc
= – tan ------------------------------
2
-
1 – ( Ω/Ω c )
MOTOROLA 1-7
1.5
d=0.707
d=1.0
1.0 d=1.41
Gain
d=2.0
0.5
0.1 1.0 10
Normalized Frequency (Ω/Ωc)
0 d=0.707
d=1.0
d=1.41
d=2.0
Phase
-π/2
-π
0.1 1.0 10
Normalized Frequency (Ω/Ωc)
Figure 1-2 Gain and Phase Response of Second-Order Lowpass Analog
Filter at Various Values of Damping Factor, d
1-8 MOTOROLA
of the system; whereas, the ratio of the imaginary
part to real part of H(s), I{H(jΩ)}/R{H(jΩ)}, is the tan-
gent of the phase, φ(Ω), introduced by the filter. If
the input signal is Ak sin (Ωkt + φK), then the output
signal is AKG(ΩK) sin [ΩKt + φK+ φ(ΩK)] Figure 1-2
shows the gain, G(Ω), and phase, φ(Ω), plots for the
second-order lowpass network of Figure 1-1 for var-
ious values of damping factor, d; d also controls the
amplitude and position of the peak of the normal-
ized response curve.
2
Ω M = Ω c ( 1 – d /2 ) Eqn. 1-1
1
G M = ---------------------------------- Eqn. 1-2
2
d ( 1 – d /4 )
MOTOROLA 1-9
1.3 Analog Highpass Filter
The passive RCL circuit forming a highpass filter
network is shown in Figure 1-3 where the transfer
function, H(s), is again derived from a voltage divid-
er analysis of the RCL network. The gain and phase
response are plotted in Figure 1-4 for different val-
ues of damping coefficient. As evidenced, the
highpass filter response is the mirror image of the
lowpass filter response.
1-10 MOTOROLA
V0 X ||R
L Vi V0 Xc = 1/jΩC
----- = ------------------------
-
Vi X C + X L ||R C
L R
j Ω LR / ( jΩ L + R ) XL = jΩL
= --------------------------------------------------------
1/j ΩC + j Ω LR / jΩ L + R
–Ω2 1
= ------------------------------------------------- Ωc = -----------
2 LC
– Ω + jΩ /RC + 1 / LC
–Ω2 L
d = ------------
= -------------------------------------------
2
– Ω + jdΩ c Ω + Ω c2 2
R C
G(Ω) ≡ H ( s ) H∗ ( s )
s = jω 2
( Ω/Ω c )
= ---------------------------------------------------------------
-
2 2
( 1 – Ω 2 /Ω 2c ) + ( dΩ/Ω c )
where ∗ denotes complex conjugate.
The phase angle, φΩ, is the angle between the imaginary and
real components of H(s).
–1
φ ( Ω ) ≡ tan [ l { H ( s ) }/R { H ( s ) } ]
–1 d ( Ω/Ω c ) for Ω ≤ Ωc
= π – tan ------------------------------
2
-
1 – ( Ω/Ω c )
MOTOROLA 1-11
1.5
d=0.707
d=1.0
d=1.414
1.0 d=2.0
Gain
0.5
0.1 1.0 10
Normalized Frequency (Ω/Ωc)
π d=0.707
d=1.0
d=1.414
d=2.0
Phase
π/2
0.1 1.0 10
Normalized Frequency (Ω/Ωc)
Figure 1-4 Gain and Phase Response of Second-Order Highpass Analog Filter
at Various Values of Damping Factor, d
1-12 MOTOROLA
1.5 Analog Bandpass Filter
The passive RCL circuit forming a bandpass filter
network is shown in Figure 1-7 where the transfer
function, H(s), is again derived from a voltage di-
vider analysis of the RCL network. The gain and
phase response are plotted in Figure 1-8 for differ-
ent values of Q. The lowpass gain approaches an
asymptotic function of G = (fc/f)2 for f/fO >> 1. The
highpass asymptotic gain is G = (fC/f)2 for f/fC << 1;
whereas, the bandstop case approaches unity at
zero and infinity with a true zero at the center fre-
quency. The bandpass gain, on the other hand,
approaches G = Q-1f/fC for f/fc << 1 and G = Q-1fc/f
for f/fc >> 1. The primary differences to note in the
bandpass response are:
1. the stopband attenuation is 6 dB/octave or
20 dB/decade (since it goes as 1/f); whereas,
the lowpass and highpass go as l/f2 (12 dB/
octave, 40 dB/decade)
2. the stopband attenuation asymptote is dependent
on the quality factor; whereas, for the lowpass and
highpass cases, the stopband attenuation
asymptote is independent of damping factor, d
3. the maximum value of gain is unity regardless of
the filter Q.
MOTOROLA 1-13
L
V0 R Vi V0 Xc = 1/jΩC
----- = ------------------------
Vi x C ||X + R
L R
C
R XL = jΩL
= -------------------------------------------------------------------
R + ( jΩL/jΩC ) / ( jΩL + 1/jΩC )
– Ω 2 + 1/LC 1
Ωc = ----------
= -------------------------------------------------
2 LC
– Ω + jΩ /RC + 1 / LC
– Ω 2 + Ω 02 2
= ---------------------------------------------- Q = 1/d = R C/L
– Ω 2 + jΩ 0 Ω/Q + Ω 02
G(Ω) ≡ H ( s ) H∗ ( s )
s = jω
2
– ( Ω/Ω 0 ) 1
= ---------------------------------------------------------------
2 2
( 1 – Ω 2 /Ω 20 ) + Ω/Ω 0 Q )
where ∗ denotes complex conjugate.
The phase angle, φΩ, is the angle between the imaginary and
real components of H(s).
–1
φ ( Ω ) ≡ tan [ l { H ( s ) }/R { H ( s ) } ]
–1
( Ω/Ω 0 Q )
= – tan --------------------------------
2
1 – ( Ω/Ω 0 )
1-14 MOTOROLA
1.0 d=0.707
d=1.0
d=1.414
d=2.0
Gain
0.5
0.1 1.0 10
Normalized Frequency (Ω/Ω0)
π/2
d=0.707
d=1.0
Phase
d=1.414
0
d=2.0
-π/2
0.1 1.0 10
Normalized Frequency (Ω/Ω0)
Figure 1-6 Gain and Phase Response of Second-Order Bandstop Analog Filter
at Various Values of Damping Factor, d
MOTOROLA 1-15
V0 R Vi V0 Xc = 1/jΩC
----- = ----------------------------
Vi XL + XC + R L C R
XL = jΩL
R
= ---------------------------------
jΩL + 1/jΩ + R
1
jΩR/L Ωc = ----------
= ----------------------------------------------- LC
– Ω 2 + jΩ R/L + 1/LC
jΩ 0 Ω/Q
= ---------------------------------------------- 2
2 Q = 1/d = R C/L
– Ω + jΩ 0 Ω/Q + Ω 02
G(Ω) ≡ H ( s ) H∗ ( s )
s = jω
Ω/Ω Q 0
= ----------------------------------------------------------------
-
2 2 2 2
( 1 – Ω /Ω 0 ) + ( Ω/Ω 0 Q )
–1 Ω/Ω 0 Q
= tan ------------------------------
-
2
1 – ( Ω/Ω 0 )
1-16 MOTOROLA
1.0
d=1.414
d=2.0
Gain
0.5
d=0.707
d=1.0
π/2 d=0.707
d=1.0
d=1.41
d=2.0
Phase
-π/2
0.1 1.0 10
Normalized Frequency (Ω/Ωc)
1-17 MOTOROLA
1-18 MOTOROLA
SECTION 2
Second-Order
Direct-Form IIR
Digital Filter Sections
“In the direct- The traditional approach to deriving the digital filter
form coefficients has been to start with the digital z-domain
implementation, description, transform to the analog s-domain to un-
the ai and bi are derstand how to design filters, then transform back to
used directly in the digital domain to implement the filter. This ap-
the difference proach is not used in this report. Instead, formulas are
equation, which developed relating the s-domain filter to the z-domain
can be easily filter so transformations to and from one domain to the
programmed on other are no longer necessary.
a high-speed
The Laplace or s-transform in the analog domain was
DSP such as the
developed to facilitate the analysis of continuous time
DSP56001.”
signals and systems. For example, using Laplace
transforms the concepts of poles and zeros, making
system analysis much faster and more systematic.
The Laplace transform of a continuous time signal is:
X(s) = L{x(t)}
∫ x ( t )e
– st Eqn. 2-3
dt
0
MOTOROLA 2-1
In the digital domain, the continuous signal, x(t), is
first sampled, then quantized by an analog-to-digital
(A/D) converter before being processed. That is, the
signal is only known at discrete points in time, which
are multiples of the sampling interval, T = 1/fs,
where fs is the sampling frequency. Because of
the sampled characteristic of a digital signal, its
z-transform is given by a summation (as opposed
to an integral):
X(z) = Z{x(n)}
∞
–n
= ∑ x ( n )z Eqn. 2-4
n = –∞
2-2 MOTOROLA
unique and depends on the viewpoint used. It is ob-
vious that the trivial mapping, s = z, is inappropriate;
the signal has been sampled. When a bandlimited
signal is sampled (i.e., multiplied by a periodic im-
pulse function), the spectrum of the resulting signal is
repetitive as shown in Figure 2-9 (see Reference 10).
S(f)
usable
region
Frequency (f)
MOTOROLA 2-3
One mapping or transformation from the s-domain
to the z-domain discussed later in this report is the
bilinear transformation. To understand the origin of
this transformation, consider the simple first-order
linear analog filter with the system function:
Y(s) b
H ( s ) = ------------ = ------------ Eqn. 2-6
X(s) s+a
d –1
----- x ( t ) = L { sX ( s ) } Eqn. 2-7
dt
d
where: x ( t ) is the time derivative of x(t)
dt
d
----- y ( t ) + ay ( t ) = bx ( t ) Eqn. 2-8
dt
2-4 MOTOROLA
where the approximate solution is given by:
1 d d
y ( t ) = --- ----- y ( t ) + ----- y ( t 0 ) ( t – t 0 ) + y ( t 0 ) Eqn. 2-10
2 dt dt
( 2 + aT )y ( n ) – ( 2 – aT )y ( n – 1 ) = bT [ x ( n ) + x ( n – 1 ) ]
Eqn. 2-11
Y(z) b
H ( z ) = ------------ = ------------------------------------- Eqn. 2-12
X(z) –1
2 1 – z
--- ------------------ + a
T
1+z
–1
2 1 – z
–1
s = --- -----------------
- Eqn. 2-13
T 1 + z –1
MOTOROLA 2-5
Although this transformation was developed using a
first-order system, it holds, in general, for an Nth-order
system (see Reference 14). By letting s = σ + jΩ and
z = rejθ, it can be shown that the left-half plane in the
s-domain is mapped inside the unit r = 1 circle in the
z-domain under the bilinear transformation. More im-
portantly, when r = 1 and σ = 0, the frequencies in the
s-domain and the z-domain are related by:
2 θ
Ω = --- tan --- Eqn. 2-14
T 2
or equivalently:
– 1 ΩT
θ = 2tan -------- Eqn. 2-15
2
2-6 MOTOROLA
with θ = Ω. In summary, the bilinear transformation
is a one-to-one nonlinear mapping from the s-do-
main into the z-domain in which high frequencies
(Ω > 2πfs/4) in the s-domain are compressed into a
small interval in the z-domain. Therefore, the gain
and phase expressions of the previous section can
be directly transformed into the digital domain by
simply substituting Eqn. 2-14 into the correspond-
ing expressions. This will be done for each filter
type in the following paragraphs.
–1 –2
b0 + b1 z + b2 z
H ( z ) = ---------------------------------------------------- Eqn. 2-16
–1 –2
1 + a1 z + a2 z
MOTOROLA 2-7
property in particular as follows:
–1 –1
Z {H(z)} = Z { Y ( z )/X ( z ) }
–1 –1 –2 –1
–2
= Z b0 + b1 z + b2 z / 1 + a1 z + a2 z
Eqn. 2-17
so that:
–1 –2 –1 –1
( z ) 1 + a1 z + a2 z = Z X ( z ) b0 + b1 z + b2
y ( n ) = b0 x ( n ) + b1 x ( n – 1 ) + b2 x ( n – 2 ) + a1 y ( n – 1 ) – a2 y ( n – 2 )
Eqn. 2-18
2-8 MOTOROLA
Eqn. 2-18 can be directly implemented in software,
where x(n) is the sample input and y(n) is the corre-
sponding filtered digital output. When the filter
output is calculated using Eqn. 2-18, y(n) is calcu-
lated using the direct-form implementation of the
digital filter.
jθc
Hz ( e ) = H s ( jΩ c ) Eqn. 2-19
MOTOROLA 2-9
Figure 2-10 are similar to the analog plots shown
in Figure 1-2, except for the asymmetry introduced
by the zero at fs/2. That is, the frequency axis is
modified so that a gain of zero at f = ∞ in the s-do-
main corresponds to a gain of zero at f = fs/2 in the
z-domain. The fact that the magnitude of the trans-
fer functions, H(s) and H(z), is identical once the
proper frequency transformation is made is very
useful for understanding the digital filter and its re-
lationship to the analog equivalent. This fact is
also useful for purposes of scaling the gain since
the maximum magnitude of Gs(ΩM) = GZ(θM),
where ΩM and θM are related by Eqn. 2-14. In oth-
er words, scaling analysis of the digital transfer
function, H(z), can be done in the s-domain (the al-
gebra is often easier to manage). Scaling of the
gain is an essential part of digital filter implemen-
tation since the region of numeric calculations on
fixed-point DSPs such as the DSP56001 are usu-
ally restricted to a range of -1 to 1.
2-10 MOTOROLA
The DSP56001 code to implement the second-or-
der lowpass filter section is shown in Figure 2-12.
The address register modifiers are initially set to
M0 = 4, M4 = 1, and M5 = 1 to allow use of the cir-
cular buffer or modulo addressing in this particular
implementation (see Reference 8). Typically, this
code would be an interrupt routine driven by the input
data (A/D converter, for example) sample rate clock.
The basic filter code and the interrupt overhead and
data l/O moves for this second-order filter could be
executed at a sample rate of nearly 1 MHz on the
DSP56001.
MOTOROLA 2-11
case but also in the code for the highpass, band-
stop, and bandpass cases.
2-12 MOTOROLA
¥¥¥
Network Diagram
α
x(n) 2 y(n)
z-1 z-1
2α γ
Σ
z-1 z-1
α −β
Transfer Function –1 –2
α ( 1 + 2z + z )
H ( z ) = ---------------------------------------------
–1 –2
1/2 – γ z + βz
Phase
– 1 2 ( cos θ – cos θ c ) for θ≤θc
tan -----------------------------------------
d sin θ sin θ c
φ(θ) =
– 1 2 ( cos θ – cos θ c )
– π + tan ----------------------------------------
d sin θ sin θ c
- for θ>θc
Coefficients
1 1 – d ⁄ 2 sin θ c
β = --- ----------------------------------
2 1 + d ⁄ 2 sin θ c
γ = ( 1/2 + β ) cos θ c
α = ( 1/2 + β – γ )/4
MOTOROLA 2-13
fo/fny=0.1 fo/fny=0.65
1.5
Lowpass Gain
1.0
d=0.707
d=1.0
d=1.41
0.5 d=2.0
0
d=0.707
Lowpass Phase
d=1.0
d=1.41
d=2.0
-π/2 fo/fny=0.1 fo/fny=0.65
-π
Figure 2-11 Gain and Phase Response of Second-Order Lowpass IIR Filter
2-14 MOTOROLA
Difference Equation
y ( n ) = 2 { α [ x ( n ) + 2x ( n – 1 ) + x ( n – 2 ) ] + γy ( n – 1 ) – βy ( n – 2 ) }
Data Structures
X:(R0) Y:(R4)
2α x(n-1)
α x(n-2)
γ
Y:(R5)
–β y(n-1)
α y(n-2)
DSP56001 Code
;Y1=x(n) (Input)
;X0=α
MPY X0,Y1,A X:(R0)+,X0 Y:(R4)+,Y0 ;A=αx(n)
MAC X0,Y0,A X:(R0)+,X0 Y:(R4),Y0 ;A=A+2αx(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5)+,Y0 ;A=A+αx(n-2)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5),Y0 ;A=A+γy(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y1,Y:(R4) ;A=A-βy(n-2)
MOVE A,X1 A,Y:(R5) ;y(n-2)=2A (assumes scaling
;mode is set).
;X1 is Output.
Figure 2-12
Figure 2-12 DSP56001 Code and Data Structures for Second-Order Direct-Form
Implementation of a Lowpass IIR Filter
MOTOROLA 2-15
Network Diagram
α
x(n) 2 y(n)
z-1 z-1
−2α γ
Σ
z-1 z-1
α −β
Transfer Function –1 –2
α ( 1 –2 z + z )
H ( z ) = ---------------------------------------------
–1 –2
1/2 – γ z + βz
Phase
– 1 2 ( cos θ – cos θ c ) for θ≤θc
π + tan -----------------------------------------
d sin θ sin θ c
φ(θ) =
–1 2 ( cos θ – cos θ c )
tan ----------------------------------------
d sin θ sin θ c
- for θ>θc
Coefficients
1 1 – d ⁄ 2 sin θ c
β = --- ----------------------------------
2 1 + d ⁄ 2 sin θ c
γ = ( 1/2 + β ) cos θ c
α = ( 1/2 + β + γ ) ⁄ 4
Figure 2-13 Direct-Form Implementation of Second Order Highpass IIR Filter and
Analytical Formulas Relating Desired Response to Filter Coefficients
2-16 MOTOROLA
fo/fny=0.1 fo/fny=0.65
1.5
HIGHPASS GAIN
1.0
d=0.707
d=1.0
0.5 d=1.41
d=2.0
π
HIGHPASS PHASE
d=0.707
d=1.0
d=1.41
π/2 d=2.0
fo/fny=0.1 fo/fny=0.65
Figure 2-14 Gain and Phase Response of Second-Order Highpass IIR Filter
MOTOROLA 2-17
Difference Equation
y ( n ) = 2 { α [ x ( n ) – 2 x ( n – 1 ) + x ( n – 2 ) ] + γy ( n – 1 ) – βy ( n – 2 ) }
Data Structures
X:(R0) Y:(R4)
−2α x(n-1)
α x(n-2)
γ
Y:(R5)
–β y(n-1)
α y(n-2)
DSP56001 Code
;Y1=x(n) (Input)
;X0=α
MPY X0,Y1,A X:(R0)+,X0 Y:(R4)+,Y0 ;A=αx(n)
MAC X0,Y0,A X:(R0)+,X0 Y:(R4),Y0 ;A=A-2αx(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5)+,Y0 ;A=A+αx(n-2)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5),Y0 ;A=A+γy(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y1,Y:(R4) ;A=A-βy(n-2)
MOVE A,X1 A,Y:(R5) ;y(n)=2A (assumes scaling
;mode is set).
;X1 is Output.
Figure 2-15 DSP56001 Code and Data Structures for Second-Order Direct-Form
Implementation of a Highpass IIR Filter
2-18 MOTOROLA
2.8 Digital Bandstop Filter
The formulas and network diagram for the digital
bandstop filter are presented in Figure 2-16. The
DSP56001 code from Figure 2-17 is identical to that
for the lowpass and highpass cases except for the
coefficient data calculated from the equations of
Figure 2-16. Scaling of this filter is not a problem for
the singlesection case since the gain from the
equation in Figure 2-16 never exceeds unity (as is
true in the analog case as seen by the gain equation
from Figure 1-5). Figure 2-18 is the calculated gain
and phase of the digital filter, which should compare
to the response curves of the equivalent analog fil-
ter plotted in Figure 1-6.
MOTOROLA 2-19
Network Diagram α
x(n) 2 y(n)
z-1 z-1
−2αcosθ0 γ
Σ
z-1 z-1
α −β
Transfer Function –1 –2
α ( 1 – 2 cosθ 0 z + z )
H ( z ) = --------------------------------------------------------
-
–1 –2
1/2 – γ z + βz
Phase
–1 2 ( cos θ – cos θ 0 )
φ ( θ ) = tan ----------------------------------------
-
d sin θ sin θ 0
1 1 – tan ( θ 0 /2Q )
β = --- --------------------------------------
2 1 + tan ( θ 0 /2Q )
γ = ( 1/2 + β ) cos θ 0
α = ( 1/2 + β )/2
Figure 2-16 Direct-Form Implementation of Second-Order Bandstop IIR Filter and
Analytical Formulas Relating Desired Response to Filter Coefficients
2-20 MOTOROLA
Difference Equation
y ( n ) = 2 { α [ x ( n ) – 2 cos θ 0 x ( n – 1 ) + x ( n – 2 ) ] + γy ( n – 1 ) – βy ( n – 2 ) }
Data Structures
X:(R0) Y:(R4)
−2αcosθ0 x(n-1)
α x(n-2)
γ
Y:(R5)
–β y(n-1)
α y(n-2)
DSP56001 Code
;Y1=x(n) (Input)
;X0=α
MPY X0,Y1,A X:(R0)+,X0 Y:(R4)+,Y0 ;A=αx(n)
MAC X0,Y0,A X:(R0)+,X0 Y:(R4),Y0 ;A=A-2αcosq0x(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5)+,Y0 ;A=A+αx(n-2)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5),Y0 ;A=A+γy(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y1,Y:(R4) ;A=A-βy(n-2)
MOVE A,X1 A,Y:(R5) ;y(n)=2A (assumes scaling
; mode is set).
;X1 is Output.
Figure 2-17 DSP56001 Code and Data Structures for Second-Order Direct-Form
Implementation of a Bandstop IIR Filter
MOTOROLA 2-21
1.5
BANDSTOP GAIN
fo/fny=0.1 fo/fny=0.65
1.0
0.5 d=0.707
d=1.0
d=1.41
0 d=2.0
fo/fny=0.1 fo/fny=0.65
π/2
d=0.707
d=1.0
π d=1.41
d=2.0
Figure 2-18 Gain and Phase Response of Second-Order Bandstop IIR Filter
2-22 MOTOROLA
2.10 Summary of Digital
Coefficients
Figure 2-22 gives a summary of the coefficient val-
ues for the four basic filter types. Note that the
coefficient, β has the same form for all four filter
types and that it can only assume values between
0 and 1/2 for practical filters. β is bounded by 1/2
because Q (or d) and θ0 are not independent. For
Q >> 1, β→1/2; whereas, for θ0 = fs/4 and Q = 1/2,
β→0. These properties are independent of the form
of implementation; they are only dependent on the
form of the transfer function. Alternate implementa-
tions (difference equations) will be described in the
following sections.
MOTOROLA 2-23
Network Diagram
α
x(n) 2 y(n)
z-1 z-1
γ
Σ
z-1 z-1
−α −β
Transfer Function –2
α(1 – z )
H ( z ) = ---------------------------------------------
–1 –2
1/2 – γ z + βz
Phase
–1 2 ( cos θ – cos θ 0 )
φ ( θ ) = – tan -----------------------------------------
d sin θ sin θ 0
1 1 – tan ( θ 0 /2Q )
β = --- --------------------------------------
2 1 + tan ( θ 0 /2Q )
γ = ( 1/2 + β ) cos θ 0
α = ( 1/2 – β )/2
2-24 MOTOROLA
Difference Equation
y ( n ) = 2 { α [ x ( n ) – x ( n – 2 ) ] + γy ( n – 1 ) – βy ( n – 2 ) }
Data Structures
X:(R0) Y:(R4)
−α x(n-1)
γ x(n-2)
–β
Y:(R5)
α y(n-1)
y(n-2)
DSP56001 Code
;Y1=x(n) (Input)
;X0=α
MPY X0,Y1,A X:(R0)+,X0 Y:(R4),Y0 ;A=αx(n)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5)+,Y0 ;A=A-αx(n-2)
MAC X0,Y0,A X:(R0)+,X0 Y:(R5),Y0 ;A=A+γy(n-1)
MAC X0,Y0,A X:(R0)+,X0 Y1,Y:(R4)+ ;A=A-βy(n-2)
MOVE A,X1 A,Y:(R5) ;y(n)=2A (assumes scaling
; mode is set).
;X1 is Output.
MOTOROLA 2-25
fo/fny=0.1 fo/fny=0.65
1.5
BANDPASS GAIN
d=0.707
d=1.0
d=1.41
1.0 d=2.0
0.5
π/2
d=0.707
d=1.0
d=1.41
d=2.0
0
fo/fny=0.1 fo/fny=0.65
-π/2
Figure 2-21 Gain and Phase Response of Second-Order Bandpass IIR Filter
2-26 MOTOROLA
Z-Domain Transfer Function
–1 –2
α ( 1 + µz + σz )
H ( z ) = -------------------------------------------------
–1 –2
1/2 – γ z + βz
Coefficients
Numerator Coefficients
Type α µ σ Unity Gain at
NOTE: θ0 = 2πf0/fs
Figure 2-22 Summary of Digital Coefficients for the Four Basic Filter Types
MOTOROLA 2-27
Pole Equation of H(z) Z p = r cos θ p + jr sin θ p
2
= γ ± j 2β – γ
For d<2
2
cos θ 0 ± j sin θ 0 1 – ( 1/2d )
= --------------------------------------------------------------------
1
1 + --- d sin θ 0
2
1 γ = ( 1/2 + β ) cos θ 0
where: β = --- ( 2 – d sin θ 0 )/ ( 2 + d sin θ 0 ) and
2
Distance from Origin to Pole is Z p = 2β
2
For d>2 Z p = γ – γ – 2β
2
cos θ 0 – sin θ 0 ( 1/2d ) – 1
= -----------------------------------------------------------------
-
1
1 + --- d sin θ 0
2
1
where: θ p = 0 To satisfy requirement 0<β<1/2 results in --- d sin θ 0 < 1
2
Im[z]
Center or Cutoff
Z0 Frequency
Zp θ0
Pole
θp
Re[z]
r = 2β
2-28 MOTOROLA
APR7section3 Page 1 Monday, June 2, 1997 1:51 PM
SECTION 3
Single-Section
Canonic Form
(Direct Form II)
MOTOROLA 3-1
x(n) b0 y(n)
+ +
z-1 z-1
b1
x(n-1) + + y(n-1)
-a1
z-1 z-1
b2
x(n-2) y(n-2)
-a2
(a) Direct-Form Network Diagram of Equation 3-1
x(n) b0 y(n)
+ +
z-1 z-1
b1
+ +
-a1
z-1 z-1
b2
-a2
(b) Interchanged Left and Right Halves of Direct-form Network
z-1
b1
+ +
-a1
z-1
b2
-a2 w(n-2)
(c) Collapsing Delay Terms (part ‘a’ above) Resulting in Canonic-Form Diagram
Figure 3-24 The Second-Order Canonic (Direct Form II) IIR Filter Network
3-2 MOTOROLA
The diagram of Figure 3-24(b) represents the same
transfer function implemented by Eqn. 3-20, but
now the delay variable is w(n). Comparison of this
network with that of the direct-form network of Fig-
ure 3-24 (a) shows that interchanging the order of
the left and right halves does not change the overall
system response (see Reference 11).
MOTOROLA 3-3
The last step uses the definition for y(n) from Eqn.
3-21a. The result is exactly equivalent to Eqn. 3-
20, the direct-form difference equation. To utilize
the scaling mode on the DSP56001, it is advanta-
geous to write Eqn. 3-21a and Eqn. 3-2b as
follows:
1 µ α
y ( n ) = 2 --- w ( n ) + --- w ( n – 1 ) + ---w ( n – 2 )
2 2 2
Eqn. 3-4a
and
w ( n ) = 2 { αx ( n ) + γw ( n – 1 ) – βw ( n – 2 ) } Eqn. 3-4b
3-4 MOTOROLA
cular nature of twos-complement arithmetic).
To insure that overflow does not occur, it is necessary
to calculate the gain at the internal nodes (accumula-
tor output) of a filter network. Although canonic
realization is susceptible to overflow, it is advanta-
geous because of the minimum storage requirements
and implementation in fewer instruction cycles.
MOTOROLA 3-5
where: θp is the angle (see Figure 2-23) to the
pole of the filter
3-6 MOTOROLA
Y(z)
H ( z ) = ------------
X(x)
X(z) Y(z)
Y(z)
H w ( z ) = ------------
X(z)
α W(z)
x(n) + + 2 y(n)
(Left Shift)
2 (Left Shift)
W(z)
w(n)
w ( z ) ) z-1
--------------
z w(n-1)
+ +
γ µ
---
w ( z ) ) z-1 2
--------------
2 w(n-2)
z
−β w(n-2) σ
---
2
α ( 1 + µz + σz )
–1 –2 α
H ( z ) = ------------------------------------------------- H w ( z ) = --------------------------------------
1 1 –1 –2
--- – γ z + βz
–1 –2 --- – γ z + βz
2 2
MOTOROLA 3-7
Since this result does not depend on the numerator
of the filter transfer function, H(z), the result is valid
for all four basic filter types. However, as shown by
the example given for a bandpass network in Figure
3-26, go may exceed unity by a large amount, espe-
cially for filters having poles at frequencies much
less than fs/2 where sin θp << 1. To compensate,
the input must be scaled down by an amount equal
to 1/go or guaranteed not to exceed 1/go before ar-
riving at the filter. This scaling aspect of the
canonic-form network is a disadvantage, but this
network has the advantage of being implemented in
one less instruction than the other filter realizations
for the lowpass, highpass, and bandstop filters; of
course, less memory is required since only two inter-
mediate variables are stored.
2β cos θ o
------------- = --------------- Eqn. 3-6
1 cos θ p
--- + β
2
3-8 MOTOROLA
Gain at w(n) is: W(z) α
H w ( z ) = ------------- = ---------------------------------------
X(z) 1 –1 –2
--- – γ z + βz
2
jθ – jθ
Gw ( θ ) = H w ( e )H w ( e )
α
= --------------------------------------------------------------------------------------------------------------
2 2
1 --- – β sin θ + --- + β ( cosθ – cosθ )
2 1 2
2 2 0
1
where: γ = ( -2- + β) cos θ0 has been used.
d
Peak Gain is: ------G ( θ ) = 0
dθ w θ = θm
α otherwise
= ------------------------------------------------
1 --- + β ( 1 – cos θ 0 )
2
where γ2 = 2β2 cos2θp has been used and α= (1/2-β)/2 for a bandpass filter.
If sinθp > 1/2, then g0 <1; otherwise, an overflow (i.e., g0>1) may occur at the
internal node, w(n), unless the input is scaled down by 1/g0.
MOTOROLA 3-9
Difference Equation
1 µ σ
y ( n ) = 2 --- w ( n ) + --- w ( n – 1 ) + ---w ( n – 2 )
2 2 2
w ( n ) = 2 { αx ( n ) + γw ( n – 1 ) – βw ( n – 2 ) }
Data Structures
X:(R0) Y:(R4)
w(n-1) γ
w(n-2) −β
µ/2
σ/2
α
DSP56001 Code
;Y1=x(n) (Input)
;X0=α
MPY X0,Y1,A X:(R0)+,X0 Y:(R4)+,Y0 ;A=αx(n)
MAC X0,Y0,A X:(R0),X1 Y:(R4)+,Y0 ;A=A+γw(n-1)
MACR X1,Y0,A X0,X:(R0)- Y:(R4)+,Y0 ;A=A-βw(n-2)
MAC X0,Y0,A A,X:(R0) Y:(R4)+,Y0 ;A=1/2w(n)+µ/2w(n-1)
MACR X1,Y0,A A,X0 Y:(R4)+,Y0 ;A=A+σ/2w(n-2). X0=2A
;(assumes scaling mode
;is set).X0 is Output.
3-10 MOTOROLA
3.13 Implementation on the
DSP56001
Figure 3-27 shows the DSP56001 code and data
structures for implementation of the single-sec-
tion canonic-form network. Note that the modifier
register M4 is set equal to 4 to allow circular op-
eration for addressing coefficient data. M0 is set
to FFFF to turn off circular addressing for w(n-1)
and w(n-2). ■
3-11 MOTOROLA
3-12 MOTOROLA
SECTION 4
Single-Section
Transpose Form
A third realization of IIR filters is the transpose form
“The modifier (direct form l) shown in Figure 4-1. This network imple-
register M4 is mentation can be derived directly from the direct-form
initially set to a difference equation (see Figure 4-1) or by taking the
value of 4 so that transpose of the canonic network (see References 10
a circular buffer and 11). The transpose realization is characterized by
can be three accumulator operations. One reason for the pop-
conveniently ularity of this realization is that, like the canonic
used to address realization, it only requires two memory locations;
the coefficient however, unlike the canonic realization, it is much less
data.” prone to overflow at internal nodes. The disadvantage
is that this realization requires more instructions to im-
plement.
MOTOROLA 4-1
expression for the maximum gain at the internal
nodes can be derived by calculating the maxima of
the gain functions. For the bandpass and bandstop
networks, the maximum of Gu(θ) and Gv(θ) is gm =
β + 1/2. Since, β < 1/2, then gm < 1 so that no over-
flow occurs at these nodes in the bandpass or
bandstop case.
Figure 4-4 contains example plots of Gu(θ) and Gv(θ)
for the second-order transpose-form lowpass filter
with various values of cutoff frequency, θc, and
damping factor, d. In most cases, Gu(θ) and Gv(θ)
never exceed the maximum value of G(θ), so that, if
the total gain does not exceed unity, the internal
nodes will not exceed unity (i.e., no overflow).
4-2 MOTOROLA
Network Diagram ασ −β
Σ
(Left Shift) 2
u(n)
z-1
αµ γ
x(n) Σ y(n)
(Left Shift) 2
v(n)
-1
z
α (Left Shift)
Σ 2
= 2 { αx ( n ) + αµx ( n – 1 ) + γy ( n – 1 ) + [ ασx ( n – 2 ) – βy ( n – 2 ) ] }
1
= 2 αx ( n ) + [ αµx ( n – 1 ) + γy ( n – 1 ) + -2 u ( n – 2 ) ]
1
= 2 αx ( n ) + -2- v ( n – 1 )
MOTOROLA 4-3
GAIN AT INTERNAL NODE, u(n)
Transfer function of u(n) is U(z) = 2 [ ασX ( z ) – βY ( z ) ]
= Hu ( z ) X ( z )
where H u ( z ) = 2 [ ασ – βH ( z ) ]
–1
ασ ( 1/2 – γ z + βz –2 ) – αβ ( 1 + µz –1 + σ z –2 )
= 2 -------------------------------------------------------------------------------------------------------
–1 –2
1/2 – γ z + βz
–1
2α ( A – Bz )
= 2 --------------------------------------
–1 –2
1/2 – γ z + βz
where Hu(z) is the transfer function from input node, x(n), to internal mode, u(n), and
A=σ/2-β and B = σγ + µβ.
Gain of u(n) is Gu ( θ ) = Hu ( z )
jθ
z=e
2 2
2α A + B – 2AB cos θ
= -----------------------------------------------------------------------------------------------------------
2 2 2
( 1/2 – β ) sin 2 θ + ( 1/2 + β ) ( cos θ – cos θ 0 )
BANDPASS EXAMPLE
Bandpass Coefficients are σ = –1 µ = 0 α = ( 1/2 – β ) /2
so that A = – ( 1/2 + β )
B = –γ
= – ( 1/2 + β ) cos θ 0
2
( 1/2 – β ) ( 1/2 + β ) sin 2 θ + ( cos θ – cos θ 0 )
and Gu ( θ ) = -----------------------------------------------------------------------------------------------------------
-
2 2 2
( 1/2 – β ) sin 2 θ + ( 1/2 + β ) ( cos θ – cos θ 0 )
Peak Gain is gm = Gu ( θm )
d
which is found by evaluating ----- G u ( θ ) θ = θ = 0
dθ m
Figure 4-2 Gain Evaluation at First Internal Node, u(n), of Transpose Network
4-4 MOTOROLA
GAIN AT INTERNAL NODE, v(n)
Transfer function of v(n) is V(z) = [ Y ( z ) – 2αX ( z ) ] /z –1
= Hv ( z ) X ( z )
1 H ( z ) – 2α
Hv ( z ) =
–1
where Y(z)= 2[ - V(z)z + αX ( z ) ] ----------------------
2 –1
z
–1 –2 –1 –2
α [ ( 1 + µ z + σz ) – 2 ( 1/2 + γ z + βz ) ]
and = -------------------------------------------------------------------------------------------------------
–1 –1 –2
z ( 1/2 – γ z + βz )
–1
2α ( C + Az )
= --------------------------------------
–1 –2
1/2 – γ z + βz
where Hv(z) is the transfer function from input node, x(n), to internal mode, v(n), and
A=σ/2-b and C = µ/2 + g.
Gain of v(n) is Gv ( θ ) = Hv ( z )
jθ
z=e
2 2
2α A + C + 2AC cos θ
= -----------------------------------------------------------------------------------------------------------
2 2 2
( 1/2 – β ) sin 2 θ + ( 1/2 + β ) ( cos θ – cos θ 0 )
BANDPASS EXAMPLE
Bandpass Coefficients are σ = –1 µ = 0 α = ( 1/2 – β ) /2
so that A = – ( 1/2 + β )
C = γ
= ( 1/2 + β ) cos θ 0
2
( 1/2 – β ) ( 1/2 + β ) sin 2 θ + ( cos θ – cos θ 0 )
and Gv ( θ ) = -----------------------------------------------------------------------------------------------------------
2 2 2
( 1/2 – β ) sin 2 θ + ( 1/2 + β ) ( cos θ – cos θ 0 )
Peak Gain is gm = Gv ( θm )
d
which is found by evaluating ----- G v ( θ ) θ = θ = 0
dθ m
Figure 4-3 Gain Evaluation at Second Internal Node, v(n), of Transpose Network
MOTOROLA 4-5
1.2
1.0
G
0.8
0.6
Gain
0.4
Gv
0.2
Gu
0.0
-0.2
0 50 100 150 200 250 300 350 400 450 500
Frequency
0.5
0.4
0.3
0.2 Gu
0.1
2.5
2.0
1.5
G
Gain
1.0 Gv
0.5 Gu
0.0
4-6 MOTOROLA
Difference Equation
1
y ( n ) = 2 αx ( n ) + --- v ( n – 1 )
2
1
v ( n ) = 2 αµx ( n ) + γy ( n ) + --- u ( n – 1 )
2
u ( n ) = 2 { ασx ( n ) – βy ( n – 1 ) }
Data Structures
X:(R0) Y:(R4)
v(n-1) αµ
γ
ασ
X:(R1)
u(n-1) –β
α
DSP56001 Code
;Y1=x(n) (Input)
;Y0=α . A=v(n-1)/2
MACR Y0,Y1,A X:(R1),B Y:(R4)+,Y0 ;A=A+αx(n)
ASR B A,X0 ;y(n)=X0=2A (scale mode on)
MAC Y0,Y1,B Y:(R4)+,Y0 ;B=u(n-1)/2+αµx(n)
MACR X0,Y0,B Y:(R4)+,Y0 ;B=B+γy(n)
MPY Y0,Y1,B B,X:(R0) Y:(R4)+,Y0 ;y(n)=2B. B=ασx(n)
MACR X0,Y0,B X:(R0),A ;B=B- βy(n)
ASR A B,X:(R1) Y:(R4)+,Y0 ;A=v(n)/2. u(n)=2B
;Y0=α. y(n)=X0 (output)
MOTOROLA 4-7
4-8 MOTOROLA
SECTION 5
MOTOROLA 5-1
damping factors, dk, of each individual kth section.
The damping coefficients, dk, are calculated from a
simple formula for any order N of response.
H ( s ) = --------------------------------------------------------------- ---------------------------------------------------------------------- …
1 1
2 2
( s/Ω c ) + d 1 ( s/Ω c ) + 1 ( s/Ω c ) + d 2 ( 1 ) ( s/Ω c ) + 1
N/2
∏
1
= -------------------------------------------------------------- Eqn. 5-7
2
k = 1 ( s/Ω c ) + d k ( s/Ω c ) + 1
5-2 MOTOROLA
sections. The second-order section of a Butterworth
filter can be derived from the simple RCL network of
Figure 1-1. However, the Butterworth damping factors
are predetermined values, which can be shown to
yield a maximally flat passband response (see Refer-
ence 14). The Butterworth damping coefficients are
given by the following equation:
( 2k – 1 )π
d k = 2 sin ------------------------ Eqn. 5-8
2N
2 1/2
p k1 = – d k /2 – j 1 – d k /4 (a)
and
2 1/2
p k 2 = d k /2 + j 1 – d k /4 (b)
Eqn. 5-9
MOTOROLA 5-3
Using , Eqn. 5-7 becomes:
N/2
∏ [--------------------------------------------------------------------
1
H(s) = - Eqn. 5-10
( s/Ω ) – p ] [ ( s/Ω ) – p ∗ ]
c k c k
k=1
G(Ω) = H ( s )H∗ ( s )
s = jΩ
N/2
∏
1 Eqn. 5-11
= ---------------------------------------------------------------------------------
2
k = 1 ( Ω/Ω ) 2 – 1 + ( d Ω/Ω ) 2
c k c
5-4 MOTOROLA
N/2 d k Ω/Ω c
–1
φ(Ω) = ∑ tan --------------------------------
2
Eqn. 5-12
k=1 ( Ω/Ω c ) – 1
–1 –2
α k ( 1 + 2z + z )
H k ( z ) = -------------------------------------------------- Eqn. 5-13
1 –1 –2
--- – γ z + β z
2 k k
MOTOROLA 5-5
2
α k = tan ( θ c /2 ) /A k ( c ) (a)
2
β k = 1 – d k tan ( θ c /2 ) + tan ( θ c /2 ) /A k ( c ) (b)
2
γ k = 2 1 – tan ( θ c /2 ) /A k ( θc ) (c)
2
A k ( θ c ) = 2 1 + d k tan ( θ c /2 ) + tan ( θ c /2 ) (d)
Eqn. 5-14
1 – ( d k /2 ) sin ( θ c )
β k = ------------------------------------------------------ (a)
2 [ 1 + ( d k /2 ) sin ( θ c ) ]
5-6 MOTOROLA
20
15
10
k=1
20log(G) (db)
0
k=2
-5
k=3
Composite
-10
Response
-15
-20
0 100 200 300 400 500 600 700
Frequency (Hz)
20
15
10
20log(G) (db)
0 k=1
k=2
-5 k=3
-10
Composite
-15 Response
-20
0 100 200 300 400 500 600 700
Frequency (Hz)
MOTOROLA 5-7
pass Butterworth filter (three second-order sections)
in both the analog domain and digital domain. Note
that the gain of the first section (k = 1) is greater than
unity near the cutoff frequency but that the overall
composite response never exceeds unity. This fact
allows for easy implementation of the Butterworth fil-
ter in cascaded direct form (i.e., scaling of sections
is not needed as long as the sections are imple-
mented in the order of decreasing k). Overflow at the
output of any section is then guaranteed not to occur
(the gain of the filter never exceeds unity). Note that
the digital response (see Figure 5-28) is identical to
the analog response but warped from the right along
the frequency axis. Imagine the zero at plus infinity
in the analog response mapping into the zero at fs/2
in the digital case. Also note that, because of this
mapping, the digital response falls off faster than the
-12 dB/octave of the analog filter when the cutoff is
near fs/2.
5-8 MOTOROLA
set of the center of each section reduces the final
center response, which must be compensated at
some point in the filter network. For cases such as
higher order Butterworth bandpass filter designs,
commercially available filter design packages such
as FDAS are useful. The use of FDAS is discussed
in SECTION 6 Filter Design And Analysis Sys-
tem (FDAS) and SECTION 7 Fir Filters.
MOTOROLA 5-9
Network Diagram
x(n) α1 α2 α3 y(n)
2 2 2
z-1 z -1
z-1 z-1
α1σ1 −β1 α2σ2 −β2 α3σ3 −β3
Difference Equations
y1 ( n ) = 2 { αi [ xi ( n ) + µi xi ( n + 1 ) + σi xi ( n – 2 ) ] + γ i xi ( n – 1 ) – βi yi ( n – 2 ) }
xi + 1 ( n – k ) = yi ( n – k )
Figure 5-29 Network Diagram for Cascaded Direct-Form Filter and Data
Structures Used in Code Implementation (Three-Section Example)
5-10 MOTOROLA
DSP56001 CODE
;Output:y(n)=Y1
MOVE X:Buflen, M4 ;Filter Order +1
NOP
MOVE Y1,Y:(R4)+N4 ;Save y(n)
MOTOROLA 5-11
5-12 MOTOROLA
SECTION 6
MOTOROLA 6-1
can be assembled by the DSP56001 assembler or
linker software. Examples of these files are shown
in Figure 6-10 to Figure 6-10.
6-2 MOTOROLA
0
-20
Log Magnitude (dB)
-40
-60
-80
-100
0.000 1.000 2.000 3.000 4.000 5.000
E+00 E+02 E+02 E+02 E+02 E+02
Frequency (Hz)
MOTOROLA 6-3
π
π/2
Phase (Radians)
-π/2
-π
0.000 1.000 2.000 3.000 4.000 5.000
E+00 E+02 E+02 E+02 E+02 E+02
Frequency (Hz)
6-4 MOTOROLA
1.00
0
MOTOROLA 6-5
6.3
E-03
4.7
E-03
Seconds
3.1
E-03
1.5
E-03
0.0
0.000 1.000 2.000 3.000 4.000 5.000
E+00 E+02 E+02 E+02 E+02 E+02
Frequency (Hz)
Figure 6-9 Group Delay Versus Frequency for FDAS IIR Example
6-6 MOTOROLA
Filter Type Low Pass
Analog Filter Type Butterworth
Passband Ripple In -dB -.5000
Stopband Ripple In -dB -20.0000
Passband Cutoff Frequency 200.000 Hertz
Stopband Cutoff Frequency 300.000 Hertz
Sampling Frequency 1000.00 Hertz
Filter Order: 6
Filter Design Method: Bilinear Transformation
MOTOROLA 6-7
ZEROES OF TRANSFER FUNCTION Hd(z)
Real Part Imaginary Part Real Part Imaginary Part Radius
-.100000000E+01 .00000000E+00 -.100000000E+01 .00000000E+00 .100000000E+01
-.999290168E+00 .00000000E+00 -.100071034E+01 .00000000E+00 .999290168E+00
-.100000000E+01 .00000000E+00 -.100000000E+01 .00000000E+00 .100000000E+01
6-8 MOTOROLA
FILTER COEFFICIENT FILE
IIR DESIGN
FILTER TYPE LOW PASS
ANALOG FILTER TYPE BUTTERWORTH
PASSBAND RIPPLE IN -dB -.5000
STOPBAND RIPPLE IN -dB -20.0000
PASSBAND CUTOFF FREQUENCY .200000E+03 HERTZ
STOPAND CUTOFF FREOUENCY .300000E+03 HERTZ
SAMPLING FREQUENCY .100000E+04 HERTZ
FILTER DESIGN METHOD: BILINEAR TRANSFORMATION
FILTER ORDER 6 0006h
NUMBER OF SECTIONS 3 0003h
NO. OF QUANTIZED BITS 24 0018h
QUANTIZATION TYPE - FRACTIONAL FIXED POINT
COEFFICIENTS SCALED FOR CASCADE FORM 11
0 00000000 /* shift count for overall gain */
7349395 00702493 /* overall gain */
0 00000000 /* shift count for section 1 value */
2114226 002042B2 /* section1 coefficient B0 */
4228452 00408564 /* section1 coefficient B1 */
2114226 002042B2 /* section1 coefficient B2 */
1228022 0012BCF6 /* section1 coefficient A1 */
-188810 FFFD1E76 /* section1 coefficient A2 */
0 00000000 /* shift count for section 2 values */
1983261 001E431D /* section2 coefficient B0 */
3966523 003C863B /* section2 coefficient B1 */
1983261 001E431D /* section2 coefficient B2 */
1413078 00158FD6 /* section2 coefficient A1 */
-1481374 FFE96562 /* section2 coefficient A2 */
0 00000000 /* shift count for section 3 values */
3025257 002E2969 /* section3 coefficient B0 */
6050514 005C52D2 /* section3 coefficient B1 */
3025257 002E2969 /* section3 coefficient B2 */
1912173 001D2D6D /* section3 coefficient A1 */
-4967423 FFB43401 /* section3 coefficient A2 */
.2520353794097900D+00 3FD0215900000000 .25203538E+00 /* section 1 B0 */
.504D707588195801D+00 3FE0215900000000 .50407076E+00 /* section 1 B1 */
.2520353794097900D+00 3FDD215900000000 .25203538E+00 /* section 1 B2 */
.1463916301727295D+00 3FC2BCF600000000 .14639171E+00 /* section 1 A1 */
-.2250790596008301D-01 BF970C5000000000 -.22507921E-01 /* section 1 A2 */
.236423134803772OD+00 3FCE431D00000000 .23642325E+00 /* section 2 B0 */
.4728463888168335D+00 3FDE431D80000000 .47284651E+00 /* section 2 B1 */
.2364231348037720D+00 3FCE431D00000000 .23642325E+00 /* section 2 B2 */
.1684520244598389D+00 03FC58FD60000000 .168452D4E+D0 /* section 2 A1 */
.17659354Z0989990D+00 BFC69A9E000000D0 -.17659356E+00 /* section 2 A2 */
.3606387376785278D+00 3FD714B480000000 .36063876E+00 /* section 3 B0 */
.7212774753570557D+00 3FE714B480000000 .72127753E+00 /* section 3 Bl */
.3606387376785278D+00 3FD714B480000000 .36063876E+00 /* section 3 B2 */
.2279487848281860D+00 3FCD2D6DD0000000 .22794882E*00 /* section 3 A1 */
-.5921629667282104D+00 BFE2F2FFC0000000 -.59216306E+00 /* section 3 A2 */
MOTOROLA 6-9
1 COEFF ident 1,0
6-10
2 include 'head2.asm'
3
4 page 132, 66, 0,10
5 pt cex, mex
6
7 ; This program implements an IIR filter in cascaded canonic sections
8 ; The coefficients of each section are scaled for cascaded canonic sections
9
10
11 00FFFF datin equ $ffff ;location in Y memory of input file
12 00FFFF datout equ $ffff ;location in Y memory of output file
13 00FFF0 m_scr equ $fff0 ;sci control register
14 00FFF1 m_ssr equ $fff1 ;sci status register
15 00FFF2 m_sccr equ $fff2 ;sci clock control register
16 00FFE1 m_pcc equ $ffe1 ;port c control register
17 00FFFF m_ipr equ $ffff ;interrupt priority register
18 000140 xx equ @cvi(20480/64*1.000)) ;timer interrupt value
19 FFD8F1 m_tim equ -9999 ;board timer interrupt value
20 000003 nsec equ 3 ;number of second order sectiona
21 include 'cascade2.asm'
22 ;
23 ; This code segment implements cascaded biquad sections in canonic form
24 ;
25
26 cascade2 macro nsec
27 m ;
28 m ;assumes each section's coefficients are divided by 2
29 m
30 m mpy y0,y1,a x:(r0)+,y0 y:(r4)+,y0 ;x0=1st section w(n-2),y0=a12/2
31 m do #nsec,_ends ;do each section
32 m mac x0,y0,a x:(r0)-,x1 y:(r4)+,y0 ;x1=w(n-1) ,y0=ai1/2
33 m macr x1,y0,a x1,x:(r0)+ y:(r4)+,y0 ;push w(n-1) to w(n-2),y0=bi2/2
34 m mac x0,y0,a a,x:(r0) y:(r4)+,y0 ;push w(n) to w(n-1),y0=bi1/2
35 m mac x1,y0,a x:(r0)+,x0 y:(r4)+,y0 ;get this iter w(n),y0=bi0/2
36 m mac x0,y0,a x:(r0)+,x0 y:(r4)+,y0 ;next iter:x0=w(n-2),y0=ai2/2
37 m _ends
38 m endm
Figure 6-7 COEFF.ASM File Generated by MGEN for Example Design andCascaded Canonic
Implementation (Sheet 1 of 4)
MOTOROLA
39
40
41 ;
42 ;multiple shift left macro
43
44 mshl macro scount
MOTOROLA
45 m if scount
46 m rep #scount
47 m asl a
48 m endif
49 m endm
50 X:0000 org x:0
51 X:0000 states ds 2*nsec
52 Y:0000 org y:0
53 coef
54 d Y:0000 FE8F38 dc $FE8F3B ;a(*,2)/2 =-.01125395 section number 1
55 d Y:0001 095E7B dc $095E7B ;a(*,1)/2 = .07319582 section nunber 1
56 d Y:0002 102159 dc $102159 ;b(*,2)/2 = .12601769 section number 1
57 d Y:0003 2042B2 dc $2042B2 ;b(*,1)/2 = .25203538 section number 1
58 d Y:0004 D02159 dc $D02159 ;b(*,0)/2-0.5 =-.37398231 section number 1
59 d Y:0005 F4B2B1 dc $F4B2Bl ;a(*,2)/2 =-.08829677 section number 2
60 d Y:0006 0AC7EB dc $OAC7EB ;a(*,1)/2 = .08422601 section number 2
61 d Y:0007 0F218E dc $OF218E ;b(*,2)/2 = .11821157 section number 2
62 d Y:0008 1E4313 dc $1E431D ;b(*,1)/2 = .23642319 section number 2
63 d Y:0009 CF218E dc $CF218E ;b(*,0)/2-0.5 =-.38178843 section number 2
64 d Y:000A DAlA01 dc $DA1A01 ;a(*,2)/2 =-.29608148 section number 3
65 d Y:000B 0E96B6 dc $OE96B6 ;a(*,1)/2 = .11397439 section number 3
66 d Y:000c 1714B4 dc $1714B4 ;b(*,2)/2 = .18031937 section number 3
67 d Y:000D 2E2969 dc $2EZ969 ;b(*,1)/2 = .36063874 section number 3
68 d Y:000E D714B4 dc $0714B4 ;b(*,0)/2-0.5 =-.31968063 section number 3
69 Y:00c8 org y:200
70 d Y:00C8 381249 igain dc 3674697
71 000000 scount equ 0 ;final shift count
72 include 'bodyZ.asm'
73
74 000040 start equ $40 ;origin for user program
75
76 P:0000 org p:$0 ;origin for reset vector
Figure 6-7 COEFF.ASM File Generated by MGEN for Example Design and Cascaded Canonic
Implementation (Sheet 2 of 4)
6-11
77 P:0000 0C0040 jmp start ;jump to 'start' on system reset
6-12
78
79 P:00lc org p:$lc ;origin for timer interrupt vector
80 P:00lc 0BF080 jsr filter ;jump to 'filter' on timer interrupt
000051
81
82 P:0040 org p:start ;origin for user program
83
84 P:0040 0003F8 ori #3,mr ;disable all interrupts
85 P:0041 08F4B2 movep #(xx-1),x:m_sccr ;cd=xx-1 for divide by xx
00013F
86 P:0043 08F4A1 movep #$7,x:m_pcc ;set cc(2;0) to turn on timer
000007
87 P:0045 08F4B0 movep #$2000,x:m_scr ;enable timer interrupts
002000
88 P:0047 08F4BF movep #$c000,x:m_ipr ;set interrupt priority for sci
00C000
89
90 P:0049 300000 move #states,r0 ;initialize internal state storage
91 P:004A 200013 clr a ;* set memory to zero
92 P:004B 0606A0 rep #nsec*2 ;*
93 P:004C 565800 move a,x:(rO)+ ;*
94
95 P:004D 4FF000 move y:igain,yl ;y1=initial gain/2
0000C8
96 P:004F 00FCB8 andi #$fc,mr ;allow interrupts
97 P:0050 0C0050 jmp * ;wait for interrupt
98
99 filter
100 P:0051 0008F8 ori #$08,mr ;set scaling node
101 P:0052 300000 move #states,r0 ;point to filter states
102 P:0053 340000 move #coef,r4 ;point to filter coefficients
103 P:0054 09463F movep y:datin,y0 ;get sample
104
105 cascade2 nsec ;do cascaded biquads
106 + ;
107 + ;assumes each section's coefficients are divided by 2
108 + ;
Figure 6-7 COEFF.ASM File Generated by MGEN for Example Design and Cascaded Canonic
Implementation (Sheet 3 of 4)
MOTOROLA
109 + P:0055 F098B0 mpy y0,yl,a x:(r0)+ x0 y:(r4)+,y0 ;x0=1stsection w(n-2),y0=ai2/2
110 + P:0056 060380 do #nsec,_ends ;do each section
00005C
111 + P:0058 F490D2 mac x0,y0,a x:(r0)- ,xl y:(r4)+,y0 ;x1=w(n-1)y0=ai1/2
112 + P:0059 F418E3 macr xl,y0,a x1,x:(r0)+ y:(r4)+,y0 ;push w(n-1) to w(n 2),y0=bi2/2
MOTOROLA
113 + P:005A F800D2 mac x0,y0,a a,x:(r0) y:(r4)+,y0 ;push w(n) to w(n-1),y0=bi1/2
114 + P:005B F098E2 mac x1,y0,a x:(r0)+,x0 y:(r4)+,y0 :get this iter w(n),y0=bi0/2
115 + P:005C F098D2 mac x0,y0,a x:(r0)+,x0 y:(r4)+,y0 ;next iter:x0=w(n-2),yo=ai2/2
116 _ends
117 mshl scount
118 + if scount
121 + endif
122 P:005D 200011 rnd a ;round result
123 P:005E 09CE3F movep a,y:datout ;output sample
124 P:005F 000004 rti
125
126 end
0 Errors
0 Warnings
Figure 6-7 COEFF.ASM File Generated by MGEN for Example Design and Cascaded Canonic
Implementation (Sheet 4 of 4)
6-13
6.2 Transpose
Implementation
(Direct Form I)
Figure 6-8 is the output file from FDAS for a trans-
pose-form implementation. As before, it contains
information on the analog s-domain equivalent filter
as well as the final digital coefficients (listed again
in Figure 6-9), which have been properly scaled to
prevent overflow at the internal nodes and outputs
of each cascaded section. Because of the stability
of the internal node gain of the transpose form and
because of the response of each second-order But-
terworth section, scaling was not done by the
program because it was not needed. Executable
code shown in Figure 6-10 is again generated by
MGEN. The code internal to each cascaded section
is seven instructions long; thus, 700 ns (assuming a
DSP56001 clock of 20 MHz) is added to the execu-
tion time for each additional second-order section.
6-14 MOTOROLA
FILTER TYPE LOW PASS
ANALOG FILTER TYPE BUTTERWORTH
PASSBAND RIPPLE IN -dB -.5000
STOPBAND RlPPLE lN -dB -20.0000
PASSBAND CUTOFF FREQUENCY 200.000 HERTZ
STOPBAUD CUTOFF FREQUENCY 300.000 HERTZ
SAMPLING FREQUENCY 1000.00 HERTZ
FILTER ORDER: 6
FILTER DESIGN METHOD: BILINEAR TRANSFORMATION
COEFFICIENTS OF Hd(Z) ARE QUANTIZED TO 24 BITS
QUANTIZATION TYPE: FIXED POINT FRACTIONAL
COEFFICIENTS SCALED FOR CASCADE FORM I (TRANSPOSE FORM)
MOTOROLA 6-15
POLES OF TRANSFER FUNCTION Hd(z)
Real Part Imaginary Part Real Part Imaginary Part Radius
-.731958151E-01 -.130959072E+00 -.731958151E-01 -.130959072E+00 -.150026351E+00
-.842260122E-01 -.411703195E+00 -.842260122E-01 -.411703195E+00 -.420230344E+00
-.113974392E+00 -.761034036E+00 -.113974392E-00 -.761034036E+00 -.769521258E+00
6-16 MOTOROLA
FILTER COEFFICIENT FILE
IIR DESIGN
FILTER TYPE LOW PASS
ANALOG FILTER TYPE BUTTERWORTH
PASSBAND RIPPLE IN -dB -.5000
STOPBAND RIPPLE IN -dB -20.0000
PASSBAND CUTOFF FREQUENCY .200000E+03 HERTZ
STOPBAND CUTOFF FREQUENCY .300000E+03 HERTZ
SAMPLING FREQUENCY .100000E+04 HERTZ
FILTER DESIGN METHOD: BILINEAR TRANSFORMATION
FILTER ORDER 6 0006h
NUMBER OF SECTIONS 3 0003h
NO. OF QUANTIZED BITS 24 0018h
QUANTIZATION TYPE - FRACTIONAL FIXED POINT
COEFFICIENTS SCALED FOR CASCADE FORM I
1 00000001 /* shift count for overall gain */
4194304 00400000 /* overall gain */
0 00000000 /* shift count for section 1 values */
1837348 001C0924 /* section 1 coefficient B0 */
3674697 00381249 /* section 1 coefficient B1 */
1837348 001C0924 /* section 1 coefficient B2 */
1228022 00128CF6 /* section 1 coefficient A1 */
-188810 FFFDlE76 /* section 1 coefficient A2 */
0 00000000 /* shift count for section 2 values */
2114226 00204292 /* section 2 coefficient B0 */
4228452 00408564 /* section 2 coefficient B1 */
2114226 00204282 /* section 2 coefficient B2 */
1413078 00158FD6 /* section 2 coefficient A1 */
-1481374 FFE96562 /* section 2 coefficient A2 */
0 00000000 /* shift count for section 3 values */
2860964 002BA7A4 /* section 3 coefficient B0 */
5721929 00574F49 /* section 3 coefficient B1 */
2860964 002BA7A4 /* section 3 coefficient B2 */
1912173 001D2D6D /* section 3 coefficient Al */
-4967423 FFB43401 /* section 3 coefficient A2 */
.2190289497375488D+00 3FCC092400000000 .21902905E+00 /* section 1 B0 */
.4380580186843872D+00 3FDC092480000000 .43805810E+00 /* section 1 B1 */
.2190289497375488D+00 3FCC092400000000 .21902905E+00 /* section 1 B2 */
.146391630172 n95D+00 3FC2BCF600000000 .14639171E+00 /* section 1 A1 */
-.2250790596008301D-01 BF970C5000000000 -.22507921E-01 /* section 1 A2 */
.2520353794097900D+00 3FD0215900000000 .25203538E+00 /* section 2 B0 */
.5040707588195801D+00 3FE0215900000000 .50407076E+00 /* section 2 Bl */
.2520353794097900D+00 3FD0215900000000 .25ZD3538E+00 /* section 2 B2 */
.1684520244598389D+00 3FC58FD600000000 .16845204E+00 /* section 2 Al */
-.1765935420989990D+00 BFC69A9E00000000 -.17659356E+00 /* section 2 A2 */
.34105348587036130+00 3FDSD3D200000000 .34105356E+00 /* section 3 B0 */
.6821070909500122D+00 3FESD3DZ40000000 .68210712E+00 /* section 3 Bl */
.3410534858703613D+00 3FDSD3D200000000 .34105356E+00 /* section 3 B2 */
.2279487848281860D+00 3FCD2D6D00000000 .22794882E+00 /* section 3 Al */
-.5921629667282104D+00 BFE2F2FFC0000000 -.59216306E+00 /* section 3 A2 */
Figure 6-9 COEFF.FLT File for Example Filer Design–Scaled for Cascaded
Transpose Form
MOTOROLA 6-17
6-18
1 C0EFF ident 1,0
2 include 'head1.asm'
3
4 page132,66,0,10
5 optcex, mex
6 ;
7 ; This program implements an IIR filter in cascaded transpose sections
8 ; The coefficients of each section are scaled for cascaded transpose sections
9
10
11 00FFFF datin equ $ffff ;location in Y memory of input file
12 00FFFF datout equ $ffff ;location in Y memory of output file
13 00FFF0 m_scr equ $fff0 ;sci control register
14 00FFF1 m_ssr equ $fff1 ;sci status register
15 00FFF2 m_sccr equ $fff2 ;sci clock control register
16 00FFE1 m_pcc equ $ffe1 ;port c control register
17 00FFFF m_ipr equ $ffff ;interrupt priority register
18 000140 xx equ @cvi(20480/(64*1.000)) ;timer interrupt value
19 FFD8F1 m_tim equ -9999 ;board timer interrupt value
20 000003 nsec equ 3 ;number of second order sections
21 include 'cascade1.asm'
22 ;
23 ;This code segment implements cascaded biquad sections in transpose form
24 ;
25
26 cascade1 macro nsec
27 m
28 m ;assumes each section's coefficients are divided by 2
29 m
30 m do #nsec,_ends ;do each section
31 m macr y0,yl,a x:(r1),b y:(r4)+,y0 ;a=x(n)*bi0/2+wi1/2,b=wi2,y0=bi1/2
32 m asr b a,x0 ;b=wi2/2,x0=y(n)
33 m mac y0,yl,b y:(r4)+,y0 ;b=x(n)*bi1/2+wi2/2,y0=ai1/2
34 m macr x0,y0,b y:(r4)+,y0 ;b=b+y(n)*ai1/2,y0=bi2/2
35 m mpy y0,y1,b b,x:(r0)+ y:(r4)+,y0 ;b=x(n)*bi2/2,save wi1,y0=ai2
36 m macr x0,y0,b x:(r0),a a,y1 ;b=b+y(n)*ai2/2,a=next iter wi1,
37 m ;yl=output of section i
Figure 6-10 COEFF.ASM File Generated by MGEN for Example Design and Cascaded Transpose–Form
Implementation (sheet 1 of 4)
MOTOROLA
38 m asr a b,x:(r1)+ y:(r4)+,y0 ;a=next iter wi1/2,save wi2,
39 m ;y0=next iter bi0
40 m _ends
41 m endm
42
43
MOTOROLA
44 X:0000 org x:0
45 X:0000 statel dsm nsec
46 X:0004 state2 dsm nsec
47 Y:0000 org y:0
48 coef
49 d Y:0000 0E0492 dc $0E0492 ;b(*,0)/2 = .10951447section number 1
50 d Y:0001 lC0924 dc $1C0924 ;b(*,1)/2 = .21902901 section number 1
51 d Y:0002 095E7B dc $095E7B ;a(*,1)/2 = .07319582 section number 1
52 d Y:0003 0E0492 dc $0E0492 ;b(*,2)/2 = .10951447 section number 1
53 d Y:0004 FE8F3B dc $FE8F3B ;a(*,2)/2 =-.01125395 section number 1
54 d Y:0005 102159 dc $102159 ;b(*,0)/2 = .12601769 section number 2
55 d Y:0006 2042B2 dc $2042B2 ;b(*,1)/2 = .25203538 section number 2
56 d Y:0007 OAC7EB dc $0AC7EB ;a(*,1)/2 = .08422601 section number 2
57 d Y:0008 102159 dc $102159 ;b(*,2)/2 = .12601769 section number 2
58 d Y:0009 F4B2B1 dc $F4B2B1 ;a(*,2)/2 =-.08829677 section number 2
59 d Y:000A lSD3D2 dc $l5D3D2 ;b(*,0)/2 = .17052674 section number 3
60 d Y:000B 2BA7A4 dc $2BA7A4 ;b(*,1)/2 = .34105355 section number 3
61 d Y:000c 0E96B6 dc $0E9686 ;a(*,1)/2 = .11397439 section number 3
62 d Y:0000 lSD3D2 dc $l5D3D2 ;b(*,2)/2 = .17052674 section number 3
63 d Y:000E DAlA01 dc $DAlA01 ;a(*,2)/2 =-.29608148 section number 3
64 include 'bodyl.asm'
65
66 000040 start equ $40 ;origin for user program
67
68 P:0000 org p:$0 ;origin for reset vector
69 P:0000 0C0040 jmp start ;jump to 'start' on system reset
70
71 P:001C org p:$lc ;origin for timer interrupt vector
72 P:00lC 0BF080 jsr filter ;jump to 'filter' on timer interrupt
000057
73
74 P:0040 org p:start ;origin for user program
Figure 6-10 COEFF.ASM File Generated by MGEN for Example Design and Cascaded Transpose–Form
Implementation (sheet 2 of 4)
6-19
6-20
75
76 P:0040 0003F8 ori #3,mr ;disable all interrupts
77 P:0041 08F4B2 movep #(xx-1),x:m_sccr ;cd=xx 1 for divide by xx
00013F
78 P:0043 08F4A1 movep #$7,x:m_pcc ;set cc(2;0) to turn on timer
000007
79 P:0045 08F4B0 movep #$2000,x:m_scr ;enable timer interrupts
002000
80 P:0047 08F4BF movep #$c000,x:m_ipr ;set interrupt priority for sci
00C000
81
82
83 P:0049 300000 move #state1,r0 ;point to filter state1
84 P:004A 310400 move #state2,rl ;point to filter state2
85 P:004B 340000 move #coef,r4 ;point to filter coefficients
86 P:004C 0502A0 move #nsec l,m0 ;addressing modulo nsec
87 P:004D 050EA4 move #5*nsec-l,m4 ;addressing modulo 5*nsec
88 P:004E 0502Al move #nsec-1,m1 ;addressing modulo nsec
89 P:004F 200013 clr a ;initialize internal state storage
90 P:0050 0603A0 rep #nsec ;* zero statel
91 P:0051 565800 move a,x:(r0)+ ;*
92 P:0052 0603A0 rep #nsec ;* zero state2
93 P:0053 565900 move a,x:(r1)+ ;*
94
95 P:0054 F88000 move x:(r0),a y:(r4)+,y0 ;a=wl (initially zero) ,y0=bl0/2
96
97 P:0055 00FCB8 andi #$fc,mr ;allow interrupts
98 P:0056 0C0056 jmp * ;wait for interrupt
99
100 filter
101 P:0057 0008F8 ori #$08,mr ;set scaling mode
102 P:0058 09473F movep y:datin,yl ;get sample
103
104 cascade1 nsec ;do cascaded biquads
105 + ;
106 + ; assumes each section's coefficients are divided by 2
107 + ;
Figure 6-10 COEFF.ASM File Generated by MGEN for Example Design and Cascaded Transpose–Form
Implementation (sheet 3 of 4)
MOTOROLA
108 + P:0059 060380 do #nsec,_ends ;do each section
000061
109 + P:00SB FC81B3 macr y0,y1,a x:(r1),b y:(r4)+,y0 ;a=x(n)*bi0/2+wi1/2,b=wi2,y0=bi1/2
110 + P:OOSC 21C42A asr b a,x0 ;b=wi2/2,x0=y(n)
111 + P:005D 4EDCBA mac y0,yl,b y:(r4)+,y0 ;b=x(n)*bi1/2+wi2/2,y0=ail/2
MOTOROLA
112 + P:00SE 4EDCDB macr x0,y0,b y:(r4)+,y0 ;b=b+y(n)*ai1/2,y0=bi2/2
113 + P:00SF FC18B8 mpy y0,y1,b b,x:(r0)+ y:(r4)+,y0 ;b=x(n)*bi2/2,save wi1,y0=ai2
114 + P:0060 19A0DB macr x0,y0,b x:(r0),a a,y1 ;b=b+y(n)*ai2/2,a=next iter wi1,
115 + ;y1=output of section i
116 + P:0061 FC1922 asr a b,x:(r1)+ y:(r4)+,y0 ;a=next iter wi1/2,save wi2,
117 + ;y0=next iter bi0
118 + _ends
119
120 P:0D62 09C73F movep y1,y:datout ;output sample
121 _endp
122
123 P:0063 000004 rti
124 end
0 Errors
0 Warnings
6-21
6-22 MOTOROLA
SECTION 7
FIR FILTERS
“The filter can If phase distortion is of secondary importance to
be efficiently magnitude response, the desired filter can generally
implemented on be implemented with less memory, less computation-
the DSP56001 by al complexity, and at the lowest cost using IIR
using modulo structures. On the other hand, in applications requir-
addressing to ing linear phase in the passband and a specific
implement the magnitude response, the specified filter is generally
shifting and best implemented using FIR structures. Examples of
parallel data applications requiring linear phase are as follows:
moves to load
4. Communication systems such as modems or
the multiplier- Integrated Services Digital Networks (ISDN) in
accumulator.” which the data pulse shape and relative timing in
the channel must be preserved
MOTOROLA 7-1
7.19 Linear-Phase FIR
Filter Structure
The basic structure of a FIR filter is simply a tapped
delay line in which the output from each tap is
summed to generate the filter output. This is shown
in Figure 7-31. This structure can be represented
mathematically as:
N–1
y(n) = ∑ h ( i )x ( n – i ) Eqn. 7-16
i=0
7-2 MOTOROLA
Digital Delay Line
h0 x h1 x hN-1 x
Σ
y(n) (Filter Output)
N–1
Y(z) –1
H ( z ) = ------------ =
X(z) ∑ h ( i )z Eqn. 7-17
i=0
MOTOROLA 7-3
N–1
– jiθ
G(θ) = ∑ h ( i )e
i=0 Eqn. 7-18
N–1
= ∑ [ h ( i ) cos iθ – jh ( i ) sin iθ ]
i=0
N–1
– ∑ h ( i ) sin iθ
–1 i=0
φ ( θ )=tan --------------------------------------
- Eqn. 7-19
N–1
∑ h ( i ) cos iθ
i=0
7-4 MOTOROLA
delayed by two cycles (4π) and the first harmonic is
delayed by four cycles (8π). The group delay of a
system, τg, is defined by taking the derivative of φ(θ):
dφ
τ g ≡ – ------ Eqn. 7-21
dθ
Filter
x1(t) = sin ωt
t
∆φ1 = 4π-8π = -4π
Legend:
Represents the filtered wave
Represents the unfiltered wave (i.e., no delay)
MOTOROLA 7-5
but is twice the width of the original pulse; that is the
change in the pulse width is equal to the group de-
lay. The negative sign indicates the phase is
retarded or delayed (i.e., a causal system).
N–1
∑ h ( i ) sin iθ
i=0
tan θτ g = ------------------------------------ Eqn. 7-22
N–1
∑ h ( i ) cos iθ
i=0
N–1
∑ h ( i ) ( cos iθ sin θτ g – sin iθ cos θ τ g ) = 0
i= 0
or
N–1
∑ h ( i ) sin [ θ ( τ g – i ) ] = 0 Eqn. 7-23
i=0
7-6 MOTOROLA
LHS = h 0 sin θτ g + h 1 sin θ ( τ g – 1 ) + h 2 sin θ ( τ g – 2 ) + …
so that if:
(N – 1)
τ g = ------------------ Eqn. 7-24
2
θ ------------- – 1 = θ -------------
N–1 N–3
2 2
θ ------------- – N + 2 = – θ -------------
N–1 N–3
2 2
so that if:
φ ( θ ) = – ------------- θ
N–1
Eqn. 7-26
2
MOTOROLA 7-7
Therefore, a nonrecursive filter (FIR), unlike a recur-
sive filter (IIR), can have a constant time delay for all
frequencies over the entire range (from 0 to fs/2). It is
only necessary that the coefficients (and therefore
impulse response) be symmetrical about the mid-
point between samples (N-2)/2 and N/2 for even N or
about sample (N-1)/2 for odd N (see Eqn. 7-25).
When this symmetry exists, τg for the filter will be
N
------------- T seconds.
–1
2
7-8 MOTOROLA
design system such as FDAS to perform numerical
curve-fitting and optimization, a procedure that ne-
cessitates using a computer. For example, the
inverse Fourier transform integral is used to deter-
mine the FIR coefficients from a response
specification in the frequency domain, which gener-
ally requires a numerical integration procedure. The
inverse discrete Fourier transform (IDFT), which
can be implemented using the inverse fast Fourier
transform (IFFT) algorithm, is discussed in the fol-
lowing paragraphs. One reason for choosing this
approach is to demonstrate a method that can be
used to determine coefficients in real time since the
fast Fourier transform (FFT) can be implemented in
the same DSP56001 hardware as the FIR filter.
MOTOROLA 7-9
sides of by ej2πkm/N and summing over k as follows:
N–1 N – 1N – 1
∑ H ( k )e ∑ ∑ h ( i )e
j2πkm ⁄ N – j2πki ⁄ N j2πkm ⁄ N
= e
k=0 k=0i=0
N –1 N –1
– j2πki ⁄ N e j2πkm ⁄ N
= ∑ h(i) ∑ e
i = 0 k = 0
N –1
= ∑ h ( i ) Nδ
im
i = 0
= Nh ( m )
Eqn. 7-28
where: δim is the Kronecker delta, which is equal
to one when i = m but is zero otherwise
jφ ( k )
H ( k ) = A ( k )e
where: A ( k ) ≡ H ( k )
so that Eqn. 7-29 becomes:
7-10 MOTOROLA
N–1
1 jφ ( k ) j2πki ⁄ N
∑
Eqn. 7-30
h ( i ) = ---- A ( k )e e
N
k=0
At this point, the linear-phase constraints, Eqn. 7-25
and Eqn. 7-26, can be applied. The constraint that
the coefficients be real and symmetrical when h(i) is
complex (see Reference 1) implies that:
h ( i ) = h∗ ( N – 1 – i )
therefore:
N–1
1 – j φ ( k ) – j 2πk ( N – 1 – i ) ⁄ N
h∗ ( N – 1 – i ) = ----
N ∑ A ( k )e e
k=0
N–1
1 – j [ φ ( k ) + 2πk ( N – 1 ) ⁄ N ] j2πki ⁄ N
= ----
N ∑ A ( k )e e
k=0
Eqn. 7-31
2πk ( N – 1 )
φ ( k ) = – φ ( k ) – ----------------------------- + 2πr for r=0,1,2,...
N
or
(N – 1)
φ ( k ) = πr – πk ------------------ Eqn. 7-32
N
MOTOROLA 7-11
N–1
1 j [ πr – πk ( N – 1 ) ⁄ N + 2πki ⁄ N ]
h ( i ) = ----
N ∑ A ( k )e
Eqn. 7-33
k=0
1 jπr j [ πr – π ( N – 1 ) ⁄ N + 2πi ⁄ N ]
( i ) = ---- { A ( 0 )e + A ( 1 )e +…
N
j [ πr – π ( N – 1 ) ⁄ 2 + πi ]
+A ( N ⁄ 2 )e +…
j [ πr – π ( N – 1 ) ( N – 1 ) ⁄ N + 2π ( N – 1 ) i ⁄ N ]
+A ( N – 1 )e
j [ π – π ( N – k ) ( N – 1 ) ⁄ N + 2π ( N – k ) i ⁄ N ]
e
j [ πk ( N – 1 ) ⁄ N –2 πki ⁄ N ] j [ π – π ( N – 1 ) + 2πi ]
= e e
– j [ – π k ( N – 1 ) ⁄ N + 2πki ⁄ N ] – j [ π ( N – 2 ) + 2πi ]
= e e
– j [ – π k ( N – 1 ) ⁄ N – 2 π ki ⁄ N ]
= e
7-12 MOTOROLA
purely real, which is the desired result. In general,
for N even, the formulas for the frequency sampling
method can be reduced to:
N–1
1 j [ πr – πk ( N – 1 ) ⁄ N + 2πki ⁄ N ]
h ( i ) = ---- { A ( 0 )+
N ∑ A ( k )e
k=1
N⁄2–1
1 j [ πr – πk ( N – 1 ) ⁄ N + 2πki ⁄ N ] +
= ---- { A ( 0 )+
N ∑ Ak [ e
k=1 j [ π – π ( N – k ) ( N – 1 ) ⁄ N + 2π ( N – k ) i ⁄ N ]
e ]
N⁄2–1
1 j –π kN – 1 ⁄ N + 2πki ⁄ N
= ---- { A ( 0 ) +
N ∑ Ak [ e +
k=1 – j [ – πk ( N – 1 ) ⁄ N + 2πki ⁄ N ]
e ]
N⁄2–1
1 – j πk j [ πk ⁄ N + 2πki ⁄ N ]
= ---- { A ( 0 ) +
N ∑ A(k)[e e +
k=1 jπk – j [ πk ⁄ N + 2πki ⁄ N ]
e e ]
N⁄2–1
1 k πk
= ---- A ( 0 ) + 2 ∑ A ( k ) ( – 1 ) cos ------ ( 1 + 2i )
N N
k=1
Eqn. 7-34
where: r= 0 for 0 ≤ k < N/2
MOTOROLA 7-13
r= 1 for N/2 < k ≤ N-1
given
A(k) = A(N – k) N
for 1 ≤ k≤ ---- -1
2
with
A(N ⁄ 2) = 0
and
N–1 N
φ ( k ) = – πk ------------- for 0 ≤ k ≤ ---- -1
N 2
N–1 N
φ ( k ) = π – π k ------------- for ---- + ≤ k≤ N-1
N 2
In summary, if a filter with an even number of sym-
metrical real coefficients is desired, then the phase
must be linear, and the frequency response must
be symmetrical about N/2 and zero at N/2 (see Ref-
erence 1).
7-14 MOTOROLA
1.0
N/2
0.5
H(k)
0
0 8 16 24 31
k(N=32)
(a) Arbitrary Input Specification for Frequency Response Magnitude
0
Phase φ
-14.5π
-28π
0 16 31
MOTOROLA 7-15
Likewise, the y component (imaginary part) is the
product of the length and the sine of the phase angle.
This transformation to rectangular coordinates is
necessary to perform the IDFT (or IFFT) calculation:
N–1
1 jkθn
h ( n ) = ----
N ∑ H ( k )e Eqn. 7-35
k=0
7-16 MOTOROLA
0.5
Re[H(k)]
-0.5
0 16 31
k
(a) Real Part
0.5
Im[H(k)]
-0.5
0 16 31
k
(b) Imaginary Part
Figure 7-34 Response Transformed from Polar Coordinates
MOTOROLA 7-17
0.2
0.1
h(n)
-0.1
0 16 31
Figure 7-35 FIR Coefficients from Eqn. 7-17 for Filter Example
Imaginary
Real
7-18 MOTOROLA
The transfer function has exactly the same form as
the DFT of the h(n), but now the frequency is con-
tinuous up to fs/2:
N–1
– jnθ
H(θ) = ∑ h ( n )e Eqn. 7-36
n=0
where: θ = 2πf/fs
0
9 10 11
Filter Gain, G(θ), (dB)
0 1 2
-10
N/2
-20
-30
-40
3 4 5 6 7 8 12 13 14 15 16
0 π/4 π/2 3π/4 π
θ
(a) Gain (magnitude of Hz)) Plot
π/2
8 10
Phase φ(θ)
2 3 4 5 6 7
0
0
11 12 13 14 15
-π/2
9
1
-π
θ
(b) Phase Response Corresponding to Gain Plot
MOTOROLA 7-19
The continuous frequency gain and phase re-
sponse of the 32-coefficient example filter, plotted
in Figure 7-37, are generated as follows:
1⁄2
G ( θ ) = H ( θ ) = [ H ( θ )H∗ ( θ ) ]
N–1 2 N–1 2 1 ⁄ 2
= ∑ h ( n ) cos nθ + ∑ h ( n ) sin nθ
n=0 n=0
Eqn. 7-37
and
N–1
∑ h ( n ) sin nθ
–1 n = 0
φ ( θ ) = ( – tan ) ----------------------------------------
- Eqn. 7-38
N – 1
∑ h ( n ) cos nθ
n = 0
7-20 MOTOROLA
assumed a rectangular window function. A smooth-
ing window, w(n), can be used to improve this
situation (see Reference 10).
19 20 21 22 23 24
0 4 5
0 1 2 3
Filter Gain, G(θ), (dB)
-10
-20
-30
-40
6 7 8 9 10 1112 1314 15 16 17 18 25 26 27 282930 31 32
0 π/4 π/2 3π/4 π
θ
(a) N=64
0
Filter Gain, G(θ), (dB)
-10
-20
N=128
-30
-40
θ
(b) N=128
Figure 7-38 Log Magnitude Response of Filter Example with Larger N Values
MOTOROLA 7-21
is symmetrical so as not to disrupt the linear-phase
characteristics of the filter. Figure 7-34(b) uses a
window function described by w(n) = sin2[πn/(N-1)]
(also known as a Hanning window) to demonstrate
the sensitivity of the gain to windowing. w(n) is basi-
cally an envelope function used to taper the ends of
h(n) smoothly. The rounding of the transition-band
edges in Figure 7-34(b) is the trade-off for window-
ing; however, in most applications, this trade-off is
well worthwhile.
0
-10
Filter Gain, G(θ), (dB)
-20 N=128
-30
-40
-50
-60
-70
-80
0 π/4 π/2 3π/4 π
θ
(a) Rectangular Window
Filter Gain, G(θ), (dB)
0
-10
-20
-30 SINE2 WINDOW
-40
-50
-60
-70
-80
0 π/4 π/2 3π/4 π
θ
(b) Sine2 (Hanning) Window
Figure 7-39 Window Function Effects on Filter Example
7-22 MOTOROLA
Window functions have a powerful effect on the stop-
band attenuation as well as the passband transition
slope.The best passband transition slope perfor-
mance is achieved with the rectangular window, but
this window results in very poor stopband perfor-
mance and often severe passband fluctuation (or
ripple). All window functions have the effect of in-
creasing the stopband attenuation and reducing the
passband ripple at the expense of increasing the
width of the transition region. However, for most
window functions, the passband ripple is relatively
insensitive to N. Windowing is described in virtually
any DSP textbook (see REFERENCES). Also, win-
dowing is discussed with practical examples in
Implementation of Fast Fourier Transforms on Mo-
torola's DSP56000/DSP56001 and DSP96002
Digital Signal Processors (see Reference 19).
MOTOROLA 7-23
7-24
Figure 7-40 FDAS Output for FIR Bandpass Filter Example with a Kaiser Window
MOTOROLA
Recall that the continuous frequency response of
a FIR filter can be found by setting z = ejθ in the
z-transform so that:
N–1
– jθn
H(θ) = ∑ h ( n )e Eqn. 7-39
n=0
N–1
– jθ ( N – 1 ) ⁄ 2 jθ [ ( N – 1 ) ⁄ 2 – n ]
H(θ) = e ∑ h ( n )e
n=0
– jθ ( N – 1 ) ⁄ 2 jθ ( N – 1 ) ⁄ 2 jθ [ ( N – 1 ) ⁄ 2 ) – 1 ]
= e {h ( 0 )e + h ( 1 )e +…
– jθ ( N – 1 ) ⁄ 2 –j θ [(N – 1) ⁄ 2 ) – 1]
h ( N – 1 ) )e + h ( N – 2 )e }
Eqn. 7-40
Using Euler's identity, Eqn. 7-40 can be grouped
into sine and cosine terms as follows:
– jθ ( N – 1 ) ⁄ 2 (N – 1)
H(θ) = e { [ h ( 0 ) + h ( N – 1 ) ] cos θ ------------------
2
N–1 (N – 1)
+jh0 – hN – 1 sin θ ------------- + h ( 1 ) + h ( N – 2 ) ] cos θ ------------------ – 1
2 2
N–1
+j [ h ( 1 ) – h ( N – 2 ) ] sin θ ------------- – 1
2
Eqn. 7-41
MOTOROLA 7-25
If it is assumed that linear phase is achieved by
even symmetry (i.e., h(n) = h(N-1-n) and that N is
even, reduces to:
N⁄2–1
– jθ ( N – 1 ) ⁄ 2
∑ 2 h ( n ) cos θ ------------- – n
N–2
H(θ) = e
2
n=0
N⁄2–1
– jθ ( N – 1 ) ⁄ 2
2h ( n ) cos θ ------------- – n
N–2
H(θ) = e ∑ 2
n=0
Eqn. 7-42
jPθ
H ( θ ) = A ( θ )e Eqn. 7-43
7-26 MOTOROLA
the ideal response, then the error function in Eqn.
7-44 can be minimized:
max
E ( θ ) = ----------- D ( θ ) – A ( θ ) Eqn. 7-44
θ
E ( θe ) = –E ( θe + 1 ) N
fore = 1, 2, …, ---- + 1
2
and
max
E ( θ e ) = ----------- [ E ( θ ) ]
θ
N⁄2–1
∑ 2h ---- – k – 1 cos θ e k + ---
N 1
D ( θ ) ±δ = A ( θe ) =
2 2
k=0
Eqn. 7-45
MOTOROLA 7-27
Reference 5). Basically, a guess is made for the ini-
tial N/2 + 1 extremal frequencies. (Usually, this
guess consists of N/2 + 1 equally spaced frequen-
cies in the Nyquist range.) Using this guess, is
solved for the coefficients and δ. Using these coef-
ficients, A(θ) is calculated for all frequencies and
the extrema, and frequencies at which the extrema
are attained are determined. If the extrema are all
equal and equal to or less than that specified in the
initial filter specification, the problem is solved.
However, if this is not the case, the frequencies at
which the extrema were attained are used as the
next guess. Note that the final extremal frequencies
do not have to be equally spaced. Clearly, the equir-
ipple design approach is calculation intensive.
7-28 MOTOROLA
MOTOROLA
Figure 7-41 FDAS Output for FIR Bandpass Filter Example with Equiripple Design
7-29
Figure 7-41 shows an example of an equiripple de-
sign generated from the FDAS software package.
This example is the same as that used for the Kaiser
window example of Figure 7-40. The number of co-
efficients in the equiripple design is far less than that
generated by the Kaiser window method (179 ver-
sus 291). However, the passband ripple is larger.
7-30 MOTOROLA
3. Hardware DO loops execute without overhead
once the loop is started. After a three-cycle
initialization of the DO loop, the body of the loop
executes as if it were straight-line code. Since
the DO loop does not require any overhead
cycles for each pass, the need for straight-line
code is eliminated.
MOTOROLA 7-31
The CLR instruction clears accumulator A and per-
forms parallel data moves. The data move saves
the most recent input value to the filter (assumed to
be in XO) into the location occupied by the oldest
data in the shift register and moves the first coeffi-
cient in the filter (h0) into the data ALU.
b0 b1 b2
+ +
X:(R0) Y:(R4)
M0 =ntaps-1
x(n) =3 b(0) M4 =ntaps-1
=3
R0 x(n-1) R0 b(1)
Input Data
x(n-2) b(2) Filter Coefficients
x(n-3) b(3)
x(n) b(4)
7-32 MOTOROLA
The MAC instruction multiplies the data in X0 by the
coefficient in Y0 and adds the result to accumulator
A in a single cycle. The data move in this instruction
loads the next input data variable into X0 and the
next coefficient into Y0. Both address registers R0
and R4 are incremented. The MACR instruction cal-
culates the final tap of the filter, rounds the result
using convergent rounding, and address register
R0 is decremented.
7-33 MOTOROLA
7-34 MOTOROLA
REFERENCES
MOTOROLA Reference-1
16. McClellan, J. H. and T. W. Parks. “A Unified Approach
to the Design of Optimum FIR Linear-Phase Digital
Filters.” IEEE Trans. Circuits Systems CT-20, 1973,
pp. 697-701.
Reference-2 MOTOROLA