ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring...

22
ITEC 352 Lecture 6 Back to binary

Transcript of ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring...

Page 1: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

ITEC 352

Lecture 6Back to binary

Page 2: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Review

• Decoders• 7 segment display• Complexity of wiring• Questions?

Page 3: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Outline

• Homework• Binary–May be short depending on what you

remember from Discrete Math

Page 4: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Questions

• How can you tell if a number is negative in binary?

• How can you tell if a number is 3.5743 in binary?

• How can you tell if a set of binary digits is a String?

• What do these questions lead you to believe about binary numbers?

Page 5: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Numeral systems

• Numeral Vs. Number– same as difference between a word vs.

the things it refers to.–numeral is a group of symbols that

represents a number.• E.g., 15 can be represented as:–15, Fifteen, XV (roman)

• What numeral system do we use everyday ?

Page 6: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Numeral system (2)

• Any numeral system is characterized by the number of digits used to represent numbers.

• E.g., – Unary system: ?– Binary system: ?– Octal: ? – Decimal: ?

• The numeral system is called the base.

Page 7: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Numeral system (3)

• If we had lots of numeral systems in use, things will get confusing: – E.g., What is: 20 + 10 = ? – Is it:• 30 ? • 24? • 12?

Page 8: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Number Systems

• To make things easier for us: we use decimal number system as our base.

• Every number in any other base is converted to decimal for us to be able to understand.

• How do we do this conversion?

Page 9: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Radix

• Determines the value of a number, by assigning a weight to the position of each digit.– E.g., Number 481

• start all positions from 0.• Position of “1” : 0; weight of position: 1• Position of “8” : 1; weight of position: 10• Position of “4” : 2; weight of position: 100• Hence number: 4*100 + 8 * 10 + 1 * 1

– Weight is calculated as 10^position – Any decimal number can be represented this way.– 10 is called the base or radix of the number system.

• We use notation ()r to represent the radix.

– E.g., the decimal number 481 can also be written as: (481)10

Page 10: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Other bases

• Octal• Hexadecimal• Does it matter that you can convert

between them?

Page 11: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

ConversionChart

Page 12: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Basics

• Conversion– How do you do it?

• What is 10 in binary?• What is 100 in binary?

Page 13: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Adding Subtracting

• What is binary 1 + binary 0 = ?• What about binary 1 + binary 1 = ? • Addition is similar to decimal addition.– remember though that the answer will only use

one of two digits: 0 or 1.

• How about subtraction?

Page 14: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Subtraction

• 101 – 011 =

Page 15: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Subtraction

• Subtraction introduces some challenges: – Answer maybe negative. How to represent

negative binary numbers? – Subtraction isn’t easy: requires carry-ins… • Can we make it easier? What type of subtractions

are easy to implement?

– Can we use the same circuit for addition and subtraction. ?

Page 16: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Limitations

• TWO key limitations: • It only represents positive numbers.

– How do we accommodate negative numbers?

• What about numbers that have too many digits? – A computer is bound by its data bus in the number of digits it can

handle.• E.g., a 32 bit data bus, implies, the computer can store upto 32 bits

for a basic data such as a byte. – Ofcourse, integers can be represented as multiple bytes, but this

decreases the speed of compuration. – Solution: Floating Point Representation.

• Next: Representing negative numbers.

Page 17: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Negative numbers

• Our goal: –We want a representation of negative

numbers such that: • Subtractions are as easy as additions:

– Instead of subtraction we should be able to simply add.

– Or– If it is a subtraction, there should be no carry.

• We have some facts at our disposal. The number of bits you can use to represent any number in a computer is limited.

Page 18: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Complement notation.

• The invention of complements.– Assume our computer is limited to two digits.– Find x in the following equation (restricting answer to two

digits):• 54 – 45 = 54 + x

– Introducing 10’s complement• 10’s complement of 45 = 55• 10’s complement of 99 = 1

– What is 54 + (10’s complement of 45) restricted to two digits ? – The 9’s complement for decimal digits:

• 9’s complement for 45 = 99 – 45 = 54 – 54 + 54 = 108 – 1 + 08 = 9 = 54 - 45

Page 19: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

One’s complement

• Invert all positions in the number• To subtract, add the numbers• If there is a carry out, add it to the

first number in the result• Done

Page 20: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Question

• In one’s complement what are the following numbers?

• 000• 111

Page 21: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Questions

• On 3-bit architecture, what are all the positive and negative numbers that can be represented if numbers are represented in one’s complement notation?

• Write down the binary representations of all the numbers.

Page 22: ITEC 352 Lecture 6 Back to binary. Binary Review Decoders 7 segment display Complexity of wiring Questions?

Binary

Review

• Binary• Numbering systems• Addition / Subtraction• One different way to represent them