Visible to Intel only — GUID: mwh1416946691007
Ixiasoft
Visible to Intel only — GUID: mwh1416946691007
Ixiasoft
4.4.2.2. Modifying Linker Memory Regions
Suppose you have a memory region named onchip_ram. The Tcl script named reserve_1024_onchip_ram.tcl separates the top 1024 bytes of onchip_ram to create a new region named onchip_special.
For more information about an explanation of each Tcl command used in this example, refer to the "Nios II Software Build Tools Reference" chapter.
# Get region information for onchip_ram memory region. # Returned as a list. set region_info [get_memory_region onchip_ram] # Extract fields from region information list. set region_name [lindex $region_info 0] set slave_desc [lindex $region_info 1] set offset [lindex $region_info 2] set span [lindex $region_info 3] # Remove the existing memory region. delete_memory_region $region_name # Compute memory ranges for replacement regions. set split_span 1024 set new_span [expr $span-$split_span] set split_offset [expr $offset+$new_span] # Create two memory regions out of the original region. add_memory_region onchip_ram $slave_desc $offset $new_span add_memory_region onchip_special $slave_desc $split_offset $split_span
If you pass this Tcl script to nios2-bsp, it runs after the default Tcl script runs and sets up a linker region named onchip_ram0. You pass the Tcl script to nios2-bsp as follows:
nios2-bsp hal my_bsp --script reserve_1024_onchip_ram.tcl
If you run nios2-bsp again to update your BSP without providing the --script option, your BSP reverts to the default linker memory regions and your onchip_special memory region disappears. To preserve it, you can either provide the --script option to your Tcl script or pass the DONT_CHANGE keyword to the default Tcl script as follows:
nios2-bsp hal my_bsp --default_memory_regions DONT_CHANGE
Intel FPGA recommends that you use the --script approach when updating your BSP. This approach allows the default Tcl script to update memory regions if memories are added, removed, renamed, or resized. Using the DONT_CHANGE keyword approach does not handle any of these cases because the default Tcl script does not update the memory regions at all.
For more information about using the --script argument, refer to the “Calling a Custom BSP Tcl Script” section.