Tut 01
Tut 01
Outline
• Number Systems
– Binary, Octal, Hexadecimal Numbers
– 1’s complement and 2’s complement
– Addition and subtraction
• Boolean Algebra
– Logic Gates
– Boolean Theorems
– De Morgan’s Theorem
1
26/9/2020
D d 2 r 2 d1 r 1 d 0 r 0 d 1 r 1 d 2 r 2
2
26/9/2020
3
26/9/2020
Example 1
• Convert (10100)2 to base-10
• Convert (274)8 to base-10
Answer 1
4
26/9/2020
Example 2
• Convert (1101.011)2 to base-8
• Convert (AF3.15)16 to base-10
Answer 2
10
5
26/9/2020
Answer 2
11
Example 3
• Convert (234)10 to base-8
• Convert (234)10 to base-16
• Convert (0.25)10 to base-2
12
6
26/9/2020
Answer 3
13
Answer 3
14
7
26/9/2020
Answer 3
• Convert (0.25)10 to base-2
15
16
8
26/9/2020
17
18
9
26/9/2020
– Subtraction:
A – B = A + (-B) = A + Complement of B
19
For 8 bits,
27 = 1000 0000
20
10
26/9/2020
21
• Subtraction
– 1’s Complement: A – B = A + 1’s Complement of B
– 2’s Complement: A – B = A + 2’s Complement of B
22
11
26/9/2020
1’s Complement
• Addition
– 1’s Complement: add carry bit to the result
• Subtraction
– Take 1’s complement of the subtrahend
– Add with the minuend
– If the result of the above addition has carry bit, then
add it to the LSB
– If there is no carry bit 1, then take 1’s complement of
the result which will be negative
23
Overflow
• If the result of a n-bit arithmetic operation is too large
to fit into the resultant n-bit, then arithmetic overflow
occurs.
• Therefore:
– Adding two positive numbers must give a positive result
– Adding two negative numbers must give a negative result
– Overflow (when correct representation of the result
requires more than n bits)
– Sum of two positive numbers yields a negative result or
sum of two negative numbers yields a positive result
– The carry out of the sign position is not equal to the carry
into the sign position
24
12
26/9/2020
• Exercise 1:
Assuming that the computer uses 4-bit 2’s
complement arithmetic, show how it would
compute
3+4, 5+6, 5+(-6), (-5)+6, (-3)+(-4), (-5)+(-6)
and show whether there is an overflow
25
+5
26
13
26/9/2020
-5
27
• Exercise 2:
Assuming that the computer uses 4-bit 1’s
complement arithmetic, show how it would
compute
3+4, 5+6, 5+(-6), (-5)+6, (-3)+(-4), (-5)+(-6)
and show whether there is an overflow
28
14
26/9/2020
29
30
15
26/9/2020
Binary Codes
• ASCII (American Standard Code for
Information Interchange)
– Uses 7 bits to represent 94 graphics printing
characters and 34 control characters
– Extended ASCII (8 bits) include more graphic
characters
31
Parity Bit
• An extra bit is added to make the sum of ‘1’s
even or odd.
• Parity can be used to detect odd number of
bits in error, but cannot correct any error
32
16
26/9/2020
33
Logic Gates
• AND gate: output is 1 only when all inputs are
1’s
• OR gate: output is 0 only when all inputs are
0’s
• XOR gate: output is 1 only when two inputs
are different
• NOT gate, NOR gate, NAND gate …
34
17
26/9/2020
Boolean Theorems
• Elements : true or false ( 1, 0)
• Operations: a OR b; a AND b, NOT a
e.g.
0 OR 1 = 1 0 OR 0 = 0
1 AND 1 = 1 1 AND 0 = 0
NOT 0 = 1 NOT 1 = 0
35
Boolean Theorems
(A1) X = 0 if X 1 (A1’) X = 1 if X 0
(A2) If X = 0, then X’ = 1 (A2’) if X = 1, then, X’ = 0
(A3) 0·0 = 0 (A3’) 1 + 1 = 1
(A4) 1·1 =1 (A4’) 0 + 0 = 0
(A5) 0·1=1·0=0 (A5’) 1 + 0 = 0 + 1 = 1
36
18
26/9/2020
Boolean Theorems
37
38
19
26/9/2020
39
40
20
26/9/2020
41
Example 1
Why
x + x’y = x + y ?
42
21
26/9/2020
43
44
22
26/9/2020
45
45
23