BitFlow

Simple Dual-Port SRAM

intermediate · memory · 160 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

Simple Dual-Port SRAM A 256 × 8-bit RAM with **two separate ports**: one dedicated write port and one dedicated read port, both operating simultaneously every cycle. **Interface** | Port | Direction | Description | |--------------|-----------|------------------------------------| | `clk` | input | Clock | | `we` | input | Write enable | | `waddr[7:0]` | input | Write address | | `wdata[7:0]` | input | Write data | | `raddr[7:0]` | input | Read address | | `rdata[7:0]` | output | Read data (**asynchronous/combinational**) | **Write:** synchronous (posedge clk, we=1). **Read:** asynchronous — combinational: `rdata = mem[raddr]` always, no clock. If `waddr == raddr` in the same cycle: the async read returns the **old** value (before the write completes), because it reads combinationally from the array before the synchronous write resolves. This is the standard RISC register file: write one result while reading two operands.

Constraints

  • Write port is synchronous (posedge clk).
  • Read port is asynchronous: `assign rdata = mem[raddr];`
  • Simultaneous read+write to same address → rdata = old value.

Examples

Input: we=1, waddr=5, wdata=0xAB; raddr=7 simultaneously

Output: rdata=mem[7] (independent)

Different addresses — independent

Input: we=1, waddr=5, wdata=0xFF; raddr=5 simultaneously

Output: rdata=old mem[5]

Same address — async read sees old value

Common questions

What does the Simple Dual-Port SRAM problem ask you to build?
Simple Dual-Port SRAM A 256 × 8-bit RAM with **two separate ports**: one dedicated write port and one dedicated read port, both operating simultaneously every cycle.
What constraints does Simple Dual-Port SRAM have?
Write port is synchronous (posedge clk).; Read port is asynchronous: `assign rdata = mem[raddr];`; Simultaneous read+write to same address → rdata = old value.
What is an example input and output for Simple Dual-Port SRAM?
Input we=1, waddr=5, wdata=0xAB; raddr=7 simultaneously gives output rdata=mem[7] (independent). Different addresses — independent
Which Verilog concepts does Simple Dual-Port SRAM practise?
memory, SRAM, dual-port, interview, register-file.