logic gates ii informatics info i101 february 5, 2003 john c. paolillo, instructor

Post on 28-Dec-2015

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Logic Gates II

Informatics INFO I101

February 5, 2003

John C. Paolillo, Instructor

Items for Today

• Last time– Logic Circuits– Applications of Boolean Logic

• This time– More Circuits– Addition and subtraction– Two’s complement representation– Color

Quiz Answers

and 0 1

0 0 0

1 0 1

(1)

or 0 1

0 0 1

1 1 1

(2)

C

AB

Exclusive OR (XOR)

xor 0 1

0 0 1

1 1 0

(3)

Quiz: 10 minutes

• Take out a sheet of paper

• Write you name on it and date it

• Answer the following questions (next slide)

Quiz Questions

(1) Give the truth table for Boolean AND

(2) Give the truth table for Boolean OR

(3) What does the following circuit do? Give a truth table for it, and name the logic gate it corresponds to.

C

AB

Graphic Paint/Copy Modes

COPY OR XOR

Arithmetic

Addition and Subtraction

Addition: Half Adder

+ 00 01

00 00 01

01 01 10

S

A B

xor 0 1

0 0 1

1 1 0

and 0 1

0 0 0

1 0 1

C

The half adder sends a carry, but can’t accept one

+

Addition: Full Adder

A

B S

CO

CI

Addition: Truth Tables

CI00001111

A01010101

B00110011

S COS01101001

CO00010111

More Digits

FullAdder

ci

co

s

ab

a0

s0

b0

FullAdder

ci

co

s

ab

a1

s1

b1

FullAdder

ci

co

s

ab

a2

s2

b2

FullAdder

ci

co

s

ab

a3

s3

b3

Full adders can be cascaded

Subtraction

– 00 01

00 00 01

01 –01 00

• Subtraction is asymmetrical

• That makes it harder• We have to borrow

sometimes

Solution: “Easy Subtraction”

456–123333

999–123876

• Subtraction is easy if you don’t have to borrow

• i.e. if all the digits of the minuend are greater than (or equal to) all those of the subtrahend

• This will always be true if the minuend is all 9’s: 999, or 999999, or 9999999999 etc.

How can we use easy subtraction?

• Subtract the subtrahend from 999 (or whatever we need) (easy)

• Add the result to the minuend (easy enough)• Add 1 (easy)• Subtract 1000 (not too hard)

Difference = Minuend + 999 – Subtrahend + 1 – 1000

This works for binary as well as decimal

Subtraction Example

10010101–01101110?????????

11111111–0110111010010001

This is the same as inverting each bit

+ 10010101100100110

+1100100111

–10000000000100111

Regular addition

Add one

Now drop the highest bit (easy: it’s out of range)

00100111

Subtraction Procedure

Invert each bit

Regular addition

Add one

Now drop the highest bit (easy: it’s out of range)

Each of these steps is a simple operation we can perform using our logic circuits

Bitwise XOR

Cascaded Adders

Add carry bit

Drop the highest bit (overflows)

Negative Numbers

Invert each bit

Add one

These steps make the negative of a number in twos-complement notation

• Twos complements can be added to other numbers normally• Positive numbers cannot use the highest bit (the sign bit)• This is the normal representation of negative numbers in binary

Counting

00000000 000000001 100000010 200000011 300000100 400000101 500000110 600000111 700001000 800001001 9

etc.

11111111 –111111110 –211111101 –311111100 –411111011 –511111010 –611111001 –711111000 –811110111 –911110110 –10etc.

Representations

• The number representation you use (encoding) affects the way you need to do arithmetic (procedure)

• This is true of all codes: encoding (representation) affects procedure (algorithm)

• Good binary codes make use of properties of binary numbers and digital logic

Color

(review)

The Eight-Color Computer

• Eight colors: black, yellow, magenta, red, cyan, green, blue, white

• Three color tubes on a TV monitor: Red, Green, Blue23=8

• Additive color relations: red+green+blue=white

Color Perception

3 Electron guns, aimed at 3 different colors of phosphor dots

3 types of retinal sensor cells, sensitive to 3 different bands of light

Color: Response Patterns

red conesgreen cones blue cones

Wavelength

Color: Neural Encoding

Wavelength

RGB

101 100 110 010 011 001 101

000 111

top related