Scripting is a powerful feature of Antares that allows you to influence the behavior of circuits during simulation in different ways. To do this, you write small scripts, i.e. small pieces of program that are stored in different places in a circuit and that are executed by Antares during simulation.
Enter Scripts
The programming language in which the scripts is a custom DSL (domain specific language) that carefully been tailored to work particularly well with digital signals and accessing ports of circuits.
Since this programming language does not need to be compiled, but is interpreted during execution, the scripts do not need to be created separately and stored in the directory where Antares is installed, but can be stored as pure text within the circuit.
Scripts are entered as properties of selected objects in the properties window.
In the example above, the "Function" property contains a script. This is indicated by the text "[Script]". If there were no script, the text would be empty. If you click in the field, Antares will display a button to open the script editor. In the current version of Antares, the script editor is a simple multi-line text field without any special properties like syntax highlighting or alike.
In this window you write your script as described in the following sections. You can use the button Check to let Antares check your script for syntactic or semantic errors. With the button OK the current script is saved in the property where you opened the script editor.
If you have made a programming error in a script (which can happen), Antares will detect this during simulation - sooner or later depending on the type of script - and pause the simulation. In the "Issues" view, which can be displayed at the bottom of the main window, the color of the icon changes to red, and the table in the view contains a new entry that gives you information about the error that occurred.
The entries in the table have the following properties:
- Name
-
The name or type of the issue. For scripting errors the name "Script Error". There are other types of errors, such as "Design Error", which occurs when your circuit contains wires connecting pins of different bit widths.
- Origin
-
An identification of the object where the error occurred. This can be a subcircuit, a use case, a scenario or in the future any other origin.
It would be desirable if Antares would highlight the source of the problem in the circuit when you select an entry in the table. This feature may be available in a future version of Antares. |
- Context
-
Additional information that further specifies the source of the error. If an object contains multiple scripts, the context is the name of the property of the source whose script contains the error. In the example above, this is the property "Function" of the subcircuit "SR Latch".
- Description
-
Describes the cause of the error. In the example above, in the script on line 6, the statement
if (not S and not R) {
was replaced by the erroneous statementif (not I and not R) {
, which caused the error, because Antares tried to access a signal from port "I", which doesn’t exist in the SR latch.
The content of the table is deleted every time a simulation is started. You can delete the contents of the table yourself at any time using the button in the upper right corner of the view.
Scripting Applications
The different applications of scripting are described in separate chapters.