Class Cache<D extends Data,​A extends Address>

  • Type Parameters:
    D - the data type.
    A - the address type.
    All Implemented Interfaces:
    Buffer<D,​A>, BufferObserver, ModelStateManager

    public abstract class Cache<D extends Data,​A extends Address>
    extends java.lang.Object
    implements Buffer<D,​A>, BufferObserver, ModelStateManager
    This is an abstract representation of a partially associative cache memory. A cache unit is characterized by the following parameters (except the data and address types):
    1. length - the number of sets in the cache,
    2. associativity - the number of lines in each set,
    3. policyId - the data replacement policy,
    4. indexer - the set indexer, and
    5. matcher - the line matcher.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  Cache.Proxy
      Proxy class is used to simply code of assignment expressions.
    • Constructor Summary

      Constructors 
      Constructor Description
      Cache​(java.math.BigInteger length, int associativity, PolicyId policyId, Indexer<A> indexer, Matcher<D,​A> matcher)
      Constructs a buffer of the given length and associativity.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      D getData​(A address)
      Returns the data associated with the given address.
      boolean isHit​(A address)
      Checks whether the given address causes a hit.
      boolean isHit​(ru.ispras.fortress.data.types.bitvector.BitVector value)
      Checks whether the given address causes a hit.
      protected abstract A newAddress()  
      protected abstract D newData​(ru.ispras.fortress.data.types.bitvector.BitVector value)  
      void resetState()  
      ru.ispras.fortress.util.Pair<ru.ispras.fortress.data.types.bitvector.BitVector,​ru.ispras.fortress.data.types.bitvector.BitVector> seeData​(ru.ispras.fortress.data.types.bitvector.BitVector index, ru.ispras.fortress.data.types.bitvector.BitVector way)
      Returns data and associated address without changing the state.
      Cache.Proxy setData​(A address)  
      D setData​(A address, D data)
      Updates the data associated with the given address.
      void setUseTempState​(boolean value)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Cache

        public Cache​(java.math.BigInteger length,
                     int associativity,
                     PolicyId policyId,
                     Indexer<A> indexer,
                     Matcher<D,​A> matcher)
        Constructs a buffer of the given length and associativity.
        Parameters:
        length - the number of sets in the buffer.
        associativity - the number of lines in each set.
        policyId - the data replacement policy.
        indexer - the set indexer.
        matcher - the line matcher.
    • Method Detail

      • isHit

        public final boolean isHit​(A address)
        Description copied from interface: Buffer
        Checks whether the given address causes a hit.
        Specified by:
        isHit in interface Buffer<D extends Data,​A extends Address>
        Parameters:
        address - the data address.
        Returns:
        true if the address causes a hit; false otherwise.
      • isHit

        public final boolean isHit​(ru.ispras.fortress.data.types.bitvector.BitVector value)
        Description copied from interface: BufferObserver
        Checks whether the given address causes a hit.
        Specified by:
        isHit in interface BufferObserver
        Parameters:
        value - Address to be checked.
        Returns:
        true if the address causes a hit; false otherwise.
      • getData

        public final D getData​(A address)
        Description copied from interface: Buffer
        Returns the data associated with the given address.
        Specified by:
        getData in interface Buffer<D extends Data,​A extends Address>
        Parameters:
        address - the data address.
        Returns:
        the data object if the address causes a hit; null otherwise.
      • seeData

        public ru.ispras.fortress.util.Pair<ru.ispras.fortress.data.types.bitvector.BitVector,​ru.ispras.fortress.data.types.bitvector.BitVector> seeData​(ru.ispras.fortress.data.types.bitvector.BitVector index,
                                                                                                                                                               ru.ispras.fortress.data.types.bitvector.BitVector way)
        Description copied from interface: Buffer
        Returns data and associated address without changing the state.
        Specified by:
        seeData in interface Buffer<D extends Data,​A extends Address>
        Specified by:
        seeData in interface BufferObserver
        Parameters:
        index - Set index.
        way - Line index.
        Returns:
        Pair(Address, Data) or null if it is not found.
      • setData

        public final D setData​(A address,
                               D data)
        Description copied from interface: Buffer
        Updates the data associated with the given address.
        Specified by:
        setData in interface Buffer<D extends Data,​A extends Address>
        Parameters:
        address - the data address.
        data - the new data.
        Returns:
        the old data if they exist; null otherwise.
      • newAddress

        protected abstract A newAddress()
      • newData

        protected abstract D newData​(ru.ispras.fortress.data.types.bitvector.BitVector value)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object