Title: CS101 Introduction to Computing Lecture 6 CPU-II
1CS101 Introduction to ComputingLecture 6CPU-II
2Learning Goals for Today
- To become familiar with number system used by the
microprocessors - binary numbers - To become able to perform decimal-to-binary
conversions - To understand the NOT, AND, OR and XOR logic
operations the fundamental operations that are
available in all microprocessors
3 4- DECIMAL
- (BASE 10)
- numbers
5Decimal (base 10) number system consists of 10
symbols or digits
6Binary (base 2) number system consists of just two
7Other popular number systems
- 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)
8Decimal (base 10) numbers are expressed in the
positional notation
- 4202 2x100 0x101 2x102 4x103
The right-most is the least significant digit
The left-most is the most significant digit
9Decimal (base 10) numbers are expressed in the
positional notation
- 4202 2x100 0x101 2x102 4x103
1
1s multiplier
10Decimal (base 10) numbers are expressed in the
positional notation
- 4202 2x100 0x101 2x102 4x103
10
10s multiplier
11Decimal (base 10) numbers are expressed in the
positional notation
- 4202 2x100 0x101 2x102 4x103
100
100s multiplier
12Decimal (base 10) numbers are expressed in the
positional notation
- 4202 2x100 0x101 2x102 4x103
1000
1000s multiplier
13Binary (base 2) numbers are also expressed in the
positional notation
- 10011 1x20 1x21 0x22 0x23 1x24
The right-most is the least significant digit
The left-most is the most significant digit
14Binary (base 2) numbers are also expressed in the
positional notation
- 10011 1x20 1x21 0x22 0x23 1x24
1
1s multiplier
15Binary (base 2) numbers are also expressed in the
positional notation
- 10011 1x20 1x21 0x22 0x23 1x24
2
2s multiplier
16Binary (base 2) numbers are also expressed in the
positional notation
- 10011 1x20 1x21 0x22 0x23 1x24
4
4s multiplier
17Binary (base 2) numbers are also expressed in the
positional notation
- 10011 1x20 1x21 0x22 0x23 1x24
8
8s multiplier
18Binary (base 2) numbers are also expressed in the
positional notation
- 10011 1x20 1x21 0x22 0x23 1x24
16
16s multiplier
19Counting in Decimal
Counting in Binary
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 10
011
10100 10101 10110 10111 11000 11001 11010 11011 11
100 11101
11110 11111 100000 100001 100010 100011 100100 . .
.
20Why 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?
21bit
binary digit
22Byte 8 bits
23Decimal Binary conversion
24Convert 75 to Binary
75
2
remainder
37
1
2
18
1
2
9
0
2
4
1
2
2
0
2
1
0
2
0
1
1001011
25Check
- 1001011 1x20 1x21 0x22 1x23 0x24
0x25 1x26 -
- 1 2 0 8 0 0 64
-
- 75
26Convert 100 to Binary
100
2
remainder
50
0
2
25
0
2
12
1
2
6
0
2
3
0
2
1
1
2
0
1
1100100
27- That finishes our first topic - introduction to
binary numbers and their conversion to and from
decimal numbers - Our next topic is
28Boolean Logic Operations
29Let x, y, z be Boolean variables. Boolean
variables can only have binary values i.e., they
can have values which are either 0 or 1For
example, if we represent the state of a light
switch with a Boolean variable x, we will assign
a value of 0 to x when the switch is OFF, and 1
when it is ON
30A few other names for the states of these Boolean
variables
0 1
Off On
Low High
False True
31We define the following logic operations or
functions among the Boolean variables
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
32Well define these operations with the help of
truth tableswhat is the truth table of a logic
functionA truth table defines the output of a
logic function for all possible inputs
?
33Truth Table for the NOT Operation(y true
whenever x is false)
x y x
0
1
34Truth Table for the NOT Operation
x y x
0 1
1 0
35Truth Table for the AND Operation(z true when
both x y true)
x y z x y
0 0
0 1
1 0
1 1
36Truth Table for the AND Operation
x y z x y
0 0 0
0 1 0
1 0 0
1 1 1
37Truth Table for the OR Operation(z true when x
or y or both true)
x y z x y
0 0
0 1
1 0
1 1
38Truth Table for the OR Operation
x y z x y
0 0 0
0 1 1
1 0 1
1 1 1
39Truth Table for the XOR Operation(z true when x
or y true, but not both)
x y z x ? y
0 0
0 1
1 0
1 1
40Truth Table for the XOR Operation
x y z x ? y
0 0 0
0 1 1
1 0 1
1 1 0
41Those 4 were the fundamental logic operations.
Here are examples of a few more complex situations
- z (x y)
- z y (x y)
- z (y x) ? w
STRATEGY Divide Conquer
42z (x y)
x y x y z (x y)
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0
43z y (x y)
x y x y z y (x y)
0 0 0 0
0 1 1 1
1 0 1 0
1 1 1 1
44z (y x) ? w
x y w y x z (y x) ? w
0 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
45Number of rows in a truth table?
- 2n
- n number of input variables
46What have we learnt today?
- About the binary number system, and how it
differs from the decimal system - Positional notation for representing binary and
decimal numbers - A process (or algorithm) which can be used to
convert decimal numbers to binary numbers - Basic logic operations for Boolean variables,
i.e. NOT, OR, AND, XOR, NOR, NAND, XNOR - Construction of truth tables (How many rows?)