UNIT IV: DATA PATH DESIGN

Similar documents
Computer Architecture and Organization

Principles of Computer Architecture. Chapter 3: Arithmetic

Sign & Magnitude vs 2 s Complement ( Signed Integer Representa:ons)

Organisasi Sistem Komputer

Floa.ng Point : Introduc;on to Computer Systems 4 th Lecture, Sep. 10, Instructors: Randal E. Bryant and David R.

Divide: Paper & Pencil

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

Chapter 4 Arithmetic Functions

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

Number Systems and Computer Arithmetic

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Floats are not Reals. BIL 220 Introduc6on to Systems Programming Spring Instructors: Aykut & Erkut Erdem

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8

Chapter 3: part 3 Binary Subtraction

EC2303-COMPUTER ARCHITECTURE AND ORGANIZATION

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

CO212 Lecture 10: Arithmetic & Logical Unit

Module 2: Computer Arithmetic

Floating Point Arithmetic

MIPS Integer ALU Requirements

ECE 30 Introduction to Computer Engineering

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Chapter 4. Combinational Logic

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

By, Ajinkya Karande Adarsh Yoga

EE 109 Unit 6 Binary Arithmetic

CPE300: Digital System Architecture and Design

Chapter 10 Binary Arithmetics

CS222: Processor Design

Chapter 5 : Computer Arithmetic

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Floa=ng- Point Numbers

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Chapter 10 - Computer Arithmetic

Arithmetic and Logical Operations

CO Computer Architecture and Programming Languages CAPL. Lecture 9

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Writing a Fraction Class

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

How a computer runs a program. Binary Representa8on and Opera8ons on Binary Data. Opera8ng System 9/17/13. You can view binary file contents

Foundations of Computer Systems


Chapter 3: Arithmetic for Computers

EE878 Special Topics in VLSI. Computer Arithmetic for Digital Signal Processing

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)

CHW 261: Logic Design

Advanced Computer Architecture-CS501

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Chapter 4. Operations on Data

Chapter 2 Data Representations

INF2270 Spring Philipp Häfliger. Lecture 4: Signed Binaries and Arithmetic

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

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

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

Outline. Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers. Reading Assignment:

BINARY SYSTEM. Binary system is used in digital systems because it is:

Outline. Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers. Reading Assignment:

Topics. 6.1 Number Systems and Radix Conversion 6.2 Fixed-Point Arithmetic 6.3 Seminumeric Aspects of ALU Design 6.4 Floating-Point Arithmetic

D I G I T A L C I R C U I T S E E

COMPUTER ORGANIZATION AND ARCHITECTURE

Number Systems CHAPTER Positional Number Systems

Experiment 7 Arithmetic Circuits Design and Implementation

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

PESIT Bangalore South Campus

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers Implementation

Measuring Improvement When Using HUB Formats to Implement Floating-Point Systems under Round-to- Nearest

Data Representa+on: Floa+ng Point Numbers

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

CS/COE 0447 Example Problems for Exam 2 Spring 2011

carry in carry 1101 carry carry

UNIT-III COMPUTER ARTHIMETIC

Computer Architecture Set Four. Arithmetic

ECE 341 Midterm Exam

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state

Number System. Introduction. Decimal Numbers

Data Representations & Arithmetic Operations

Roadmap. The Interface CSE351 Winter Frac3onal Binary Numbers. Today s Topics. Floa3ng- Point Numbers. What is ?

Number Systems. Both numbers are positive

Computer Arithmetic andveriloghdl Fundamentals

The Sign consists of a single bit. If this bit is '1', then the number is negative. If this bit is '0', then the number is positive.

Floating Point. CSE 238/2038/2138: Systems Programming. Instructor: Fatma CORUT ERGİN. Slides adapted from Bryant & O Hallaron s slides

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Arithmetic Logic Unit

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

Lecture 2: Number Representa2on

International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering

Computer Organisation CS303

FPGA IMPLEMENTATION OF FLOATING POINT ADDER AND MULTIPLIER UNDER ROUND TO NEAREST

COMPUTER ARITHMETIC (Part 1)

Real Digital Problem Set #6

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

Transcription:

UNIT IV: DATA PATH DESIGN

Agenda Introduc/on Fixed Point Arithme/c Addi/on Subtrac/on Mul/plica/on & Serial mul/plier Division & Serial Divider Two s Complement (Addi/on, Subtrac/on) Booth s algorithm Design of basic serial adders Serial & parallel(ripple) Subtractors High speed adders Floa/ng Point Arithme/c Addi/on & Subtrac/on Guard, Round & S/cky bits Mul/plica/on & Division Combina/onal & Sequen/al ALU: Assignment 2

Data Representa/on

Fixed Point Numbers

Fixed Point Numbers: Decimal to Binary Conversion

Fixed Point Numbers: Unsigned Integers

Signed Integers

Fixed Point Arithme/c Four basic arithme/c instruc/ons: Addi/on Subtrac/on Mul/plica/on Division

Addi/on

Addi/on

Subtrac/on

Subtrac/on: Example

