# suresh-kumar-21/parameterized-cache-memory-subsystem architecture

> Architecture diagram of the GitHub repository suresh-kumar-21/parameterized-cache-memory-subsystem, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/suresh-kumar-21/parameterized-cache-memory-subsystem
- Repository: https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem

## Overview

This repository implements a parameterized Verilog cache subsystem with direct-mapped and 2-way set-associative designs. The principal workflow is a memory request entering a cache, being decoded and checked for a hit or miss, then being served from cached data or handled through refill and, when needed, dirty-line write-back. The 2-way design adds LRU victim selection. The README documents these capabilities and benchmark comparisons, but no RTL excerpts were provided, so internal call and data-transfer edges are marked unverified rather than inferred as confirmed wiring.

Main entry points: [`rtl/cache_datapath.v`](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_datapath.v) (Cache Datapath), [`rtl/cache_datapath_2way.v`](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_datapath_2way.v) (2-Way Datapath), [`rtl/cache_top_2way.v`](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_top_2way.v) (2-Way Cache), [`rtl/cache_top.v`](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_top.v) (Direct-Mapped Cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cache_arch["Cache Architectures"]
  node_direct_cache["Direct-Mapped Cache<br/>[cache_top.v]"]
  node_two_way_cache["2-Way Cache<br/>[cache_top_2way.v]"]
end

subgraph group_control["Request Control"]
  node_controller["Cache Controller<br/>[cache_controller.v]"]
  node_request_register["Request Register<br/>[request_register.v]"]
  node_decoder_dm["Address Decoder<br/>[address_decoder.v]"]
  node_decoder_2w["2-Way Decoder"]
  node_comparator["Tag Comparators<br/>[comparator.v]"]
end

subgraph group_storage["Cache State"]
  node_datapath_dm["Cache Datapath<br/>[cache_datapath.v]"]
  node_datapath_2w["2-Way Datapath"]
  node_tag["Tag Arrays<br/>[tag_array.v]"]
  node_valid["Valid Arrays<br/>[valid_array.v]"]
  node_dirty["Dirty Arrays<br/>[dirty_array.v]"]
  node_data["Data Arrays<br/>[data_array.v]"]
end

subgraph group_replacement["Replacement Policy"]
  node_lru["LRU State<br/>[lru_array.v]"]
end

node_requester(("Requesting System"))
node_memory[("Backing Memory")]

node_requester -.->|"issues request"| node_direct_cache
node_requester -.->|"issues request"| node_two_way_cache
node_direct_cache -.->|"returns result"| node_requester
node_two_way_cache -.->|"returns result"| node_requester
node_direct_cache -.->|"refills / writes back"| node_memory
node_two_way_cache -.->|"refills / writes back"| node_memory
node_direct_cache -.->|"controls requests"| node_controller
node_two_way_cache -.->|"controls requests"| node_controller
node_direct_cache -.->|"uses datapath"| node_datapath_dm
node_two_way_cache -.->|"uses datapath"| node_datapath_2w
node_controller -.->|"captures request"| node_request_register
node_datapath_dm -.->|"decodes address"| node_decoder_dm
node_datapath_2w -.->|"decodes address"| node_decoder_2w
node_datapath_dm -.->|"checks tags"| node_tag
node_datapath_2w -.->|"checks tags"| node_tag
node_datapath_dm -.->|"checks validity"| node_valid
node_datapath_2w -.->|"checks validity"| node_valid
node_datapath_dm -.->|"tracks dirty lines"| node_dirty
node_datapath_2w -.->|"tracks dirty lines"| node_dirty
node_datapath_dm -.->|"reads / writes data"| node_data
node_datapath_2w -.->|"reads / writes data"| node_data
node_datapath_dm -.->|"detects hit"| node_comparator
node_datapath_2w -.->|"detects hit"| node_comparator
node_two_way_cache -.->|"selects victim"| node_lru

click node_direct_cache "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_top.v"
click node_two_way_cache "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_top_2way.v"
click node_controller "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_controller.v"
click node_request_register "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/request_register.v"
click node_decoder_dm "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/address_decoder.v"
click node_decoder_2w "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/address_decoder_2way.v"
click node_datapath_dm "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_datapath.v"
click node_datapath_2w "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_datapath_2way.v"
click node_tag "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/tag_array.v"
click node_valid "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/valid_array.v"
click node_dirty "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/dirty_array.v"
click node_data "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/data_array.v"
click node_comparator "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/comparator.v"
click node_lru "https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/lru_array.v"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_direct_cache,node_two_way_cache toneBlue
class node_controller,node_request_register,node_decoder_dm,node_decoder_2w,node_comparator,node_memory toneAmber
class node_datapath_dm,node_datapath_2w,node_tag,node_valid,node_dirty,node_data,node_requester toneMint
class node_lru toneRose
```

## Components

### Cache Architectures

- [Direct-Mapped Cache](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_top.v): `rtl/cache_top.v`
- [2-Way Cache](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_top_2way.v): `rtl/cache_top_2way.v`

### Request Control

- [Cache Controller](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_controller.v): `rtl/cache_controller.v`
- [Request Register](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/request_register.v): `rtl/request_register.v`
- [Address Decoder](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/address_decoder.v): `rtl/address_decoder.v`
- [2-Way Decoder](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/address_decoder_2way.v): `rtl/address_decoder_2way.v`
- [Tag Comparators](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/comparator.v): `rtl/comparator.v`

### Cache State

- [Cache Datapath](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_datapath.v): `rtl/cache_datapath.v`
- [2-Way Datapath](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/cache_datapath_2way.v): `rtl/cache_datapath_2way.v`
- [Tag Arrays](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/tag_array.v): `rtl/tag_array.v`
- [Valid Arrays](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/valid_array.v): `rtl/valid_array.v`
- [Dirty Arrays](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/dirty_array.v): `rtl/dirty_array.v`
- [Data Arrays](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/data_array.v): `rtl/data_array.v`

### Replacement Policy

- [LRU State](https://github.com/suresh-kumar-21/parameterized-cache-memory-subsystem/blob/cache-2way-lru-development/rtl/lru_array.v): `rtl/lru_array.v`

### Other components

- **Requesting System**
- **Backing Memory**

## Connections

- Requesting System → Direct-Mapped Cache: issues request
- Requesting System → 2-Way Cache: issues request
- Direct-Mapped Cache → Requesting System: returns result
- 2-Way Cache → Requesting System: returns result
- Direct-Mapped Cache → Backing Memory: refills / writes back
- 2-Way Cache → Backing Memory: refills / writes back
- Direct-Mapped Cache → Cache Controller: controls requests
- 2-Way Cache → Cache Controller: controls requests
- Direct-Mapped Cache → Cache Datapath: uses datapath
- 2-Way Cache → 2-Way Datapath: uses datapath
- Cache Controller → Request Register: captures request
- Cache Datapath → Address Decoder: decodes address
- 2-Way Datapath → 2-Way Decoder: decodes address
- Cache Datapath → Tag Arrays: checks tags
- 2-Way Datapath → Tag Arrays: checks tags
- Cache Datapath → Valid Arrays: checks validity
- 2-Way Datapath → Valid Arrays: checks validity
- Cache Datapath → Dirty Arrays: tracks dirty lines
- 2-Way Datapath → Dirty Arrays: tracks dirty lines
- Cache Datapath → Data Arrays: reads / writes data
- 2-Way Datapath → Data Arrays: reads / writes data
- Cache Datapath → Tag Comparators: detects hit
- 2-Way Datapath → Tag Comparators: detects hit
- 2-Way Cache → LRU State: selects victim
