CSE370 Laboratory Assignment 6


Shift Registers


Distributed: 10 November 2003
Due: 18 November 2003


Objectives

In this laboratory assignment we will construct a larger sequential systems, namely, a new type of shift-register.  We will primarily use the '377 octal D-FF with input enable (see map) in your kit. 


Linear Feedback Shift Registers (LFSRs)

A linear feedback shift register is a special kind of shift register whose single data input is a function of the shift register's outputs.  They have an interesting property that a particular function of a subset of the outputs will cause the shift register to cycle through a maximal length sequence of output values.  In the case of a 4-bit shift register, a maximal  length sequence would have 15 (24 - 1, the all-zero pattern is not counted) different outputs.  If the function can be implemented efficiently, this capability can be much easier to implement than building a binary counter (recall that a binary counter is a specialized adder but still has a long carry-chain or larger and larger gates to do lookahead).  Binary counters with a large number of bits can be quite expensive in terms of the logic they require.  On the other hand, LFSRs with maximal sequences can be made with input functions that are low fan-in (depend on only a few of the register's outputs) and do not have a carry-chain.  This makes LFSRs very attractive when we need to count to large values but don't care about what the patterns are (that is, they don't have to be consecutive binary numbers).  Variations of LFSRs are often used as random number generators as well - consecutive output patterns can be made to look quite different and are uniformally distributed over the space of all possible patterns.  You can read a lot more about LFSRs at New Wave Instruments or Xilinx, each of these sites includes a complete list of functions that will generate maximal sequences for any number of bits from 4 to 32 and beyond.

For example, a 4-bit LFSR with maximal length sequence will have the following function: D1 = Q4 xor Q3.  A larger 8-bit LFSR with D1 = Q8 xor Q7 xor Q6 xor Q1 will have a 255 pattern long  maximal sequence.   Interestingly, a 32-bit LFSR can also have a maximal sequence (232-1 patterns long) with a function of only 4 output variables, namely, D1 = Q32 xor Q31 xor Q30 xor Q10.


Tasks

  1. Wire up your '377 octal D-FF to form a 4-bit shift register.  Connect the four FF outputs to four of the LEDs.  Connect the output of a 2:1 multiplexer to the first input with a switch connected to the mux's control input.  The two mux inputs should be the value of another switch and the last output of the shift register (the fourth bit).  Verify the operation of your shift register by setting the input to come from the switch.  Go through a few clock cycles shifting in different values - basically, this is a four-bit version of the shift register you made at the end of the last lab assignment. Make sure to tie the enable input of the '377 to a value rather than leaving it floating.
  2. Shift the pattern 1, 1, 0, 0 into your shift register.  Flip the input mux switch so that the last output is now fed back into the input.  Go through a few clock cycles.  You should see your pattern shifting in a circular pattern through the register.  How many different patterns are there in all before the output pattern on the LEDs repeats itself?
  3. Invert the value of the last bit being fed back around before it goes into the mux.  Repeat the previous task with this new configuration.  How many different patterns do you see?
  4. Remove the inverter and replace it with an XOR gate with the 4th and 3rd outputs as its inputs.  Connect the output of this XOR gate to the input mux of the shift register.  This is a 4-bit LFSR.  Begin by shifting in zeros into your shift register (use the switch input to the mux).  Now flip the mux to select the output of the XOR gate to be the input.  Go through a few clock cycles.  Does the pattern change?  Now, shift in all ones (instead of zeros) to set up the shift register and then go through a few clock cycles.  How many patterns do you go through before they begin to repeat?  Is this a maximal sequence?  Show your LFSR in operation to one of the TAs.  Try different taps instead of 4th and 3rd, for example, 4th and 2nd.  How many different patterns does this configuration generate? Demonstrate your LFSR to the TA to get checked off for this assignment.


Comments to: cse370-webmaster@cs.washington.edu (Last Update: )