L9 – Arithmetic Circuits 1 Comp 411 – Fall 2009 10/14/09 Arithmetic Circuits 01011 +00101 10000 Didn’t I learn how to do addition in the second grade?

Slides:



Advertisements
Similar presentations
ECE2030 Introduction to Computer Engineering Lecture 13: Building Blocks for Combinational Logic (4) Shifters, Multipliers Prof. Hsien-Hsin Sean Lee School.
Advertisements

L10 – Transistors Logic Math 1 Comp 411 – Spring /22/07 Arithmetic Circuits Didn’t I learn how to do addition in the second grade?
Comparator.
Arithmetic Functions and Circuits
Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19,
ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:
Tutorial: Wednesday Week 3 Hand in on Monday, Do the questions for tutorials 1 & 2 at the back of the course notes (answers to tutorial 3 will be published.
Computer Organization and Design Arithmetic & Logic Circuits Henry Fuchs Slides adapted from Montek Singh, who adapted them from Leonard McMillan and from.
Parallel Adder Recap To add two n-bit numbers together, n full-adders should be cascaded. Each full-adder represents a column in the long addition. The.
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.
Overview Iterative combinational circuits Binary adders
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Lecture 8 Arithmetic Logic Circuits
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
ECE 301 – Digital Electronics
Overview Iterative combinational circuits Binary adders
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Arithmetic Operations and Circuits Lecture 5. Binary Arithmetic let’s look at the procedures for performing the four basic arithmetic functions: addition,
CS 105 Digital Logic Design
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
Basic Arithmetic (adding and subtracting)
IKI a-Combinatorial Components Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Chapter 6-1 ALU, Adder and Subtractor
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Basic Arithmetic (adding and subtracting)
CHAPTER 4 Combinational Logic Design- Arithmetic Operation (Section 4.6&4.9)
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 8 Arithmetic.
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits
CPEN Digital System Design
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.
Addition and multiplication Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
Computer Organization and Design Arithmetic & Logic Circuits Montek Singh Nov 2, 2015 Lecture 11.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Addition and multiplication1 Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
Combinational Circuits
COMP541 Datapaths I Montek Singh Mar 28, 2012.
CSCI206 - Computer Organization & Programming
Addition and multiplication
Digital Systems Section 8 Multiplexers. Digital Systems Section 8 Multiplexers.
Computer Organization and Design Arithmetic & Logic Circuits
Computer Organization and Design Arithmetic & Logic Circuits
Computer Organization and Design Arithmetic & Logic Circuits
Arithmetic Circuits Didn’t I learn how
CSCI206 - Computer Organization & Programming
Computer Organization and Design Arithmetic & Logic Circuits
Arithmetic Circuits (Part I) Randy H
Digital Systems Section 12 Binary Adders. Digital Systems Section 12 Binary Adders.
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Addition and multiplication
Instructor: Mozafar Bag-Mohammadi University of Ilam
Addition and multiplication
ECE 352 Digital System Fundamentals
Combinational Circuits
Computer Organization and Design Arithmetic Circuits
Arithmetic and Logic Circuits
Presentation transcript:

L9 – Arithmetic Circuits 1 Comp 411 – Fall /14/09 Arithmetic Circuits Didn’t I learn how to do addition in the second grade? UNC courses aren’t what they used to be... Finally; time to build some serious functional blocks We’ll need a lot of boxes

L9 – Arithmetic Circuits 2 Comp 411 – Fall /14/09 Review: 2’s Complement … 2 N-2 -2 N-1 …… N bits 8-bit 2’s complement example: = – = – = – 42 If we use a two’s-complement representation for signed integers, the same binary addition procedure will work for adding both signed and unsigned numbers. By moving the implicit “binary” point, we can represent fractions too: = – = – = – “sign bit”“binary” point Range: – 2 N-1 to 2 N-1 – 1

L9 – Arithmetic Circuits 3 Comp 411 – Fall /14/09 Binary Addition Here’s an example of binary addition as one might do it by “hand”: A: 1101 B: Carries from previous column Adding two N-bit numbers produces an (N+1)-bit result Then we can cascade them to add two numbers of any size… A B CO CI S FA A B CO CI S FA A B CO CI S FA A B CO CI S FA A3 B3 A2 B2 A1 B1 A0 B0 S4 S3 S0 S1 S0 Let’s start by building a block that adds one column: called a “full adder” (FA) A B CO CI S FA

L9 – Arithmetic Circuits 4 Comp 411 – Fall /14/09 Designing a “Full Adder”: From Last Lecture 1) Start with a truth table: 2) Write down eqns for the “1” outputs C o = C i AB + C i AB + C i AB + C i AB S = C i AB + C i AB + C i AB + C i AB 3) Simplifying a bit (seems hard, but experienced designers are good at this art!) C o = C i (A + B) + AB S = C i  A  B C o = C i (A  B) + AB S = C i  (A  B)

L9 – Arithmetic Circuits 5 Comp 411 – Fall /14/09 For Those Who Prefer Logic Diagrams … A little tricky, but only 5 gates/bit CI A B S CO C o = C i (A  B) + AB S = C i  (A  B) “Sum” Logic “Carry” Logic

