Download ADSP-2181 Experiments - ECE
Transcript
4
EXPERIMENTS
94
0.250
0.625
0.500
0.750
0.000
0.000
0.000
=
=
=
=
=
=
=
0x2000
0x5000
0x4000
0x6000
0x0000
0x0000
0x0000
=
=
=
=
=
=
=
2/8
5/8
4/8
6/8
0/8
0/8
0/8
0.21875
0.43750
0.53125
0.84375
0.87500
0.90625
0.84375
=
=
=
=
=
=
=
0x1c00
0x3800
0x4400
0x6c00
0x7000
0x7400
0x6c00
=
=
=
=
=
=
=
7/32
14/32
17/32
27/32
28/32
29/32
27/32
4
EXPERIMENTS
95
rti; nop; nop; nop;
start:
i2
i4
i5
i7
=
=
=
=
^w;
^x;
^y;
^a;
L2 = %w;
m4 = 1; L4 = 0;
m5 = 1; L5 = 0;
L7 = 2*(M+1);
{delay-line buffer}
{input samples}
{output samples}
{double-length a,b coef-}
{-ficient buffer}
{clear delay line}
zero(i2, m2, L2);
(The b-coefficients and x have been scaled down to fit in 1.15 format,
as compared to Example 7.5.4.)
Scaling factors:
cntr = L;
do outputs until ce;
sr1 = dm(i4, m4);
sr = ashift sr1 by -ex (hi);
The a,b coefficients that are used in the program and read from
the file ab.hex are the related to the true a,b coefficients by
the following scale factors whoes exponents are passed to ccan():
a_used = 2^(-ea) * a_true
b_used = 2^(-eb) * b_true
ccan(M, i7, m7, i2, m2, ea, eb, sr1);
sr = ashift sr1 by ex (hi);
dm(i5, m5) = sr1;
outputs:
{read input x}
{pre-scale x down}
{compute output y}
{input from sr1}
{output in sr1}
{post-scale y up}
{write y}
idle;
In this example: ea = 0, eb = 0, (no further scaling is needed)
.endmod;
The input samples x must also, in general, be scaled down before
passed into ccan() and then the output from ccan() must be scaled up:
x1 = 2^(-ex) * x
y1 = ccan(x1)
y = 2^ex * y1
input to ccan()
output from ccan() due to x1
output due to x
In this example, we must use ex = 1 (or larger).
The unscaled input (ex = 0) causes overflows and the wrong output.
Further down-scaling of the input and up-scaling of the output are necessary to
avoid overflows. The input scaling exponent was ex = 1. The program direx1.dsp
implements an IIR filter using the direct-form realization macro cdir. It does not
need any input down-scaling and therefore ex = 0.
{direx1.dsp - direct-form-I realization example using cdir}
{Junior DSP Lab - Rutgers ECE Dept - S. J. Orfanidis - Jan 1996}
}
.include <c:\adi_dsp\macros\dspmac.dsp>;
.module/ram/abs=0
.const
.const
.var/dm
.var/dm
.var/dm/circ
.var/pm/circ
.init
.init
.init
canex1;
L=9;
M=3;
x[L];
y[L];
w[M+1];
a[M+1], b[M+1];
x: <xiir.hex>;
a: <a.hex>;
b: <b.hex>;
.const ea = 0;
.const eb = 0;
.const ex = 1;
jump
rti;
rti;
rti;
rti;
rti;
{dsp macros}
start; nop; nop; nop;
nop; nop; nop;
nop; nop; nop;
nop; nop; nop;
nop; nop; nop;
nop; nop; nop;
{Based on Example 7.5.4 of Introduction to Signal Processing. The filter
coefficients are:
a = [1, 0, 0, -1]
b = [1, 1, 2, 0] / 4 = [0.25, 0.25, 0.50, 0]
{input signal length}
{filter order}
{input samples}
{output samples}
{delay-line buffer in DM}
{concatenated coeffs in PM}
{input samples}
{denominator coefficients}
{numerator coefficients}
{scaling exponent for a}
{scaling exponent for b}
{pre/post scaling exponent}
{Interupt vector table}
{No interrupts used}
The coefficients define a double-length concatenated circular buffer i7,
and are stored in the files a.dec/a.hex and b.dec/b.hex. The input and
output signals are in the files xiir.dec/xiir.hex, yiir.dec/yiir.hex:
x = 0.125
0.375
0.250
0.625
0.500
0.750
0.000
0.000
0.000
=
=
=
=
=
=
=
=
=
0x1000
0x3000
0x2000
0x5000
0x4000
0x6000
0x0000
0x0000
0x0000
=
=
=
=
=
=
=
=
=
1/8
3/8
2/8
5/8
4/8
6/8
0/8
0/8
0/8
y = 0.03125
0.12500
0.21875
0.43750
0.53125
0.84375
0.87500
0.90625
0.84375
=
=
=
=
=
=
=
=
=
0x0400
0x1000
0x1c00
0x3800
0x4400
0x6c00
0x7000
0x7400
0x6c00
=
=
=
=
=
=
=
=
=
1/32
4/32
7/32
14/32
17/32
27/32
28/32
29/32
27/32
(The b-coefficients and x have been scaled down to fit in 1.15 format,
as compared to Example 7.5.4.)
Scaling factors:
The a,b coefficients that are used in the program and read from