Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.

Slides:



Advertisements
Similar presentations
Modular Combinational Logic
Advertisements

ECE2030 Introduction to Computer Engineering Lecture 13: Building Blocks for Combinational Logic (4) Shifters, Multipliers Prof. Hsien-Hsin Sean Lee School.
Lab 10 : Arithmetic Systems : Adder System Layout: Slide #2 Slide #3 Slide #4 Slide #5 Arithmetic Overflow: 2’s Complement Conversions: 8 Bit Adder/Subtractor.
Fast Adders See: P&H Chapter 3.1-3, C Goals: serial to parallel conversion time vs. space tradeoffs design choices.
Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H 2.4 (signed), 2.5, 2.6, C.6, and Appendix C.6.
Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Fast Adders See: P&H Chapter 3.1-3, C Goals: serial to parallel conversion time vs. space tradeoffs design choices.
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.
ECE 331 – Digital System Design
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
Assembly Language and Computer Architecture Using C++ and Java
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.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 301 – Digital Electronics
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.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See: P&H Chapter 2.4, 3.2, B.2, B.5, B.6.
Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Computer Systems 1 Fundamentals of Computing Negative Binary.
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ć.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit
Numbers & Arithmetic Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Numbers and Arithmetic Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
CS Data representation 1 Ch. 2.1 Data Representation Unsigned and Signed Integers – representation, addition, subtraction.
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.
Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow.
Computer Architecture Lecture 3 Combinational Circuits Ralph Grishman September 2015 NYU.
N, Z, C, V in CPSR with Adder & Subtractor Prof. Taeweon Suh Computer Science Education Korea University.
08 ARTH Page 1 ECEn/CS 224 Number Representation and Binary Arithmetic.
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 –
69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position.
EEL-3705 TPS QUIZZES Chapter 4. Quiz 4-1 Using the 2x4 Decoder shown below and two-input OR gates, design a logic circuit which implements.
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
1 IKI20210 Pengantar Organisasi Komputer Kuliah No. 23: Aritmatika 18 Desember 2002 Bobby Nazief Johny Moningka
CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits
Addition, Subtraction, Logic Operations and ALU Design
CHAPTER 2 Digital Combinational Logic/Arithmetic Circuits
1 Fundamentals of Computer Science Combinational Circuits.
Registers and Binary Arithmetic Prof. Sirer CS 316 Cornell University.
Numbers and Arithmetic Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
Arithmetic-Logic Units. Logic Gates AND gate OR gate NOT gate.
Gates AND, OR, NOT NAND, NOR Combinational logic No memory A set of inputs uniquely and unambiguously specifies.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
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.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
Lecture 7. Subtractor Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
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 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Computer Arthmetic Chapter Four P&H.
Addition and Subtraction
Homework Reading Machine Projects Labs
Numbers and Arithmetic
Numbers and Arithmetic
Homework Reading Machine Projects Labs
ECE 352 Digital System Fundamentals
Presentation transcript:

Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6

2 4-bit Adder Adds two 4-bit numbers, along with carry-in Computes 4-bit result and carry out A 0 B 0 R0R0 A 1 B 1 R1R1 A 2 B 2 R2R2 A 3 B 3 R3R3 Cout Cin

3 Arithmetic with Negative Numbers Addition with negatives: pos + pos  add magnitudes, result positive neg + neg  add magnitudes, result negative pos + neg  subtract smaller magnitude, keep sign of bigger magnitude

4 First Attempt: Sign/Magnitude Representation 1 bit for sign (0=positive, 1=negative) N-1 bits for magnitude

5 Two’s Complement Representation Better: Two’s Complement Representation Leading 1’s for negative numbers To negate any number: –complement all the bits –then add 1

6 Two’s Complement Non-negatives (as usual): +0 = = = = = = = = = 1000 Negatives (two’s complement: flip then add 1): ~0 = = 0000 ~1 = = 1111 ~2 = = 1110 ~3 = = 1101 ~4 = = 1100 ~5 = = 1011 ~3 = = 1010 ~7 = = 1001 ~8 = = 1000

7 Two’s Complement Facts Signed two’s complement Negative numbers have leading 1’s zero is unique: +0 = - 0 wraps from largest positive to largest negative N bits can be used to represent unsigned: –eg: 8 bits  signed (two’s complement): –ex: 8 bits 

8 Sign Extension & Truncation Extending to larger size Truncate to smaller size

9 Two’s Complement Addition Addition with two’s complement signed numbers Perform addition as usual, regardless of sign (it just works) A 0 B 0 R0R0 A 1 B 1 R1R1 A 2 B 2 R2R2 A 3 B 3 R3R3 Cout

10 Diversion: 10’s Complement How does that work?

11 Overflow adding a negative and a positive? adding two positives? adding two negatives? Rule of thumb: Overflow happened iff carry into msb != carry out of msb

12 Two’s Complement Adder Two’s Complement Adder with overflow detection A 0 B 0 R0R0 A 1 B 1 R1R1 A 2 B 2 R2R2 A 3 B 3 R3R3 over flow 0

13 Binary Subtraction Two’s Complement Subtraction Lazy approach A – B = A + (-B) = A + (B + 1) R0R0 R1R1 R2R2 R3R3 over flow 1 A0A0 B0B0 A1A1 B1B1 A2A2 B2B2 A3A3 B3B3 Q: What if (-B) overflows?

14 A Calculator decoder 8 8 S 0=add 1=sub A B 8

15 A Calculator 0101 adder mux decoder S A B 8

16 Is this design fast enough? Can we generalize to 32 bits? 64? more? Efficiency and Generality A 0 B 0 R0R0 A 1 B 1 R1R1 A 2 B 2 R2R2 A 3 B 3 R3R3 C0C0

17 Performance Speed of a circuit is affected by the number of gates in series (on the critical path or the deepest level of logic) Combinational Logic t combinational inputs arrive outputs expected

18 4-bit Ripple Carry Adder A3B3 R3 C4 A1B1 R1 A2B2 R2 A0B0 C0 R0 C1C2C3 First full adder, 2 gate delay Second full adder, 2 gate delay … Carry ripples from lsb to msb