Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
PN generator

Subject: PN generator

From: ahmad zaki

Date: 24 Jul, 2002 16:01:43

Message: 1 of 2

hi all, i want to know how do design a PN generator, and how to make
use from the XOR gates in building it, what is the specified function
that will i base in my design. could we design a PN generator with a
maximal length without using the XOR gates

Subject: PN generator

From: AJ \"no z\" Johnson

Date: 25 Jul, 2002 07:02:19

Message: 2 of 2

"ahmad zaki" <eeng_albanna@hotmail.com> wrote in message
news:eeb02f2.-1@WebX.raydaftYaTP...
> hi all, i want to know how do design a PN generator, and how to make
> use from the XOR gates in building it, what is the specified function
> that will i base in my design. could we design a PN generator with a
> maximal length without using the XOR gates

This is a function I had lying around, that uses a simple shift register
with feedback, which (AFAIK) is often used in hardware implementations
because it is simple: just XOR various taps of a shift register and feed it
into the front. Like so many math thingys, someone has found a way to
characterize these devices with a polynomial, which predetermines the PN
sequence.

-Aj

function x=pngen(p);
% x=pnegn(p) - Generate pseudo-random sequence
% p = either a scaler (2..12) to generate a PN sequence
% using a predefined polynomial of length p, or
% a binary generating polynomial.
% x = sequence, of length 2^length(p) - 1.

% Predefined seqence polynomials:
pl{2} = [1 1];
pl{3} = [1 1 0];
pl{4} = [1 0 0 1];
pl{5} = [1 0 1 1 1];
pl{6} = [1 1 1 0 0 1];
pl{7} = [1 1 0 0 1 0 1];
pl{8} = [1 0 1 0 1 1 1 1];
pl{9} = [1 0 1 0 1 1 0 1 1];
pl{10} = [1 0 1 0 1 0 1 0 1 1];
pl{11} = [1 0 1 0 1 0 1 0 1 0 1];
pl{12} = [1 1 0 1 0 0 0 0 1 1 0 1];
if length(p) == 1
  p = pl{p};
end

L=length(p);
N=2^L-1;

s=ones(1,length(p));
x=zeros(1,N);
for i=1:N
  snew = mod(sum(and(p,s)),2);
  x(i) = snew;
  s=[s(2:end),snew];
end

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us