CS101 Lecture 06: Logic Gates + Binary Addition = The Adder Review - - PDF document

cs101 lecture 06 logic gates binary addition the adder
SMART_READER_LITE
LIVE PREVIEW

CS101 Lecture 06: Logic Gates + Binary Addition = The Adder Review - - PDF document

1/30/13 CS101 Lecture 06: Logic Gates + Binary Addition = The Adder Review Logic Gates Adding Binary Numbers Aaron Stevens (azs@bu.edu) 30 January 2013 Computer Science What You ll Learn Today Computer Science Review: logic gates


slide-1
SLIDE 1

1/30/13 1

Computer Science

CS101 Lecture 06: Logic Gates + Binary Addition = The Adder

Review Logic Gates Adding Binary Numbers

Aaron Stevens (azs@bu.edu)

30 January 2013

Computer Science

2

What You’ll Learn Today

  • Review: logic gates
  • Review: How do we add in binary?
  • Combining logic gates in a single circuit.
  • Logic gates + binary addition = digital computing

Why should you care? This is what a computer actually does! WTF? Exactly.

slide-2
SLIDE 2

1/30/13 2

Computer Science

3

Review: AND Gate

The AND gate accepts two input signals. The output is 1 if and only if both inputs are 1. Otherwise the output is 0. Just like wiring in series.

Computer Science

4

Review: OR Gate

The OR gate accepts two input signals. The output is 1 if either input is 1. The output is 0 if both inputs are 0.

Just like wiring in parallel.

slide-3
SLIDE 3

1/30/13 3

Computer Science

5

Review: XOR Gate

An XOR gate accepts two input signals. When the 2 inputs differ, the output is 1 When both inputs are the same, the output is 0 Just like wiring with a 3-way switch.

Computer Science

6

0 + 0 is a sum of 0 with a carry of 0 1 + 0 is a sum of 1 with a carry of 0 0 + 1 is a sum of 1 with a carry of 0 1 + 1 is a sum of 0 with a carry of 1

Hint: work right to left. Carry Values 1 1 0 0 1 1 1 + 0 0 1 0 1 0 0 1 14

Binary: Add with Carry

Sum Operands

slide-4
SLIDE 4

1/30/13 4

Computer Science

7

An 8-bit Adder

Consider this 8-bit adder:

Notice how the carry out from one bit’s adder becomes the carry-in to the next adder.

http://faculty.mc3.edu/pvetere/Applets/APPLETS/BINARYADD/applet_frame.htm

Computer Science

A binary Adding Machine

http://www.youtube.com/watch?v=GcDshWmhF4A

slide-5
SLIDE 5

1/30/13 5

Computer Science

9

Combinational Circuits

Combines some basic gates (AND, OR, XOR, NOT) into a more complex circuit.

  • Outputs from one circuit flow into the inputs of another

circuit.

  • The input values explicitly determine the output values.

Computer Science

10

Combinational Circuits

Three inputs require eight rows to describe all possible input combinations (23 = 8):

slide-6
SLIDE 6

1/30/13 6

Computer Science

11

Binary Number Addition

Look closely at the values for Sum and Carry… Do they look like any of the gates we’ve seen?

Computer Science

12

A Circuit for Binary Addition

Sum = A XOR B Carry = A AND B

This circuit is called a half-adder. (It doesn’t take a carry-in.)

slide-7
SLIDE 7

1/30/13 7

Computer Science

13

Full Adder Circuit

The full adder takes 3 inputs:

  • A, B, and a carry-in value

Computer Science

14

The Full Adder

Here is the Full Adder, with its internal details hidden (an abstraction). What matters now are:

  • inputs are A, B, and CI.
  • outputs are S and CO
slide-8
SLIDE 8

1/30/13 8

Computer Science

15

An 8-bit Adder

Consider this 8-bit adder:

Notice how the carry out from one bit’s adder becomes the carry-in to the next adder.

http://faculty.mc3.edu/pvetere/Applets/APPLETS/BINARYADD/applet_frame.htm

Computer Science

16

An 8-bit Adder

To add two 8-bit numbers together, we need an 8-bit adder:

Notice how the carry out from one bit’s adder becomes the carry-in to the next adder.

slide-9
SLIDE 9

1/30/13 9

Computer Science

17

An 8-bit Adder

We can abstract away the 1-bit adders, And summarize with this diagram: Notice the inputs and outputs.

Computer Science

18

Number Overflow

If each value is stored using eight bits, consider adding 250 + 9: 11111010 (8 bits) + 00001001

  • (8 bits)

00000011 (8 bits) How do we interpret the value 00000011? 250 + 9 = 3. WTF? This is called overflow.

slide-10
SLIDE 10

1/30/13 10

Computer Science

19

Number Overflow

Adding two 8-bit numbers can result in an 9 bit result.

  • More generally, adding 2 n-bit numbers can give

a n+1 bit result.

Can we trust the sum? What does one do about overflow?

Computer Science

20

What You Learned Today

  • Basic logic gates (AND, OR, XOR)
  • Combination gates
  • Half-Adder
  • Full Adder
  • Overflow
slide-11
SLIDE 11

1/30/13 11

Computer Science

21

Announcements And To Do

  • Readings:
  • Reed chapter 7, pp121-131
  • Wikipedia: http://en.wikipedia.org/wiki/VLSI (introductory remarks

about gates on integrated circuits)

  • HW02 due tonight
  • HW03 due next week
  • Quiz 1 on Friday 2/1
  • Covers material from lectures 1-4 (i.e., not including this week)