Cec337-Dsp Architecture and Programming-1187423045-Dspap Lab Manual
Cec337-Dsp Architecture and Programming-1187423045-Dspap Lab Manual
02.
Programming examples
using C, Assembly and
linear assembly.
03.
Implementation of
moving average filter.
04.
FIR implementation with
a Pseudorandom noise
sequence as input to a
filter.
05.
Fixed point
implementation of IIR
filter.
06.
FFT of Real-Time input
signal.
1
2
STUDY OF TMS320C6713 DIGITAL SIGNAL PROCESSOR :
3
TMS320C6713 DIGITAL SIGNAL PROCESSOR :
The TMS320C6713 (C6713) is based on the very - long - instruction - word (VLIW)
architecture, which is very well suited for numerically intensive algorithms. The
internal program memory is structured so that a total of eight instructions can be
fetched every cycle. For example, with a clock rate of 225 MHz, the C6713 is capable
of fetching eight 32 - bit instructions every 1/(225 MHz) or 4.44 ns.
Features of the C6713 include 264 kB of internal memory (8 kB as L1P and L1D
Cache and 256 kB as L2 memory shared between program and data space), eight
functional or execution units composed of six ALUs and two multiplier units, a 32 -
bit address bus to address 4 GB (gigabytes), and two sets of 32 - bit general - purpose
registers.
The C67xx processors (such as the C6701, C6711, and C6713) belong to the family
of the C6x floating - point processors; whereas the C62xx and C64xx belong to the
family of the C6x fi xed - point processors. The C6713 is capable of both fi xed - and
floating - point processing. The architecture and instruction set of the C6713 .
Features of the C6416 include 1056 kB of internal memory (32 kB as L1P and
L1D cache and 1024 kB as L2 memory shared between program and data space),
eight functional or execution units composed of six ALUs and two multiplier units,
a 32 - bit address bus to address 4 GB (gigabytes), and two sets of 32 - bit general -
purpose registers.
4
CODE COMPOSER STUDIO :
A Code Composer Studio project comprises all of the fi les (or links to all of the
fi les) required in order to generate an executable fi le. A variety of options enabling
fi les of different types to be added to or removed from a project are provided. In
addition, a Code Composer Studio project contains information about exactly how
fi les are to be used in order to generate an executable fi le. Compiler/linker options
can be specifi ed. A number of debugging features are available, including setting
breakpoints and watching variables, viewing memory, registers, and mixed C and
assembly code, graphing results, and monitoring execution time. One can step
through a program in different ways (step into, or over, or out).
Real - time analysis can be performed using CCS ’ s real - time data exchange
(RTDX) facility. This allows for data exchange between the host PC and the target
DSK as well as analysis in real - time without halting the target.
5
FILE TYPES :
You will be working with a number of fi les with different extensions. They include:
4. file.sa : linear assembly source program. The linear optimizer uses file.sa
as input to produce an assembly program file.asm .
6. file.lib : library fi le, such as the run - time support library file rts6700.lib .
6
EXP NO : 01
REAL-TIME SINE WAVE GENERATION.
DATE :
AIM :
To generate the waveform for the sine wave signal using MATLAB.
APPARATUS REQUIRED :
ALGORITHM :
1) Enter the number of cycles, period and amplitude for respective waves.
7
8
PROGRAM :
clear all;
close all;clc;
t = 0:0.05:N;
x = sin(2*pi*t);
subplot(121);
plot(t,x);
xlabel('---> time');
ylabel('---> amplitude');
subplot(122);
stem(t,x);
xlabel('---> time');
ylabel('---> amplitude');
9
OUTPUT :
10
1.(B) : SINE WAVE GENERATION PROGRAM USING EIGHT POINTS
WITH DIP SWITCH CONTROL ( SINE8_LED.C ) :
PROGRAM :
11
OUTPUT :
12
RESULT :
Thus the real time sine wave signal was generated .
13
14
EXP NO : 02
PROGRAMMING EXAMPLES USING C,
ASSEMBLY AND LINEAR ASSEMBLY.
DATE :
AIM :
To implement the programming examples using C for assembly and linear assembly.
APPARATUS REQUIRED :
ALGORITHM :
1) Enter the number of cycles, period and amplitude for respective waves.
15
16
PROGRAM :
#include <stdio.h>
main()
{
short n=6; //set value
short result; //result from asm function
result = sumfunc(n); //call ASM function sumfunc
printf("sum = %d", result); //print result from asm function
}
17
OUTPUT :
18
2.(B) : FACTORIAL OF A NUMBER USING C CALLING AN
ASSEMBLY FUNCTION ( FACTORIAL ).
19
OUTPUT :
20
2.(C ) : 32 - BIT PSEUDORANDOM NOISE GENERATION USING C
CALLING AN ASSEMBLY FUNCTION ( NOISEGEN_CASM ).
21
ADD A1,A2,A2 ;
SHR A1,1,A1 ;shift right 1->bit 31 to LSB
ADD A1,A2,A2 ;
AND A2,1,A2 ;Mask LSB of A2
SHL A4,1,A4 ;shift seed left 1
OR A2,A4,A4 ;Put A2 into LSB of A4
B B3 ;return to calling function
NOP 5 ;5 delays for branch
OUTPUT :
22
2.(D) : DOT PRODUCT USING C FUNCTION CALLING A LINEAR
ASSEMBLY FUNCTION ( DOTP4CLASM) :
23
OUTPUT :
24
2.(E) : FACTORIAL USING C CALLING A LINEAR ASSEMBLY
FUNCTION ( FACTCLASM ).
25
OUTPUT :
26
RESULT :
Thus the programming examples using C for assembly and linear assembly wasimplemented.
27
28
EXP NO : 03
IMPLEMENTATION OF MOVING AVERAGE
FILTER
DATE :
AIM :
To implement the moving average filter .
APPARATUS REQUIRED :
ALGORITHM :
1) Enter the number of cycles, period and amplitude for respective waves.
29
30
PROGRAM :
//average.c
31
OUTPUT :
32
RESULT :
33
34
EXP NO : 04 FIR IMPLEMENTATION WITH A
PSEUDORANDOM NOISE SEQUENCE AS INPUT
TO A FILTER.
DATE :
AIM :
To implement the FIR with a pseudorandom noise sequence as input to a filter .
APPARATUS REQUIRED :
ALGORITHM :
1) Enter the number of cycles, period and amplitude for respective waves.
35
36
PROGRAM :
DSK_FIR67.M
% MATLAB function to write FIR filter coefficients
% in format suitable for use in C6713 DSK programs
% firnc.c and firprn.c
% written by Donald Reay
%
function dsk_fir67(coeff)
%
coefflen=length(coeff);
fname = input('enter filename for coefficients ','s');
fid = fopen(fname,'wt');
fprintf(fid,'// %s\n',fname);
fprintf(fid,'// this file was generated automatically using
function
dsk_fir67.m\n',fname);
fprintf(fid,'\n#define N %d\n',coefflen);
fprintf(fid,'\nfloat h[N] = { \n');
% j is used to count coefficients written to current line
% in output file
j=0;
% i is used to count through coefficients
for i=1:coefflen
% if six coeffs have been written to current line
% then start new line
if j>5
j=0;
fprintf(fid,'\n');
end
% if this is the last coefficient then simply write
% its value to the current line
% else write coefficient value, followed by comma
if i==coefflen
fprintf(fid,'%2.4E',coeff(i));
else
fprintf(fid,'%2.4E,',coeff(i));
j=j+1;
end
end
fprintf(fid,'\n};\n');
fclose(fid);
37
OUTPUT :
38
//FIRPRN.C FIR WITH INTERNALLY GENERATED INPUT NOISE SEQUENCE
39
OUTPUT :
40
RESULT :
Thus the FIR with a pseudorandom noise sequence as input to a filter was implemented.
41
42
EXP NO : 05
FIXED POINT IMPLEMENTATION OF IIR
FILTER
DATE :
AIM :
To implement the fixed point implementation of IIR filter.
APPARATUS REQUIRED :
ALGORITHM :
1) Enter the number of cycles, period and amplitude for respective waves.
43
44
PROGRAM :
45
OUTPUT :
46
RESULT :
Thus the fixed point implementation of IIR filter was implemented.
47
48
EXP NO : 06
FFT OF REAL-TIME INPUT SIGNAL
DATE :
AIM :
To implement the FFT of real time signal.
APPARATUS REQUIRED :
ALGORITHM :
1) Enter the number of cycles, period and amplitude for respective waves.
49
50
PROGRAM :
//fft128c.c
#include "DSK6713_AIC23.h" //codec support
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#define DSK6713_AIC23_INPUT_MIC 0x0015
#define DSK6713_AIC23_INPUT_LINE 0x0011
Uint16 inputsource=DSK6713_AIC23_INPUT_LINE;
#include <math.h>
#include "fft.h"
#define PI 3.14159265358979
#define TRIGGER 32000
#define N 128
#include "hamm128.h"
short buffercount = 0; //no of samples in iobuffer
short bufferfull = 0; //indicates buffer full
COMPLEX A[N], B[N], C[N];
COMPLEX *input_ptr, *output_ptr, *process_ptr, *temp_ptr;
COMPLEX twiddle[N];
short outbuffer[N];
interrupt void c_int11(void) //ISR
{
output_left_sample((short)((output_ptr + buffercount)->real));
outbuffer[buffercount] =
-(short)((output_ptr + buffercount)->real);
(input_ptr + buffercount)->real =
(float)(input_left_sample());
(input_ptr + buffercount++)->imag = 0.0;
if (buffercount >= N)
{
buffercount = 0;
bufferfull = 1;
}
51
}
52
main()
{
int n;
for (n=0 ; n<N ; n++) //set up twiddle factors
{
twiddle[n].real = cos(PI*n/N);
twiddle[n].imag = -sin(PI*n/N);
}
input_ptr = A;
output_ptr = B;
process_ptr = C;
comm_intr(); //initialise DSK
while(1) //frame processing loop
{
while(bufferfull==0); //wait for new frame
bufferfull = 0; //of input samples
temp_ptr = process_ptr; //rotate frame pointers
process_ptr = input_ptr;
input_ptr = output_ptr;
output_ptr = temp_ptr;
fft(process_ptr,N,twiddle); //process contents of buffer
for (n=0 ; n<N ; n++) // compute magnitude
{ // and place in real part
(process_ptr+n)->real =
-sqrt((process_ptr+n)->real*(process_ptr+n)->real
+ (process_ptr+n)->imag*(process_ptr+n)->imag)/16.0;
}
(process_ptr)->real = TRIGGER; // add oscilloscope trigger
} //end of while(1)
}
53
OUTPUT :
54
RESULT :
Thus the FFT of real time signal was implemented.
55
56