COMMAND REFERENCE

The following sections list all the commands supported by EasyHDL. For each command there is listed its syntax, purpose and one or more examples of its use. The notation used in the syntax definitions is explained in Explanation of Syntax Layout.

The ABORT Command

Syntax

ABORT idcode_expr

Purpose

The ABORT command provides a means of aborting the current simulation. The execution of this command causes the simulator engine to cause a EasyHDL process run-time error. The error message inserted into the simulation log includes the identification code given in the idcode_expr expression that followed the ABORT keyword.

You should note that ABORT command not only aborts the current EasyHDL invocation but the entire simulation session.

Example

IF input=TRUE THEN PRINT "Input Is TRUE!" : ABORT 0

The ALIAS Command

Syntax

ALIAS new_name=existing_name [[,new_name=existing_name]] [[,etc]]

Purpose

The ALIAS command provides a means of aliasing one variable name with another. Aliasing is particularly useful where the name of the pin on a device uses characters not allowed in a EasyHDL variable name. and therefore it is not possible to directly declare a variable of type PIN or NODE for the generator pin. The new_name is the name you now wish to refer to the variable or external pin or property by, and must obey EasyHDL variable naming rules. The existing_name is the existing variable, property or pin name. Everything up to a comma or the end of the line is taken as part of the existing name, so a name that contains spaces needs no quoting, and a trailing comma introduces the next alias in the same statement. Following the alias declaration, new_name can be regarded as synonym for existing_name and can be used wherever you might have needed to use existing_name.

For example, the 7493 TTL counter has reset pin names that contain brackets, namely R0(1) and R0(2). As you cannot have variable names with brackets within EasyHDL you need to alias the 7493 pin name with your own names, for example RS0 and RS1, and then declare variables of type PIN with these names, as in the following example.

BOOL and PIN Types for further information on using the ALIAS command to declare variables of type PIN.

Like a variable declaration, an ALIAS command must appear before the first executable statement of the script.

Example

ALIAS RS1=R0(1),RS2=R0(2)

...

PIN RS1,RS2 // RS1 is the synonymous with R0(1), etc.

...

IF RS1 AND RS2 THEN ...

The BOUNDSTEP Command

Syntax

BOUNDSTEP (time_expression)

Purpose

The BOUNDSTEP command places an upper bound on the timestep that the SPICE kernel is permitted to take, expressed in seconds. The kernel normally chooses its own timesteps according to what the circuit is doing, which means an analogue script has no guaranteed invocation rate; this command is the way to impose one.

The time expression must be enclosed in parentheses. Once the bound is in force the simulation will not advance by more than the given interval in a single step, although the kernel remains free to take smaller steps where the circuit requires them. The bound takes effect from the point at which the command is executed and may be changed at any time, so a script can tighten it over a region of interest and relax it again afterwards. A value of zero removes the bound altogether.

A tight bound forces the simulator to compute a great many more timepoints and will slow the simulation down, so use no smaller a value than the waveform you are generating actually requires.

Example

REM Guarantee an invocation at least every 10us

ON BOOT

BOUNDSTEP (10u)

ENDON

OUT = AMP * SIN(2*PI*FREQ*REALTIME)

Controlling the Timestep

REALTIME and EVTTIME System Variables

The BREAK Command

Syntax

BREAK

Purpose

The BREAK command causes termination of the current FOR...TO...NEXT, WHILE...WEND, REPEAT...UNTIL loop or the termination of the current case of a MAP ON or SWITCH command, as follows:

  • The execution of the command within a WHILE...WEND loop causes execution to continue with the first command after the WEND keyword.
  • The execution of the command within a REPEAT...UNTIL loop causes execution to continue with the first command after the UNTIL keyword.
  • The execution of the command within a FOR...TO...NEXT loop causes execution to continue with the first command after the NEXT keyword.
  • The execution of the command within a MAP ON...ENDMAP command causes execution to continue with the first command after the ENDMAP keyword.
  • The execution of the command within a SWITCH...ENDSW command causes execution to continue with the first command after the ENDSW keyword.

Example

