FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Topics n Number representation. n Shifters. n Adders and ALUs.

Slides:



Advertisements
Similar presentations
1 ECE 4436ECE 5367 Computer Arithmetic I-II. 2 ECE 4436ECE 5367 Addition concepts 1 bit adder –2 inputs for the operands. –Third input – carry in from.
Advertisements

Introduction So far, we have studied the basic skills of designing combinational and sequential logic using schematic and Verilog-HDL Now, we are going.
Chapter 9 Computer Design Basics. 9-2 Datapaths Reminding A digital system (or a simple computer) contains datapath unit and control unit. Datapath: A.
Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19,
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI Circuit Design Lecture 24 - Subsystem.
1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.
S. Reda EN160 SP’07 Design and Implementation of VLSI Systems (EN0160) Lecture 28: Datapath Subsystems 2/3 Prof. Sherief Reda Division of Engineering,
Modern VLSI Design 2e: Chapter 6 Copyright  1998 Prentice Hall PTR Topics n Multipliers.
Digital Integrated Circuits 2e: Chapter Copyright  2002 Prentice Hall PTR, Adapted by Yunsi Fei ECE 300 Advanced VLSI Design Fall 2006 Lecture.
EECS Components and Design Techniques for Digital Systems Lec 18 – Arithmetic II (Multiplication) David Culler Electrical Engineering and Computer.
1 Lecture 4: Arithmetic for Computers (Part 3) CS 447 Jason Bakos.
CSE477 VLSI Digital Circuits Fall 2002 Lecture 20: Adder Design
Computer Structure - The ALU Goal: Build an ALU  The Arithmetic Logic Unit or ALU is the device that performs arithmetic and logical operations in the.
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Modern VLSI Design 2e: Chapter 6 Copyright  1998 Prentice Hall PTR Topics n Shifters. n Adders and ALUs.
Digital Arithmetic Wen-Hung Liao, Ph.D.. Objectives Perform binary addition, subtraction, multiplication, and division on two binary numbers. Add and.
Digital Integrated Circuits© Prentice Hall 1995 Arithmetic Arithmetic Building Blocks.
ECE 301 – Digital Electronics
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Combinational Circuits Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer, 2003.
Chapter 6-2 Multiplier Multiplier Next Lecture Divider
Logical Circuit Design Week 8: Arithmetic Circuits Mentor Hamiti, MSc Office ,
1. Copyright  2005 by Oxford University Press, Inc. Computer Architecture Parhami2 Figure 10.1 Truth table and schematic diagram for a binary half-adder.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
+ CS 325: CS Hardware and Software Organization and Architecture Combinational Circuits 1.
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Fall 2004EE 3563 Digital Systems Design EE 3563 Comparators  Comparators determine if two binary inputs are equal  Some will signal greater than/less.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Advanced VLSI Design Unit 05: Datapath Units. Slide 2 Outline  Adders  Comparators  Shifters  Multi-input Adders  Multipliers.
EECS Components and Design Techniques for Digital Systems Lec 16 – Arithmetic II (Multiplication) David Culler Electrical Engineering and Computer.
FPGA-Based System Design: Chapter 4 Copyright  2004 Prentice Hall PTR Topics n Multipliers.
1 CPSC3850 Adders and Simple ALUs Simple Adders Figures 10.1/10.2 Binary half-adder (HA) and full-adder (FA). Digit-set interpretation: {0, 1}
Chap 7. Register Transfers and Datapaths. 7.1 Datapaths and Operations Two types of modules of digital systems –Datapath perform data-processing operations.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Modern VLSI Design 4e: Chapter 6 Copyright  2008 Wayne Wolf Topics n Shifters. n Adders and ALUs.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
EE 466/586 VLSI Design Partha Pande School of EECS Washington State University
EE141 © Digital Integrated Circuits 2nd Arithmetic Circuits 1 Digital Integrated Circuits A Design Perspective Arithmetic Circuits Jan M. Rabaey Anantha.
Ch3b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University There is logic to it andRd, Rs, RtRd
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
COMP541 Arithmetic Circuits
Computer Architecture Lecture 3 Combinational Circuits Ralph Grishman September 2015 NYU.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
COMP541 Arithmetic Circuits
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
Digital Integrated Circuits 2e: Chapter Copyright  2002 Prentice Hall PTR, Adapted by Yunsi Fei ECE 300 Advanced VLSI Design Fall 2006 Lecture.
Copied with Permission from prof. Mark PSU ECE
Addition, Subtraction, Logic Operations and ALU Design
ECE/CS 552: Arithmetic I Instructor:Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes partially based on set created by Mark Hill.
1. 2 Figure 10.1 Truth table and schematic diagram for a binary half-adder Simple Adders Half-adder.
Computer Organization and Design Arithmetic & Logic Circuits Montek Singh Nov 2, 2015 Lecture 11.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
EE141 Arithmetic Circuits 1 Chapter 14 Arithmetic Circuits Rev /12/2003 Rev /05/2003.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Topic: N-Bit parallel and Serial adder
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
1 Design of Datapath elements in Digital Circuits Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT.
Combinational Circuits
Topics Number representation. Shifters. Adders and ALUs.
Combinational Circuits
Lecture 9 Digital VLSI System Design Laboratory
Presentation transcript:

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Topics n Number representation. n Shifters. n Adders and ALUs.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Signed number representations n One’s complement: –3 = 0101 –-3 = ~(0101) = 1010 –Two zeroes: 0000, 1111 n Two’s complement: –3 = 0101 –-3 = ~(0101) +1 = 1011 –One zero: 0000

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Representations and arithmetic N =  2 i b i n Test for zero: all bits are 0. n Test for negative: sign bit is 1. n Subtraction: negate then add. –a – b = a + (-b) = a + (~b+1)

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Combinational shifters n Useful for arithmetic operations, bit field extraction, etc. n Latch-based shift register can shift only one bit per clock cycle. n A multiple-shift shifter requires additional connectivity.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Barrel shifter n Can perform n-bit shifts in a single cycle.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Barrel shifter structure Accepts 2n data inputs and n control signals, producing n data outputs. data 1 data 2 n bits output n bits

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Barrel shifter operation n Selects arbitrary contiguous n bits out of 2n input buts. n Examples: –right shift: data into top, 0 into bottom; –left shift: 0 into top, data into bottom; –rotate: data into top and bottom.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for barrel shifter module shifter(data,b,result); parameter Nminus1 = 31; /* 32-bit shifter */ input [Nminus1:0] data; /* compute parity of these bits */ input [3:0] b; /* amount to shift */ output [Nminus1:0] result; /* shift result */ assign result = data << b; endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Adders n Adder delay is dominated by carry chain. n Carry chain analysis must consider transistor, wiring delay. n Modern VLSI favors adder designs which have compact carry chains.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Full adder n Computes one-bit sum, carry: –s i = a i XOR b i XOR c i –c i+1 = a i b i + a i c i + b i c i n Half adder computes two-bit sum. n Ripple-carry adder: n-bit adder built from full adders. n Delay of ripple-carry adder goes through all carry bits.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for full adder module fulladd(a,b,carryin,sum,carryout); input a, b, carryin; /* add these bits*/ output sum, carryout; /* results */ assign {carryout, sum} = a + b + carryin; /* compute the sum and carry */ endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for ripple-carry adder module nbitfulladd(a,b,carryin,sum,carryout) input [7:0] a, b; /* add these bits */ input carryin; /* carry in*/ output [7:0] sum; /* result */ output carryout; wire [7:1] carry; /* transfers the carry between bits */ fulladd a0(a[0],b[0],carryin,sum[0],carry[1]); fulladd a1(a[1],b[1],carry[1],sum[1],carry[2]); … fulladd a7(a[7],b[7],carry[7],sum[7],carryout]); endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-lookahead adder n First compute carry propagate, generate: –P i = a i + b i –G i = a i b i n Compute sum and carry from P and G: –s i = c i XOR P i XOR G i –c i+1 = G i + P i c i

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-lookahead expansion n Can recursively expand carry formula: –c i+1 = G i + P i (G i-1 + P i-1 c i-1 ) –c i+1 = G i + P i G i-1 + P i P i-1 (G i-2 + P i-1 c i-2 ) n Expanded formula does not depend on intermerdiate carries. n Allows carry for each bit to be computed independently.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Depth-4 carry-lookahead

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Analysis n Deepest carry expansion requires gates with large fanin: large, slow. n Carry-lookahead unit requires complex wiring between adders and lookahead unit—values must be routed back from lookahead unit to adder. n Layout is even more complex with multiple levels of lookahead.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for carry-lookahead carry block module carry_block(a,b,carryin,carry); input [3:0] a, b; /* add these bits*/ input carryin; /* carry into the block */ output [3:0] carry; /* carries for each bit in the block */ wire [3:0] g, p; /* generate and propagate */ assign g[0] = a[0] & b[0]; /* generate 0 */ assign p[0] = a[0] ^ b[0]; /* propagate 0 */ assign g[1] = a[1] & b[1]; /* generate 1 */ assign p[1] = a[1] ^ b[1]; /* propagate 1 */ … assign carry[0] = g[0] | (p[0] & carryin); assign carry[1] = g[1] | p[1] & (g[0] | (p[0] & carryin)); assign carry[2] = g[2] | p[2] & (g[1] | p[1] & (g[0] | (p[0] & carryin))); assign carry[3] = g[3] | p[3] & (g[2] | p[2] & (g[1] | p[1] & (g[0] | (p[0] & carryin)))); endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for carry-lookahead sum unit module sum(a,b,carryin,result); input a, b, carryin; /* add these bits*/ output result; /* sum */ assign result = a ^ b ^ carryin; /* compute the sum */ endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for carry-lookahead adder module carry_lookahead_adder(a,b,carryin,sum,carryout); input [15:0] a, b; /* add these together */ input carryin; output [15:0] sum; /* result */ output carryout; wire [16:1] carry; /* intermediate carries */ assign carryout = carry[16]; /* for simplicity */ /* build the carry-lookahead units */ carry_block b0(a[3:0],b[3:0],carryin,carry[4:1]); carry_block b1(a[7:4],b[7:4],carry[4],carry[8:5]); carry_block b2(a[11:8],b[11:8],carry[8],carry[12:9]); carry_block b3(a[15:12],b[15:12],carry[12],carry[16:13]); /* build the sum */ sum a0(a[0],b[0],carryin,sum[0]); sum a1(a[1],b[1],carry[1],sum[1]); … sum a15(a[15],b[15],carry[15],sum[15]); endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-skip adder n Looks for cases in which carry out of a set of bits is identical to carry in. n Typically organized into b-bit stages. n Can bypass carry through all stages in a group when all propagates are true: P i P i+1 … P i+b-1. –Carry out of group when carry out of last bit in group or carry is bypassed.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Two-bit carry-skip structure AND PiPi P i+1 P i+b-1 … OR C i+b-1 cici

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-skip structure b adder stages skip P[0,b-1] Carry out b adder stages skip P[b,2b-1] Carry out b adder stages skip P[2b,3b-1] Carry out

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Worst-case carry-skip n Worst-case carry-propagation path goes through first, last stages:

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for carry-skip add with P module fulladd_p(a,b,carryin,sum,carryout,p); input a, b, carryin; /* add these bits*/ output sum, carryout, p; /* results including propagate */ assign {carryout, sum} = a + b + carryin; /* compute the sum and carry */ assign p = a | b; endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for carry-skip adder module carryskip(a,b,carryin,sum,carryout); input [7:0] a, b; /* add these bits */ input carryin; /* carry in*/ output [7:0] sum; /* result */ output carryout; wire [8:1] carry; /* transfers the carry between bits */ wire [7:0] p; /* propagate for each bit */ wire cs4; /* final carry for first group */ fulladd_p a0(a[0],b[0],carryin,sum[0],carry[1],p[0]); fulladd_p a1(a[1],b[1],carry[1],sum[1],carry[2],p[1]); fulladd_p a2(a[2],b[2],carry[2],sum[2],carry[3],p[2]); fulladd_p a3(a[3],b[3],carry[3],sum[3],carry[4],p[3]); assign cs4 = carry[4] | (p[0] & p[1] & p[2] & p[3] & carryin); fulladd_p a4(a[4],b[4],cs4, sum[4],carry[5],p[4]); … assign carryout = carry[8] | (p[4] & p[5] & p[6] & p[7] & cs4); endmodule

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Delay analysis n Assume that skip delay = 1 bit carry delay. n Delay of k-bit adder with block size b: –T = (b-1) (k/b –2) + (b-1) block 0 OR gate skips last block n For equal sized blocks, optimal block size is sqrt(k/2).

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-select adder n Computes two results in parallel, each for different carry input assumptions. n Uses actual carry in to select correct result. n Reduces delay to multiplexer.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-select structure

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-save adder n Useful in multiplication. n Input: 3 n-bit operands. n Output: n-bit partial sum, n-bit carry. –Use carry propagate adder for final sum. n Operations: –s = (x + y + z) mod 2. –c = [(x + y + z) –2] / 2.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR FPGA delay model n Xing/Yu---ripple-carry adder: –n-stage adder divided into x blocks; –each block has n/x stages; –block k, 1<= k <= x. n Delays: –ripple-carry R(y k ) = 1 +  y k –carry-generate G(y k ) = 2 +  y k -1) –carry-terminate T(y k ) = G(y k ) # stages in block k constant Delay of a single stage

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Carry-skip delay model n Consider only inter-CLB delay. n Delay dominated by interconnect: –S(y k ) = 3 +  l 2 n Wire length l is proportional to the number of carry-skip layers.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Adder comparison n Ripple-carry adder has highest performance/cost. n Optimized adders are most effective in very long bit widths (> 48 bits).

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR © 1998 IEEE

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Serial adder n May be used in signal-processing arithmetic where fast computation is important but latency is unimportant. n Data format (LSB first): 0110 LSB

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Serial adder structure LSB control signal clears the carry shift register:

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR ALUs n ALU computes a variety of logical and arithmetic functions based on opcode. n May offer complete set of functions of two variables or a subset. n ALU built around adder, since carry chain determines delay.

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR ALU as multiplexer n Compute functions then select desired one: opcode AND OR NOT SUM

FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Verilog for ALU ‘define PLUS 0 ‘define MINUS 1 ‘define AND 2 ‘define OR 3 ‘define NOT 4 module alu(fcode,op0,op1,result,oflo); parameter n=16, flen=3; input [flen-1:0] fcode; [n-1:0] op0, op1; output [n-1:0] result; output oflo; assign {oflo,result} = (fcode == ‘PLUS) ? (op0 + op1) : (fcode == ‘MINUS) ? (op0 - op1) : (fcode == ‘AND) ? (op0 & op1) : (fcode == ‘OR) ? (op0 | op1) : (fcode == ‘NOT) ? (~op0) : 0; endmodule