Академический Документы
Профессиональный Документы
Культура Документы
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-1
Syllabus
Objectives Addition and subtraction Multiplication Division Arithmetic and logic unit
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-2
Objectives
After completing this chapter, you will be able to: Describe both addition and subtraction modules Understand the principles of carry-look-ahead (CLA) adder Understand the essential ideas of parallel-prefix adders Describe the basic operations of multiplication Describe the basic operations of division Describe the designs of arithmetic-logic unit (ALU)
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley 14-3
Syllabus
Objectives Addition and subtraction
Carry-look-ahead (CLA) adders Parallel-prefix adders
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-4
others
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-5
A CLA adder
Definition
carry generate (gi): gi = xi yi carry propagate (pi): pi = xi yi
si = pi ci ci +1 = g i + pi ci
c1 = g 0 + p0c0
c2 = g1 + p1c1 = g1 + p1 ( g 0 + p0c0 ) = g1 + p1 g 0 + p1 p0 g 0
14-6
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
A Carry-Lookahead Generator
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-7
A CLA Adder
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-8
A CLA Adder
// a 4-bit CLA adder using assign statements module cla_adder_4bits(x, y, cin, sum, cout); // inputs and outputs input [3:0] x, y; input cin; output [3:0] sum; output cout; // internal wires wire p0,g0, p1,g1, p2,g2, p3,g3; wire c4, c3, c2, c1; // compute the p for each stage assign p0 = x[0] ^ y[0], p1 = x[1] ^ y[1], p2 = x[2] ^ y[2], p3 = x[3] ^ y[3];
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley 14-9
A CLA Adder
// compute the g for each stage assign g0 = x[0] & y[0], g1 = x[1] & y[1], g2 = x[2] & y[2], g3 = x[3] & y[3]; // compute the carry for each stage assign c1 = g0 | (p0 & cin), c2 = g1 | (p1 & g0) | (p1 & p0 & cin), c3 = g2 | (p2 & g1) | (p2 & p1 & g0) | (p2 & p1 & p0 & cin), c4 = g3 | (p3 & g2) | (p3 & p2 & g1) | (p3 & p2 & p1 & g0) | (p3 & p2 & p1 & p0 & cin); // compute Sum assign sum[0] = p0 ^ cin, sum[1] = p1 ^ c1, sum[2] = p2 ^ c2, sum[3] = p3 ^ c3; // assign carry output assign cout = c4; endmodule
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley 14-10
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-11
Syllabus
Objectives Addition and subtraction
Carry-look-ahead (CLA) adder Parallel-prefix adders
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-13
Parallel-Prefix Adders
The prefix sums s[i,0] = xi ~xi-1~ ~x1 ~x0
where 0 i < n
From bits k to i
g[ i ,k ] = g[ i , j +1] + p[ i , j +1] g[ j ,k ] p[ i ,k ] = pi , j +1] p[ j ,k ] where 0 i < n, k j < i, 0 k < n
g[i ,i ] = xi yi p[i ,i ] = xi yi
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley 14-14
Parallel-Prefix Adders
The carry of ith-bit adder ci = gi 1 + pi 1 ci 1 can be written as
g[ i ,0] = g[ i , j +1] + p[ i , j +1] g[ j ,0]
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-15
Parallel-Prefix Adders
The operator ~ in w[i,k] = w[i,j+1]~w[j,k] is a binary associative operator.
ci = gi 1 + pi 1 ci 1 g[ i ,0] = g[ i , j +1] + p[ i , j +1] g[ j ,0]
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-16
Kogge-Stone Adder
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-17
Brent-Kung Adder
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-18
Parallel-Prefix Adders
An n-input Kogge-Stone parallel-prefix network
a propagation delay of log2n levels a cost of nlog2n - n + 1 cells
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-19
Syllabus
Objectives Addition and subtraction Multiplication
Shift-and-add multiplication Basic array multipliers A signed array multiplier
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-20
Shift-and-Add Multiplication
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-21
Shift-and-Add Multiplication
A sequential implementation
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-22
Syllabus
Objectives Addition and subtraction Multiplication
Shift-and-add multiplication Basic array multipliers A signed array multiplier
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-23
P = X Y = xi 2 y j 2 (xi y j ) 2
i j i =0 j =0 i =0 j =0
m1
n 1
m1 n 1
i+ j
m+ n 1 k =0
(Pk ) 2k
14-24
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-25
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-26
Syllabus
Objectives Addition and subtraction Multiplication
Shift-and-add multiplication Basic array multipliers A signed array multiplier
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-27
+ xi 2i
i =0
m2
Y = yn1 2
P = XY
n 1
+ yj2j
j =0
n2
m2 n2 m 1 i n 1 j = xm1 2 + xi 2 yn1 2 + y j 2 i =0 j =0
= xi y j 2
i =0 j =0
m2 n2
i+ j
+ xm1 yn1 2
m+ n2
n2 m2 i + n 1 j + m1 x y 2 x y 2 + i n 1 m1 j i = j = 0 0
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-28
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-29
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-30
Syllabus
Objectives Addition and subtraction Multiplication Division
Nonrestoring division algorithm Implementations
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-31
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-32
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-33
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-34
Syllabus
Objectives Addition and subtraction Multiplication Division
Nonrestoring division algorithm Implementations
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-35
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-36
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-37
Syllabus
Objectives Addition and subtraction Multiplication Division Arithmetic and logic unit
Basic functions Implementations
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-38
Arithmetic-Logic Units
Arithmetic unit
addition subtraction multiplication division
Logical unit
AND OR NOT
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-39
Shift Operations
Logical shift
Logical left shift Logical right shift
Arithmetic shift
Arithmetic left shift Arithmetic right shift
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-40
Syllabus
Objectives Addition and subtraction Multiplication Division Arithmetic and logic unit
Basic functions Implementations
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-41
Arithmetic-Logic Units
Digital System Designs and Practices Using Verilog HDL and FPGAs @ 2008-2010, John Wiley
14-42