Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 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. The value of m is specified in a config file config.txt.

Config File

The config file config.txt 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).

What to Submit

a) Code Your source code. On compilation, we should be able to execute your simulator with the following command ./branchsimulator.out config.txt trace.txt Your simulator should output a file trace.txt.out in the same directory. A readme.txt with instructions on how to compile your code Please write detailed comments on your code.

b) Analysis For the provided trace.txt, plot a graph of the branch misprediction rate as a function of m with m varying from 10 to 20. Submit your plot as a PDF file in the same folder as your source code.

Text written in config.txt file : 12

Text written in trace.text :

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions