How computers calculate How binary operations yield complex capabilities.

Post on 14-Jan-2016

216 views 1 download

Transcript of How computers calculate How binary operations yield complex capabilities.

How computers calculate

How binary operations yield complex capabilities

Activity Part 1

Answer the questions in the Before You Start section

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

Discussion Question:

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

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

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)

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

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

Activity Part 3

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

Activity Part 4

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

section

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

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

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

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)

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

Adding large numbers

Start with right-most digits and work left

Number of gates needed grows quickly

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

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?

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).

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

Evaluation

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