21
How computers calculate How binary operations yield complex capabilities

How computers calculate How binary operations yield complex capabilities

Embed Size (px)

Citation preview

Page 1: How computers calculate How binary operations yield complex capabilities

How computers calculate

How binary operations yield complex capabilities

Page 2: How computers calculate How binary operations yield complex capabilities

Activity Part 1

Answer the questions in the Before You Start section

Page 3: How computers calculate How binary operations yield complex capabilities

Why Digital Not Analog?

What is difference? Digital is discrete number; analog varies

continuously

Analog signals prone to distortion because of large range

Analog signals lose information with every replication and over time

Page 4: How computers calculate How binary operations yield complex capabilities

Discussion Question:

What are some applications for which you would prefer an analog device? When would a digital device be preferable?

Page 5: How computers calculate How binary operations yield complex capabilities

Why Binary not Decimal?

Two options is a lot easier to manage than 10

Switch can be on/off Less confusion between different

settings Faster

Page 6: How computers calculate How binary operations yield complex capabilities

What is Binary?

Only uses digits 1 and 0 So 1+1=10 (1+1=2)

10+1=11 (2+1=3)

11+1=100 (3+1=4)

1001+1010=? ([1+8]+[2+8]=19)

10011 (1+2+16)

Page 7: How computers calculate How binary operations yield complex capabilities

Activity Part 2

Hook up the equipment as shown by your instructor, and answer the first 3

questions in the What type of signal is it? section

Page 8: How computers calculate How binary operations yield complex capabilities

What Good is Binary?

Can use numbers to represent letters Standard code ASCII has 7 binary digits

(bits) per character: e = 1100101 ! = 0100001 Del = 1111111 E = 1000101

Page 9: How computers calculate How binary operations yield complex capabilities

Activity Part 3

Answer questions 4-8 in the What are the properties of the signal? section

Page 10: How computers calculate How binary operations yield complex capabilities

Activity Part 4

Answer questions 9-15 in the How do signals from different keys compare?

section

Page 11: How computers calculate How binary operations yield complex capabilities

Boolean Logic

NOT – the simplest: outputs the opposite of the input.

AND – outputs a 1 only if both of its two inputs are 1.

NAND – outputs a 1 unless both of its two inputs are 1.

OR – outputs 1 if either input is 1. XOR – outputs 1 if only one input is 1

Page 12: How computers calculate How binary operations yield complex capabilities

So how do these do math?

Can create a half-adder and a full adder Half-adders add two digits and output the

unit output and the carry digit Full -adders add two digits and a carried

digit and give the two outputs

Page 13: How computers calculate How binary operations yield complex capabilities

Creating a half-adder

An XOR gate can give the unit output: 0 + 0 0 0 + 1 1 1 + 0 1 1 + 1 0

An AND gate can give the carry digit: 0 + 0 0 0 + 1 0 1 + 0 0 1 + 1 1

Page 14: How computers calculate How binary operations yield complex capabilities

Creating a full-adder

Combine 2 half-adders and 1 OR: First half-adder adds two input digits, giving

unit and carry digit Second adds new unit digit with carry input,

giving final unit output and carry digit

OR gives carry digit if either half-adder has a

carry digit (you will never have carry digits

from both)

Page 15: How computers calculate How binary operations yield complex capabilities

Adding 11+11

1 1

Ones (20)Twos (21)

1 1

11

1

So answer is 110, or 6 in decimal representation

1 0

1

Page 16: How computers calculate How binary operations yield complex capabilities

Adding large numbers

Start with right-most digits and work left

Number of gates needed grows quickly

Page 17: How computers calculate How binary operations yield complex capabilities

An exercise

How many gates needed to add any possible 2-digit decimal integers? 99=1*64+1*32+0*16+0*8+0*4+1*2+1*1 So need to add 2 7-digit binary numbers Need one half-adder and 6 full-adders Half-adder has 1 XOR and 1 AND Full-adders have 2 XOR, 2 AND, 1 OR Total is 13 XOR, 13 AND, 6 OR

Page 18: How computers calculate How binary operations yield complex capabilities

Discussion Question:

Think about different mathematical functions you are familiar with. Could you perform each of them using only adders and half-adders?

How would you do it?

Page 19: How computers calculate How binary operations yield complex capabilities

The Rest of Mathematics Subtraction, Multiplication, and Division can be

performed by combos of Addition and data shifting Mathematical features such as Taylor sums can be

used to express complicated functions using addition.

Data processing boils down to nothing but addition (and storage and shifting).

Page 20: How computers calculate How binary operations yield complex capabilities

So what have we learned today? Computers use digital binary numbers to

communicate and calculate One convention for expressing text as binary

numbers is ASCII Keyboards do not use ASCII, but use a quite

different format Boolean operators can process binary information AND, NAND, and XOR can be used to create half-

adders and full-adders All mathematical functions can be performed by a

series of addition and data shifting

Page 21: How computers calculate How binary operations yield complex capabilities

Evaluation

Log on to WebCT and answer the 6 questions in the Act02eval quiz