Cache memory having enhanced performance and security features
A cache memory having enhanced performance and security feature is provided. The cache memory includes a data array storing a plurality of data elements, a tag array storing a plurality of tags corresponding to the plurality of data elements, and an address decoder which permits dynamic memory-to-cache mapping to provide enhanced security of the data elements, as well as enhanced performance. The address decoder receives a context identifier and a plurality of index bits of an address passed to the cache memory, and determines whether a matching value in a line number register exists. The line number registers allow for dynamic memory-to-cache mapping, and their contents can be modified as desired. Methods for accessing and replacing data in a cache memory are also provided, wherein a plurality of index bits and a plurality of tag bits at the cache memory are received. The plurality of index bits are processed to determine whether a matching index exists in the cache memory and the plurality of tag bits are processed to determine whether a matching tag exists in the cache memory, and a data line is retrieved from the cache memory if both a matching tag and a matching index exist in the cache memory. A random line in the cache memory can be replaced with a data line from a main memory, or evicted without replacement, based on the combination of index and tag misses, security contexts and protection bits. User-defined and/or vendor-defined replacement procedures can be utilized to replace data lines in the cache memory.
1. A method for accessing data in a cache memory, comprising the steps of:
receiving a plurality of tag bits and a plurality of index bits at the cache memory;
processing the plurality of index bits using an address decoder having a plurality of line number registers to identify whether a matching index exists in the plurality of line number registers;
if a matching index exists in the plurality of line number registers, comparing the plurality of tag bits to a tag of a tag array identified by the matching index to determine if the plurality of tag bits match the tag identified in the tag array; and
if the plurality of tag bits match the tag identified in the tag array, retrieving a data line from a data array using the matching index.
2. The method of claim 1 , further comprising replacing a data line in the cache memory using a first pre-defined procedure if a matching index does not exist in the cache memory.
3. The method of claim 2 , further comprising replacing a data line in the cache memory using a second pre-defined procedure if a matching tag does not exist in the cache memory.
4. The method of claim 1 , further comprising replacing a random line in the cache memory with a data line from a main memory.
5. The method of claim 1 , further comprising determining whether an incoming line and a selected line of the cache memory is protected.
6. The method of claim 5 , further comprising storing a new data line from main memory at a pre-defined location in the cache memory determined by a matching index, if a matching tag does not exist in the cache memory, if a matching index exists in the cache memory, and if neither the incoming line nor the selected line of the cache memory are protected.
7. The method of claim 5 , further comprising erasing a randomly-selected location of the cache memory if a matching tag does not exist in the cache memory, if a matching index exists in the cache memory, and if either the incoming line or the selected line of the cache memory is protected.
8. A non-transitory computer-readable medium for use with a cache memory, the computer-readable medium having instructions stored thereon which, when executed, cause a cache memory to access data in the cache memory by performing the steps of:
receiving a plurality of tag bits and a plurality of index bits at the cache memory;
processing the plurality of index bits using an address decoder having a plurality of line number registers to identify whether a matching index exists in the plurality of line number registers;
if a matching index exists in the plurality of line number registers, comparing the plurality of tag bits to a tag of a tag array identified by the matching index to determine if the plurality of tag bits match the tag identified in the tag array; and
if the plurality of tag bits match the tag identified in the tag array, retrieving a data line from a data array using the matching index.
9. The non-transitory computer-readable medium of claim 8 , wherein the computer-readable medium instructs the cache memory to replace a data line in the cache memory using a first pre-defined procedure if a matching index does not exist in the cache memory.
10. The non-transitory computer-readable medium of claim 9 , wherein the computer-readable medium instructs the cache memory to replace a data line in the cache memory using a second pre-defined procedure if a matching tag does not exist in the cache memory.
11. The non-transitory computer-readable medium of claim 8 , wherein the computer-readable medium instructs the cache memory to replace a random line in the cache memory with a data line from a main memory.
12. The non-transitory computer-readable medium of claim 8 , wherein the computer-readable medium instructs the cache memory to determine whether an incoming line and a selected line of the cache memory is protected.
13. The non-transitory computer-readable medium of claim 12 , wherein the computer-readable medium instructs the cache memory to store a new data line from main memory at a pre-defined location in the cache memory if a matching tag does not exist in the cache memory, if a matching index exists in the cache memory, and if neither the incoming line nor the selected line of the cache memory are protected.
14. The non-transitory computer-readable medium of claim 12 , wherein the computer-readable medium instructs the cache memory to erase a randomly-selected location of the cache memory if a matching tag does not exist in the cache memory, if a matching index exists in the cache memory, and if either the incoming line or the selected line of the cache memory is protected.