Roth 1 Number Systems and Conversion
Roth 1 Number Systems and Conversion
Class Introduction
In-Cheol Park
School of EE, KAIST
EE303
◆ Course Name: Digital System Design
◆ No Prerequisite
◆ Instructor: In-Cheol Park (박인철)
[email protected] , Tel. 042)350-3461,
National NanoFab Center 316
◆ Teaching Assistants:
Sungho Kim (김성호 [email protected])
Seungju Woo (우승주 [email protected])
Seunghee Han (한승희 [email protected])
Hansol Jung (정한솔 [email protected])
Kangjun Choi (최강준 [email protected])
2
EE303 Course Description
The goal of this course is for the students to understand the principles of
digital gates and how to design digital logic circuits using the gates, and
to learn several mathematical manipulations of Boolean algebra and
practical design techniques useful in minimizing the circuit complexity.
Starting from combinational circuits, this class deals with how to express
the circuit to be designed and how to optimize it, and then moves to
sequential circuits on which most of digital circuits are based.
3
EE303 Textbook
4
Homework
5
EE303 Tentative Timetable
6
Chapter 1.
Introduction
Number Systems and Conversion
Outline
8
1.1 Digital Systems and Switching Circuits (1)
◆ Analog vs Digital
Analog Digital
▪ Continuous
▪ Discrete
▪ Natural Phenomena
▪ Binary Digit (bit) : (0, 1)
(Pressure, Temperature, …)
→ Enables digital signal processing
▪ Difficulty in realizing,
▪ Easy to realize and process
processing using electronics
using electronics
◆ Digital systems
❖ Reliable, easy to integrate.
9
1.1 Digital Systems and Switching Circuits (2)
◆ Switching Circuit
❖ Combinational Circuit
⚫ Outputs depend on only present inputs, not on past inputs
❖ Sequential Circuit
⚫ Outputs depend on both present inputs and past inputs
⚫ Has “memory” function
10
1.2 Number Systems and Conversion (1)
Radix(base)
N = (a4 a3a2 a1a0 .a−1a−2 a−3 ) R
= a4 R 4 + a3 R 3 + a2 R 2 + a1 R1 + a0 R 0
+ a−1 R −1 + a−2 R −2 + a−3 R −3
Examples
▪ Decimal 953.7810 = 9 102 + 5 101 + 3 100 + 7 10−1 + 8 10−2
▪ Binary 1011.112 = 1 23 + 0 2 2 + 1 21 + 1 20 + 1 2 −1 + 1 2 −2
1 1 3
= 8 + 0 + 2 +1+ + = 11 = 11.7510
2 4 4
▪ Hexadecimal A2F16 = 10 162 + 2 161 + 15 160 = 2560 + 32 + 15 = 260710
11
1.2 Number Systems and Conversion (2)
N
= an R n −1 + an −1 R n −2 + + a2 R1 + a1 = Q1 , remainder a0
R
Q1
= a n R n − 2 + a n −1 R n −3 + + a 3 R 1 + a 2 = Q 2 , remainder a1
R
Q2
= an R n −3 + an −1 R n −4 + + a3 = Q3 , remainder a2
R
12
1.2 Number Systems and Conversion (3)
◆ Example
❖ Convert 5310 to binary
2 53
2 26 rem. = 1 = a0
2 13 rem. = 0 = a1
2 1 rem. = 1 = a4
0 rem. = 1 = a5
13
1.2 Number Systems and Conversion (4)
14
1.2 Number Systems and Conversion (5)
◆ Example
❖ Conversion from .62510 to binary
.62510 = .1012
15
1.2 Number Systems and Conversion (6)
◆ Example
❖ Convert 0.710 to binary
.7
2
(1).4
2
(0).8
2
(1).6
2
(1).2
2
(0).4 Process starts repeating here because .4 was previously
2 obtained
(0).8 0.710 − 0.1 0110 0110 0110 2
16
1.2 Number Systems and Conversion (7)
◆ Example
❖ Conversion from binary to octal or hexadecimal
⚫ Starting at the binary point, the bits are divided into groups of
four(for hexadecimal), and is replaced by a hexadecimal digit
17
1.3 Binary Arithmetic (1)
◆ Addition
0+0 =0
0 +1 = 1
1+ 0 =1
1 +1 = 0 and carry 1 to the next column
Example
1111 carries
1310 = 1101
1110 = 1011
11000 = 2410
18
1.3 Binary Arithmetic (2)
◆ Subtraction
0−0 = 0
0 −1 = 1 and borrow 1 from the next column
1− 0 =1
1 −1 = 0
Example
19
1.3 Binary Arithmetic (3)
205
− 18
205 − 18 = [2 102 + 0 101 + 5 100 ]
−[ 1 101 + 8 100 ]
187
note borrow from column 1
= [2 102 + (0 − 1) 101 + (10 + 5) 100 ]
−[ 1 101 + 8 100 ]
note borrow from column 2
= [( 2 − 1) 102 + (10 + 0 − 1) 101 + 15 100 ]
−[ 1) 101 + 8 100 ]
= [1102 + 8 101 + 7 100 ] = 187
20
1.3 Binary Arithmetic (4)
1111 multiplicand
1101 multiplier
1111 first partial product
0000 second partial product
(01111) sum of first two partial products
1111 third partial product
(1001011) sum after adding third partial product
1111 fourth partial product
11000011 final product (sum after adding fourth partial prodoct)
21
1.3 Binary Arithmetic (5)
◆ Division example
1101
1011 10010001
1011
1110
1011
1101 The quotient is 1101 with a remainder
1011 of 10.
10
22
1.4 Representation of Negative Numbers (1)
For n=4,
3 2 1 0
0 1 0 1
=5
sign magnitude
3 2 1 0
1 1 0 1 = -5
sign magnitude
23
1.4 Representation of Negative Numbers (2)
24
1.4 Representation of Negative Numbers (3)
❖ Other representation
n−2
X = − xn −1 (2 n −1
− 1) + xi 2i
i =0
25
1.4 Representation of Negative Numbers (4)
27
1.4 Representation of Negative Numbers (6)
Case 5 −3 1101
−4 1100
−7 (1)1001 correct answer when the last carry is ignored
(this is not an overflow)
Case 6 −5 1011
−6 1010
(1)0101 wrong answer because of overflow
(-11 requires 5 bits including sign)
28
Overflow Detection
◆ An overflow occurs
if adding two positive numbers gives a negative answer or
if adding two negative numbers gives a positive answer.
An alternative method:
◆ An overflow occurs
if and only if the carry out of the sign position is not equal
to the carry into the sign position.
29
1.4 Representation of Negative Numbers (7)
1100
Case 5
−3 1011
−4 (1) 0111
1 (end-around carry)
1000 (correct answer, no overflow)
30
1.4 Representation of Negative Numbers (8)
Case 6 1010
−5 1001
−6 (1) 0011
1 (end-around carry)
0100 (wrong answer because of overflow)
Case 4 : − A + B (where B A)
A + B = (2 n − 1 − A) + B = 2 n + ( B − A) − 1
Case 5 : − A − B ( A + B 2 n−1 )
A + B = (2 n − 1 − A) + (2 n − 1 − B) = 2 n + [2 n − 1 − ( A + B)] − 1
31
1.5 Binary Codes (1)
9 3 7.2 5
1001 0011 0111 . 0010 0101
8-4-2-1
Decimal Code 6-3-1-1 Excess-3 2-out-of-5 Gray
Digit (BCD) Code Code Code Code
0 0000 0000 0011 00011 0000
1 0001 0001 0100 00101 0001
2 0010 0011 0101 00110 0011
3 0011 0100 0110 01001 0010
4 0100 0101 0111 01010 0110
5 0101 0111 1000 01100 1110
6 0110 1000 1001 10001 1010
7 0111 1001 1010 10010 1011
8 1000 1011 1011 10100 1001
9 1001 1100 1100 11000 1000
32
1.5 Binary Codes (2)
N = 6 1 + 3 0 + 11 + 11 = 8
33