Mohamed Younis CMCS 411, Computer Architecture 1 CMCS 411-101 Computer Architecture Lecture 7 Arithmetic Logic Unit February 19, 2001 www.csee.umbc.edu/~younis/CMSC411/

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

Arithmetic for Computers
Lecture 19: Hardware for Arithmetic Today’s topic –Designing an ALU –Carry Look-Ahead Adder 1.
1 Lecture 12: Hardware for Arithmetic Today’s topics:  Designing an ALU  Carry-lookahead adder Reminder: Assignment 5 will be posted in a couple of days.
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
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.
CSE-221 Digital Logic Design (DLD)
Arithmetic II CPSC 321 E. J. Kim. Today’s Menu Arithmetic-Logic Units Logic Design Revisited Faster Addition Multiplication (if time permits)
1 Lecture 4: Arithmetic for Computers (Part 3) CS 447 Jason Bakos.
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
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.
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 301 – Digital Electronics
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
Binary Arithmetic Stephen Boyd March 14, Two's Complement Most significant bit represents sign. 0 = positive 1 = negative Positive numbers behave.
Basic Arithmetic (adding and subtracting)
Fall 2004EE 3563 Digital Systems Design EE 3563 Comparators  Comparators determine if two binary inputs are equal  Some will signal greater than/less.
Chapter 6-1 ALU, Adder and Subtractor
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /19/2013 Lecture 7: 32-bit ALU, Fast Carry Lookahead Instructor: Ashraf Yaseen DEPARTMENT OF MATH &
1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)
Computing Systems Designing a basic ALU.
Arithmetic Logic Unit (ALU) Anna Kurek CS 147 Spring 2008.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
Lecture 18: Hardware for Arithmetic Today’s topic –Intro to Boolean functions (Continued) –Designing an ALU 1.
Ch3b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University There is logic to it andRd, Rs, RtRd
COMP541 Arithmetic Circuits
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
MIPS ALU. Building from the adder to ALU ALU – Arithmetic Logic Unit, does the major calculations in the computer, including – Add – And – Or – Sub –
COMP541 Arithmetic Circuits
1  2004 Morgan Kaufmann Publishers Performance is specific to a particular program/s –Total execution time is a consistent summary of performance For.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
1 IKI20210 Pengantar Organisasi Komputer Kuliah No. 23: Aritmatika 18 Desember 2002 Bobby Nazief Johny Moningka
1  2004 Morgan Kaufmann Publishers Lets Build a Processor Almost ready to move into chapter 5 and start building a processor First, let’s review Boolean.
Addition, Subtraction, Logic Operations and ALU Design
Arithmetic-Logic Units. Logic Gates AND gate OR gate NOT gate.
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.
1 Lecture 11: Hardware for Arithmetic Today’s topics:  Logic for common operations  Designing an ALU  Carry-lookahead adder.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
1 Arithmetic Where we've been: –Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: –Implementing the Architecture.
Computer Arthmetic Chapter Four P&H. Data Representation Why do we not encode numbers as strings of ASCII digits inside computers? What is overflow when.
MIPS ALU. Exercise – Design a selector? I need a circuit that takes two input bits, a and b, and a selector bit s. The function is that if s=0, f=a. if.
Simple ALU  Half adder  Full adder  Constructing 4 bits adder  ALU does several operations  General ALU structure  Timing diagram of adder  Overflow.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
1 The ALU l ALU includes combinational logic. –Combinational logic  a change in inputs directly causes a change in output, after a characteristic delay.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Computer Arthmetic Chapter Four P&H.
Combinational Circuits
Lecture 11: Hardware for Arithmetic
Computer Architecture & Operations I
MIPS ALU.
5. Combinational circuits
MIPS ALU.
Lecture 11: Hardware for Arithmetic
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
COMS 361 Computer Organization
A 1-Bit Arithmetic Logic Unit
Combinational Circuits
MIPS ALU.
MIPS ALU.
Presentation transcript:

Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19, CMSC411.htm

Mohamed Younis CMCS 411, Computer Architecture 2 Lecture’s Overview q Previous Lecture: Number representation (Binary vs. decimal, Sign and magnitude, Two’s complement) Addition and Subtraction of binary numbers (Sign handling, Overflow conditions) Logical operations (Right and left shift, AND and OR) q This Lecture: Constructing an Arithmetic Logic Unit Scaling bit operations to word sizes Optimization for carry generation

