Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
    • SRAM and ROM
    • Register Files
      • Multi-Port Register File Fundamentals
      • 2R1W Register File with Bypass
      • Read-During-Write Hazards and Assertions
    • Valid/Ready Handshake
    • AXI-Lite
    • AXI-Stream
    • Bus Integration
    • Synchronous FIFO
    • Register-Map and CSR RTL
    • Memory Reliability
    • Peripheral RTL Integration
    • Full AXI4: RTL Roadmap
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Register Files
  1. Topics
  2. RTL Design
  3. Memory & Buses
  4. Register Files
  5. Multi-Port Register File Fundamentals

Part 7 · Memory & Buses · Intermediate

Multi-Port Register File Fundamentals

Two reads and one write each cycle: the same-cycle contract, the x0 rule, and flop, bank and multi-port costs.

On this page

    Why this matters

    A 32-entry by 32-bit flop array costs 1024 flops and two 32-to-1 read muxes, and each extra read port adds another mux. What a read returns while the same register is being written has to be settled before any code is.

    After this lesson you can: state the 2R1W contract, including x0 and a same-cycle read of the written register, and weigh a flop array against SRAM banks.

    The 2R1W contract

    CPU-style register files often require 2 read + 1 write ports in one cycle. True multi-port SRAM is expensive, so many designs use flop arrays or replicated RAM banks.

    The contract below fixes the same-cycle semantics per the architectural spec. Every implementation in this topic follows it.

    The flop-array 2R1W file: the write port updates one word at the clock edge, and each read port is its own mux on the same array

    Read the picture with the table below beside it. The write commits at the edge, while both reads are combinational. That is why a read of the register being written needs a rule: without one it returns the old word in that cycle.

    • Two read muxes: the two reads never compete, because each port has its own mux on the shared array.

    • One write port: a single word changes per cycle, so the only same-cycle conflict is a read of that word.

    • x0: the read side forces zero and the write side drops the write, so register 0 never holds anything else.

    Case

    Result

    Read address differs from write address

    The stored word

    Read address equals write address, write enabled

    The NEW write data (write-through)

    Write disabled

    The stored word on every read

    Read address is x0

    Zero, always, regardless of writes

    Write address is x0

    Dropped: the write changes nothing

    One more rule sets up the next lesson. A bypass is added when the decode stage needs a just-written value immediately.

    Flop array versus SRAM bank

    A 32-entry by 32-bit flop array holds 1024 storage flops plus two 32-to-1 read muxes. It resets with a loop, reads combinationally, and grows a mux per read port.

    Style

    How 2R1W is built

    Cost

    Use when

    Flop array

    One array, two read muxes, one write enable

    Flops plus muxes; area grows with ports and words

    Tens of words, for example a 32-entry integer file

    Replicated banks

    One SRAM bank per read port; writes broadcast to all banks

    One bank per read port plus broadcast logic

    Hundreds of words with few read ports

    True multi-port RAM

    One macro with two read and one write port

    Dense storage; port combinations are process-limited

    Large files where the macro ports match 2R1W

    The reset loop in the next lesson targets flops. Conventional FPGA block RAM and selected synchronous SRAM macros cannot clear every word at once and require clocked reads, so this combinational-read, array-reset code does not match them. Other SRAM resources can support asynchronous reads; inspect the chosen macro's interface. Replacing this file with synchronous banks changes read latency and requires a matching pipeline contract.

    Common mistakes

    Common pitfall

    A bypass comparator without the x0 exclusion forwards write data to register 0. Reads of x0 must return zero even while a write to x0 is asserted, so the comparator needs the nonzero guard on both the write and the match.

    Interview

    Likely question: how is a 2R1W file built from flops, and what does a same-cycle read of the written register return?

    • Structure: one flop array, two combinational read muxes, one clocked write port, x0 hardwired to zero.

    • Same-cycle read of the written register: the new write data, through the bypass mux.

    • Trade-off: flop arrays suit small files; replicated banks or a multi-port macro suit large ones.

    Check yourself A write to register 5 and a read of register 5 happen in the same cycle with the write enabled. What does the read return under this topic's contract?

    The new write data. Same-cycle read of the written register is write-through by contract.

    Check yourself A write targets x0 while both read ports read x0. What do the ports return, and what happens to the array?

    Both return zero. The write is dropped, so the array is unchanged.

    Check yourself A design grows its register file from 32 to 1024 entries but keeps the flop array. What breaks first?

    Area and timing. The flop count grows 32x and each read mux grows from 32-to-1 to 1024-to-1. A replicated-bank or multi-port SRAM structure fits large files better.

    Remember

    • 2R1W means two combinational reads and one clocked write in the same cycle.

    • By contract, a same-cycle read of the written register returns the write data. Register x0 reads zero and drops writes.

    • Synchronous SRAM banks cannot clear every word at once, and they change the read latency.

    Rule of thumb: fix read-during-write and x0 in the contract first, then write the code.

    Keep going

    • Practice: Register file with two read ports and one write port

    • Practice: Multi-port register file (3+ ports)

    • Code lab: 2x8 register file

    • Interview: run a mock interview on this topic

    Related topics

    • 2R1W register file with bypass

    Previous

    195 / 350

    Next: 2R1W Register File with Bypass

    Up next

    Up next2R1W Register File with Bypass

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Read-During-Write Hazards and Assertions