The document describes a Matlab program to generate pseudo-random noise (PN) sequences using flip-flops. The program takes the number of flip-flops as input and generates the sequence. It displays the output of the flip-flops at each clock cycle and the resulting PN sequence, which repeats with a period determined by the number of flip-flops. Examples are provided for generating PN sequences using 3 and 4 flip-flops.
The document describes a Matlab program to generate pseudo-random noise (PN) sequences using flip-flops. The program takes the number of flip-flops as input and generates the sequence. It displays the output of the flip-flops at each clock cycle and the resulting PN sequence, which repeats with a period determined by the number of flip-flops. Examples are provided for generating PN sequences using 3 and 4 flip-flops.
The document describes a Matlab program to generate pseudo-random noise (PN) sequences using flip-flops. The program takes the number of flip-flops as input and generates the sequence. It displays the output of the flip-flops at each clock cycle and the resulting PN sequence, which repeats with a period determined by the number of flip-flops. Examples are provided for generating PN sequences using 3 and 4 flip-flops.
PROGRAM: clc; clear all; close all; m=input ('Enter the number of flip-flops used to generate PN sequence = ');
% statement to calculate period of sequence n=2^m-1; disp ('Enter initial state of flip-flops');
% enter elements m times in 1st row of array i.e. enter initial state of all m flip-flops for i=1:1:m a(1,i)=input ('Enter either 0 or 1: '); end
%logic to add o/p of 1st flip-flops and last flip-flops at i th
clock to get i/p to first flip flop at (i+1) th clock for i=1:1:n-1 a(i+1,1)=xor(a(i,1),a(i,m)); for j=1:1:m-1 a(i+1,j+1)=a(i,j) ; end end
% to display value of all flip-flops at initial state and at each clock disp ('Output of flip flops at each clock will be as:-'); disp(a); Lakshmanan. M & Noor Mohammed. V, Assistant Professor (Senior) VIT University, Vellore % to display the PN sequence for i=1:1:n b(i)=a(i,m); end
% to display the o/p PN sequence values for one period only disp ('Output PN sequence will be:-'); disp(b); disp ('and this sequence will repeat with period of'); disp(n)
% to display the o/p PN sequence values for one period only stem(b); xlabel('time'); ylabel('Amplitude of PN sequence'); title('PN sequence generation for 3 flip-flops');
Output for 3 flip-flops: Enter the number of flip-flops used to generate PN sequence = 3 Enter initial state of flip-flops Enter either 0 or 1: 1 Enter either 0 or 1: 0 Enter either 0 or 1: 0 Output of flip flops at each clock will be as:- 1 0 0 1 1 0 1 1 1 0 1 1 1 0 1 0 1 0 0 0 1 Output PN sequence will be:- 0 0 1 1 1 0 1 Lakshmanan. M & Noor Mohammed. V, Assistant Professor (Senior) VIT University, Vellore and this sequence will repeat with period of 7 Model Graph: 1 2 3 4 5 6 7 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 time A m p l i t u d e
o f
P N
s e q u e n c e PN sequence generation for 3 flip-flops
Output for 4 flip-flops: Enter the number of flip-flops used to generate PN sequence = 4 Enter initial state of flip-flops Enter either 0 or 1: 1 Enter either 0 or 1: 0 Enter either 0 or 1: 0 Enter either 0 or 1: 0 Output of flip flops at each clock will be as:- 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 Lakshmanan. M & Noor Mohammed. V, Assistant Professor (Senior) VIT University, Vellore 0 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 0 0 1 1 1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 Output PN sequence will be:- 0 0 0 1 1 1 1 0 1 0 1 1 0 0 1 and this sequence will repeat with period of 15 Model Graph: 0 5 10 15 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 time A m p l i t u d e
o f
P N
s e q u e n c e PN sequence generation for 3 flip-flops
RESULT: The PN Sequence is generated using Matlab.