Nios II Classic Software Developer’s Handbook

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

4.4.2.3.2. Dividing a Linker Region to Create a New Region and Section

This example works with any hardware design containing an on-chip memory named tightly_coupled_instruction_memory connected to a Nios II instruction master.

Example 4–2. To Create a Section named .isrs in the tightly_coupled_instruction_memory on-chip memory

# Get region information for tightly_coupled_instruction_memory memory region. 
# Returned as a list. 
set region_info [get_memory_region tightly_coupled_instruction_memory] 
# Extract fields from region information list. 
set region_name [lindex $region_info 0] 
set slave [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 tightly_coupled_instruction_memory $slave $offset $new_span 
add_memory_region isrs_region $slave $split_offset $split_span 
add_section_mapping .isrs isrs_region 

The above Tcl script splits off 1 KB of RAM from the region named tightly_coupled_instruction_memory, gives it the name isrs_region, and then calls add_section_mapping to add the .isrs section to isrs_region.

Using the Create a New Region and Section Tcl Script

To use such a Tcl script, you would execute the following steps:

  1. Create the Tcl script as shown in the example, above.
  2. Edit your create-this-bsp script, and add the following argument to the nios2-bsp command line:

    --script <script name>.tcl

  3. In the BSP project, edit timer_interrupt_latency.h. In the timer_interrupt_latency_irq() function, change the .section directive from .exceptions to .isrs.
  4. Rebuild the application by running make.