Package mars.tools

Class CacheSimulator

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, Memory.Listener, MarsTool

public class CacheSimulator extends AbstractMarsTool
A data cache simulator for simulating and illustrating data cache performance.
  • Version 1.0 (16-18 October 2006)
  • Version 1.1 (7 November 2006)
  • Version 1.2 (23 December 2010) fixes a bug in the hit/miss animator under full or N-way set associative. It was animating the block of initial access (first block of set). Now it animates the block of final access (where address found or stored). Also added log display to GUI (previously used System.out).
Author:
Pete Sanderson
See Also:
  • Field Details

  • Constructor Details

    • CacheSimulator

      public CacheSimulator()
      Construct an instance of this tool. This will be used by the ToolManager.
  • Method Details

    • getName

      public String getName()
      Required MarsTool method to return Tool name.
      Specified by:
      getName in interface MarsTool
      Specified by:
      getName in class AbstractMarsTool
      Returns:
      Tool name. MARS will display this in menu item.
    • buildMainDisplayArea

      protected JComponent buildMainDisplayArea()
      Method that constructs the main cache simulator display area. It is organized vertically into three major components: the cache configuration which an be modified using combo boxes, the cache performance which is updated as the attached MIPS program executes, and the runtime log which is optionally used to display log of each cache access.
      Specified by:
      buildMainDisplayArea in class AbstractMarsTool
      Returns:
      The GUI component containing these three areas.
    • startObserving

      protected void startObserving()
      Description copied from class: AbstractMarsTool
      Register this tool as a listener of memory and/or registers, if applicable. This method is called when the tool is opened by the user. Does nothing by default.
      Overrides:
      startObserving in class AbstractMarsTool
      See Also:
    • stopObserving

      protected void stopObserving()
      Description copied from class: AbstractMarsTool
      Unregister this tool as a listener of memory and/or registers, if applicable. This method is called when the tool is closed by the user. Does nothing by default.
      Overrides:
      stopObserving in class AbstractMarsTool
      See Also:
    • memoryRead

      public void memoryRead(int address, int length, int value, int wordAddress, int wordValue)
      Description copied from interface: Memory.Listener
      Invoked upon any read operation which is relevant to this listener's active range. Does nothing by default.
      Parameters:
      address - The address which was read from.
      length - The number of bytes read. Will always be 1 (single byte), Memory.BYTES_PER_HALFWORD, or Memory.BYTES_PER_WORD.
      value - The value which was read.
      wordAddress - The address of the word affected by the operation.
      wordValue - The full value of the word.
    • memoryWritten

      public void memoryWritten(int address, int length, int value, int wordAddress, int wordValue)
      Description copied from interface: Memory.Listener
      Invoked upon any write operation which is relevant to this listener's active range. Does nothing by default.
      Parameters:
      address - The address which was written to.
      length - The number of bytes written. Will always be 1 (single byte), Memory.BYTES_PER_HALFWORD, or Memory.BYTES_PER_WORD.
      value - The value which was written.
      wordAddress - The address of the word affected by the operation.
      wordValue - The resulting value of the word.
    • initializePreGUI

      protected void initializePreGUI()
      Initialize all JComboBox choice structures not already initialized at declaration. Also creates initial default cache object. Overrides inherited method that does nothing.
      Overrides:
      initializePreGUI in class AbstractMarsTool
    • initializePostGUI

      protected void initializePostGUI()
      The only post-GUI initialization is to create the initial cache object based on the default settings of the various combo boxes. Overrides inherited method that does nothing.
      Overrides:
      initializePostGUI in class AbstractMarsTool
    • reset

      protected void reset()
      Method to reset cache, counters and display when the Reset button selected. Overrides inherited method that does nothing.
      Overrides:
      reset in class AbstractMarsTool