// sp_ram.sv // Single-port RAM with a synchronous (registered) read, read-first behaviour. // Synthesis tools map this template to block RAM when the size justifies it. // Read-first: during a write, dout returns the OLD contents of addr. `timescale 1ns/1ps module sp_ram #( parameter int DW = 16, // data width parameter int AW = 10 // address width, depth = 2**AW ) ( input logic clk, input logic en, // port enable: no read or write when low input logic we, // write enable input logic [AW-1:0] addr, input logic [DW-1:0] din, output logic [DW-1:0] dout ); logic [DW-1:0] mem [0:(1<