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

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

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

Number Systems and Computer Arithmetic

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

Course Administration

Divide: Paper & Pencil

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

Computer Arithmetic Logical, Integer Addition & Subtraction Chapter

12-B FRACTIONS AND DECIMALS

Basics of Logic Design Arithmetic Logic Unit (ALU)

Engineer To Engineer Note

Parallel Square and Cube Computations

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

Subtracting Fractions

Floating Point Numbers and Interval Arithmetic

10.5 Graphing Quadratic Functions

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

Section 10.4 Hyperbolas

ECEN 468 Advanced Logic Design Lecture 36: RTL Optimization

COMP 303 Computer Architecture Lecture 6

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

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

5 Regular 4-Sided Composition

SIMPLIFYING ALGEBRA PASSPORT.

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

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

Rational Numbers---Adding Fractions With Like Denominators.

Digital Design. Chapter 4: Datapath Components

9.1 apply the distance and midpoint formulas

Tailoring the 32-Bit ALU to MIPS

Small Business Networking

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

10/9/2012. Operator is an operation performed over data at runtime. Arithmetic, Logical, Comparison, Assignment, Etc. Operators have precedence

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

Verification of Floating-Point Adders

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

Review: MIPS Organization

x )Scales are the reciprocal of each other. e

Geometric transformations

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

Engineer-to-Engineer Note

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

MIPS Integer ALU Requirements

MIPS I/O and Interrupt

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

Small Business Networking

Chapter 1: Introduction

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

CMU Fall VLSI CAD

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

Before We Begin. Introduction to Spatial Domain Filtering. Introduction to Digital Image Processing. Overview (1): Administrative Details (1):

Module 2: Computer Arithmetic

Section 3.1: Sequences and Series

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

Small Business Networking

4452 Mathematical Modeling Lecture 4: Lagrange Multipliers

Small Business Networking

Small Business Networking

Computer Architecture. Chapter 3: Arithmetic for Computers

6.2 Volumes of Revolution: The Disk Method

Today. CS 188: Artificial Intelligence Fall Recap: Search. Example: Pancake Problem. Example: Pancake Problem. General Tree Search.

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

Small Business Networking

Digital Signal Processing: A Hardware-Based Approach

Integration. September 28, 2017

LAB L Hardware Building Blocks

Small Business Networking

Small Business Networking

MATH 25 CLASS 5 NOTES, SEP

Accelerating 3D convolution using streaming architectures on FPGAs

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

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

Study Guide for Exam 3

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

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

COMPUTER ORGANIZATION AND DESIGN

6/23/2011. Review: IEEE-754. CSE 2021: Computer Organization. Exercises. Examples. Shakil M. Khan (adapted from Profs. Roumani & Asif)

Transparent neutral-element elimination in MPI reduction operations

CSE 401 Midterm Exam 11/5/10 Sample Solution

Approximate computations

Digital Design. Chapter 6: Optimizations and Tradeoffs

Fault injection attacks on cryptographic devices and countermeasures Part 2

Angle properties of lines and polygons

Ray surface intersections

a(e, x) = x. Diagrammatically, this is encoded as the following commutative diagrams / X

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

Matrices and Systems of Equations

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

ALU Design. 1-bit Full Adder 4-bit Arithmetic circuits. Arithmetic and Logic Unit Flags. Add/Subtract/Increament/Decrement Circuit

Computer Architecture Set Four. Arithmetic

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

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

CPE300: Digital System Architecture and Design

Integration. October 25, 2016

Timing for Ripple Carry Adder

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

2-3 search trees red-black BSTs B-trees

Transcription:

Questions About Numbers Number Systems nd Arithmetic or Computers go to elementry school 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 klik 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? 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

Some Alterntives 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 ti of negtive numbers Tke the bitwise inverse nd dd Biggest 4-bit Binry Number: 7 Smllest 4-bit Binry Number: -8 Deciml -8-7 -6-5 -4 - - - 4 5 6 7 Two s Complement Binry Two s Complement Arithmetic Deciml s Complement Binry Deciml s Complement Binry - - - -4 4-5 5-6 6-7 7-8 Exmples: 7-6 = 7 (- 6) = - 5 = (- 5) = - Some Things We Wnt To Know About Our Number System negtion sign extension =>,, - =>,, overflow detection 5 6

