pnseq

12
ENEE 408F: Capstone Design: Communication System Design 1 Chapter 09: Pseudo-Random Binary Sequences and Data Scramblers Pseudo-Random Binary Sequences and Data Scramblers ENEE 408F: Capstone Design: Communication System Design 2 Goal To generate pseudo-random binary sequences that can be used for testing digital communication systems or scrambling input data. Overview 1. Review/Introduce linear feedback shift registers 2. PN sequence generation 3. Self synchronizing data scramblers 4. Lab exercises Pseudo-Random Binary Sequences and Data Scramblers

Upload: rajivtr

Post on 04-Dec-2015

212 views

Category:

Documents


0 download

DESCRIPTION

PN SEQUENCE...

TRANSCRIPT

Page 1: pnseq

ENEE 408F: Capstone Design: Communication System Design 1'

&

$

%

Chapter 09:Pseudo-Random Binary Sequences

and Data Scramblers

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 2'

&

$

%

Goal

To generate pseudo-random binary sequences that can be used fortesting digital communication systems or scrambling input data.

Overview

1. Review/Introduce linear feedback shift registers

2. PN sequence generation

3. Self synchronizing data scramblers

4. Lab exercises

Pseudo-Random Binary Sequences and Data Scramblers

Page 2: pnseq

ENEE 408F: Capstone Design: Communication System Design 3'

&

$

%

Ideal Binary Random Sequences

An ideal binary random sequence is an i.i.d. sequence of equallylikely 1’s and 0’s.

• 0 and 1 are equally likely:

Pr {x(n) = 1} = Pr {x(n) = 0} = 0.5

• The bits are independent, i.e., for n 6= m

Pr ({x(n) = i} ∩ {x(m) = j}) = Pr {x(n) = i}Pr {x(m) = j}

• Therefore they are uncorrelated, i.e., for n 6= m

cov {x(n), x(m)} = 0

Often used as models for data streams generated by binary sources.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 4'

&

$

%

Linear Feedback Shift Registers

A linear feedback shift register (LFSR) is a delay line which feedsback a logical combination of its stages to the input.

D D D

⊕ ⊕⊕

⊕x(n)�

y(n)�

y(n-1)� y(n-2)� y(n-m)�

h1 h2 hm-1 hm

y(n) = x(n) +m∑k=1

hky(n− k)

x(n) = 0 =⇒ Generate PN sequences

x(n) 6= 0 =⇒ Randomize data stream

Pseudo-Random Binary Sequences and Data Scramblers

Page 3: pnseq

ENEE 408F: Capstone Design: Communication System Design 5'

&

$

%

Similar to linear filtering, but

• Constants and variables can only take on the values 0 or 1.

hk ∈ {0, 1} x(n) ∈ {0, 1} y(n) ∈ {0, 1}

• Additions are performed “modulo 2” (exclusive-or).

0 + 0 = 0 0 + 1 = 1

1 + 1 = 0 1 + 0 = 1

• The state vector is defined as

s(n) = [y(n− 1), y(n− 2), . . . , y(n−m)]

= [s1(n), . . . , sm(n)]

• Note: {0, 1} form the field GF(2) under mod 2 add and mult.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 6'

&

$

%

The Huffman Transform

• Binary sequences and linear sequential circuits can be analyzedusing the Huffman transform.

• The Huffman transform of a binary sequence, x(n), is

X(D) =∞∑n=0

x(n)Dn

• Same basic properties as Z-transform, but arithmetic ismodulo-2.

Pseudo-Random Binary Sequences and Data Scramblers

Page 4: pnseq

ENEE 408F: Capstone Design: Communication System Design 7'

&

$

%

The Connection Polynomial

• The output transform with zero initial state is given by

y(n) +m∑k=1

hky(n− k) = x(n)

...

Y (D)

[1 +

m∑k=1

hkDk

]= X(D)

• Defining the connection polynomial as

h(D) = 1 +m∑k=1

hkDk

we have Y (D)h(D) = X(D) or Y (D) = X(D)/h(D)

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 8'

&

$

%

Generating PN Sequences Using LFSRs

If the input is zero for all time, x(n) = 0 ∀ n,

D D D

⊕ ⊕⊕

y(n-1)� y(n-2)� y(n-m)�

h1 h2 hm-1 hm

y(n)�

the shift register output satisfies the homogeneous equation

y(n) +m∑k=1

hky(n− k) = 0

Pseudo-Random Binary Sequences and Data Scramblers

Page 5: pnseq

ENEE 408F: Capstone Design: Communication System Design 9'

&

$

%

The Trivial Solution

If the initial state is zero, s(0) = 0, then all outputs must be zero,

