The present disclosure relates generally to memory systems, and more particularly to systems using cache memories.
Systems that utilize victim caches operate in cache write mode by transferring a cache line being overwritten in an upper-level cache to a lower-level victim cache for storage. During a read operation requested data is transferred from the victim cache to the higher-level cache in response to the requested data residing in a line of the victim cache, as indicated by a cache hit. A write to invalidate the cache line read from the victim cache occurs as part of the read operation. Invalidating the read cache line to allow the cache line to be identified by the cache controller as available for subsequent write operations.
The present disclosure may be better understood, and its numerous features and advantages made apparent to those skilled in the art by referencing the accompanying drawings.
The use of the same reference symbols in different drawings indicates similar or identical items.
A victim cache system is disclosed in accordance with a specific embodiment of the present disclosure. In one embodiment, a Level 1 (L1) and Level 2 (L2) cache work together such that the L2 cache is a victim cache that stores data evicted from the L1 cache. In accordance with a specific embodiment of the present disclosure, when data is written from the L1 cache to the L2 cache, the cache line being written is identified in the MRU array as the most recently used (MRU) cache line in its cache row. A data read to the victim cache, however, results in the cache line being read from the victim cache as being identified in the MRU array as the least recently used (LRU) line in its cache row. Identifying the cache line just read from the cache as being the least recently used line in the row has a similar effect as invalidating the line in the TAG array, in that the most recently read cache line is subject to being overwritten before any other valid line of the cache row. This is advantageous over previous systems using victim caches because the data of read cache lines remains available for a subsequent read in case it is needed. For example, if the initial read transfer of victim cache data is aborted the cache line can be subsequently read from the victim cache because it has not been invalidated. Another advantage is that the victim cache bandwidth is improved because there is no need for a separate write cycle to invalidate the TAG location for the read cache line.
As used herein the term row, or cache row, refers to the set of cache lines that is selected based upon an index portion, see A(INDEX) in
In operation, Requesting Device 110 has a bus port that is electrically connected to a bus port of the L1 Cache 120. In a specific embodiment, the Requesting Device 110 can be a central processing unit of a microcontroller. During a data access operation, the Requesting Device 110 will request that information be read (received) or written (transmitted). Either a read or write access operation can result in data being written to caches 120 and 130.
Cache Module 120 will provide the data requested by Requesting Device 110 if a hit occurs at Cache Module 120. If a miss occurs at Cache Module 120, i.e. the requested data is not present, the data will be written to Cache Module 120 from either Victim Cache 130 or from a another memory location (not shown) such as system memory. For example, if requested data is not present in either Cache 120 or Cache 130 the data will be received from a different memory location. If in response to receiving data from a different memory location it is necessary to overwrite data at a cache line of Cache 120, the data to be overwritten will first be evicted from the L1 Cache 120 and written to the Victim Cache 130 for storage Victim Cache 130 identifies a cache line receiving evicted data as the most recently used cache line in response to its being written.
If a cache hit for data requested by Requesting Device 110 occurs in the Victim Cache 130, instead of external memory or the L1 Cache 120, the requested data is provided from the Victim Cache 130 to the L1 Cache 120 for storage. This read of the a cache line within the Victim Cache 130 results in the read cache line being identified as least recently used.
The Victim Cache 130 is illustrated to include Memory Array 140, Tag/Valid Bit Array 135, Cache Tag Control Portion 165, Cache Hit Module 155, Most Recently Used (MRU) Control Module 166, MRU Array 170, and Way Select Module Portion 150.
Bus 125 couples the L1 cache 120 to the Victim cache 130 to provide address information that includes a TAG portion and an INDEX portion from the L1 Cache 120 to the Victim Cache 130. It will be appreciated that additional data and control busses exist, and that only the address bus is illustrated for purposes of discussion. The portion of Bus 125 that transmits address information used to identify a specific set of cache lines of memory array 135 is labeled A(INDEX) and is connected to Cache Tag Control 165. Address information used to select a specific way of a cache row is labeled A(TAG) and is provided to the Cache Hit Module Portion 155. The Memory Array Portion 140 comprises cache rows 141-144, and is illustrated to further comprise four ways, ways 146-149. Way Select Module 150 is connected to the Cache Memory Array 140 to receive a signal to select data associated with one of the ways of memory array 140 to be provided to the L1 Cache 120 in response to a hit in the Victim Cache 130.
The Cache Tag Controller 165 selects one of the cache rows of the Cache Memory Array 140 as well as the TAG and valid bits in Array 135 associated with the row. If in response to receiving a specific address it is determined that the current address TAG, A(TAG), is stored within the Cache Tag/Valid Bit Array 135, signals will be asserted by the Cache Hit Module 155 and provided to the MRU Control 166 and the Way Select module 150, resulting in data being provided from the Victim Cache 130 to the L1 Cache 120 and in an update of the MRU register.
During a write operation the MRU Control Module 166 will update the MRU Array 170 to indicate that the line being written is the most recently used line within its row.
During a read operation the MRU Control Module 166 will update the MRU Array 170 to indicate that the line being read is the least recently used cache line within its row. By indicating the read line is the least recently used line, when it is actually the most recently accessed, it is assured that the line just read will have the highest likelihood of being overwritten during a subsequent write operation, while maintaining the availability of the recently read data prior to being overwritten. This is beneficial over previous systems that invalidate the victim caches TAG for a line once the cache line data is read, thereby preventing a subsequent data read of the cache line if the original data is subsequently needed from the victim cache, such as if the original read of the cache line had to be aborted.
Improved bandwidth can also be realized using the disclosed system because a separate write to the TAG/Valid Array 135 to invalidate the cache line is not needed. This can be better understood with reference to
Signal 213 represents accesses to TAG/valid bits of the TAG in the disclosed system. Signal 214 represents accesses to the MRU indicators of the MRU array. Specifically, the TAG and invalid bits of the selected cache row are read during C1 at a time represented by pulse RD1 of signal 213. During the same cycle, the MRU indicators for the accessed row are read and written, as represented by signal 214 pulses RD1 and W1. Because the MRU array is written back during C1 a second read operation can occur at cycle C2, thereby improving the read bandwidth of the Victim Cache 130.
The path from Line 242 to Line 242A of
During a read operation to row 142, way 149, the MRU values associated with the cache row of 142 are modified so that the recently read line contains the value 4, and thereby is identified as the least recently used line. During a write operation to row 142, way 149, the MRU values associated with the cache row 142 are modified so that the recently written line contains the value 1, an thereby is identified as the most recently used line.
The manner in which a specific cache line's use status is stored can be accomplished in many ways. For example, each cache line can be associated with a memory location having sufficient size to indicate its current use ranking. For a cache row having four cache lines this would require four two-bit locations. Alternatively, a cache row having four cache lines could use a pseudo-ranking scheme using only three bits. In such a scheme there are two non-overlapping sets of cache lines identified, each non-overlapping set representing two of the four cache lines. A first bit of the three bits used to implement the pseudo ranking scheme is asserted to indicate the first set contains the most recently used cache line, and negated to indicate the second set contains the most recently used cache line. The remaining two bits of the pseudo-ranking scheme are asserted or negated to indicate which cache line within a respective set is the most recently accessed. It will be appreciated that this scheme allows identification of the most recently and least recently used cache line with in a row.
At step 312, in response to a successful hit at step 311, retrieval of the requested information is facilitated from the first cache location. Referring to
At step 313, in response to a successful hit at step 311, the cache location from which the requested information was accessed will be identified as being the least recently used cache location in response to being read. In this manner the data remains accessible, but is subject to being overwritten the next time information needs to be stored at that cache tag location.
At step 322, the first information is received at the first cache from the victim cache. For example, referring to
At step 323, an indicator is stored at the victim cache to facilitate overwriting the first information at the victim cache. It will be appreciated that once a read of the information from the L2 victim cache 130 has occurred, that there is a strong presumption the data just read resides within the L1 Cache 120, which requested the information. Therefore an indicator, such as a least recently used indicator, can be applied to the location previously storing the first information to facilitate a subsequent overwriting of the data.
At step 324, a second read request for the same information is provided to the L2 cache. In response to receiving this request, the information can be received at the first cache from the victim cache, as indicated at step 325 prior to the first information having ever been overwritten by the victim cache. This represents one improvement over the previous methods in that once a victim cache location is read; its data is not invalidated.
In the preceding detailed description, reference has been made to the accompanying drawings that form a part hereof, and in which are shown by way of illustration specific embodiments in which the invention may be practiced. These embodiments and certain variants thereof, have been described in sufficient detail to enable those skilled in the art to practice the invention. For example, it will be appreciated that although separate address connections are illustrated connecting device 110 to device 120 and device 120 to device 130, that a common set of address connections can shared by the three devices. It is to be understood that other suitable embodiments may be utilized. In addition, it will be appreciated that the functional portions shown in the figures could be further combined or divided in a number of manners without departing from the spirit or scope of the invention. For example, the control portions of the victim cache 130 can be formed on a common substrate with the L1 Cache 120 and Requesting Device separate from the memory array 135. In such an embodiment, the valid bits associated with each cache line can be stored as part of the control portions or as part of the memory array 135. Further, it will be appreciated that data stored within the described cache areas can be instruction-type data or data-type data, i.e. non-instruction data. The preceding detailed description is, therefore, not intended to be limited to the specific forms set forth herein, but on the contrary, it is intended to cover such alternatives, modifications, and equivalents, as can be reasonably included within the spirit and scope of the appended claims.