# pranjal9005/2-way-set-associative-cache architecture

> Architecture diagram of the GitHub repository pranjal9005/2-way-set-associative-cache, 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/pranjal9005/2-way-set-associative-cache
- Repository: https://github.com/pranjal9005/2-way-set-associative-cache

## Overview

This repository implements a read-only, 2-way set-associative cache in Verilog. A request enters the top-level cache; address decoding, tag comparison, hit/miss and way selection, and LRU state support the controller’s lookup and refill behavior. On a miss, the controller uses the behavioral backing memory’s ready handshake before responding. The README documents the module roles and top-level connections, but no RTL excerpts were available, so connections below are limited to those documented there.

Main entry points: [`rtl/cache_2way.v`](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_2way.v) (Cache top level), [`rtl/cache_controller.v`](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_controller.v) (Cache controller), [`rtl/main_memory.v`](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/main_memory.v) (Backing memory), [`rtl/address_decoder.v`](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/address_decoder.v) (Address decoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Cache integration"]
  node_cache_top["Cache top level<br/>[cache_2way.v]"]
  node_controller["Cache controller<br/>[cache_controller.v]"]
end

subgraph group_lookup["Lookup and selection"]
  node_decoder["Address decoder<br/>[address_decoder.v]"]
  node_comparator["Tag comparator<br/>[tag_comparator.v]"]
  node_hit_miss["Hit/miss selector<br/>[hit_miss_unit.v]"]
  node_lru["LRU replacement<br/>[lru_unit.v]"]
end

subgraph group_storage["Cache and memory state"]
  node_cache_array[("Cache array<br/>[cache_array.v]")]
  node_main_memory[("Backing memory<br/>[main_memory.v]")]
end

node_requester(("Requesting client"))

node_requester -->|"sends request"| node_cache_top
node_cache_top -->|"connects"| node_controller
node_cache_top -->|"connects"| node_decoder
node_cache_top -->|"connects"| node_comparator
node_cache_top -->|"connects"| node_hit_miss
node_cache_top -->|"connects"| node_lru
node_cache_top -->|"connects"| node_cache_array
node_cache_top -->|"connects"| node_main_memory
node_controller -->|"requests refill"| node_main_memory

click node_cache_top "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_2way.v"
click node_controller "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_controller.v"
click node_decoder "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/address_decoder.v"
click node_comparator "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/tag_comparator.v"
click node_hit_miss "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/hit_miss_unit.v"
click node_lru "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/lru_unit.v"
click node_cache_array "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_array.v"
click node_main_memory "https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/main_memory.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_cache_top,node_controller,node_requester toneBlue
class node_decoder,node_comparator,node_hit_miss,node_lru toneAmber
class node_cache_array,node_main_memory toneMint
```

## Components

### Cache integration

- [Cache top level](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_2way.v): `rtl/cache_2way.v`
- [Cache controller](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_controller.v): `rtl/cache_controller.v`

### Lookup and selection

- [Address decoder](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/address_decoder.v): `rtl/address_decoder.v`
- [Tag comparator](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/tag_comparator.v): `rtl/tag_comparator.v`
- [Hit/miss selector](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/hit_miss_unit.v): `rtl/hit_miss_unit.v`
- [LRU replacement](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/lru_unit.v): `rtl/lru_unit.v`

### Cache and memory state

- [Cache array](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/cache_array.v): `rtl/cache_array.v`
- [Backing memory](https://github.com/pranjal9005/2-way-set-associative-cache/blob/main/rtl/main_memory.v): `rtl/main_memory.v`

### Other components

- **Requesting client**

## Connections

- Requesting client → Cache top level: sends request (evidence: `README.md`)
- Cache top level → Cache controller: connects (evidence: `README.md`)
- Cache top level → Address decoder: connects (evidence: `README.md`)
- Cache top level → Tag comparator: connects (evidence: `README.md`)
- Cache top level → Hit/miss selector: connects (evidence: `README.md`)
- Cache top level → LRU replacement: connects (evidence: `README.md`)
- Cache top level → Cache array: connects (evidence: `README.md`)
- Cache top level → Backing memory: connects (evidence: `README.md`)
- Cache controller → Backing memory: requests refill (evidence: `README.md`)
