<< Chapter < Page Chapter >> Page >

Appendix b:

c_fft_given.asm

1 ; v:\ece420\54x\dspclib\c_fft_given.asm 2 ; dgs - 9/14/2001 3 .copy "v:\ece420\54x\dspclib\core.inc" 4 5 .global _bit_rev_data 6 .global _fft_data 7 .global _window 8 9 .global _bit_rev_fft 10 11 .sect ".data" 12 13 .align 4*N 14 _bit_rev_data .space 16*2*N ; Input to _bit_rev_fft 15 16 .align 4*N 17 _fft_data .space 16*2*N ; FFT output buffer 18 19 20 ; Copy in the Hamming window 21 _window ; The Hamming window 22 .copy "window.asm" 23 24 .sect ".text" 25 26 _bit_rev_fft 27 ENTER_ASM 28 29 call bit_rev ; Do the bit-reversal. 30 31 call fft ; Do the FFT 32 33 LEAVE_ASM 34 RET 35 36 bit_rev: 37 STM #_bit_rev_data,AR3 ; AR3 -> original input 38 STM #_fft_data,AR7 ; AR7 -> data processing buffer 39 MVMM AR7,AR2 ; AR2 -> bit-reversed data 40 STM #K_FFT_SIZE-1,BRC 41 RPTBD bit_rev_end-1 42 STM #K_FFT_SIZE,AR0 ; AR0 = 1/2 size of circ buffer 43 MVDD *AR3+,*AR2+ 44 MVDD *AR3-,*AR2+ 45 MAR *AR3+0B 46 bit_rev_end: 47 NOP 48 RET 49 50 ; Copy the actual FFT subroutine. 51 fft_data .set _fft_data ; FFT code needs this. 52 .copy "v:\ece420\54x\dsplib\fft.asm" 53 54 55 ; If you need any more assembly subroutines, make sure you name them 56 ; _name, and include a ".global _name" directive at the top. Also, 57 ; don't forget to use ENTER_ASM at the beginning, and LEAVE_ASM 58 ; and RET at the end!

Appendix c:

lab4.h

1 #define N 1024 /* Number of FFT points */ 2 #define logN 10

lab4fft.c

