Project lfsr
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • Can anybody post the verilog code for lfsr with clock gating for any bits...
    Are you sure you want to
    Your message goes here
  • fine
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
4,150
On Slideshare
4,133
From Embeds
17
Number of Embeds
2

Actions

Shares
Downloads
92
Comments
2
Likes
1

Embeds 17

http://harshayelisala.info 15
http://www.harshayelisala.info 2

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. A 32-bit Linear Feedback Shift Register based Pseudo Random Number Generator Harsha Yelisala http://harshayelisala.info FALL 2008
  • 2. Technology Profile The following technologies are used in this project 1. 90 nm CMOS Technology. 2. MAGIC VLSI Layout Tool (http://opencircuitdesign.com/magic/) 3. HSpice Synopsys Circuit Simulator. 4. MATLAB 5. Java Programming Language.
  • 3. Aim The Objectives of this project are 1. To design a pseudo random number generation circuit in 90nm Technology. 2. To get hands on expertise on working with layouts using MAGIC tool. 3. To get experience in simulating digital circuits using HSpice. 4. To understand the design rules in 90nm technology. 5. To work with MATLAB and Java Programming Language.
  • 4. Introduction Abstract A Pseudo Random Number Generator (PRNG) is a circuit capable of generating a large, repeating stream of pseudo random bits. As the technology grows faster and denser it can be more optimum to implement the Random Number Generator in hardware. This project deals with designing a 32 bit Pseudo Random Number Generator in 90 nm CMOS technology using the Linear Feedback Shift Register (LFSR). This work is implemented in MAGIC and simulations are done using HSPICE. The results are verified using MATLAB and Java programs.
  • 5. Work Flow 1. Studying the literature regarding Random number generators. 2. Finalizing the linear feed back shift register scheme for random number generation. 3. Layout drawing on 90nm Technology. 4. Writing JAVA code for test bench creation. 5. Verifying the results.
  • 6. Random Numbers Where are they used? Random numbers are used in a variety of applications in digital electronics industry. A few applications include data encryption, counters, built-in self-test, pattern generators, compression and spectrum spreading.
  • 7. Random Numbers Types of Random Numbers There are two primary types of Random numbers. True Random numbers. Pseudo Random numbers. True Random Numbers True random numbers are the real random numbers. They are generated from microscopic phenomenon like thermal noise, photoelectric effect, or other quantum phenomena where the pattern is highly unpredictable. Pseudo Random Numbers Pseudo random numbers are a long periodic series of numbers which seems random within the cycle. The original value (seed value) is repeated after a certain period.
  • 8. Random Numbers LFSR Scheme to produce Pseudo Random Numbers Linear Feedback Shift Register is used in producing the random bits. In this the next bit to generate is the xor operation on the present and previous bit combinations. Though the next value can be predictable, if this is used in multi bit random number generation, the probability of finding the next value is very low. Unless the seed value is known it is hard to guess the next number.
  • 9. LFSR based Random Number Generation Single bit random number generator It produces a value of 0 or 1. This is implemented using LFSR which 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 previous values through a sequence of AND-XOR operations. Multi bit random number generator When a series of shift registers are connected and the outputs are tapped from each flipflop, then it is forms as a LFSR based multi bit random number generator.
  • 10. 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 four flip 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 the four flip flops in the circuit and using them as a 32 bit random number. 32-bit Leap forward LFSR random number generator It is same as a 32 bit LFSR generator but with 32 shift operations.
  • 11. 4-bit random number generator Operating mechanism Let q3 , q2 , q1 , q0 be the outputs of the registers and q3 next , q2 next , q1 next , q0 next be the next values. Then the equations can be written as: q0 next = q1 q1 next = q2 q2 next = q3 q3 next = q3 ⊕ q0 The seed value is initialized by the set pins of the D- flipflop. The outputs are tapped at the Q pins and are read as a Figure: 4-bit LFSR single 4 bit random number.
  • 12. LFSR based Random Number Generation 4-bit Leap forward random number generator The LFSR is the easiest way of obtaining a random number. But the degree of randomness can be increased by using the concept of leap forwarding. This can be achieved by increasing the shift operators equal to the number of the bits in the random number instead of shifting by 1 bit.
  • 13. Leap Forward Mechanism Transition Matrix The equations for a 4-bit LFSR RNG are: q0 next = q1 q1 next = q2 q2 next = q3 q3 next = q3 ⊕ q0 These can be represented in matrix notation as: q0 next q0 0 1 0 0 q1 next q1 0 0 1 0 q2 next = q2 . 0 0 0 1 q3 next q3 1 0 0 1 01 0 0 where A = 00 1 0 is known as Transition matrix. 00 0 1 10 0 1
  • 14. Transition Matrix Implication to Leap forwarding A unique property of the Transition matrix (A) is that the power of the Transition matrix is equal to the number of shift operations in the circuit. This property helps in increasing the randomness of the generator, by increasing the shift operations by increasing the power of the A matrix. For example, the A matrix of a 32-bit LFSR circuit, is to be raised by a power of 32 to obtain the new A matrix of the 32-bit leap forward LFSR circuit. Thus a leap forward LFSR circuit can be formed from just knowing the transition matrix of a LFSR circuit. Another assumption to be made is that all the non zero digits in the A matrix are to be treated as 1.
  • 15. 4-bit Leap Forward random number generator Operating mechanism The A matrix of a 4-bit LFSR is 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 1 The A’ matrix of a 4-bit 1 0 0 1 LF-LFSR is A4 .i.e 1 1 1 1 0 1 1 1 1 1 1 0 The equations to the new circuit are q0 next = q0 ⊕ q3 q1 next = q0 ⊕ q1 ⊕ q3 q2 next = q0 ⊕ q1 ⊕ q2 ⊕ q3 q3 next = q0 ⊕ q1 ⊕ q2 Figure: 4-bit Leap Forward LFSR
  • 16. 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 LFSR 1000 (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 (12)
  • 17. 32-bit LFSR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0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 00000000000000000000000000000010 00000000000000000000000000000001 01000110000000000000000000000001
  • 18. 32-bit Leap Forward random number generator The A matrix of a 32-bit Leap Forward LFSR is 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 01100111000000000000000000000001 0 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 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1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 01111111111111111111111111111111 01111111111111111111111111111111 01111111111111111111111111111111
  • 19. 32-bit Leap Forward random number generator Block Diagram Figure: Block diagram of Leap Forward LFSR Random Number Generator
  • 20. 32-bit Leap Forward random number generator ROM The ROM part of the circuit is used for storing the two fixed seed values. The seed values chosen are 11111111111111111111111111111111 and 10101010101010101010101010101010. The value of S pin chooses which seed value is to be loaded into the flip flops circuitry. MUX The MUX block of the circuit is used to load the seed value for a certain amount of time during the start of the operation and then to select the intermediate values from the XOR circuitry. The SEL pin value changes accordingly. XOR Circuitry The XOR circuitry is responsible for the xor calculations from the previous values of the flip flops.
  • 21. 32-bit Leap Forward random number generator Just as the case of 4 bit leap forward circuit, the new transition matrix is obtained by rasing the old transition matrix by a power of 32. This is done by the MATLAB program. Based on the new transition matrix the new circuit is formed and is drawn as a layout using MAGIC using CMOS 90nm technology. The results are simulated using HSPICE and are verified using a JAVA program. The circuit works fine for frequency of 33.33 Mhz with FO4 load.
  • 22. Results Figure: Layout of 32-bit Leap Forward Figure: output of 32-bit Leap Forward LFSR RNG LFSR RNG
  • 23. Results Figure: output of D-Flipflop Figure: Layout of D-Flipflop
  • 24. Results Figure: Layout of 4-bit LFSR RNG Figure: output of 4-bit LFSR RNG
  • 25. Results Figure: Layout of 4-bit Leap Forward LFSR RNG Figure: output of 4-bit Leap Forward LFSR RNG
  • 26. References [1]. Design Techniques of FPGA based Random Number Generator by 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 Long Pseudo- Random Sequence Generators (XILINX)