MOTOROLA
MC68349 USER’S MANUAL
5- 9
passed to the CPU32+ for execution, and the cache maintenance logic ignores the
access. Only fetches from the external memory subsystem are cached, making maximum
use of the internal memory elements of the processor.
If available, an invalid line is updated with the tag address and data from memory, and the
line transitions from the INVALID state to the VALID state by setting the valid bit for each
instruction word loaded. An invalid line is one in which one or both words are invalid—the
replacement algorithm does not distinguish between lines which are completely invalid
(neither valid bit set) and lines which are partially valid (one valid bit set). If all lines are
already valid, a pseudo-random replacement technique is used to select one of the
available lines and replace the tag and data contents of the line with the new line
information. A cache block can be locked to prevent lines within it from being changed;
however, the same function can be achieved for some applications by configuring the
block as SRAM and preloading with instructions. Using a CIC block as SRAM also
doubles the storage size from 256 bytes to 512 bytes (see 5.2.1.2 SRAM Mode).
The replacement algorithm uses a 2-bit counter which is incremented on every access to
the cache. When a miss occurs and all available lines in the cache are valid, the line in the
block pointed to by the current counter value is replaced (provided that the block is not
locked or in SRAM mode), after which the counter is incremented. If the block is locked or
is in SRAM mode, the line in the next available block is replaced, where 0 is the lowest
block and 3 is the highest block.
One or more cache sets can be selectively invalidated by setting the corresponding INV
bit in the CIC module configuration register. All lines within a cache set are also
invalidated when the block is switched from SRAM mode into instruction cache mode. The
state diagram in Figure 5-5 shows the instruction cache word state transitions.
VALID
LOCKED
INVALID
LOCKED
VALID
UNLOCKED
INVALID
UNLOCKED
HIT
UNLOCK
LOCK
UNLOCK
LOCK
MISS
HIT
MISS
INVALIDATE
Figure 5-5. Instruction Cache Word State Diagram
The cache controller does not monitor data accesses by the CPU32+ or by alternate bus
masters to maintain cache coherency. Any change in context that modifies memory
previously fetched as instructions (such as changing code flow from a debugger or
downloading new code) requires that the instruction cache be invalidated before executing
the modified code.