Memory & FIFOs
CAM 4x8 with Invalidate
A 4-entry, 8-bit Content-Addressable Memory with individual entry invalidate capability.
About this block
Simulate it in the Verilog IDE
CAM 4x8 with Invalidate is a Verilog reference block in the Memory & FIFOs catalog. SRAM models, FIFOs, register files, and memory-style storage. Marked Hard: a larger reference. Simulate the packaged testbench before you change the RTL.
This IP implements a 4-entry, 8-bit Content-Addressable Memory (CAM). It supports individual entry invalidation via a dedicated control interface, allowing entries to be logically disabled without erasing their stored data. This feature is useful for dynamic cache management or tag files where entries need to be retired without data loss.
### Key Features
- Write: Updates data and marks entries as valid.
- Invalidate: Marks specific entries as invalid without changing stored data.
- Search: Returns the address of the first matching valid entry.
- Synchronous Control: All control signals are synchronized to the clock edge.
- Combinational Search: Search logic provides immediate results upon assertion of
search_en.
This IP provides a simple, synchronous CAM with 4 entries and 8-bit width, featuring individual entry invalidation. It is suitable for small lookup tables, tag files, or simple associative caches where low latency and simple control are required. The search logic is combinational, providing immediate results upon assertion of search_en.
- Choose Open in IDE. RTL Studio loads the packaged workspace for CAM 4x8 with Invalidate.
- Read the Verilog module in the editor. The catalog line for this block: A 4-entry, 8-bit Content-Addressable Memory with individual entry invalidate capability.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.
RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.
Architecture
The design consists of:
- A 4x8 bit storage array (
cam_mem). - A 4-bit validity register (
valid) tracking entry status. - Write Logic: Synchronous update of data and validity bit on
wr_en. - Invalidate Logic: Synchronous clearing of validity bit on
inv_en. - Search Logic: Combinational logic checking all valid entries against
search_data.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low reset |
wr_addr | Input | 2 | Write address [1:0] |
wr_data | Input | 8 | Write data [7:0] |
wr_en | Input | 1 | Write enable |
inv_addr | Input | 2 | Invalidate address [1:0] |
inv_en | Input | 1 | Invalidate enable |
search_data | Input | 8 | Search data [7:0] |
search_en | Input | 1 | Search enable |
match_addr | Output | 2 | Match address [1:0] |
match_valid | Output | 1 | Match valid flag |
Verification
The provided testbench (tb_cam_invalidate_4x8.v) verifies the following scenarios:
- Reset: Verifies all entries are invalid after reset.
- Write: Writes four distinct values to all entries.
- Search: Verifies correct address match for each written value.
- No Match: Verifies no match for a non-existent value (e.g.,
0xFF). - Invalidate: Invalidates one entry and verifies it no longer matches.
- Persistence: Verifies other entries still match after invalidation.
- Re-write: Writes a new value to the invalidated entry and verifies it matches.
Run the simulation in RtlStudio. The Log panel should display INFO: PASS upon completion.
More in Memory & FIFOs
- 16-Word 16-Bit Sync RAM with Byte Enable — L2 Upgrade
- 16×8 Sync RAM (No Reset, Registered Read) — L2 Upgrade
- 32-Bit Asynchronous FIFO with Gray Pointer Encoding
- 32-Bit Register with Byte Writes
- 32x16 Synchronous Single-Port RAM
- 4x8 1W1R Register File (Comb Read)
- 4×8 Sync RAM (Async Reset, Comb Read)
- 64-bit Wide Scratchpad RAM with Dual-Port Access
- 8-Bit Valid/Ready Skid Buffer
- 8x16 Single-Port Sync RAM
- 8x32 Dual-Read Register File
- 8×8 Sync RAM (Async Reset, Comb Read, Loop Init) — L1 Upgrade
- Asymmetric RAM WR8 RD16 — L2 Upgrade
- Byte-Enable Regfile 8x32 — L2 Upgrade
- Circular Buffer 16x8
- Count-Based Sync FIFO with Dual Ready/Valid