What do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers

Similar documents
What do all those bits mean now? Number Systems and Arithmetic. Introduction to Binary Numbers. Questions About Numbers

Questions About Numbers. Number Systems and Arithmetic. Introduction to Binary Numbers. Negative Numbers?

Number Systems and Computer Arithmetic

Course Administration

Stack Manipulation. Other Issues. How about larger constants? Frame Pointer. PowerPC. Alternative Architectures

COMP 303 Computer Architecture Lecture 6

Computer Arithmetic Logical, Integer Addition & Subtraction Chapter

Representation of Numbers. Number Representation. Representation of Numbers. 32-bit Unsigned Integers 3/24/2014. Fixed point Integer Representation

Subtracting Fractions

12-B FRACTIONS AND DECIMALS

Divide: Paper & Pencil

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division

Tailoring the 32-Bit ALU to MIPS

Basics of Logic Design Arithmetic Logic Unit (ALU)

Engineer To Engineer Note

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits

9.1 apply the distance and midpoint formulas

Concepts Introduced. A 1-Bit Logical Unit. 1-Bit Half Adder (cont.) 1-Bit Half Adder

Unit 5 Vocabulary. A function is a special relationship where each input has a single output.

Rational Numbers---Adding Fractions With Like Denominators.

George Boole. IT 3123 Hardware and Software Concepts. Switching Algebra. Boolean Functions. Boolean Functions. Truth Tables

EECS 281: Homework #4 Due: Thursday, October 7, 2004

Digital Design. Chapter 1: Introduction. Digital Design. Copyright 2006 Frank Vahid

Floating Point Numbers and Interval Arithmetic

ECEN 468 Advanced Logic Design Lecture 36: RTL Optimization

COMPUTER SCIENCE 123. Foundations of Computer Science. 6. Tuples

Section 3.1: Sequences and Series

Digital Design. Chapter 4: Datapath Components

EECS150 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3

Section 10.4 Hyperbolas

Chapter 4: Datapath Components. Instructor: Dr. Hyunyoung Lee. Copyright Based on slides by Frank Vahid. Frank Vahid

9 4. CISC - Curriculum & Instruction Steering Committee. California County Superintendents Educational Services Association

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

5 Regular 4-Sided Composition

EEC 483 Computer Organization

Parallel Square and Cube Computations

Small Business Networking

Geometric transformations

MIPS I/O and Interrupt

Integer Multiplication and Division

SIMPLIFYING ALGEBRA PASSPORT.

10.5 Graphing Quadratic Functions

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26)

CS 241. Fall 2017 Midterm Review Solutions. October 24, Bits and Bytes 1. 3 MIPS Assembler 6. 4 Regular Languages 7.

Chapter 1: Introduction

2 Computing all Intersections of a Set of Segments Line Segment Intersection

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

Lecture 8: Addition, Multiplication & Division

EECS150 - Digital Design Lecture 23 - High-level Design and Optimization 3, Parallelism and Pipelining

LAB L Hardware Building Blocks

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Dynamic Programming. Andreas Klappenecker. [partially based on slides by Prof. Welch] Monday, September 24, 2012

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

MIPS Integer ALU Requirements

Review of Last lecture. Review ALU Design. Designing a Multiplier Shifter Design Review. Booth s algorithm. Today s Outline

COMPUTER ARITHMETIC (Part 1)

Module 2: Computer Arithmetic

Engineer-to-Engineer Note

Algorithm Design (5) Text Search

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

CMU Fall VLSI CAD

An Efficient Divide and Conquer Algorithm for Exact Hazard Free Logic Minimization

Small Business Networking

Stack. A list whose end points are pointed by top and bottom

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

a < a+ x < a+2 x < < a+n x = b, n A i n f(x i ) x. i=1 i=1

CS/COE 0447 Example Problems for Exam 2 Spring 2011

Matrices and Systems of Equations

Chapter 3 Arithmetic for Computers

CPS 104 Computer Organization and Programming

Review: MIPS Organization

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig

Small Business Networking

MATH 25 CLASS 5 NOTES, SEP

Digital Design using HDLs EE 4755 Final Examination

1 Quad-Edge Construction Operators

Grade 7/8 Math Circles Geometric Arithmetic October 31, 2012

Timing for Ripple Carry Adder

