Nios® V Processor Software Developer Handbook

ID 743810
Date 2/14/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

12.5.3. Tcl Commands for BSP Generation Callbacks

If you are defining a device driver or a software package, you can define Tcl callback functions to run whenever a BSP is generated containing your driver or package. Tcl callback functions enable you to create settings dynamically for the driver or package. This capability is essential when the driver or package settings must be customized to the hardware configuration, or to other BSP settings.

Tcl callback scripts are defined and controlled from the *_sw.tcl file associated with the driver or package. In *_sw.tcl, you can specify where the Tcl functions come from, when function runs, and the scope of each Tcl function’s operation.

When the BSP is generated with your driver or software package, the settings you define in the callback scripts are inserted in settings.bsp.

You specify the source of the callback functions with the set_sw_property command, using the callback_source_file property.

A Tcl callback function can run at one of the following times:
  • BSP initialization
  • BSP generation
  • BSP validation
Note: Although you can specify a new setting’s value when you create the setting at BSP initialization, the setting’s value can change between initialization and generation. For example, the BSP developer might edit the setting in the BSP Editor.
A Tcl callback can function in either of the following scopes:
  • Component class
  • Component instance

You specify each callback function’s runtime environment by using the appropriate property in the set_sw_property command, as shown in the table below.

Table 48.  Callback Properties
Property as specified in set_sw_property Run time Scope Callback Arguments
initialization_callback Initialization Component instance Component instance name
validation_callback Validation Component instance Component instance name
generation_callback Generation Component instance
  • Component instance name
  • BSP generate target directory
  • Driver BSP subdirectory4
class_initialization_callback Initialization Component class Driver class name
class_validation_callback Validation Component class Driver class name
class_generation_callback Generation Component class
  • Driver class name
  • BSP generate target directory
  • Driver BSP subdirectory(1)

Tcl callbacks have access to a specialized set of commands, described in this section. In addition, Tcl callbacks can use any read-only BSP setting Tcl command.

Note: For more information about BSP setting Tcl commands, refer to the Tcl Commands for BSP Settings chapter. When a Tcl callback creates a setting, it can specify the value. However, callbacks cannot change the value of a pre-existing setting.
4 The BSP subdirectory into which the driver or package files are copied