lecture4 binary-numbers-logic-operations

64

Upload: markme18

Post on 15-Jul-2015

373 views

Category:

Documents


1 download

TRANSCRIPT

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

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

BINARY(BASE 2)numbers

DECIMAL(BASE 10)numbers

0 1 2 3 4 5 6 7 8 9

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)

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

The right-most is the least significant digit

The left-most is the most significant digit

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

1’s multiplier

1

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

10’s multiplier

10

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

100’s multiplier

100

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

1000’s multiplier

1000

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

The right-most is the least significant digit

The left-most is the most significant digit

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

1’s multiplier

1

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

2’s multiplier

2

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

4’s multiplier

4

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

8’s multiplier

8

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

16’s multiplier

16

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

?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?

binary digit

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.

Decimal Binary conversion

752

37 12

18 12

9 02

4 12

2 02

1 02

0 1

1001011

remainder

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

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

= 75

1002

50 02

25 02

12 12

6 02

3 02

1 12

0 1

1100100

remainder

Binary Decimal conversion

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

=0 + 0 + 0 + 8

=810

1110012

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

5710

Hexadecimal

Decimal conversion

100AH

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

4106

Binary

Hexadecimal conversion

1001 10102

10 = A

99AH

Hexadecimal

Binary conversion

1 0 0 AH

101000000000 = 00010000000010100001 or

1000000001010

Decimal

Octal

conversion

1581

87

178

1st remainder

1st quotient

180

01 2nd remainder

2nd quotient

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

Octal

Decimal

conversion

1248

4x80 = 42x81 = 161x82 = 64

84

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

Our next topic is …

0 1

Off On

Low High

False True

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

?

x y = x´

0

1

x y = x´

0 1

1 0

x y z = x · y

0 0

0 1

1 0

1 1

x y z = x · y

0 0 0

0 1 0

1 0 0

1 1 1

x y z = x + y

0 0

0 1

1 0

1 1

x y z = x + y

0 0 0

0 1 1

1 0 1

1 1 1

x y z = x y

0 0

0 1

1 0

1 1

x y z = x y

0 0 0

0 1 1

1 0 1

1 1 0

z = (x + y)´

z = y · (x + y)

z = (y · x) w

STRATEGY: Divide & Conquer

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

0 0 0 1

0 1 1 0

1 0 1 0

1 1 1 0

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

0 0 0 0

0 1 1 1

1 0 1 0

1 1 1 1

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

2n

n = number of input variables

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.

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

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