s(0) = 0 =⇒ y(n) = 0 ∀ n

Non-Trivial Solutions

• Any non-zero initial state results in a non-trivial solution whichnever becomes identically zero.

• The state vector has at most N = 2m − 1 non-zero values, so itmust repeat at some time. Then y(n) and s(n) will also repeat.

• So the shift register will generate a periodic output sequencewith a period at most 2m − 1. Sequences with period equal to2m − 1 are called maximal length sequences.

• Properties of the non-trivial solutions are determined by h(D).

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 10'

&

$

%

Sequence Period For Irreducible h(D)

• A polynomial with binary coefficients is said to be irreducibleover the field of binary numbers, if it cannot be factored intothe product of polynomials with binary coefficients.

• Irreducible polynomials over GF(2) must have an odd numberof 1 coefficients. Otherwise, h(1) = 0 and D + 1 is a factor.

For example consider

h(D) = D3 + 1

Since h(1) = 1 + 1 = 0 we know D + 1 must be a factor of h(D)

h(D) = D3 + 1 = (D + 1)(D2 +D + 1

)

Pseudo-Random Binary Sequences and Data Scramblers

Page 6: pnseq

ENEE 408F: Capstone Design: Communication System Design 11'

&

$

%

• The sequence period for an irreducible connection polynomialof degree m,

h(D) = 1 +m∑k=1

hkDk,

is the smallest int L 6= 0 such that DL − 1 is divisible by h(D)

DL − 1 = h(D)g(D)

using modulo 2 arithmetic for the coefficients.

• We call L the exponent of h(D).

• It can be shown that h(D) must always divide D2m−1 − 1, soL ≤ N = 2m − 1.

• h(D) is a primitive polynomial when L = N = 2m − 1.

• Primitive polynomials of all degrees exist.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 12'

&

$

%

Example

Consider the connection polynomial h(D) = D3 +D + 1.

• h(1) = h(0) = 1, so D + 1 and D are not factors

• h(D) cannot be the product of a 1st and 2nd degree factorbecause it has no 1st degree factors

Therefore, h(D) is irreducible.

The feedback shift register is given by

D D D

y(n-1)� y(n-2)� y(n-3)�y(n)�

y(n) = y(n− 1) + y(n− 3) mod 2

Pseudo-Random Binary Sequences and Data Scramblers

Page 7: pnseq

ENEE 408F: Capstone Design: Communication System Design 13'

&

$

%

Consider an initial state of s = [1 0 0].

y(n) = y(n− 1) + y(n− 3)

Output Current Staten y(n) y(n− 1) y(n− 2) y(n− 3)0 1 1 0 01 1 1 1 02 0 1 1 13 1 0 1 14 0 1 0 15 0 0 1 06 1 0 0 17 1 1 0 0

The state repeats with period 7, but N = 23 − 1 = 7. Hence, h(D)is primitive.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 14'

&

$

%

Properties of PN Sequences

1. Frequency of 1’s and 0’sEach period contains 2m−1 ones and 2m−1 − 1 zeros.

2. Frequency of Runs of 1’s and 0’s: A run of k ones is astring starting with a zero, followed by k ones, and ending witha zero. Runs of zeros are defined similarly.

One period of a maximal length sequence contains:

• One run of m ones• No run of m− 1 ones• 2m−k−2 runs of k ones for 1 ≤ k ≤ m− 2.• No run of m zeros• One run of m− 1 zeros• 2m−k−2 runs of k zeros for 1 ≤ k ≤ m− 2.

Pseudo-Random Binary Sequences and Data Scramblers

Page 8: pnseq

ENEE 408F: Capstone Design: Communication System Design 15'

&

$

%

3. Autocorrelation FunctionTo evaluate correlation properties, it is more convenient to dealwith ±1 instead of 0 and 1. Therefore, let y(n) be a binarysequence with period N , and define

y(n) = [−1]y(n) =