Detection Instruction Fetch Arithmetic -- The hert of finstruction ti execution -4 Instruction Decode - 5-6 Opernd Fetch opertion 7-6 7-4 -5 Execute Store b result So how do we detect overflow? Next Instruction Designing n Arithmetic Logic Unit A B N N op N Zero Control Lines (op) Function And Or Add Subtrct Set-on-less-thn A One Bit This -bit will perform AND, OR, nd ADD - 4 - -6 b

A -bit -bit -bit b b How About Subtrction? Keep in mind the following: (A - B) is the sme s: A (-B) s 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 Binvert b b b b Detection Logic Crry into MSB! = Crry out of MSB For N-bit : = [N - ] XOR [N - ] A -bit B A -bit B A -bit B A -bit B 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 A B A B A B A B -bit -bit -bit -bit

Set-on-less-thn Binvert b Binvert Full Bnegte Do subtrct use sign bit route to bit of result ll other bits zero. Binvert b b b b b b b wht signls ccomplish: Binvert CIn Oper dd? sub? nd? or? beq? slt? Zero Set b. detection b b Set Set sign bit (dder output from bit ) The Disdvntge of Ripple Crry MULTIPLY 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 Pper nd pencil exmple: Multiplicnd Multiplier x Product =? m bits x n bits = mn bit product Binry mkes it esy: => plce ( x multiplicnd) => plce multiplicnd ( x multiplicnd) 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 HARDWARE Observtions on Multiply 64-bit Multiplicnd reg, 64-bit, 64-bit Product reg, -bit multiplier reg 64-bit Multiplicnd Shift left 64 bits Multiplier Shift right bits 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. Product 64 bits Write Control test Divide: Pper & Pencil DIVIDE HARDWARE Divisor Quotient Dividend 64-bit Divisor reg, 64-bit, 64-bit Reminder reg, -bit Quotient reg Divisor 64 bits 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 64 bits Write Control test Quotient Shift left bits

Divide Hrdwre Hi nd Lo registers in MIPS combine to ct s 64-bit register for multiply nd divide Signed Divides: id 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. Binry Frctions = x x x x so.... = x x x x - x - x - e.g.,.75 = /4 = / = / /4 =. sign Recll Scientific Nottion deciml point Mntiss exponent -4 6. x.67 x rdix (bse) Issues: Arithmetic (, -, *, / ) Representtion, Norml form Rnge nd Precision Rounding Exceptions (e.g., divide by zero, overflow, underflow) Errors Properties ( negtion, inversion, if A = B then A - B = )

Floting-Point Numbers Representtion of floting point numbers in IEEE 754 stndrd: 8 single precision sign S E M exponent: excess 7 binry integer (ctul exponent is e = E - 7) mntiss: sign mgnitude, normlized binry significnd w/ hidden integer bit:.m N = (-) S E-7(.M) < E < 55 =... -.5 =... 5 = X =. X 8 =. =... X =... X - =... rnge of bout X -8 to X 8 lwys normlized (so lwys leding, thus never shown) specil representtion of (E = ) (why?) cn do integer compre for greter-thn, sign Wht do you notice?.5 * -.75 * -.5 *.75* Does this work with negtive numbers, s well? Double Precision Floting Point Floting Point Addition Representtion of floting point numbers in IEEE 754 stndrd: double precision sign S E M M exponent: mntiss: excess binry integer sign mgnitude, normlized binry significnd w/ hidden ctul exponent is e = E - integer bit:.m N = (-) S E-(.M) < E < 48 5 () bit mntiss rnge of bout X -8 to X 8 How do you dd in scientific nottion? 9.96 x 4 5. x Bsic Algorithm. Align. Add. Normlize 4. Round

FP Addition Hrdwre Sign Exponent Significnd Sign Exponent Significnd Floting Point Multipliction Smll Exponent difference Compre exponents How do you multiply in scientific nottion? (9.9 x 4 )(5. x ) = 5.48 x 7 Control Increment or decrement Shift right Rounding hrdwre Big Shift left or right Shift smller number right Add Normlize Round Bsic Algorithm. Add exponents. Multiply. Normlize 4. Round 5. Set Sign Sign Exponent Significnd FP Accurcy Extremely importnt in scientific clcultions Very tiny errors cn ccumulte over time IEEE 754 FP stndrd hs four rounding modes lwys round up (towrd ) lwys round down (towrd - ) truncte round dto nerest => in cse of tie, round to nerest even Requires extr bits in intermedite representtions Key Points Floting Point extends the rnge of numbers tht cn be represented, t the expense of precision (ccurcy). FP opertions re very similr il to integer, but with pre- nd post-processing. Rounding implementtion is criticl to ccurcy over time.