Mul/plica/on

Mul/plica/on Example

Mul/plica/on Example Multiplication of two 4-bit unsigned binary integers produces an 8-bit result. Multiplication of two 4-bit signed binary integers produces only a 7-bit result (each operand reduces to a sign bit and a 3-bit magnitude for each operand, producing a sign-bit and a 6-bit result).

Mul/plica/on: A serial Mul/plier

Mul/plica/on: Example

Division: Example

Division: Example

Division: Example of Base 2 (7 / 3 = 2) 10 with a remainder R of 1. Equivalently, (0111/ 11 = 10) 2 with a remainder R of 1.

Sign-Magnitude LeV most bit is sign bit 0 means posi/ve 1 means nega/ve +18 = 00010010-18 = 10010010 Problems Need to consider both sign and magnitude in arithme/c Two representa/ons of zero (+0 and -0)

Two s Complement: Signed Integers Numbers are added or subtracted on the number circle by traversing clockwise for addi/on and counterclockwise for subtrac/on. Unlike the number line (a) where overflow never occurs, overflow occurs when a transi/on is made from +3 to -4 while proceeding around the number circle when adding, or from -4 to +3 while subtrac/ng. 2-bits 0,1,2,3 3-bits 0-7 0-3, (-1)-(-4) 4-bits 0-15 0-7, (-1)-(-8)

Two s Complement: Unsigned Integers

Two s Complement

Two s Complement

Two s Complement: Addi/on

Two s Complement: Subtrac/on

Two s Complement: Subtrac/on

Addi/on and Subtrac/on Normal binary addi/on Monitor sign bit for overflow Take twos compliment of substahend and add to minuend i.e. a - b = a + (-b) So we only need addi/on and complement circuits

Hardware for Addi/on and Subtrac/on

2's complement of floa/ng point numbers: Example

2's complement of floa/ng point numbers To create 2's complement: Take the number given by you 010111.1100. Start on the least significant bit and locate the first 1 marked red 010111.1100. Then flip every bit aver that first one (1 change to zero and vice verse) 010111.1100-> 101000.0100

2's complement of floa/ng point numbers: Example Example: 2.50 6.75 = -3.75

Conversion of 2 s complement to decimal

Booth s Algorithm :Mul/plying Nega/ve Numbers

Example of Booth s Algorithm Q 0 Q -1 Opera8on 0 0 ShiVing Multiplicand (M) = 0111 = 7 Multiplier (Q) = 0011 = 3 1 1 ShiVing 1 0 A = A M ShiVing 0 1 A = A + M ShiVing No. of cycles = No. of bits

Half Adder It adds two 1 bits but has no provision to include the carry output from previous bit posi/on.

Full Adder It is a combina/onal circuit that forms the arithme/c sum of three input bits. It consists of three inputs & two outputs. Two input variables as A & B. The third input Cin represents the carry from the previous bit posi/on.

Full Subtractor Truth table and schematic symbol for a ripple-borrow subtractor:

Serial Adder A serial adder has only a single bit adder. It is used to perform addi/on of two numbers sequen/ally bit by bit. Addi/on of one bit posi/on takes one clock cycle. Thus for n-bit serial adder, n clock cycles are required to complete the addi/on process & get the result. At each cycle, the carry produced by a bit posi/on is stored in a flip-flop & it is given as an input during the next cycle as carry.

Serial Adder

N-bit Ripple/Parallel Adder N-bit parallel adder using n number of full-adder circuits connected in cascade. The carry output of each adder is connected to the carry input of the next higher-order adder.

4-bit Ripple Carry Adder Two binary numbers A and B are added from right to lev, crea/ng a sum and a carry at the outputs of each full adder for each bit posi/on.

Construc/ng Larger Adders A 16-bit adder can be made up of a cascade of four 4-bit ripple-carry adders.

Ripple-Borrow Subtractor A ripple-borrow subtractor can be composed of a cascade of full subtractors. Two binary numbers A and B are subtracted from right to lev, crea/ng a difference and a borrow at the outputs of each full subtractor for each bit posi/on

Ripple Adder/Subtractor (Combined) A single ripple-carry adder can perform both addi/on and subtrac/on. The subtrac/on A-B ca be done by taking two s complement of B & adding it to A. 2 s complement can be obtained by taking 1 s complement & adding one to the least significant pair of bits. 1 s complement can be implemented with inverters & a one can be added to the sum through the input carry to get 2 s complement.

Design of Fast Adders

Carry Lookahead Adder One method of speeding up this process by elimina/ng inter stage carry delay is called lookahead-carry addi/on. This method look at the lower-order bits of augend & addend to see if a higher order carry is to be generated. It uses two func/ons: carry generate & carry propogate.

N- bit Carry Lookahead Adder

Carry-Lookahead Addi/on s i = a i b i c i + a i b i c i + a i b i c i + a i b i c i c i+1 = b i c i + a i c i + a i b i c i+1 = a i b i + (a i + b i )c i Carries are represented in terms of G i (generate) and P i (propagate) expressions. c i+1 = G i + P i c i G i = a i b i and P i = a i + b i c 0 = 0 c 1 = G 0 c 2 = G 1 + P 1 G 0 c 3 = G 2 + P 2 G 1 + P 2 P 1 G 0