{+1 if y(n) = 0−1 if y(n) = 1

The periodic autocorrelation function is

R(n) =1N

N−1∑k=0

y(k)y(n+ k)

where the sum is performed using ordinary addition.

For maximal length sequences with period N = 2m − 1,

R(n) =

{− 1N for n not a multiple of N

1 for n a multiple of N

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 16'

&

$

%

Sequence Period For Reducible h(D)

The situation is more complicated when the connection polynomialis reducible (i.e. it can be factored). Suppose

h(D) =L∏k=1

fk(D)

where each factor is irreducible and has exponent Nk.

• In this case, the shift register will generate sequences withdifferent periods depending on its initial state.

• Each period will be the product of a subset of the exponents.

Pseudo-Random Binary Sequences and Data Scramblers

Page 9: pnseq

ENEE 408F: Capstone Design: Communication System Design 17'

&

$

%

Self Synchronizing Data Scramblers

• Digital receivers have various levels of synchronization toestimate the carrier phase, symbol timing, frame location, etc.

• Long strings of 1’s and 0’s cause these algorithms to fail.

• Long strings of 1’s and 0’s must be randomized before beingapplied to the transmitter

• We can scramble the bits by passing the sequence through alinear feedback shift register. This is an example of a selfsynchronizing scrambler with input x(n) and output y(n)

• A primitive connection polynomial is typically used.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 18'

&

$

%

The Scrambler

D D D

⊕ ⊕⊕

⊕x(n)�

y(n)�

y(n-1)� y(n-2)� y(n-m)�

h1 h2 hm-1 hm

Recall that the input/output relation is given by

y(n) = x(n) +m∑k=1

hky(n− k)

Y (D) =X(D)h(D)

Pseudo-Random Binary Sequences and Data Scramblers

Page 10: pnseq

ENEE 408F: Capstone Design: Communication System Design 19'

&

$

%

The Descrambler

The descrambling equations are

x(n) = y(n) +m∑k=1

hky(n− k)

X(D) = Y (D)h(D)

which is an m+ 1 tap FIR filter that uses modulo 2 arithmetic.

D D D

⊕ ⊕⊕ x(n)�

y(n-1)� y(n-2)� y(n-m)�

h1 h2 hm-1 hm

y(n)�

Note: The initial states of the scrambler and descrambler do nothave to be identical if an initial burst of errors is acceptable.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 20'

&

$

%

Note that

• If y(n) is corrupted by channel errors, the scrambler outputwill also contain errors.

• If h(D) has K nonzero coefficients, a single isolated error iny(n) will cause K output errors as it propagates by the nonzerocoefficients.

Therefore, a connection polynomial with the least number ofnonzero coefficients should be chosen.

Pseudo-Random Binary Sequences and Data Scramblers

Page 11: pnseq

ENEE 408F: Capstone Design: Communication System Design 21'

&

$

%

Exercises for a Primitive Connection Polynomial

Perform the following exercises for h(D) = 1 +D2 +D5

1. Let x(n) = 0 ∀ n with a nonzero initial state. Calculate thetheoretical period N of the shift register output sequence.

2. Write a C program to implement the scrambler including aninput x(n) which is set to 0.

• Store the shift register state as 5 consecutive bits in a singleinteger variable.

• To update the state, OR each new output with theappropriate bit in this integer, then use the C shift operator.

3. Set the state of your shift reg to a nonzero value. Generate andrecord enough outputs to verify your calculation of the period.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 22'

&

$

%

4. Count the number of 1’s and 0’s in one period of your sequenceand check that the results agree with the theory.

5. Count the number of runs of 1’s and 0’s of each possible lengthin one period of your sequence and make a table showing theresults. Make sure they agree with the theoretical values.

6. Compute the scaled periodic autocorrelation function NR(n)for n = 0, 1, . . . , N − 1 from your sequence and check that itagrees with the theoretical result.

7. Write a C program to implement the descrambler.

• Store the descrambler shift register as 5 consecutive bitsin a single C integer variable.

• Let the input be x(n) = 1. Generate a scrambled sequence,put it through the descrambler, and check that thedescrambler output is all 1’s.

Pseudo-Random Binary Sequences and Data Scramblers

Page 12: pnseq

ENEE 408F: Capstone Design: Communication System Design 23'

&

$

%

Exercises for an Irreducible Non-Primitive h(D)

Let h(D) = 1 +D +D2 +D3 +D4. This h(D) is irreducible butnot primitive.

1. Find the period N for this sequence generator.

2. The four stage shift reg can have 24 − 1 = 15 nonzero values.

3. Let y(n) be the sequence generated by a particular nonzeroinitial state. Consider y(n) and the sequences obtained bydelaying y(n) by 1, 2, . . . , N − 1 samples to be an equivalenceclass of N sequences. It can be shown that each member of theequivalence class corresponds to a unique shift register initialstate. Thus, there must be (24 − 1)/N equivalence classes.

4. Find one member of each equivalence class and itscorresponding initial shift register state.

Pseudo-Random Binary Sequences and Data Scramblers

ENEE 408F: Capstone Design: Communication System Design 24'

&

$

%

Exercises for a Reducible h(D)

h(D) = (1 +D +D2)(1 +D +D3) = 1 +D4 +D5

1. Verify that the product is correct.

2. Both factors are irreducible. Find the exponents for the factors.

3. Find initial states that result in sequences with periods 3, 7,and 21. Record the states and corresponding sequences.

Pseudo-Random Binary Sequences and Data Scramblers