1 of 6

CSE12 Lab session 10/19

Yiwei Yang

2 of 6

About Lab2

  1. Shift: move all bits in a direction (left or right)
    1. Denoted by << (left shift) and >> (right shift) in C/C++/Java
    2. ICQ: Left shift example: 001010 << 2 = ?
    3. ICQ: Right shift example: 001010 >> 2 = ?
    4. Shifts are useful for
      1. Bit manipulation: extracting and setting individual bits in words
      2. Multiplication and division by powers of 2
        1. A * 4 = A << 2
        2. A / 8 = A >> 3
        3. A * 5 = (A << 2) + A
      3. Compilers use this optimization, called strength reduction
      4. Easier to shift than it is to multiply (in general)

3 of 6

About Lab2(Cond)

  1. Rotation
    1. Rotations are slightly different than shifts
    2. 1101 rotated 2 to the right = ?
    3. Rotations are generally less useful than shifts
    4. But their implementation is natural if a shifter is there
    5. 4 Mux with 2 selector
    6. 8 Mux with 3 selector
  2. What about shifting left by any amount from 0 to 15?
    • Cycle input through “left-shift-by-1” up to 15 times?
    • Complicated, variable latency
    • 16 consecutive “left-shift-by-1-or-0” circuits?
    • Fixed latency, but would take too long
    • Barrel shifter: four “shift-left-by-X-or-0” circuits (X = 1,2,4,8)

4 of 6

About Lab2(Cond)

  1. Register mapping
    1. You can simply add a decoder to store the abcdefg info for the monitor
    2. Normally we do Monitor Display Driver with same trick.
  2. 3=2+1

5 of 6

Some other things to tell

  1. Multiplier

  1. Divider
  2. Float Divider

6 of 6

Q&A

You can do anything till 5:30

Your technical communication should not violate the academic integrity, cuz the course is important