views:

72

answers:

0

Problem ; Consider following simplified code fragment;

if (d==0) d=1;
if (d==1) ...

Construct the action table for the 1-bit predictor with 1-bit correlation assuming predictor initialized to NOT TAKEN and the correlation bit is initialized to TAKEN. The value of d alternates 1,2,1,2 Note count the instances of misprediction.

I tried to solve question my answer is ;

---------------------------------------------------------------
|d=?|B1        |B1    |New B1    |B2        |B2    | New B2   |
|   |Prediction|Action|Prediction|Prediction|Action|Prediction|
---------------------------------------------------------------
|1  | NT/NT    |  T   |  T/NT    | NT/NT    |  NT  |  NT/NT   |
---------------------------------------------------------------
|2  | T/NT     |  T   |  T/NT    | NT/NT    |  T   |  NT/T    |
---------------------------------------------------------------
|1  | T/NT     |  T   |  T/NT    |  NT/T    |  NT  |  NT/NT   |
---------------------------------------------------------------
|2  | T/NT     |  T   |  T/NT    |  NT/NT   |  T   |  NT/T    |
---------------------------------------------------------------

I doubt whether it is true or not ? Any idea ?