L9 – Arithmetic Circuits 6 Comp 411 – Fall /14/09 Subtraction: A-B = A + (-B) Using 2’s complement representation: –B = ~B + 1 But what about the “+1”? So let’s build an arithmetic unit that does both addition and subtraction. Operation selected by control input: A B CO CI S FA A B CO CI S FA A B CO CI S FA A B CO CI S FA A3 A2 A1 A0 S4 S3 S0 S1 S0 B3 B2 B1 B0 Subtract ~ = bit-wise complement B0B0 B B1B1 B

L9 – Arithmetic Circuits 7 Comp 411 – Fall /14/09 Condition Codes Besides the sum, one often wants four other bits of information from an arithmetic unit: To compare A and B, perform A–B and use condition codes: Signed comparison: LTN  V LEZ+(N  V) EQZ NE~Z GE~(N  V) GT~(Z+(N  V)) Unsigned comparison: LTUC LEUC+Z GEU~C GTU~(C+Z) To compare A and B, perform A–B and use condition codes: Signed comparison: LTN  V LEZ+(N  V) EQZ NE~Z GE~(N  V) GT~(Z+(N  V)) Unsigned comparison: LTUC LEUC+Z GEU~C GTU~(C+Z) V (overflow): indicates that the answer has too many bits to be represented correctly by the result width, e.g., “(2 i-1 - 1)+ (2 i-1 - 1)” Z (zero): result is = 0 big NOR gate N (negative): result is < 0 S N-1 C (carry): indicates that add in the most significant position produced a carry, e.g., “1 + (-1)” from last FA -or-

L9 – Arithmetic Circuits 8 Comp 411 – Fall /14/09 T PD of Ripple-Carry Adder Worse-case path: carry propagation from LSB to MSB, e.g., when adding 11…111 to 00…001. t PD = (t PD,XOR +t PD,AND + t PD,OR ) +(N-2)*(t PD,OR + t PD,AND ) + t PD,XOR   (N) CI to CO CI N-1 to S N-1  (N) is read “order N” and tells us that the latency of our adder grows in proportion to the number of bits in the operands. A B CO CI S FA A B CO CI S FA A B CO CI S FA A n-1 B n-1 A n-2 B n-2 A 2 B 2 A 1 B 1 A 0 B 0 S n-1 S n-2 S 2 S 1 S 0 A B CO CI S FA A B CO CI S FA C … CI A B S CO A,B to CO What is T PD ?? See Lec. 8.

L9 – Arithmetic Circuits 9 Comp 411 – Fall /14/09 Can we add faster? Yes, there are many sophisticated designs that are faster… – Carry-Lookahead Adders (CLA) – Carry-Skip Adders – Carry-Select Adders

L9 – Arithmetic Circuits 10 Comp 411 – Fall /14/09 Adder Summary Adding is not only common, but it is also tends to be one of the most time-critical of operations. As a result, a wide range of adder architectures have been developed that allow a designer to tradeoff complexity (in terms of the number of gates) for performance. Ripple Carry Carry Skip Carry Select Carry Lookahead Smaller / SlowerBigger / Faster Add AB S Add/Sub AB S sub At this point we’ll define a high-level functional unit for an adder, and specify the details of the implementation as necessary.

L9 – Arithmetic Circuits 11 Comp 411 – Fall /14/09 Shifting Logic Shifting is a common operation that is applied to groups of bits. Shifting can be used for alignment, as well as for arithmetic operations. X << 1 is often the same as 2*X X >> 1 can be the same as X/2 For example: X = = Left Shift: (X << 1) = = Right Shift: (X >> 1) = = Signed or “Arithmetic” Right Shift: (-X >>> 1) = ( >>> 1) = = R7R6R5R4R3R2R1R0R7R6R5R4R3R2R1R0 X7X6X5X4X3X2X1X0X7X6X5X4X3X2X1X0 “0” SHL1

L9 – Arithmetic Circuits 12 Comp 411 – Fall /14/09 Boolean Operations It will also be useful to perform logical operations on groups of bits. Which ones? ANDing is useful for “masking” off groups of bits. ex & = (mask selects last 4 bits) ANDing is also useful for “clearing” groups of bits. ex & = (0’s clear first 4 bits) ORing is useful for “setting” groups of bits. ex | = (1’s set last 4 bits) XORing is useful for “complementing” groups of bits. ex ^ = (1’s complement last 4 bits) NORing is useful for.. uhm… ex # = (0’s complement, 1’s clear)

L9 – Arithmetic Circuits 13 Comp 411 – Fall /14/09 Boolean Unit It is simple to build up a Boolean unit using primitive gates and a mux to select the function. Since there is no interconnection between bits, this unit can be simply replicated at each position. The cost is about 7 gates per bit. One for each primitive function, and approx 3 for the 4-input mux. This is a straightforward, but not too elegant of a design. AiAi BiBi QiQi Bool This logic block is repeated for each bit (i.e. 32 times)

L9 – Arithmetic Circuits 14 Comp 411 – Fall /14/09 An ALU, at Last Now we’re ready for a big one! An Arithmetic Logic Unit. That’s a lot of stuff Flags V,C AB R Bidirectional Shifter Boolean Add/Sub Sub Bool Shft Math 1 0 … N Flag Z Flag