Top Banner
64

Lecture4 binary-numbers-logic-operations

Jul 15, 2015

Download

Documents

markme18
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture4  binary-numbers-logic-operations
Page 2: Lecture4  binary-numbers-logic-operations

During that lecture we learnt about the various types of computers with respect to their size, capability, applications (FIVE TYPES)

And its five essential components and various subsystem

Bus interface unit

Port

Modem

Page 3: Lecture4  binary-numbers-logic-operations

1. To become familiar with number system used by the microprocessors - binary numbers

2. To become able to perform decimal-to-binaryconversions

3. To understand the NOT, AND, OR and XOR logic operations – the fundamental operations that are available in all microprocessors

Page 4: Lecture4  binary-numbers-logic-operations

BINARY(BASE 2)numbers

Page 5: Lecture4  binary-numbers-logic-operations

DECIMAL(BASE 10)numbers

Page 6: Lecture4  binary-numbers-logic-operations

0 1 2 3 4 5 6 7 8 9

Page 7: Lecture4  binary-numbers-logic-operations
Page 8: Lecture4  binary-numbers-logic-operations

Octal

base = 8

8 symbols (0,1,2,3,4,5,6,7)

Hexadecimal

base = 16

16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

Page 9: Lecture4  binary-numbers-logic-operations

4202 = 2x100 + 0x101 + 2x102 + 4x103

The right-most is the least significant digit

The left-most is the most significant digit

Page 10: Lecture4  binary-numbers-logic-operations

4202 = 2x100 + 0x101 + 2x102 + 4x103

1’s multiplier

1

Page 11: Lecture4  binary-numbers-logic-operations

4202 = 2x100 + 0x101 + 2x102 + 4x103

10’s multiplier

10

Page 12: Lecture4  binary-numbers-logic-operations

4202 = 2x100 + 0x101 + 2x102 + 4x103

100’s multiplier

100

Page 13: Lecture4  binary-numbers-logic-operations

4202 = 2x100 + 0x101 + 2x102 + 4x103

1000’s multiplier

1000

Page 14: Lecture4  binary-numbers-logic-operations

10011= 1x20 + 1x21 + 0x22 + 0x23 + 1x24

The right-most is the least significant digit

The left-most is the most significant digit

Page 15: Lecture4  binary-numbers-logic-operations

10011= 1x20 + 1x21 + 0x22 + 0x23 + 1x24

1’s multiplier

1

Page 16: Lecture4  binary-numbers-logic-operations

10011= 1x20 + 1x21 + 0x22 + 0x23 + 1x24

2’s multiplier

2

Page 17: Lecture4  binary-numbers-logic-operations

10011= 1x20 + 1x21 + 0x22 + 0x23 + 1x24

4’s multiplier

4

Page 18: Lecture4  binary-numbers-logic-operations

10011= 1x20 + 1x21 + 0x22 + 0x23 + 1x24

8’s multiplier

8

Page 19: Lecture4  binary-numbers-logic-operations

10011= 1x20 + 1x21 + 0x22 + 0x23 + 1x24

16’s multiplier

16

Page 20: Lecture4  binary-numbers-logic-operations

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

.

.

.

0

1

10

11

100

101

110

111

1000

1001

1010

1011

1100

1101

1110

1111

10000

10001

10010

10011

10100

10101

10110

10111

11000

11001

11010

11011

11100

11101

11110

11111

100000

100001

100010

100011

100100

.

.

.

Counting

in Binary

Page 21: Lecture4  binary-numbers-logic-operations

?Because this system is natural for digital computers

The fundamental building block of a digital computer –

the switch – possesses two natural states, ON & OFF.

It is natural to represent those states in a number

system that has only two symbols, 1 and 0, i.e. the

binary number system

In some ways, the decimal number system is natural

to us humans. Why?

Page 22: Lecture4  binary-numbers-logic-operations

binary digit

Page 23: Lecture4  binary-numbers-logic-operations
Page 24: Lecture4  binary-numbers-logic-operations

1 Kilobyte = 1,024 bytes 1 Megabyte = 1, 024 KB = 1, 048, 576 bytes 1 Gigabyte = 1,024 MB = 1, 048, 576 KB

= 1, 073, 741, 824 bytes.

Page 25: Lecture4  binary-numbers-logic-operations

Decimal Binary conversion

Page 26: Lecture4  binary-numbers-logic-operations

752

37 12

18 12

9 02

4 12

2 02

1 02

0 1

1001011

remainder

Page 27: Lecture4  binary-numbers-logic-operations

1001011 = 1x20 + 1x21 + 0x22 + 1x23 +0x24 + 0x25 + 1x26

= 1 + 2 + 0 + 8 + 0 + 0 + 64

= 75

Page 28: Lecture4  binary-numbers-logic-operations

1002

50 02

25 02

12 12

6 02

3 02

1 12

0 1

1100100

remainder

Page 29: Lecture4  binary-numbers-logic-operations

Binary Decimal conversion

Page 30: Lecture4  binary-numbers-logic-operations

10002 = 0x20 + 0x21 + 0x22 + 1x23

=0 + 0 + 0 + 8

=810

Page 31: Lecture4  binary-numbers-logic-operations

