1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)

Slides:



Advertisements
Similar presentations
Part 4: combinational devices
Advertisements

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.
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.
Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19,
1 Foundations of Software Design Lecture 3: How Computers Work Marti Hearst Fall 2002.
1 Lecture 4: Arithmetic for Computers (Part 3) CS 447 Jason Bakos.
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.
Chap 3.3~3.5 Construction an Arithmetic Logic Unit (ALU) Jen-Chang Liu, Spring 2006.
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Arithmetic Logic Unit ALU By: Ahmad Yazdankhah CS 147 Fall 2008 Prof: Dr. Sin-Min Lee.
Chapter 3 Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Building Functions.
Logical Circuit Design Week 8: Arithmetic Circuits Mentor Hamiti, MSc Office ,
Basic Arithmetic (adding and subtracting)
CS1Q Computer Systems Lecture 9 Simon Gay. Lecture 9CS1Q Computer Systems - Simon Gay2 Addition We want to be able to do arithmetic on computers and therefore.
Digital Arithmetic and Arithmetic Circuits
Introduction to Chapter 6  Digital circuits are frequently used for arithmetic operations  Fundamental arithmetic operations on binary numbers and digital.
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ć.
Basic Arithmetic (adding and subtracting)
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
Arithmetic Logic Unit (ALU) Anna Kurek CS 147 Spring 2008.
Digital Logic. 2 Abstractions in CS (gates) Basic Gate: Inverter IO IO GNDI O Vcc Resister (limits conductivity) Truth Table.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
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
IT253: Computer Organization
The Karnaugh Map.
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.
Appendix C Basics of Digital Logic Part I. Florida A & M University - Department of Computer and Information Sciences Modern Computer Digital electronics.
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
1 Fundamentals of Computer Science Combinational Circuits.
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 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
1 Lecture 11: Hardware for Arithmetic Today’s topics:  Logic for common operations  Designing an ALU  Carry-lookahead adder.
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.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
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.
Csci136 Computer Architecture II Lab#5 Arithmetic Review ALU Design Ripple Carry Adder & Carry lookahead HW #4: Due on Feb 22, before class Feb.16, 2005.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
Discrete Systems I Lecture 10 Adder and ALU Profs. Koike and Yukita.
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.
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.
Arithmetic Logic Unit ALU
Combinational Circuits
CS 270: Mathematical Foundations of Computer Science
Lecture 11: Hardware for Arithmetic
Computer Science 210 Computer Organization
MIPS ALU.
5. Combinational circuits
MIPS ALU.
Lecture 11: Hardware for Arithmetic
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Digital Logic.
COMS 361 Computer Organization
Combinational Circuits
XOR Function Logic Symbol  Description  Truth Table 
MIPS ALU.
MIPS ALU.
Presentation transcript:

1 Arithmetic Logic Unit ALU

2 The Bus Concept

3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)

4 The Simplest Computer Building Blocks Instruction Register (IR)Program Counter (PC) Control Unit (CU) ALU Accumulator (ACC) CPURAM Status Register (FLAG)

5 What’s ALU? 1.ALU stands for: Arithmetic Logic Unit 2.ALU is a digital circuit that performs Arithmetic (Add, Sub,...) and Logical (AND, OR, NOT) operations. 3.John Von Neumann proposed the ALU in 1945 when he was working on EDVAC.

6 Typical Schematic Symbol of an ALU A and B: the inputs to the ALU (aka operands) R: Output or Result F: Code or Instruction from the Control Unit (aka as op-code) D: Output status; it indicates cases such as: carry-in carry-out, overflow, division-by-zero

7 Let’s Build a 1-Bit ALU This is an one-bit ALU which can do Logical AND and Logical OR operation. Result = a AND b when operation = 0 Result = a OR b when operation = 1 The operation line is the input of a MUX.

8 Adding a full adder to our ALU Building a 1-Bit ALU (cont’d)

9 The Goal ALU 32 bit operand 32 bit operand 32 bit result Control (operation selection)

10 Starting Small We can start by designing a 1 bit ALU. Put a bunch of them together to make larger ALUs. –building a larger unit from a 1 bit unit is simple for some operations, can be tricky for others. Bottom-Up approach: –build small units of functionality and put them together to build larger units.

11 1 bit AND/OR machine We want to design a single box that can compute either AND or OR. We will use a control input to determine which operation is performed. –Name the control “ Op ”. if Op==0 do an AND if Op==1 do an OR

12 Truth Table For 1-bit AND/OR OpABResult A B Op Result Op =0: Result is A B Op =1: Result is A + B

13 Logic for 1-Bit AND/OR We could derive SOP or POS and build the corresponding logic. We could also just do this: –Feed both A and B to an OR gate. –Feed A and B to an AND gate. –Use a 2-input MUX to pick which one will be used. Op is the selection input to the MUX.

14 Logic Design for 1-Bit AND/OR Mux Result A B Op

15 Addition We need to build a 1 bit adder –compute binary addition of 2 bits. We already know that the result is 2 bits. ABO0O0 O1O A + B O 0 O 1 This is addition, not logical OR!

16 One Implementation A B O0O0 A B A B O1O1

17 Binary addition and our adder What we really want is something that can be used to implement the binary addition algorithm. –O 0 is the carry –O 1 is the sum Carry

18 What about the second column? We are adding 3 bits –new bit is the carry from the first column. –The output is still 2 bits, a sum and a carry Carry

