Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Lecture-3

ALU-3
Division
CSE-2823
Computer Architecture
Dr. Md. Waliur Rahman Miah
Associate Professor, CSE, DUET

Dr. Md. Waliur Rahman Miah Dept of CSE, DUET 1


Today’s Topic

ALU
Division

Ref:
Ch-9 Stallings
Ch-3 Hennessy-Petterson
Dr. Md. Waliur Rahman Miah Dept of CSE, DUET 2
Division
• More complex than multiplication
• Negative numbers are really bad!
• Based on long division
• It even leads to a mathematically invalid
operation: dividing by 0
• less frequent

Dr. Md. Waliur Rahman Miah Dept of CSE, DUET


Division of Unsigned Binary Integers
147 ÷ 11 = 13; 𝑅=4

00001101 Quotient

Divisor 1011 10010011 Dividend


1011
001110
Partial
1011
Remainders
001111
1011
100 Remainder

Dividend = Quotient X Divisor + Remainder

Dr. Md. Waliur Rahman Miah Dept of CSE, DUET


Division hardware (primitive)

The remainder
is initialized
with the
dividend.

FIGURE 3.8 [Patterson & Hennessy ]


Dr. Md. Waliur Rahman Miah Dept of CSE, DUET
The remainder
is initialized
with the
dividend.
A division
algorithm,
Unsigned Division

Remember the num of iteration:


1 more than the num of bits

FIGURE 3.9 [Patterson & Hennessy ]

Dr. Md. Waliur Rahman Miah Dept of CSE, DUET


Division Example (7  2) initialized
with the
dividend.

FIGURE 3.10 [Patterson & Hennessy ]


Dr. Md. Waliur Rahman Miah Dept of CSE, DUET
Division hardware Initial:
RQ register => Dividend
(improved) right half = Q = Dividend
Final:
Left half of the RQ register
=> Remainder(R)
Right half of the RQ
register => Quotient(Q)

Dividend (RQ)
Remainder(R)|Quotient(Q)

FIGURE 3.8 [Patterson & Hennessy ]


Dr. Md. Waliur Rahman Miah Dept of CSE, DUET
Division hardware
(improved)
Dividend
Itera Divisor
Step (RQ)
tion (D)
R | Q
0 Initial values 0010 0000 0111
1: Shift Left RQ; 0010 0000 1110
Step 2: R = R – D 0010 1110 1110
-1: 3: R < 0 ⇒ +D, (restor R);
0010 0000 1110
Q0 = 0
1: Shift Left RQ; 0010 0001 1100
Step 2: R = R – D 0010 1111 1100
-2 3: R < 0 ⇒ +D, (restor R);
0010 0001 1100
Q0 = 0
1: Shift Left RQ; 0010 0011 1000
Step
2: R = R – D 0010 0001 1000
-3
3: R ≥ 0 ⇒ ; Q0 = 1 0010 0001 1001
1: Shift Left RQ; 0010 0011 0010
Step
2: R = R – D 0010 0001 0010
-4
3: R ≥ 0 ⇒ ; Q0 = 1 0010 0001 0011

Dr. Md. Waliur Rahman Miah Dept of CSE, DUET


Signed Division
• remember the signs of the divisor and dividend and
then negate the quotient if the signs disagree
• Dividend = Quotient  Divisor + Remainder
• V=QD+R [this formula should always hold]
• + 7 = (3  2) + (+1) = 6 + 1 ; [(+7)  (+2)]
• + 7 = ( 3   2) + 1 = 6 + 1; [(+ 7)  ( 2)]
•  7 = (3   2) + ( 1) =  6 + ( 1) ; [( 7)  ( 2)]
•  7 = ( 3  2) + ( 1) =  6 + ( 1) ; [( 7)  (+ 2)]
• Dividend(V) and remainder(R) must have the same
signs, no matter what the signs of the divisor(D) and
quotient(Q).
Dr. Md. Waliur Rahman Miah Dept of CSE, DUET 10
Reference
[1] Patterson, D. A., & Hennessy, J. L. (2014). Computer
organization and design: The hardware/software interface
(5th ed.). Burlington, MA: Morgan Kaufmann Publishers.

[2] William Stallings, (2010), Computer Organization and


Architecture,(8th Ed), Prentice Hall Upper Saddle River, NJ
07458.

[3] Carl Hamacher, Zvonko Vranesic, Safwat Zaky, Naraig


Manjikian, (2012), Computer Organization and Embedded
Systems (6th Ed), McGraw-Hill, New York, NY 10020.

[4] M. Morris Mano (1993), Computer System Architecture (3rd


Ed), Prentice-Hall Inc. USA. (Ch-10-Comp Arith)

Dr. Md. Waliur Rahman Miah Dept of CSE, DUET 11

You might also like