Dylan Ferrara
Program Description: The main file takes in 2 text files, input and output, opens them and reads in from the input file the traces. It keeps reading until it can’t put anything into addr anymore. It then passes addr and behavior to the guess functions from each predictor file. Before that it initializes objects for BimodalSingleBit, BimodalDoubleBit, Gshare, and TournamentPredict. Inside BimodalSingleBit, it initializes a table to all true values, checks the value at the partial addr and updates if its correct or not. Then it sets the value at the table to true or false based on the behavior. Inside BimodalDoubleBit, creates a struct of 2 bool values, makes a table of said structs, and sets those values to false. In this predictor, I flipped the bits for the FSM (00 - Strongly Taken, 01 - Weak Taken, 10 - Weak NT, 11 - Strongly NT). It then checks if the topBit is 0 or 1 and updates the correct counter if the behavior corresponds. It then changes the state based on the previous state (initialized to 00 - Strong Taken) and what the behavior is. Inside Gshare, same design to BimodalDoubleBit except it initializes a global register and global size. It takes in the addr, mods it by the size, and sets it to a new value based on its previous value XOR’d with the global register modded with 1 shifted by the global size. It does the same thing as the BimodalDoubleBit, but updates the global register by shifting it by 1 and bit-wise or-ing it with 1 or 0 depending on the behavior. Inside TournamenPredict, similar initialization to the previous predictors but creates 2 tables for its own Gshare and BimodalDoubleBit with 2048 values and 11 bits for Gsahre. It then makes guesses for the addr from BimodalDoubleBit and Gshare with new functions that are identical to the other guess functions but return a string with their guess in it. It then checks which has the correct guess and updates it state accordingly with the same logic as the other update state blocks. Back to the main file, it then outputs the correct guesses from each predictor into the output file. It then closes both files.