Specifications

For more information, refer to an example of custom Tcl script usage in the “Creating Memory Initializa‐
tion Files” chapter.
Note: Any settings you specify in your script override the BSP default values.
For more information about BSP defaults, refer to the “Specifying BSP Defaults” chapter.
Note: When you update an existing BSP, you must include any scripts originally used to create it.
Otherwise, your project’s settings revert to the defaults.
Note: When you use a custom Tcl script to create your BSP, you must include the script in the set of files
archived in your version control system.
For more information, refer to the “Using Version Control” chapter.
Related Information
Specifying BSP Defaults on page 4-34
Using Version Control on page 4-8
Creating Memory Initialization Files on page 4-10
Getting Started with the Graphical User Interface on page 2-1
Simple Tcl Script
Example 4–8. To Set stdio to a Device with the name my_uart
set default_stdio my_uart
set_setting hal.stdin $default_stdio
set_setting hal.stdout $default_stdio
set_setting hal.stderr $default_stdio
Tcl Script to Examine Hardware and Choose Settings
Note:
The Nios II SBT uses slave descriptors to refer to components connected to the Nios II processor.
A slave descriptor is the unique name of a hardware component’s slave port.
If a component has only one slave port connected to the Nios II processor, the slave descriptor is the same
as the name of the component (for example, onchip_mem_0). If a component has multiple slave ports
connecting the Nios II to multiple resources in the component, the slave descriptor is the name of the
component followed by an underscore and the slave port name (for example, onchip_mem_0_s1).
# Select a device connected to the processor as the default STDIO device.
# It returns the slave descriptor of the selected device.
# It gives first preference to devices with stdio in the name.
# It gives second preference to JTAG UARTs.
# If no JTAG UARTs are found, it uses the last character device.
# If no character devices are found, it returns "none".
# Procedure that does all the work of determining the stdio device
proc choose_default_stdio {} {
set last_stdio "none"
set first_jtag_uart "none"
# Get all slaves attached to the processor.
set slave_descs [get_slave_descs]
foreach slave_desc $slave_descs {
# Lookup module class name for slave descriptor.
set module_name [get_module_name $slave_desc]
set module_class_name [get_module_class_name $module_name]
# If the module_name contains "stdio", we choose it
NII5V2
2015.05.14
Simple Tcl Script
4-27
Nios II Software Build Tools
Altera Corporation
Send Feedback