CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.

Slides:



Advertisements
Similar presentations
Arithmetic for Computers
Advertisements

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 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
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.
Arithmetic II CPSC 321 Andreas Klappenecker. Any Questions?
Chap 3.3~3.5 Construction an Arithmetic Logic Unit (ALU) Jen-Chang Liu, Spring 2006.
Lecture 8 Arithmetic Logic Circuits
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
Chapter Four Arithmetic and Logic Unit
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
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)
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
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.
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ć.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
1  1998 Morgan Kaufmann Publishers Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
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.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
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
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
MIPS ALU. Building from the adder to ALU ALU – Arithmetic Logic Unit, does the major calculations in the computer, including – Add – And – Or – Sub –
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.
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Arithmetic: Part II.
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.
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?
Gates AND, OR, NOT NAND, NOR Combinational logic No memory A set of inputs uniquely and unambiguously specifies.
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.
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.
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 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
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
Chap 7. Register Transfers and Datapaths
5. Combinational circuits
Arithmetic Where we've been:
MIPS ALU.
Systems Architecture I
Lecture 11: Hardware for Arithmetic
COMS 361 Computer Organization
A 1-Bit Arithmetic Logic Unit
October 8 Rules for Programming Assignments ASK QUESTIONS!
Combinational Circuits
MIPS ALU.
MIPS ALU.
Presentation transcript:

CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013

Overview Hardware building blocks ALU design ALU implementation 1-bit ALU 32-bit ALU

Hardware Building Blocks ALUs are implemented using lower level components (logic gates) Gate (review) –Hardware element that receives a certain number of inputs and produces one output –Can be represented as a truth table or logic equation –Gates in turn are implemented with transistors ALU Building Blocks (review) –And gate –Or gate –Inverter (not gate) –Multiplexor (mux)

Basic Gates

Modular ALU Design Facts –Building blocks work with individual (I/O) bits –ALU works with 32-bit registers –ALU performs a variety of tasks (+, -, *, /, shift, etc) Principles –Build 32 separate 1-bit ALUs –Build separate hardware blocks for each task –Perform all operations in parallel –Use a mux to choose the actual operation (make decision) Advantages –Easy to add new operations (instructions) Add new data lines into the muxes; inform “control” of the change.

ALU Implementation 1.32-bit ALU uses 32 muxes ( one for each output bit ) 2.Go through instruction set and add data (and control) lines to implement the corresponding operations. Control lines (n) Output: one per mux Data lines (2 n )

One-Bit Logical Instructions Map directly onto hardware components –AND instruction One of data lines should be a simple AND gate –OR instruction Another data line should be a simple OR gate A B C 0 1 Op (control)Definition OpC 0A and B 1A or B

One-Bit Full Adder Each bit of addition has –Three input bits: A i, B i, CarryIn i –Two output bits: Sum i, CarryOut i ( CarryIn i+1 = CarryOut i ) CarryIn... (0) (1) (0) (0) (0) (0) 1 (1) 0 (0) 1 (0) 1 + Inputs Outputs A: B: Sum : CarryOut

Full Adder’s Truth Table Sum A Symbol B CarryIn CarryOut + Definition A B CarryInCarryOutSum CarryOut = (A’*B*CarryIn) + (A*B’*CarryIn) + (A*B*CarryIn’) + (A*B*CarryIn) = (B*CarryIn) + (A*CarryIn) + (A*B) Sum = (A’*B’*CarryIn) + (A’*B*CarryIn’) + (A*B’*CarryIn’) + (A*B*CarryIn)

Full Adder Circuit (1/2) 1.Construct the gates for Sum 2.Implement the gates for CarryOut 3.Connect all inputs with the same name

Full Adder Circuit (2/2)

One-Bit ALU Least significant bitOther bits

32-Bit ALU a0a0 a1a1 a 31 b0b0 b1b1 b Result 0 Result 31 Result 1 BinvertOperation

Summary Building blocks: basic gates (AND, OR, NOT) Modular design and implementation –Gates have multiple inputs and one output –ALU works with 32-bit words (integers) –ALU implements a variety of operations in parallel => Construct first a 1-bit ALU –Mux chooses one of many different ALU operations –From the architecture’s instruction set, add the basic ALU operations necessary to implement that instruction –Two’s complement representation allows the use of the same hardware for both addition and subtraction

Anticipate the Weekend!!

Application to MIPS ALU MIPS ALU extensions Overflow detection Slt instruction Branch instructions Shift instructions Immediate instructions ALU performance –Performance vs. cost –Carry lookahead adder Implementation alternatives

