Professional Documents
Culture Documents
SEMESTER – I
MANUAL
PREPARED BY
M.SOMASEKAR. M.E.,
LIST OF EXPERIMENTS
1. Simulation of Modulation and Coding in a AWGN Communication Channel using Simulation Packages.
2. Implementation of Adaptive Filters, periodogram and multistage multirate system in DSP Processor
5. Implementation and study of Stop and Wait, Goback-N and Selective Repeat ARQ protocols
PAGE
S.NO DATE EXPERIMANT TITLE
NO
PERIODOGRAM
2(a) 23
DATE
AIM:
To generate amplitude modulated, double side band and single side band suppressed carrier using
MAT LAB Program.
EQUIPMENT REQUIRED:
1. AMPLITUDE MODULATION
FORMULA
Vm(t) = Vm Sin ωmt
Vc(t) = Vc Sin ωct
Ma – modulation index
ALGORITHM:
FORMULA:
ALGORITHM:
ALGORITHM:
fm=100;
fc=3000;
t=0:0.01:50;
am=0.9;
ac=1;
mi=am/ac;
mt=am*sin(2*3.14*fm*t);
subplot(3,1,1);
plot (t,mt);
ct=ac*sin(2*3.14*fc*t);
subplot(3,1,2);
plot (t,ct);
lsb=cos((2*3.14*fc*t)-(2*3.14*fm*t));
msb=cos((2*3.14*fc*t)+(2*3.14*fm*t));
st=((am*ac)/2)*(lsb-msb);
subplot(3,1,3);
plot (t,st);
RESULT:
Thus the amplitude modulated , double side band and single side band suppressed carrier
signal are generated using MAT LAB Program and the outputs are verified
DATE
AIM:
To generate amplitude shift keying, frequency shift keying and phase shit keying using
MATLAB program
.
EQUIPMENT REQUIRED:
ALGORITHM:
• Read the two different amplitude values for high and low inputs
• Generate the output waveform for high and low inputs and plot them in time domain
• Read the two different Frequencies for high and low inputs
• Generate the output waveform for high and low inputs and plot them in time domain
• Generate the output signal with inphase and outphase components according to high
and low inputs
E1=5;
E2=3;
f=3000;
t1=1:1:50;
t=100;
res1=sqrt(2*E1/t)*(cos((2*3.14*f*t1)+90));
t2=51:1:100;
res2=sqrt(2*E2/t)*(cos((2*3.14*f*t2)+90));
t=1:1:100;
result(1:50)=res1(1:50);
result(51:100)=res2(1:50);
figure(1);
plot(t,result);
xlabel('time ---->');
ylabel('amplitude ---->');
grid on;
E=15;
t1=1:1:50;
f1=100;
T=50;
res1=(sqrt(2*E/T))*(cos(2*3.14*f1*t1));
t2=51:1:100;
f2=250;
res2=(sqrt(2*E/T))*(cos(2*3.14*f2*t2));
t=1:1:100;
res(1:50)=res1(1:50);
res(51:100)=res2(1:50);
plot(t,res);
xlabel('time ---->');
ylabel('amplitude ---->');
E=10;
f1=1:1:50;
f=3000;
T=100;
i=1;
m=2;
res1=(sqrt(2*E/T))*(cos((2*3.14*f*t1)+(2*180*i/m)));
t2=51:1:100;
i=2;
res2=(sqrt(2*E/T))*(cos((2*3.14*f*t2)+(2*180*i/m)));
t=1:1:100;
result(1:50)=res1(1:50);
result(51:100)=res2(1:50);
figure(1);
plot(t,result);
xlabel('time---->');
ylabel('amplitude---->');
RESULT:
Thus the amplitude shift keying ,frequency shift keying and phase shit keying are generated
using MATLAB program and the outputs are verified
DATE
AIM:
.
EQUIPMENT REQUIRED:
• Rs 232 cable
ALGORITHM:
• Assign location for input data count normal sequence order etc.
LDP #100H
CALL FFT
LAR AR0,#8030H
LAR AR1,#PERIO
LACC 0H
SUB #1H
SACL 75H
LAR AR2,75H
START ZAP
MAR *,AR0
LT *
MPY *+
PAC
BSAR 0CH
SACL 65H
LT *
MPY *+,AR1
PAC
BSAR 0CH
ADD 65H
BSAR 4
AND #0FFFH
CALL 0B400H
MAR *,AR1
SACH *+,AR2
BANZ START,*-
H B H
FFT
LDP #100H
LACC N
CALL 0B000H
LAR AR0,#BIT_REV
LAR AR5,#INPLACE
CALL 0B100H
SPLK #3H,STG
SPLK #1H,BFLY
SPLK #2H,DNS
SPLK #2H,0FH
ZAP
LT 0FH
MPY N
SPL 2H
LT 2H
MPY STG
SPL 2H
LAR AR1,#TWIDLE
MAR *,AR1
RPT 2H
BLPD #TABLE,*+
LAR AR1,#TWIDLE
LACC STG
SUB #1H
SACL STGC
LACC 00
SACL GRP
LAR AR7,STGC
STGLOP LACC GRP
BSAR 1H
SACL GRP
SUB #1H
SACL GRPC
LAR AR6,GRPC
LACC BFLY
SUB #1H
SACL BFLYC
LACC DNS
SUB #1H
SACL DNSC
LAR AR0,#INPLACE
GRPLOP LAR AR2,BFLYC
BFLYLOP CALL 0B200H
MAR *,AR0
RPT DNSC
LACC *+
CALL 0B200H
MAR *,AR0
RPT DNSC
LACC *-
CALL 0B300H
MAR *,AR0
RPT DNSC
LACC *-
MAR *,AR2
BANZ BFLYLOP,*-
MAR *,AR0
RPT DNSC
LACC *+
MAR *,AR6
BANZ GRPLOP,*-
LT BFLY
MPY #2H
SPL BFLY
LT DNS
MPY #2H
SPL DNS
MAR *,AR7
BANZ STGLOP,*-
RET
TABLE
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00000H
.word 0FF00H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00000H
.word 0FF00H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 00100H
.word 00000H
.word 000B5H
.word 0FF4BH
.word 00100H
.word 00000H
.word 00000H
.word 0FF00H
.word 00100H
.word 00000H
.word 0FF4BH
.word 0FF4BH
.END
INPUT / OUTPUT
Location:
N: 8000 = A
RESULT:
DATE
AIM:
APPARATUS REQUIRED:
ALGORITHM:
Decimation:
• The output of the fir filter is sent out of the DAC once every 4 outputs
• Next data is loaded in DAC after convolution and send out after next 4 sample
Interpolation:
• Get the samples of the input frequency signal at 35 KHZ at lower sampling rate
• Move the filter co efficient from program memory location to data memory location
X(n) y(n)
W(n)
L LPF
Fs LFs LFs
SATRT
L-1
ZEROS
NO
YES
PROGRAM DESCRIPTION:
In this program the sampling rate is increased at the input by including zeros. The samples are
taken at the lower sampling rate and since this program uses the interpolation factor of 4, three zeros
are included after each sample taken from the ADC. So the number of samples and thus the sampling
rate is also increased.
.word 0FDB6H
.word 0FAEEH
.word 0FA92H
.word 0FC20H
.word 0FEADH
.word 0132H
.word 02DDH
.word 0342H
.word 0271H
.word 0DEH
.word 0FF31H
.word 0FE01H
.word 0FDACH
.word 0FE38H
.word 0FF5BH
.word 09DH
.word 0188H
.word 01CFH
.word 0167H
.word 083H
.word 0FF82H
*
* Move the Filter coefficients
* from program memory to data memory
*
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
*
* Input data and perform convolution
*
LAR AR0,#4H
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
MAR *,AR0
BANZ INC0,*-
IN 0,06H
; LAR AR7,#0 ;change value to modify sampling freq.
; MAR *,AR7
;BACK: BANZ BACK,*-
RPT #10H
IN 0,4
LAR AR0,#4H
B STORE
INC0: SPLK #0H,0H
RPT #15H
NOP
STORE: NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SFR ;remove if o/p is less amplitude
SACL *
OUT *,4
LACC #0FFFH
SACL 0
OUT 0,05
NOP
B ISR
.end
Fs Fs Fs/M
START
M
SAMPLING
OBTAINED
COMPUTE OUTPUT
SAMPLES Y(M)
PROGRAM DESCRIPTION:
In this program the sampling rate at the input is 35 KHz. This input sampling rate is reduced by
a factor of 4 at the output. For this, the auxiliary register AR0 is loaded with the value of 4 initially.
Then the output of the FIR filter is sent out to the DAC only once out of 4 outputs. i.e. when ever the
register AR0 becomes 0, the filter output is sent to the DAC and reloaded with 4. Where 4 is the
decimation factor of this decimator
Approximation type: Window design - Rectangular Window
Filter type: Low pass filter
Filter Order: 52
.word 0FAEEH
.word 0FA92H
.word 0FC20H
.word 0FEADH
.word 0132H
.word 02DDH
.word 0342H
.word 0271H
.word 0DEH
.word 0FF31H
.word 0FE01H
.word 0FDACH
.word 0FE38H
.word 0FF5BH
.word 09DH
.word 0188H
.word 01CFH
.word 0167H
.word 083H
.word 0FF82H
*
* Move the Filter coefficients
* from program memory to data memory
*
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
*
* Input data and perform convolution
*
LAR AR0,#4H
ISR:
LDP #0AH
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
IN 0,06H
LAR AR7,#0 ;change value to modify sampling freq.
MAR *,AR7
BACK: BANZ BACK,*-
IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SFR ;remove if o/p is less amplitude
SACL *
MAR *,AR0
BANZ NO_OUT,*-
MAR *,AR1
OUT *,4
LAR AR0,#4H
NO_OUT:
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end
Result:
Thus the incoming sine wave with frequency 35 KHZ is decimated and interpolated by the factor 4
DATE
AIM:
EQUIPMENT REQUIRED:
• MATLAB 2007 R
• SIMULINK
THEORY:
The basic building block in applications of quadrature mirror filters (QMF) is the two
channel QMF bank. This is the multirate digital filter structure that employs two decimators in the
signal analysis section and two interpolators in the signal synthesis section and the low pass and high
pass filters in the analysis section have impulse response h 0 (0) and h 1 (n) respectively. Similarlylow
pass and high pass filters contained in the synthesis section have impulse response g 0 (n) and g 1 (n)
respectively.
The scale factor 2 corresponse to the interpolation factor used to normalize the
overall frequency response of the QMF. With this choice of the filter characteristics, the component
due to aliasing vanishes.
Thus the aliasing resulting from decimation in the analysis section of QMF bank is
perfectly cancelled by the image signal spectrum that arises due to interpolation. As a result, two
channels QMF behaves as a linear time invariant system.
CHARACTERSTICS OF QMF:
RESULT :
Thus by using the abover theory the QMF has been simulated using MATLAB filters
packages
AIM:
To Implement and to study stop and wait, goback-nand selective repeat arq protocol using lan
trainer implementation software.
EQUIPMENT REQUIRED:
THEORY:
GOBACK-N:
It is a more efficient use of a connection than Stop-and-wait ARQ, since unlike waiting for an
acknowledgement for each packet, the connection is still being utilized as packets are being sent.
In other words, during the time that would otherwise be spent waiting, more packets are being
sent. However, this method also results in sending frames multiple times – if any frame was lost
or damaged, or the ACK acknowledging them was lost or damaged, then that frame and all
following frames in the window (even if they were received without error) will be re-sent.
GOBACK-N:
The receiver process keeps track of the sequence number of the earliest frame it has not
received, and sends that number with every acknowledgement (ACK) it sends. If a frame from the
sender does not reach the receiver, the sender continues to send subsequent frames until it has
emptied its window. The receiver continues to fill its receiving window with the subsequent frames,
replying each time with an ACK containing the sequence number of the earliest missing frame. Once
the sender has sent all the frames in its window, it re-sends the frame number given by the ACKs, and
then continues where it left off.
PROCEDURE:
Click send at the server and then click recive at the client
RESULT:
Thus by using the above procedure the stop and wait, goback-nand selective repeat arq
protocol has been Implemented using lan trainer and its working has been studied.
AIM:
To Implement Distance vector routing and link state routing algorithms using netsim
simulation software.
EQUIPMENT REQUIRED:
4. Netsim dongle
THEORY:
DISTANCE VECTOR:
Routers using distance vector protocol do not have knowledge of the entire path to a destination.
Instead DV uses two methods:
It is one of the two main classes of routing protocols used in packet switching networks for
computer communications, the other major class being the distance-vector routing protocol.
Examples of link-state routing protocols include OSPF and IS-IS.The link-state protocol is performed
by every switching node in the network (i.e. nodes that are prepared to forward packets; in the
Internet, these are called routers). The basic concept of link-state routing is that every node constructs
a map of the connectivity to the network, in the form of a graph, showing which nodes are connected
to which other nodes. Each node then independently calculates the next best logical path from it to
every possible destination in the network. The collection of best paths will then form the node's
routing table.This contrasts with distance-vector routing protocols, which works by having each node
share its routing table with its neighbors. In a link-state protocol the only information passed between
nodes is connectivity related
• Set the distance between the each node for Distance vector routing
• Get the total number of nodes and the link between the nodes
• Before updating of the routing table, get the nodes and hop count details and display it
• After getting complete information about the network (i.e) after updation of routing
display the nodes and hop count details
//ospf.c
#include<stdio.h>
struct route
{
int n[10];
int h[10];
}
rt[10];
int main()
{
int k,i,j,n,s,d,c=0,ma[10][10];
printf(“\n enter the no.of nodes:”);
scanf(“%d”,&n);
printf(“\n enter the links for the nodes:\n”);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
scanf(“%d”,&ma[i][j]);
rt[i].n[j]=j:
rt[i].h[j]=ma[i][j];
}
printf(“\n enter the source node:”);
scanf(“%d”,&s);
printf(“\n enter the destination node:”);
scanf(“%d”,&d);
printf(“routhing table of source node before updation\n”);
printf(“node\tHopcount\n”);
for(j=1;j<=n:j++)
printf(“%d\t%d\n”,j,rt[s].h[j]);
for(i=1;i<=n;i++)
{
if((rt[s].n[i]==d)&&(rt[s].h[i]==1))
break:
if(rt[s].h[i]==1)
{
k=1;
for(j-1;j<=n;j++)
f((rt[i].n[j]==d)&&(rt[i].h[j]==1))
{
c++;
printf("\n path:%d\t%d\t%d",s,i,d);
if(c==1)
k=k+1;
OUTOUT:
RESULT:
Thus by using the above procedure the Distance vector routing and link state routing
algorithms has been Implemented using netsim simulation software and its working has been
studied
DATE
AIM:
To implement a cyclic code generator and syndrome calculator and to verify the same for the given
polynomial
EQUIPMENT REQUIRED:
• IC 7495
• IC 7486
• Trainer kit
• Connectivity wires
THEORY:
Cyclic code:
Cyclic code from a subclass of linear block codes an advantage of cyclic code over most other
types of codes is that are easy to encode further more cyclic codes posses a well defined mathematical
structure, which has led to the development of very efficient decoding schemes A binary code is said
to be a cyclic code if it exhibits two fundamental properties
1.linear property:
The sum of two code words is also a code word
2.cyclic property:
Any cyclic shift of a code word is also a code word
The gate is switched on hence the M message bits are shifted into channel as soon as the K
message bits have entered the shift register, the resulting (n-k) bits in the register from the parity bits
The gate is switched OFF there by berating the feedback connection the contents of the shift
register are shifted out into the channel the polynomial for the message (1001) is given by g(t).the
contents of the shift register are modified by the incoming message bits as in tables, after A shifts the
parity bits are (011), according appending these parity bits to the message bits (1001),we get the code
word(0111001)
SYNDROME CALCULATOR:
Suppose if the code word (X0,X1,X2,X3………Xn) is transmitted over the noisy channel and
received word (Y0,Y1.Y2,Y3……..Yn) the syndrome is calculated for error, if syndrome contain
zero there is an error and if non zero is present it contains error.
In case of cyclic code, the received word be represented by polynomial of degree (n-1) as
Yn=a(n).g(n) + s(d)S.T
The remainder S(n) is syndrome polynomial of degree n-k-1 or less. Its co-efficients are
making up the (n-k) by -1 syndrome S once we know S, we can determine the corresponding error
pattern and there by mate the approximate correction.
The cyclic code generation includes the following steps:
1. Multiplication of the message polynomial D(x) by X(n-k).
2. Division of X(n-k) by D(x) by the generator polynomial G(x) to obtain the remainder.
3. Addition of the remainder to X(n-k) D(x) to form the desired code polynomial.
PROCEDURE:
Code generator:
• Connect the circuit as shown in the figure
• Give the message bits and note down the outputs across flipflop P0,P1,P2
• As the last message bits is given as the input the required code to be transmitted is get across
the flipflop P0,P1,P2
• The transmitted message = message + code
Syndrome calculator:
• Connect the circuit as shown in the figure
• Give the code word as the input to one of the X – OR gate as shown in the figure starting from
LSB.note down the output across flipflop S0,S1,S2
• At the MSb if the required bit is correct we get zeros across S0,S1,S2 we get error according
to the bit corrupted which has to be checked in the table
CODE GENERATOR
Messge I/O P0 P1 P2
0 0 0 0
1 0 1 0
0 1 1 1
0 0 1 1
1 1 1 1
LSS1 1 0 0
0 0 1 0
0 0 0 1
1 0 1 0
1 1 0 1
1 0 0 0
MSB0 0 0 0
1st bit 2nd bit 3rd bit 4th bit 5th bit 6th bit 7th bit
Shift
0111000 0111010 0111101 0110001 1001001 0011001 1111001
ERROR PATTERN
The cyclic code was designed for generating word where message a = 1001 and parity bit
generating was 011. The circuit was executed and output table was verified.
The syndrome calculator circuit was designed first for the class where no error occurred and if
one bit error was occurring . both the output flipflop for these cases were verified and observation
were written.
DATE
AIM:
EQUIPMENT REQUIRED:
ALGORITHM
• Create the tokes for the string from the input file
• Based on the result, write the tokens on the output file using file concept
PROGRAM CODING:
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<string.h>
void main()
{
int i=0,j-0,z=0,f;
char ch,ch1,head[4][10]={"stdio.h","conio.h","math.h","printf"};
char temp[10];
FILE *Fp1,*Fp2;
clrscr();
Fp1 = Fopen("intxt.c","r");
Fp2 = Fopen("outtxt.c","w");
fscanf(Fp1,"%c",&ch);
while(!feof(Fp1))
{
f=0;
i=0;
while (is digit(ch))
for(z=0;z<=10;z++)
temp[z]=NULL;
while(is alpha(ch)||ch == '.')
{
temp [i]=ch;
fscanf(fp1,"%c",&ch);
i++;
}
i=0;
while(isdigit(ch))
{
temp[i]=ch;
fscanf(Fp1,"%c",&ch);
i++;
f=5;
}
i=0;
switch(ch)
{
case'#':case '<': case'>':case'{':
case'}':case'(':case')':case'%':
fprintf(Fp2,"\n%c\t\t special character",ch);
break;
}
for(j=0;j<3;j++)
if(strcmp(temp,head[j])==0)
{
case 5:
fprintf(Fp2,"\n%s\t digit \n\t",temp);
break;
fscanf(fp1,"%c",&ch)l;
if(feof(Fp1))
Fclose(Fp1);
}
}
INPUT FILE
#inclued<stdio.h>
void main()
{
int a,b,c;
a=10;
printf("%d",a);
}
OUTPUT FILE
# special character
< special character
include keyword
> special character
stdio.h header file
void keyword
( special character
main keyword
) special character
{ special character
int keyword
a identifier
b identifier
c identifier
10 digit
printf keyword
% special character
d identifier
) special character
a identifier
} special character
RESULT:
Thus the c program to implement the lexical analyzer has been executed and the output was verified
AIM:
EQUIPMENT REQUIRED:
ALGORITHM
• If buffer size within the limit then, get the details & store in buffer
PROGRAM CODING:
#define BUFFER_SIZE 20
#include<stdio.h>
typedef int semaphore;
semaphore full=0;
semaphore empty=BUFFER_SIZE;
typedef struct
{
int year;
int roll;
}
item;
item buffer[BUFFER_SIZE];
int counter=0;
int in=0;
int out=0;
main()
{
int choice;
int year1,roll1;
int i;
while(1)
{
printf("\n1.producer");
printf("\n2.consumer");
printf("\n3.display");
printf("\n4.exit");
printf("\enter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
if(((in+1)%BUFFER_SIZE)!==out)
{
printf("enter the year:");
scanf("%d",&year1);
printf("enter roll no:");
scanf("%d",&roll1);
wait(empty);
buffer[in].year=year1;
buffer[in].roll=roll1;
signal(full);
In=(in+1)%BUFFER_SIZE;
counter++;
}
break;
case 2:
if(in!=out)
{
wait(full);
printf("\n the name is %d",buffer[out].year);
printf("\n the roll no is %d",buffer[out].roll);
signal(empty);
out=(out+1)%BUFFER_SIZE;
counter --;
}
if(in<=out)
printf("\n buffer is empty ");
break;
case 3:
for(i=out;i<in;i++)
{
printf("\n the name is %d",buffer[i].year);
printf("\n the roll no is %d",buffer[i].roll);
}
if(in<=out)
printf("buffer is empty");
break;
case 4:
exit(0);
}
}
}
}
signal(int temp)
{
temp++;
}
wait(int temp1)
{
temp--;
}
INPUT/OUTPUT:
1.producer
2.consumer
3.display
4.exit
Enter your choice:1
Enter the year:1
Enter roll no:1
1.producer
2.consumer
3.display
4.exit
Enter your choice:1
Enter the year:2
Enter roll no:2
1.producer
2.consumer
3.display
4.exit
Enter your choice:3
The name is 1
The roll no is 1
The name is 2
The roll no is 2
1.producer
2.consumer
3.display
4.exit
Enter your choice:2
The name is 1
The roll no is 1
RESULT:
Thus the semaphore is implemented and the output is verified for the classical problem of
synchronization successfully