Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Build one-write/two-read memory from BRAM

Hardware interview practice

Build one-write/two-read memory from BRAM

MediumRTL DesignSystemVerilog

Two identical synchronous 1W1R BRAMs must implement a logical memory with one write and two independent reads. Implement the mirrored SystemVerilog wrapper with defined collision behavior.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

input logic clk, we; input logic [7:0] waddr, raddr0, raddr1;
input logic [31:0] wdata;
output logic [31:0] rdata0, rdata1;
Reviewed example

Work through one case

Input
Write address 5 with 32'h0000_00AA, then issue reads of address 5 on both read ports.
Expected output
One edge after the reads, rdata0=rdata1=32'h0000_00AA.

The write is mirrored into both BRAM copies, and each registered read port retrieves the same defined logical location.

What to cover

Requirements

  1. Instantiate or infer two 256x32 1W1R memories and apply every write to both copies on the same rising edge.
  2. Use copy 0 for read address raddr0 and copy 1 for raddr1; both read outputs are registered with one-cycle latency.
  3. Define same-edge read/write to the same address as write-first, returning wdata on the matching read output.
  4. There is no reset for memory contents or read data; the testbench compares read outputs only after a defined location is written.
Continue practicing

Related questions

RTL DesignEnabled modulo-five counter→RTL DesignAccumulate a four-lane signed dot product→RTL DesignEncode the highest active request and its one-hot form→
asic.fyi · Learn silicon end to end.info@asic.fyi