Standard Test and ProgrammingLanguage (STAPL)
JESD71
August 1999
ELECTRONIC INDUSTRIES ALLIANCEJEDEC Solid State Technology Association
NOTICE
EIA/JEDEC standards and publications contain material that has been prepared, reviewed, andapproved through the JEDEC Board of Directors level and subsequently reviewed and approved bythe EIA General Counsel.
EIA/JEDEC standards and publications are designed to serve the public interest througheliminating misunderstandings between manufacturers and purchasers, facilitatinginterchangeability and improvement of products, and assisting the purchaser in selecting andobtaining with minimum delay the proper product for use by those other than JEDEC members,whether the standard is to be used either domestically or internationally.
EIA/JEDEC standards and publications are adopted without regard to whether or not theiradoption may involve patents or articles, materials, or processes. By such action JEDEC does notassume any liability to any patent owner, nor does it assume any obligation whatever to partiesadopting the EIA/JEDEC standards or publications.
The information included in EIA/JEDEC standards and publications represents a sound approachto product specification and application, principally from the solid state device manufacturerviewpoint. Within the JEDEC organization there are procedures whereby an EIA/JEDEC standardor publication may be further processed and ultimately become an ANSI/EIA standard.
No claims to be in conformance with this standard may be made unless all requirements stated inthe standard are met.
Inquiries, comments, and suggestions relative to the content of this EIA/JEDEC standard orpublication should be addressed to JEDEC Solid State Technology Association, 2500 WilsonBoulevard, Arlington, VA 22201-3834, (703)907-7560/7559 or www.jedec.org
Published by
©ELECTRONIC INDUSTRIES ALLIANCE 1999
Engineering Department2500 Wilson BoulevardArlington, VA 22201-3834
This document may be downloaded free of charge, however EIA retains thecopyright on this material. By downloading this file the individual agrees not to
charge or resell the resulting material.PRICE: Please refer to the current
Catalog of JEDEC Engineering Standards and Publications or call Global Engineering
Documents, USA and Canada (1-800-854-7179), International (303-397-7956)
Printed in the U.S.A.All rights reserved
PLEASE!DON”T VIOLATE
THELAW!
This document is copyrighted by the Electronic Industries Alliance and may not be
reproduced without permission.Organizations may obtain permission to reproduce a limited number of copies
through entering into a license agreement. For information, contact:
JEDEC Solid State Technology Association
2500 Wilson BoulevardArlington, Virginia 22201-3834
or call (703) 907-7559
JEDEC Standard No. 71
Page i
STANDARD TEST AND PROGRAMMING LANGUAGE (STAPL)
(From JEDEC Board Ballot JCB-99-23, formulated under the cognizance of the JC-42.1 Committee on Programmable Logic Devices (PLD).)
CONTENTS
1. Introduction......................................................................................................................................................................................12. Language Overview.........................................................................................................................................................................1
2.1 Description............................................................................................................................................................................12.2 Overall Structure...................................................................................................................................................................12.4 Program Flow........................................................................................................................................................................22.5 Data Management.................................................................................................................................................................22.6 Input & Output......................................................................................................................................................................23. Creating & Interpreting STAPL files...............................................................................................................................................3
3.1 Overview................................................................................................................................................................................33.2 The STAPL Composer...........................................................................................................................................................33.3 The STAPL Player.................................................................................................................................................................44. Statements........................................................................................................................................................................................6
4.1 Overview...............................................................................................................................................................................64.2 Labels (Optional)..................................................................................................................................................................64.3 Instructions............................................................................................................................................................................64.4 Comments.............................................................................................................................................................................75. Program Flow..................................................................................................................................................................................8
5.1 Overview...............................................................................................................................................................................85.2 The Stack..............................................................................................................................................................................85.3 ACTION...............................................................................................................................................................................85.4 CALL....................................................................................................................................................................................85.5 GOTO...................................................................................................................................................................................85.6 FOR Loops............................................................................................................................................................................85.7 Recursion..............................................................................................................................................................................96. Data Management............................................................................................................................................................................9
6.1 Identifier Names....................................................................................................................................................................96.2 Types.....................................................................................................................................................................................96.3 Initialization..........................................................................................................................................................................96.4 Literal Values......................................................................................................................................................................106.5 Constants.............................................................................................................................................................................106.6 Advanced Compression Algorithm (ACA)........................................................................................................................107. Expressions & Operators...............................................................................................................................................................15
7.1 Expressions.........................................................................................................................................................................157.2 Integer & Boolean Operations............................................................................................................................................157.3 Array Operations.................................................................................................................................................................177.4 String Operations................................................................................................................................................................178. STAPL Statement Specifications...................................................................................................................................................18
8.1 Overview..............................................................................................................................................................................188.2 ACTION..............................................................................................................................................................................188.3 Assignment..........................................................................................................................................................................198.4 BOOLEAN..........................................................................................................................................................................19
JEDEC Standard No. 71Page ii
8.5 CALL...................................................................................................................................................................................208.6 CRC.....................................................................................................................................................................................208.7 DATA..................................................................................................................................................................................208.8 DRSCAN.............................................................................................................................................................................218.9 DRSTOP..............................................................................................................................................................................218.10 ENDDATA........................................................................................................................................................................218.11 ENDPROC.........................................................................................................................................................................228.12 EXIT..................................................................................................................................................................................228.13 EXPORT............................................................................................................................................................................228.14 FOR....................................................................................................................................................................................228.15 GOTO................................................................................................................................................................................238.16 IF........................................................................................................................................................................................238.17 INTEGER..........................................................................................................................................................................248.18 IRSCAN.............................................................................................................................................................................248.19 IRSTOP..............................................................................................................................................................................258.20 NEXT.................................................................................................................................................................................258.21 NOTE.................................................................................................................................................................................258.22 POP....................................................................................................................................................................................258.23 POSTDR............................................................................................................................................................................268.24 POSTIR..............................................................................................................................................................................268.25 PREDR..............................................................................................................................................................................268.26 PREIR................................................................................................................................................................................278.27 PRINT................................................................................................................................................................................278.28 PROCEDURE....................................................................................................................................................................278.29 PUSH.................................................................................................................................................................................288.30 STATE...............................................................................................................................................................................288.31 TRST..................................................................................................................................................................................298.32 WAIT.................................................................................................................................................................................299. STAPL Extension Specifications...................................................................................................................................................30
9.1 Overview.............................................................................................................................................................................309.2 VMAP.................................................................................................................................................................................309.3 VECTOR.............................................................................................................................................................................319.4 FREQUENCY.....................................................................................................................................................................3210. Structural Requirements..............................................................................................................................................................33
10.1 Overview............................................................................................................................................................................3310.2 Reserved Key Strings for NOTE Fields............................................................................................................................3310.3 Reserved Identifiers for ACTIONs....................................................................................................................................3510.4 Reserved Identifiers for PROCEDURE Blocks.................................................................................................................3510.5 Reserved Key Strings for EXPORT Strings......................................................................................................................3610.6 EXIT Codes.......................................................................................................................................................................36 ANNEX A EXAMPLES..................................................................................................................................................................38 ANNEX B CALCULATING THE CRC FOR A STAPL FILE......................................................................................................41
JEDEC Standard No. 71
Page 1
1. INTRODUCTION
The Standard Test And Programming Language (STAPL) is designed to support the programming of programmable devices and testing of electronic systems, using the IEEE Standard 1149.1: “Standard Test Access Port and Boundary Scan Architecture” (commonly referred to as JTAG) interface. As a STAPL file is executed, signals are produced on the IEEE 1149.1 interface, as described in the STAPL file. STAPL operates on a single IEEE 1149.1 chain. STAPL supports the programming of any IEEE 1149.1-compliant programmable device.
STAPL has support for programming and test systems with user interface features. A single STAPL file may perform several different functions, such as programming, verifying, and erasing a programmable device. The STAPL file makes these different high-level functions available through ACTION statements that correspond to user controls in an interactive system. STAPL also supports systems that have no user interface features, such as embedded systems. STAPL files may be “filtered” to remove
unneeded ACTION statements and their associated procedure code, reducing the size of the file. This is advantageous for systems that have strict memory requirements.
STAPL may be implemented as either an interpreted or a compiled language. An interpreted implementation means that the STAPL file statements are executed directly by an interpreter program, without first being compiled into binary executable code. A compiled implementation means that the STAPL file is first pre-processed and then executed.
STAPL also provides an extended instruction set that allows the STAPL file to drive any parallel vectors to the system. STAPL compliance does not require support of this extension.
2.LANGUAGE OVERVIEW2.1
Description
A STAPL file consists of a sequence of program statements. A STAPL statement consists of a label, which is optional, an instruction, and arguments, and terminates with a semicolon (;). Arguments may be literal constants, variables, or expressions resulting in the desired data type (i.e., Boolean or integer). Each statement usually occupies one line of the STAPL file, but this is not required. Line breaks are not significant to STAPL syntax, except for terminating comments. An apostrophe character (‘) can be used to signify a comment, which is ignored. The language does not specify any limits for line length, statement length, or file size.
2.2Overall Structure
A STAPL file consists of the following elements, in the order shown below:
••••
NOTE statementsACTION statements
PROCEDURE blocks and DATA blocksA CRC statement
A NOTE statement contains text strings for documentation of the contents and features of the STAPL file.
An ACTION statement describes the sequence of steps required to implement a complete operation, such as programming a device. A STAPL file must contain an ACTION statement corresponding to each operation that can be selected by a user. Each ACTION statement specifies a list of PROCEDURE blocks that must be called, in the specified order, to complete the operation. Some of these listed PROCEDURE blocks may be identified as recommended or optional and may be included or excluded as desired by the end user, such as verifying a device after programming.
A PROCEDURE block contains STAPL statements describing computations and other processing, including interactions with IEEE 1149.1-compliant devices. Statements inside a PROCEDURE block may use data variables contained in other DATA blocks, and they may call other PROCEDURE blocks.
JEDEC Standard No. 71Page 2
2.2Overall Structure (cont’d)
A DATA block contains variable declaration statements. A PROCEDURE block that uses this DATA block (referenced via the USES keyword) may contain STAPL statements that use these variables.
The CRC statement contains the cyclic redundancy code of the entire STAPL file that verifies the data integrity of the file.Variable declaration statements must appear inside a PROCEDURE block or a DATA block. NOTE, ACTION, and CRC statements must appear outside all blocks. All other statements may appear only inside a PROCEDURE block. A PROCEDURE or DATA block may not contain another PROCEDURE or DATA block.
2.3Program Flow
A STAPL session is the execution process of a STAPL file. A STAPL session starts with the ACTION statement selected by the user and ends with the completion of that statement. The PROCEDURE blocks listed for that ACTION are called in order. Within each PROCEDURE block, statements are executed from the beginning of the block until the ENDPROC statement is encountered. The CALL statement begins execution of a different PROCEDURE block, and the GOTO statement causes execution to branch to another statement within the same PROCEDURE block. To call a PROCEDURE block, the PROCEDURE block containing the CALL statement must be linked to the called block by the USES keyword in the PROCEDURE statement.
No facility exists within a STAPL file for linking multiple STAPL files together, or for including the contents of another file into a STAPL file.
2.4Data Management
All variables in a STAPL file must be declared in order to be used. Variables declared inside a PROCEDURE block are only available inside that block. Variables declared inside a DATA block are available in and shared by any PROCEDURE block that uses that DATA block. STAPL files have variables of two types: integer and Boolean. Integers are 32-bit signed numbers. Boolean variables can be considered to be single-bit unsigned integers, although they cannot be used interchangeably with integer variables. One-dimensional Boolean or integer arrays can be declared. These arrays are indexed to give access to a single element or a range of elements inside the array. Multi-dimensional arrays are not supported.
STAPL does not support string variables. However, string constants and string representations of Boolean and integer values can be used to form text output messages. A complete set of arithmetic, logical, and relational operators is available for integers, and a complete set of logical operators is provided for Boolean expressions. No operators are provided to work directly on integer arrays or Boolean arrays. For strings, concatenation is available to permit the construction of simple messages.
STAPL is not case sensitive. All labels, variable names, instruction names, and other language elements are processed without regard to case. (The only exception is the encoded format used for compressed Boolean array initialization data, which is described in “Data Management” on page 9.) In this document, STAPL file examples use uppercase instruction and keyword names and lowercase label and variable names, but the language does not require this convention. For string constants in PRINT statements, the case is preserved when printing the string.Go to Annex A on page 38 for a sample STAPL file.
2.5Input & Output
The only input and output mechanisms supported in STAPL are the IEEE 1149.1 hardware interface, parallel vector hardware interface, user-specified action and optional procedure, the PRINT statement for debugging messages, and the EXPORT statement for sending data values to the calling program.
The EXPORT statement transmits information from the STAPL file to the calling program using a callback function. The EXPORT statement can be used to relay the current execution status, or to pass other information. The information transmitted by the EXPORT statement consists of a key string and an integer value. The significance of the integer value depends on the key string. See Table 13 on page 33 for a list of defined key strings. STAPL does not provide access to any other input or output files or devices.
JEDEC Standard No. 71
Page 3
3.CREATING & INTERPRETING STAPL FILES3.1
Overview
The STAPL Composer and the STAPL Player are software programs that write and interpret STAPL files. Figure 1 shows how the STAPL Composer writes STAPL files, and the STAPL Player interprets STAPL files.
Optional Player FeatureOptional PlayerFeatureSTAPL Translator.jed orotherData File.jed orotherData FileSTAPLFileVendorProgrammingAlgorithmSTAPLComposer(Writer)STAPLFileSTAPL PlayerTDITMSTCKTDOChainInformationOptional Player FeatureSTAPLReferenceAlgorithmOptional PlayerFeatureTDITMSTCKTDOChain of Deviceswith IEEE 1149.1PortTDITMSTCKTDOFigure 1 - Flow of STAPL Composer and Player
3.2The STAPL Composer
The STAPL Composer generates the STAPL files in accordance with this specification. The STAPL Composer may be implemented as a stand-alone utility or as part of an integrated software tool.
The only required feature of the STAPL Composer is to create a STAPL file compliant with this language specification. The required contents of a STAPL file are:
••••
All mandatory NOTE fields
One or more ACTION statements
One or more PROCEDURE or DATA blocksOne CRC statement
JEDEC Standard No. 71Page 4
3.2 The STAPL composer (cont’d)
The STAPL Composer may create STAPL files with many different types of information. STAPL files may contain any or all of the following:
••••••
Design data (single device or chain of devices)ISP programming algorithm informationIEEE 1149.1 chain configurationTest vectors
Any IEEE 1149.1-based instructions
Parallel vectors via VECTOR/VMAP extended instructions
For example, a STAPL Composer for device programming may create STAPL files whose contents vary based on the platform for which the STAPL file is targeted. A STAPL file created for programming a device via an embedded processor may contain design data for the devices in the chain, programming algorithms for each device, and information on the chain configuration. A STAPL file for use on a standard socket-based programmer may contain design data and programming algorithms. A STAPL file created for programming with an IEEE 1149.1-based tester may contain design data and programming algorithms and test algorithms; chain information would then be specified in the STAPL Player on these testers.
3.3The STAPL Player
STAPL supports implementations in either an interpreted or a compiled mode. In an interpreted implementation, the STAPL file statements are executed directly without first compiling these statements into binary executable code. The interpreter program that reads and executes a STAPL file is called the STAPL Player. In a compiled implementation, the STAPL file statements are first pre-processed and then executed.
The mechanism by which the STAPL Player reads the contents of the STAPL file is platform-dependent—it may use a file system, or it may simply read characters from a memory buffer. The STAPL Player has access to the IEEE 1149.1 signals that are used for all instructions based on the IEEE 1149.1 interface. When executing a STAPL file that requires the use of the VECTOR and VMAP instructions, the STAPL Player may also need access to several other signal pins. The hardware access to the IEEE 1149.1 and other signal pins is platform dependent. The mapping of pin names to hardware channels may be read from a wiring file or it may be built directly into the STAPL Player.
Executing STAPL statements based on the IEEE 1149.1 interface requires information on the location of the target device(s) along the serial chain. The method for conveying this chain information is platform-dependent—it may be specified via a user interface, in the STAPL file using the POSTDR, POSTIR, PREDR, and PREIR instructions, or read from a chain file. When a file is used to store this chain information, the STAPL Player must support chain files as specified in the EIA/JEDEC Standard: “Standard for Chain Description File (EIA/JESD32)”.
If the STAPL Player is running inside a system that has a console or teletype output device, that device can be used to display messages generated by the STAPL file. 3.3.1 Required Features of the STAPL PlayerThe STAPL Player shall have the following capabilities:
••••••••
Execute a STAPL file
Process the user-specified actions and procedures (if the specified action or procedure does not exist in the file or no action is specified, an error will result)
Check the CRC of a STAPL file (without executing the STAPL file)
Extract information from the NOTE fields of a STAPL file (without executing the STAPL file)Access to the signals of an IEEE 1149.1 interface
Access to the signals specified by VECTOR/VMAP instructions as supported by the platformReliable mechanism for creating accurate real-time delays
Report exit status information following the execution of a STAPL file (e.g., an exit code)
JEDEC Standard No. 71
Page 5
3.3.2 Optional Filtering Feature
A STAPL file may support many ACTION statements. In some situations, only a subset of these supported ACTION statements may be desired in a STAPL file. For these cases, the original file may be filtered down to preserve only the desired actions. All ACTION statements, and DATA and PROCEDURE blocks not necessary for these desired ACTION statements, are removed from the STAPL file.
To filter a STAPL file to the desired subset of actions, identify the list of PROCEDURE blocks called by the desired ACTION statements, and recursively identify all other DATA and PROCEDURE blocks that are used (USES keyword) by that PROCEDURE block.
Finally, a new STAPL file is created by preserving only those PROCEDURE and DATA blocks that have been identified. All NOTE fields must be preserved and a new CRC is calculated. This new STAPL file is called the “filtered” STAPL file.
Implementing this optional filtering feature of the STAPL Player allows STAPL Composers to generate full-featured STAPL files while allowing users to minimize file size by selecting only the actions that they desire.3.3.3
Optional Update Feature for Device Programming
A STAPL file that programs a programmable device must contain both the data pattern to be programmed into the device and the algorithm for programming that data into the device. In some situations it may be necessary to provide an updated programming algorithm for the STAPL file, while leaving the data pattern undisturbed. In particular, this updating process may be required to permit the programming of a new device version. For dedicated device programming systems, the update process should be done automatically by the STAPL Player.
For STAPL files to be updated automatically, the STAPL Player must have access to a library of STAPL files containing
programming algorithms for the supported devices. Each of these “reference” programs must have NOTE statements to define the following attributes: DEVICE, SAVE_DATA, and ALG_VERSION. When a STAPL file is loaded into the STAPL Player, if the same three NOTE statements are defined in the loaded STAPL file, it is possible to update the STAPL file. If the library of reference programs contains a program whose DEVICE string matches that of the loaded STAPL file, and whose SAVE_DATA string matches that of the loaded STAPL file, the ALG_VERSION of the loaded program is compared to the ALG_VERSION of the reference program. If the ALG_VERSION of the reference program is greater, the loaded STAPL file should be updated.
To update the loaded STAPL file, the list of preserved DATA blocks must be extracted from the value string of the SAVE_DATA statement. This value string must contain a comma-separated list of DATA block names. The STAPL Player must then process the loaded STAPL file to find these DATA blocks. Finally, a new STAPL file is created, using the reference program as a basis, and substituting the preserved DATA blocks from the loaded STAPL file with the corresponding DATA blocks in the reference program and calculating the new CRC. This new STAPL file is called the “updated” STAPL file.
The updated STAPL file can exist only temporarily, or it can be saved for future use. If it is not saved, the update procedure will occur each time that STAPL file is used.
Implementing this optional feature of the STAPL Player allows two locations for the algorithm: the version of the algorithm
contained in the STAPL file and the version of the algorithm from a library of reference programs. This implementation of selecting the newer algorithm is useful because it permits the STAPL Player to support new programmable devices easily and quickly, using the algorithm contained in the STAPL file. Older devices for which a reference program exists will automatically use the newest algorithm available.3.3.4
Optional Read Feature for Device Programming
In some situations, it may be necessary to read the data pattern from a device or chain of devices to program other boards with the same device(s). The common use of this feature is where a “master board” or “master device” is used to store programming data for programming many copies of this board.
Support of this read feature requires an algorithm for reading the data from the master device(s) and a corresponding algorithm that uses the read data to program copies of the master device(s). The algorithm for reading the device(s) will be designated by the ACTION READ statement, and the algorithm for programming the device(s) will be designated by the ACTION PROGRAM
statement. The algorithm for reading the device will contain EXPORT statements to pass the data back to the STAPL Player. The STAPL file that contains these algorithms must have NOTE statements to define the following:
JEDEC Standard No. 71Page 6
••
SAVE_DATA_VARIABLES attribute to list all variables that will store programming data.
SAVE_DATA attribute (the same attribute described in the optional update feature) to list all data blocks that contain variables listed in the SAVE_DATA_VARIABLES attribute.
All listed variables must also be defined within the STAPL file. Thus, once the SAVE_DATA and SAVE_DATA_VARIABLES notes are read, the STAPL Player will know which variable(s) will be exported from the STAPL file during the READ action.
To read the data pattern from one or more devices, the STAPL file is executed by selecting the READ action. As the STAPL file is executing, EXPORT statements are processed, sending data to the STAPL Player via a callback function. Each time the EXPORT statement is called, the STAPL Player stores the key string, which contains a variable name, and the associated data, which
represents the data value for that variable. When the STAPL file execution is complete, if the exit code is zero (indicating success), the STAPL Player compares the variable names specified in the SAVE_DATA_VARIABLES note field to the key strings exported during the STAPL file execution. If all the variables listed in the SAVE_DATA_VARIABLES note field were received by the export callback function, the STAPL Player will create an updated STAPL file containing the new data.
The updated STAPL file is created using a reference program as a basis. (See the “Optional Update Feature for Device
Programming” section.) The variables listed in the SAVE_DATA_VARIABLES note are located in the reference program, and a new STAPL file is created, substituting the new data values for those variables. The STAPL Player can store the algorithm with the new data in either of the following ways:
••
Temporarily for immediate programming of the master device copies.
Permanently for later programming by writing the information into a new output STAPL file.
4.STATEMENTS4.1
Overview
Each statement in a STAPL file contains up to three elements: a label (optional), an instruction, and arguments. The number and type of arguments depends on the instruction. A semicolon (;) terminates the statement.
4.2Labels (Optional)
Labels provide a means of branching within the program. A unique label can begin each STAPL file statement and must be followed by a colon (:). Label names are not case sensitive (i.e., two label names that differ only by case are considered equal).
4.3Instructions
Each STAPL statement (except the Assignment statement) begins with one of the following instruction names. “STAPL Statement Specifications” on page 18 provides a detailed description of each instruction name. The instruction names, including the names of the optional instructions, are reserved keywords and cannot be used as variable or label identifiers in a STAPL file.
••••••••••••••
Notes:
(1)This instruction allows the changing of the TCK frequency on hardware that can support it.(2)This instruction allows the application of parallel vectors if the hardware exists to support it.
Assignment (=)ACTIONBOOLEANCALLCRCDATADRSCANDRSTOPENDDATAENDPROCEXITEXPORTFOR
FREQUENCY (1)••••••••••••••GOTOIF
INTEGERIRSCANIRSTOPNEXTNOTEPOPPOSTDRPOSTIRPREDRPREIRPRINT
PROCEDURE
••••••PUSHSTATETRSTWAIT
VECTOR (2)VMAP (2)
JEDEC Standard No. 71
Page 7
All STAPL instructions take arguments in the form of variables or expressions, except for the following:
•••••••
The GOTO instruction takes labels as arguments.
The CALL instruction takes procedure names as arguments.
The PRINT instruction takes a string expression as an argument.
The DRSCAN, IRSCAN, and VECTOR instructions take Boolean array expressions as arguments.
The DATA and PROCEDURE instructions take identifiers representing names of DATA and PROCEDURE blocks as arguments.The ENDDATA and ENDPROC instructions take no arguments at all.
The ACTION instruction takes identifiers representing the name of the ACTION, a list of PROCEDURE blocks, and a string.
When a statement is processed, each argument is checked for a valid variable or expression type.
Table 1 shows the sixteen state names that are reserved keywords in STAPL. These keywords correspond to the state names specified in the IEEE 1149.1 specification.
Table 1 - Reserved State Names
IEEE 1149.1 State Names
Test-Logic-ResetRun-Test-IdleSelect-DR-ScanCapture-DRShift-DRExit1-DRPause-DRExit2-DRUpdate-DRSelect-IR-ScanCapture-IRShift-IRExit1-IRPause-IRExit2-IRUpdate-IR
STAPL Reserved State Names
RESETIDLEDRSELECTDRCAPTUREDRSHIFTDREXIT1DRPAUSEDREXIT2DRUPDATEIRSELECTIRCAPTUREIRSHIFTIREXIT1IRPAUSEIREXIT2IRUPDATE
The following strings are also reserved keywords in STAPL, due to their significance in STAPL statements or expressions:
••••••
BOOLCAPTURECHR$COMPARECYCLESINT
••••••
MAX
OPTIONALRECOMMENDEDSTEPTHENTO
••
USECUSES
4.4Comments
A comment is a part of a STAPL file that is ignored during processing. Comments can be placed anywhere in the program and are made using the apostrophe character (‘). The apostrophe, and all characters following it on the same line, are ignored. A line break indicates the end of a comment.
JEDEC Standard No. 71Page 8
5.PROGRAM FLOW5.1
Overview
When a STAPL Player executes a STAPL file, exactly one ACTION will be executed. Because a STAPL file may contain multiple ACTION statements, execution of a STAPL file begins by searching the STAPL file for the ACTION statement whose name matches the one specified by the user. Execution continues with calls to the list of PROCEDURE blocks listed in the ACTION statement. Execution terminates either when the end of the ACTION statement is reached or when an EXIT statement is processed. The flow of execution within each of the called PROCEDURE blocks is controlled using three methods: branches, calls to other PROCEDURE blocks, and loops.
5.2The Stack
STAPL manages subroutine calls and loops using a stack. The stack is a repository for information about all activities that can be nested. These nested activities are ACTIONs, CALL and ENDPROC, FOR and NEXT, and PUSH and POP. When an ACTION, CALL, FOR, or PUSH statement is encountered, information about the operation is added to the stack. When the corresponding ENDPROC, NEXT, or POP statement is encountered, the record is removed from the stack. (For the NEXT statement, the stack record is removed only when the loop has run to completion.) Recursion using the stack is allowed; however, the resulting stack depth must be determinate.
5.3ACTION
When a STAPL file is executed, the user must specify the action to perform and may also specify changes to the default state for the optional or recommended PROCEDURE statements that comprise the action. The ACTION statement causes execution to
sequentially jump to each PROCEDURE listed in the statement and the progress through the ACTION statement is saved on the stack. When execution of the called PROCEDURE block has reached completion by encountering an ENDPROC statement, execution jumps back to the next procedure listed in the ACTION statement and the record is deleted from the stack.
5.4CALL
The CALL statement causes execution to jump to a PROCEDURE and the location of the CALL statement is saved on the STACK. When execution of the called PROCEDURE block has reached completion by encountering an ENDPROC statement, execution jumps to the statement following the CALL statement, and the record is deleted from the stack. If an ENDPROC statement is executed when the stack is empty or does not have a CALL record on the top, an error occurs. The program will terminate with a corresponding error code.
The IF statement can be used with the CALL statements to call a subroutine conditionally.
5.5GOTO
The GOTO statement causes execution to jump to the statement that corresponds to the label. This label must be located within the same PROCEDURE block as the GOTO statement. This label may or may not have been encountered already in that PROCEDURE block. If the label was not encountered, the remainder of the PROCEDURE block will be processed (without executing any statements) until the label is found, or until the end of the PROCEDURE block is reached. If the label is found, execution of the program will continue from that point.
The IF statement can be used with the GOTO statement to create a conditional branch.
5.6FOR Loops
The FOR statement is used for iteration or “looping”. Each FOR statement has an associated integer variable called the “iterator”, which maintains a count of the iterations. When a NEXT statement using the same iterator variable is encountered, the iterator is compared to its terminal value. If the iterator has reached its terminal value and the body of the loop has been executed for the last time, the FOR loop is complete and control is passed to the statement following the NEXT statement. Otherwise, the iterator is incremented (or stepped, if the STEP keyword is used with the FOR statement) and control jumps back to the statement following the FOR statement.
JEDEC Standard No. 71
Page 9
5.7Recursion
A PROCEDURE block may call itself. This technique, known as recursion, must be used with care because PROCEDURE blocks are not normally re-entrant (i.e., every call to the PROCEDURE block will share the same copy of all data variables). To make a PROCEDURE block re-entrant, the PUSH and POP statements may be used to save and restore the values of data variables on the stack. The PUSH statement is used to save data variables before the call, and the POP statement is used to restore values after the return. In that case, the PROCEDURE block may call itself to implement recursion. The “Initialization” section describes the rules for initializing variables.
6.DATA MANAGEMENT6.1
Identifier Names
STAPL uses identifiers to represent ACTION names, PROCEDURE block names, DATA block names, label names, and variable names. Identifier names are limited to 32 characters, and must begin with an alphabetic character—not a number or underscore character (_). Identifier names consist of alphabetic characters, numeric characters, and the underscore (_) character—no other characters are allowed. Identifier names are not case sensitive (i.e., two identifier names that differ only by case are considered equal).
Declaration of an identifier whose name exceeds 32 characters in length, contains illegal characters, or conflicts with a previously defined identifier or reserved keyword is an error. All identifiers must be unique. For example, a variable may not have the same name as a PROCEDURE block. No two variables may have the same name even if they occur in different blocks.
6.2Types
The two data types available in STAPL are integer and Boolean. These types may be used to declare “scalar” variables and one-dimensional arrays. Any variable or array must be declared before any reference to it is made.
All arrays are zero-based (i.e., valid indices range from zero to one less than the total number of elements in the array).
6.3Initialization
By default, all variables and arrays are initialized to zero when they are created. Variables and arrays can also be initialized explicitly at the time of declaration.
When a variable declaration statement inside a PROCEDURE block is executed, the variable is initialized to the specified value, or to zero if no initial value is specified. If the variable declaration statement is executed multiple times, for example, inside a loop, the variable is initialized each time the declaration statement is executed.
When a variable declaration statement inside a DATA block has an initial value, the variable is initialized to the specified value only once, at any time before the DATA block is used for the first time within the current STAPL session.For initialization of Boolean arrays, the initial array data can be specified in one of three ways:
•••
Binary (one bit per character)
Hexadecimal (four bits per character)
Advanced Compression Algorithm (ACA)
To initialize integer arrays, the initial array data must be specified as a comma-separated sequence of decimal numbers. Array data can be accessed three ways:
•••
Indexing (using an integer) resulting in a single scalar value
Subrange indexing (using two integers) resulting in a smaller arrayCollectively as an array
JEDEC Standard No. 71Page 10
Arrays and subrange indexed arrays can only be used as arguments with Assignment, DRSCAN, IRSCAN, POSTDR, POSTIR, PREDR, PREIR, and VECTOR statements, which accept array arguments. No arithmetic, logical, or relational operators are provided for whole arrays or subrange indexed arrays.
6.4Literal Values
Literal data values may appear in integer or Boolean expressions. For example, in the statement a = a + 1, the number one is a literal value. The literal values 0 and 1 may be used in either integer or Boolean expressions; other signed decimal numbers between –2147483648 (–231) and 2147483647 (231 – 1) can be used only in integer expressions. Only decimal format is supported for integers.For Boolean array expressions, a literal Boolean array value can be expressed in one of three ways:
•••
Binary (one bit per character)
Hexadecimal (four bits per character)
Advanced Compression Algorithm (ACA)
Such literal arrays can be used as arguments with Assignment, DRSCAN, IRSCAN, POSTDR, POSTIR, PREDR, PREIR, and
VECTOR statements, which accept Boolean arrays as arguments. The array elements are ordered from right to left, i.e., the least significant bit (LSB) of the right-most hexadecimal digit corresponds to index zero of the array. If the size of a literal array is greater than the expected size, the excess most significant bits are ignored. If the size of the literal array is less than the expected size, an error occurs. Literal Boolean arrays must begin with a format symbol to avoid confusion with variable names. These format symbols are the pound symbol (#) for a binary array, the dollar sign ($) for a hexadecimal array, and the ‘at’ symbol (@) for the ACA compression format. For example, the 9-bit value of 101101111 can be expressed as a binary value of “#101101111”, as a
hexadecimal value of “$16F”, or as an ACA value of “@30000uj000”. Since literal values for large Boolean arrays may become long, white space (space, tabs, or carriage returns) may appear anywhere in the literal Boolean array value. No format is supported for literal use of integer arrays.
Text strings must be specified as literal values for the PRINT statement, because STAPL does not support any character or string variable types.
6.5Constants
No facility is provided for integer or Boolean constants. A variable should be declared with an initialized value when a symbolic name for a quantity is desired.
6.6Advanced Compression Algorithm (ACA)
The ACA format uses text characters to store Boolean array data in a compressed form. This section describes the algorithm and syntax for recovering raw binary data from ACA compressed format.
The ACA decompression process is performed in two steps. Because ACA format uses text characters to store the compressed representation of a Boolean array, the first step is to convert the text characters into an array of binary values, called the compressed binary array. This compressed binary array is then processed using the ACA decompression algorithm to recover the original uncompressed data bytes.
JEDEC Standard No. 71
Page 11
The character set for ACA compressed arrays is the set of digits (0 - 9), uppercase and lowercase alphabetic characters (A – Z and a – z), the underscore character (_), and the ‘at’ symbol (@). These 64 text characters are used to represent numeric quantities, with each character representing six bits of compressed data. Each character in an ACA compressed array (excluding white-space characters) must be one of these text characters. White-space characters may occur anywhere in an ACA compressed array and are ignored. The decoding of binary values from text characters is shown in Table 2.
Table 2 - Character Decoding into Binary Values
Character
‘0’..’9’‘A’..’Z’‘a’..’z’‘_’‘@’
Decimal Value
0..910..3536..616263
Binary Value
000000..001001001010..100011100100..111101111110111111
To convert an ACA compressed array from text format to binary format, each text character is processed sequentially, beginning with the initial format symbol character, which must be the ‘at’ character (@). Subsequent characters in the compressed array are processed as follows: all white space characters are ignored, others are converted into six-bit binary values according to the
decoding rules shown in Table 2. The resulting six-bit binary values are packed into bytes, such that four six-bit values pack into three bytes of the compressed binary array. For example, the first six-bit value is stored in the lower six bits of the first byte; the second six-bit value is stored in the two remaining bits of the first byte and the lower four bits of the second byte; the third six-bit value is stored in the remaining four bits of the second byte and the lower two bits of the third byte; and the fourth six-bit value is stored in the remaining six bits of the third byte.
The overall structure of the ACA format consists of a data length block, followed by any number of data blocks. The data length block and data blocks are composed of binary values, located in bit-fields within the compressed binary array. Compression is achieved by storing data in two types of data blocks: literal data blocks and repeated data blocks. To uncompress the data, these data blocks are processed sequentially, producing the uncompressed data bytes. Figure 2 shows the overall structure of data in the ACA format.
UncompressedData Length(Number of Bytes)Literal DataLiteral or RepeatedDataLiteral or RepeatedDataFigure 2 - ACA Data Structure
The uncompressed data length block contains a numeric value that is 32 bits long, representing the length (in bytes) of the data when it is uncompressed. Thus, the maximum length of binary data that can be compressed by the ACA algorithm is
232 – 1 bytes of raw data. The four bytes that make up the uncompressed data length block are ordered in the Little Endian format, meaning that the least-significant byte is stored at the lowest memory address, followed by bytes in increasing significance. For example, if the length is Hex 12345678, the first byte is Hex 78, followed by Hex 56, etc. Figure 3 shows the uncompressed data length block.
Byte PositionBits of 32-Bit ValueByte 07..0 (LSB)Byte 115..8Byte 223..16Byte 331..24 (MSB)Figure 3 - ACA Uncompressed Data Length Block
As the ACA data blocks are processed, uncompressed data is copied to an output buffer. The current position in the output buffer is advanced as data is copied. Before the first byte is processed, the current position in the output buffer is zero.
JEDEC Standard No. 71Page 12
Each literal data block begins with a bit whose value is 0 and is followed by three bytes of uncompressed data (see Figure 4). When this block is processed, the three literal data bytes are copied directly to the output buffer, starting at the current position. The current position is advanced by three bytes.
Bit Position in BlockLiteral data byte:08..1Byte 016..9Byte 124..17Byte 2Figure 4 - ACA Literal Data Block
The repeated data block indicates a sequence of data bytes that is a repetition of previous data. Each repeated data block begins with a bit whose value is 1. The next 1 to 13 bits comprise the offset, which is followed by a byte specifying the length. To process the repeated data block, the offset value and length value are extracted from the block, and the corresponding repeated data is copied from the reference position in the output buffer (specified by the offset value) to the current position in the output buffer. The offset value, represented by a variable number of bits, specifies the number of bytes back in the output buffer (relative to the current position) where the repeated data begins. The length value indicates the number of bytes of data that are repeated. The size of the offset field (variable N in Figure 5) depends on the current position in the output buffer; it is the minimum number of bits required to represent the current position. For example, if the current position is 1025, N = 11. Since the first data block must always be a literal data block, the size of the offset field is always greater than zero.
As an example of the repeated data block, if the offset value is eight and the length value is five, the reference position is eight bytes less than the current position in the output buffer, and five bytes are to be copied from that position to the current position in the output buffer. Figure 5 illustrates the structure of the repeated data block.
Bit Position in BlockFunctionSizeLimits0Constant Bit1 bitN..1OffsetUp to 13 bits1 ≤ Offset ≤ (213) – 1N + 8..N + 1Length8 bits4 ≤ Length ≤ 255Figure 5 - ACA Repeated Data Block
The following example illustrates how uncompressed data is recovered from a compressed Boolean array. In this example, the compressed data consists of the text string “O00008Cn63PbPMRWpGBDgj6RV60”.
The first step in uncompressing the data is to convert each character into the corresponding binary value, using the conversion mapping described in Table 2. This step produces the compressed binary array. See Table 3.
JEDEC Standard No. 71
Page 13
Table 3 - Sample Compressed Data
Offset
01234567891011121314151617181920212223242526
ASCII Data
O00008Cn63PbPMRWpGBDgj6RV60
Binary Data
011000000000000000000000000000001000001100110001000110000011011001100101011001010110011011100000110011010000001011001101101010101101000110011011011111000110000000
The second step in uncompressing the data is to find and process the data blocks in the compressed binary array. Note that the offset field for the first repeated data block is three bits long, because at that stage the current position in the output buffer is six, which may be represented in three bits. The offset field for the second repeated data block is five bits long, because at that stage the current position in the output buffer is 18, which may be represented in five bits. Table 4 shows the compressed binary array data for this example, with annotations to show the uncompressed data length block and the literal and repeated data blocks.
JEDEC Standard No. 71Page 14
Table 4 - Sample Compressed Binary Array
Block Type
Uncompressed data length
Binary Data
000110000000000000000000000000000
0110000101100010011000110
0110010001100101011001101110
000001100
0110101001101011011010010
0110101001101011011011001
0111100000110
Notes
Uncompressed data length = 24 bytes
Literal data
Type = literal data‘a’‘b’‘c’
Type = literal data‘d’‘e’‘f’
Type = repeated dataOffset = 6Length = 6Type = literal data‘g’‘h’‘i’
Type = literal data‘j’‘k’‘l’
Type = repeated dataOffset = 15Length = 6
Literal data
Repeated data
Literal data
Literal data
Repeated data
After processing the data blocks in sequential order, the output buffer contains the uncompressed data corresponding to the
compressed input data. Although the uncompressed data in this example contains text characters, it is not required. Table 5 shows the uncompressed data for this example.
JEDEC Standard No. 71
Page 15
Table 5 - Sample Uncompressed Data
Offset
01234567891011121314151617181920212223
Hex Data
6162636465666162636465666768696A6B6C646566616263
ASCII Data
‘a’‘b’‘c’‘d’‘e’‘f’‘a’‘b’‘c’‘d’‘e’‘f’‘g’‘h’‘i’‘j’‘k’‘l’‘d’‘e’‘f’‘a’‘b’‘c’
Binary Data
011000010110001001100011011001000110010101100110011000010110001001100011011001000110010101100110011001110110100001101001011010100110101101101100011001000110010101100110011000010110001001100011
In this example, the uncompressed data consists of the text string “abcdefabcdefghijkldefabc”. Compression was achieved by recognizing that the sequences “abcdef” and “defabc” were repeated in the original data array. These sequences were then compressed in two repeated data blocks. During decompression, the repeated data blocks were processed, causing the desired repetition of those sequences and resulting in an exact reproduction of the original data array in the output buffer.
7.EXPRESSIONS & OPERATORS7.1
Expressions
An expression in STAPL is a collection of variables, literal data values, or other expressions joined together by operators to describe a computation. Parentheses may be used to control the precedence of evaluation. The result of every expression, applied as an instruction argument, must match the expected type.
7.2Integer & Boolean Operations
STAPL offers a complete set of arithmetic, logical, and relational operators. The character codes and behavior used for these operators are similar to the operators used in the ‘C’ programming language. The Assignment operator (=) is not included in this list because it is considered to be part of the Assignment statement. The ternary operator in the ‘C’ language (A = B ? C : D) is not supported in STAPL. Arithmetic and logical operators always produce the same type of result as used by the arguments (i.e., integer arguments produce integer results, and Boolean arguments produce Boolean results). The relational operators always produce a Boolean result.
JEDEC Standard No. 71Page 16
The arithmetic and logical operators described in Table 6 take one or two integer arguments and produce an integer result.
Table 6 - Operators Yielding an Integer Result
Operator
~*/%+–<<>>&^|
Description
Bitwise unary inversionMultiplicationDivisionModuloAddition
Subtraction and unary negationLeft shiftRight shiftBitwise logical ANDBitwise logical exclusive ORBitwise logical OR
The relational operators described in Table 7 take two integer arguments and produce a Boolean result.
Table 7 - Operators with Integer Arguments and a Boolean ResultOperator
==!=><>=<=
Description
Equality comparisonInequality comparisonGreater comparisonLess comparison
Greater or equal comparisonLess or equal comparison
The logical and relational operators described in Table 8 take two Boolean arguments and produce a Boolean result (except the unary inversion operator, which takes one Boolean argument).
Table 8 - Operators with Boolean Arguments and a Boolean ResultOperator
&&||!==!=
Description
Logical ANDLogical ORUnary inversionEquality comparisonInequality comparison
For the logical AND and logical OR, both operands are always evaluated.
Note that the equality and inequality comparison operators (== and !=) are used for both integer and Boolean arguments. However, both arguments must be either Boolean or integers (i.e., an integer argument cannot be directly compared to a Boolean argument).The functions described in Table 9 allow type conversions between Boolean arrays and integers. Note that the conversion is using two’s complement Boolean values.
Table 9 - Functions for Converting Types
Function
BOOL()INT()
Description
Integer to 32-bit Boolean array conversion32-bit Boolean array to integer conversion
JEDEC Standard No. 71
Page 17
The INT() function converts Boolean array arguments of 32 or fewer bits. For arguments of fewer than 32 bits, zeros are used to extend the argument prior to conversion, producing a non-negative integer result.
Table 10 shows the precedence of operations, in descending order of priority. However, parentheses can be used to force the precedence in any expression.
Table 10 - Operator Precedence
Precedence
1234567891011
Operator
!, ~*, /, %+, -<<, >><, <=, >, >===, !=&^|&&||
Description
Unary inversion
Multiplication, division, and modulo
Addition, subtractionShift
Magnitude comparisonEquality comparisonBitwise logical ANDBitwise logical exclusive ORBitwise logical ORLogical ANDLogical OR
7.3Array Operations
Square brackets ([ ]) are used to index arrays. The result of indexing is either a single element (integer or Boolean) or an array, representing a subset of the original array. To gain access to a single element of an array, the index consists of a single integer expression. For example, one element of an array can be assigned to another element as follows:vect[52] = vect[0];
An array expression can consist of a range of elements from another array variable. The syntax for this expression is the same as for indexing, but with a start index and stop index, separated by two periods (..). The indices of array variables may be listed in increasing order (i.e., vect[0..9]) or in decreasing order (i.e., vect[9..0]). Decreasing order is preferred. When increasing order is specified, it represents a reversal of the preferred order of the bits. For example, to copy a group of elements from one array to another while reversing the order:dest[255..0] = source[0..255];
If no indexing expression is given inside the brackets, this is equivalent to a subrange index spanning the entire array in decreasing order. Thus, the expression vect[] is equivalent to vect[n-1..0], where n is the total number of elements in array vect[]. This method is used to provide Boolean array expressions for Assignment, DRSCAN, IRSCAN, POSTDR, POSTIR, PREDR, PREIR, and VECTOR statements. For example:
DRSCAN length, invect[start..stop], CAPTURE outvect [start..stop];
7.4String Operations
String operations can be used only in PRINT statements. Integer and Boolean expressions are converted to strings automatically in the PRINT statement. Boolean expressions are converted to a string of “0” and “1”. For example, the following statement prints out the value of an integer variable:
PRINT \"The signed integer value of a is \
The following statement displays the character represented by an integer variable:
PRINT \"The character in a is \
JEDEC Standard No. 71Page 18
The CHR$() function converts an integer value to its ASCII (ANSI X3.4-1986(R1997)) code, allowing STAPL to print ASCII characters. For example, if message text is acquired from a device during test or programming, it can be stored and manipulated as integer data, and displayed as text characters.
8.STAPL STATEMENT SPECIFICATIONS8.1
Overview
The following section describes each STAPL statement type.
8.2ACTION
The ACTION statement specifies the sequence of steps required to implement a complete operation, such as programming a device. A STAPL file must contain an ACTION statement corresponding to each operation that can be selected by a user. Each ACTION statement specifies a list of PROCEDURE blocks that must be called, in the specified order, to complete the operation. Each of these listed PROCEDURE blocks may be identified as optional or recommended. Optional and recommended PROCEDURE blocks may be included or excluded as desired by the end user.
The ACTION statement contains the name of the operation, and an optional text string describing the operation. To support
localization, the string should not be used with reserved ACTION names. After the equal sign, the names of the PROCEDURE blocks are listed in the order in which they will be called. Each PROCEDURE block name may be followed by one of the keywords RECOMMENDED or OPTIONAL. PROCEDURE blocks with these notations may be included or excluded from the execution of the ACTION. The RECOMMENDED keyword indicates that the PROCEDURE block will be called unless explicitly declined by the user, while the OPTIONAL keyword indicates that the PROCEDURE block will not be called unless explicitly requested by the user. A PROCEDURE block listed without these keywords will always be included. One PROCEDURE block must exist for each PROCEDURE name listed in ACTION statements; however, multiple ACTION statements may call a PROCEDURE block. All ACTION statements must be located after the NOTE statements and before all PROCEDURE and DATA blocks.Syntax:
ACTION {, DO_ENTER_ISP, DO_SECURE, DO_EXIT_ISP; ACTION VERIFY “Verify only” = DO_ENTER_ISP, DO_VERIFY,DO_EXIT_ISP; ACTION PROGRAM “Program all devices” = DO_ENTER_ISP,DO_ERASE, DO_BLANK_CHECK OPTIONAL,DO_PROGRAM, DO_VERIFY RECOMMENDED,DO_EXIT_ISP;ACTION READ_IDCODE = DO_READ_IDCODE; Examples: JEDEC Standard No. 71 Page 19 8.3Assignment The Assignment statement assigns the value of an expression to a variable. It may be used to assign integer or Boolean values, and it may be used with scalar (single) quantities or arrays. When assigning arrays or array subranges, the variable receiving the Assignment must be an array or a subrange of such an array. The array expression being assigned to the array may be a Boolean array variable or literal Boolean array value. When assigning an array variable subrange to another array variable subrange, the ordering may be the same or opposite; however, the width must be the same. All Assignment statements must be located within PROCEDURE blocks.Syntax: i = i + 1; ' i is an integer variableb = !c; ' b and c are Boolean variablesia[2] = 3; ' ia[] is an integer arrayba[2] = 0; ' ba[] is a Boolean arrayia[7..0] = ia[15..8];' copy array subrangeba[0..8] = $0AB; ' literal Boolean array-reverse order Examples: 8.4BOOLEAN The BOOLEAN statement declares a Boolean variable or array. All variables in a STAPL file must be declared before they are used. Variables declared inside a PROCEDURE block are only available inside that block. Variables declared inside a DATA block are available in any PROCEDURE block that uses (USES keyword) that DATA block. Boolean variables can be initialized to 0 or 1. Arrays can be initialized using binary, hexadecimal, or ACA compressed format. To select the format for initialization data, the pound (#), dollar ($), and ‘at’ (@) symbols can be used to represent binary, hexadecimal, or ACA compression, respectively. The size of a Boolean array is an integer expression. Initialization data specified using binary or hexadecimal formats is always ordered from right to left (i.e., the right-most binary digit or the LSB of the right-most hexadecimal digit corresponds to index zero of the array). The size (number of elements) of the initialization data must not be less than that of the initialized array. If the size of the initialization data is greater than that of the initialized array, the excess bits must be zero. If no initialization data is specified, the variable or array is initialized to zero. All BOOLEAN statements must be located within either PROCEDURE or DATA blocks.Syntax: BOOLEAN BOOLEAN BOOLEAN Examples: BOOLEAN status = 0;BOOLEAN flags[3]= #010;BOOLEAN verifydata[100]; BOOLEAN address[20] = #10100101101001011010;BOOLEAN data[31] = $34B4CDBF;BOOLEAN verify[128] = @hd30000t@ztV; JEDEC Standard No. 71Page 20 8.5CALL The CALL statement causes execution to jump to the first statement in the specified PROCEDURE block, and saves a CALL record on the stack. In this case, the ENDPROC statement causes execution to return to the statement following the CALL statement. One PROCEDURE block must exist for all procedure names called by the CALL statement. To call a PROCEDURE block, the PROCEDURE block containing the CALL statement must reference the PROCEDURE block to be called in its USES list. All CALL statements must be located within PROCEDURE blocks.Syntax:Example: CALL 8.6CRC The CRC statement is a mandatory statement used to verify the data integrity of the STAPL file; it is not an executable statement. The CRC statement must be located at the end of the STAPL file, after all other STAPL statements. To check the integrity of the STAPL file, the cyclic redundancy code (CRC) of all characters in the file, including comments and white-space characters but excluding carriage-return (CR) characters, must be calculated up to (but not including) the CRC statement. The CRC value obtained is then compared to the value found in the CRC statement. If the CRC values agree, the data integrity of the STAPL file is verified.A CRC value of “0” indicates that CRC should not be compared.Syntax:Example: CRC <4-digit hexadecimal number>;CRC 9C4A; See Annex B for details on how the CRC is computed. 8.7DATA The DATA statement marks the beginning of a DATA block. A DATA block may only contain variable declaration statements (INTEGER or BOOLEAN) with or without initialization values. No other statement may be encountered in a DATA block. All DATA statements must have a corresponding ENDDATA statement to indicate the end of the DATA block. DATA blocks may be used by one or more PROCEDURE blocks with the USES keyword. When a PROCEDURE uses a DATA block, the variables declared in that DATA block are available for use in the PROCEDURE. Any variable declared in a DATA block is initialized only the first time the block is used (USES keyword); all subsequent times the DATA block is used, the initialization value is ignored. If multiple PROCEDURE blocks use a DATA block, those PROCEDURE blocks share the variables in the DATA block. The shared variables will not lose their values at the end of any PROCEDURE block. If a PROCEDURE block does not use a DATA block, the statements inside that PROCEDURE block may not use or modify variables in the DATA block. All DATA and PROCEDURE blocks must be located after the ACTION statements and before the final CRC statement. However, within that constraint, PROCEDURE and DATA blocks may occur in any order.Syntax: Example: DATA DATA prog_data; INTEGER num_of_address = 10; BOOLEAN data[100] = $764396545498705A7545BD8E4;ENDDATA; JEDEC Standard No. 71 Page 21 8.8DRSCAN The DRSCAN statement specifies an IEEE 1149.1 data register scan pattern to be updated into the target data register. The scan data shifted out of the target data register may be captured in a Boolean array variable, compared to a Boolean array expression, or both, or it may be ignored. The data register length is an integer expression specifying the number of data bits to be shifted. This length must be greater than zero. The scan data array is a Boolean array expression, specifying the data to be loaded into the data register. The data is shifted in increasing order of the array index, that is, beginning with the least index. The capture array is a Boolean array variable. The compare array and mask array are Boolean array expressions and the result is a Boolean variable or a single element of a Boolean array variable that receives the result of the comparison. All Boolean array expressions must have size greater than or equal to the specified data register length (excess bits are ignored). Mask array bit values of “1” represent bits to be compared, and bit values of “0” represent bits not to be compared. A successful comparison will cause a one (or TRUE) value to be stored in the result variable. An unsuccessful comparison will cause a zero (or FALSE) value to be stored in the result variable, but will not interrupt the STAPL file execution. To abort in the case of an error, a conditional (IF) statement must be used to test the result value, and the EXIT statement called to stop the program. All DRSCAN statements must be located within PROCEDURE blocks.Syntax: DRSCAN [,COMPARE DRSCAN 20, datain[19..0], CAPTURE dataout[19..0];DRSCAN 41, indata[40..0], COMPARE expecteddata[40..0], maskdata[40..0],verify_result;DRSCAN 10, #0111100011, COMPARE #1111011110, #1111111110, done[3]; Examples: 8.9DRSTOP The DRSTOP statement specifies the IEEE 1149.1 end state for data register scan operations. This end state must be one of the IEEE 1149.1 states: RESET, IDLE, IRPAUSE, or DRPAUSE. The default state is IDLE, when no state name is provided. Once an end state is specified, all subsequent data register scan operations will park in that end state, until another DRSTOP statement is encountered. All DRSTOP statements must be located within PROCEDURE blocks.Syntax:Example: DRSTOP 8.10ENDDATA The ENDDATA statement indicates the end of a DATA block. ENDDATA statements may only appear following a previous DATA statement marking the beginning of the block. Exactly one ENDDATA statement must exist per DATA block.Syntax:Example: ENDDATA; DATA prog_data; INTEGER num_of_address = 10; BOOLEAN data[100] = $764396545498705A7545BD8E4;ENDDATA; JEDEC Standard No. 71Page 22 8.11ENDPROC The ENDPROC statement indicates the end of the current PROCEDURE block and execution returns to the calling location, determined by removing the CALL record from the stack. If the record on the stack is not a CALL record, an error will occur. If the PROCEDURE block is called from the list of PROCEDURES in an ACTION statement, execution jumps to the following PROCEDURE in the list. If the PROCEDURE block is called from another PROCEDURE block using a CALL statement, execution jumps to the statement after the CALL statement. Exactly one ENDPROC statement must exist per PROCEDURE block. Syntax:Example: ENDPROC; PROCEDURE print_message; PRINT “Scan Complete”;ENDPROC; 8.12EXIT The EXIT statement immediately terminates the execution or processing of the STAPL file with the specified EXIT code. By default, if all the PROCEDURE blocks listed in the user-selected ACTION statement are processed without encountering an EXIT statement, the execution of the STAPL file terminates with a successful EXIT code. An EXIT code of zero indicates success, and non-zero values indicate error conditions. A set of standard EXIT codes is defined in the “Structural Requirements” section. All EXIT statements must be located within PROCEDURE blocks.Syntax:Example: EXIT EXIT status; 8.13EXPORT The EXPORT statement exports a key string and a data value to the calling program via a callback function. The data value may be the result of a Boolean expression, an integer expression, or a Boolean array expression. The calling program should ignore exported data if the key string is not recognized. A set of standard key strings is defined in the “Structural Requirements” section. All EXPORT statements must be located within PROCEDURE blocks.Syntax:Example: EXPORT EXPORT \"USERCODE\ 8.14FOR The FOR statement initiates a loop. Each FOR statement has an associated integer variable called the “iterator”, which maintains a count of the iterations. The NEXT statement continues or terminates the loop. When the NEXT statement is encountered, the value of the iterator variable is compared to the terminal value. Comparison to a terminal value is determined using the following methods: •• For a positive step value—Greater than or equal toFor a negative step value—Less than or equal to If the loop has not yet run to completion, the iterator is “stepped” by adding the specified step value. (If no value is specified, the default step value is 1). Then, control jumps to the statement after the FOR statement. If the loop has run to completion, control jumps to the statement following the NEXT statement. JEDEC Standard No. 71 Page 23 FOR loops can be nested. When a FOR statement is encountered, a FOR record is pushed onto the stack. This record stores the name of the iterator variable and the location of the FOR statement. When the corresponding NEXT statement is encountered, the terminating condition is evaluated. If the FOR loop has reached its terminal value and the body of the loop has been executed for the last time, the FOR loop record is deleted from the stack and control jumps to the statement following the NEXT statement. If the FOR loop has not reached its terminal value, the iterator variable is incremented (or stepped), and control continues at the statement following the FOR statement. If a NEXT statement is encountered and the top record on the stack is not a FOR record with the same iterator variable, or if the stack is empty, an error occurs. When nesting one FOR loop inside another, the inner loop must run to completion before the NEXT statement of the outer loop is encountered. The iterator variable may be assigned a value within the FOR loop. This capability allows the number of iterations to be defined during the execution of the loop. Additionally, the STEP value may be zero, allowing the terminating condition to be independent of the STEP value and be solely dependent on the assigning of values to the iterator variable. The start, end, and STEP values are evaluated when first entering the FOR loop. Although the value of these variables can be changed during the loop, this change will not affect the rest of the loop. Since the terminating condition is not evaluated until the NEXT statement is processed, the body of the loop will always be executed at least once, even if the initial value of the iterator is equal to the terminal value. All FOR statements must be located within PROCEDURE blocks and the corresponding NEXT statement must be located in the same PROCEDURE block. Once initiated, a FOR loop must run to completion before the ENDPROC statement is encountered.Syntax: FOR [STEP accumulator = accumulator + vector[index];NEXT index; FOR done = 0 TO 1 STEP 0; WAIT 10 USEC; DRSCAN 100, in[99..0], COMPARE out[99..0], done;NEXT done FOR index = 1 TO 5 STEP 1; WAIT 100 USEC; DRSCAN 20, in[19..0], COMPARE out[19..0], done IF done == 1 THEN index = 5; NEXT index; Examples: 8.15GOTO The GOTO statement causes execution to jump to the statement corresponding to the label. The label must be located within the same PROCEDURE block as the GOTO statement; however, it may occur in the PROCEDURE block either before or after the GOTO statement. The IF statement can be used with the GOTO statement to create a conditional branch. All GOTO statements must be located within PROCEDURE blocks.Syntax:Example: GOTO