1 /*****************************************************************/ 2 /* lab4fft.c */ 3 /* Douglas L. Jones */ 4 /* University of Illinois at Urbana-Champaign */ 5 /* January 19, 1992 */ 6 /* Changed for use w/ short integers and lookup table for ECE420 */ 7 /* Matt Kleffner */ 8 /* February 10, 2004 */ 9 /* */ 10 /* fft: in-place radix-2 DIT DFT of a complex input */ 11 /* */ 12 /* Permission to copy and use this program is granted */ 13 /* as long as this header is included. */ 14 /* */ 15 /* WARNING: */ 16 /* This file is intended for educational use only, since most */ 17 /* manufacturers provide hand-tuned libraries which typically */ 18 /* include the fastest fft routine for their DSP/processor */ 19 /* architectures. High-quality, open-source fft routines */ 20 /* written in C (and included in MATLAB) can be found at */ 21 /* http://www.fftw.org */ 22 /* */ 23 /* #defines expected in lab4.h */ 24 /* N: length of FFT: must be a power of two */ 25 /* logN: N = 2**logN */ 26 /* */ 27 /* 16-bit-limited input/output (must be defined elsewhere) */ 28 /* real: integer array of length N with real part of data */ 29 /* imag: integer array of length N with imag part of data */ 30 /* */ 31 /* sinetables.h must */ 32 /* 1) #define Nt to an equal or greater power of two than N */ 33 /* 2) contain the following integer arrays with */ 34 /* element magnitudes bounded by M = 2**15-1: */ 35 /* costable: M*cos(-2*pi*n/Nt), n=0,1,...,Nt/2-1 */ 36 /* sintable: M*sin(-2*pi*n/Nt), n=0,1,...,Nt/2-1 */ 37 /* */ 38 /*****************************************************************/ 39 40 #include "lab4.h" 41 #include "sinetables.h" 42 43 extern int real[N]; 44 extern int imag[N]; 45 46 void fft(void) 47 { 48 int i,j,k,n1,n2,n3; 49 int c,s,a,t,Wr,Wi; 50 51 j = 0; /* bit-reverse */ 52 n2 = N >> 1; 53 for (i=1; i < N - 1; i++) 54 { 55 n1 = n2; 56 while ( j >= n1 ) 57 { 58 j = j - n1; 59 n1 = n1 >> 1; 60 } 61 j = j + n1; 62 63 if (i < j) 64 { 65 t = real[i]; 66 real[i] = real[j]; 67 real[j] = t; 68 t = imag[i]; 69 imag[i] = imag[j]; 70 imag[j] = t; 71 } 72 } 73 74 /* FFT */ 75 n2 = 1; n3 = Nt; 76 77 for (i=0; i < logN; i++) 78 { 79 n1 = n2; /* n1 = 2**i */ 80 n2 = n2 + n2; /* n2 = 2**(i+1) */ 81 n3 = n3 >> 1; /* cos/sin arg of -6.283185307179586/n2 */ 82 a = 0; 83 84 for (j=0; j < n1; j++) 85 { 86 c = costable[a]; 87 s = sintable[a]; 88 a = a + n3; 89 90 for (k=j; k < N; k=k+n2) 91 { 92 /* Code for standard 32-bit hardware, */ 93 /* with real,imag limited to 16 bits */ 94 /* 95 Wr = (c*real[k+n1] - s*imag[k+n1]) >> 15; 96 Wi = (s*real[k+n1] + c*imag[k+n1]) >> 15; 97 real[k+n1] = (real[k] - Wr) >> 1; 98 imag[k+n1] = (imag[k] - Wi) >> 1; 99 real[k] = (real[k] + Wr) >> 1; 100 imag[k] = (imag[k] + Wi) >> 1; 101 */ 102 /* End standard 32-bit code */ 103 104 /* Code for TI TMS320C54X series */ 105 106 Wr = ((long int)(c*real[k+n1]) - (long int)(s*imag[k+n1])) >> 15; 107 Wi = ((long int)(s*real[k+n1]) + (long int)(c*imag[k+n1])) >> 15; 108 real[k+n1] = ((long int)real[k] - (long int)Wr) >> 1; 109 imag[k+n1] = ((long int)imag[k] - (long int)Wi) >> 1; 110 real[k] = ((long int)real[k] + (long int)Wr) >> 1; 111 imag[k] = ((long int)imag[k] + (long int)Wi) >> 1; 112 113 /* End code for TMS320C54X series */ 114 115 /* Intrinsic code for TMS320C54X series */ 116 /* 117 Wr = _ssub(_smpy(c, real[k+n1]), _smpy(s, imag[k+n1])); 118 Wi = _sadd(_smpy(s, real[k+n1]), _smpy(c, imag[k+n1])); 119 real[k+n1] = _sshl(_ssub(real[k], Wr),-1); 120 imag[k+n1] = _sshl(_ssub(imag[k], Wi),-1); 121 real[k] = _sshl(_sadd(real[k], Wr),-1); 122 imag[k] = _sshl(_sadd(imag[k], Wi),-1); 123 */ 124 /* End intrinsic code for TMS320C54X series */ 125 } 126 } 127 } 128 return; 129 }

Questions & Answers

