5. ModSlaveSim Language

5.1. Lexical Structure
5.2. Phrase Structure
5.3. Syntax Summary
5.3.1. Tokens
5.3.2. Keywords
5.3.3. Identifiers
5.3.4. Constants
5.3.5. Operators
5.3.6. Expressions
5.3.7. Statements
5.4. Pre-defined Variables
5.5. Values

The ModSlaveSim language is used to create a statement for a register, and this is used by ModSlaveSim to calculate the value of a register.

When running the slave simulation (the Run Slave Simulation button on the toolbar is highlighted), the values of registers are calculated periodically. The 'period' is the value of Run Interval, which can be changed (see section Edit Run Interval for how to enter a new time for Run Interval).

A statement may be entered when first adding a register via the SettingsEdit Settings... dialog (section Add Register). Once the register is added, it can be edited from the panel described in the section Edit Register Statement. (The latter panel can also be accessed by clicking the checkbox of the Statement column of the slave register in ModSlaveSim's main window.)

Initially, you might prefer to look at some examples of the language use in a simulation by going to the section of that name Programming Simulations.

The ModSlaveSim language for entering Statements is a small subset of a normal programming language. A summary of the syntax is provided in Syntax Summary. The first section, Lexical Structure, describes the symbols used and how they are combined to form fundamental units. In the Phrase Structure section, larger components of the language are described.

In the description of the language, the notation is as follows:

In the following illustration of the notation, the unary_sign is optional; the term_expr is obligatory, and there may be zero or more {binary_sign term_expr} expressions. The { and } here indicate the group to which the '*' applies.

numeric_expr :
        unary_sign? term_expr {binary_sign term_expr}* 
      

In this illustration of the notation, the identifier, constant, CycleTime,TimeNow, and left_parenth numeric_expr right_parenth are all alternative definitions of a primary_expr. Note the bold type of the terminal symbols CycleTime and TimeNow.

primary_expr:
        identifier 
        constant 
        CycleTime
        TimeNow
        left_parenth bitwise_expr right_parenth
      

The following shows the use of the | symbol (rather than a new line) to separate the alternative terminal symbols * / % :

multiplier : * |  / | %