19 Revised Truth Table for Addition ABCarry In Carry Out Sum

20 Logic Design for new adder We can derive SOP expressions from the truth table. We can build a combinational circuit that implements the SOP expressions. We can put it in a box and give it a name.

21 New Component: Adder adder A B Carry In Carry Out Sum

22 1 Bit ALU Combine the AND/OR with the adder. We must now use a 4-input MUX with 2 selection inputs. ANDORadd

23 This is 2 bits!

24 Building a 32 bit ALU 64 inputs 3 different Operations (AND,OR,add). 32 bit output A 0 A 1 … A 31 B 0 B 1 … B 31 …… Op R 0 R 1 … R 31 … Result

25 Ripple Carry Adder Carry out from ALU 0 is sent to carry in of ALU 1 How long will it take for the result to become available? the CarryOuts must propagate through all 32 1-Bit ALUs.

26 New Operation: Subtraction Subtraction can be done with an adder: A - B can be computed as A + -B To negate B we need to: –invert the bits. –add 1

27 Negating B in the ALU We can negate B by in the ALU by: –providing B to the adder. need a selection bit to do this. –To add 1, just set the initial carry in to 1!

28 Revised 1 Bit ALU

29 Uses for our ALU addition, subtraction, OR and AND instructions can be implemented with our ALU. –we still need to get the right values to the ALU and set control lines. We can also support the slt instruction. –need to add a little more to the 1 bit ALU.

30 Supporting slt slt needs to compare 2 numbers. –comparison requires a subtraction. if A-B is negative, then A<B is true. otherwise A<B is false. True: output should be …001 False: output should be …000 This is what slt stores in the dest. register

31 slt Strategy To compute slt A B : –subtract B from A (set Binvert and the L.S. Carry In to 1. –Result for all 1-bit ALUs except the LS should always be 0. –Result for the LS 1-bit ALU should be the result bit from the MS 1-bit ALU! LS: Least significant (rightmost) MS: Most significant (leftmost)

32 New 1-bit ALU 0 3 Result Operation a 1 CarryIn CarryOut 0 1 Binvert b 2 Less

33 MS ALU

34 New 32-bit ALU Less input is 0 for all but the LS. Result of addition in the MS ALU is fed back to the Less input of the LS ALU

35 Put it in a box and give it a name

36 Speed is important. Using a ripple carry adder the time it takes to do an addition is too long. –each 1-bit ALU has something like 4 levels of gates. –The input to the i th ALU includes an output from the i-1 th ALU. –For 32 bits we have something like 128 gate delays before the addition is complete.

37 Strategies for speeding things up. We could derive the truth table for each of the 32 result bits as a function of 64 inputs. We know we can build SOP expressions for each and implement using 2 levels of gates. This might be a good test question! –don’t worry, you would need so much paper I couldn’t carry the tests to class…

38 A more realistic approach The problem is the ripple –The last carry-in is takes a long time to compute. We can try to compute the carry-in bits as fast as possible –this is called carry lookahead –It turns out we can easily compute the carry-in bits much faster (but not in constant time).

39 Carry In Analysis CarryIn i is an input to the i th 1 bit adder. CarryOut i-1 is connected to CarryIn i We know about how to compute the CarryOuts ABCarry In Carry Out Sum

40 Computing Carry Bits CarryIn 0 is an input to the adder. –we don’t compute this – it’s an input. CarryIn 1 depends on A 0, B 0 and CarryIn 0 : CarryIn 1 = (B 0 CarryIn 0 ) + (A 0 CarryIn 0 )+(A 0 B 0 ) SOP: Requires 2 levels of gates

41 CarryIn 2 CarryIn 2 = (B 1 CarryIn 1 ) + (A 1 CarryIn 1 )+(A 1 B 1 ) We can substitute for CarryIn 1 and get this mess: CarryIn 2 = (B 1 B 0 CarryIn 0 ) + (B 1 A 0 CarryIn 0 )+(B 1 A 0 B 0 ) + (A 1 B 0 CarryIn 0 ) + (A 1 A 0 CarryIn 0 )+(A 1 A 0 B 0 )+(A 1 B 1 ) The size of these expressions will get too big (that’s the whole problem!).

42 Another way to describe CarryIn C i+1 = (B i C i ) + (A i C i )+(A i B i ) = (A i B i ) + (A i + B i ) C i A i B i : Call this Generate (G i ) A i + B i : Call this Propagate (P i ) C i+1 = G i + P i C i

43 Generate and Propagate When A i and B i are both 1, G i becomes a 1. –a CarryOut is generated. If P i is a 1, any Carry in is propagated to Carry Out. C i+1 = G i + P i C i G i =A i B i P i =A i + B i

44 Using G i and P i C 1 = G 0 +P 0C 0 C 2 = G 1 +P 1C 1 = G 1 + P 1 (G 0 +P 0C 0 ) = G 1 + P 1 G 0 + P 1 P 0C 0 C 3 = G 2 + P 2G 1 + P 2P 1G 0 + P 2P 1P 0C 0

45 Implementation Expression is still too big to handle (for 32 bits). We can minimize the time needed to compute all the CarryIn bits for a 4 bit adder. Connect a bunch of 4 bit adders together and treat CarryIns to these adders in the same manner.

46

47 Binary Multiplication 1000 x multiplicand multiplier product

48 Implementing Multiplication

49 t 32nd repetition? Start Multiplier0 = 0Multiplier0 = 1 No: < 32 repetitions Yes: 32 repetitions