SYSTEM CONSTANTS AND VARIABLES
A system constant is a constant value defined by EasyHDL for the purpose of providing portability of scripts; system constants are fixed for a particular release of the simulator engine and never change value from one invocation of the script to another. A system variable is a read-only variable that returns some value particular to the current simulation run and the current invocation of the script; system variables may thus change from one invocation to another. The system constants are defined as follows:
Numeric Constants
The following numeric constants are defined:
PI (pi), which has the value 3.141592654...
Event Identification Constants
The constants EI_ANY, EI_BOOT, EI_SETTLE, EI_INPUT, EI_OUTPUT and EI_CALLBACK are provided for testing the system variable EVTID in order to determine whether the current invocation of the script is the result of a system event or of an undefined user event, and for use in the SLEEP and WAIT commands.
When a script is invoked, the event identification that caused the invocation is placed in the system variable EVTID. The EI_INPUT value indicates that the invocation is the result of a change in the state of a net to which one of the pins of the device the script is modelling. The EI_OUTPUT value indicates a change on an output pin. The EI_CALLBACK value indicates that the invocation is the result of a user-defined call-back event that was initialised without a user supplied event identification code.
The SLEEP Command for information on the SLEEP command.
The WAIT Command for information on the WAIT command.
The ON EVENT ... ENDON Command for the block form of the same test.
Net State Constants
The constants SHI, SLO, FLT, WLO, WHI are provided for assignment to variables of type PIN in order to directly drive the net to which the corresponding device pin or generator is connected.
BOOL and PIN Types for information on using these constants.
PIN And BOOL Pin Activity Constants
The pin activity states FALSE, INACTIVE, FF, TRUE, ACTIVE, TT, FT, POSEDGE, TF and NEGEDGE are provided for testing against variables of type PIN in order to obtain information on the current and previous pin activity.
BOOL and PIN Types for information on using these constants.
TDSCALE System Variable
The TDSCALE variable returns the current value of the simulator engine's TDSCALE Simulator Control Property which provides a scaling value for timing properties. If the TDSCALE property was initialised to produce random time-scaling values, then the TDSCALE variable returns a new random time-scaling value each time it is read.
RANDOM System Variable
The RANDOM variable returns the next random number from the script's random number generator. The random number returned is in the range 1 to 32768, that is 215.
Whilst the sequence of numbers generated by the generator appears to be random, the sequence itself is determinate and is set by the generator's seed value. You can seed the generator at any point in the script by using the SEED command. For a given seed value the sequence of numbers returned by subsequent reads of the RANDOM variable is guaranteed to be the same on every run, so seeded randomness is repeatable. Without a SEED command the sequence differs from one run to the next.
The SEED Command for information on using the SEED command to seed the script's random number generator.
REALTIME and EVTTIME System Variables
The REALTIME variable returns the current value of time in the analogue simulation as a value of type FLOAT. This contrasts with EVTTIME which returns the time of the current event in the digital simulation as a value of type TIME. Event times are quantised with a resolution of 1ps.
How often REALTIME advances is decided by the SPICE kernel, which chooses its own timesteps according to what the circuit is doing. The BOUNDSTEP command is the only way for a script to constrain this, by placing an upper bound on the timestep the kernel is allowed to take.
See Also: