Forum Discussion
Altera_Forum
Honored Contributor
8 years agoHow to infer MLAB memory?
I have a simple memory code
(* ramstyle = "MLAB" *) module memory_module # (parameter addr_width = 8, data_width = 32) (input clk, input [data_width-1:0] wr_data, output reg [data_width-1:0]rd_data, input [addr_width-1:0] wr_addr, input [addr_width-1:0] rd_addr, input we, input re); reg [data_width-1:0] mem [2**addr_width-1:0] /* synthesis syn_ramstyle = "MLAB"*/; always@(posedge clk) begin if (we) mem[wr_addr] <= wr_data; if (re) rd_data <= mem[rd_addr]; end endmodule And I am trying to use MLAB for this. Is there any other attribute that I am missing to infer MLABs? The attributes in the code do not work as intended.1 Reply
- Altera_Forum
Honored Contributor
Try to add (* ramstyle = "MLAB" *) just before reg [data_width-1:0]...
Also, try lower addr_width. Maximum depth for a MLAB is 32. You have addr_width=8 which corresponds to depth 256. The compiler might make it work with lots of multiplexers, but may also decide not to bother, ignore the attribute, and put the whole construct into a M9K/M10K/M20K instead.