220.127.116.11.2. Data Cache
The data cache memory has the following characteristics:
- Direct-mapped cache implementation
- Configurable line size of 4, 16, or 32 bytes
- The data master port reads an entire cache line at a time from memory, and issues one read per clock cycle.
- Write-allocate (i.e., on a store instruction, a cache miss allocates the line for that address)
- Virtually-indexed, physically-tagged, when MMU present
The size of the tag field depends on the size of the cache memory and the physical address size. The size of the line field depends only on the size of the cache memory. The size of the offset field depends on the line size. Line sizes of 4, 16, and 32 bytes have offset widths of 2, 4, and 5 bits respectively. The maximum data byte address size is 31 bits in systems without an MMU present. In systems with an MMU, the maximum data byte address size is 32 bits and the tag field always includes all the bits of the PFN.
The data cache is optional. If the data cache is excluded from the core, the data master port can also be excluded.
The Nios II instruction set provides several different instructions to clear the data cache. There are two important questions to answer when determining the instruction to use. Do you need to consider the tag field when looking for a cache match? Do you need to write dirty cache lines back to memory before clearing? Below the table lists the most appropriate instruction to use for each case.
|Instruction||Ignore Tag Field||Consider Tag Field|
|Write Dirty Lines||flushd||flushda|
|Do Not Write Dirty Lines||initd||initda|
For more information regarding the Nios II instruction set, refer to the Instruction Set Reference chapter of the Nios® II Processor Reference Handbook.
The Nios II/f core implements all the data cache bypass methods.
For information regarding the data cache bypass methods, refer to the Processor Architecture chapter of the Nios® II Processor Reference Handbook
Mixing cached and uncached accesses to the same cache line can result in invalid data reads. For example, the following sequence of events causes cache incoherency.
- The Nios II core writes data to cache, creating a dirty data cache line.
- The Nios II core reads data from the same address, but bypasses the cache.