WHILE pin_enable=TRUE

...

IF EVTTIME > 1 THEN BREAK

...

WEND

The CALLBACK Command

Syntax

CALLBACK [[eventid]] AFTER time_expression

CALLBACK [[eventid]] AT time_expression

Purpose

The CALLBACK command allows a call-back event to be posted; the EasyHDL script is invoked when the event time is reached.

This command also allows an event identification value to be specified; this will be placed in the system variable EVTID when the event is processed and the script invoked. As all system event identification codes are zero or negative, only positive non-zero identification codes should be used in CALLBACK commands. If no identification value is specified, then the EVTID variable will contain the system constant value EI_CALLBACK when the script is invoked.

The event identification expression, if any, is followed by either the keyword AFTER or the keyword AT and then an expression for the time at which the call-back is to take place. The AFTER keyword indicates that the time expression is a delay value to be added to the current event time; the AT keyword indicates that the time expression is the absolute time at which that call-back event is to occur.

A callback happens once. To schedule an event that repeats, use the TIMER command, which is the only command that accepts an EVERY clause.

Event Identification Constants for an explanation of the EVTID system variable and the event identification codes.

The TIMER Command for repeating events.

Example:

IF EVTID = EI_BOOT THEN

REM BOOT Sequence; post call back for 1u.

CALLBACK 2 AT 1u

ELIF EVTID = 2 THEN

REM Process out call-back.

...

ENDIF

The CONTINUE Command

Syntax

CONTINUE

Purpose

The CONTINUE command causes the loop expression of the current WHILE...WEND, REPEAT...UNTIL loop to be re-evaluated or for the loop variable of the current FOR...TO...NEXT loop to be incremented and re-tested against the command's limit expression, as follows:

  • The execution of the command within a WHILE...WEND loop causes execution to continue with the WHILE command.
  • The execution of the command within a REPEAT...UNTIL loop causes execution to continue with the UNTIL command.
  • The execution of the command within a FOR...TO...NEXT loop causes execution to continue as though the NEXT keyword had been reached.

Example:

REPEAT

...

IF EVTTIME <= 100n THEN CONTINUE

...

UNTIL pin_enable=F

The DATA Command

Syntax

DATA constant [[,constant]] [[,etc]]

DATA REPEAT

Purpose

The DATA command specifies one or more constant values that can be read in sequence by the READ command. Typically, the data stored will determine the evolution of the test signal(s) controlled by the script over time. For example, you could define time/voltage pairs in order to define a piecewise linear waveform, or you could store data and address values to be output onto a bus.

The constant values can be any of any valid EASYHDL data type including strings.

The keyword REPEAT causes the data table to be considered as circular, that is that after the last data item has been read, the next READ command will begin again at the start of the table.

DATA REPEAT closes the table, so it must be the last DATA statement in the script. Any further DATA statement after it is a compile error.

String escape sequences are recognised inside a quoted data item, so the \r in the example below stores a carriage return.

Example:

DATA "Hello World ", 250m

DATA "- EASYHDL Test Program\r", 500m

DATA REPEAT

The END Command

Syntax

END

Purpose

The END command causes termination of the current invocation of the EasyHDL script and return of control to the simulator engine. There is no need to end an EasyHDL script with an END command; this is implicit.

Example

IF EVTTIME < 100n THEN END

The FOR...TO...STEP...NEXT Command

Syntax

