CH 1 Digital Logic Design
CH 1 Digital Logic Design
Digital Systems
Discrete Data
● Examples:
♦ 26 letters of the alphabet (A, B … etc)
Analog Discrete
♦ 10 decimal digits (0, 1, 2 … etc)
● Combine together
♦ Words are made of letters (University … etc)
♦ Numbers are made of digits (4241 … etc)
Binary System
● Only ‘0’ and ‘1’ digits
● Can be easily implemented in electronic circuits
3 / 45
Decimal Number System
Base (also called radix) = 10
● 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
Digit Position 2 1 0 -1 -2
5 / 45
Binary Number System
Base = 2
● 2 digits { 0, 1 }, called binary digits or “bits”
4 2 1 1/2 1/4
Weights
Position 1 0 1 0 1
● Weight = (Base)
2 1 0 -1 -2
Magnitude 2 1 0 -1
1 *2 +0 *2 +1 *2 +0 *2 +1 *2
-2
7 / 45
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega
1 1 Carry
5 5
+ 5 5
1 1 0
= Ten ≥ Base
Subtract a Base
9 / 45
Binary Addition
Column Addition
1 1 1 1 1 1
1 1 1 1 0 1 = 61
+ 1 0 1 1 1 = 23
1 0 1 0 1 0 0 = 84
≥ (2)10
10 / 45
Binary Subtraction
Borrow a “Base” when needed
1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1 = 77
− 1 0 1 1 1 = 23
0 1 1 0 1 1 0 = 54
11 / 45
Binary Multiplication
Bit by bit
1 0 1 1 1
x 1 0 1 0
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
1 1 1 0 0 1 1 0
12 / 45
Number Base Conversions
Evaluate
Magnitude
Octal
(Base 8)
Evaluate
Magnitude
Decimal Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
Evaluate
Magnitude 13 / 45
Decimal (Integer) to Binary Conversion
Divide the number by the ‘Base’ (=2)
Take the remainder (either 0 or 1) as a coefficient
Take the quotient and repeat the division
Example: (13)10
Quotient Remainder Coefficient
13/ 2 = 6 1 a0 = 1
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2
MSB LSB
14 / 45
Decimal (Fraction) to Binary Conversion
Multiply the number by the ‘Base’ (=2)
Take the integer (either 0 or 1) as a coefficient
Take the resultant fraction and repeat the division
Example: (0.625)10
Integer Fraction Coefficient
0.625 * 2 = 1 . 25 a-1 = 1
0.25 * 2 = 0 . 5 a-2 = 0
0.5 *2= 1 . 0 a-3 = 1
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2
MSB LSB
15 / 45
Decimal to Octal Conversion
Example: (175)10
Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8
Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
16 / 45
Binary − Octal Conversion
8 = 23 Octal Binary
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16
20 / 45
Complements
1’s Complement (Diminished Radix Complement)
● All ‘0’s become ‘1’s
● All ‘1’s become ‘0’s
Example (10110000)2
(01001111)2
If you add a number and its 1’s complement …
10110000
+ 01001111
11111111
21 / 45
Complements
2’s Complement (Radix Complement)
● Take 1’s complement then add 1
OR
● Toggle all bits to the left of the first ‘1’ from the right
Example:
Number: 10110000 10110000
1’s Comp.: 0 1 0 0 1 1 1 1
+ 1
01010000 01010000
22 / 45
Negative Numbers
Computers Represent Information in ‘0’s and ‘1’s
● ‘+’ and ‘−’ signs have to be represented in ‘0’s and ‘1’s
3 Systems
● Signed Magnitude
● 1’s Complement
● 2’s Complement
All three use the left-most bit to represent the sign:
♦ ‘0’ positive
♦ ‘1’ negative
23 / 45
Signed Magnitude Representation
Magnitude is magnitude, does not change with sign
S Magnitude (Binary)
(+3)10 ( 0 0 1 1 )2
(−3)10 ( 1 0 1 1 )2
Sign Magnitude
Range 0 ≤ N ≤ 15 -7 ≤ N ≤ +7 -7 ≤ N ≤ +7 -8 ≤ N ≤ +7
0 0 0
Positive
Binary Binary Binary Binary
1 1 1
Negative X
Binary 1’s Comp. 2’s Comp.
29 / 45
Binary Subtraction Using 1’s Comp. Addition
Change “Subtraction” to “Addition”
If “Carry” = 1 (5)10 – (1)10 (5)10 – (6)10
then add it to the (+5)10 + (-1)10 (+5)10 + (-6)10
LSB, and the result
is positive 0101 0101
(in Binary) + 1110 + 1001
If “Carry” = 0 0 1110
1 0011
then the result +
is negative
(in 1’s Comp.) 0100 1110
+4 −1
30 / 45
Binary Subtraction Using 2’s Comp. Addition
Change “Subtraction” to “Addition”
If “Carry” = 1 (5)10 – (1)10 (5)10 – (6)10
ignore it, and the (+5)10 + (-1)10 (+5)10 + (-6)10
result is positive
(in Binary) 0101 0101
If “Carry” = 0 + 1111 + 1010
then the result 1 0100 0 1111
is negative
(in 2’s Comp.) +4 −1
31 / 45
Binary Codes
Group of n bits
● Up to 2n combinations
● Each combination represents an element of information
35 / 45
ASCII Code
a 1100001
b 1100010
. .
. .
. .
z 1111010
@ 1000000
? 0111111
+ 0101011
36 / 45
Error Detecting Codes
Parity
One bit added to a group of bits to make the total number
of ‘1’s (including the parity bit) even or odd
● Even 1 0 1 1 1 0 1 0 0 0 0 0 1
● Odd 0 0 1 1 1 1 1 0 0 0 0 0 1
AND OR NOT
x y z x y z x z
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
z=x•y=xy z=x+y z = x = x’
x x x
y z y z z
39 / 45
Logic Signals
Binary ‘0’ is represented
by a “low” voltage
(range of voltages)
Binary ‘1’ is represented
by a “high” voltage
(range of voltages)
The “voltage ranges” guard
against noise
AND OR
41 / 45
Homework
Mano Write your family name in
● Chapter 1 ASCII with odd parity
♦ 1-2 Decode the following ASCII
♦ 1-7 string (with MSB = parity):
♦ 1-9
11000011 01101111 11101101
♦ 1-10 11110000 11000000 01010000
♦ 1-11 01010011 01010101 11010100
♦ 1-16
Is the parity even or odd?
♦ 1-18
♦ 1-20
♦ 1-24(a)
♦ 1-29 42 / 45
Homework
Mano
1-2 What is the exact number of bytes in a system that
contains (a) 32K byte, (b) 64M byte, and (c) 6.4G byte?
1-7 Express the following numbers in decimal: (10110.0101)2,
(16.5)16, and (26.24)8.
1-9 Convert the hexadecimal number 68BE to binary and
then from binary convert it to octal.
1-10 Convert the decimal number 345 to binary in two ways:
(a) convert directly to binary, (b) convert first to
hexadecimal, then from hexadecimal to binary. Which
method is faster?
43 / 45
Homework
1-11 Do the following conversion problems:
(a) Convert decimal 34.4375 to binary.
(b) Calculate the binary equivalent of 1/3 out to 8 places.
Then convert from binary to decimal. How close is the
result to 1/3?
(c) Convert the binary result in (b) into hexadecimal.
Then convert the result to decimal. Is the answer the
same?
1-16 Obtain the 1’s and 2’s complements of the following
binary numbers:
(a) 11101010 (b) 01111110 (c) 00000001 (d) 10000000
(e) 00000000
44 / 45
Homework
1-18 Perform subtraction on the following unsigned binary
numbers using the 2’s-complement of the subtrahend.
Where the result should be negative, 2’s complement it
and affix a minus sign.
(a) 11011 – 11001 (b) 110100 – 10101 (c) 1011 – 110000
(d) 101010 – 101011
1-20 Convert decimal +61 and +27 to binary using the signed-
2’s complement representation and enough digits to
accommodate the numbers. Then perform the binary
equivalent of (+27) + (– 61), (–27) + (+61) and
(–27) + (–61). Convert the answers back to decimal and
verify that they are correct.
45 / 45
Homework
1-24 Represent decimal number 6027 in (a) BCD
46 / 45