BitFlow

Synchronous SRAM (Read-First)

intermediate · memory · 150 XP

Sign in to write your solution, run it in the simulator and submit it for grading.

Sign in or create a free account →

Problem

Synchronous SRAM — Read-First Same as the write-first SRAM, but with **read-first behaviour**: when a read and write occur to the same address in the same cycle, `dout` returns the **old** value (what was there before the write). This is the **default BRAM mode** on most FPGAs and the natural behaviour of most SRAM macros on ASICs. **Interface** (identical to MEM.01) | Port | Direction | Description | |------------|-----------|--------------------------| | `clk` | input | Clock | | `we` | input | Write enable | | `addr[7:0]`| input | Address | | `din[7:0]` | input | Write data | | `dout[7:0]`| output | Read data (registered) | **The subtle difference from MEM.01:** `dout` is assigned from `mem[addr]` unconditionally, and because the non-blocking write hasn't taken effect yet when the read evaluates, `dout` sees the old value. In your comments, describe a real-world scenario where the choice between write-first and read-first matters.

Constraints

  • dout is always assigned from mem[addr] (unconditionally).
  • Simultaneous read+write to same address → dout = old value.
  • Write still happens synchronously when we=1.
  • Use non-blocking assignments to get correct read-first simulation.

Examples

Input: we=1, addr=0x10, din=0xFF (addr previously held 0xAA)

Output: dout=0xAA (old value)

Read-first returns old data

Input: Next cycle: we=0, addr=0x10

Output: dout=0xFF

Write has now completed

Common questions

What does the Synchronous SRAM (Read-First) problem ask you to build?
Synchronous SRAM — Read-First Same as the write-first SRAM, but with **read-first behaviour**: when a read and write occur to the same address in the same cycle, `dout` returns the **old** value (what was there before the write).
What constraints does Synchronous SRAM (Read-First) have?
dout is always assigned from mem[addr] (unconditionally).; Simultaneous read+write to same address → dout = old value.; Write still happens synchronously when we=1.; Use non-blocking assignments to get correct read-first simulation.
What is an example input and output for Synchronous SRAM (Read-First)?
Input we=1, addr=0x10, din=0xFF (addr previously held 0xAA) gives output dout=0xAA (old value). Read-first returns old data
Which Verilog concepts does Synchronous SRAM (Read-First) practise?
memory, SRAM, read-first, BRAM.