Small Business Networking

PYTHON PROGRAMMING. The History of Python. Features of Python. This Course

Small Business Networking

Enginner To Engineer Note

Today s Lecture. Basics of Logic Design: Boolean Algebra, Logic Gates. Recursive Example. Review: The C / C++ code. Recursive Example (Continued)

Union-Find Problem. Using Arrays And Chains. A Set As A Tree. Result Of A Find Operation

Computer Architecture Set Four. Arithmetic

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

Small Business Networking

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

50 AMC LECTURES Lecture 2 Analytic Geometry Distance and Lines. can be calculated by the following formula:

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

Lecture T4: Pattern Matching

Hyperbolas. Definition of Hyperbola

CS201 Discussion 10 DRAWTREE + TRIES

COMP 423 lecture 11 Jan. 28, 2008

RATIONAL EQUATION: APPLICATIONS & PROBLEM SOLVING

Small Business Networking

T insn-mem T regfile T ALU T data-mem T regfile

ZZ - Advanced Math Review 2017

Transcription:

Wht do ll those bits men now? bits (...) Number Systems nd Arithmetic or Computers go to elementry school instruction R-formt I-formt... integer dt number text chrs... floting point signed unsigned single precision double precision............ Questions About Numbers How do you represent negtive numbers? frctions? relly lrge numbers? relly smll numbers? How do you do rithmetic? identify errors (e.g. overflow)? Wht is n nd wht does it look like? =rithmetic logic unit Introduction to Binry Numbers Consider 4-bit binry number Deciml Binry Deciml Binry 4 5 6 7 Exmples of binry rithmetic: = 5 = 6

Negtive Numbers? Some Alterntives We would like number system tht provides obvious representtion of,,... uses dder for ddition single vlue of equl coverge of positive nd negtive numbers esy detection of sign esy negtion Sign Mgnitude -- MSB is sign bit, rest the sme - == -5 == One s complement -- flip ll bits to negte - == -5 == Two s Complement Representtion s complement representtion of negtive numbers Tke the bitwise inverse nd dd Biggest 4-bit Binry Number: 7 Smllest 4-bit Binry Number: -8 Deciml -8-7 -5 - - - 4 5 6 7 Two s Complement Binry Two s Complement Arithmetic Deciml s Complement Binry Deciml s Complement Binry - - - 4-5 5 6-7 7-8 Exmples: 7-6 = 7 (- 6) = - 5 = (- 5) = -

Some Things We Wnt To Know About Our Number System Detection negtion sign extension =>,, - =>,, overflow detection 5 6 5 7 - -5 7 So how do we detect overflow? Instruction Fetch Instruction Decode Opernd Fetch Execute Store Next Instruction Arithmetic -- The hert of instruction execution b opertion result Designing n Arithmetic Logic Unit A B N N op Control Lines (op) Function And Or Add Subtrct Set-on-less-thn N Zero

A One Bit -bit A -bit -bit This -bit will perform AND, OR, nd ADD b b - b b b b How About Subtrction? Keep in mind the following: (A - B) is the sme s: A (-B) s Complement negte: Tke the inverse of every bit nd dd Bit-wise inverse of B is!b: A - B = A (-B) = A (!B ) = A!B b Binvert Detection Logic Crry into MSB! = Crry out of MSB For N-bit : = [N - ] XOR [N - ] A B A B A B A B -bit -bit -bit -bit X Y X XOR Y

Zero Detection Logic Zero Detection Logic is just one BIG NOR gte Any non-zero input to the NOR gte will cuse its output to be zero Set-on-less-thn A B A B A B A B -bit -bit -bit -bit Do subtrct use sign bit route to bit of result ll other bits zero Binvert b. Binvert b detection b. Set Binvert b b b b Full Bnegte b b b b Set Set wht signls ccomplish: neg oper dd? sub? nd? Zero or? beq? slt? The Disdvntge of Ripple Crry The dder we just built is clled Ripple Crry Adder The crry bit my hve to propgte from LSB to MSB Worst cse dely for n N-bit RC dder: N-gte dely A -bit B A -bit B A -bit B A -bit B A B sign bit (dder output from bit ) The point -> ripple crry dders re slow. Fster ddition schemes re possible tht ccelerte the movement of the crry from one end to the other.

