Add & Subtract. Addition Add bit by bit from right to left Ex 5+6 or 7+3 0101 (5)0111 (7) +0110 (6)OR +0011 (3) 1011 (11)1010 (10)

Slides:



Advertisements
Similar presentations
Lecturer PSOE Dan Garcia
Advertisements

Pipeline Example: cycle 1 lw R10,9(R1) sub R11,R2, R3 and R12,R4, R5 or R13,R6, R7.
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
Computer Structure - Computer Arithmetic Goal: Representing Numbers in Binary  Base 10 (decimal) - Numbers are represented using 10 numerals: 0, 1, 2,
The Processor: Datapath & Control
Arithmetic CPSC 321 Computer Architecture Andreas Klappenecker.
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
Arithmetic I CPSC 321 Andreas Klappenecker. Administrative Issues Office hours of TA Praveen Bhojwani: M 1:00pm-3:00pm.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
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.
ADDING INTEGERS Positive + Positive = Positive Positive + Positive = Positive ( +3) + (+2) = +5 ( +3) + (+2) = +5 When a number is positive, you do not.
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
1.11, 1.12, 1.13, 1.14, 1.18, 1.20, 1.23, 1.24, 1.25, 1.32, 1.33.
Computer Engineering AddSub page 1 Basic Building Blocks Multiplexer + Demultiplexer Adder.
Number Representation
CS Data representation 1 Ch. 2.1 Data Representation Unsigned and Signed Integers – representation, addition, subtraction.
Computer Architecture and Design – ECEN 350 Part 6 [Some slides adapted from A. Sprintson, M. Irwin, D. Paterson and others]
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell 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 –
CPE 232 MIPS Arithmetic1 CPE 232 Computer Organization MIPS Arithmetic – Part I Dr. Gheith Abandah [Adapted from the slides of Professor Mary Irwin (
Addition, Subtraction, Logic Operations and ALU Design
CHAPTER 3 Arithmetic For Computers 1/31/ Topics for discussion 1/31/ Number system: { radix/base, a set of distinct digits, operations} Radix.
Cpu control.1 2/14 Datapath Components for Lab The Processor! ( th ed)
1 Signed Arithmetic Logical Operations Ellen Spertus MCS 111 October 1, 2002.
Datapath and Control AddressInstruction Memory Write Data Reg Addr Register File ALU Data Memory Address Write Data Read Data PC Read Data Read Data.
COM181 Computer Hardware Lecture 6: The MIPs CPU.
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.
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.
May 2, 2001System Architecture I1 Systems Architecture I (CS ) Lecture 11: Arithmetic for Computers * Jeremy R. Johnson May 2, 2001 *This lecture.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
MIPS Arithmetic and Logic Instructions
Computer Architecture Lecture 6.  Our implementation of the MIPS is simplified memory-reference instructions: lw, sw arithmetic-logical instructions:
Single Cycle CPU - Control
Based on slides from D. Patterson and www-inst.eecs.berkeley.edu/~cs152/ COM 249 – Computer Organization and Assembly Language Chapter 3 Arithmetic For.
Computer System Design Lecture 3
Computer Arthmetic Chapter Four P&H.
Design of the Control Unit for Single-Cycle Instruction Execution
CSCI206 - Computer Organization & Programming
Design of the Control Unit for One-cycle Instruction Execution
CSCI206 - Computer Organization & Programming
MIPS ALU.
Topic 3a Two’s Complement Representation
Enemies make you stronger, allies make you weaker. Frank Herbert
MIPS Processor.
Topic 5: Processor Architecture Implementation Methodology
Rocky K. C. Chang 6 November 2017
CS/COE0447 Computer Organization & Assembly Language
The Processor Lecture 3.2: Building a Datapath with Control
Topic 5: Processor Architecture
CS/COE0447 Computer Organization & Assembly Language
MIPS Assembly.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
A 1-Bit Arithmetic Logic Unit
Basic Building Blocks Multiplexer Demultiplexer Adder +
Basic Building Blocks Multiplexer Demultiplexer Adder +
The Processor.
Datapath and Control Exceptions
COMS 361 Computer Organization
The Processor: Datapath & Control.
MIPS Arithmetic and Logic Instructions
MIPS ALU.
MIPS ALU.
MIPS Processor.
Processor: Datapath and Control
Presentation transcript:

Add & Subtract

Addition Add bit by bit from right to left Ex 5+6 or (5)0111 (7) (6)OR (3) 1011 (11)1010 (10)

Subtraction Take the 2s compliment of subtracting number, then add the 2 numbers 2s compliment conversion: Invert bits then add 1 Ex subtract 5 from (9) (5) (-5) 0100 (4)

Overflow Overflow can occur when adding two positive numbers and the sum is negative, or vice versa. (+) + (+) = (-) or (-) + (-) = (+) Subtracting positive from a negative and result is negative or negative from a positive and the result is positive (-) – (+) = (-) or (+) – (-) = (+)

Overflow Cont’d Add, Addi (immediate), sub – cause exceptions on overflow Addu (unsigned), addiu (immediate unsigned), subu (unsigned) – do not cause exceptions on overflow

ALU Addition and subtraction are both handled by the ALU ALU takes 2 inputs from “register file”, a control input from “ALU control”, and outputs to “data memory”

ALU Control “ALU control” determines which function for the ALU to perform “ALU control” input consists of a 2 bit “ALUop” control field + a 6 bit function field ALUop for add and subtract is the same (10) Function field – Add : – Sub :

ALU The 4 bit result from the ALU control is sent to the ALU This 4 bit control line controls which function is performed by the ALU 4 bit control line – Add : 0010 – Sub : 0110

ALU First input is read from register file (yellow wire, next slide) Second input, sign extended lower 16 bits of instruction (Blue wire) ALUop+Function sent to ALU control which converts to 4 bit signal sent to ALU (green wire) Result written to data memory (Red wire)

Data path