Many Simics commands will look up files based on the current directory. When Simics is launched from the command line, the current directory is the current directory of the shell Simics was launched from. When Simics is launched by double clicking its icon, the current directory is the project directory. This may be impractical when writing scripts or building new configurations, so Simics provides two features to ease directory handling:
%simics%
For example, %simics%/scripts/foo.simics
could be translated to:
C:\Program
Files\Simics\Simics 6\Simics
6.0.1\scripts\foo.simics
/opt/simics/simics-6/simics-6.0.1/scripts/foo.simics
Note that if you change the version of Simics,
%simics%
will change as well, so you should use it to refer only
to files that you know are present in all Simics versions. Notice also that
%simics%
has no meaning if no file can be found. You can use the
command lookup-file to find out how the path will be
translated.
%script%
For example, if the directory baz
contains the scripts
foo.simics
bar.simics
foo.simics
to call bar.simics
by issuing the command:
run-command-file %script%/bar.simics
%simics%
and %script%
are always translated to
absolute paths, so they never interact with the next feature, called
Simics's search path. One consequence is that they must
always be used in double
quotes "%simics%/targets/qsp-x86/images"
to ensure
that escaped characters such as spaces are used correctly.
C:\Users\joe\scripts\
C:\Users\joe\project\
simics> run-command-file test/start-test.simics
is issued, Simics will look for the following files to run:
C:\Users\joe\project\test\start-test.simics
C:\Users\joe\scripts\test\start-test.simics
/home/joe/scripts/
and that the current directory is
/home/joe/project
. If the command:
simics> run-command-file test/start-test.simics
is issued, Simics will look for the following files to run:
/home/joe/project/test/start-test.simics
/home/joe/scripts/test/start-test.simics
Simics's search path can be manipulated using the add-directory, clear-directories and list-directories commands. Simics's search path is also used when looking for image files belonging to checkpoints or new configurations. This is described in section Image Search Path.
Remember that setting a CLI variable to a path with %simics% or %script% does not in itself evaluate the path marker. This means that the path marker may evaluate to another directory than is anticipated. The following two lines evaluate quite differently:
$just_a_string = "%script%/images/my_image" $absolute_path = (lookup-file "%script%/images/my_image")
The first CLI variable reads the given text and may evaluate to wherever.
The second variable is evaluated locally and reads the absolute path for the
my_image
file that is located nearby the script.
sim
object in
checkpoints, allowing image files that were found through it to be opened again
by the checkpoint, it is not available until the object creation phase. Module
initialization code should not rely on the Simics path since that code is run
before the sim
object from the checkpoint has been created.