<< Chapter < Page Chapter >> Page >

Appendix b:

c_fft_given.asm

.ARMS_off ;enable assembler for ARMS=0 .CPL_on ;enable assembler for CPL=1 .mmregs ;enable mem mapped register names .global _bit_rev_data .global _fft_data .global _window .global _bit_rev .copy "macro.asm" .sect ".data" N .set 1024 K_FFT_SIZE .set 1024 .align 4*N _bit_rev_data .space 16*2*N ; Output of bit reversing function .align 4*N _fft_data .space 16*2*N ; FFT output buffer .sect ".text" _bit_rev ENTER_ASM MOV #_fft_data, AR3 MOV #_bit_rev_data, AR7 MOV AR7, AR2 MOV #K_FFT_SIZE-1, BRC0 MOV #K_FFT_SIZE, T0 RPTB bit_rev_end-1 MOV dbl(*AR3), AC0 MOV AC0, dbl(*AR2+) AMAR *(AR3+T0B) bit_rev_end: LEAVE_ASM RET ; If you need any more assembly subroutines, make sure you name them ; _name, and include a ".global _name" directive at the top. Also, ; don't forget to use ENTER_ASM at the beginning, and LEAVE_ASM ; and RET at the end!

Appendix c:

lab4fft.c

/*****************************************************************/ /* lab4fft.c */ /* Douglas L. Jones */ /* University of Illinois at Urbana-Champaign */ /* January 19, 1992 */ /* Changed for use w/ short integers and lookup table for ECE420 */ /* Matt Kleffner */ /* February 10, 2004 */ /* */ /* fft: in-place radix-2 DIT DFT of a complex input */ /* */ /* Permission to copy and use this program is granted */ /* as long as this header is included. */ /* */ /* WARNING: */ /* This file is intended for educational use only, since most */ /* manufacturers provide hand-tuned libraries which typically */ /* include the fastest fft routine for their DSP/processor */ /* architectures. High-quality, open-source fft routines */ /* written in C (and included in MATLAB) can be found at */ /* http://www.fftw.org */ /* */ /* #defines expected in lab4.h */ /* N: length of FFT: must be a power of two */ /* logN: N = 2**logN */ /* */ /* 16-bit-limited input/output (must be defined elsewhere) */ /* real: integer array of length N with real part of data */ /* imag: integer array of length N with imag part of data */ /* */ /* sinetables.h must */ /* 1) #define Nt to an equal or greater power of two than N */ /* 2) contain the following integer arrays with */ /* element magnitudes bounded by M = 2**15-1: */ /* costable: M*cos(-2*pi*n/Nt), n=0,1,...,Nt/2-1 */ /* sintable: M*sin(-2*pi*n/Nt), n=0,1,...,Nt/2-1 */ /* */ /*****************************************************************/ #include "sinetables.h" void fft(void) { int i,j,k,n1,n2,n3; int c,s,a,t,Wr,Wi; j = 0; /* bit-reverse */ n2 = N >> 1; for (i=1; i < N - 1; i++) { n1 = n2; while ( j >= n1 ) { j = j - n1; n1 = n1 >> 1; } j = j + n1; if (i < j) { t = real[i]; real[i] = real[j]; real[j] = t; t = imag[i]; imag[i] = imag[j]; imag[j] = t; } } /* FFT */ n2 = 1; n3 = Nt; for (i=0; i < logN; i++) { n1 = n2; /* n1 = 2**i */ n2 = n2 + n2; /* n2 = 2**(i+1) */ n3 = n3 >> 1; /* cos/sin arg of -6.283185307179586/n2 */ a = 0; for (j=0; j < n1; j++) { c = costable[a]; s = sintable[a]; a = a + n3; for (k=j; k < N; k=k+n2) { /* Code for standard 32-bit hardware, */ /* with real,imag limited to 16 bits */ /* Wr = (c*real[k+n1] - s*imag[k+n1]) >> 15; Wi = (s*real[k+n1] + c*imag[k+n1]) >> 15; real[k+n1] = (real[k] - Wr) >> 1; imag[k+n1] = (imag[k] - Wi) >> 1; real[k] = (real[k] + Wr) >> 1; imag[k] = (imag[k] + Wi) >> 1; */ /* End standard 32-bit code */ /* Code for TI TMS320C54X series */ /* Wr = ((long int)(c*real[k+n1]) - (long int)(s*imag[k+n1])) >> 15; Wi = ((long int)(s*real[k+n1]) + (long int)(c*imag[k+n1])) >> 15; real[k+n1] = ((long int)real[k] - (long int)Wr) >> 1; imag[k+n1] = ((long int)imag[k] - (long int)Wi) >> 1; real[k] = ((long int)real[k] + (long int)Wr) >> 1; imag[k] = ((long int)imag[k] + (long int)Wi) >> 1; */ /* End code for TMS320C54X series */ /* Intrinsic code for TMS320C55X series */ Wr = _ssub(_smpy(c, real[k+n1]), _smpy(s, imag[k+n1])); Wi = _sadd(_smpy(s, real[k+n1]), _smpy(c, imag[k+n1])); real[k+n1] = _sshl(_ssub(real[k], Wr),-1); imag[k+n1] = _sshl(_ssub(imag[k], Wi),-1); real[k] = _sshl(_sadd(real[k], Wr),-1); imag[k] = _sshl(_sadd(imag[k], Wi),-1); /* End intrinsic code for TMS320C55X series */ /* Intrinsic code for TMS320C54X series */ /* Wr = _ssub(_smpy(c, real[k+n1]), _smpy(s, imag[k+n1])); Wi = _sadd(_smpy(s, real[k+n1]), _smpy(c, imag[k+n1])); real[k+n1] = _sshl(_ssub(real[k], Wr),-1); imag[k+n1] = _sshl(_ssub(imag[k], Wi),-1); real[k] = _sshl(_sadd(real[k], Wr),-1); imag[k] = _sshl(_sadd(imag[k], Wi),-1); */ /* End intrinsic code for TMS320C54X series */ } } } return; }

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing laboratory (ece 420 55x). OpenStax CNX. Jan 18, 2010 Download for free at http://cnx.org/content/col10397/1.10
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing laboratory (ece 420 55x)' conversation and receive update notifications?

Ask