what is math number
Tric Reply
x-2y+3z=-3 2x-y+z=7 -x+3y-z=6
Sidiki Reply
Need help solving this problem (2/7)^-2
Simone Reply
x+2y-z=7
Sidiki
what is the coefficient of -4×
Mehri Reply
-1
Shedrak
the operation * is x * y =x + y/ 1+(x × y) show if the operation is commutative if x × y is not equal to -1
Alfred Reply
An investment account was opened with an initial deposit of $9,600 and earns 7.4% interest, compounded continuously. How much will the account be worth after 15 years?
Kala Reply
lim x to infinity e^1-e^-1/log(1+x)
given eccentricity and a point find the equiation
Moses Reply
12, 17, 22.... 25th term
Alexandra Reply
12, 17, 22.... 25th term
Akash
College algebra is really hard?
Shirleen Reply
Absolutely, for me. My problems with math started in First grade...involving a nun Sister Anastasia, bad vision, talking & getting expelled from Catholic school. When it comes to math I just can't focus and all I can hear is our family silverware banging and clanging on the pink Formica table.
Carole
I'm 13 and I understand it great
AJ
I am 1 year old but I can do it! 1+1=2 proof very hard for me though.
Atone
hi
Adu
Not really they are just easy concepts which can be understood if you have great basics. I am 14 I understood them easily.
Vedant
hi vedant can u help me with some assignments
Solomon
find the 15th term of the geometric sequince whose first is 18 and last term of 387
Jerwin Reply
I know this work
salma
The given of f(x=x-2. then what is the value of this f(3) 5f(x+1)
virgelyn Reply
hmm well what is the answer
Abhi
If f(x) = x-2 then, f(3) when 5f(x+1) 5((3-2)+1) 5(1+1) 5(2) 10
Augustine
how do they get the third part x = (32)5/4
kinnecy Reply
make 5/4 into a mixed number, make that a decimal, and then multiply 32 by the decimal 5/4 turns out to be
AJ
how
Sheref
can someone help me with some logarithmic and exponential equations.
Jeffrey Reply
sure. what is your question?
ninjadapaul
20/(×-6^2)
Salomon
okay, so you have 6 raised to the power of 2. what is that part of your answer
ninjadapaul
I don't understand what the A with approx sign and the boxed x mean
ninjadapaul
it think it's written 20/(X-6)^2 so it's 20 divided by X-6 squared
Salomon
I'm not sure why it wrote it the other way
Salomon
I got X =-6
Salomon
ok. so take the square root of both sides, now you have plus or minus the square root of 20= x-6
ninjadapaul
oops. ignore that.
ninjadapaul
so you not have an equal sign anywhere in the original equation?
ninjadapaul
hmm
Abhi
is it a question of log
Abhi
🤔.
Abhi
I rally confuse this number And equations too I need exactly help
salma
But this is not salma it's Faiza live in lousvile Ky I garbage this so I am going collage with JCTC that the of the collage thank you my friends
salma
Commplementary angles
Idrissa Reply
hello
Sherica
im all ears I need to learn
Sherica
right! what he said ⤴⤴⤴
Tamia
hii
Uday
hi
salma
hi
Ayuba
Hello
opoku
hi
Ali
greetings from Iran
Ali
salut. from Algeria
Bach
hi
Nharnhar
A soccer field is a rectangle 130 meters wide and 110 meters long. The coach asks players to run from one corner to the other corner diagonally across. What is that distance, to the nearest tenths place.
Kimberly Reply
Jeannette has $5 and $10 bills in her wallet. The number of fives is three more than six times the number of tens. Let t represent the number of tens. Write an expression for the number of fives.
August Reply
What is the expressiin for seven less than four times the number of nickels
Leonardo Reply
How do i figure this problem out.
how do you translate this in Algebraic Expressions
linda Reply
why surface tension is zero at critical temperature
Shanjida
I think if critical temperature denote high temperature then a liquid stats boils that time the water stats to evaporate so some moles of h2o to up and due to high temp the bonding break they have low density so it can be a reason
s.
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Digital signal processing laboratory (ece 420). OpenStax CNX. Sep 27, 2006 Download for free at http://cnx.org/content/col10236/1.14
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)' conversation and receive update notifications?

Ask