Professional Documents
Culture Documents
Lec05 - DS - 2018 - Print
Lec05 - DS - 2018 - Print
2018
Digital Systems
Arithmetic
BK
TP.HCM
dce
Introduction
2018
2
dce
Binary Addition
2018
3
dce
Binary Addition
2018
• 0+0=0
• 1+0=1
• 1 + 1 = 0 + carry 1
• 1 + 1 + 1 = 1 + carry 1
• E.g.:
1010 (10) 001 (1)
+1100 (12) +101 (5)
10110 (22) +111 (7)
1101 (13)
4
dce
Representing Signed Numbers
2018
5
dce
Representing Signed Numbers
2018
6
dce
Representing Signed Numbers
2018
• Unsigned number
7
dce
Examples of 2’s Complement
2018
8
dce
Why 2’s complement representation?
2018
27 0001 1011 b
- 17 0001 0001 b
+ 10 0000 1010 b
+ 27 0001 1011 b
+ - 17 1110 1111 b
+ 10 0000 1010 b
• Note that the range for 8-bit unsigned and signed numbers
are different.
• 8-bit unsigned: 0 …… +255
• 8-bit 2’s complement signed number: -128 …… +127
9
dce
Comparison Table
2018
10
dce
Sign Extension
2018
11
dce
Sign Extension
2018
12
dce
Representing Signed Numbers
2018
13
dce
Signed Addition
2018
15
dce
2018
16
dce
2018
17
dce
Multiplication and Division by 2N
2018
18
dce
Multiplication of Binary Numbers
2018
19
dce
Binary Division
2018
20
dce
2018
Summary of Signed and Unsigned Numbers
Unsigned Signed
MSB has a positive value (e.g. +8 MSB has a negative value (e.g. -8
for for
a 4-bit system) a 4-bit system)
The carry-out from the MSB of an To avoid overflow in an adder,
adder can be used as an extra bit need to sign extend and use an
of the answer to avoid overflow adder with one more bit than the
numbers to be added
21
dce
BCD Addition
2018
22
dce
Hexadecimal Arithmetic
2018
• Hex addition:
– Add the hex digits in decimal.
– If the sum is 15 or less express it directly in hex digits.
– If the sum is greater than 15, subtract 16 and carry 1 to the
next position.
• Hex subtraction – use the same method as for binary
numbers.
• When the MSD in a hex number is 8 or greater, the
number is negative. When the MSD is 7 or less, the
number is positive.
FFF – 3A5 = C5A
C5A + 1 = C5B is 2’s complement of 3A5
23
dce
Arithmetic Circuits
2018
• An arithmetic/logic unit
(ALU) accepts data
stored in memory and
executes arithmetic
and logic operations as
instructed by the
control unit.
24
dce
Arithmetic Circuits
2018
25
dce
Binary Addition
2018
26
dce
Parallel Binary Adder
2018
27
dce
Half Adder
2018
• Truth Table
• Boolean Equations
• Implementation
28
dce
Full Adder
2018
• Truth Table
• Boolean Equations
29
dce
2018
K maps for the full-adder outputs.
30
dce
Circuitry for a full adder
2018
31
dce
Full Adder from Half Adders
2018
• Truth Table
• Boolean Equations
32
dce
2018
Adder Example
33
dce
2018
Hierarchy
• Any Verilog design you do will be a module
• This includes testbenches!
34
dce
2018
Hierarchy
• Build up a module from smaller pieces
– Primitives
– Other modules (which may contain other
modules)
• Design: typically top-down
• Verification: typically bottom-up
Full Adder Hierarchy Add_full
Add_half Add_half or
Add_half Module
Add_half
xor and
36
dce
2018
Add_full Module
Add_full
Add_half Add_half or
37
dce
2018
input A, B, CI ;
output S, CO ;
endmodule
39
dce
2018
input A, B, CI;
output S, CO;
reg S, CO; // explained in later lecture – “holds” values
41
dce
2018
42
dce
2018
Complete Parallel Adder With Registers
43
dce
Carry Propagation
2018
44
dce
2018
Design a carry look-ahead adder
45
dce
Integrated Circuit Parallel Adder
2018
46
dce Parallel adder used to add and subtract numbers
2018
in 2’s-complement system.
47
dce 2’s Complement Addition using 1’s Complement
2018
Operands
Parallel adder used to perform subtraction (A – B) using the 2’s-
complement system. The bits of the subtrahend (B) are inverted
(1’s complement), and C0 = 1 to produce the 2’s complement
48
dce Parallel adder/subtractor using the 2’s-
2018
complement system
ADD = 1, SUB = 0:
B register passes to adder
and Carry in = 0
ADD = 0, SUB = 1:
Complement of B register
passes to adder and Carry
in = 1
49
dce
2018
ALU Integrated Circuits
eight-bit adder
51