|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.tools.AbstractMarsToolAndApplication
mars.tools.BHTSimulator
public class BHTSimulator
A MARS tool for simulating branch prediction with a Branch History Table (BHT)
The simulation is based on observing the access to the instruction memory area (text segment). If a branch instruction is encountered, a prediction based on a BHT is performed. The outcome of the branch is compared with the prediction and the prediction is updated accordingly. Statistics about the correct and incorrect number of predictions can be obtained for each BHT entry. The number of entries in the BHT and the history that is considered for each prediction can be configured interactively. A change of the configuration however causes a re-initialization of the BHT.
The tool can be used to show how branch prediction works in case of loops and how effective such simple methods are. In case of nested loops the difference of BHT with 1 or 2 Bit history can be explored and visualized.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class mars.tools.AbstractMarsToolAndApplication |
---|
AbstractMarsToolAndApplication.ConnectButton, AbstractMarsToolAndApplication.EnterKeyListener |
Nested classes/interfaces inherited from class javax.swing.JFrame |
---|
JFrame.AccessibleJFrame |
Nested classes/interfaces inherited from class java.awt.Frame |
---|
Frame.AccessibleAWTFrame |
Nested classes/interfaces inherited from class java.awt.Window |
---|
Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
BHT_DEFAULT_HISTORY
constant for the default history size |
static boolean |
BHT_DEFAULT_INITVAL
constant for the default inital value |
static int |
BHT_DEFAULT_SIZE
constant for the default size of the BHT |
static String |
BHT_HEADING
the heading of the tool |
static String |
BHT_NAME
the name of the tool |
static String |
BHT_VERSION
the version of the tool |
Fields inherited from class mars.tools.AbstractMarsToolAndApplication |
---|
connectButton, isBeingUsedAsAMarsTool, theWindow, thisMarsApp |
Fields inherited from class javax.swing.JFrame |
---|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
BHTSimulator()
Creates a BHT Simulator with given name and heading. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent event)
Handles the actions when selecting another value in one of the two combo boxes. |
protected void |
addAsObserver()
Adds BHTSimulator as observer of the text segment. |
protected JComponent |
buildMainDisplayArea()
Creates a GUI and initialize the GUI with the default values. |
protected static int |
extractBranchAddress(ProgramStatement stmt)
Extracts the target address of the branch. |
String |
getName()
Returns the name of the tool. |
protected void |
handleExecBranchInst(int branchInstAddr,
boolean branchTaken)
Handles the execution of the branch instruction. |
protected void |
handlePreBranchInst(ProgramStatement stmt)
Handles the execution branch instruction. |
protected static boolean |
isBranchInstruction(ProgramStatement stmt)
Determines if the instruction is a branch instruction or not. |
protected void |
processMIPSUpdate(Observable resource,
AccessNotice notice)
Callback for text segment access by the MIPS simulator. |
protected void |
reset()
Performs a reset of the simulator. |
protected void |
resetSimulator()
Resets the simulator by clearing the GUI elements and resetting the BHT. |
protected static boolean |
willBranch(ProgramStatement stmt)
Checks if the branch instruction delivered as parameter will branch or not. |
Methods inherited from class mars.tools.AbstractMarsToolAndApplication |
---|
action, addAsObserver, addAsObserver, buildButtonAreaMarsTool, buildButtonAreaStandAlone, buildHeadingArea, deleteAsObserver, deleteAsObserver, getHelpComponent, go, initializePostGUI, initializePreGUI, isObserving, performSpecialClosingDuties, update, updateDisplay |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Field Detail |
---|
public static final int BHT_DEFAULT_SIZE
public static final int BHT_DEFAULT_HISTORY
public static final boolean BHT_DEFAULT_INITVAL
public static final String BHT_NAME
public static final String BHT_VERSION
public static final String BHT_HEADING
Constructor Detail |
---|
public BHTSimulator()
Method Detail |
---|
protected void addAsObserver()
addAsObserver
in class AbstractMarsToolAndApplication
protected JComponent buildMainDisplayArea()
buildMainDisplayArea
in class AbstractMarsToolAndApplication
public String getName()
getName
in interface MarsTool
getName
in class AbstractMarsToolAndApplication
protected void reset()
reset
in class AbstractMarsToolAndApplication
public void actionPerformed(ActionEvent event)
actionPerformed
in interface ActionListener
protected void resetSimulator()
protected void handlePreBranchInst(ProgramStatement stmt)
stmt
- the branch statement that is executedprotected void handleExecBranchInst(int branchInstAddr, boolean branchTaken)
branchInstAddr
- the address of the branch instructionbranchTaken
- the information if the branch is taken or not (determined in a step before)protected static boolean isBranchInstruction(ProgramStatement stmt)
stmt
- the statement to investigate
protected static boolean willBranch(ProgramStatement stmt)
stmt
- the branch instruction to be investigated
protected static int extractBranchAddress(ProgramStatement stmt)
stmt
- the branch instruction
protected void processMIPSUpdate(Observable resource, AccessNotice notice)
processMIPSUpdate
in class AbstractMarsToolAndApplication
resource
- the observed resourcenotice
- signals the type of access (memory, register etc.)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |