Package mars.tools

Class BHTSimulator

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Observer, Accessible, RootPaneContainer, WindowConstants, MarsTool

public class BHTSimulator extends AbstractMarsToolAndApplication implements ActionListener
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.

Author:
ingo.kofler@itec.uni-klu.ac.at
See Also:
Serialized Form
  • Field Details

    • BHT_DEFAULT_SIZE

      public static final int BHT_DEFAULT_SIZE
      constant for the default size of the BHT
      See Also:
      Constant Field Values
    • BHT_DEFAULT_HISTORY

      public static final int BHT_DEFAULT_HISTORY
      constant for the default history size
      See Also:
      Constant Field Values
    • BHT_DEFAULT_INITVAL

      public static final boolean BHT_DEFAULT_INITVAL
      constant for the default inital value
      See Also:
      Constant Field Values
    • BHT_NAME

      public static final String BHT_NAME
      the name of the tool
      See Also:
      Constant Field Values
    • BHT_VERSION

      public static final String BHT_VERSION
      the version of the tool
      See Also:
      Constant Field Values
    • BHT_HEADING

      public static final String BHT_HEADING
      the heading of the tool
      See Also:
      Constant Field Values
  • Constructor Details

    • BHTSimulator

      public BHTSimulator()
      Creates a BHT Simulator with given name and heading.
  • Method Details

    • getName

      public String getName()
      Returns the name of the tool.
      Specified by:
      getName in interface MarsTool
      Specified by:
      getName in class AbstractMarsToolAndApplication
      Returns:
      the tool's name as String
    • actionPerformed

      public void actionPerformed(ActionEvent event)
      Handles the actions when selecting another value in one of the two combo boxes. Selecting a different BHT size or history causes a reset of the simulator.
      Specified by:
      actionPerformed in interface ActionListener