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

Similar documents
Questions About Numbers. Number Systems and Arithmetic. Introduction to Binary Numbers. Negative 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

Computer Arithmetic Logical, Integer Addition & Subtraction Chapter

Divide: Paper & Pencil

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

12-B FRACTIONS AND DECIMALS

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

Parallel Square and Cube Computations

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

Floating Point Numbers and Interval Arithmetic

Subtracting Fractions

COMP 303 Computer Architecture Lecture 6

ECEN 468 Advanced Logic Design Lecture 36: RTL Optimization

Section 10.4 Hyperbolas

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

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

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

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

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

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

5 Regular 4-Sided Composition

10.5 Graphing Quadratic Functions

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

Tailoring the 32-Bit ALU to MIPS

9.1 apply the distance and midpoint formulas

SIMPLIFYING ALGEBRA PASSPORT.

Small Business Networking

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

Rational Numbers---Adding Fractions With Like Denominators.

Verification of Floating-Point Adders

Digital Design. Chapter 4: Datapath Components

x )Scales are the reciprocal of each other. e

Engineer-to-Engineer Note

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

Chapter 1: Introduction

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

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

MIPS Integer ALU Requirements

Small Business Networking

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

MIPS I/O and Interrupt

Geometric transformations

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

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

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

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

Review: MIPS Organization

Small Business Networking

Digital Signal Processing: A Hardware-Based Approach

Small Business Networking

CMU Fall VLSI CAD

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

Small Business Networking

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

Section 3.1: Sequences and Series

4452 Mathematical Modeling Lecture 4: Lagrange Multipliers

Transparent neutral-element elimination in MPI reduction operations

Module 2: Computer Arithmetic

Small Business Networking

Small Business Networking

Small Business Networking

Study Guide for Exam 3

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

Accelerating 3D convolution using streaming architectures on FPGAs

6.2 Volumes of Revolution: The Disk Method

Computer Architecture. Chapter 3: Arithmetic for Computers

Slides for Data Mining by I. H. Witten and E. Frank

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

COMPUTER ORGANIZATION AND DESIGN

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

LAB L Hardware Building Blocks

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

Fault injection attacks on cryptographic devices and countermeasures Part 2

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

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

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

MATH 25 CLASS 5 NOTES, SEP

CPSC 213. Polymorphism. Introduction to Computer Systems. Readings for Next Two Lectures. Back to Procedure Calls

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

CPE300: Digital System Architecture and Design

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

CSE 401 Midterm Exam 11/5/10 Sample Solution

Approximate computations

Digital Design. Chapter 6: Optimizations and Tradeoffs

Angle properties of lines and polygons

Integration. September 28, 2017

CS 130 : Computer Systems - II. Shankar Balachandran Dept. of Computer Science & Engineering IIT Madras

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

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

1 Quad-Edge Construction Operators

ZZ - Advanced Math Review 2017

COMMON HALF YEARLY EXAMINATION DECEMBER 2018

Small Business Networking

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 relly lrge numbers? relly smll numbers? How do you do rithmetic? identify (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? Some Alterntives We would like 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 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) = - + +

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: s s Complement negte: Tke the 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 = m+n 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 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. So Fr Binry Frctions Cn do logicl, dd, subtrct, multiply, divide,... But... wht bout frctions? wht bout relly lrge numbers? = 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 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.