Nios II Classic Software Developer’s Handbook

ID 683282
Date 5/14/2015
Public
Document Table of Contents

4.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 17.  mem_init.mk Targets
Target Operation
mem_init_install
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.