Mohamed Younis CMCS 411, Computer Architecture 3 Building Blocks

Mohamed Younis CMCS 411, Computer Architecture 4 A 1-Bit Arithmetic Unit A single bit adder has 3 inputs, two operands and a carry-in and generates a sum bit and a carry-out to passed to the next 1-bit adder

Mohamed Younis CMCS 411, Computer Architecture 5 ) The multiplexor selects either a AND b, a OR b or a + b depending on whether the value of operation is 0, 1, or 2 ) To add an operation, the multiplexor has to be expanded & a circuit for performing the operation has to be appended 1-Bit logical unit A 1-Bit ALU 1-Bit adder

Mohamed Younis CMCS 411, Computer Architecture 6 Supporting Subtraction q Subtraction can be performed by inverting the operand and setting the “CarryIn” input for the adder to 1 (i.e. using two’s complement) q By adding a multiplexor to the second operand, we can select either b or b q The Binvert line indicates a subtraction operation and causes the two’s complement of b to be used as an input _ The simplicity of the hardware design of a two’s complement adder explains why it is a universal standard for computer arithmetic

Mohamed Younis CMCS 411, Computer Architecture 7 A 32-Bit ALU q A full 32-bit ALU can be created by connecting adjacent 1-bit ALU’s using the Carry in and carry out lines q The carry out of the least significant bit can ripple all the way through the adder (ripple carry adder) q Ripple carry adders are slow since the carry propagates from a unit to the next sequentially q Subtraction can be performed by inverting the operand and setting the “CarryIn” input for the whole adder to 1 (i.e. using two’s complement)

Mohamed Younis CMCS 411, Computer Architecture 8 Supporting MIPS’ “slt” instruction Most Significant Bit Basic 1-Bit ALU -Less input support the “slt instruction -“slt” produce 1 only if rs<rt and 0 otherwise 32-Bit Basic MIPS ALU Most Significant Bit - a < b iff (a-b) < 0 (value of sign bit is 1) -Checks for overflow - Sets the least significant bit to the value of sign bit

Mohamed Younis CMCS 411, Computer Architecture 9 MIPS’ ALU Conditional Branching - “bne” and “beq” instruction compares two operands for equality - a = b iff (a-b) = 0 - Zero signal indicates all zero results ALU Symbol MIPS’ ALU Circuits

Mohamed Younis CMCS 411, Computer Architecture 10 Ripple Carry Adders q The CarryIn input depends on the operation in the adjacent 1-bit adder q The result of adding most significant bits is only available after all other bits, i.e. after n-1 single-bit additions q The sequential chain reaction is too slow to be used in time-critical hardware Carry Lookahead q Anticipate the value of the carry ahead of time q Worst-case scenario is a function of log 2 n (the number of bits in the adder) q It takes many more gates to anticipate the carry Fast Carry Using "Infinite" Hardware Using the equation: c2 = (b1. c1) + (a1. c1) + (a1. b1) c1 = (b0. c0) + (a0. c0) + (a0. b0) Substituting the definition of c1 in c2 equation c2 = (a1. a0. b0) + (a1. a0. c0) + (a1. b0. c0) + (b1. a0. b0) + (b1. a0. c0) + (b1. b0. c0) + (a1. b1) è Number of gates grows exponentially when getting to higher bits in the adder Optimizing Adder’s Design

Mohamed Younis CMCS 411, Computer Architecture 11 abc-out 000“kill” 01c-in“propagate” 10c-in“propagate” 111“generate” p = a and b g = a or b a0 b0 S a1 b1 S g p a2 b2 S a3 b3 S c-in c1 =g0 + c0  p0 c2 = g1 + g0  p1 + c0  p0  p1 c3 = g2 + g1  p2 + g0  p1  p2 + c0  p0  p1  p2 g p g p g p g p c i+1 = (b i. c i ) + (a i. c i ) + (a i. b i ) = (a i. b i ) + c i. (a i + b i ) = g i + c i. p i c i+1 = (b i. c i ) + (a i. c i ) + (a i. b i ) = (a i. b i ) + c i. (a i + b i ) = g i + c i. p i Carry Lookahead (propagate & generate) * Figure is courtesy of Dave Patterson

