Download Simics User Guide for Unix

Transcript
Chapter 8
Simics Scripting Environment
The Command-Line Interface in Simics has simple scripting capabilities that can be used
when writing parameterized configurations and scripts with conditional commands. For
more advanced scripting, the Python language can be used.
This chapter describes how to write simple scripts in the Simics command line interface
(CLI), using control flow commands, and variables. It also explains how the configuration
system can be accessed from scripts, and how Python can be used for more advanced scripting.
All commands can be executed either by typing them at the prompt in the Simics console, or by writing them to a file, e.g. example.simics, and executing the command runcommand-file example.simics, or for Python examples: run-python-file example.py.
8.1
8.1.1
Script Support in CLI
Variables
The Simics command line has support for string and integer variables. Variables are always
prefixed with the $ character. Variables that are not set have a value of 0.
simics> $foo = "some text"
simics> $foo
some text
simics> echo $not_used_before
0
There is also support for indexed variables (arrays). This is useful in loops for example.
simics> $foo[0] = 10
simics> $foo[1] = 20
simics> echo $foo[0] + $foo[1]
30
CLI also has support for local variables, described later in this chapter.
83