Lecture 12 Modular Design Topics Adder and Subtractor Design

Slides:



Advertisements
Similar presentations
Kuliah Rangkaian Digital Kuliah 7: Unit Aritmatika
Advertisements

ECE2030 Introduction to Computer Engineering Lecture 13: Building Blocks for Combinational Logic (4) Shifters, Multipliers Prof. Hsien-Hsin Sean Lee School.
Chapter 4 -- Modular Combinational Logic. Decoders.
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
Comparator.
ECE 331 – Digital System Design
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Chapter # 5: Arithmetic Circuits Contemporary Logic Design Randy H
Lecture 8 Arithmetic Logic Circuits
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
ECE 301 – Digital Electronics
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,
Lecture # 12 University of Tehran
Digital Arithmetic and Arithmetic Circuits
ADDERS Half Adders Recall that the basic rules of binary addition are as indicated below in Table 2-9. A circuit known as the half-adder carries out these.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
5-1 Programmable and Steering Logic Chapter # 5: Arithmetic Circuits.
Computing Systems Designing a basic ALU.
درس مدارهای منطقی دانشگاه قم مدارهای منطقی محاسباتی تهیه شده توسط حسین امیرخانی مبتنی بر اسلایدهای درس مدارهای منطقی دانشگاه.
Arithmetic Functions BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
COE 202: Digital Logic Design Combinational Circuits Part 2 KFUPM Courtesy of Dr. Ahmad Almulhem.
9/15/09 - L15 Decoders, Multiplexers Copyright Joanne DeGroat, ECE, OSU1 Decoders and Multiplexer Circuits.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 8 Arithmetic.
COMP541 Arithmetic Circuits
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
1 Carry Lookahead Logic Carry Generate Gi = Ai Bi must generate carry when A = B = 1 Carry Propagate Pi = Ai xor Bi carry in will equal carry out here.
Copied with Permission from prof. Mark PSU ECE
CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits
1 Lecture 14 Binary Adders and Subtractors. 2 Overview °Addition and subtraction of binary data is fundamental Need to determine hardware implementation.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
ECE 3110: Introduction to Digital Systems Chapter 5 Combinational Logic Design Practices Adders,subtractors, ALUs.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
Lecture 12 Logistics Last lecture Today HW4 due today Timing diagrams
Subtitle: How to design the data path of a processor.
Lecture Adders Half adder.
Swamynathan.S.M AP/ECE/SNSCT
Addition and multiplication
Combinational Logic Logic circuits for digital systems may be combinational or sequential. A combinational circuit consists of input variables, logic gates,
Digital Systems Section 8 Multiplexers. Digital Systems Section 8 Multiplexers.
Reference: Moris Mano 4th Edition Chapter 4
Principles & Applications
Summary Half-Adder Basic rules of binary addition are performed by a half adder, which has two binary inputs (A and B) and two binary outputs (Carry out.
Combinational Circuits
ECE 331 – Digital System Design
CSE Winter 2001 – Arithmetic Unit - 1
Topic 3b Computer Arithmetic: ALU Design
Lecture 14 Logistics Last lecture Today
Arithmetic Functions & Circuits
Computer Organization and Design Arithmetic & Logic Circuits
Arithmetic Circuits (Part I) Randy H
EE207: Digital Systems I, Semester I 2003/2004
Unit 5 COMBINATIONAL CIRCUITS-1
Topic 3b Computer Arithmetic: ALU Design
Digital Systems Section 12 Binary Adders. Digital Systems Section 12 Binary Adders.
Digital System Design Combinational Logic
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Addition and multiplication
Lecture 14 Logistics Last lecture Today
Overview Iterative combinational circuits Binary adders
Addition and multiplication
ECE 352 Digital System Fundamentals
74LS283 4-Bit Binary Adder with Fast Carry
Electronics for Physicists
Lecture 9 Digital VLSI System Design Laboratory
Arithmetic Circuits.
Presentation transcript:

Lecture 12 Modular Design Topics Adder and Subtractor Design Multiplier Design ALU Design

Adders and Subtractors

The Half Adder A0 + B0 CO1 S0 A0 B0 C01 S0 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0

Half Subtractor A0 - B0 BO1 D0 A0 B0 B01 D0 0 0 0 0 0 1 1 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 Contrast with Half Adder: same equation for D0! But BO1 and CO1 are different. Must complement A0. Can build HS from HA by Inverting A0, then inverting S bit to correct.

The Full Adder Consider a circuit to add two 4-bit numbers: A3 A2 A1 A0 + B3 B2 B1 B0 CO4 S3 S2 S1 S0 Truth table would have 8 inputs (28 = 256 rows) and 5 outputs, requiring 5 minimized functions (5 8-variable K-maps). But operation at each bit position (after A0/B0) is identical: COi Ai + Bi COi+1 Si “bit slice”

Full Adder Truth Table CI A B CO S 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1

Ripple Carry Adders

Ripple Carry Adder A1 A0 + B1 B0 CO2 S1 S0

Modular Two Bit Adder/Subtractor This is one of the reasons we choose 2s complement for representing negative numbers! Increment and decrement Increment: +1 (just use CI) Decrement: -1 (use all 1s)

XOR Application: Twos Complement 4 bit adder/subtractor circuit from Chapter 1 showing XOR to form twos complement (RC)

Propagation Delay in Ripple Adder Assuming S is implemented using AND, OR, NOT S: Tpd = 3 tp CO: Tpd = 2 tp Can use HA for first bit and knock off 1 Tp

Partition Carry-Out Logic Settling time for n stage ripple adder ST = 3tp + (n-1)(2tp) = (2n+1)tp S of MSB stage C of remaining earlier n-1 stages Let’s look at what happens if we pull the carry-out portion of the logic out of the FA… If we use HA the CO1 is computed by a single AND gate (Tp)

Using HA for LSB Stage If we use HA for 1st stage (no CI) ST = 3tp + (n-2)(2tp) + tp = (2n)tp

Carry Look Ahead Adders

Carry Look-Ahead Adder Con+1 logic not dependent upon entire prior stage (COn) logic

Intuitively, you can think of it in this way… G (carry generate) is dependent upon current stage's ability to generate a carry. P (carry propagate) is dependent upon current (and prior) stages’ ability to propagate a carry. A carry is generated at a stage i if it is generated by stage i’s inputs (Ai,Bi) or by any prior stage and propagated by every succeeding stage. We can re-arrange the Cout equation, a defining G = A & B and P = A + B to get… Intuitively, you can think of it in this way… Alternatively, you can back substitute and observe that because we can generate all the P and G terms in one Tpd we are no longer dependent on Cout of previous stage

Carry Look-Ahead Adder Con+1 logic not dependent upon entire prior stage (COn) logic Uses: G0 through Gn-1 and P1 through Pn-1 Settling Time = 6tp (constant) for 3 or more stages Look closely at Tpd – not cumulative through the carry look-ahead part. Doesn’t use previous carry-out stage

Speed Up Improvement Conclusion Ripple Carry Adder (n) Stages using HA for LSB (2n)Tp Carry Look-Ahead Adder (n) Stages (using SOP) 6Tp Speed up for n stage adder ((2n)Tp-6Tp)/(2nTp) Assume Tp =1 and 4 stages: (2 x 4 – 6)/(2 x 4)= =2/8 =25% Conclusion Assuming Carry Look-Ahead we have 25% speedup for 4 stages

Speed Up Improvement Conclusion Ripple Carry Adder (n) Stages using HA for LSB (2n)Tp Carry Look-Ahead Adder (n) Stages (using SOP) 5Tp Speed up for n stage adder ((2n)Tp-5Tp)/(2n)Tp) Assume 4 stages (2 x 4 – 5)/(2 x 4) 3/8 37.5% changed Conclusion Assuming Carry Look-Ahead we have 37.5% speedup for 4 stages

