Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

5.4.2.1. Creating Memory Initialization Files

The mem_init.mk file includes targets designed to help you create memory initialization files (.dat, .hex, .sym, and .flash). The mem_init.mk file is designed to be included in your application makefile. Memory initialization files are used for HDL simulation, for Quartus Prime compilation of initializable FPGA on-chip memories, and for flash programming. Memories that can be initialized include M512 and M4K, but not MRAM.

Although the application makefile provides the mem_init.mk targets, it does not build any of them by default. The SBT creates the memory initialization files in the application directory (under a directory named mem_init). The SBT optionally copies them to your Quartus Prime project directory and HDL simulation directory.

Note: The Nios® II SBT does not generate a definition of QUARTUS_PROJECT_DIR in your application makefile.
If you have an on-chip RAM, and require that a compiled software image be inserted in your SRAM Object File (.sof) at Quartus Prime compilation, you must manually specify the value of QUARTUS_PROJECT_DIR in your application makefile. You must define QUARTUS_PROJECT_DIR before the mem_init.mk file is included in the application makefile, as in the following example:
QUARTUS_PROJECT_DIR = ../my_hw_design
MEM_INIT_FILE := $(BSP_ROOT_DIR)/mem_init.mk
include $(MEM_INIT_FILE)
Table 19.  mem_init.mk Targets
Target Operation
mem_init_install

Generates memory initialization files in the application mem_init directory. If the QUARTUS_PROJECT_DIR variable is defined, mem_init.mk copies memory initialization files to your Intel® Quartus® Prime project directory named $(QUARTUS_PROJECT_DIR).

mem_init_generate Generates all memory initialization files in the application mem_init directory.

This target also generates a Quartus Prime IP File (.qip). The .qip file tells the Quartus Prime software where to find the initialization files.

mem_init_clean Removes the memory initialization files from the application mem_init directory.
.hex Generates all .hex files.
.dat Generates all .dat files.
.sym Generates all .sym files.
.flash Generates all .flash files.
<memory name> Generates all memory initialization files for <memory name> component.