0% found this document useful (0 votes)
33 views5 pages

Direct Mapped Cache Memory Design

This document provides an overview and explanation of a direct-mapped cache memory design implemented in Verilog. It describes the overall structure, which includes a cache controller state machine and modules for cache data selection and input/output. It then explains the states of the cache controller and the signals asserted in each state to handle read and write operations, including cache hits, misses, and accessing main memory. It also provides pointers for extending the design to a two-way set-associative cache.

Uploaded by

ANKIT GUPTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Topics covered

  • Memory Read,
  • Finite-State Machine,
  • Cache Data Select,
  • Valid Signal,
  • Memory Management,
  • Cache Control,
  • Write-Through,
  • Data Flow Control,
  • Memory Waiting Period,
  • Signal Assertion
0% found this document useful (0 votes)
33 views5 pages

Direct Mapped Cache Memory Design

This document provides an overview and explanation of a direct-mapped cache memory design implemented in Verilog. It describes the overall structure, which includes a cache controller state machine and modules for cache data selection and input/output. It then explains the states of the cache controller and the signals asserted in each state to handle read and write operations, including cache hits, misses, and accessing main memory. It also provides pointers for extending the design to a two-way set-associative cache.

Uploaded by

ANKIT GUPTA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Topics covered

  • Memory Read,
  • Finite-State Machine,
  • Cache Data Select,
  • Valid Signal,
  • Memory Management,
  • Cache Control,
  • Write-Through,
  • Data Flow Control,
  • Memory Waiting Period,
  • Signal Assertion

First Verilog Project

(Cache Memory)
Some explanation of the direct
mapped d cache
h modeld l

Overall Structure:

1
Cache Structure

Note: Clk input


to FSM control
is not shown Hit Miss
This is
CacheDataSelect

CacheDataInputMux

0 1

This is DDataSelect
0
DDataMux 1

/ WCSLoadValue = READ_WAITCYCLES-1
Cache Control
State Machine !Match || !Valid / nreadmiss++
!WSCSig/

READ READMISS READMEM

Dstrobe && DRW / WSCSig/

!Dstrobe / Match && Valid/

READDATA
IDLE

Match && Valid / WRITEDATA


Dstrobe && !DRW /
WRITEHIT /nwritehits++

WRITE / WCSLoadVal =
WRITE_WAITCYCLES -2; WSCSig/
WRITEMEM

!Match || !Valid / WRITEMISS


/nwritemiss++ !WSCSig/

2
Cache Controller--States
• IDLE: no memory access underway
• READ: Read access initiated by driver; Cache is checked
during this state. If hit, access is satisfied from cache during
this cycle and control returns to IDLE state at next transition.
If miss
miss, transition to READMISS state to initiate main
memory access
• READMISS: Initiate memory access following a read miss.
Wait state counter is loaded to time the wait for completion
of the main memory access. Transition to READMEM
State.
• READMEM: Main memory read in progress. Remain in this
state until wait state counter expires then transition to
READDATA state. (Main memory read requires
READ_WAITCYCLES cycles to complete)
• READDATA: Data available from main memory read. Write
this data into the cache line and use it to satisfy the original
processor (driver) read request

Cache Controller States--Continued


• WRITE: Write access initiated by Driver. If cache is hit, transition to
WRITEHIT state. If miss, transition to WRITEMISS state.
• WRITEHIT: Cache has been hit on a write operation. Complete write to
cache and initiate write-through
g to main memory.y Load wait state counter to
time main memory access waiting period. Transition to WRITEMEM state.
• WRITEMISS: Cache has been missed on a write operation. Write to cache
(cache load) and initiate write-through to main memory Load wait state
timer to time main memory waiting period
• WRITEMEM: Main memory write in progress. Wait for expiration of wait
state counter, then transition to WRITEDATA state.
• WRITEDATA: Last Cycle of Main memory write. Assert Ready signal to
Driver to indicate completion of write.

3
Cache Control—Signals Asserted
• IDLE: none
• READ: DReadyEnable, DDataOE, Hit (if read hit)
• READMISS: Miss, WSCLoad, MStrobe, MRW, DDataOE
• READMEM: MRW, DDataOE
• READDATA Ready,
READDATA: R d Write,
W it MRW,
MRW CacheDataSelect,
C h D t S l t DDataSelect,
DD t S l t
DDataOE
• WRITE:
• WRITEHIT: Hit, WSCLoad, Write, MStrobe, MDataOE
• WRITEMISS: Miss, WSCLoad, Write, MStrobe, MDataOE
• WRITEMEM: MDataOE
• WRITEDATA: Ready, MDataOE

Note: Signals Hit and Miss are not shown on the diagrams or used in the
implementation of the direct mapped cache. These signals may aid in the
implementation of the set-associative cache

Explanation of the DReady Signal


• In module CacheControl, the output
DReady is controlled by a “continuous
assignment”
i t” off the
th form:
f
wire DReady = (DReadyEnable && Match && Valid && DRW) || Ready;

• This is equivalent to:

DReadyEnable
y
Match
Valid AND
DReady
DRW OR
Ready

4
Two-way set-associative cache

Note: Basically
utilizes two
copies of a
direct mapped
cache.

WHAT ELSE
IS NEEDED?

Some Additional Pointers


• You should not need to mess with the
driver module (driver.v)
• You should not need to mess with (or even
understand the internals of) the main
memory module (hashmem.v)
• You should not need to modify the cache
controller (control
(control.v)
v) although you need do
thoroughly understand the finite-state
machine that it implements).

Common questions

Powered by AI

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 .

You might also like