FOR variable=init_expr'n TO limit_expr'n [[STEP step_expr'n]]

...

NEXT variable

Purpose

The FOR...TO...STEP...NEXT command allows the set of commands between the FOR and NEXT keywords to be executed a given number of times. The variable after the FOR keyword is referred to as the loop variable and must be a previously declared variable of either INT or FLOAT type and must also be specified after the NEXT keyword.

The loop variable is initialised to the value of init_expression, and the commands inside the FOR...NEXT block are then executed. When the NEXT keyword is encountered, the value of the loop variable is incremented by either the value of step_expression if one is specified, or by one. If the new value of the loop variable is less than or equal to the value of the limit_expression, then execution continues with the first command after the FOR keyword, otherwise execution continues with the first command after the NEXT keyword.

The commands within a FOR...NEXT block are always executed at least once, regardless of the values of the init_expression and limit_expression. The loop variable is valid within the FOR...NEXT block and may be manipulated just like any other variable. Note however that it is possible to manipulate the loop variable such that FOR...NEXT loop never terminates. For example:

FOR i=0 TO 10 STEP 2

  i=0

NEXT i

the loop variable (i) is always set to zero; even with its increment by the step value when the NEXT keyword is encountered, the loop variable will never reach the value of 10.

Example

INT v

FOR v=0 TO 10 STEP 2

PRINT v;"*";v;"=";v*v

NEXT v

The GOSUB Command

Syntax

GOSUB label_name

Purpose

The GOSUB command calls a subroutine. Execution transfers to the command following the label named in label_name, and continues there until a RETURN command is executed, at which point execution resumes with the command following the GOSUB. Forward and backward calls are both allowed.

The rules for the label are the same as for GOTO: it must be declared at the start of a line, must consist of alphanumeric and underscore characters, must be followed by a colon and should not be the same as any EasyHDL keyword.

A subroutine is a convenient way of writing out a sequence that the script performs in more than one place, such as a bus write or a reset pulse. Since a script does not declare local variables, a subroutine works on the same variables as the rest of the script.

Example

REM Send two bytes down the bus

d = $A5 : GOSUB SEND_BYTE

d = $5A : GOSUB SEND_BYTE

END

SEND_BYTE:

DATABUS = d

STROBE = 1

SLEEP FOR 100n

STROBE = 0

SLEEP FOR 100n

RETURN

The RETURN Command

The GOTO Command

The GOTO Command

Syntax

GOTO label_name

Purpose

The GOTO allows program execution order to be switched to the next command after the label specified in label_name. A label of the same name as label_name must be declared somewhere within the EasyHDL script; forward and backward jumps are both allowed.

A label must be declared at the start of a line and must consist of no more than 127 alphanumeric and underscore ('_') characters. The label must be followed by a colon and, to avoid ambiguity, the label should not be the same as any EasyHDL keyword. Further commands may follow the label's terminating colon, if desired.

Example

LBL_START: // Declare the label.

PRINT "START OF SCRIPT"

...

IF !done THEN GOTO LBL_START // Jump to PRINT... command.

The IF...ELIF...ELSE...ENDIF Command

Syntax

IF expression [[THEN]]

...

...

[[ELIF expression [[THEN]]

...

...]]

[[ELIF expression [[THEN]]

...

...]]

etc

[[ELSE

...

...]]

ENDIF

IF expression [[THEN]] ... [[ELIF expression [[THEN]] ... ]][[ELSE ... ]][[ENDIF]]

Purpose

The IF...ELIF...ELSE...ENDIF command allows conditional execution of the commands in each of the blocks. There can only be one IF keyword and optionally one ELSE keyword. There may be any number of ELIF keywords between the IF keyword before the ELSE or ENDIF keywords.

The expression following the IF and ELIF keywords are evaluated in succession; if any of the these evaluates non-zero, then the commands following the IF or ELIF keyword and before the next ELIF, ELSE or ENDIF keyword are executed. If none of the IF or ELIF expressions evaluates non-zero, then statements following the ELSE keyword (if any) are executed. Execution then continues with the command after the ENDIF keyword.

ELSEIF and ELSIF are accepted as synonyms for ELIF, so you may use whichever spelling you are used to.

Example

IF i=0 THEN

PRINT "Value is zero"

zero = TRUE

ELSE

PRINT "Value is non-zero"

zero = FALSE

ENDIF

IF i THEN j=0 : WHILE (i>0) j=j*2:i=i-1 : WEND : i=0 ELSE j=-1

The IPROP Command

Syntax

IPROP property_name [[=expression]] [[,property_name [[=expression]]]] [[,etc]]

Purpose

The IPROP command declares an integer property. A property is a value that the script reads from the object it is attached to, so that one script can serve objects that differ only in their parameters. Where the object carries a property of the same name, that value is used; otherwise the optional initialisation expression supplies a default. The property is evaluated once, during the boot invocation, and can then be used in expressions exactly like a variable.

A property declaration must appear before the first executable statement of the script, alongside the variable declarations.

Properties are mainly of use to model authors, since they are the mechanism by which one script models a whole family of devices. A generator script that drives a single design does not usually need them.

Example

IPROP DIVISOR=16

...

count = count + DIVISOR

The NPROP Command

The TPROP Command

The MAP ON...ENDMAP Command

The LET Command

Syntax

LET variable=expression [[,variable=expression]] [[,etc]]

Purpose

The LET command assigns the result of an expression to a variable. Several assignments may be made in one statement by separating them with commas.

The LET keyword is optional and is usually omitted. Any statement whose leading token is not a recognised EasyHDL keyword is treated as an assignment, so the two forms below are equivalent.

Assignments to a variable of type PIN or NODE may carry timing information using the AT, @ and AFTER keywords.

Example

LET j = 1, k = j*2

j = 1, k = j*2 // The same thing

OUT = TRUE AFTER 20n

Assigning To Variables

The MAP ON...ENDMAP Command

Syntax

MAP ON property_name[[+property_name]][[+etc]]

CASE string1 : ...

...

[[BREAK]]

[[CASE string2 : ...

...

[[BREAK]] ]]

[[DEFAULT : ...

...

[[BREAK]] ]]

ENDMAP

Purpose

The MAP ON...ENDMAP command allows a set of commands in one or more of its cases to be executed, the case being selected according to the result of the comparing value of the property named after the MAP ON keyword with each case's label.

Within the MAP ON...ENDMAP block are one or more cases. Each case consists of the either the DEFAULT followed by a colon, or the keyword CASE followed by a case label and a colon. The characters after the CASE keyword and up to either a space, a tab character or the colon are deemed part of the case label, to a maximum of 127 characters. Following the colon are the commands associated with the case.

Several property names may be joined with plus signs after the MAP ON keyword. Their values are then joined with plus signs in the same order to form the selector, and each case label must be written to match that combined string. This is how a script distinguishes between devices that share a value but differ in some other property.

The textual value of property named after the MAP ON keyword is compared against each case label in the order the cases are declared. Case is not sensitive. If a match is found, then execution continues with the first command after the case label; if no match is found, and a DEFAULT case is specified, then execution continues with the first command after the DEFAULT keyword. Execution then continues with all commands up to the ENDMAP keyword; if execution only up to the next case is required, then the last command in the case should be a BREAK command. If no match is found with any case and there is no DEFAULT case, or if a BREAK command is encountered in any case, execution continues with the first command after the ENDMAP keyword.

The MAP ON...ENDMAP is intended for use in initialising a model script according to the state of some device property, most likely its value. To this end, it is only within a MAP ON...ENDMAP block that properties may be assigned, and consequently, the command and the relevant case or cases within it are only executed during the boot invocation of the script; for all other invocations, the command is automatically ignored and there is no need to place it within an IF...ENDIF block.

Example

// Assign timing properties depending on what family

// of device we are modelling.

MAP ON VALUE

   CASE 74259   : TDRQ=16n   : TDLHDQ=14n

  TDHLDQ=11n : TDLHAQ=15n

BREAK

   CASE 74LS259 : TDRQ=12n   : TDLHDQ=19n

TDHLDQ=13n : TDLHAQ=17n

BREAK

ENDMAP

Example

// Select on two properties at once.

MAP ON VALUE+PACKAGE

CASE 74259+DIL16 : TDRQ=16n : BREAK

CASE 74259+SO16 : TDRQ=15n : BREAK

ENDMAP

The IPROP Command for how a property is declared.

The NPROP Command

Syntax

NPROP property_name [[=expression]] [[,property_name [[=expression]]]] [[,etc]]

Purpose

The NPROP command declares a numeric property, that is a property whose value is held as a floating point quantity. It behaves in every other respect like IPROP: the value comes from the object the script is attached to where one is given, and from the optional initialisation expression otherwise, and it is evaluated once during the boot invocation.

A property declaration must appear before the first executable statement of the script, alongside the variable declarations.

Properties are mainly of use to model authors, since they are the mechanism by which one script models a whole family of devices.

Example

NPROP VTHRESH=2.5

...

IF V(IN) > VTHRESH THEN OUT=TRUE

The IPROP Command

The TPROP Command

The ON BOOT ... ENDON Command

Syntax

ON BOOT

...

...

ENDON

Purpose

The ON BOOT command allows a set of commands to be executed just once, at the start of the simulation. It is exactly equivalent to writing:

IF EVTID = EI_BOOT THEN

...

...

ENDIF

Example

ON BOOT

REM BOOT Sequence; post call back for 1u.

CALLBACK AT 1u

ENDON

The ON Command Family

Four conditions may follow the ON keyword:

Condition Executes the block when

ON BOOT

The script is invoked for the boot pass, once at the start of the simulation.

ON CALLBACK

The script is invoked by a callback that was posted without an event identification code, that is when EVTID is EI_CALLBACK.

ON EVENT

The script is invoked by a real event, or by the particular event whose identification code is given.

ON TIMER

The timer declared by the command itself triggers.

Conditions may be combined by separating them with commas, in which case the block is executed if any one of them holds. This is a compact way of writing initialisation that must run both at boot and on every callback:

ON BOOT, CALLBACK

REM Runs at startup and at each unnumbered callback

ENDON

Every form is closed with ENDON, or by the end of the line if the block is written inline.

The ON EVENT ... ENDON Command

Syntax

ON EVENT [[event_id]]

...

...

ENDON

Purpose

The ON EVENT command allows a set of commands to be executed whenever a particular event occurs. It is exactly equivalent to

IF EVTID = event_id THEN

...

...

ENDIF

If event_id is not specified then the block is executed whenever the invocation is the result of a real event, which is to say on any invocation that is not a settle pass or an ordinary analogue timepoint.

Any code inside an ON EVENT block will not be executed during an ordinary analogue timepoint.

Example

ON TIMER AT PERIOD EVERY PERIOD

   RESTORE

   OFFSET=EVTTIME

ENDON

ON EVENT

READ t,v

IF t > 0

  t = t + OFFSET

  OUT=v AT t

  CALLBACK AT t

ENDIF

ENDON

The ON EVENT clause is executed at startup (EI_BOOT), every TIMER period, and also at each callback (EI_CALLBACK).

The ON TIMER ... ENDON Command

Syntax

ON TIMER event_id AFTER delay_expr

...

...

ENDON

ON TIMER event_id AT time_expr [[EVERY period_expr]]

...

...

ENDON

Purpose

The ON TIMER command sets up a timer and then allows a set of commands to be executed whenever it is triggered. It is exactly equivalent to

TIMER event_id AT time_expr EVERY period_expr

IF EVTID = event_id

...

...

ENDIF

If event_id is not specified then a unique id is allocated automatically.

As with the TIMER command, an ON TIMER command cannot be retriggered once an event has been scheduled, and it counts towards the limit of 32 timers per script.

Example

ON TIMER AT PERIOD EVERY PERIOD

   OFFSET=EVTTIME

   SLOPE=1

ENDON

The PAUSE Command

Syntax

PAUSE

Purpose

The PAUSE command suspends the simulation at the point at which it is executed and writes a message of the form EASYHDL script paused at line 12 to the simulation log, naming the line responsible. Execution resumes with the command following the PAUSE when you restart the simulation.

Because it is an ordinary command it can be placed inside a conditional, which makes it the direct way to stop a simulation on a data-dependent condition rather than at a fixed line. It is the script's own counterpart to a breakpoint set in the source window.

The command has no effect during a settle pass or during an ordinary analogue timepoint, for the same reason that breakpoints are not offered there. The rest of the script executes normally in those passes.

Example

REM Stop as soon as the input goes out of range.

IF V(IN) > 5.5 THEN PRINT "Overvoltage: ";V(IN) : PAUSE

Debugging EasyHDL Scripts

The PRINT Command

Syntax

PRINT expression | "text" [[,|; expression | "text"]][[etc]][[,|;]]

Purpose

The PRINT command provides a means to insert text and the values of variables/expressions into the simulation log.

The PRINT keyword is followed by a list of arguments separated by commas or semicolons; each argument can be either an expression or literal text enclosed in double-quotes. Each argument is inserted in the simulation log in order from left to right; arguments separated by a comma will be inserted in to the log separated by a single space, arguments separated by a semicolon will be inserted in to the log directly after the previous argument. If the PRINT command's argument list ends with an argument, then a new line (a carriage-return and linefeed) is inserted in to the log after the last argument; if the list ends in a comma or semicolon separator then no new line is inserted and any output from subsequent PRINT commands will follow the last argument output, on the same line.

How a value is rendered depends on its type:

Type Printed as

INT

A decimal integer.

FLOAT, NODE

A number in engineering notation, to eight significant figures.

TIME

A number of seconds in the shorter of fixed or exponential form.

PIN, BOOL

A single character, T if the pin is active and F if it is inactive. An asterisk follows the character where the pin has just changed state, so TT prints as T, FF prints as F, FT prints as T* and TF prints as F*.

STRING

The characters of the string, with any escape sequences already resolved.

Example

PRINT var1;"+";var2;"=";var1+var2;".";

Diagnostics for how to view the simulation log.

The READ Command

Syntax

READ var1 [[,var2]] [[,etc]]

READ pin_var AT|@ time_expression

READ pin_var AFTER time_expression[[,time_expression]]

Purpose

The READ command retrieves the next item or items from the constant values declared in any DATA statements within the program and stores them in the specified variables.

Where the variable being read into is of type PIN or NODE, the same timing keywords that are available on an assignment may follow it, so that the value read from the data table is applied to the pin at or after a given time rather than immediately. As with an assignment, two times may be given after AFTER, the first for a low to high transition and the second for a high to low transition.

Example

REM Define data to be output

DATA "Hello World", 250m

REM Read the data

READ s,td

The REM Command

Syntax

REM text

Purpose

The REM (remark) command allows comments and information to be included within a EasyHDL script. All text after the REM keyword is ignored by the EasyHDL Compiler.

Note that, as all text after the REM keyword is ignored, the REM command should be placed at the end of a colon-separated sequence of commands.

Note also that you can also indicate a comment with a double forward-stroke ('//'); this has advantage that, not being a keyword, it does not require a colon in front of it. As for a REM everything after the second stroke is ignored by the EasyHDL compiler.

Example

REM This is a comment, and will be ignored.

REM So is this.

PRINT "A=",a // Display the value of A

The REPEAT...UNTIL Command

Syntax

REPEAT

...

...

UNTIL expression

Purpose

The REPEAT...UNTIL command allows the commands between the REPEAT and UNTIL keywords to be repeatedly executed until the loop expression following the UNTIL keyword evaluates as non-zero.

The commands between the REPEAT and UNTIL keyword are executed. When the UNTIL keyword is reached, the loop expression following it is evaluated; if the result is non-zero, execution continues with the first command after the UNTIL keyword, otherwise execution continues with the first command after the REPEAT keyword.

Note that, as the loop expression is tested at the end of the loop, the commands between the REPEAT and UNTIL keywords are always executed at least once.

Example:

REPEAT

WAIT

count=count+1

UNTIL enable_pin=TRUE

The RESTORE Command

Syntax

RESTORE

Purpose

The RESTORE command resets the data pointer used by the READ command such that it points to the first DATA statement in the program. This allows the data to be read again.

Example:

// Define data to be output

DATA "Hello World", 250m

// Read the data

READ s,td

// Read the data again

RESTORE

READ s,td

The RETURN Command

Syntax

RETURN

Purpose

The RETURN command ends a subroutine that was entered with GOSUB. Execution continues with the command following the GOSUB that called the subroutine.

Since a subroutine is reached only by GOSUB, place the subroutine bodies after an END command or otherwise out of the path of ordinary execution, so that the script does not fall into them.

Example

GOSUB PULSE

END

PULSE:

OUT = 1 : SLEEP FOR 1u

OUT = 0

RETURN

The GOSUB Command

The SEED Command

Syntax

SEED (value)

Purpose

The SEED command is used to seed the script's random number generator. The value expression must be enclosed in parentheses.

The sequence of values returned by subsequent reads of the RANDOM system variable appears random but is in fact determined entirely by the seed. For a given seed value the same sequence is produced on every run, so a test that uses randomness can be repeated exactly and a failure can be reproduced. Where no SEED command is executed the sequence differs from one run to the next.

Seeding at the start of the script is therefore the usual practice; seed again part way through only if you want a later section to restart from a known point.

RANDOM System Variable for an explanation of the RANDOM system variable.

Example

SEED (500)

FOR i=1 TO 10

   PRINT "Random Value",i,"=",RANDOM

NEXT I

The SLEEP Command

Syntax

SLEEP [[eventid]] FOR time_expression

SLEEP [[eventid]] UNTIL time_expression

Purpose

The SLEEP command causes the current invocation of a digital script to be suspended either for a fixed delay or until a set time. When the end time is reached execution continues with the first command after the SLEEP command.

The SLEEP command allows an event identification value to be specified. The value of this expression determines whether the script's suspension can be interrupted by other events, such as a previously declared call-back event becoming due, or a change occurring in one or more of the nets to which input pins are connected. The event identification expression, if specified, should be either a unique positive non-zero integer or one of the system constants: EI_ANY, EI_INPUT, or EI_CALLBACK. Using either a unique integer or the EI_CALLBACK constant guarantees that the suspension will not be interrupted; EI_ANY or EI_INPUT allows the suspension to be interrupted by either any event or by changes on input pin nets. When the suspension is complete, the EVTID variable will contain the value for the event identification specified. The default identification value, if no expression is given, is EI_CALLBACK.

The event identification expression, if any, is followed by either the keyword FOR or the keyword UNTIL and then an expression for the time at which the suspension is to end. The FOR keyword indicates that the time expression is a delay value to be added to the current event time; the UNTIL keyword indicates that the time expression is the absolute time at which that suspension is to end.

The SLEEP command cannot be used in an analogue generator script, where it produces a run-time error.

SUSPEND is accepted as a synonym for SLEEP. It is retained only so that older scripts continue to compile, and SLEEP should be used in new work.

Event Identification Constants for an explanation of the EVTID system variable and the event identification codes.

Example

PIN output

...

// Generate 100 periods of mark=20n, space=10n clock

FOR i=0 TO 100

output = TRUE // Output active

SLEEP 1 FOR 20n // Wait 20ns (mark time)

output = FALSE // Output inactive

SLEEP 1 FOR 10n // Wait 10ns (space time)

NEXT i

...

The SWITCH...ENDSW Command

Syntax

SWITCH switch_expression

CASE value1 : ...

  ...

[[BREAK]]

[[CASE value2 : ...

...

[[BREAK]] ]]

[[DEFAULT : ...

...

[[BREAK]] ]]

ENDSW

Purpose

The SWITCH...ENDSW command allows a set of commands in one or more of its cases to be executed, the case being selected according to the result of the evaluating switch expression.

Within the SWITCH...ENDSW block are one or more cases. Each case consists of either the keyword CASE followed by a fixed integer value and a colon, or the keyword DEFAULT followed by a colon. Following the colon are the commands associated with the case.

Case values are integers. A value may be written in decimal, in hexadecimal with a leading dollar character or in binary with a leading percent character, but it must have no fractional part and must lie within the range of the INT type; anything else is a compile error. Two cases may not carry the same value.

The switch expression which follows the SWITCH keyword is evaluated as an integer value and is compared against each case value in the order they are declared. If a match is found, then execution continues with the first command after the CASE value; if no match is found, and a DEFAULT case is specified, then execution continues with the first command after the DEFAULT keyword. Execution then continues with all commands up to the ENDSW keyword; if execution only up to the next case is required, then the last command in the case should be a BREAK command. If no match is found with any case and there is no DEFAULT case, or if a BREAK command is encountered in any case, execution continues with the first command after the ENDSW keyword.

Example

SWITCH bus[0..2]

CASE $04 : PRINT "Bus is 4" : BREAK

CASE %101 : PRINT "Bus is 5" : BREAK

ENDSW

SWITCH bus[0..2]

CASE 0 : REM Fall through to next case...

CASE 1 : REM Fall through to next case...

CASE 2 : PRINT "Bus is 0,1,or 2" : BREAK

DEFAULT : PRINT "Unknown bus value!" : BREAK

ENDSW

The TIMER Command

Syntax

TIMER [[event_id]] AFTER delay_expr

TIMER [[event_id]] AT time_expr [[EVERY period_expr]]

Purpose

The TIMER command allows for the scheduling of events in a fashion similar to the CALLBACK command. However, it is different in that a timer can only be re-triggered when any previously scheduled event has occurred. In other words, once a TIMER statement has been executed and has posted an event, subsequent executions of it will do nothing until the time of that event has been reached.

The EVERY keyword makes the timer repeat at the given interval, and is the only way to schedule a repeating event. The CALLBACK command does not accept it.

A script may declare at most 32 timers. Each TIMER statement and each ON TIMER block counts as one, whether or not it is ever executed, and the thirty-third is a compile error.

Example

PIN OUT = 0

TIMER 1 AT PERIOD EVERY PERIOD

OUT = !OUT

The TPROP Command

Syntax

TPROP property_name [[=expression]] [[,property_name [[=expression]]]] [[,etc]]

Purpose

The TPROP command declares a timing property. It behaves like NPROP, with one addition: the resulting value is multiplied by the simulator's TDSCALE control property, so that every propagation delay declared this way scales together when the design's timing is scaled.

Use TPROP for any property that expresses a delay, and NPROP for one that does not.

A property declaration must appear before the first executable statement of the script, alongside the variable declarations.

Properties are mainly of use to model authors, since they are the mechanism by which one script models a whole family of devices.

Example

TPROP TDLH=14n, TDHL=11n

...

Q = D AFTER TDLH,TDHL

The IPROP Command

The NPROP Command

TDSCALE System Variable

The WAIT Command

Syntax

WAIT [[eventid]]

Purpose

The WAIT command causes the current invocation of the script to be suspended pending a new event. When and if this event occurs, execution continues with the first command after the WAIT command.

The command can optionally be followed by an expression for the event identification value to be waited for; if such a value is specified, then the script will only resume when an event of the expression value becomes due. If no event identification value is specified, then a default value equal to the system constant EI_ANY is used, and the script will resume on any event becoming due.

The WAIT command cannot be used in an analogue generator script, where it produces a run-time error.

Event Identification Constants for an explanation of event identification codes.

Example

REM Post call-back, and then wait for it and only it - input

REM pin transitions are ignored.

CALLBACK 2 AFTER 100n

WAIT 2

...

REM Post call-back; wait for it or an input pin transition

CALLBACK 3 AFTER 200n

WHILE EVTID != 3 AND EVTID != EI_INPUT WAIT

The WHILE...WEND Command

Syntax

WHILE expression

...

...

WEND

WHILE expression ... [[WEND]]

Purpose

The WHILE...WEND command allows the commands between the WHILE and WEND keywords to be repeatedly executed whilst the loop expression following the WHILE keyword evaluates non-zero.

The loop expression following the WHILE keyword is evaluated and if the result is zero, execution continues with the first command after the WEND keyword. Otherwise, the commands between the WHILE and WEND keywords are executed; when the WEND keyword is encountered, execution returns to the WHILE command and the re-evaluation of the loop expression.

Note that, as the loop expression is evaluated at the start of the loop, the commands between the WHILE and WEND keywords may not be executed at all if the expression evaluates as zero the first time it is tested.

Example

WHILE i<j

PRINT "i is less than j"

i=i+2:j=j+1

WEND

WHILE enable_pin=F WAIT

See Also:

Explanation of Syntax Layout

Program Structure

Variables

Expressions

System Constants and Variables