ModSlaveSim help v3.07 - 5. ModSlaveSim Language

Download manual: HTML

5. ModSlaveSim Language

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:

  • italic represents the syntactic groups that describe the language

  • A colon following a syntactic group indicates the definition (in terms of other groups or terminal symbols) to follow.

  • A | symbol or a newline indicates an alternative syntactic definition.

  • A ? symbol indicates an optional entity.

  • A * symbol after a syntactic group within braces {...}* indicates zero or more of the group.

  • Bold type indicates a terminal symbol (i.e. the symbol used in a program not the description of it). (The bold may not show clearly for all characters in the fonts installed on your system.)

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 : * |  / | %