A synthesizable 32-bit Direct Mapped Cache Controller implemented in Verilog HDL, demonstrating the fundamental principles of cache memory design in computer architecture. The project features cache hit/miss detection, cache refill from main memory, finite state machine (FSM) based control, and a modular RTL design suitable for simulation and synthesis.
Developed and simulated using Xilinx Vivado 2022.2
Cache memory plays a vital role in improving processor performance by reducing the average memory access time. This project implements a Direct Mapped Cache, where each memory block maps to exactly one cache line.
For every CPU memory request, the controller compares the requested tag with the stored cache tag.
- β Cache Hit: Data is immediately returned to the CPU.
- β Cache Miss: Data is fetched from main memory, stored in the cache, and then supplied to the CPU.
The design follows a modular architecture, making it easy to understand, simulate, and extend into more advanced cache organizations.
- βοΈ 32-bit Address Space
- βοΈ 32-bit Data Width
- βοΈ Direct Mapped Cache Organization
- βοΈ 16 Cache Lines
- βοΈ Tag Array
- βοΈ Data Array
- βοΈ Valid Bit Support
- βοΈ Cache Hit/Miss Detection
- βοΈ Main Memory Interface
- βοΈ FSM-Based Cache Controller
- βοΈ Parameterized Verilog Modules
- βοΈ Fully Synthesizable RTL
- βοΈ Comprehensive Testbench
- βοΈ Functional Simulation using Xilinx Vivado
| Parameter | Value |
|---|---|
| Cache Type | Direct Mapped |
| Address Width | 32 bits |
| Data Width | 32 bits |
| Cache Lines | 16 |
| Index Bits | 4 |
| Offset Bits | 2 |
| Tag Bits | 26 |
+----------------------+---------+--------+
| Tag (26) | Index | Offset |
+----------------------+---------+--------+
31:6 5:2 1:0
The cache controller is implemented using a five-state finite state machine.
Implements the control logic of the cache.
Responsibilities:
- Handle CPU read/write requests
- Perform tag comparison
- Detect cache hits and misses
- Generate memory read/write requests
- Update cache contents
- Control CPU response timing
Stores:
- Cache Tags
- Valid Bits
Supports synchronous write operations and asynchronous read access.
Stores the cached 32-bit data words.
Supports synchronous writes and asynchronous reads.
Behavioral model of the main memory used during simulation.
Provides:
- Memory Read
- Memory Write
- Memory Ready Signal
Top-level integration module connecting all cache components into a complete subsystem.
Self-contained Verilog testbench used to verify the complete cache controller.
The following scenarios were verified successfully.
Address: 0x00000020
Expected:
- Cache Miss
- Main Memory Access
- Cache Update
- CPU Response
Address: 0x00000020
Expected:
- Cache Hit
- Immediate Response
Address: 0x00000040
Expected:
- Cache Miss
- Memory Refill
Address: 0x00000040
Data: 0xDEADBEEF
Expected:
- Cache Updated
- Main Memory Updated
Expected:
- Cache Hit
- Updated Data Returned
Address: 0x00000080
Expected:
- Cache Miss
- Cache Refill
The waveform verifies:
- βοΈ Cache Hit Detection
- βοΈ Cache Miss Detection
- βοΈ FSM State Transitions
- βοΈ Tag Comparison
- βοΈ Cache Refill
- βοΈ Data Update
- βοΈ Main Memory Access
- βοΈ CPU Ready Signal
- Verilog HDL
- Xilinx Vivado 2022.2
- Xilinx Simulator (XSim)
Potential extensions include:
- Two-Way Set Associative Cache
- Four-Way Set Associative Cache
- Write-Back Cache Policy
- Dirty Bit Implementation
- LRU Replacement Algorithm
- Burst Memory Transfers
- Multi-Level Cache Hierarchy
- Pipeline Processor Integration
This project helped reinforce concepts in:
- Computer Architecture
- Cache Memory Organization
- Memory Hierarchy
- Direct Mapping
- RTL Design using Verilog
- Finite State Machine Design
- Hardware Verification
- Digital System Design
- FPGA-Oriented RTL Development
Archita Roy B.Tech β Electronics and Communication Engineering National Institute of Technology Silchar
GitHub: @archita-2005
Feedback and suggestions are always welcome.