Limits to Speed Up Carry generation G0 of first stage must be capable of driving all succeeding stages Each succeeding stage requires gates with increasing number of inputs (fan-in) Gate count increases with each stage

Expandable Carry Look-Ahead Adder 74LS83A & 74LS283 74LS83A: change slide after checking Wakerly? Actual device sum is 24ns and carry is 17 and gate equivalent description confirms 4 Tpd for Sum, 3Tpd for CO4. Carry look ahead used internally.

Wallace Trees

Carry-Save Adders (Wallace Tree Summing Network) Adding more than two operands with full adders (A,B,CI,CO) A0 B0 + C0 S10 CO11 + D0 S21 S20 CO21 + E0 S31 S30 CO32 CO31 + CO42_________ S42 S41 S40

Carry-Save Adders

Multipliers

Multiplier Design M x N bit multiplier requires M+N bit result: 2M x 2N = 2M+N Consider a 2-bit x 2-bit binary multiplier 11 x11 + 11.. 1001 multiplicand multiplier partial product 0 partial product 1 result A0 B0 A0xB0 A0×B0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 Truth tables quickly become unmanageable –use modular approach Every partial product can be obtained from an AND operation Use ripple or carry look-ahead adder to add two sets of partial products Use carry save adder to add more than two sets of partial products