Floa/ng Point Representa/on

Floa/ng Point Arithme/c Floating point arithmetic differs from integer arithmetic in that exponents must be handled as well as the magnitudes of the operands. The exponents of the operands must be made equal for addition and subtraction. The fractions are then added or subtracted as appropriate, and the result is normalized. Increase the power of exponent: Right shift Decrease the power of exponent: Left shift

Floa/ng Point Arithme/c Ex: Perform the floating point operation: (.101 2 3 +.111 2 4 ) 2 Start by adjusting the smaller exponent to be equal to the larger exponent, and adjust the fraction accordingly. Thus we have.101 2 3 =.0101 2 4, rounding off to.010 2 4 (.0101-.010) 2 4 =.0001 2 4 =.001 2 3 Therefore, losing.001 2 3 of precision in the process. The resulting sum is (.010 +.111) 2 4 = 1.001 2 4 =.1001 2 5, and rounding to three significant digits,.100 2 5, and we have lost another 0.001 2 4 in the rounding process.

Floa/ng Point Arithme/c (Cont ) If we simply added the numbers using as much precision as we needed and then applied rounding only in the final normalization step, then the calculation would go like this: Normalizing yields.10011 2 5, and rounding to three significant digits using the round to nearest even method yields.101 2 5. Which calculation is correct.100 x 2 5 or.101 x 2 5? According to the IEEE 754 standard, the final result should be the same as if the maximum precision needed is used before applying the rounding method, and so the correct result is.101 2 5. So what do we do?

Rounding using G, R, S 1.BBGRXXX Guard bit: LSB of result Round bit: 1 st bit removed Sticky bit: OR of remaining bits If G=1 & R=1, add 1 to LSB If G=0 & R=0 or 1, no change If G=1 & R=0, look at S If S=1, add 1 to LSB If S=0, round to the nearest even (i.e. if LSB =1, then make it 0 (add 1 to LSB) & if LSB =0 then no change 1 = ODD, 0 = EVEN)

Guard, Round, and S/cky Bits This raises the issue of how to compute the intermediate results with sufficient accuracy and without requiring too much hardware, and for this we use guard, round, and sticky bits. For the previous example, applying guard (g) and round (r) bits with the round toward nearest even method, we have:

Guard, Round, and S/cky Bits Only one extra bit is needed for this intermediate result, the guard bit (g), but we also show the round bit (r = 0) to locate its position. As we shift the number to normalize, we set a sticky bit (s) if any of the shifted out bits are nonzero. For this case, there are no nonzero bits to the right of the r bit and so s = 0:

Guard, Round, and S/cky Bits (Cont ) Now for the rounding step: simply append the sticky bit to the right of the result before rounding. There is no tie as there would be for.100100 and so we round up, otherwise we would have rounded down to the closest even number (.100): For this case, the guard, round, and sticky bits changed our previous result. Note that if r is 0 instead of 1, so that the grs combination is 100, we would have rounded down to.100 because.100 is even whereas.101 is not.

Examples: Guard, Round, and S/cky Bits Frac/on GRS Incr? Rounded 1.000000 000 N 1.000 1.101100 100 Y 1.110 1.000010 010 N 1.001110 1.000 110 Y 1.000111 1.010 111 Y 1.111111 1.001111 Y 10.000 If G=1 & R=1, add 1 to LSB If G=0 & R=0 or 1, no change If G=1 & R=0, look at S If S=1, add 1 to LSB If S=0, round to the nearest even (i.e. if LSB =1, then make it 0 (add 1 to LSB) & if LSB =0 then no change 1 = ODD, 0 = EVEN)

Floa/ng Point Mul/plica/on/Division Floating point multiplication/division are performed in a manner similar to floating point addition/subtraction, except that the sign, exponent, and fraction of the result can be computed separately. Like/unlike signs produce positive/negative results, respectively. Exponent of result is obtained by adding exponents for multiplication, or by subtracting exponents for division. Fractions are multiplied or divided according to the operation, and then normalized. Ex: Perform the floating point operation: (+.110 2 5 ) / (+.100 2 4 ) 2 The source operand signs are the same, which means that the result will have a positive sign. We subtract exponents for division, and so the exponent of the result is 5 4 = 1. We divide fractions, producing the result: 110/100 = 1.10. Putting it all together, the result of dividing (+.110 2 5 ) by (+.100 2 4 ) produces (+1.10 2 1 ). After normalization, the final result is (+.110 2 2 ).

FP Arithme/c +/- Check for zeros Align significands (adjus/ng exponents) Add or subtract significands Normalize result

FP Addi/on & Subtrac/on Flowchart

FP Arithme/c x/ Check for zero Add/subtract exponents Mul/ply/divide significands (watch sign) Normalize Round All intermediate results should be in double length storage

Floating Point Multiplication

Floating Point Division