3. Department of Electrical Engineering, NCTU 3
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Digital Systems:
A system that can perform data computation, storage and data
input and output in digital formats
Why digital systems instead of analog systems?
Easy and reliable control of data precision (number of bits)
Easy and reliable circuit implementations (on/off switch)
Applications of Digital Systems:
Computation, data processing, signal acquisition and processing,
automatic control, communications and measurements, etc
Input/Output
Interface
Arithmetic/Logic Unit
Data Storage
Control Unit
4. Department of Electrical Engineering, NCTU 4
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Design of digital systems includes 3 phases:
System design: design functions to meet specific applications
Logic design : implement functions in logic gates
Circuit design : design and implement logic gates
System design involves functional definitions and system
partitions. The aspect of system design varies a lot
Logic design means coming up with methods to
implement the defined functions, using basic logic units
Circuit design here refers to the implementations of basic
logic units such as AND, OR, Flip-Flops, etc. with
resistors, diodes and transistors
We will not cover circuit design in this course
5. Department of Electrical Engineering, NCTU 5
Logic Design Unit 1 Introduction Sau-Hsuan Wu
A simple digital system : Y = max { C, A+B}
If C > A+B
Y=C
else
Y=A+B
A simple logic implementation of the above system
Yes, C1=1
Start
A+B > C
Save Y
No, C1=0
C2
A B C
Adder
Comp
Mux
Y
C1
C2
6. Department of Electrical Engineering, NCTU 6
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Logic circuits can be categorized into two classes:
Combinational logic
Sequential Logic
Combinational logic’s outputs depend only on the
present inputs:
E.g. Adder, multiplier, comparator, multiplexer
Sequential logic’s output depend on both the present
and the past outputs. In general, a sequential circuit is
composed of a combinational circuit with added
memory elements.
E.g. C = A+B
E = C+D
F = CD
8. Department of Electrical Engineering, NCTU 8
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Base R representation of a rational number
Any positive integer R > 1 can be chosen as the base of a
number
E.g. : converting an octal number to decimal
3 82 + 2 81 + 1 80 + 1 8-1
= 192 + 16 + 1 + 0.125
= 208.125
4 3 2 1 0 1 2 3
4 3 2 1 0
4 3 2 1 0
1 2 3
1 2 3
( . )
0 1i
N a a a a a a a a
a R a R a R a R a R
a R a R a R
a R
其中where
9. Department of Electrical Engineering, NCTU 9
Logic Design Unit 1 Introduction Sau-Hsuan Wu
For bases greater than 10, more than 10 symbols are
needed to represent the digits
Letters are usually used to represent digits greater than 9
E.g., for a hexadecimal number, we have digits
0,1,2,3,…9,A,B,C,D,E,F
E.g. : converting a hexadecimal to decimal
A 162 + 2 161 + B 160 + F 16-1
= 10 256 + 2 16 + 11 + 15/16
= 2603.9375
10. Department of Electrical Engineering, NCTU 10
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Conversion of a decimal number to base R
10 2
For integer,
53 110101
53 2 26 1
26 2 13 0
13 2 6 1
6 2 3 0
3 2 1 1
使用除法
10 2
For fraction,
.625 .101
.625 2 1.25 1
.25 2 0.5 0
.5 2 1.0 1
使用乘法use division use multiplication
11. Department of Electrical Engineering, NCTU 11
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Conversion between two bases R1 & R2 other than
decimal
Convert from base R1 to decimal first, then convert the
decimal number to base R2
4 10 7231.3 45.75 63.5151
45 7 6 3
.75 7 5.25 5
.25 7 1.75 1
.75 7 5.25 5
13. Department of Electrical Engineering, NCTU 13
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Arithmetic operations in digital systems are usually done
in binary because design of logic circuits to perform
binary arithmetic is much simpler than decimal arithmetic
We only need switches: On 1, OFF 0
Binary addition
0 0 0
0 1 1
1 0 1
1 1 0 carry 1 to the next column
10
10
10
Ex.
1111 carries
13 = 1101
11 = 1011
24 11000
14. Department of Electrical Engineering, NCTU 14
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Binary subtraction
0 0 0
0 1 1 borrow 1 from the next column
1 0 1
1 1 0
Ex.
1 borrow
11101
10011
1010
18. Department of Electrical Engineering, NCTU 18
Logic Design Unit 1 Introduction Sau-Hsuan Wu
For signed integer (both positive and negative integers), the first bit
in a word is used as a sign bit, with 0 for plus and 1 for minus
There are 3 types of representations of negative numbers:
sign and magnitude, 2’s complement and 1’s complement
19. Department of Electrical Engineering, NCTU 19
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Sign and magnitude:
For an n-bit word, the first bit, the most significant bit (MSB), is the
sign and the remaining n-1 bits represent the magnitude
Ex. 0011=+3, 1011=-3
2’s complement:
A positive number is represented by a 0 followed by the magnitude
A negative number is represented by its 2’s complement N*:
N* = 2n –N
1’s complement:
A negative number, -N, is represented by its 1’s complement of N
defined as
Notice
Therefore, if
N* = 2n –N
(2 1)n
N N
2 1 111 11 (n bits)n
00110001100111 NN
00110011*
NN
20. Department of Electrical Engineering, NCTU 20
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Addition of 2’s complement numbers:
E.g. 4-bit word, n = 4
5 –6 = –1
5 + (2n –6) = 2n –1 2’s complement of 1
So the addition is carried out just as if the numbers were positive
The addition of two 4-bit words becomes a 5-bit word in general
Do sign extension before addition
E.g. 5 + 6 = 11
By sign extension 5 = 00101, 6 = 00110
5+6 = 01011
E.g. –5 –6 = –11
By sign extension, –5 24 –5 = 11010+1 = 11011
–6 24 –6 = 11001+1 = 11010
–11 25 –6 –5 = 10101 2’s complement of 11
21. Department of Electrical Engineering, NCTU 21
Logic Design Unit 1 Introduction Sau-Hsuan Wu
Addition of 1’s complement numbers:
Similar to 2’s complement except that instead of discarding the
last carry, it is added to the n-bit sum in the position furthest to
the right, least significant bit (LSB).
This is referred to as an end-around carry
–A+B (B > A) (2n 1 A) + B
= B A + (2n 1) removing (2n 1)
–A –B (A+B < 2n-1)
(2n 1 A) + (2n 1 B) = [2n 1 (A+B)] + (2n 1)
Similarly, do sign extension to protect from overflow
( 5) ( 6)
1010
0110
10000
1
0001
End-around carry