Iterative Integer Division Techniques Shantanu Dutt UIC.

Slides:



Advertisements
Similar presentations
CMPE 325 Computer Architecture II
Advertisements

Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Division Circuits Jan 2013 Shmuel Wimer Bar Ilan University, Engineering Faculty Technion, EE Faculty 1.
Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 © McQuain Algorithm for Integer Division The natural (by-hand)
Integer division Pencil and paper binary division (dividend)(divisor) 1000.
Division CPSC 321 Computer Architecture Andreas Klappenecker.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
Number Systems Standard positional representation of numbers:
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
Converting binary to decimal decimal to binary
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Data Representation – Binary Numbers
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Multiplication of signed-operands
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
Number Systems & Operations
Partial Quotients.
Partial Quotient Method In this division algorithm the children record on the right side of the problem. The first thing they do is divide. They ask themselves.
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
Chapter 2 Number Systems Consists of a set of symbols called digits and a set of relations such as +, -, x, /.
COE 308: Computer Architecture (T032) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
Introduction To Number Systems Binary System M. AL-Towaileb1.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Division Quotient Divisor Dividend – – Remainder.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
COMPUTER ARITHMETIC Arithmetic with Signed-2's Complement Numbers
Integer Operations Computer Organization and Assembly Language: Module 5.
Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
COMPUTER ARITHMETIC Arithmetic with Signed-2's Complement Numbers
Multiplication and Division basics
Dividing larger Numbers
Digital Logic & Design Adil Waheed Lecture 02.
COMPUTING FUNDAMENTALS
Long Division With 2 Digit Divisor
William Stallings Computer Organization and Architecture 7th Edition
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
CSCI206 - Computer Organization & Programming
Topic 3c Integer Multiply and Divide
ECEG-3202 Computer Architecture and Organization
Computer Architecture
Chapter 8 Computer Arithmetic
Binary to Decimal Conversion
How To Use Times Table - For Long Division!
Presentation transcript:

Iterative Integer Division Techniques Shantanu Dutt UIC

Division – Basics Radix r division is essentially a trial-and-error process, in which the next quotient bit is chosen from 0, …, r = D V = = Q = R Binary division is much simpler, since the next quotient bit is either a 0 or 1 depending on whether the partial remainder is less than or greater than/equal to the divisor, respectively Integer division: Given 2 integers D the dividend and V the divisor, we want to obtain an integer quotient Q and an integer remainder R, s.t. D = V.Q + R, R < V Integer–FP division: Given 2 integers D the dividend and V the divisor, we want to obtain a floating-point (FP) or real quotient s.t. D ~ V.Q SHR-Divisor Method: Start subtraction of V from left most position of D, considering as many digits of D as there are in the V (ignoring leading 0’s). After subtraction, consider the next lower digit of D (i.e., in the “partial remainder”), and align D*(current Q digit) so that LS digits align, and subtract from the PR from that digit to its MS non-0 digit. This is almost equivalent to a SHR V for next subtraction every iteration.

Division – SHL-Partial-Remainder Method Instead of shifting the divisor right by 1 bit, the partial remainder can be shifted left by one bit (in non-binary case, if the current Q bit is non-zero) 353 = D V = = Q = R 330 SHL: = D V = = Q = R SHL: SHL: SHL: If D is n bits and V is k bits (ignoring leading 0’s), perform n-k+1 iterations of the SHL & subtract process

Division – Handling V with leading 0’s Some higher order bits of an n-bit V are 0’s One of the main requisites of correct division by repeated subtraction is that the portion of D (in general the partial remainder) from which V is being subtracted be < 2.V, since the Q bit can only be 0 or 1 Note that for 6-bit division (n=6), V is stored as a 6-bit # (000100) in the computer. The type of manual adjustment done in the above example of converting 6-bit subtractions into 4-bit ones (in general, n- bit subtractions into k-bit ones, k < n, k is the most significant 1’s position in V) is impractical in digital hardware (though a complex circuit may be designable to do variable-bit division) Method 1: –Shift V to the left by n-k-1 bits (until its MSB=1), and perform the div. for n-k steps (equivalently D is considered a n+n-k-1 = 2n-k-1 bit #) –Divide remainder R’ of this process by 2 n-k-1 (SHR by n-k-1 bits) to get final remainder R = D V = = Q = R’ SHL: SHL: SHL:

Division – Handling V with leading 0’s Method 2: Augment D to the left by n-1 0’s, making D a (2n-1)-bit #, while V remains an n-bit #. Perform the division for n iterations Note that this ensures that at least in iteration 1: – The MS n bits of D < 2V. It can be proved that this will be true at the beginning of every iteration, i.e., after subtraction and SHL of the previous iteration = D V = = Q SHL: SHL: SHL: SHL: = R This is the type of division algorithm used in a computer/digital-hardware

16 also n-bit n-bit n’th and

SHL

2’s Complement Division