0% found this document useful (0 votes)
13 views3 pages

Quiz2 Sol

The document is a quiz for EE557 at USC, focusing on a perceptron branch predictor problem. It provides a current state of the global history register and a branch PC, requiring the prediction and potential update of the predictor table based on specific calculations. The quiz includes detailed steps for predicting the branch outcome and updating the weights if the prediction is incorrect.

Uploaded by

Ha Moondancer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Quiz2 Sol

The document is a quiz for EE557 at USC, focusing on a perceptron branch predictor problem. It provides a current state of the global history register and a branch PC, requiring the prediction and potential update of the predictor table based on specific calculations. The quiz includes detailed steps for predicting the branch outcome and updating the weights if the prediction is incorrect.

Uploaded by

Ha Moondancer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

NAME: ____________________

USC ID: ___________________

University of Southern California


Department of Electrical Engineering
EE557 Spring 2025
Professor: Murali Annavaram
QUIZ 2

Problem: Perceptron Branch Predictor

Assume that the current state of the global history register is: ghist[5:0] = 101010 and the current
branch PC is PC[31:0]= 00000000000000001000011101010100. You are asked to predict and
update (if needed) a perceptron branch predictor that has a threshold of value θ=3 and has the
following predictor table.

address w5 w4 w3 w2 w1 w0
000 1 3 3 3 -1 1
001 2 -1 0 6 -4 2
010 7 4 -5 -2 -4 7
011 6 -4 1 -2 7 6
100 -2 6 -5 6 2 -2
101 -3 1 6 -7 -2 -3
110 -4 6 6 -2 -4 -4
111 -5 -7 3 1 -2 5

The hash function to be used to produce a table index is:

Hash function: PC[4:2] ⊕ghist[5:3] ⊕ghist[2:0]

Here is a copy of the perceptron branch predictor slide taught in class for your reference.
(Quiz 2 continued)
Answer the following questions using the information we provided:

a) Find the outcome of the prediction. Show your steps in detail.

Hash function:

PC[4:2] ⊕ghist[5:3] ⊕ghist[2:0]

= 101 xor 101 xor 010 = 010

Prediction = ghist[4]*w5 + ghist[3]*w4 + ghist[2]*w3 + ghist[1]*w2 + ghist[0]*w1 + w0

= -w5 + w4 - w3 + w2 - w1 + w0 = -7+ 4 + 5 - 2+ 4 +7 = 11 > 0 Predict taken

b) Assume the branch is not taken, how will you update the predictor state, if any? Enter the
updated weights in the table below and show your steps.

addres w w w w w w
s 5 4 3 2 1 0

000 1 3 3 3 -1 1
001 2 -1 0 6 -4 2
010 7 4 -5 -2 -4 7
011 6 -4 1 -2 7 6
100 -2 6 -5 6 2 -2
101 -3 1 6 -7 -2 -3
110 -4 6 6 -2 -4 -4
111 -5 -7 3 1 -2 5

Update:

When sign(yout) != t or | yout | <= θ (prediction wrong)

wi = wi+t*xi

Since sign(yout)!= t, so we need to update wi 01010

wi = wi+t*xi = wi - ghist[i-1]

w0 = w0 -1 = 7-1 = 6

w1 = w1 +1 = -4 +1 = -3
w2 = w2 -1 = -2 - 1 = -3

w3 = w3 +1 = -5 + 1 = -4

w4 = w4 -1 = 4 - 1 = 3

w5 = w5 +1 = 7 + 1 = 8

You might also like