10
IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. ASSP-24, NO. 6, DECEMBER 1916 529 York: McGraw-W, 1969, ch. 4, pp. 98-130. land, 1963, pp. 100-107. [79] B. Eckhardt, and H. W. Schiissler, “On the quantization error of [Sl] B. Liu and A. Peled, “Heuristic optimization of cascaderealiza- a multiplier,” in Proc. 1976 IEEE Znt. Symp. Circuits and Sys- tion of futed-point digital filters,” ZEEE Trans. Acoust. Speech, terns, Munich, Germany, 1976, pp. 634-637. SignalProcessing, vol. ASSP-23, pp. 464-473, Oct. 1975. [SO] H. W. Smith, “The applicability of quasi-linear methodsto[82] G. Dehner, “On the noise behaviour of a digital fdter in cascade non-linear feedback systems with random inputs,” in Proc. structure,” in Proc. 1976 IEEE Int. Symp. Circuits and Systems, Second Int. Congr. Znt. Fed. Automat. Contr., Basel, Switzer- Munich, Germany, 1976, pp. 348-351. A Computer Program for Designing Digital Elliptic Filters Abstract-A computer program is presented for designing digital elliptic fiiters of the four most common types: low-pass, highpass, bandpass, and bandstop. The program is presented in Fortran TV. The various numerical algorithms required for implementing the elliptic functions are referenced in the program and are obtained from readily availabletablesofmathematicalfunctions.Examples for each filter type are presented. E I. INTRODUCTION LLIPTIC filters’ have been widely used t o achieve re- strictive frequency domain requirements. They can simultaneously provide small passband ripple, 1,argestop- band attenuation, and small transition bandwidths, with equal ripple characteristics in both the passband and the stopband. Based on the early work of Cauer [l] , Norton 123, and Darlington [3] , a large amount of information is already in print. For example, the work of Grossman [4] is based upon Darlington’s early notes.Textbookssuch as Guillemin [SI , Storer 161, and Gold and Rader .[7] devote considerablespace to elliptic filters. Daniels [8] presents a detailed discussion of theoretical issues and approximation techniques. For the design of elliptic filters, there axe tables such as in Zverev [9] , Christian and Eisenmann [lo] , and Saal [l 11 , Manuscript received December 13, 1974; revised October 24, 1975 and June 6, 1976. This research was supported by the Advanced Re- search Projects Agency of theDepartment of Defense and was monitored by the Office of Naval Research under Contract N00014-7342-0221. A. H. Gray, Jr. is with the Department of Electrical Engineering and Computer Science, University of California, Santa Barbara, CA 93109, and the Speech Communications Research Laboratory, Inc., Santa Barbara,CA 93109. J. D. Markel is with the Speech Communications Research Labora- tory, Inc., Santa Barbara, California 93109. ‘Also referred to as Cauer filters, Zolltarev fiiters, and Chebyshev parameter filters. monographs such as in Henderson [ 121 and Szentirmai [ 131 , and design charts such as illustrated in Rabiner and Gold [ 141 . Many ofthe algorithmsneeded can befound in computer form such as in [8] , but a complete user-oriented computer program for the design of digital elliptic filters does not appear to exist in the currently available literature. A computer program for the design of fiite-duration im- pulse response (FIR) linear phase filters with equal ripple in the passband and stopband has been presented by McClellan, Parks, and Rabiner [ 151. If linear phase is not ofmajor impor- tance, considerably fewer coefficients are usually necessary with an infmiteduration impulse-response (IIR) digital elliptic filter design to match the specifications of an FIR equal ripple filter [14]. In this paper, a computer program for the design of digital elliptic filters is presented. The program is written in Fortran N and allows for the design of low-pass, high-pass, bandpass,andband-reject orbandstop filters. The program output provides computed filter specifications (based upon the input parameters) and the transfer function coefficients. Numerical algorithms with rapid convergence and high accu- racy are chosen so that very restrictive conditions can be met as long as sufficient computer accuracy is used. All algorithms for the Jacobi elliptic functions are taken from Abramowitz and Stegun [16] and each algorithm is identified within the computer program. The digital elliptic filter prdgram and its associated subroutines are presented in Appendix A. A brief description of the subroutines and an outline ofthe main program are presented in Appendix B. 11. PROTOTYPE FILTER All filter designs are based upon a normalized low-pass elliptic filter of order N in the s-plane, as illustrated in Fig. 1,

Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

  • Upload
    others

  • View
    7

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. ASSP-24, NO. 6 , DECEMBER 1916 529

York: McGraw-W, 1969, ch. 4, pp. 98-130. land, 1963, pp. 100-107. [79] B. Eckhardt, and H. W. Schiissler, “On the quantization error of [Sl] B. Liu and A. Peled, “Heuristic optimization of cascade realiza-

a multiplier,” in Proc. 1976 IEEE Znt. Symp. Circuits and Sys- tion of futed-point digital filters,” ZEEE Trans. Acoust. Speech, terns, Munich, Germany, 1976, pp. 634-637. SignalProcessing, vol. ASSP-23, pp. 464-473, Oct. 1975.

[SO] H. W. Smith, “The applicability of quasi-linear methods to [82] G. Dehner, “On the noise behaviour of a digital fdter in cascade non-linear feedback systems with random inputs,” in Proc. structure,” in Proc. 1976 IEEE Int. Symp. Circuits and Systems, Second Int. Congr. Znt. Fed. Automat. Contr., Basel, Switzer- Munich, Germany, 1976, pp. 348-351.

A Computer Program for Designing Digital Elliptic Filters

Abstract-A computer program is presented for designing digital elliptic fiiters of the four most common types: low-pass, highpass, bandpass, and bandstop. The program is presented in Fortran TV. The various numerical algorithms required for implementing the elliptic functions are referenced in the program and are obtained from readily available tables of mathematical functions. Examples for each filter type are presented.

E I. INTRODUCTION

LLIPTIC filters’ have been widely used to achieve re- strictive frequency domain requirements. They can simultaneously provide small passband ripple, 1,arge stop-

band attenuation, and small transition bandwidths, with equal ripple characteristics in both the passband and the stopband. Based on the early work of Cauer [l] , Norton 123, and Darlington [3] , a large amount of information is already in print. For example, the work of Grossman [4] is based upon Darlington’s early notes. Textbooks such as Guillemin [SI , Storer 161, and Gold and Rader .[7] devote considerable space to elliptic filters. Daniels [8] presents a detailed discussion of theoretical issues and approximation techniques.

For the design of elliptic filters, there axe tables such as in Zverev [9] , Christian and Eisenmann [lo] , and Saal [l 11 ,

Manuscript received December 13, 1974; revised October 24, 1975 and June 6, 1976. This research was supported by the Advanced Re- search Projects Agency of theDepartment of Defense and was monitored by the Office of Naval Research under Contract N00014-7342-0221.

A. H. Gray, Jr. is with the Department of Electrical Engineering and Computer Science, University of California, Santa Barbara, CA 93109, and the Speech Communications Research Laboratory, Inc., Santa Barbara,CA 93109.

J. D. Markel is with the Speech Communications Research Labora- tory, Inc., Santa Barbara, California 93109.

‘Also referred to as Cauer filters, Zolltarev fiiters, and Chebyshev parameter filters.

monographs such as in Henderson [ 121 and Szentirmai [ 131 , and design charts such as illustrated in Rabiner and Gold [ 141 . Many of the algorithms needed can be found in computer form such as in [8] , but a complete user-oriented computer program for the design of digital elliptic filters does not appear to exist in the currently available literature.

A computer program for the design of fiite-duration im- pulse response (FIR) linear phase filters with equal ripple in the passband and stopband has been presented by McClellan, Parks, and Rabiner [ 151. If linear phase is not of major impor- tance, considerably fewer coefficients are usually necessary with an infmiteduration impulse-response (IIR) digital elliptic filter design to match the specifications of an FIR equal ripple filter [14]. In this paper, a computer program for the design of digital elliptic filters is presented. The program is written in Fortran N and allows for the design of low-pass, high-pass, bandpass, and band-reject or bandstop filters. The program output provides computed filter specifications (based upon the input parameters) and the transfer function coefficients. Numerical algorithms with rapid convergence and high accu- racy are chosen so that very restrictive conditions can be met as long as sufficient computer accuracy is used. All algorithms for the Jacobi elliptic functions are taken from Abramowitz and Stegun [16] and each algorithm is identified within the computer program. The digital elliptic filter prdgram and its associated subroutines are presented in Appendix A. A brief description of the subroutines and an outline of the main program are presented in Appendix B.

11. PROTOTYPE FILTER All filter designs are based upon a normalized low-pass

elliptic filter of order N in the s-plane, as illustrated in Fig. 1,

Page 2: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

5 30 IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, DECEMBER 1976

I

FTRANSITION BAND I

I

wc=l w, PASSBAND STOPEAND

EDGE EDGE

Fig. 1. Prototype filter in the s-plane.

in terms of the magnitude squared response 1 TI ' . The proto- type filter is normalized to have a passband edge frequency of unity. The stopband edge frequency w, will depend upon the filter specifications to be described in the examples to follow. Using assorted mappings, the normalized low-pass filter can be transformed into various unnormalized filter types such as thosz described by Grossman [4] and Constantinides [17] . An equivalent approach is to use the bilinear and biquadratic transformations to obtain discrete low-pass and bandpass filters from the prototype low-pass filter in the s-plane. Re- placing s by l/s interchanges the stop and passbands and re- sults in the high-pass and band-reject or bandstop filters.

Filter design tables [9 ] -[11] generally use as parameters a reflection coefficient p and an angle 8 where, in terms of the variables of Fig. 1,

p = € / d W and

e = sin-' (1 /w,).

These parameters are also given as outputs by the computer program, with 8 expressed in degrees.

111. INPUT PARAMETERS The parameters entered into the program are the filter order,

the passband edge frequency or frequencies, and a single stop- band edge frequency (or the stopband attenuation). The way in which these parameters are entered determines the type of filter-low-pass, high-pass, bandpass, or bandstop. The pro- gram requests an input by typing the line

N,DBR,FS,Fl,F2,F3ORDBDOWN. The variable N is the order of the filter in the s-plane? It will equal the order of the filter in the z-plane for the low-pass and high-pass filters. For bandpass and bandstop filters, the filter order in the z-plane will equal 2N.

A minimum value for N can be estimated using the approxi- mation [6]

2 N G - In (4A/e) In [8/(0, - l)] (1) 71'

'A zero or negative value entered for N terminates the program.

where o, is the s-plane prototype filter stopband edge as shown in Fig. 1.

The input variable DBR is the dB ripple in the passband, related to E- of Fig. 1 by

DBR = 10 loglo (1 t e 2 ) . (2)

The variable FS is the sampling frequency, used to normalize the other frequency entries. The variables F 1 and F2 define passband edge frequencies as described in the following sec- tions. The variable F3 OR DBDOWN defines one stopband edge frequency if it is positive or the stopband attenuation if it is negative. For example, entering 30 for F3 OR DBDOWN implies a stopband edge frequency of 30 (in the same units as FS j, while entering -30 for F3 OR DBDOWN implies a stop- band attenuation of 30 dB, i.e.,

20 loglo ( A ) = 30.

V. LOW-PASS FILTERS A low-pass filter is identified by F1 being either zero or

negative. F2 then represents the passband edge frequency, which is mapped into w = 1 or s = j in the s-plane by using the bilinear transformation

1 (z - 1) c (z t 1)

s = - - (3 1

where

c = tan (nF21FS). (4)

F3 OR DBDOWN is the stopband edge frequency or the dB attenuation in the stopband for F3 OR DBDOWN positive or negative, respectively.

For F3 OR DBDOWN > 0, the prototype stopband edge fre- quency is computed from (3) as

w, = tan (nF3/FS)/tan (nlC!/FS). (5 1 As a first example, the filter used by Gold and Rader [7] is

illustrated where the original specifications were a minimum stopband attenuation of 60 dB, a maximum passband ripple of 0.5 dB, a sampling frequency of 10 kHz, a passband edge fre- quency of 2 kHz, and a stopband edge frequency of 2.2 kHz. Using (5 j and the approximation (l), a minimum of 7.8 is found [7]. Since N must then be at least 8, one or more of the requirements can be improved upon. The approach out- lined by Gold and Rader improves the requirements on both the stopband attenuation and the passband ripple. The pro- gram presented here can improve on either the stopband at- tenuation or the stopband edge frequency, as illustrated by the two examples to follow.

Fig. 2 shows the program input and output for the specifica- tions N = 8, FS = 10, F1 = 0, F2 = 2, F3 = 2.2, while Fig. 3 shows the filter response. Fig. 4 shows the program input and output for the specifications N = 8 , FS= 10, F1 = 10, F1 = 0, IT! = 2 , and F3 OR DBDOWN = -60. The corresponding €iter response is not shown since differences between the two cases are visually negligible. The only difference in the input data for the two cases lies in the entry F3 OR DBDO WN.

The printouts show the input data, the prototype filter

Page 3: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

GRAY AND MARKEL: COMPUTER PROGRAM FOR DESIGNING DIGITAL ELLIPTIC FILTERS 531

N,OBR,FS,Fl,F2,F3 OR OBOOWN

8, 8.58, 1a.m. a . m , 2.08. 2.26

LP FILTER, ~ . ~ E B O ~ E O + ~ B OB RIPPLE PASS EAND EDGE a . 2 0 ~ 0 a m + a 1 STOP BAND EDGE a.z2aaam+a1

I

-90 1 100 j ' g ' * 8 1

0 1 2 5 4 5

FREQUENCY (kHz)

Fig. 3. Filter response for the low-pass fiiter example of Fig. 2.

parameters 0 and p as THETA and RHO, followed by a listing of the fiiter parameters. First, for use in direct form imple- mentation or as a starting point in the design of orthogonal polynomial filter structures [18], [19] , the denomiflator and numerator coefficients are listed for the transfer function T(z) where

M+1 P(i) zl-i

A( i ) zl+ T(z) = i=l

M+1

i= 1

For example, from Fig. 4, the transfer function with rounded coefficients is of the form

T(z) = 0.0122 + 0.0159 z-' + * * . + 0.0122 z - ~

1 . - 3 . 3 6 ~ - ~ + . * * + 0 . 2 4 1 ~ - ~ Next the real and imaginary parts of the complex z-plane

poles and zeros and their quadratic forms for cascade imple- mentation are printed out. Only those poles and zeros on or above the real axis are printed, for they occur in complex con- jugate pairs. Thus, for examples,'the first line for POLES and QUADRATIC FORMS in Fig. 4 indicates a complex pole pair at 0.3009 + j 0.9356 through the printout of the real and ima-

N.OBR.FS,Fl.F2,FB OR OBOOWN

8, 8.58. 10.80, a .m. 2.80, -68.68

LP FILTER, ~.5~8aaao+m DE RIPPLE PASS BAND EDGE a.zoaoaao+al

SAMPLE FREQUENCY 6.1888080+62 STOP BAN0 EDGE 8.2188160+81

THETA- a.~28a63o+az. RHO- a.3297710+a~ -a.6~aaam+az OB DOWN

8 - ORDER A ( J )

1 a . ~ a ~ a a m m ~ + a : 8.1218279840-e1 P (J )

z - ~ . 3 3 6 4 2 8 2 9 8 o + a 1 8 . m 8 m 4 6 0 - 8 1 3 8.707598235C+81 8.4177208610-81 4 -8.980087218U+81 8.4596796180-61 s a. 934a978550+81 3.5968570230-a1 6 -a.730353a460+a1 a.459679810o-a1 7 0 . 3 8 4 3 9 4 3 9 ~ 0 ~ ~ 1 0 . 4 1 m 0 0 ~ 1 0 - 0 1 8 -0.1324945470+81 8.1588854450-81 9 0.2405882983+88 E. i218879040-01

POLES OUAORAlIC FACTORS @.3889853433+09 0.935$3383960+88 -8.6018186870+88 8.9659482640+88 8.3416382650+88 8.8653147280+00 -6.6832685380+88 6.856346367D+88 8.4433793C90+88 8.E854876880+80 -8.8987587370+88 8.67183517613+88 ~ . ~ ~ a z z ~ s 1 z o + a a ~ .z~1885~18o+ao -a .11804s3azo . ta 8 .427781w+o+aa

a . 1 9 1 5 6 ~ 9 a 3 o + a ~ a.981479;57o+aa .-8.3831338a60+a0 a . 1 a ~ ~ a m a m + m a . 1 1 1 4 3 9 1 5 1 0 + ~ a ~ . 9 9 3 7 7 1 m o + a a -.a.2228783a30+88 e.lmaaaaaao+a1

ZERCS QUADRATIC FACTORS

-0.1561814040+88 8.987728388040 8.3123628080+88 8.1888888680+81 -8.7985933670+88 6.6Rl6789410+88 8.1597186730+81 6.1888888880+81

GAIN TERM FOR CASCADE FCRM-Pl1)- 8.1218880-81

Fig. 4. A low-pass frlter example with stopband attenuation specified.

N,DBR.FS,Fl,F2.F3 OR DBOOWN

5. 8-38 , 6.50. 2.88, 3.25, -48.80

HP FILTER. 8.3808800+88 OB RIPPLE PASS BAND EOGE 0.20aamo+a1 STOP BAND EDGE a.1724770+81

POLES QUADRATIC FACTORS -B.3874898560+08 0.8780623320+88 0.614978113O+08 0.8655429790+68 -8.383198SEED+68 8.5958784620+88 8.7663978803+88 8.5619826980+68 -a.462214939o+a~ 8.a~a00aaam+m a . 4 6 2 ~ 1 4 9 3 9 0 + ~ ~ E . E B B B B ~ ~ ~ E D + ~ ~

-8.6333483460-81 8.9979548760+80 8.1278696690+80 8.1888888880+61 ZEROS QUAORATIC FACTORS

~ . 2 9 7 2 8 2 1 z ~ o + a ~ ~ . 9 5 4 7 8 9 ~ 8 4 o + a ~ -a.5945642400+aa o.laaaaaaaoo+al a . l a a ~ a a ~ 8 a o + ~ l a . a a ~ ~ a ~ ~ a a a o + a Q -a .1~aaaa~mo+a1 ~ . a a a ~ a a a a ~ o + m

GAIN TERM FOR CASCADE FORI~=PU)= a.5891790-a1

Fig. 5 , Program outputs for a high-pass fiiter design example.

ginary parts asp = 0.3009 t j 0.9356, and a quadratic form

= 1 - 0.6018 z - ~ + 0.9659 z-'.

For the case of real zeros on the unit circle (at z = -1 or z = +l), the quadratic form results are expressed in a degener- ate linear manner, as can be seen in the example of Fig. 5 where there is a zero at z = +1, resulting in the quadratic form

1 - 2-1 + oz-2 = 1 - z-1.

Following the printout of the poles, zeroes, and their quad- ratic form, the gain term for a cascade implementation P( 1) is printed.

If the filter is to be implemented in a parallel form, the user must supply his own subroutine to evaluate the residues at the poles.

Page 4: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

532 IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, DECEMBER 1976

VI. HIGH-PASS FILTERS High-pass Titers are identified by an entry F 2 which is equal

to or larger than the folding frequency FS/2. F1 represents the passband edge frequency. The entry F3 OR DBDOWN de- fines the stopband edge frequency, if positive, or the dB attenuation, if negative. The mapping for this case also uses the bilinear transformation of (3 ) , but with s replaced by l / s in the s-plane.

A fifth-order high-pass filter design example is shown in Figs. 5 and 6. Other input parameters are a sampling frequency of 6.5 kHz, a bandpass ripple of 0.3 dB, a bandpass edge fre- quency of 2 kHz, and a stopband attenuation of 40 dB. The interpretation of the output is identical to that discussed for the low-pass filter. As the passband edge frequency is greater than one quarter of the sampling frequency, all of the poles have negative real parts.

VII. BANDPASS AND BANDSTOP (BAND-REJECT) FILTERS The bandpass digital elliptic filter is obtained by using the

biquadratic transformation [7, p. 761 to get to the prototype s-plane filter,

1 z2 - 2 z c o s ( y ) + l C z2 - 1

s = - (6)

The bandstop filters are found by replacing s by I/s in (6). The constants c and y are chosen to map passband edge fre- quencies F1 and F 2 into s 2 j or o = 21. For the bandpass filter, this gives

c = tan (A6l2) ( 7 4

and

cos (y) = cos (8)/cos ( A 6 / 2 ) (7b)

where 8 and A8 are the normalized center frequency and bandwidths

8 = (F1 -t F 2 ) nlFS ( 8 4

and

A6 = 2n(F2 - Fl ) /FS . (8b)

If the input data are entered with 0 <F1 <F2 < FS/2, a bandpass filter is defined. If the input data are entered with 0 <F2 < F1 < FS/2, a bandstop filter is defined. Since N is the order of the filter in the s-plane, 2N is the order in the z-plane. The final data entry is F3 OR DBDOWN. If it is posi- tive and lies within the stopband, the entry defines one stop- band edge frequency. If the entry is negative, it is used as the stopband attenuation. If the entry does not fit either cate- gory, an error message is typed and the input data are re- quested again.

The program output and frequency response for a tenth- order digital bandpass filter is shown in Figs. 7 and 8, respec- tively. By requiring a stopband attenuation of -60 dB, both stopband edge frequencies are determined by the other input parameters. The program output and frequency response for an eighth-order digital bandstop filter are shown in Figs. 9 and 10, respectively. By specifying one of the stopband edge fre-

/ c I

FREQUENCY [kHz)

Fig. 6. Filter response for a high-pass filter design example.

6 0.3888272580+02 -E.9061670020-17 7 8.2998609150+02 -E.131E283090-01 8 0.1772095470+02 -0.1470363830-El 9 8.7661820770+!31 -8.1629E01860-01

IE ~.22a0281540ta1 -0.1431397260-01 11 8.3390826880+88 -0.5181266720-02

POLE5 QUAORATIC FACTORS -8.7945317810+08 8.5565137410+08 0.1589663480+01 8.9409881680+88

-8.6948459280+86 0.5678187640+80 8.1388891840+01 8.8841178880+00 -8.2692E9371O+EE 0.9115287640+00 0.5384187410+08 8.9033437880+00

-8.5188594660+66 8.64013478EO+EE 8.1037718930+61 8.679664581C+OE -8.3469248840+88 0.7811357370+00 8.693848009O+EEi 0.738529384D+00

ZEROS -E.9083375910+00 0.4182377560+80 0.1816675180+01 E.l00EEB~00O+Bl

QUADRATIC FACTORS

-8.9513676m+m a.3as~s75350+0a ~.19a27353m+a1 ~.1aa800~800+01 8.7416579540-81 a.99724592~~+~0 -a.14~331~910+0~ ~ . I E ~ ~ E ~ E B O + E I

-8.lEE88000EO+Ol 0.00EE08000040 8.1EE0000880t01 E.0E00000080+08 8.3819692940+E@ 2.9241750520+60 -E.7639384080+00 8.1E00BBE0E0+01

Fig. 7 . Program outputs for a bandpass filter design example.

0 I I I I I

40 L

" '1 -I 4 5

FREQUENCY (kHz)

Fig. 8. Frequency response of the bandpass filter design example.

quencies (F3 = 1.1), the other stopband edge frequency and stopband attenuation are determined by the other input parameters.

Although relatively low-order and nonstringent elliptic filter design examples have been presented here for simplicity, care has been exercised in the choice of numerical algorithms to assure that the complexity or stringency of the design is limited only by the computer accuracy used.

Page 5: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

GRAY AND MARKEL: COMPUTER PROGRAM FOR DESIGNING DIGITAL ELLIPTIC FILTERS 533

-100 -90 0 1 2 3 4 5 I.,J FREOUENC\ (kHz)

Fig. 10. Frequency response of the band-reject filter design example.

APPENDIX A COMPUTER PROGRAM

ELLIPTIC FILTER DESIGN PROGRAM DOUBLE PRECISION DIGITAL

BY

A. H. GRAY, JR. AN0 J. 0. NARKEL SPEECH COMNUNICATIONS RESEARCH LAEORATORY 8BBA MIRAMONTE DRIVE SANTA BARBARA. CA. 931a9

LOADING OF DATA -- MAIN PROGRAM INPUTS:

N- ORDER OF FILTER ( IN S-PLANE) DER- PASS BAND RIPPLE I N OB FS- SAMPLE FREQUENCY F1,FZ- PASS BANO EDGES [SEE OPTIONS) F3- STOP BAND EOGE OF! DBOOWN (SEE OPTIONS)

OPTIONS: ~~

ENTERED. I T IS TREATEO AS THOUGH I T IS THE STOP I N ALL CASES, I F A NEGATIVE VALUE FOR F 3 I S

BAND ATTENUATION I N OB. THE DESCRIPTIONS BELOW ARE FOR POSITIVE ENTRIES.

LOW PASS---- ENTER F1 AS LESS THAN OR EQUAL TO ZERO. THEN PASS BAND FROM 8 TO F2 WITH F3 STOP BAND EDGE.

THEN PASS BAND FROM F l TO FS/2 W I T H F3 STOP BANO EOGE.

STOP 2ANO.

HIGH PASS----ENTER FZ AS GREATER THAN OR ERUAL TO FS/;

BAND PASS---EE!IER 8cFlcF2<FS/2 WITH F 3 I N

BAND REJECT--ENTER B<FZ<Fl<FS/Z WITH F 3 I N STOP BANO

FOR SINGLE PRECISION, REMOVE THE DCUBLE PRECISION STATEMENTS. BEING SURE TO PUT I N DIMENSION STATEMENTS

READ AN0 WRITE STATEMENTS TO E OR F FORMATS. REMOVE FOR DIEENSIONEO VARIABLES. CHANGE 0 FORMATS FOR

THE WORDS DOUBLE PRECISION FROn THE FUNCTION STATEMENTS. IN ADDITION REMOVE THE D FROM EACH DCCURANCE OF OSIN. DCOS, DATAN. OSQRT, DABS, DEXP, AND REPLACE OLOG BY ALOG I N THE TWO PLACES I T OCCURS.

OOUBLE PRECISION A(41).ANG,BW.C,CANG.CGAM DOUBLE PRECISION OBO.DBFAC,DBR.OEN,F1,F2,F3,F.FNYQ,FS

DOUBLE PRECISION X. ZDUM(821 COMMON A.P.WL.PI.OBFAC,TEST,ZOUM,FS,IP.JP DIMENSION LB(4) 1.6 HOLDS LABEL FOR FILTER TYPES DATA LB(1)/2HLP/,LB(2)/2HBP/.LB(3~/2HHP/.LB(4)/2HBP/ IRD AN0 I P ARE READ AND WRITE DEVICE NUMBERS

DOUBLE PRECISION P(~~) ,P I ,Q ,SANG,TEST.TFO,WL(~~ I ,WR

IRD.5 IP-5

FOR DIFFERENT PRECISIONS PI-4.dJATANIl.OB)

GENERATION OF PI AND 1a/LoG(la)

OBFAC-18./OLOG~1E.D8~ TEST IS SET AT THE VALUE 0-16 FOR OOUBLE PRECISION ON A POP18. BUT ITS VALUE MAY VARY BETWEEN MACHINES.

ADDED TO ONE GIVES ONE. TEST-1.0-16

A RULE OF THUMB IS THE LARGEST NUMBER WHICH WHEN

WRITE(IP.351 FORMAT(/ZBH N.OBR,Z.Fl.F2,F3 OR DBOOWN/l NON-STANOARO FORflAT STATEMENT ON THE INPUT TO BE’ READ. THIS SHOULD BE ALTERED ON MOST NACHINES. REAO(IR0,48)N,DBR,FS,Fl,FZ,F3 FORNAT(I.50) SPECIFICATIONS ENTEREO I N Z-PLANE, CONVERTED TO S-PLANE.

CASE 1- LOW PASS FILTER CASE 2- BAND PASS FILTER CASE 3- HIGH PASS FILTER

I N S-PLANE ALL FILTERS HAVE PASS BAND EDGE AT WSWC-1. STOP BAND EDGE AT WR.

CASE 4- BAND REJECT FILTER

DBD--F3 FNYQ-FS/Z. I CASE-2 IF(N.LE.8) CALL EXIT

X-FZ IF(FZ-F1)58.63,68

F2-F l F 1 -X ICASE-4 BW-FZ-F1 IF(F1.GT.E.) GO TO 65

F1-8. ICASE-1

IF(DBD.GT.OBR) GO TO 75 IF((F3.LE.FZ).OR. (F3.GE.FNYQ)) GO TO 63 GO TO 75 WRITE(IP.64) FORMAT(Z2H OATA ERROR, TRY AGAIN) GO TO 1

FZ=FNYO IFLF2.LT.FNYQ)GO TO 78

BW-F1 ICASE-3 IF(OBO.GT.DBR1 GO TO 75 IF((F3.LE.8.).OR.lF3.GT.FlJ)GO TO 63 GO TO 75

IF(IF3.LT.F1).OR. (F3.GT.FZ)) ICASE-2 IF(DBD.GT.DBR) GO TO 75

IF((FB.GE.FNYQ).OR.(F3.LE.B.)) GO TO 63

ANG=BW?<PI /FS IFI(F3.LT.FZl.AND. (F3.GT.Fl)) ICASE-4

CANG=DCOS (ANG) C-OSIN(ANG)iCAXG

CGAM=DCOS (TFOrcPI /FS) /CANG TFO=Fl+FZ

I F F 3 WAS NEGATIVE AT ENTRY, THEN THE SUBROUTINE DBOUN USES IT AS OB OOWN I N STOP BAND TO FINO A STOP BAND EOGE.

ANG-FBIP I /FS IF(DBD.GT.OBR) CALL DBOWN(Fl.FP,FS, ICASE,C,CGAN.OBR.N)

CANG-DCOS(ANG) SANG-OSIN(ANG) GO TO (88.98.88,981 , ICASE WR-SANG/ (CANC>*L) GO TO lE0

WR- (CGAM-CANG) / (SANGnCI IF((ICASE.EQ.3).0R.(ICASE.EQ.4)1 WR-l./WR WR-OABS(WR) WLL1)=1. WL (2) =wn WRITE(IP.178) LB(ICASE),DBR IF((ICASE.EQ.31.0R.(ICASE.EQ.4)) ~ ~ 1 2 ) - l . / U L ( 2 ) GO T0(135,145,135.1451, ICASE DO 140 J-1.2

Page 6: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

534 IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, DECEMBER 1976

01340 148 01350 81360 01370 01380 145 01390 01400 01418 01420 01438 158 01440 01450 81460 160 01470 165 01488 170 01490 175 01500 180 01510 C 01520 C

01540 01530 C

01560 01558

01570 C E1580 C 01598 C 01608 C

01628 C 81610 C

01640 C 01630 C

01650 C 01668 C 01670 C 01688 C 81690 C 01788 C

01720 C 01710 C

01730 01740 01750

01770 01760

01780 81798

E1818 E1820 01830

01850 01840

01860 C 01870 C 81888 C 01890 01900 01910 01928 01930

01950 81940

01968 01978

m a 0

01980 01998 02008 82010

02030 02028

02040 C 82050 C 02060 02870

02890 510 02080 500

02100 02110 02120 02130 82140 02150 02160 C 02170 C 02180 E2190 02200 02218 02228 c 02230 C 02240 02250 82260 02270 02280

02300 02290

02310 02320 158 02330

WRITE(IP.175IA(ll A~JI=OATANICaWL~JI I~~~FS/PI

WRITE(IP.1801 A(21 GO TO 160 00 15i J= l ,2 OEN=DATAN 1CT:WL (J) I O=OSORT~1.+lC~:WLIJ~l~r;~~2-CGANa~~~21 O=OATANZ(O.CGAPIl AIJI=(O+OEN)~:FNYO/PI PlJ)-(O-OENl~~NYO/PI URITE(IP,1751 Pl11,AIll WRITElIP.180; P(21,AIZ) WRiTE(IP,1651 FS FORMAT(18H SAMPLE FREOUENCY ,013.6) FORMATIlX.A2,SH FILTER, ,013.6.10H OB RIPPLE1 FORMAT(17H PASS BANO EOGE ,2013.63 FORMAT [17H STOP BANO EOGE ,2013.61 A T THIS POINT FILTER TYPE (ICASEI AN0 RAPPING PARAMETERS (C AN0 CGAI1). ALONG WITH S-PLANE SPECIFICATIONS (WR. OBR. N l ARE GIVEN. CALL ELLIP(N,WR,OBR.ICASE,C,CGAM) GO TO 1 END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ................. ELLIP ................... ARITHMESIC-GEOMETRIC NEAN ALGORITHPI FOR CALUCLATION OF ELLIPTIC FUNCTIONS. TAKEN FROM ABRANOWITZ AN0 STEGLiN (ABS!. ......... NOTATION... ........ ABS GOLOSRAOER PROGRAN SClRT (ill K AK ALPHA ALPHA U.F U.F PHI

~,

K (ALPHA) K ( K l SN , CN SN , CN

PHI AKK SN, CN .................................................. .............. ..................

SUBROUTINE TO EVALUATE K1. AN0 00 LEVEL ELLIPTIC FILTER

SUBROUTINE ELLIP(N,WR,OBR;ICASE,C,CGAR1 DOUBLE PRECISION AK,AKl.AKlP,AKK.AKP,AS.ASN,C,CAY OOUBLE PRECISION CGAM.OISIN.OBO.OBFAC.OBR

OOUBLE PRECISION THETA,U.U0,V.WC.WR,X,XOUflll23l,Y,Z DOUBLE PRECISION ZOUill83)

OOUBLE PRECISION EPSIL, EP~~,PI,PS~,O,RHO.SCALE,T,TEST

COMMON XOUM,PI.OBFAC.TEST,ZOUM.IP.JP T-TEST wc-1. EPSO=OEXP IOBR/OBFACl-l. EPSIL=OSQRT (EPSOI PSO=l. -1. / 11. +EPSQl , RHO=OSORT (PSO) RHO IS A "REFLECTION COEFFICIENT" USEO I N NANY ELLIPTIC FILTER TABLES, AN0 IS OFTEN GIVEN AS A PERCENT. AK-WC/WR AKP=OSQRT (1. - A K w 2 1 X=AKKlAK.AKPl Y=AKK(AKP.AKI O=OEXP(-PIaFLOAT(Nl$:Y/Xl SCALE.1. NH-N/2 NC=NH+NH 1FLNC.EQ.N) SCALE-OSORTIl.+EPSOl AK1-CAY (0, TI AKlP=OS~RT(l.-AKl~~r;21 V=AKK (AKlP, AK1) AS=l.+(EPSIL/AKlIa?,2 OBO=-OBFAC;~JILOG (AS1 THETA=DISIN(T,WC/WRl?;l88./PI THETA I S A COMMON PARANETER USED TO OESCRIBE THE

WRITE(IP.588) THETA,RHO TRANSISITION BANO FOR ELLIPTIC FILTERS.

WRITE(IP.Sl81 OB0 FORNAT(7H THETA=.013.6,6H. RHO=.013.6) FORMAT(lX.013.6.8H OB OOWNI Z-l . /EPSIL UB=YsASN ( Z l / V CALL SING lN,UE.AK,WC.U,X. ICASE,NP,NZl CALL ZPLNlNP.NZ.C.CGAN.ICASE.SCALE1 RETURN EN0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

OOUBLE PRECISION FUNCTION AKK(AK.AKP1 AKKIAK,AKP!

DOUBLE PRECISION A(41),AK.AKP,B(411,C(41),OBFAC.PI OOUBLE PRECISION TEST,ZOUN(83) COMMON A.B,C,PI,OBFAC.TEST.ZDUN,IP,JP GENERATION OF TABLE USING AR1TH.-GEON. PIEAN AS I N SEC. 17.6 OF ABS. A(lI=l. BI l l=AKP

00 150 J=1,13. CI l l=AK

A ~ J + l l = . 5 : ~ ~ l A ~ J l + B ~ J l l B (J+ l I -OS~RT(A(J IaB(J l ) C (J+ l )= .S~ ; (A (J l -B (J I l

CONTl NUE IFIC(J+l)-TESTI 160,168,158

WRITE(IP,155)

. .

............. .............................

02340 02350 155 02368 157 E2378 160 E2388 C 02390 C E2480 C 024 10 02420 688 02430 02440 C

02460 C E2450 C

02470 C 02480 C 02490 C 02500 02510 82520 02530 02540 C 02550 210 02560 E2570 C 82588 C 02590 02600

02620 02610

02640 02630

02650 02660 02670 250 02680 300 02690 328 02700 02710 C 02728 02730 02740 C 02750 C 02760 02770 E2780 02790 02800

02820 02810 C

02830 410 02840

02860 02858 .

02870 02880 500 02890 82900 02910 C 82928

02940 82930 600

02960 C 02950 C

02970 C 02988 C 82998 C E3000 03010 03020 03030 03040 83050 03068 03070 03080 03090 03100

83120 83118

03130 03140 03150 03160 03170 83180 400 03190 03288 03210 03220 03230 E3240

03260 03250

83288 03270 500

03290 03380 C 03318 C 83320 C 03330 83340

WRITE(IP.1571 FORMAT(37H VALUE OF VARIABLE TEST I S TOO SMALL.) FORPIATl38H OR YOUR ACCURACY INSJFFICIENTII JP=J+1 END OF TABLE CALCULATION CALCULATION OF K ( K 1 AS IN GBR. CALLEO HERE AKK OONE BY USING 17.6.3 OF ABS. AKK=.5aPI/AIJPI RETURN EN0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ................ ASNIZI ............................ INVERSE SN OF JZ THIS SUBROUTINE EVALUATES THE INVERSE SC OF Z.

DOUBLE PRECISION FUNCTION ASN(Z1 OOUBLE PRECISION A~41~,AK,B~41l,Cl41l,OlSIN,OBFAC DOUBLE PRECISION F(83l.P.PI.O.TEST.TT.TWO.U.Z COMNON A,B,C.PI ,OBFAC,TEST,F, I P . JP GENERATION OF F-U BY 17.6.8 AN0 17.6.9 OF ABS P=OATAN(Zl

KQ I S USED FOR OUAORANT COUNT TO KEEP THE PROPER VALUE TWO-1.

KO=1 OF THE INVERSE TANGENT.

00 320 J-1,JP FIJ I -P/ (A(JI~~~TWOI TWO-TWOn2.

TTzOATAN (01 IF(TT1 258,308,388 KO=KO+l KH-K0/2 P=P-TT+PI.<FLOAT(KH) ASN=F (JP)

RETURN EN0 OF U CALCULATION

EN0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ............ SCN(U,SN,CN.ON.AK!. ........................ SUBROUTINE SCN(U.SN,CN,DN,AKl DOUBLE PRECISION A~41~,AK,B~41~.Ci41~,CN,OISlN DOUBLE PRECISION OBFAC,ON.P.PI.Q.SN,T.TEST,U.ZDO CONMON A.B,C.PI.DBFAC.TEST.ZO.IP.JP

EVALUATION OF SN, CN. AN0 ON USING SECTION 16.4 OF AB5 T-TEST

JPM=JP-1 N-JPN-1

OD 508 K=l,N P=(Z.a-N)aAIJPMl-U

JPMK=JPPI+l-K 8=CIJPNK)~OSIN(Pl/A(JPNKl

SN-OSIN(P1 P=0.5o(P+OISIN(T,Oll

EN0 OF SN AN0 CN CALCULATION CN=OCOS(PI

O N * O S Q R T ~ l . - ~ A K ~ ~ S N 1 ~ ~ ~ ~ ~ 2 1 RETURN EN0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ................ SING ............................. EVALUATION OF POLE ZERO LOCATIONS, USING PlAPPING OESCRIBEO I N GSR BY NEANS OF 16.8.1, 16.21.1. AN0 16.21.2 OF A&S. (ALL HERE I N S-PLANE). SUBROUTINE SING(N,U0,AK,WC,U,X,lCASE,NP,NZ1 OOLlBLE PRECISION AK.AKK,AKP,C,Cl,CN,O.O1.DBFAC,OEN,ON OOUBLE PRECISION Pl,S.Sl,SN.TEST,U.U0.WC OOUBLE PRECISION X,XOUN(123I.Y,Z.ZSl83) COPINON XOUPI.PI.OBFAC,TEST,ZS,IP.JP AKP=OSORT (1. -AK?&I Y-AKK(AKP.AK1 CALL SCN(UB,SI,C1,OI,AKP) NZ=N/2 NP- (N+1 I /2 X=AKK IAK.AKP1 DO 480 LPI=l,NZ L=N+l-LN-LN . Z=FLOAT IL I ftX/FLOAT (N)

L I -LR+l LR-29;NP+2<<LR-l

CALL SCN(Z,SN,CN,ON,AKl ZS (LRI =O. 25 ( L I 1 =WC/ lAK&Nl 00 508 LPI=l,NP L=N+l-LN-LR Z=FLOAT (Ll?<X/FLOAT(Nl LR-2;':LR-1

RETURN EN0 # # # # # # # # # # # # # X # # # # # # # ~ # # ~ U ~ ~ U U U # # # ~ # ~ ~ ~ ........... EVALUATION OF K FROM a. ..................... USING R A T I O OF ABS EOS. 16.38.7816.38.5 OOUBLE PRECISION FUNCTION CAY(O.TEST) OOUBLE PRECISION AO.AN.O.QF,OP.TEST

Page 7: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

GRAY AND MARKEL: COMPUTER PROGRAM FOR DESIGNING DIGITAL ELLIPTIC FILTERS 535

AN-1. AO=1. aF=l.

OF-OF;tOP AN=AN+Z. <<OF

OF-OFaOP

ap-a

IFKlF.LE.TEST) GO TO 858

END uuuuuuuuuuuuuu#u#uuuuuuuu#uuuuuuuuuu#u ..... ~3 F R D ~ aB DOWN INPUT ......................... USED TO FINO F3 WHEN STOP BAND ATTENUATION HAS BEEN ENTERED INSTEAD OF A STOP BAND EDGE. SUBROUTINE DBDWN(Fl.F2.F3.1CASE,C,CGAfl,DBR,N) DOUBLE PRECISION AK,AKl,AKlP.AKK,AKP.AS,C.CAY.CGAPl,CPHI DOUBLE PRECISION OBR,DBFAC,EPSIL,EPSQ,Fl,FZ,F3,FS,PI.QP DOUBLE PRECISION RAD.T.TEST,U,V.WR.X,XDUfl(l23).ZDUfl(SZl COflMON XDUR, PI.DBFAC,TEST,ZDUR.FS,IP.JP T-TEST EPSQ-DEXP (DBR/DBFAC) -1. EPSIL=OSPRT(EPSO) AS-DEXP (-F3/OBFAC) AKl=EPSIL/OSC!RT(AS-I.) AKlP-OSQRT(1. - A K l . d )

V=AKKIAKlP,AKl) U=AKK (AK1, AKlP)

AKP-CAY (OP, TI AK=DSORT 11. -AKPI*&) WR-l./AK IF((ICASE.ECl.3).0R. (ICASE.EQ.4)) WR-l./WR

F3-FS?rOATAN( (CaWR)I/PI IF((ICASE.ED.Z).OR. (ICASE.EQ.4)) GO TO 288

X= (C;.dJRl ?ctZ RAD=X$'t (l.-CGAMaaZ)+XauZ CPHI I (CGAfl+DSQRT (RAD) 1 / (1, +X1 F3-DICOS1T.CPHl)aFS/(Z.~~PI) RETURN END uuuuuuu#uuuuuuu#uuu##uuu#uuu##uuuuuuuu

flAPPING OF S-PLANE POLES AND ZEROS INTO 2-PLANE POLES ANC ZEROS, FDLLOWEO BY FORMING OF POLYNOflIAL5. SUBROUTINE ZPLN(NP,NZ,C.CGAfl,ICASE.SCALE) OOUBLE PRECISION A(41),ALPHA(41).AI,AN,AR,BI,BR DOUBLE PRECISION C.CGAfl.CNG,0(41I,DICOS,DBFAC,DEN,E(41)

'DOUBLE PRECISION OI.OR,Ofl.RI.RR.SCALE,S[II,S~R,SSIGN OOUBLE PRECISION FS.GAfl.P~41~,PI~41l.PII,PN,(l,OA

DOUBLE PRECISION T,TEST,WL(2).Y(41).Z~2,821,ZS(82) CORflDN A.P,Y.PII,DBFAC.TEST.ZS.FS.IP.JP DIMENSION IE(41) . IS(41) T=TEST

NT-NP+NZ 00 15 J-1,NT NR=Ja2-1 N I -NR+l OEN=ZS(NR)~~,Z+ZS(NI)us2 ZS (NR) =ZS INRI /DEN ZS IN1 ) -ZS IN1 1 /DEN

NR=NI +1 IFINP-NZ) 38.38,26

N I -NR+l NZ=NZ+l ZS (NRI -E. ZS(NI)=B. GO TO 18 CONTINUE

NO-NP READ I N S PLANE ROOTS.

NN=-1

NC=ND JT-B

I R = I l + l I I = I R + l RR-ZS(IR) RI-ZS(I1) NC-NC-1 DEN- ( R l L ) ~ r 2 + (1. -RR<C) ~ n ?

CASE 1, Cu5. (2-1) / (Z+l).. ......

~ P - ~ E ~ P ( - P I , ~ F L D A T ( N ) ~ U I V )

GO TO 3aa

................. ................... Z PLANE

GO ~ 0 ( 3 a , 3 ~ , 1 a , 1 m , ICASE

I 1-8

GO TO (1aa.1wlaa.1za1 ,ICASE

OR z - ( l+~UsJ/ ( l -CUS)

JT-JT+1 Z ( l . J T ) - ( l . - ( R R n C l a ~ ~ 2 - ( R I c C ) ~ ~ ~ , 2 ) / D E N Z12,JT)--2.~~;PI:'~~OEN

JT-JT+1 Z( l ,JT)=Z( l ,JT- l ) Z(Z,JT)--Z(Z,JT- l )

CASE 2 C<&-lZn>'2 - ZaZ>dOSlGAR) + l ) / ( Z a a 2 - 1)

IFIRI) 11a.zaa.m

GO TO zaa

sa1 = a n m I N IOA)

Z(I.JT)=AR+SaR JT=JT+l

Z(2. JT) =AI+SDI JT-JT+l Z (1, JT) =AR-SOR 7 (2, JT) ,AI -5GI

JT=JT+Z DO 143 KK=1,2 JJ=JT-2+KK Z( l .JJ ) -Z( I .JJ -2) Z(2. JJ1=-2(2. JJ-2)

IF(NN1 230,258,258

I F ( R I 1 zoa,zaa,13a

IF(NCI z20.zza.90

NN-NZ M=JT IF(NN) 258,258,248 NC-NN GO TO 90

IF~ I - JT ) 3aa,3aa,26a INSERT NUflERATOR ZEROS AS NEEDED

Z( l ,JT)=- l . JT=JT+l

Z (2, JT) =6.

JT=JT+l Z( l , JT) - l . Z(Z.JTI=B.

LJRITE(iP,3iE) fl CONTINUE

FOHflAT(I4,BH s ORDER) CREATE THE POLYNOflIALS flPl=fl+1

DO 556 J=l.MPl ICPIT-6

P(J ) -0 .

P ( l J = l . Y(J1-0.

OD 688 lk1.P DO 688 KK-i, J K=J+l-KK JJ=J+MaICNT P(K+l)-P(K+l)-Z(l ,JJlaP(K)+Z(2,.IJ)aY(K) Y ( K + l ) = Y ( K + l ) - Z ( Z , J J I n P ( K ) - Z ( l , J J ) a Y ( K ) IF(ICNT1 626.628.648

00 G3B J=l,f lPi ICNT=i

A(J )=P(J)

CONTINUE NORRALIZE TO S=8 SSI GN=i .

GO TO m a , 278,25a,27a) , I CASE

GO TO 258

GO TO 518

GO ~0(680,69a.670,680), ICASE SIGN=-1.

AN=1. PN-1.

PN=SSIGN;,:PN+P (J) DO 6% J=Z,MPi

AN=SSIGNaAN+A(JI GO TO 708 GAM=OICOS(T,CGAfl) MH=fl/Z PN=P (flH+i I AN=A (flt'+l j I I E N 4 AI-8. IF(RH - 2 a l I E l 694,694,692 Al.1.- PN=B. AN=@.

J I = J 00 695 J=l . f lH

JH=MH+l+J CNG=OCOS(FLOAT(Jl)sCAfl - A I ~ ~ ~ P I I / Z . l

JL=flH+l-J PN=PN+CNG+(P(JH)+(l.-Z.::AII>~:P(JL)!

O=AN/ (PN6CALE) AN-AN+CNG,;;(A(JH)+ll.-Z.?,AI),.~A(JL))

00 718 J=l.MPl P(JI-O,.P(J)

Page 8: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

536 IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, DECEMBER 1976

85358 05368 715 05378 85380 725 E5330 738 85480 85418 05420 85438 05448 85450 888

05470 05480 85490 85588 85510 05528 05538 888 85548 85558 900 85560 310 05570 920 85588 85530

85618 C 85680 C

05620 85638 05640 85658 85668 85670 05680 05690 05708 85718 85728 85730 05748 83758 85760 85778

85730 85788

05800 C 25818 C 85828 85838 85840 05858 85868 85878 85880 05830 180 85908

85460 a77

wRITElIP,715I FORflATIlEX.4HAlJ),14X,4HP(J))

WR;TE(IP,73E)J,A(J).P(J) 00 725 J=l.PIPl

FORflAT(13,2317.31 WRlTE(IP.388) 00 877 Jil,N IF(Zl2,Jl.LT.0.IGO TO 877 CALL OUAO(T.ZIl,J).Z12.J).OR,OPI) WRITElIP.880) Zll,J),Z(2,JI,OR.OM FORflAT(lX.4017.9) CONTINUE WRITE(IP.91Rl 00 888 J=l.il JJ=J+fl IFlZI2.JJI.LT.8.) GO TO 888 CALL OUAO~T.Z~1.JJ),ZI2,JJl,OR,Ofll WRITE!IP.8881 Z(l,JJl,Z(2,JJI,[IR,Otl CONTINUE WRITE(lP.9281 PI1) FORtlAT(15X.SHPOLES,28X,l7HQUAORATIC FACTORS] FORPlATllSX,SHZEROS,20X.l7HOUAORATIC FACTORS)

RETURN FORNAT(33H GAIN TERfl FOR CASCADE FORlI=P(ll=D13.6)

EN0 ###################x###### DOUBLE PREClSiON lNVERSE SINE AN0 COSINE.. .. DOUBLE PRECISION FUNCTION OISIN(TEST.X) OOUBLE PRECISION A.TEST,X.XO,Y xo=x

~~

A=OABS (X) IF(A.LT.TEST1 XO=8.08 Y=OSQRT Il.-XO:.-.2) OISIN=OAiAN2(XO.Y) RETURN EN0 DOUBLE PRECISION FUNCTION OICOS(TES1.X) DOUBLE PRECISION A,TEST,X,XO.Y XD=X A=OABS (X) 1FlA.LT.TEST) X0=0.00 Y=OSQRT (1. -XO.::'<21 OICOS=OATAN2(Y,XO) RETURN EN3 d#X#n####P##~Ul#~####~##~############ SUBROUTINE TO GENERATE QUADRATIC FACTORS SUBRCUTINE OUAD(T.ZR.ZI,QR,QN) DOUBLE PRECISION T.ON.OR.ZI,ZR OR=-ZR-ZR afl=ZR.;d?2+2 Ii.??2

Qrl=8. 1FIZI.GE.T) GO TO 180

OR=-ZR RETURN END

APPENDIX B The computer program of Appendix A implements the

necessary transformations between the z-plane and s-plane, designs a prototype filter in the s-plane, and gives the output transfer function parameters in the z-plane. The necessary equations for the prototype design are summarized in [6] and [7] with only minor differences in notation between the two references. Algorithms for evaluation of all of the neces- sary elliptic functions are taken from 1161 and specific refer- ences to sections and equations are presented in the program.

The program is portable to the extent that at most three statements should have to be changed in order to run on most Fortran machines. The read and write device numbers are specified in l i e s 520 and 530, with IRD being the read device and IP being the write device. The input data is read with FORMAT statement number 35, line 640, which presently is a free format not standard on many machines.

Rather than give a flow chart for the functioning of the program, we present an outline description since there are few conditional branching statements other than those used to determine the filter type from the input data. This outline refers to the line numbers printed with the program. The main program uses a set of 11 subroutines or functions given by

subroutine ELLIP lines 01570-02150 function AKK lines 02 160-02430 subroutine ASN lines 02440-02730 subroutine SCN lines 02740-02940 subroutine SING lines 02950-03290 function CAY lines 03300-03480 subroutine DBDWN lines 03490-03790 subroutine ZPLN lines 03800-05590 function DISIN lines 05600-05780 function DICOS lines 05710-05790 subroutine QUAD lines 05800-05900

The function of each of these subroutines and functions is described in the outline.

Main Program (Lines 00010-01560) The main program takes the input specifications for the

filter and uses them to obtain the specifications for the proto- type s-plane fdter by first finding the appropriate mapping between the z-plane and the s-plane. There are no calculations involving the Jacobi elliptic functions that take place in the main program.

00010-00620 00630-00640 00650-01060

01070-01110

01 120-01 150

01 160-01530

01540-01560

Comments and initialization. Request for input data. Reading of input data, comments, logic to test for type of filter, and logic to test for input data errors. Generation of the parameters needed for the mapping as in (4) and (7). Comments and test for input of dB attenua- tion in stopband rather than stopband edge. If the data entry for F3 OR DBDOWN is negative, then that entry is treated as stop- band attenuation, and the subroutine DBDWN i s called. The mapping parameters and filter type are used to obtain the prototype filter stopband edge a,. For the case of bandpass and bandstop frlters, both stopband edges (in the z-plane) are evaluated for computer printout. The subroutine ELLIP is called for filter design, and command returns to the request for input data to design a new filter.

Subroutine ELLIP

This subroutine, combined with the other subroutines and functions that it calls, carries out the design of the prototype filter in the s-plane.

01570-01880 Comments and evaluation of e of Fig. 1 and the reflection coefficient

p = € ] 4 - 7 7 .

01890-01920 Evaluates the modulus k and the com- plete elliptic integrals K(k) and K'(k) = K(d') needed to be used with [6, eq. (30.21a)l or [7, eq. (3.27)]. The modulus

Page 9: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

GRAY AND MARKEL: COMPUTER PROGRAM FOR DESIGNING DIGITAL ELLIPTIC FILTERS 5 37

01930-01950

01960-02000

02010-02030

02040-02110

02 120

02 130

02140-02150

Function AKK

02160-02430

Subroutine ASN

02440-02730

Subroutine SCN 02740-02940

Subroutine SING

02950-03290

k is the transition ratio, which for a nor- malized prototype filter is given by

k = l / q . (9)

The complete elliptic integrals are evaluated by the function AKK. A variable SCALE is evaluated to be used later to insure that the peak magnitude filter response is one. In addition, 16, eq. (20.21a)J or [7, eq. (3.27)1 is used to evaluate the ratio of K(kl) /Kr(kl) . The function CAY is then used to evaluate kl from the ratio where

kl = E / ~ A T . . (10)

The modulus kl is used to evaluate the complete elliptic integral K'(kl) , called V in the program. Equation (10) is used to give the value of A , and thus the stopband attenuation, from the values of kl and e. After comments and assorted print state- ments, the variable uo of (61 and [7] is obtained for use in the evaluation of pole locations. This is done through the function ASN by using the unnumbered equation at the top of [6, p. 2961 or [7, eq. (3.30)]. Subroutine SING is called, which actually finds the locations of the poles and zeros in the s-plane for the prototype filter. Subroutine ZPLN is called to transform the poles and zeros from the s-plane to the z- plane, and to find the digital filter parameters. Termination of the subroutine.

This function implements the arithmetic- geometric mean (AGM) table of [16] and obtains the complete elliptic integral. Spe- cific algorithms from [16] are referenced in comment statements.

This subroutine is used to evaluate the in- verse elliptic sine function of an imaginary argument as needed for line number 021 10. It is based upon [16] and uses the AGM table generated by function AKK . . . .

This subroutine uses the AGM table gen- erated by function AKK and algorithms of [16] to evaluate the elliptic functions sn ( ), cn ( * ), aEd dn ( - ).

This subroutine evaluates the locations of

Function CA Y

03300-03480

the poles and zeros in the s-plane for the prototype filter. It is based on [6, eq. (30.18) and (30.15)1 or equivalently, [7, figs. 3.1 1 and 3.12 and eq. (3.29)] .

This function evaluates a modulus, k or kl , from a ratio of complete elliptic integrals K(k)/K'(k) or ~ ( k ~ ) / K ' ( k ~ ) . Its input is called a nome, Q defined by [16, eq. (17.3.17)] as

Q = exp [- K'( * )/K( . )] . (1 1)

Subroutine DBDWN 03490-03790 This subroutine is used when the final data

entry F3 OR DBDOWN is negative, so that it is taken as a stopband attenuation. For ease of programming, this subroutine was de- signed to take that entry and obtain a value for F 3 , a discrete stopband edge frequency so that the remainder of the calculations carry on as though that F3 value had been entered. The stopband attenuation is used to give A of Fig. 1. The modulus k , is found from (1 l), and the elliptic integrals K(k, ) and K'(k,) by using function AKK. Equation (30.21a) of [6] or [7, eq. (3.27)1 are then used to give the ratio K(k)/K'(k), and the function CAY gives the modulus k and from (1 1) the prototype stopband edge frequency. Using the mapping param- eters, this stopband edge frequency is transformed back to the z-plane to give the equivalent stopband edge frequency entry which would have produced the required stopband attenuation.

Subroutine ZPLN

This subroutine maps the s-plane poles and zeros into the z-plane, and obtains the final transfer function.

03800-04720

04730-04850

04860-05040

The type of mapping and appropriate trans- formation is used to map the s-plane poles and zeros into the z-plane, not including s-plane zeros at infinity. The complex calculations are all carried out with real arithmetic. Any s-plane zeros at infinity are mapped into the z-plane. The net result is a total of N poles and N zeros for low-pass and high- pass fdters and 2N poles and 2N zeros for bandpass and bandstop filters. The poles and zeros are used to form numer- ator and denominator polynomials for the z-plane transfer function, each with unity leading coefficient, so they are not yet normalized.

Page 10: Computer Program for Designing Digital Elliptic Filtersread.pudn.com/downloads93/doc/comm/368875/A computer progra… · A Computer Program for Designing Digital Elliptic Filters

538 IEEE TRANSACTIONS ON ACOUSTICS, SPEECH, AND SIGNAL PROCESSING, VOL. ASSP-24, NO. 6 , DECEMBER 1976

05050-05340 The numerator polynomial is normalized so as to give a transfer function whose maxi- mum passband magnitude is unity.

05350-05590 The fi ter parameters are printed out.

Functions DISIN and DICOS

05600-05790 Inverse sines and inverse cosines are calculated by these subroutines using inverse tangents. A few compilers have their own double precision inverse sines and cosines, usually called DASIN and DACOS.

Subroutine QUAD

05800-05900 This subroutine generates the quadratic factors for the printed output.

ACKNOWLEDGMENT The authors would like to thank M. Dolan for her assistance

in making the computer program portable and N. Dechter for her assistance in preparing the computer printout.

REFERENCES [ l ] W. Cauer, Siebschaltungen. Berlin: V.D.I. Verglan, 1931. [2] E. L. Norton, “Constant resistance networks with applications to

filter groups,” Bell syst. Tech. J. , vol. 15, pp. 178-193, Apr. 1937.

[3] S. Darlington, “Synthesis of reactance 4-poles,” J. Math. Phys., vol. 18, pp. 257-353, Sept. 1939.

[4] A. J. Grossman, “Synthesis of Tchebycheff parameter symmetri-

cal fiiters,”Proc. IRE, vol. 45, pp. 454-473, Apr. 1957.

Wilev. 1957. [5] E. A. Guillemin, Synthesis of Passive Networks. New York:

[6] J.-E. Storer, Passive Network Synthesis. New York: McGraw- I> - - - . -

Hill, 1957. [7] B. Gold and C. M. Rader, Digital Processing of Signals. New

York: McGraw-Hill, 1969. [8] R. W. Daniels, Approximation Methods for Electronic Filter

Design. New York: McGraw-Hill, 1974. [9] A. I. Zverev, Handbook of Filter Synthesis. New York: Wiley,

1967. [ 101 E. Christian and E. Eisenmann, Filter Design Tables and Graphs.

New York: Wiley, 1966. [ l l ] V. R. Sad, Der Entwurf von Filtern mit Hilfe des Kataloges

Normeirter TiefPasse. BacknangIWiirt, Germany: Telfunken, 1961.

[12] K. W. Henderson, “Nomographs for designing elliptic function fiters,”Proc. IRE, vol. 46, pp. 1860-1864, Nov. 1958.

[13] G. Szentirmai, “Nomographs for designing elliptiefunction fii- ters,”Proc. IRE, vol. 48, pp. 113-114, Jan. 1960.

[14] L. R. Rabiner and B. Gold, Theory and Application of Digital SignalProcessing. Englewood Cliffs, NJ: Prentice-Hall, 1975.

[15] J. H. McClellan, T. W. Parks, and L. R. Rabiner, “A computer program €or designing optimum FIR linear phase digital filters,” IEEE Trans. Audio Electroacpust., vol. AU-21, pp. 506-526, Dec. 1973.

[16] M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions. Washington, DC: National Bureau of Standards, Applied Mathematics Series 55,1964.

[17] A. G. Constantinides, “Spectral transformations for digital fii- ters,” Proc. Inst. Elec. Eng., vol. 117, pp. 1585-1590, 1970.

[18] A. H. Gray, Jr. and J. D. Markel, “Digital lattice and ladder filters,” IEEE Trans. Audio Electroacoust., vol. AU-21, pp. 491-500, Dec. 1973.

[19] -, “A normalized digital filter structure,” IEEE Trans. Acoust., Speech, Signal Processing, vol. ASSP-23, pp. 268-277, June 1975.

Roundoff Noise in Digital Filters: Frequency Transformations and Invariants

Abstruct-ne family of filters {H(F(z)) :F(z) a frequency transfor- mation} generated from a prototype filter H ( Z ) is shown to possess cer- tain common properties. These are coordinate-free quantities (called second-order modes) which are invariant under frequency transforma- tion. The invariance is significant in the design of low-noise fixed-point digital filter structures since the second-order modes characterize the minimum attainable noise. Filter structures (including parallel, cascade, and ladder configurations) are studied whose output noise is essentially

Manuscript received March 3, 1976; revised June 17, 1976. This work was supported by the National Science Foundation under Grant GK-43138 and the U.S. Army Research Office under Contract

The authors are with the Department of Electrical Engineering, Uni- DAHC04-75-G-0153.

versity of Colorado, Boulder, CO 80302.

independent of bandwidth and center frequency. An analysis of direct form structures (whether isolated or as one section within a cascade or parallel configuration) results in an expression giving the dominant term in the output noise as a function of the parameter in the low-pass- low-pass transformation. This noise term approaches infinity as band- width approaches zero. Thus, for narrowband fiiters, a difference of several orders of magnitude in the output noise can exist between a scaled direct form (having six multiplications per two-pole section) and the optimal form (having nine multiplications per two-pole section).

I. INTRODUCTION

A COMMONLY held opinion, based on experience, is that roundoff noise in fixed-point digital filters in- creases in seventy as the width of the passband is made