1110012

1x20 = 10x21 = 00x22 = 01x23 = 81x24 = 161x25 = 32

5710

Page 32: Lecture4  binary-numbers-logic-operations

Hexadecimal

Decimal conversion

Page 33: Lecture4  binary-numbers-logic-operations

100AH

10x160 = 100x161 = 00x162 = 01x163 = 4096

4106

Page 34: Lecture4  binary-numbers-logic-operations

Binary

Hexadecimal conversion

Page 35: Lecture4  binary-numbers-logic-operations

1001 10102

10 = A

99AH

Page 36: Lecture4  binary-numbers-logic-operations

Hexadecimal

Binary conversion

Page 37: Lecture4  binary-numbers-logic-operations

1 0 0 AH

101000000000 = 00010000000010100001 or

1000000001010

Page 38: Lecture4  binary-numbers-logic-operations

Decimal

Octal

conversion

Page 39: Lecture4  binary-numbers-logic-operations

1581

87

178

1st remainder

1st quotient

180

01 2nd remainder

2nd quotient

Page 40: Lecture4  binary-numbers-logic-operations

264833

2640

4108

Check if the last quotient

(MSD) is still divisible by 8.

If not consider the MSD as

the leftmost value then

append the remainder(start

with the last remainder).

1st quotient

3384

321 2nd remainder

2nd quotient

1st remainder

Page 41: Lecture4  binary-numbers-logic-operations

Octal

Decimal

conversion

Page 42: Lecture4  binary-numbers-logic-operations

1248

4x80 = 42x81 = 161x82 = 64

84

Page 43: Lecture4  binary-numbers-logic-operations

That finishes our first topic - introduction to binary numbers and their conversion to and from decimal, hexadecimal and octal numbers.

Our next topic is …

Page 44: Lecture4  binary-numbers-logic-operations
Page 45: Lecture4  binary-numbers-logic-operations
Page 46: Lecture4  binary-numbers-logic-operations

0 1

Off On

Low High

False True

Page 47: Lecture4  binary-numbers-logic-operations

Name Example Symbolically

NOT y = NOT(x) x´

AND z = x AND y x · y

OR z = x OR y x + y

XOR z = x XOR y x y

Page 48: Lecture4  binary-numbers-logic-operations

?

Page 49: Lecture4  binary-numbers-logic-operations

x y = x´

0

1

Page 50: Lecture4  binary-numbers-logic-operations

x y = x´

0 1

1 0

Page 51: Lecture4  binary-numbers-logic-operations

x y z = x · y

0 0

0 1

1 0

1 1

Page 52: Lecture4  binary-numbers-logic-operations

x y z = x · y

0 0 0

0 1 0

1 0 0

1 1 1

Page 53: Lecture4  binary-numbers-logic-operations

x y z = x + y

0 0

0 1

1 0

1 1

Page 54: Lecture4  binary-numbers-logic-operations

x y z = x + y

0 0 0

0 1 1

1 0 1

1 1 1

Page 55: Lecture4  binary-numbers-logic-operations

x y z = x y

0 0

0 1

1 0

1 1

Page 56: Lecture4  binary-numbers-logic-operations

x y z = x y

0 0 0

0 1 1

1 0 1

1 1 0

Page 57: Lecture4  binary-numbers-logic-operations

z = (x + y)´

z = y · (x + y)

z = (y · x) w

STRATEGY: Divide & Conquer

Page 58: Lecture4  binary-numbers-logic-operations

x y x + y z = (x + y)´

0 0 0 1

0 1 1 0

1 0 1 0

1 1 1 0

Page 59: Lecture4  binary-numbers-logic-operations

x y x + y z = y · (x + y)

0 0 0 0

0 1 1 1

1 0 1 0

1 1 1 1

Page 60: Lecture4  binary-numbers-logic-operations

x y w y · x z = (y · x) w0 0 0 0 0

0 0 1 0 1

0 1 0 0 0

0 1 1 0 1

1 0 0 0 0

1 0 1 0 1

1 1 0 1 1

1 1 1 1 0

Page 61: Lecture4  binary-numbers-logic-operations

2n

n = number of input variables

Page 62: Lecture4  binary-numbers-logic-operations

A. Convert the following into base 2, 8 and H:

i. The last five digits of your cellphone number

ii. 256

B. x, y & z are Boolean variables. Determine the truth tables for the following combinations:

i. (x · y) + y

ii. (x y)´ + w

Whole sheet of yellow paper. Deadline: July 12 (Monday 12nn).Show your solution.

Page 63: Lecture4  binary-numbers-logic-operations

1. About the binary number system, and how it differsfrom the decimal system

2. Positional notation for representing binary and decimal numbers

3. A process (or algorithm) which can be used to convertdecimal numbers to binary numbers

4. Basic logic operations for Boolean variables, i.e. NOT, OR, AND, XOR, NOR, NAND, XNOR

5. Construction of truth tables (How many rows?)

Page 64: Lecture4  binary-numbers-logic-operations

Next lecture will be the ?

The focus of the one after that, the 10th lecture, however, will be on software. During that lecture we will try:

To understand the role of software in computing

To become able to differentiate between system and application software