Codiode

Synchronous Single Port RAM

EasyVerilog / SystemVerilogBuildFree6 solved

A single-port RAM does one access per clock, either a read or a write. On a chip it is far denser than the same storage built from flip-flops.

The memory array contains 16 words, with each word being 8 bits wide. Access to the memory is governed by a chip enable signal and a write enable signal. When the chip is enabled, the memory performs a write operation if the write enable is asserted, or a read operation if it is de-asserted.

All operations are synchronous to the positive edge of clk. When a write operation occurs, the memory must exhibit write-first behavior, meaning the output dout updates simultaneously to reflect the newly written data. When a read operation occurs, the memory contents at addr are driven to dout. When the chip enable is de-asserted, the memory ignores all inputs and dout strictly holds its previous value. There is no reset pin for the memory array.

Cycle 1: ce=1, we=1, addr=4'h5, din=8'hAA → dout=8'hAA (Write to addr 5)
Cycle 2: ce=0, we=0, addr=4'h0, din=8'h00 → dout=8'hAA (Hold previous output)
Cycle 3: ce=1, we=0, addr=4'h5, din=8'h00 → dout=8'hAA (Read from addr 5)

Signal Direction Width Description
clk input 1 Positive-edge triggered clock
ce input 1 Chip enable; active-high
we input 1 Write enable; active-high
addr input 4 Memory address for read and write operations
din input 8 Data input for write operations
dout output 8 Data output; updates on posedge clk

Constraints

  • The memory array must be exactly 16 words deep and 8 bits wide.
  • All operations must be synchronous to the positive edge of clk.
  • When we is asserted, the memory must exhibit write-first behavior and forward the new data to dout.
  • When ce is de-asserted, dout must hold its exact previous value.
  • Do not use asynchronous resets or attempt to initialize the memory array to zero.

Topics

MemorySynchronousBRAMSingle-Port

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.

Free to solve. A Codiode account keeps your progress.

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Part of Memory and Storage

Problem 3 of 26 in the Memory and Storage track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.