Arithmetic-logic units1 An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the “heart” of a processor—you.

Slides:



Advertisements
Similar presentations
Part 4: combinational devices
Advertisements

DAT2343 Basic Logic Gates © Alan T. Pinck / Algonquin College; 2003.
Combinational Circuits
L10 – Transistors Logic Math 1 Comp 411 – Spring /22/07 Arithmetic Circuits Didn’t I learn how to do addition in the second grade?
EET 1131 Unit 7 Arithmetic Operations and Circuits
Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.
Random access memory Sequential circuits all depend upon the presence of memory. A flip-flop can store one bit of information. A register can store a single.
Arithmetic Operations and Circuits
1 Foundations of Software Design Lecture 3: How Computers Work Marti Hearst Fall 2002.
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Lecture 8 Arithmetic Logic Circuits
Chapter 10-Arithmetic-logic units
Arithmetic-Logic Units (ALUs). The four-bit adder The basic four-bit adder always computes S = A + B + CI But by changing what goes into the adder inputs.
Arithmetic-logic units
Arithmetic Operations and Circuits Lecture 5. Binary Arithmetic let’s look at the procedures for performing the four basic arithmetic functions: addition,
Building Adders & Sub tractors Dr Ahmed Telba. Introducing adder circuits Adder circuits are essential inside microprocessors as part of the ALU, or arithmetic.
Chapter 3 Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Building Functions.
CS 1308 – Computer Literacy and the Internet. It’s Not Magic  The goal of the next series of lectures is to show you exactly how a computer works. 
Homework Problems 1. M1 runs the program P in 1.4 * 9 * ns or ns M2 runs the program P in 1.6*9800*10ns or ns Hence M2 is faster by.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
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.
CS1Q Computer Systems Lecture 8
Chapter 6-1 ALU, Adder and Subtractor
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
1 © 2015 B. Wilkinson Modification date: January 1, 2015 Designing combinational circuits Logic circuits whose outputs are dependent upon the values placed.
ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit
CS231 Boolean Algebra1 K-map Summary K-maps are an alternative to algebra for simplifying expressions. – The result is a minimal sum of products, which.
IKI b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,
1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)
IT253: Computer Organization Lecture 7: Logic and Gates: Digital Design Tonga Institute of Higher Education.
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.
July 2, 2002Latches1 Defining a logic unit A logic unit supports different logical functions on two multi-bit inputs X and Y, producing an output G. This.
The Karnaugh Map.
CS 1308 – Computer Literacy and the Internet Building the CPU.
Hamming Code,Decoders and D,T-flip flops Prof. Sin-Min Lee Department of Computer Science.
CS231 Boolean Algebra1 Summary so far So far: – A bunch of Boolean algebra trickery for simplifying expressions and circuits – The algebra guarantees us.
CS1Q Computer Systems Lecture 8
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?
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.
Control units In the last lecture, we introduced the basic structure of a control unit, and translated our assembly instructions into a binary representation.
Explain Half Adder and Full Adder with Truth Table.
1 Binary Signals Logic gate circuits are designed to input and output only two types of signals: “high” (1) and “low” (0), as represented by a variable.
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.
CS231: Computer Architecture I Laxmikant Kale Fall 2002.
Combinational circuits
Morgan Kaufmann Publishers
Chap 7. Register Transfers and Datapaths
Instructors: Randy H. Katz David A. Patterson
Additional Gates and Decoders
Arithmetic Circuits (Part I) Randy H
Digital Logic.
Unit 10 Arithmetic-logic Units
Digital Logic.
Arithmetic and Decisions
Branch instructions We’ll implement branch instructions for the eight different conditions shown here. Bits 11-9 of the opcode field will indicate the.
One’s complement addition
From now on: Combinatorial Circuits:
Addition and multiplication
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Multiplexers For the rest of the day, we’ll study multiplexers, which are just as commonly used as the decoders we presented last time. Again, These serve.
Basic circuit analysis and design
ECE 352 Digital System Fundamentals
Instructor: Michael Greenbaum
Presentation transcript:

