Adders Lecture 12 CS301 Administrative Read Appendix C.5, - - PowerPoint PPT Presentation

adders
SMART_READER_LITE
LIVE PREVIEW

Adders Lecture 12 CS301 Administrative Read Appendix C.5, - - PowerPoint PPT Presentation

Adders Lecture 12 CS301 Administrative Read Appendix C.5, C.7-C.10 Program #1 due 10/24 FP Bias Infinity is represented as w exponent is all 1s w significand is all 0s Review MUX DeMux Decoder Encoder


slide-1
SLIDE 1

Adders

Lecture 12 CS301

slide-2
SLIDE 2

Administrative

  • Read Appendix C.5, C.7-C.10
  • Program #1 due 10/24
slide-3
SLIDE 3

FP Bias

  • Infinity is represented as

w exponent is all 1s w significand is all 0s

slide-4
SLIDE 4

Review

  • MUX
  • DeMux
  • Decoder
  • Encoder
slide-5
SLIDE 5

Combinational Logic

  • Half-Adder

w No carry in

A B Sum Carry Out 1 1 1 1 1 1 1

A⊕B AB

slide-6
SLIDE 6

1-bit Full Adder

  • Three inputs:

w A w B w Cin

  • Two outputs:

w Sum = (A⊕B) ⊕ Cin w Cout = AB + (A⊕B) Cin

slide-7
SLIDE 7

Combinational Logic

  • Full Adder

Note: Cout = (b Cin) + (a Cin) + (a b) + (a b Cin) = (b Cin) + (a Cin) + (a b) = (a b) + (a + b) Cin

slide-8
SLIDE 8

Ripple Carry Adder

  • Construct n-bit

adder with n 1-bit adders

  • Delay is problem
  • Faster alternative:

w Carry-lookahead adder

slide-9
SLIDE 9

Designing connections

  • Problem: Ripple-carry adder is too

slow

w Each carry must wait for all previous units to complete execution

  • Solution:
slide-10
SLIDE 10

Designing connections

  • Problem: Ripple-carry adder is too

slow

w Each carry must wait for all previous units to complete execution

  • Solution:

w Quickly get information for carries w Compute carries in parallel

slide-11
SLIDE 11

1b Adder

  • Three inputs:

w A w B w Cin

  • Two outputs:

w Sum = (A⊕B) ⊕ Cin w Cout = AB + (A⊕B) Cin w Cout = AB + ACin + BCin

slide-12
SLIDE 12

Carry Look-ahead

We already know: ci+1 = (bi Ÿ ci) + (ai Ÿ ci) + (ai Ÿ bi) = (ai Ÿ bi) + ci Ÿ (ai + bi)

slide-13
SLIDE 13

Carry Look-ahead

We already know: ci+1 = (bi Ÿ ci) + (ai Ÿ ci) + (ai Ÿ bi) = (ai Ÿ bi) + ci Ÿ (ai + bi) = Gi + Ci Ÿ Pi Let’s calculate ci+1 without waiting for ci

Generate Propagate

slide-14
SLIDE 14

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] P3 G3 P2 G2 P1 G1 P0 G0 Carry Lookahead Logic C0 C1 = G0 + C0 * P0 C1

slide-15
SLIDE 15

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] P3 G3 P2 G2 P1 G1 P0 G0 Carry Lookahead Logic C0 C1 = G0 + C0 * P0 C1

slide-16
SLIDE 16

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Lookahead Logic

C0

C1 = G0 + C0 * P0 P3 G3 P2 G2 P1 G1 P0 G0 C1

slide-17
SLIDE 17

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Lookahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2

slide-18
SLIDE 18

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Lookahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2

slide-19
SLIDE 19

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Lookahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2

slide-20
SLIDE 20

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Lookahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2

slide-21
SLIDE 21

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic

C0

C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2

slide-22
SLIDE 22

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-23
SLIDE 23

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-24
SLIDE 24

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 = G2 + G1 * P2 + G0 * P1 * P2 + C0 * P0 * P1 * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-25
SLIDE 25

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 = G2 + G1 * P2 + G0 * P1 * P2 + C0 * P0 * P1 * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-26
SLIDE 26

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 = G2 + G1 * P2 + G0 * P1 * P2 + C0 * P0 * P1 * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-27
SLIDE 27

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic C0 C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 = G2 + G1 * P2 + G0 * P1 * P2 + C0 * P0 * P1 * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-28
SLIDE 28

Carry Look-ahead

1-bit ALU 1-bit ALU 1-bit ALU 1-bit ALU B[3] B[2] B[1] B[0] A[3] A[2] A[1] A[0] Carry Look-ahead Logic

C0

C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 = G2 + G1 * P2 + G0 * P1 * P2 + C0 * P0 * P1 * P2 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

slide-29
SLIDE 29

Why is it Faster?

slide-30
SLIDE 30
slide-31
SLIDE 31

Why is it Faster?

  • 4th bit waits only for p&g to be calculated, not all of the

computations from bits 0-2

  • Only three levels of computation

