You are on page 1of 14

Exp. No.

:
Date:
C ONVOL UT ION
A IM :

To perform the following programs using TMS320C50 processor:


• Linear convolution
• Circular convolution

COMPONENTS REQUIRED:
1. C50 processor kit
2. CRO
3. Function generator
4. Power cable and probes

THEORY:
In general, convolution operations is of 2 types. They are:
1. Linear convolution
2. Circular convolution
Linear convolution is a complex operation and this can be carried
out using MAC and MACD instructions. It is given by: y(n)=x(n)*h(n) where
y(n) is the output sequence and x(n) & h(n) are the input
sequences
Convolution in frequency domain is calculated by process of multiplication
and accumulation with proper shifting of sequences. MAC and MACD
instructions are used in TMS processor for this purpose of performing

linear convolution.
Differences between MAC and MACD:
MAC MACD
The syntax is: The syntax is:
MAC pma,{ind},[nextARP] (or) MACD pma, dma (or)
MAC pma,dma MACD pma,{ind},[nextARP]
Data shift is not automatically produced It provides shifting automatically
CIRCULAR CONVOLUTION:
Consider two finite duration sequence of length N namely x(n) and y(n). Their
respective N-point DFT’s are
N1
 j* 2**n*k / N 

Xk  x(n)e , k 0,1, 2,3.......... .N1


n0

N1
 j*2**n*k /N 

Yk  y(n)e , k 0,1, 2,3.......... .N 1


n0

Multiplying the DFT’s together ,the result is a DFT, say Z(k) of a sequence z(n) of length
N.

Z(k) = x(k).Y(k), k=0,1,2,3,………………(N-1)

The IDFT of Z(k) is given as


N1

Zn  
1

 zke j*2**n*k / N
N
k 0

Substituting the values and rearranging the above equation we get the following term,

 
1
zn   N  1
xnN  1
yn e j*2** mn1*k
N

N
n0 i0  

The inner sum in the brackets of the above equation is of the form
N1

a N, a
k 1
and
k0 a  1 a /1 a
k N

e re a is d e fi
wh j* 2 ** m  n 1 *k  N ned as

e .
we observe that a=1 when m-n-1 is a multiple of N. On the other hand aN =1 for any value
a=0.

Consequently the above equation reduces to


N1

a N, l
k
m npN  mnN , p is an integer
k0

 0, otherwise
N1

Substituting this result in Z(n), we get zn   N


1
 x n y mn
   N

This expression has the form of a convolution sum. It is not the linear
convolution which relates the output sequences of linear system to the
input sequence of x(n) and the impulse response h(n). Instead, the
convolution sum involves the index (m-n) N and is called the CIRCULAR
CONVOLUTION. Thus we conclude that multiplication of the DFT’s of two
sequences is equivalent to the circular convolution of two sequences in
time domain.

PROCEDURE:

1. Open the C50 debugger software.


2. In Menu bar, choose Serial => Port settings => Set to Com1.
3. Go to Project => New Project and save it as .dpj file.
4. Go to File => New => Assembly file, then type the program and
save it.
5. In Assembly folder, choose the option Add file to Project and
save it.
6. Similarly in .cmd file, Add file to project and save it.
7. Now go to Project in Menu bar and choose the option Buuld
and in Serial => Load program.
8. Now the program will be loaded in the kit.
9. In Communication window, type input and view the output.
10. Close the window.

LINEAR CONVOLUTION:

CODING:
;--------------------------------------------------------------------
; LINEAR CONVOLUTION " y(n) = x(n)*h(n)"
;--------------------------------------------------------------------
.mmregs
.text
START:
LDP #100H
LAR AR1,#(8100H+4H) ; x(n) Input Location
(8100h) ZAC
MAR *,AR1
RPT #2H
SACL *+

LAR AR1,#(8200H+4H) ; h(n) Input Location (8200h)


ZAC
MAR *,AR1
RPT #2H
SACL *+
LAR AR3,#(8300H+6H) ; y(n) Output Location (8200h) LAR
AR4,#06H ; Count-1 ie, N1+N2-1

;Multiply & Accumulate:


;----------------------

Next_YN:
LAR AR1,#8100H
LAR AR2,#(8200H+6H)
LAR AR0,#06H
ZAC
SACL 0H
MAR *,AR1
LT *+,AR2
Loop_MAC:
MPY *-,AR1
LTP *+,AR0
ADD 0H
SACL 0H
BANZ Loop_MAC,*-,AR2
LACC0H
MAR *,AR3
SACL *- ; Store O/P Data "y(n)"

