Study Web

Week 4

Shift Registers

COS10004 Computer Systems · Lecture 3.5: Shift Registers

SHIFT REGISTERS

A shift register takes input from one end, and at each clock change this value is moved to the next D-Flip-Flop. This is used in serial data transfer when a byte (say) of data sent on a cable one bit after another can be collected in a series of D Flip-Flops to rebuild the whole data byte. This is called serial-to-parallel conversion.

2 COS10004 Computer Systems 2

Here is how a high A B C travels through a 3 bit Q Q Q Output shift register. For this Input D D D example we assume Q Q Q that each of the shift register bits is cleared at Clock Clock Clock the start.

Clock

Input

FF A

Q outputs FF B

FF C

3 COS10004 Computer Systems 3

SHIFT LEFT SHIFT REGISTERS

  • The shift registers shown so far shift data to the right. A simple rewiring gives a shift register that can move data left. Of course these may also have the ability to parallel load.

4 COS10004 Computer Systems 4

WHAT DOES A SHIFT REGISTER DO?

  • Moves a state (number such as 0, 1) from a low order bit to a higher order bit.
  • Multiplies a (binary) number by two.
  • Number of "shifts" depends on number of clock cycles.
  • Level counter (e.g. volume control)
  • Can use a counter to enable/disable clock, thereby programming the amount of shift.
  • Can shift in the other direction – divide numbers by 2.
  • Can have two clocks – one for left-shift, one for right- shift, or use gates to determine the shift direction.

SERIAL-TO-PARALLEL CONVERSION

  • Some shift registers allow all flip-flops to load at once,
  • i.e. in parallel.
  • This gives parallel-to-serial conversion

6 COS10004 Computer Systems 6

RIGHT-SHIFT SERIAL OR PARALLEL INPUT: 4-BIT

Parallel Output

  • Flip-flops are connected (output to input) with a common clock to cascade input from high bytes to low bytes.
  • Each flip-flop has a parallel bit OR-ed to the input to allow PReset. 7

WHAT ABOUT BI-DIRECTIONAL SHIFTING (SELECTABLE)?

  • This takes some thinking!
  • You need a pin to select which direction
  • You need to allow inputs to any D Flip Flop to come from either direction
  • Try and design a 2 bit selectable direction Shift Register!
  • Serial input only
  • You will probably need some OR gates,AND gates, and a NOT gate

THE LOGISIM SHIFT REGISTER

(NOT FOR USE IN ASSIGNMENTS!

THINGS TO TRY

  • Parallel Load a value and Shift to see it halve.
  • Implement both directions and see it double or halve.
  • Hold down SI to inject a bit – see it halve or double.

W HERE ARE WE?

Fast memory (RAM) Persistent

  • program and data memory (Disks) Counter

Central processing Mother Programmable unit (CPU) board shift register registers IP

Screen memory ALU within Keyboard the CPU Input / Output accel

11 Channels cards Mouse

THINGS TO REMEMBER (FILL THIS IN)

ALU Types of Flip Inputs Clock type Extra Circuit Elements Component Flops (Gates)

Register Required state Common clock (n-bit latch) Ripple none Counter Decimal D Flip Flops Counter Mod n Cascading clock AND gate Counter Mod 6 Common clock Counter 3-bit counter Enable AND gate Shift Register AND, OR gates to

WEEK 3 SUMMARY

  • Counters:
  • Ripple counter (asynchronous)
  • Common clock counters (synchronised)
  • Mod 6 counter
  • Use logic to detect illegal state and reset FFs
  • Use D FFs to buffer output and stabilise
  • Shift Registers with connected D FFs
  • Extremely useful for multi/div, bit shifting, level setting, serial/parallel data conversion.