Textbook: \"Computer Organization & Architecture: Themes and Variations\" Author
ID: 3686586 • Letter: T
Question
Textbook: "Computer Organization & Architecture: Themes and Variations" Author: Alan Clements Publisher: Cengage Learning Edition: 1st ISBN: 978-1-111-98704-6
7.39 Consider the following code:
LDR r1, [r6] ; Load r1 from memory. R6 is a pointer
ADD r1, r1, #1 ; Increment r1 by 1
LDR r2, [r6, #4] ; Load r2 from memory
ADD r2, r2, #1 ; Increment r2 by 1
ADD r3, r1, r2 ; Add r1 and r2 with total in r3
ADD r8, r8, #4 ; Increment r8 by 4
STR r2, [r6, #8] ; Store r2 in memory
SUB r2, r2, #64 ; Subtract 64 from r2
The processor has a five-stage pipeline F O E M S; that is, instruction fetch, operand fetch, operand execute, memory, and operand writeback to register file.
a. How many cycles does this code take to execute assuming internal forwarding is not used?
b. How many cycles does this code take to execute assuming internal forwarding is used?
c. How many cycles does the code take to execute assuming that it is reordered (no internal forwarding)?
d. How many cycles does the code take to execute assuming reordering and internal forwarding?
Explanation / Answer
a)
without internal
LDR r1, [r6] ; -----------> 1 cycle
ADD r1, r1, #1 ; ---------> 3 cycles
LDR r2, [r6, #4] ;--------> 1 cycle
ADD r2, r2, #1 ; ---------> 3 cycles
ADD r3, r1, r2 ; ---------> 3 cycles
ADD r8, r8, #4 ; ---------> 3 cycles
STR r2, [r6, #8] ; -------> 4 cycles
SUB r2, r2, #64 ; --------> 3 cycles
So totally 21 cycles
----------------------------------------------------------------
b)
With internal cycles, it take double than non internal
So 21 x 2 = 42 cycles
----------------------------------------------------------------
c)
FOEMS
FOEMS
FOEMS
FOEMS
FOEMS
FOEMS
FOEMS
FOEMS
So 8+4 = 12 cycles
------------------------------------------------------------------------------
d) with internal ordering ..
double the original cycles
12x2 = 24 cycles
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.