; Shift x(n) Values:

LAR AR1,#(8100H+6H) ; x(n)


LAR AR2,#5H ; Shift Count-1
LAR AR0,#2H ; Index Value 2H
MAR *,AR1
LACC*-
SACL 1H

Shift_XN: LACC*+ SACL


*0-,AR2
BANZ Shift_XN,*-,AR1
MAR *+
LACC1H
SACL *,AR4
BANZ Next_YN,*NOP
H1: B H1
;--------------------------------------------------------------------

CIRCULAR CONVOLUTION

Mnemonic Comments
LDP #0100H Load data pointer with value of 0100

LACC #00H Load the accumulator with the address 8000

SUB #01H Subtract 1 from accumulator and store it

LAR AR0,1H Load AR0 with content of 8001

LAR AR1,#8060H Load AR1 with 8060

LAR AR2,#8100H Load AR1 with 8100

COPYX2:MAR *,AR1 Modify ARP to AR2

LACC *+ Load acc with current auxiliary register and


increment it

MAR *,AR2 Modify ARP to AR2

SACL *+ Store acc lower content at AR2 and increment

MAR *,AR0 Modify ARP to AR0

BANZ COPYX2,* Branch on no zero to copy x2.decrement AR0

LAR AR0,1H Load AR0 with content of 8001

LAR AR2,#8010H Load AR2 with immediate value 8010

LOOP3:LAR AR1,#8060 Load AR1 with immediate value 8060

LAR AR3,#8050 Load AR3 with immediate value 8050

LAR AR4,1H Load AR4 with 8001

ZAP Zero acc and product register

LOOP:MAR *,AR3 Modify ARP to AR3

LT*+ Load T register with AR3 and increment

MAR *,AR1 Modify ARP to AR1

MPY *+ Multiply content of T register and AR1 and store


result in AR1

SPL 5H Store product register to memory location 05

ADD 5H Add content of location 05 with acc

MAR *,AR4 Modify ARP to AR4

SACL *+ Store acc lower content at AR2 and increment


CALL ROTATE Call the sub program rotate

LOOP2:MAR *,AR0 Modify ARP to AR0

BANZ LOOP3,*- Branch on no zero to loop3.decrement AR0

H: B H End

ROTATE :LDP # 0100H Load data pointer with value of 0100

LACC 01H Load the accumulator with the address 8001

SUB 02H Subtract 1 from accumulator and store it

LACC 0050H Load the accumulator with the address 8050

SACB Store acc content in acc buffer

LAR AR3,#8051 Load AR3 with immediate value 8051

LAR AR5,#8070 Load AR5 with immediate value 8070

LAR AR6,2H Load AR6 with content 8002

LOOP1:MAR *,AR3 Modify ARP to AR3

LACC *+ Load the accumulator with AR3 and increment

MAR *,5 Modify ARP to AR5

SACL *+ Store acc lower content at AR5 and increment

MAR *,6 Modify ARP to AR6


BANZ LOOP1,*- Branch on no zero to loop1.decrement AR0

LACB Load acc with immediate value 8070

MAR *,AR5 Modify ARP to AR5

SACL *+ Store acc lower content at AR5 and increment

LACC #8070H Load the accumulator with AR3 and increment

SAMM BMAR Store acc in memory mapped register BMAR

LAR AR3,#8050H Load AR5 with immediate value 8070

MAR *,AR3 Modify ARP to AR3

RPT #3H Repeat nest instruction 4 times

BLDD BMAR,*+ Block move from data memory to data


memory.BAMR is incremented by 1.AR is
incremented by 1
RET Return

RESULT:
Thus the linear and circular convolution of two entered sequence is
performed using DSP processor.
;INPUT ( x(n) )
; 8100 - 1
; 8101 - 3
; 8102 - 1
; 8103 - 3

;INPUT ( h(n) )
; 8200 - 1
; 8201 - 2
; 8202 - 1
; 8203 - 0

;OUTPUT (y(n) )

; 8300 - 1
; 8301 - 5
; 8302 - 8
; 8303 - 8
; 8304 - 7
; 8305 - 3
; 8306 - 0
;----------------------------------------------------------------
Memory Data location
8050 0001

8051 0002

8052 0003

8053 0004

h(n):

Memory location Data


8060 0005

8061 0006

8062 0007

8063 0008

Memory Data location


8010 0046

8011 0040

8012 003E

8013 0040

You might also like