APEL Fundamentals

  • APEL Scripts are ASCII Text files with a .APEL extension.
  • The language is NOT case sensitive.
  • Easy to Use and Learn.
  • Libraries available that can easily incorporated into your script.

Comments

A comment begins with a pair of forward slashes (//). Comments are single line only.

Data Types

Two data types are available and the type must be declared when the variable is declared. See the DIM statement. The two types are Integer and String. See the Operators section for details on assignments and comparisons. Comparisons are not allowed between the two types though conversion functions are available. These conversion functions are:

DECV (IntegerValue) Convert an Integer into a String
VALD (StringValue) Convert a String (containing a valid integer value) into an Integer

 

HEX values are stored as a String. Conversion between Integer and HEX Strings can be achieved using

VALH  (StringValue) Convert a HEX String to an Integer
HEXV  (IntegerValue) Convert an Integer value to a HEX String

 

Bus Definitions

A bus allows the definition of a set of Port pins. See the BUS statement. The bus name can be used to assign more than one port pin at the same time. Some Library functions expect bus definitions to operate correctly. BUS statements are useful for assigning multiple bits such as Address and Data buses.

 

PinStrings

When assigning/reading a value to/from a Bus or Port, the string must be in form of a PinString. This means that the variable must be of type String and be made up of the following characters :

 

Character

Function

0

Output Low

1

Output High

L

Input Low

H

Input High

Z

Input TriState

 

The length of the string must match the size of the Bus. Here are some examples

ADDRESSBUS = "0000"   // Assumes that the databus is defined as Length 4
ADDRESSBUS = STRV(0,4)    // Assigning the bus to zero using a built-in function
ADDRESSBUS = STRV(CurrentAddress,4) // Assigning an integer CurrentAddress onto the ADDRESSBUS


There are conversion functions to convert to/from a PinString. These conversion functions are

VALS  (PinString) Convert a PinString to an Integer value
HEXS  (PinString Convert a PinString to a HEX String
STRV (Integer,Num Convert an Integer value to a PinString of length Num
STRH (String,Num) Convert a HEX String to a PinString of length Num

 
Assignments and Equality

The equal sign (=) is used in APEL statements to assign values to variables: it is the assignment operator. The left hand operand of the = operator is defined as the target. Examples of targets are: 

  • variables,
  • array elements,
  • Bus' Port Pins

The right operand of the = operator is always an Expression. Expressions can be an arbitrary value of any type. Complex expressions can be up to four levels deep and can contains built-in function calls (i.e. STRV, HEXV etc).

 

value = (count * 3) * (DECV(hexstring)+10)

 

If the expression is a function call to an external function (i.e. one defined with FUNCTION... ENDFUNCTION) then the expression cannot be complex i.e.

 

value = READSPI(SPICLK,SPIDATA)

 

Expressions

An APEL expression is a 'phrase' of APEL that the interpreter can evaluate to generate a value.

 

Declaring Variables

The first time a variable appears in your script is its declaration. This first mention of the variable sets it up in memory so you can refer to it later on in your script. Always declare variables before using them. You do this using the DIM Statement

You cannot initialise your variable in the DIM statement, it automatically takes on the value undefined.  Reading the value of a variable that has not been initialised will cause an error and stop execution of the script.

You cannot use a variable that has never been declared using a DIM statement

 

Naming Variables

A variable name is an identifier. In APEL, identifiers are used to: 

  • name variables and buses
  • name functions

As APEL is NOT a case-sensitive language, a variable name such as myCounter is identical than the variable name MYCounter. Variable names can be of any length. The rules for creating legal variable names are as follows: 

  • The first character must be an ASCII letter (either uppercase or lowercase), or an underscore (_) character. Note that a number cannot be used as the first character.
  • Subsequent characters must be letters, numbers, or underscores.        The variable name must not be a Statement of  Internal Function Name

 

Speed of Execution

Execution speed is limited by the length of the JTAG chain. In order to optimise the speed of a test, put the unused Devices in BYPASS mode. This sets the length of the JTAG chain inside the BYPASSed device to 1.