Arithmetic-logic units1 An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the “heart” of a processor—you could say that everything else in the CPU is there to support the ALU. Here’s the plan: – We’ll show an arithmetic unit first, by building off ideas from the adder-subtractor circuit. – Then we’ll talk about logic operations a bit, and build a logic unit. – Finally, we put these pieces together using multiplexers. We show the same examples as from the book (pp ), but things are re-labeled to be clearer in LogicWorks. C in and S 0 are also treated a little differently.

Arithmetic-logic units2 The four-bit adder The basic four-bit adder always computes S = A + B + CI. But by changing what goes into the adder inputs A, B and CI, we can change the adder output S. This is also what we did to build the combined adder-subtractor circuit.

Arithmetic-logic units3 It’s the adder-subtractor again! Here the signal Sub and some XOR gates alter the adder inputs. – When Sub = 0, the adder inputs A, B, CI are Y, X, 0, so the adder produces G = X + Y + 0, or just X + Y. – When Sub = 1, the adder inputs are Y’, X and 1, so the adder output is G = X + Y’ + 1, or the two’s complement operation X - Y.

Arithmetic-logic units4 The multi-talented adder So we have one adder performing two separate functions. “Sub” acts like a function select input which determines whether the circuit performs addition or subtraction. Circuit-wise, all “Sub” does is modify the adder’s inputs A and CI.

Arithmetic-logic units5 Modifying the adder inputs By following the same approach, we can use an adder to compute other functions as well. We just have to figure out which functions we want, and then put the right circuitry into the “Input Logic” box.

Arithmetic-logic units6 Some more possible functions We already saw how to set adder inputs A, B and CI to compute either X + Y or X - Y. How can we produce the increment function G = X + 1? How about decrement: G = X - 1? How about transfer: G = X? (This can be useful.) This is almost the same as the increment function! One way: Set A = 0000, B = X, and CI = 1 A = 1111 (-1), B = X, CI = 0 A = 0000, B = X, CI = 0

Arithmetic-logic units7 The role of CI The transfer and increment operations have the same A and B inputs, and differ only in the CI input. In general we can get additional functions (not all of them useful) by using both CI = 0 and CI = 1. Another example: – Two’s-complement subtraction is obtained by setting A = Y’, B = X, and CI = 1, so G = X + Y’ + 1. – If we keep A = Y’ and B = X, but set CI to 0, we get G = X + Y’. This turns out to be a ones’ complement subtraction operation.

Arithmetic-logic units8 Table of arithmetic functions Here are some of the different possible arithmetic operations. We’ll need some way to specify which function we’re interested in, so we’ve randomly assigned a selection code to each operation.

Arithmetic-logic units9 Mapping the table to an adder This second table shows what the adder’s inputs should be for each of our eight desired arithmetic operations. – Adder input CI is always the same as selection code bit S 0. – B is always set to X. – A depends only on S 2 and S 1. These equations depend on both the desired operations and the assignment of selection codes.

Arithmetic-logic units10 Building the input logic All we need to do is compute the adder input A, given the arithmetic unit input Y and the function select code S (actually just S 2 and S 1 ). Here is an abbreviated truth table: We want to pick one of these four possible values for A, depending on S 2 and S 1.

Arithmetic-logic units11 Primitive gate-based input logic We could build this circuit using primitive gates. If we want to use K-maps for simplification, then we should first expand out the abbreviated truth table. – The Y that appears in the output column (A) is actually an input. – We make that explicit in the table on the right. Remember A and Y are each 4 bits long!

Arithmetic-logic units12 Primitive gate implementation From the truth table, we can find an MSP: Again, we have to repeat this once for each bit Y3-Y0, connecting to the adder inputs A3-A0. This completes our arithmetic unit. A i = S 2 Y i ’ + S 1 Y i

Arithmetic-logic units13 Bitwise operations Most computers also support logical operations like AND, OR and NOT, but extended to multi-bit words instead of just single bits. To apply a logical operation to two words X and Y, apply the operation on each pair of bits X i and Y i : We’ve already seen this informally in two’s-complement arithmetic, when we talked about “complementing” all the bits in a number AND OR XOR

