<< Chapter < Page | Chapter >> Page > |
A bit-reversing and FFT routine have also been provided in
lab4fft.c
, listed in
Appendix C .
Again,
make sure you understand how the bit reversal is takingplace. In
lab4main.c
, the line defining
C_FFT
must not be commented for use of the C FFT routine. The sine
tables (twiddle factors) are located in
sinetables.h .
This fft requires its inputs in two buffers, the real buffer
real
and the imaginary buffer
imag
,
and the output is placed in the same buffers.The length of the FFT,
N
, and
logN
are
defined in
lab4.h
, which is also listed in
Appendix C .
When experimenting with the C
FFT make sure you modify these length values instead of the onesin the assembly code and
lab4main.c
!
As mentioned, you will be using the FFT to compute the
spectrum of a windowed input. For your implementation youwill need to create a 1024-point Hamming window. First,
create a Hamming window in matlab using the function
hamming
. For the assembly FFT, use
save_coef
to save the window to a file
that can then be included in your code with the
.copy
directive. For the C FFT, use the matlab
function
write_intvector_headerfile
with
name
set to
'window'
and
elemperline
set to
8
to create
the header file that is included in
lab4main.c
.
Once the DFT has been computed, you must calculate the squared magnitude of the spectrum for display.
squr
and
squra
useful in
implementing
.
Because the squared magnitude is always nonnegative, you can replace one of the magnitude values with a -1.0 as a triggerpulse for display on the oscilloscope. This is easily performed by replacing the DC term ( ) with a -1.0 when copying the magnitude values to the output buffer. Thetrigger pulse is necessary for the oscilloscope to lock to a specific point in the spectrum and keep the spectrum fixed on the scope.
If you are planning on writing some of the code in C, then
you may be forced to use intrinsics. Intrinsic instructionsprovide a way to use assembly instructions directly in C.
An example of an intrinsic instruction is
bit_rev_data[0]=_smpyr(bit_rev_data[0],window[0])
which performs the assembly signed multiply round
instruction. You may also find the
_lsmpy
instruction useful. For more information on intrinsics, see
page 6-22 of the
TI-C54x
Optimizing C/C++ Compiler User's Guide .
The following lines of code were borrowed from the C FFT to serve as an example of arithmetic operations in C. Savethis code in a file called mathex.c and compile this file. Look at the resulting assembly file and investigate the differences betweeneach block. Be sure to reference the compiler user's guide to find out what the state of the FRCT and OVM bits are. Does each blockwork properly for all possible values?
void main(void)
{
int s1, s2;
int t1, t2;
int i1, i2;
int n1 = 16383, n2 = 16382, n3 = 16381, n4 = 16380;
/* Code for standard 32-bit hardware, */
/* with x,y limited to 16 bits */
s1 = (n1*n2 + n3*n4) >> 15;
s2 = (n1 + n2) >> 1;
/* Code for TI TMSC5000 series */
t1 = ((long int)(n1*n2) + (long int)(n3*n4)) >> 15;
t2 = ((long int)n1 + (long int)n2) >> 1;
/* Intrinsic code for TMS320C54X series */
i1 = _sadd(_smpy(n1,n2), _smpy(n3,n4));
i2 = _sshl(_sadd(n1, n2),-1);
}
Notification Switch
Would you like to follow the 'Ece 320 spring 2004' conversation and receive update notifications?