project lfsr

26
A 32-bit Linear Feedback Shift Register based Pseudo Random Number Generator Harsha Yelisala http://harshayelisala.info FALL 2008

Upload: harsha-yelisala

Post on 27-May-2015

4.417 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Project lfsr

A 32-bit Linear Feedback Shift Register basedPseudo Random Number Generator

Harsha Yelisala

http://harshayelisala.info

FALL 2008

Page 2: Project lfsr

Technology Profile

The following technologies are used in this project

I 1. 90 nm CMOS Technology.

I 2. MAGIC VLSI Layout Tool(http://opencircuitdesign.com/magic/)

I 3. HSpice Synopsys Circuit Simulator.

I 4. MATLAB

I 5. Java Programming Language.

Page 3: Project lfsr

Aim

The Objectives of this project are

I 1. To design a pseudo random number generation circuit in90nm Technology.

I 2. To get hands on expertise on working with layouts usingMAGIC tool.

I 3. To get experience in simulating digital circuits usingHSpice.

I 4. To understand the design rules in 90nm technology.

I 5. To work with MATLAB and Java Programming Language.

Page 4: Project lfsr

Introduction

AbstractA Pseudo Random Number Generator (PRNG) is a circuit capableof generating a large, repeating stream of pseudo random bits. Asthe technology grows faster and denser it can be more optimum toimplement the Random Number Generator in hardware. Thisproject deals with designing a 32 bit Pseudo Random NumberGenerator in 90 nm CMOS technology using the Linear FeedbackShift Register (LFSR). This work is implemented in MAGIC andsimulations are done using HSPICE. The results are verified usingMATLAB and Java programs.

Page 5: Project lfsr

Work Flow

I 1. Studying the literature regarding Random numbergenerators.

I 2. Finalizing the linear feed back shift register scheme forrandom number generation.

I 3. Layout drawing on 90nm Technology.

I 4. Writing JAVA code for test bench creation.

I 5. Verifying the results.

Page 6: Project lfsr

Random Numbers

Where are they used?

Random numbers are used in a variety of applications in digitalelectronics industry. A few applications include

I data encryption,

I counters,

I built-in self-test,

I pattern generators,

I compression and spectrum spreading.

Page 7: Project lfsr

Random Numbers

Types of Random Numbers

There are two primary types of Random numbers.

I True Random numbers.

I Pseudo Random numbers.

True Random NumbersTrue random numbers are the real random numbers. They aregenerated from microscopic phenomenon like thermal noise,photoelectric effect, or other quantum phenomena where thepattern is highly unpredictable.

Pseudo Random NumbersPseudo random numbers are a long periodic series of numberswhich seems random within the cycle. The original value (seedvalue) is repeated after a certain period.

Page 8: Project lfsr

Random Numbers

LFSR Scheme to produce Pseudo Random Numbers

Linear Feedback Shift Register is used in producing the randombits. In this the next bit to generate is the xor operation on thepresent and previous bit combinations. Though the next value canbe predictable, if this is used in multi bit random numbergeneration, the probability of finding the next value is very low.Unless the seed value is known it is hard to guess the next number.

Page 9: Project lfsr

LFSR based Random Number Generation

Single bit random number generator

It produces a value of 0 or 1. This is implemented using LFSRwhich is based on recurrence relation as described in equation (1).

xn = a1.xn−1 ⊕ a2.xn−2 ⊕ ....⊕ am.xn−m (1)

This implies that a new number is obtained by using m previousvalues through a sequence of AND-XOR operations.

Multi bit random number generator

When a series of shift registers are connected and the outputs aretapped from each flipflop, then it is forms as a LFSR based multibit random number generator.

Page 10: Project lfsr

LFSR based Random Number Generation

4-bit LFSR random number generator

A 4 bit LFSR can be obtained by tapping the outputs at all the fourflip flops in the circuit and using them as a 4 bit random number.

4-bit leap forward random number generator

It is same as a 4 bit LFSR generator but with 4 shift operations.

32-bit LFSR random number generator

A 32 bit LFSR can be obtained by tapping the outputs at all thefour flip flops in the circuit and using them as a 32 bit randomnumber.

32-bit Leap forward LFSR random number generator

It is same as a 32 bit LFSR generator but with 32 shift operations.

Page 11: Project lfsr

4-bit random number generator

Operating mechanism

I Let q3, q2, q1, q0 be theoutputs of the registers andq3 next , q2 next , q1 next ,q0 next be the next values.Then the equations can bewritten as:q0 next = q1q1 next = q2q2 next = q3q3 next = q3 ⊕ q0

I The seed value is initializedby the set pins of the D-flipflop.

I The outputs are tapped atthe Q pins and are read as asingle 4 bit random number.

Figure: 4-bit LFSR

Page 12: Project lfsr

LFSR based Random Number Generation

4-bit Leap forward random number generator

The LFSR is the easiest way of obtaining a random number. Butthe degree of randomness can be increased by using the concept ofleap forwarding. This can be achieved by increasing the shiftoperators equal to the number of the bits in the random numberinstead of shifting by 1 bit.

Page 13: Project lfsr

Leap Forward Mechanism

Transition MatrixThe equations for a 4-bit LFSR RNG are:q0 next = q1q1 next = q2q2 next = q3q3 next = q3 ⊕ q0These can be represented in matrix notation as:[ q0 nextq1 nextq2 nextq3 next

]=

[ q0q1q2q3

].

[0 1 0 00 0 1 00 0 0 11 0 0 1

]where A =

[0 1 0 00 0 1 00 0 0 11 0 0 1

]is known as Transition matrix.

Page 14: Project lfsr

Transition Matrix

Implication to Leap forwarding

I A unique property of the Transition matrix (A) is that thepower of the Transition matrix is equal to the number of shiftoperations in the circuit.

I This property helps in increasing the randomness of thegenerator, by increasing the shift operations by increasing thepower of the A matrix.

I For example, the A matrix of a 32-bit LFSR circuit, is to beraised by a power of 32 to obtain the new A matrix of the32-bit leap forward LFSR circuit. Thus a leap forward LFSRcircuit can be formed from just knowing the transition matrixof a LFSR circuit.

I Another assumption to be made is that all the non zero digitsin the A matrix are to be treated as 1.

Page 15: Project lfsr

4-bit Leap Forward random number generator

Operating mechanism

I The A matrix of a 4-bit LFSR is[0 1 0 00 0 1 00 0 0 11 0 0 1

]I The A’ matrix of a 4-bit

LF-LFSR is A4.i .e

[1 0 0 11 1 0 11 1 1 11 1 1 0

]I The equations to the new

circuit areq0 next = q0 ⊕ q3q1 next = q0 ⊕ q1 ⊕ q3q2 next = q0 ⊕ q1 ⊕ q2 ⊕ q3q3 next = q0 ⊕ q1 ⊕ q2 Figure: 4-bit Leap Forward LFSR

Page 16: Project lfsr

Comparision between LFSR and Leap Forward LFSR RNGs

For a 4-bit generator,

Table: Comparision between LFSR and Leap Forward LFSR

Single LFSR Leap-forward LFSR1000 (8) 1000 (8)0001 (1) 1111 (15)0011 (3) 0101 (5)0111 (7) 1001 (9)1111 (15) 0001 (1)1110 (14) 1110 (14)1101 (13) 1011 (11)1010 (10) 0010 (2)0101 (5) 0011 (3)1011 (11) 1101 (13)0110 (6) 0110 (6)1100 (12) 0100 (4)1001 (9) 0111 (7)0010 (2) 1010 (10)0100 (4) 1100 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

Block Diagram

Figure: Block diagram of Leap Forward LFSR Random Number Generator

Page 20: Project lfsr

32-bit Leap Forward random number generator

ROMThe ROM part of the circuit is used for storing the two fixed seedvalues. The seed values chosen are11111111111111111111111111111111 and10101010101010101010101010101010. The value of S pin chooseswhich seed value is to be loaded into the flip flops circuitry.

MUXThe MUX block of the circuit is used to load the seed value for acertain amount of time during the start of the operation and thento select the intermediate values from the XOR circuitry. The SELpin value changes accordingly.

XOR Circuitry

The XOR circuitry is responsible for the xor calculations from theprevious values of the flip flops.

Page 21: Project lfsr

32-bit Leap Forward random number generator

Just as the case of 4 bit leap forward circuit, the new transitionmatrix is obtained by rasing the old transition matrix by a power of32. This is done by the MATLAB program. Based on the newtransition matrix the new circuit is formed and is drawn as a layoutusing MAGIC using CMOS 90nm technology. The results aresimulated using HSPICE and are verified using a JAVA program.The circuit works fine for frequency of 33.33 Mhz with FO4 load.

Page 22: Project lfsr

Results

Figure: Layout of 32-bit Leap ForwardLFSR RNG

Figure: output of 32-bit Leap ForwardLFSR RNG

Page 23: Project lfsr

Results

Figure: Layout of D-FlipflopFigure: output of D-Flipflop

Page 24: Project lfsr

Results

Figure: Layout of 4-bit LFSR RNG

Figure: output of 4-bit LFSR RNG

Page 25: Project lfsr

Results

Figure: Layout of 4-bit Leap ForwardLFSR RNG

Figure: output of 4-bit Leap ForwardLFSR RNG

Page 26: Project lfsr

References

[1]. Design Techniques of FPGA based Random Number Generatorby Pong Chu and Robert Jones.[2]. Resources from New Wave Instruments and Xilinx[3]. www.newwave instruments.com/resources[4]. Digital Logic Design by Morris Mano[5]. P. Alf ke, Efficient Shift Registers, LFSR, Counters, and LongPseudo- Random Sequence Generators (XILINX)