Intel® Quartus® Prime Pro Edition User Guide: Third-party Synthesis

ID 683122
Date 12/12/2023
Public
Document Table of Contents

2.10.3.3. RAM Initialization

Use the Verilog HDL $readmemb or $readmemh system tasks in your HDL code to initialize RAM memories. The Synplify compiler forward-annotates the initialization values in the .srs (technology-independent RTL netlist) file and the mapper generates the corresponding hexadecimal memory initialization (.hex) file. One .hex file is created for each of the altsyncram IP cores that are inferred in the design. The .hex file is associated with the altsyncram instance in the .vqm file using the init_file attribute.

The examples show how RAM can be initialized through HDL code, and how the corresponding .hex file is generated using Verilog HDL.

Using $readmemb System Task to Initialize an Inferred RAM in Verilog HDL Code

initial
begin
    $readmemb("mem.ini", mem);
end
always @(posedge clk)
begin
    raddr_reg <= raddr;
    if(we)
        mem[waddr] <= data;
end

Sample of .vqm Instance Containing Memory Initialization File

altsyncram mem_hex( .wren_a(we),.wren_b(GND),...);

defparam mem_hex.lpm_type = "altsyncram";
defparam mem_hex.operation_mode = "Dual_Port";
...
defparam mem_hex.init_file = "mem_hex.hex";