Mohamed Younis CMCS 411, Computer Architecture 12 Plumbing as Carry Lookahead Analogy The pipe will output water if one of the wrenches is turned to open a valve

Mohamed Younis CMCS 411, Computer Architecture 13 CLACLA 4-bit Adder 4-bit Adder 4-bit Adder C1 =G0 + C0  P0 C2 = G1 + G0  P1 + C0  P0  P1 C3 = G2 + G1  P2 + G0  P1  P2 + C0  P0  P1  P2 G P G0 P0 C4 =... C0 Cascaded Carry Look-ahead q Consider a 4-bit adder with its carry lookahead logic as a building block q Connect the 4-bits adders in ripple carry fashion q Carry lookahead is done at a high level q Consider a 4-bit adder with its carry lookahead logic as a building block q Connect the 4-bits adders in ripple carry fashion q Carry lookahead is done at a high level P 0 = p 3. p 2. p 1. p 0 P 1 = p 7. p 6. p 5. p 4 …. P 0 = p 3. p 2. p 1. p 0 P 1 = p 7. p 6. p 5. p 4 …. G 0 = g 3 + (p 3.g 2 ) + (p 3.p 2.g 1 ) + (p 3.p 2.p 1.g 0 ) G 1 = g 7 + (p 7.g 6 ) + (p 7.p 6.g 5 ) + (p 7.p 6.p 5.g 4 ) …. G 0 = g 3 + (p 3.g 2 ) + (p 3.p 2.g 1 ) + (p 3.p 2.p 1.g 0 ) G 1 = g 7 + (p 7.g 6 ) + (p 7.p 6.g 5 ) + (p 7.p 6.p 5.g 4 ) ….

Mohamed Younis CMCS 411, Computer Architecture 14 An Example Determine g i, p i, P i, G i and carry out (C 4 ) values for these two 16-bit numbers: a: b: Answer: Using the formula g i = (a i. b i ) and p i = (a i + b i ) g i : p i : The “super” propagates (P 0, P 1, P 2, P 3 ) are calculated as follows: P 0 = p 3. p 2. p 1. p 0 = 0 P 1 = p 7. p 6. p 5. p 4 = 1 P 2 = p 11. p 10. p 9. p 8 = 1 P 3 = p 15. p 14. p 13. p 12 = 1 The “super” generates (G 0, G 1, G 2, G 3 ) are calculated as follows: G 0 = g 3 + (p 3.g 2 ) + (p 3.p 2.g 1 ) + (p 3.p 2.p 1.g 0 ) = 0 G 1 = g 7 + (p 7.g 6 ) + (p 7.p 6.g 5 ) + (p 7.p 6.p 5.g 4 ) = 1 G 2 = g 11 + (p 11.g 10 ) + (p 11.p 10.g 9 ) + (p 11.p 10.p 9.g 8 ) = 0 G 3 = g 15 + (p 15.g 14 ) + (p 15.p 14.g 13 ) + (p 15.p 14.g 13.g 12 ) = 0 Finally carry-out (C 4 ) is: C 4 = G 3 + (P 3.G 2 ) + (P 3.P 2.G 1 ) + (P 3.P 2.P 1.G 0 ) + (P 3.P 2.P 1.P 0.C 0 ) = 1

Mohamed Younis CMCS 411, Computer Architecture 15 Speed of Carry Generation It takes two gates delay for carry-out to be available in a single bit adder q There is a (gate) delay for an output to be ready once input signals are applied to a gate q Time is estimated by simply counting the number of gates along the longest path q Carry lookahead is faster because less cascaded levels of logic gates are used q For a 16-bit ripple carry adder, carry-out is subject to 32 (16  2 for 1 -bit adder) gate q Cascaded carry lookahead (C4) is delayed by only 5 gates (1 for p and g, 2 for G and 2 for C4) in a 16-bit adder

Mohamed Younis CMCS 411, Computer Architecture 16 Conclusion q Summary è Constructing an Arithmetic Logic Unit (Different blocks and gluing them together) è Scaling bit operations to word sizes (Ripple carry adder, MIPS ALU) è Optimization for carry handling (Measuring performance, Carry lookahead) q Next Lecture è Design phases è Hardware design languages (HDL) è The “eSim” miniaturized HDL Reading assignment is section 4.5 in text book