Recall: Generic One-Bit ALU AND OR 00 – AND 01 – OR 10 – ADD First bit (LSB) Other bits 0 – ADD 1 – SUB Operations: AND, OR, ADD, SUB Control lines:

Slt Instruction Slt rd, rs, rt A A – B < 0 1.Perform subtraction using full adder 2.Check highest-order bit (sign bit) 3.Sign bit tells us whether A < B New input line ( Less ) goes directly to mux New control line (111) for slt Result for slt is not the output from ALU –Need a new 1-bit ALU for the most significant bit It has a new output line (Set) used only for slt (Overflow detection logic is also associated with this bit) r rd: 1 if (rs < rt) 0 else

Slt Support First bit (LSB)Sign bit

Branch Instructions beq $t5, $t6, L –Use subtraction: (a-b) = 0 implies a = b –Add hardware to test if the result is 0 –OR all 32 results and invert the OR output Zero = (Result 1 + Result Result 31 ) Consider A + B and A - B –Overflow if A = 0 ? B = 0 ?

Branch Support 1 (A = B) 0 otherwise

Shift instructions SLL, SRL, and SRA We need a data line for a shifter (L and R) However, shifters are much more easily implemented at the transistor level (outside the ALU) Barrel shifters x 3 x 2 x 1 x 0 x 2 x 1 x 0 00 x 3 x 2 x 1 Output, xOutput, x<<1Output, x>>1 Diagonal closed switch pattern controlled by the control unit

Immediate Instructions First input to ALU is the first register (rs) Second input –Data from register (rt) –Zero- or sing-extended immediate Add a mux at second input of ALU IR: Control Unit 0 1 Sign extend 1632 ALU Zero Overflow Result Registers Memory address rsrt

ALU Performance Is a 32-bit ALU as fast as a 1-bit ALU? –Can you see the ripple? Hardware executes in parallel Speed vs. Cost –Fewer sequential gates vs. number of gates Two extremes to do addition –Ripple carry and sum-of-products How could you get rid of the ripple –Two levels of logic c 1 = b 0 c 0 + a 0 c 0 + a 0 b 0 c 2 = b 1 c 1 + a 1 c 1 + a 1 b 1 c 2 = c 3 = b 2 c 2 + a 2 c 2 + a 2 b 2 c 3 = c 4 = b 3 c 3 + a 3 c 3 + a 3 b 3 c 4 =

Carry-Lookahead Adder (1/2) An approach in-between our two extremes Motivation: – If we didn't know the value of carry-in, what could we do? –When would we always generate a carry? g i = a i b i –When would we propagate the carry? p i = a i + b i Did we get rid of the ripple? c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 c 1 c 2 = g 1 + p 1 g 0 + p 1 p 0 c 0 c 3 = g 2 + p 2 c 2 c 3 = c 4 = g 3 + p 3 c 3 c 4 =

Carry-Lookahead Adder (2/2) Can’t build a 16 bit adder this way... (too big) Could use ripple carry of 4-bit CLA adders Better: use the CLA principle again!

Second Level P and G

Ripple Carry vs. Carry Lookahead Assume each gate (AND or OR) takes the same time Total time = number of gates of longest path Consider 16-bit adders CarryOut signals c 16 and C 4 define the longest path –Ripple carry: 2 * 16 = 32 –Carry lookahead: = 5 2 levels of logic in terms of P i and G i P i is specified in one level of logic (AND) using p i G i is specified in two levels of logic using p i and g i p i and g i are each one level of logic in terms of a i and b i A carry lookahead adder is six times faster

Implementation Alternatives The logic equation for the sum output can be expressed more simply with XOR gates Sum = a XOR b XOR CarryIn In some technologies, XOR is more efficient than two levels of AND and OR Processors are designed now in CMOS transistors (switches) CMOS ALU and barrel shifters have many fewer multiplexors than shown in our design However, the design principles are similar

Conclusions We can build an ALU to support the MIPS ISA –Key Idea: Use multiplexer to select ALU output –Subtraction uses two’s complement addition –Replicate 1-bit ALU to produce 32-bit ALU Important points about hardware –All of the gates in the ALU work in parallel –The speed of a gate is affected by the number of inputs –Speed of a circuit is affected by the number of gates in series (on the critical path or the deepest level of logic) Our primary focus: (conceptual) –Clever changes to organization can improve performance (similar to using better algorithms in software)

Enjoy the Weekend!!