Computer Organization and Design Arithmetic Circuits

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,
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.
Computer Organization and Design Arithmetic & Logic Circuits Henry Fuchs Slides adapted from Montek Singh, who adapted them from Leonard McMillan and from.
L9 – Arithmetic Circuits 1 Comp 411 – Fall /14/09 Arithmetic Circuits Didn’t I learn how to do addition in the second grade?
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 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)
Digital Arithmetic and Arithmetic Circuits
IKI a-Combinatorial Components Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
Chapter 6-1 ALU, Adder and Subtractor
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Basic Arithmetic (adding and subtracting)
Computing Systems Designing a basic ALU.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
08 ARTH Page 1 ECEn/CS 224 Number Representation and Binary Arithmetic.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
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
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
ECE 331 – Digital System Design
Arithmetic Circuits Didn’t I learn how
CSE Winter 2001 – Arithmetic Unit - 1
Topic 3b Computer Arithmetic: ALU Design
CSCI206 - Computer Organization & Programming
King Fahd University of Petroleum and Minerals
Arithmetic Functions & Circuits
Computer Organization and Design Arithmetic & Logic Circuits
Arithmetic Circuits (Part I) Randy H
Lecture 11: Hardware for Arithmetic
Topic 3b Computer Arithmetic: ALU Design
Instructor: Alexander Stoytchev
Digital Systems Section 12 Binary Adders. Digital Systems Section 12 Binary Adders.
By: A. H. Abdul Hafez CAO, by Dr. A.H. Abdul Hafez, CE Dept. HKU
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
COMS 361 Computer Organization
Addition and multiplication
Instructor: Mozafar Bag-Mohammadi University of Ilam
Montek Singh Mon, Mar 28, 2011 Lecture 11
Logic Circuits I Lecture 3.
Instructor: Alexander Stoytchev
Multiple function unit design
Addition and multiplication
ECE 352 Digital System Fundamentals
Combinational Circuits
Instructor: Alexander Stoytchev
Number Representation
Arithmetic and Logic Circuits
Presentation transcript:

Computer Organization and Design Arithmetic Circuits Montek Singh Wed, Mar 23, 2011 Lecture 10

Arithmetic Circuits 01011 +00101 10000 Didn’t I learn how to do addition in the second grade? 01011 +00101 10000 Finally; time to build some serious functional blocks We’ll need a lot of boxes

… … … Review: 2’s Complement 8-bit 2’s complement example: N bits -2N-1 2N-2 … … … 23 22 21 20 Range: – 2N-1 to 2N-1 – 1 “sign bit” “binary” point 8-bit 2’s complement example: 11010110 = – 128 + 64 + 16 + 4 + 2 = – 42 Beauty of 2’s complement representation: same binary addition procedure will work for adding both signed and unsigned numbers as long as the leftmost carry out is properly handled/ignored Insert a “binary” point to represent fractions too: 1101.0110 = – 8 + 4 + 1 + 0.25 + 0.125 = – 2.625

Binary Addition Example of binary addition “by hand”: Let’s design a circuit to do it! Start by building a block that adds one column: called a “full adder” (FA) Then cascade them to add two numbers of any size… 1 Carries from previous column A: 1101 B:+ 0101 10010 Adding two N-bit numbers produces an (N+1)-bit result A B CO CI S FA A3 B3 A2 B2 A1 B1 A0 B0 S4 S3 S0 S1 S0 A B CO CI S FA

Designing an Adder Follow the step-by-step method Start with a truth table: Write down eqns for the “1” outputs: Simplifying a bit (seems hard, but experienced designers are good at this art!)

For Those Who Prefer Logic Diagrams A little tricky, but only 5 gates/bit! CI A B S CO “Carry” Logic “Sum” Logic

Subtraction: A-B = A + (-B) Subtract B from A = add 2’s complement of B to A In 2’s complement: –B = ~B + 1 Let’s build an arithmetic unit that does both add and sub operation selected by control input: ~ = bit-wise complement B 1 But what about the “+1”? A B CO CI S FA A3 A2 A1 A0 S4 S3 S0 S1 S0 B3 B2 B1 B0 Subtract

Condition Codes One often wants 4 other bits of information from an arith unit: Z (zero): result is = 0 big NOR gate N (negative): result is < 0 SN-1 C (carry): indicates that most significant position produced a carry, e.g., “1 + (-1)” Carry from last FA V (overflow): indicates answer doesn’t fit precisely: To compare A and B, perform A–B and use condition codes: Signed comparison: LT NV LE Z+(NV) EQ Z NE ~Z GE ~(NV) GT ~(Z+(NV)) Unsigned comparison: LTU C LEU C+Z GEU ~C GTU ~(C+Z) -or-

TPD of Ripple-Carry Adder (What is TPD?? See Lec. 8-9) An-1 Bn-1 An-2 Bn-2 A2 B2 A1 B1 A0 B0 A B CO CI S FA A B CO CI S FA A B CO CI S FA A B CO CI S FA A B CO CI S FA C … Sn-1 Sn-2 S2 S1 S0 Worse-case path: carry propagation from LSB to MSB, e.g., when adding 11…111 to 00…001. tPD = (tPD,XOR +tPD,AND + tPD,OR) +(N-2)*(tPD,OR + tPD,AND) + tPD,XOR  (N) CI A B S CO CIN-1 to SN-1 CI to CO A,B to CO (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.

Can we add faster? Yes, there are many sophisticated designs that are faster… Carry-Lookahead Adders (CLA) Carry-Skip Adders Carry-Select Adders

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. Smaller / Slower Bigger / Faster Ripple Carry Carry Skip Carry Select Carry Lookahead Add A B S Add/Sub A B S At this point we’ll define a high-level functional unit for an adder, and specify the details of the implementation as necessary. sub

Shifting Logic Shifting is a common operation For example: applied to groups of bits used for alignment used for “short cut” arithmetic operations X << 1 is often the same as 2*X X >> 1 can be the same as X/2 For example: X = 2010 = 000101002 Left Shift: (X << 1) = 001010002 = 4010 Right Shift: (X >> 1) = 000010102 = 1010 Signed or “Arithmetic” Right Shift: (-X >>> 1) = (111011002 >>> 1) = 111101102 = -1010 1 R7 R6 R5 R4 R3 R2 R1 R0 X7 X6 X5 X4 X3 X2 X1 X0 “0” SHL1

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. 10101110 & 00001111 = 00001110 (mask selects last 4 bits) ANDing is also useful for “clearing” groups of bits. ex. 10101110 & 00001111 = 00001110 (0’s clear first 4 bits) ORing is useful for “setting” groups of bits. ex. 10101110 | 00001111 = 10101111 (1’s set last 4 bits) XORing is useful for “complementing” groups of bits. ex. 10101110 ^ 00001111 = 10100001 (1’s invert last 4 bits) NORing is useful for.. uhm… ex. 10101110 # 00001111 = 01010000 (0’s invert, 1’s clear)

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. Ai Bi Qi Bool 00 01 10 11 This logic block is repeated for each bit (i.e. 32 times)

An ALU, at Last Now we’re ready for a big one! A B R An Arithmetic Logic Unit! A B R Bidirectional Shifter Boolean Add/Sub Sub Bool Shft Math 1 0 … That’s a lot of stuff Flags V,C N Flag Z Flag