Direct Mapped Cache Memory Design
Topics covered
Direct Mapped Cache Memory Design
Topics covered
When a read miss occurs, the Cache Controller FSM transitions from the READ to the READMISS state to initiate main memory access. During this state, the wait state counter is loaded to time the wait for the completion of the main memory access. After the wait, it transitions to the READMEM state, where the main memory read is in progress. Once the wait state counter expires, it transitions to the READDATA state, where the data from the main memory is written into the cache line to satisfy the original processor read request .
During the WRITEHIT state, the Cache Controller asserts the following signals: Hit, WSCLoad, Write, MStrobe, and MDataOE. This state indicates a cache hit on a write operation, enabling the cache write and initiating a write-through to main memory .
The DReady signal in the CacheControl module indicates when the cache is ready to satisfy a memory operation. It is controlled by a continuous assignment: wire DReady = (DReadyEnable && Match && Valid && DRW) || Ready. This logic means DReady is asserted when the cache is ready and enabled, the address matches, it's a valid entry, and the data read/write condition is met, or simply when the Ready condition is already present .
The READMEM state in the cache control process is responsible for managing the read operation from the main memory. It remains in this state until the wait state counter expires, which marks the end of the read process. Following this, it transitions to the READDATA state, where data is made available to satisfy the processor's original read request .
A direct-mapped cache corresponds directly with cache positions based on memory addresses, while a two-way set-associative cache utilizes two copies of a direct-mapped cache to handle memory blocks in sets, rather than specific locations. This provides more flexibility and can reduce cache misses by handling multiple potential memory locations .
The Cache Controller transitions from the IDLE state to the READ state when a read access is initiated by the driver. This transition signals that the cache will be checked to determine if the requested data is present in the cache (a read hit) or if a read miss occurred, necessitating further state transitions .
When a write operation results in a cache miss, the Cache Controller transitions from the WRITE state to the WRITEMISS state. Here, it performs a cache load and initiates a write-through to the main memory. The wait state timer is loaded to manage the main memory waiting period, and once this expires, the transition to WRITEDATA state occurs, completing the write process .
The DReady signal is asserted when DReadyEnable, Match, Valid, and DRW are all true. This means the cache line is enabled and matches the requested address, holds valid data, and a data read/write condition is being requested. If these conditions are met, or if the Ready signal is already asserted, DReady will signal that the cache operation is ready to be completed .
The WRITEDATA state marks the last cycle of the main memory write operation. It asserts the Ready signal to the Driver to indicate the completion of the write, signaling that the cache operation associated with this write cycle is complete and the system can proceed with subsequent operations .
Signals like Hit and Miss are not shown on cache diagrams or used in direct-mapped cache implementation because the cache operation does not require them explicitly for cache line management. However, these signals could aid in designing and implementing more complex cache architectures, such as set-associative caches, where multiple cache lines could satisfy a single memory address .