MULTIPLY Pper nd pencil exmple: Multiplicnd Multiplier x MULTIPLY HARDWARE Version 64-bit Multiplicnd reg, 64-bit, 64-bit Product reg, -bit multiplier reg Multiplicnd Shift left Product =? m bits x n bits = mn bit product Binry mkes it esy: => plce ( x multiplicnd) => plce multiplicnd ( x multiplicnd) we ll look t couple of versions of multipliction hrdwre 64-bit Product Write Control test Multiplier Shift right bits Multiply Algorithm Version Multiplier Multiplicnd Product Multiplier =. Add multiplicnd to product nd plce the result in Product register Strt. Test Multiplier. Shift the Multiplicnd register left bit. Shift the Multiplier register right bit nd repetition? Multiplier = No: < repetitions Observtions on Multiply Version clock per cycle => clocks per multiply Rtio of multiply to dd : / bits in multiplicnd lwys => 64-bit dder is wsted s inserted in left of multiplicnd s shifted => lest significnt bits of product never chnged once formed Insted of shifting multiplicnd to left, shift product to right? Wsted spce (zeroes) in product register exctly mtches meningful bits of multiplier t ll times. Combine? Yes: repetitions Done

MULTIPLY HARDWARE Version -bit Multiplicnd reg, -bit, 64-bit Product reg, (-bit Multiplier reg) -bit Multiplicnd bits Product Shift right Write Multiplicnd Product Control test Product =. Add multiplicnd to the left hlf of the product nd plce the result in the left hlf of the Product register Strt. Test Product. Shift the Product register right bit nd repetition? Done Product = No: < repetitions Yes: repetitions Observtions on Multiply Version steps per bit becuse Multiplier & Product combined -bit dder MIPS registers Hi nd Lo re left nd right hlf of Product Gives us MIPS instruction MultU Wht bout signed multipliction? esiest solution is to mke both positive & remember whether to complement product when done. Divide: Pper & Pencil DIVIDE HARDWARE Version Divisor Quotient Dividend 64-bit Divisor reg, 64-bit, 64-bit Reminder reg, -bit Quotient reg Divisor Shift right Reminder See how big number cn be subtrcted, creting quotient bit on ech step Binry => * divisor or * divisor Dividend = Quotient x Divisor Reminder 64-bit Reminder Write Control test Quotient Shift left bits

Divide Algorithm Version Tkes n steps for n-bit Quotient & Rem. Quotient Divisor Reminder Reminder >= Strt. Subtrct the Divisor register from the Reminder register, nd plce the result in the Reminder register. Test Reminder Reminder < DIVIDE HARDWARE Version -bit Divisor reg, -bit, 64-bit Reminder reg, (-bit Quotient reg) Divisor Strt. Shift the Reminder register left bit. Subtrct the Divisor register from the left hlf of the Reminder register nd plce the result in the left hlf of the Reminder register. Shift the Quotient register to the left setting the new rightmost bit to.. Shift the Divisor register right bit. rd repetition? b. Restore the originl vlue by dding the Divisor register to the Reminder register, nd plce the sum in the Reminder register. Also shift the Quotient register to the left, setting the new lest significnt bit to. No: < repetitions bits -bit Reminder Shift right Shift left Write Control test Reminder > Reminder < Test Reminder. Shift the Reminder register to the b. Restore the originl vlue by dding left, setting the new rightmost bit to the Divisor register to the left hlf of the Reminder register nd plce the sum in the left hlf of the Reminder register. Also shift the Reminder register to the left, setting the new rightmost bit to No: < repetitions nd repetition? Yes: repetitions Yes: repetitions Done. Shift left hlf of Reminder right bit Done Observtions on Divide Version Sme Hrdwre s Multiply: just need to dd or subtrct, nd 6-bit register to shift left or shift right Hi nd Lo registers in MIPS combine to ct s 64-bit register for multiply nd divide Signed Divides: Simplest is to remember signs, mke positive, nd complement quotient nd reminder if necessry Note: Dividend nd Reminder must hve sme sign Note: Quotient negted if Divisor sign & Dividend sign disgree Key Points Instruction Set drives the design performnce, CPU clock speed driven by dder dely Multipliction nd division tke much longer thn ddition, requiring multiple ddition steps.