hw2_solutionc

# hw2_solutionc - HW2 Solutions 1(P5.7 Assume that an...

This preview shows pages 1–3. Sign up to view the full content.

HW2 Solutions 1. (P5.7) Assume that an one-bit (history bit) state machine is used as the prediction algorithm for predicting the execution of the two branches in this loop. Indicate the predicted and actual branch directions of the b1 and b2 branch instructions for each iteration of this loop. Assume initial state of 0, i.e., NT, for the predictor. Consider the following code segment within a loop body for problems 5: if (x is even) then b (branch b1) increment a b (b1 taken) if (x is a multiple of 10) then b (branch b2) increment b b (b2 taken) Use this trace instead: 9, 8, 20, 13, 20, 40, 18, 31, 32 9 8 20 13 20 40 18 31 32 b1 predicted: __N____N____T____T____N____T____T____T____N__ b1 actual: __N____T____T____N____T____T____T____N____T__ b2 predicted: __N____N____N____T____N____T____T____N____N__ b2 actual: __N____N____T____N____T____T____N____N____N__

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2. (P5.10) Assume a two-level branch prediction scheme is used. In addition to the one-bit pre- dictor, a one-bit global register (g) is used. Register g stores the direction of the last branch executed (which may not be the same branch as the branch currently being predicted) and is used to index into two separate one-bit branch history tables (BHTs) as shown below. Use this trace instead: 9, 8, 20, 13, 20, 40, 18, 31, 32
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/30/2011 for the course MECHANICAL MSC taught by Professor Dr.rahula during the Spring '10 term at University of Moratuwa.

### Page1 / 5

hw2_solutionc - HW2 Solutions 1(P5.7 Assume that an...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online