RTL Studio Open IDE

Memory & FIFOs

Dual-Port Register File 4x16 — L2 Upgrade

Dual-Port Register File 4x16 with Invalidate, Shadow Commit, Byte Enable, and Hazard Detection for L2 upgrades.

About this block

Simulate it in the Verilog IDE

Hardverilogsimsyn

Dual-Port Register File 4x16 — L2 Upgrade 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 high-performance dual-port register file with 4 entries and a 16-bit data width. It is designed for integration into RISC-V cores, specifically for L2 cache or register file upgrades. Key features include independent read/write ports, byte-enable support, atomic shadow commit mechanisms, and robust hazard detection to prevent read-after-write conflicts.

This IP provides a robust, fully verified dual-port register file with advanced control features including atomic shadow commits and hazard detection. It is ready for integration into RISC-V cores requiring L2 cache or register file upgrades.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Dual-Port Register File 4x16 — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: Dual-Port Register File 4x16 with Invalidate, Shadow Commit, Byte Enable, and Hazard Detection for L2 upgrades.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. 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.

Features

  • Dual Independent Ports: Port A and Port B support simultaneous read and write operations.
  • Configurable Depth/Width: 4 entries, 16-bit data width.
  • Byte-Enable Support: Partial word writes via be_a and be_b signals.
  • Invalidate Control: Signals inv_a and inv_b to clear specific register entries.
  • Shadow Commit Mechanism: Buffered writes in shadow memory are applied atomically to main memory via commit_shadow.
  • Hazard Detection: Outputs hazard_a and hazard_b to indicate read-after-write conflicts, allowing backpressure or stalling.
  • Synchronous Reset: Clears all internal state (main and shadow memory) on reset.

Ports

Signal NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low synchronous reset
wa_aInput2Port A write address [1:0]
we_aInput1Port A write enable
wd_aInput16Port A write data [15:0]
be_aInput2Port A byte enable [1:0] (0:LSB, 1:MSB)
inv_aInput1Port A invalidate control
rb_aInput2Port A read address [1:0]
rd_aOutput16Port A read data [15:0]
wb_bInput2Port B write address [1:0]
we_bInput1Port B write enable
wd_bInput16Port B write data [15:0]

Architecture

The module consists of two memory arrays: mem (main) and shadow_mem (buffer).

  1. Write Operation: When we_a or we_b is asserted, data is written to shadow_mem and marked valid. Byte enables allow selective updates.
  2. Invalidate: If inv_a or inv_b is asserted, the corresponding entry in mem is cleared, and the shadow entry is invalidated.
  3. Commit: When commit_shadow is asserted, valid entries from shadow_mem are copied to mem.
  4. Hazard Detection: If a write address on one port matches the read address on the other port during the same cycle, the respective hazard output is asserted. In this case, the reading port returns 0 instead of stale data.

Verification

The design has been verified using a comprehensive testbench covering:

  • Basic read/write operations for both ports.
  • Byte-enable functionality (partial word writes).
  • Invalidate logic (clearing entries).
  • Hazard detection (read-after-write conflicts).
  • Shadow commit (atomic updates).
  • Reset behavior.

All 7 test cases pass successfully.

Test CaseDescriptionResult
TC1Basic Write and Read Port APASS
TC2Basic Write and Read Port BPASS
TC3Byte Enable Port APASS
TC4Invalidate Port APASS
TC5Hazard Detection Port APASS
TC6Shadow CommitPASS
TC7ResetPASS

More in Memory & FIFOs

All Memory & FIFOs blocks