Electronic – Verilog memory designs with multiple read/write ports – poor circuit performance when synthesized

digital-logicmemoryverilog

I am interested in designing (with verilog) some memory structures that have multiple (let's say 3) read/write ports. I've been doing some studying on architecture and what I've heard is that these are not trivial hardware implementations, and can create a lot slower circuits.

With behavioural verilog I would imagine it's quite simple, something along the lines of:

always @ (posedge clk) begin
    if (read_enable) begin
        out1 <= mem[read_addr1];
        out2 <= mem[read_addr2];
        out3 <= mem[read_addr3];
    end
    //something similar if I want multiple writes
end

Assuming it synthesizes, will I have a crappy and slow circuit, and why? Can it be alleviated by going with a more custom design using gates instead of behavioural coding?

Thanks

Best Answer

Firstly, are you synthesizing to an FPGA?

This paper from Cypress shows a dual-port RAM as a block diagram. It's not quite clear from there, but the dual-port array in the middle is an array which has a double set of lines: 2 row selects, 2 write column sets, 2 read column sets.

Scaling beyond 2 is difficult because then you need 3, 4 etc sets of wires, and your RAM density goes down as you run out of space for wires.

If you write Verilog which implies more than 2 ports, the synthesis tool will build it out of flops with multiplexors on the front, consuming far more space than RAM cells.

Why do you actually need multiple ports? How large a RAM do you want? Building a memory arbitrator on the front of a normal RAM may be the solution you want.