In this lab, you will simulate a simple branch predictor with a 2-bit saturating counter. You are provided with a text file containing a trace(Below)
In this lab, you will simulate a simple branch predictor with a 2-bit saturating counter. You are provided with a text file containing a trace(Below) of branch instructions consisting of the PC at which each branch occurs, and whether the branch is Taken or Not Taken.
Your goal is write code to evaluate the performance of a 2-bit saturating counter based branch predictor on this trace. Your output file indicates, for each branch in the trace, whether it was predicted as Taken or Not Taken.
Branch Predictor Architecture
Your design must consist of 2m 2-bit saturating counters indexed using m LSBs of each branch instruction. Each 2-bit saturating predictor starts in the 11 (Predict Taken with High Confidence) state and is updated as per the finite state machine discussed in Lecture 9 and 10. The value of m is specified in a config file config.txt.
Config File
The config file config.txt(Below) contains a single line with the value of m. A sample file for m=12 is provided. The largest value of m is 32 (for 32 bit PCs), but we will not input an m larger than 20.
Trace File
The trace file, trace.txt, contains one branch per line. Each line has the PC for the corresponding branch (in hex format) followed by a single bit indicating Taken (1) or Not Taken (0). A sample trace file is provided.
Output Format
The output from your simulator should be a file trace.txt.out that has one line per branch. Each line has a single bit which indicates whether that branch was predicted as Taken (1) or Not Taken (0).
TRACE
b77a8a3a 1 b77be7ab 1 b77b55a0 1 b77b55e2 0 b77b55ec 1 b77a8b56 1 b77ae087 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77ae087 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 0 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77ae087 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77ba936 1 b77be7ab 1 b77bd7bc 1 b77b5acd 0 b77bd747 1 b77b5ae9 0 b77b5af3 1 b77bd98e 1 b77b5b52 1 b77bd936 1 b77abdba 1 b77be7ab 1 b77b55a0 1 b77b55e2 1 b77b55b4 1 b77ae087 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77ae087 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 0 b77bdeb6 1 b77b5c5f 0 b77aa792 1 b77be7ab 1 b77b652a 0 b77b6530 1 b77b654a 0 b77b6554 1 b77be7ab 1 b77b60d4 0 b77b60fa 0 b77b610c 0 b77b6150 1 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77b5c78 1 b77b616e 1 b77b615d 0 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77b5c78 1 b77b616e 1 b77b615d 0 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdeb6 1 b77b5c5f 0 b77b5c6c 1 b77b616e 0 b77b6178 0 b77b6186 1 b77b61b4 0 b77b61dc 1 b77be7ab 1 b77b5d19 0 b77b5d2a 0 b77b5d35 0 b77b5d44 0 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 1 b77bdeb6 1 b77b5e0f 0 b77b5e1c 1 b77b6200 0 b77b620a 1 b77b62b5 1 b77b6303 1 b77bb717 1 b77b6335 0 b77b6357 0 b77b6370 1 b77b6389 0 b77b63b8 0 b77b63c2 1 b77b63d0 1 b77b6428 1 b77b6568 1 b77b654a 0 b77b6554 1 b77be7ab 1 b77b60d4 0 b77b60fa 1 b77b62b5 0 b77b62db 0 b77b62f6 1 b77b62f6 0 b77b6303 1 b77bb717 1 b77b6335 0 b77b6357 1 b77b63d0 0 b77b63e0 1 b77b63f1 1 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 0 b77b6428 1 b77b6568 1 b77b654a 0 b77b6554 1 b77be7ab 1 b77b60d4 0 b77b60fa 0 b77b610c 0 b77b6150 1 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77b5c78 1 b77b616e 1 b77b615d 0 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77b5c78 1 b77b616e 1 b77b615d 0 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77b5c78 1 b77b616e 1 b77b615d 0 b77b6167 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 0 b77bdeb6 1 b77b5c5f 0 b77b5c6c 1 b77b616e 0 b77b6178 0 b77b6186 1 b77b61b4 1 b77b61dc 1 b77be7ab 1 b77b5d19 0 b77b5d2a 0 b77b5d35 0 b77b5d44 0 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 1 b77bdeb6 1 b77b5e0f 0 b77b5e1c 1 b77b6200 1 b77b61b4 1 b77b61dc 1 b77be7ab 1 b77b5d19 0 b77b5d2a 0 b77b5d35 0 b77b5d44 0 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 1 b77bdeb6 1 b77b5e0f 0 b77b5e1c 1 b77b6200 1 b77b61b4 1 b77b61dc 1 b77be7ab 1 b77b5d19 0 b77b5d2a 0 b77b5d35 0 b77b5d44 0 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 0 b77b5d54 0 b77b5d60 1 b77b5d49 1 b77bdeb6 1 b77b5e0f 0 b77b5e1c 1 b77b6200 0 b77b620a 1 b77b62b5 0 b77b62db 0 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 0 b77b6303 1 b77bb717 1 b77b6335 0 b77b6357 0 b77b6370 1 b77b6389 0 b77b63b8 1 b77b6389 0 b77b63b8 1 b77b6389 0 b77b63b8 0 b77b63c2 1 b77b63d0 0 b77b63e0 1 b77b63f1 1 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 0 b77b6428 1 b77b6568 1 b77b654a 0 b77b6554 1 b77be7ab 1 b77b60d4 0 b77b60fa 1 b77b62b5 0 b77b62db 0 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 1 b77b62f6 0 b77b6303 1 b77bb717 1 b77b6335 0 b77b6357 1 b77b63d0 0 b77b63e0 1 b77b63f1 1 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 1 b77b63f1 0 b77b641c 0 b77b6428 1 b77b6568 0 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77a94cc 1 b77be7ab 1 b77b55a0 1 b77b55e2 1 b77b55b4 1 b77a94d8 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1 b77aef9f 1 b77be7ab 1 b77bdec4 1 b77b5c36 0 b77b5c3d 1 b77bdec4 1 b77b5c5f 1 b77b5c4d 1
CONFIG
12
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started