Altera_Forum
Honored Contributor
18 years agoQuartus' own Single Port RAM template infers Dual Port RAM with pass-through logic
For portability and readability I strongly prefer infering memory, but I seem to be having a very hard time getting Quartus II 7.2 to work correctly.
To prove I wasn't insane, I started a fresh empty project (1C20 FWIW), picked edit -> insert template -> single port ram and ended up with reasonably looking code (included below). However, when I translate it, I get this warning "Warning: Inferred RAM node "ram~0" from synchronous design logic. Pass-through logic has been added to match the read-during-write behavior of the original design." To make matters even more entertaining, the online help disagrees with this template. Notably, the memory update is using a non-blocking assignment if (we) ram[addr] <= data and that doesn't infer the pass-through logic. Unfortunately, both infers Simple Dual RAM according to the Analysis & Synthesis RAM Summary. Is it even possible to infer Single Port RAM? (I care because I want to pack two single port rams into one M4K block). Thanks Tommy .... code below .... // Quartus II Verilog Template // Single port RAM with single read/write address module single_port_ram ( input [(DATA_WIDTH-1):0] data, input [(ADDR_WIDTH-1):0] addr, input we, clk, output reg [(DATA_WIDTH-1):0] q ); parameter DATA_WIDTH = 8; parameter ADDR_WIDTH = 6; // Declare the RAM variable reg [DATA_WIDTH-1:0] ram[2**ADDR_WIDTH-1:0]; always @ (posedge clk) begin // Write if (we) ram[addr] = data; // Read returns NEW data at addr if we == 1'b1. This is the // natural behavior of TriMatrix memory blocks in Single Port // mode q <= ram[addr]; end endmodule