Arithmetic-logic units14 Languages like C, C++ and Java provide bitwise logical operations: & (AND)| (OR)^ (XOR)~ (NOT) These operations treat each integer as a bunch of individual bits: 13 & 25 = 9because01101 & = They are not the same as the operators &&, || and !, which treat each integer as a single logical value (0 is false, everything else is true): 13 && 25 = 1becausetrue && true = true Bitwise operators are often used in programs to set a bunch of Boolean options, or flags, with one argument. Easy to represent sets of fixed universe size with bits: – 1: is member, 0 not a member. Unions: OR, Intersections: AND Bitwise operations in programming

Arithmetic-logic units15 IP addresses are actually 32-bit binary numbers, and bitwise operations can be used to find network information. For example, you can bitwise-AND an address with a “subnet mask” to find the “network address,” or which network the machine is connected to = & = = You can use bitwise-OR to generate a “broadcast address,” for sending data to all machines on the local network = | = = Bitwise operations in networking

Arithmetic-logic units16 Defining a logic unit A logic unit supports different logical functions on two multi-bit inputs X and Y, producing an output G. This abbreviated table shows four possible functions and assigns a selection code S to each. We’ll just use multiplexers and some primitive gates to implement this. Again, we need one multiplexer for each bit of X and Y.

Arithmetic-logic units17 Our simple logic unit Inputs: – X (4 bits) – Y (4 bits) – S (2 bits) Outputs: – G (4 bits)

Arithmetic-logic units18 Combining the arithmetic and logic units Now we have two pieces of the puzzle: – An arithmetic unit that can compute eight functions on 4-bit inputs. – A logic unit that can perform four functions on 4-bit inputs. We can combine these together into a single circuit, an arithmetic-logic unit (ALU).

Arithmetic-logic units19 Our ALU function table This table shows a sample function table for an ALU. All of the arithmetic operations have S 3 =0, and all of the logical operations have S 3 =1. These are the same functions we saw when we built our arithmetic and logic units a few minutes ago. Since our ALU only has 4 logical operations, we don’t need S 2. The operation done by the logic unit depends only on S 1 and S 0.

Arithmetic-logic units A complete ALU circuit G is the final ALU output. When S3 = 0, the final output comes from the arithmetic unit. When S3 = 1, the output comes from the logic unit. C out should be ignored when logic operations are performed (when S3=1). The arithmetic and logic units share the select inputs S1 and S0, but only the arithmetic unit uses S2. The / and 4 on a line indicate that it’s actually four lines.

Arithmetic-logic units21 Comments on the multiplexer Both the arithmetic unit and the logic unit are “active” and produce outputs. – The mux determines whether the final result comes from the arithmetic or logic unit. – The output of the other one is effectively ignored. Our hardware scheme may seem like wasted effort, but it’s not really. – “Deactivating” one or the other wouldn’t save that much time. – We have to build hardware for both units anyway, so we might as well run them together. This is a very common use of multiplexers in logic design.

Arithmetic-logic units22 The completed ALU This ALU is a good example of hierarchical design. – With the 12 inputs, the truth table would have had 2 12 = 4096 lines. That’s an awful lot of paper. – Instead, we were able to use components that we’ve seen before to construct the entire circuit from a couple of easy-to-understand components. As always, we encapsulate the complete circuit in a “black box” so we can reuse it in fancier circuits.

Arithmetic-logic units23 Arithmetic summary In the last few lectures we looked at: – Building adders hierarchically, starting with one-bit full adders. – Representations of negative numbers to simplify subtraction. – Using adders to implement a variety of arithmetic functions. – Logic functions applied to multi-bit quantities. – Combining all of these operations into one unit, the ALU. Where are we now? – We started at the very bottom, with primitive gates, and now we can understand a small but critical part of a CPU. – This all built upon our knowledge of Boolean algebra, Karnaugh maps, multiplexers, circuit analysis and design, and data representations.