Example: 3-bit x 3-bit Multiplier Using Ripple Adders

Example: 3-bit x 3-bit Multiplier Using Ripple Adders A2 A1 A0 x B2 B1 B0 P20 P10 P00 + P21 P11 P01…….. S40 S30 S20 S10 S00 + P22 P12 P02……………….. R5 R4 R3 R2 R1 R0 multiplicand multiplier partial product 0 partial product 1 partial sum 0 partial product 2 partial sum 1 (result) 9 partial products (9 AND gates) 2 rows of adders Pmn = Am x Bn

Multiplier Using Ripple Carry Adders

Pmn = Am x Bn A2 A1 A0 x B2 B1 B0 P20 P10 P00 + P21 P11 P01…….. S40 S30 S20 S10 S00 + P22 P12 P02XXXXXXXX R5 R4 R3 R2 R1 R0 multiplicand multiplier partial product 0 partial product 1 partial sum 0 partial product 2 partial sum 1 (result) Using ripple carry adder

Example: 3-bit x 3-bit Multiplier Using Carry Save Adder

Multiplier Using Carry Save Adder Can use the Wallace Summing Tree (Carry Save) Adder

ALUs – Arithmetic Logic Units

ALUs – Arithmetic Logic Units Computational heart of a computer M (mode) selects arithmetic or logic mode S (select) selects operations M S0 F and CO Comment 0 0 A+CI Increment A if CI == 1 0 1 A+B+CI Add A+B with carry 1 0 A OR B A OR B 1 1 A Å B A XOR B 1-bit slice (because of CO, capable of being expanded)

Modular ALU Implementation M S0 F and CO 0 0 A+CI 0 1 A+B+CI 1 0 A OR B 1 1 A Å B

ALUs – Arithmetic Logic Units

Hierarchical Implementation of 16-bit ALU

Hierarchical Implementation of 16-bit ALU

Hierarchical Implementation of 16-bit ALU …

Still Better… module ALUnBit(F,CO,A,B,CI,M,S); parameter nBITS = 16; input [nBITS-1:0] A,B; input CI, M, S; output [nBITS-1:0] F; output CO; wire C[nBITS:0]; genvar i; assign C[0] = CI; assign CO = C[nBITS]; generate for (i=0; i < nBITS; i = i+1) begin:ALU ALUSlice m (F[i],C[i+1],A[i],B[i],C[i],M,S); end endgenerate endmodule

Parameters Can have multiple instances (each of different sizes)! module ALUnBit(F,CO,A,B,CI,M,S); parameter nBITS = 16; input [nBITS-1:0] A,B; input CI, M, S; output [nBITS-1:0] F; output CO; wire C[nBITS:0]; genvar i; assign C[0] = CI; assign CO = C[nBITS]; generate for (i=0; i < nBITS; i = i+1) begin:ALU ALUSlice m (F[i],C[i+1],A[i],B[i],C[i],M,S); end endgenerate endmodule module Processor(…); ALUnBit ALUa (…) ALUnBit #(32) ALUb (…); . ALUnBit #(64) ALUc (…); endmodule Creates three instances of ALUnBit – one using nBITS = 16 (default), another using nBITS = 32, and another using nBITS = 64 Can have multiple instances (each of different sizes)!

Parameters module RAM( clk , // Clock Input address , // Address Input data , // Data bi-directional cs , // Chip Select we , // Write Enable/Read Enable oe // Output Enable ); parameter DATA_WIDTH = 8 ; parameter ADDR_WIDTH = 8 ; parameter RAM_DEPTH = 1 << ADDR_WIDTH; // Actual code of RAM here endmodule module RAMcontroller ();//Some ports RAM #(.DATA_WIDTH(16), .ADDR_WIDTH(8), .RAM_DEPTH(256)) R1(clk,address,data,cs,we,oe);

ALUs 32-bit ALU Typical ALU Operations

Sources Prof. Mark Faust John Wakerly