Class CacheUnit<E extends Struct<?>,​A extends Address<?>>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  CacheUnit.Proxy
      CacheUnit.Proxy eases code generation for assignment statements.
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheUnit​(Struct<E> entryCreator, Address<A> addressCreator, java.math.BigInteger length, int associativity, CachePolicy policy, Indexer<A> indexer, Matcher<E,​A> matcher, Buffer<? extends Struct<?>,​A> next)
      Constructs a cache unit of the given length and associativity.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNeighbor​(CacheUnit<?,​A> other)
      Makes a link between this cache and a neighbor.
      void allocEntry​(A address)
      Allocates an invalid entry in the buffer and associates it w/ the given address.
      boolean evictEntry​(ReplaceableBuffer<?,​A> initiator, A address)
      Evicts the entry associated w/ the given address from the buffer.
      Buffer<?,​A> getNext()
      Returns the next-level buffer.
      boolean isHit​(A address)
      Checks whether the given address hits the buffer.
      boolean isHit​(ru.ispras.fortress.data.types.bitvector.BitVector value)
      Checks whether the given address causes a hit.
      protected CacheSet<E,​A> newSet​(ru.ispras.fortress.data.types.bitvector.BitVector index)
      Creates a new set (can be overridden in a subclass).
      E readEntry​(A address)
      Reads the entry associated w/ the given address from the buffer.
      ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> readEntry​(A address, boolean invalidate)
      Reads the entry associated w/ the given address and, if required, invalidates it.
      void resetState()
      Resets the state of the buffer.
      ru.ispras.fortress.util.Pair<ru.ispras.fortress.data.types.bitvector.BitVector,​ru.ispras.fortress.data.types.bitvector.BitVector> seeEntry​(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.
      void setUseTempState​(boolean value)  
      ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> snoopEvict​(A address, ru.ispras.fortress.data.types.bitvector.BitVector oldEntry)
      Snoops an evict transaction from another cache unit.
      ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> snoopRead​(A address, ru.ispras.fortress.data.types.bitvector.BitVector oldEntry, boolean invalidate)
      Snoops a read transaction from another cache unit.
      ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> snoopWrite​(A address, ru.ispras.fortress.data.types.bitvector.BitVector newEntry)
      Snoops a write transaction from another cache unit.
      java.lang.String toString()  
      CacheUnit.Proxy writeEntry​(A address)  
      void writeEntry​(A address, int lower, int upper, ru.ispras.fortress.data.types.bitvector.BitVector newData)
      Writes the data associated w/ the given address into the given field of the entry.
      void writeEntry​(A address, ru.ispras.fortress.data.types.bitvector.BitVector newEntry)
      Writes the entry associated w/ the given address into the buffer.
      • Methods inherited from class java.lang.Object

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

      • CacheUnit

        public CacheUnit​(Struct<E> entryCreator,
                         Address<A> addressCreator,
                         java.math.BigInteger length,
                         int associativity,
                         CachePolicy policy,
                         Indexer<A> indexer,
                         Matcher<E,​A> matcher,
                         Buffer<? extends Struct<?>,​A> next)
        Constructs a cache unit of the given length and associativity.
        Parameters:
        entryCreator - the entry creator.
        addressCreator - the address creator.
        length - the number of sets in the buffer.
        associativity - the number of lines in each set.
        policy - the cache policy.
        indexer - the set indexer.
        matcher - the line matcher.
        next - the next-level cache.
    • Method Detail

      • newSet

        protected CacheSet<E,​A> newSet​(ru.ispras.fortress.data.types.bitvector.BitVector index)
        Creates a new set (can be overridden in a subclass).
        Parameters:
        index - the index of the set.
        Returns:
        the created set.
      • addNeighbor

        public void addNeighbor​(CacheUnit<?,​A> other)
        Makes a link between this cache and a neighbor.
        Parameters:
        other - the neighbor to be linked.
      • isHit

        public final boolean isHit​(A address)
        Description copied from interface: Buffer
        Checks whether the given address hits the buffer.
        Specified by:
        isHit in interface Buffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address.
        Returns:
        true iff the address hits the buffer.
      • readEntry

        public final E readEntry​(A address)
        Description copied from interface: Buffer
        Reads the entry associated w/ the given address from the buffer.
        Specified by:
        readEntry in interface Buffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address.
        Returns:
        the entry associated w/ the address or null.
      • readEntry

        public final ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> readEntry​(A address,
                                                                                       boolean invalidate)
        Description copied from interface: ReplaceableBuffer
        Reads the entry associated w/ the given address and, if required, invalidates it.
        Specified by:
        readEntry in interface ReplaceableBuffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address.
        invalidate - the invalidation flag.
        Returns:
        the entry associated w/ the address w/ the dirty bit or null.
      • writeEntry

        public final void writeEntry​(A address,
                                     ru.ispras.fortress.data.types.bitvector.BitVector newEntry)
        Description copied from interface: Buffer
        Writes the entry associated w/ the given address into the buffer.

        Note that an incoming entry is not necessarily of the E type. It may be returned from the previous- or next-level cache unit (thus, be different). It is the method's responsibility to convert the entry to the specified type.

        Specified by:
        writeEntry in interface Buffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address.
        newEntry - the new entry.
      • writeEntry

        public final void writeEntry​(A address,
                                     int lower,
                                     int upper,
                                     ru.ispras.fortress.data.types.bitvector.BitVector newData)
        Description copied from interface: Buffer
        Writes the data associated w/ the given address into the given field of the entry.
        Specified by:
        writeEntry in interface Buffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address.
        lower - the lower bit.
        upper - the upper bit.
        newData - the new data.
      • allocEntry

        public final void allocEntry​(A address)
        Description copied from interface: ReplaceableBuffer
        Allocates an invalid entry in the buffer and associates it w/ the given address.
        Specified by:
        allocEntry in interface ReplaceableBuffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address.
      • evictEntry

        public final boolean evictEntry​(ReplaceableBuffer<?,​A> initiator,
                                        A address)
        Description copied from interface: ReplaceableBuffer
        Evicts the entry associated w/ the given address from the buffer.
        Specified by:
        evictEntry in interface ReplaceableBuffer<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        initiator - the buffer that initiates the operation.
        address - the address.
        Returns:
        true iff the entry is not dirty or it has been synchronized w/ the storage.
      • snoopRead

        public final ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> snoopRead​(A address,
                                                                                       ru.ispras.fortress.data.types.bitvector.BitVector oldEntry,
                                                                                       boolean invalidate)
        Description copied from interface: SnoopController
        Snoops a read transaction from another cache unit.
        Specified by:
        snoopRead in interface SnoopController<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address used in the transaction.
        oldEntry - the entry in the cache or null.
        invalidate - the invalidation flag.
        Returns:
        the local entry w/ the dirty bit or null.
      • snoopWrite

        public final ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> snoopWrite​(A address,
                                                                                        ru.ispras.fortress.data.types.bitvector.BitVector newEntry)
        Description copied from interface: SnoopController
        Snoops a write transaction from another cache unit.
        Specified by:
        snoopWrite in interface SnoopController<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address used in the transaction.
        newEntry - the updated entry or null.
        Returns:
        the local entry w/ the dirty bit or null.
      • snoopEvict

        public final ru.ispras.fortress.util.Pair<E,​java.lang.Boolean> snoopEvict​(A address,
                                                                                        ru.ispras.fortress.data.types.bitvector.BitVector oldEntry)
        Description copied from interface: SnoopController
        Snoops an evict transaction from another cache unit.
        Specified by:
        snoopEvict in interface SnoopController<E extends Struct<?>,​A extends Address<?>>
        Parameters:
        address - the address used in the transaction.
        oldEntry - the entry being evicted.
        Returns:
        the local entry w/ the dirty bit or null.
      • 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.
      • seeEntry

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

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