w Gi and Pi w AND w OR C1 = G0 + C0 * P0 C2 = G1 + C1 * P1 = G1 + ( G0 + C0 * P0 ) * P1 = G1 + G0 * P1 + C0 * P0 * P1 C3 = G2 + C2 * P2 = G2 + (G1 + G0 * P1 + C0 * P0 * P1) * P2 = G2 + G1 * P2 + G0 * P1 * P2 + C0 * P0 * P1 * P2

slide-32
SLIDE 32

The Next Step

4-bit ALU 4-bit ALU 4-bit ALU 4-bit ALU B[12-15] B[8-11] B[4-7] B[0-3] A[12-15] A[8-11] A[4-7] A[0-3] Carry Look-ahead Logic C0 P3 G3 P2 G2 P1 G1 P0 G0 C1 C2 C3

Now what is the equation for Pi & Gi? They are for the 4-bit ALU, not just one bit!

slide-33
SLIDE 33

Basic Memory Cells and Sequential Logic

slide-34
SLIDE 34

Sequential Logic and Clocks

  • Sequential logic retains state
  • Clocks specify when that state should

be updated

  • System using clocks called

synchronous

slide-35
SLIDE 35

Clock

  • Signal with fixed

cycle time (Tcycle)

  • Frequency: 1/Tcycle
  • Tcycle has two parts

delineated by two edges

w Clock high w Clock low Tcycle Rising edge Falling edge

slide-36
SLIDE 36

Clocks (cont.)

slide-37
SLIDE 37

Memory Elements

  • All memory elements store state

w Output depends both on inputs and the value stored inside the memory element

  • Thus: All logic blocks containing

memory elements contain state and are sequential!

slide-38
SLIDE 38

Unclocked Latch

slide-39
SLIDE 39

Clocked Latch

slide-40
SLIDE 40

D Flip-Flop

  • D flip flop stores 1 bit of data
  • Created from 2 edge triggered D

latches

  • Only takes in new inputs when clock is

high

slide-41
SLIDE 41

Register

  • D flip-flop allows us to store 1 bit
  • Programmers don’t programming in bits, but

w char = 8 b w integer = 32 b w ...

  • String n D flip-flops together to store n bits

4b register implement with D flip-flops b3 b2 b1 b0

slide-42
SLIDE 42

Register Files

  • Contains set of

registers accessed by register num

w Input: register number w Output: data in register n entry register file

slide-43
SLIDE 43

Register Files

  • Components

w Array of registers built from flip-flops

  • Port

w Access point w Read port

§ register num

w Write port

§ register num, clock, data

2 read ports / 1 write port

slide-44
SLIDE 44

Register File:
 Read Ports

slide-45
SLIDE 45

Register File:
 Write Port

slide-46
SLIDE 46

Comparator

  • Comparator has three output lines

w A<B w A=B w A>B

slide-47
SLIDE 47

Comparator

slide-48
SLIDE 48

Comparator

slide-49
SLIDE 49

Comparator

slide-50
SLIDE 50

We Almost Have All the Pieces

  • Inverter, AND, OR
  • Multiplexor and demultiplexor
  • Decode and encoder
  • Comparator
  • Ripple carry adder and carry lookahead adder

w Half and full adder

  • Register file

w Registers w D flip flop

slide-51
SLIDE 51

Arithmetic Logic Unit

  • Circuitry that does arithmetic (+/-)

and logical operations (AND/OR)

  • MIPS has 32b quantities so ALU needs

to handle 32b numbers

  • Combine 32 1-b ALUs to create 32b

ALU

slide-52
SLIDE 52

AND/OR

slide-53
SLIDE 53

1b Adder

  • Three inputs:

w A w B w Cin

  • Two outputs:

w Sum = (A⊕B) ⊕ Cin w Cout = AB + (A⊕B) Cin

slide-54
SLIDE 54

1b ALU

slide-55
SLIDE 55

32b ALU

slide-56
SLIDE 56

Subtraction

  • Add negative version
  • f operand
  • Recall to get two’s

complement number:

w Invert all bits w Add 1

  • In hardware

w Use complements of all bits w Set CarryIn for LSB to 1 A+(B+1) = A+(-B)=A-B

slide-57
SLIDE 57

SLT

if (A < B) C=1 else C=0

  • Resulting 32b

w 31b set to 0 w Least significant bit set according to operation

  • Least significant bit

w Sign bit of (a-b)

  • In hardware,

w Set input for MUX to 0 for 31 MSB (Less)

slide-58
SLIDE 58

SLT

  • Resulting 32b

w 31b set to 0 w Least significant bit set according to operation

  • Least significant bit

w Sign bit of (a-b)

  • In hardware,

w Set input for MUX to 0 for 31 MSB w For LSB, need to grab

  • utput of adder of MSB

(SET) and set it as input to MUX

ALU for MSB

slide-59
SLIDE 59

32b ALU w/ SLT

slide-60
SLIDE 60

32b ALU w/ SLT

slide-61
SLIDE 61

Conditional Branch Instructions

  • Branch if 2 registers

equal or unequal

  • Easiest way:

w Test (a-b) == 0

  • In hardware,

w OR all outputs together w Invert Zero = (o31+o30+...+o0)

slide-62
SLIDE 62

Review: ALU

  • AND/OR
  • Addition/

Subtraction

  • SLT
  • Conditional

branches

slide-63
SLIDE 63

What More Do We Need?

  • Multiplication
  • Division