Teledyne LeCroy Analyzers User Manual

PROTOCOL SOLUTIONS GROUP 3385 SCOTT BLVD SANTA CLARA, CA 95054
CATC Protocol Analyzers
File-Based Decoding
User Manual
For Software Version 1.2
June 2006
Document Disclaimer
The information in this document has been carefully checked and is believed to be reliable. However, no responsibility can be assumed for inaccuracies that may not have been detected.
LeCroy reserves the right to revise the information in this document without notice or penalty.
Trademarks and Servicemarks
CATC Trace, FCTracer, SATracer, SASTracer, PETracer, PETracer ML, PETracer EML, UWBTracer, UWBTracer MPI, BTTracer, Merlin, Merlin II, USBTracer, USB Mobile, USB Mobile HS, UPAS, and BusEngine are trademarks of LeCroy.
Microsoft and Windows are registered trademarks of Microsoft Inc.
All other trademarks are property of their respective companies.
Copyright
Copyright © 2006, LeCroy; All Rights Reserved.
This document may be printed and reproduced without additional permission, but all copies should contain this copyright notice.
LeCroy Corporation

File-based Decoding User Manual Table of Contents

TABLE OF CONTENTS
Chapter 1 Introduction 1
1.1 Features of CATC Scripting Language. . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 2 Values 3
2.1 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Chapter 3 Expressions 7
3.1 select expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 4 Operators 9
4.1 Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Operator Precedence and Associativity . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 5 Comments 17
Chapter 6 Keywords 19
Chapter 7 Statements 21
7.1 Expression Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.2 if Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.3 if-else Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.4 while Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.5 for Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.6 return Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.7 Compound Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Chapter 8 Preprocessing 27
Chapter 9 Context 29
Chapter 10 Functions 31
Chapter 11 Primitives 33
11.1 General Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
11.2 Data Manipulation Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
11.3 List Manipulation Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
11.4 Transaction Decoder Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
11.5 Display Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Appendix A:PCI Express . . . . . . . . . . . . . . . . . . . . . . . . . 61
A.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Module Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
A.2 Decoder Script Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
cfg.dec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
io.dec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
mem.dec. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Appendix B:Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
B.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
LeCroy Corporation iii
Table of Contents File-based Decoding User Manual
Module Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Module Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
B.2 Input Context Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
How to Contact LeCroy . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Limited Hardware Warranty . . . . . . . . . . . . . . . . . . . . . . . 71
What this Warranty Does Not Cover . . . . . . . . . . . . . . . . . . . . . . . . . 72
Coverage During Warranty Period . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
How to Obtain Warranty Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
General Provisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Index 75
iv LeCroy Corporation

File-based Decoding User Manual List of Figures

LIST OF FIGURES
Execution of a for Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Example: Output for AddCell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Example: Output for AddDataCell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Example: Separator Cell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Example: Output for BeginCellBlock with Red Group Collapsed . . . . . . . . . . . 58
Example: Output for BeginCellBlock with Red Group Expanded and Blue Group
Collapsed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Example: Output for BeginCellBlock with Red Group Expanded and Blue Group
Expanded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
LeCroy Corporation v

List of Tables File-based Decoding User Manual

LIST OF TABLES
Table 2.1 Examples of String Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 2.2 Escape Sequences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Table 4.1 Operator Precedence and Associativity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 4.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 6.1 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
vi LeCroy Corporation
File-based Decoding User Manual Chapter 1: Introduction

Chapter 1: Introduction

CATC Scripting Language (CSL) was developed to create scripts that would allow users to perform file-based decoding with all LeCroy analyzers. CSL is used to edit CATC Decode Scripting (CDS) files, which are pre-written decoder scripts supplied by LeCroy. These script-based decoders can be modified by users or used as-is. Additionally, users can create brand new CDS files.
This document includes the following analyzer-specific contents:
Appendix A: PETracer™ Decoder Script Files (for the PETracer product).
Decoding scripts for analyzers are located in the /Scripts sub-directory below the application directory. These scripts are tools to decode and display transactions. Users can also add entirely new, customized decoders to fit their own specific development needs. The analyzer application looks in the \Scripts directory and automatically loads all of the .dec files that it finds. To prevent a particular decoder from being loaded, change its extension to something other than .dec or move it out of the \Scripts directory.
CSL is based on C language syntax, so anyone with a C programming background should have no trouble learning CSL. The simple, yet powerful, structure of CSL also enables less experienced users to easily acquire the basic knowledge needed to start writing custom scripts.

1.1 Features of CATC Scripting Language

Powerful: Provides a high-level API while simultaneously allowing implementation of complex algorithms.
Easy to learn and use: Has a simple but effective syntax.
Self-contained: Needs no external tools to run scripts.
Wide range of value types: Provides efficient and easy processing of data.
Script-based decoding: Used to create built-in script-based decoders for analyz­ers.
Custom decoding: May be used to write custom decoders.
General purpose: Is integrated in a number of LeCroy products.
LeCroy Corporation 1
Chapter 1: Introduction File-based Decoding User Manual
2 LeCroy Corporation
File-based Decoding User Manual Chapter 2: Values

Chapter 2: Values

There are five value types that may be manipulated by a script: integers, strings, lists, raw bytes, and null. CSL is not a strongly typed language. Value types need not be
pre-declared. Literals, variables and constants can take on any of the five value types, and the types can be reassigned dynamically.

2.1 Literals

Literals are data that remain unchanged when the program is compiled. Literals are a way of expressing hard-coded data in a script.
Integers
Integer literals represent numeric values with no fractions or decimal points. Hexadecimal, octal, decimal, and binary notation are supported:
Hexadecimal numbers must be preceded by 0x: 0x2A, 0x54, 0xFFFFFF01
Octal numbers must begin with 0: 0775, 017, 0400
Decimal numbers are written as usual: 24, 1256, 2
Binary numbers are denoted with 0b: 0b01101100, 0b01, 0b100000
Strings
String literals are used to represent text. A string consists of zero or more characters and can include numbers, letters, spaces, and punctuation. An empty string ("") contains no characters and evaluates to false in an expression, whereas a non-empty string evaluates to true. Double quotes surround a string, and some standard backslash ( escape sequences are supported.
String Represented Text
"Quote: \"This is a string literal.\""
"256"
"abcd!$%&*"
"June 26, 2001"
"[ 1, 2, 3 ]"
Table 2.1 Examples of String Literals
Quote: "This is a string literal."
256 **Note that this does not represent the
integer 256, but only the characters that make up the number.
abcd!$%&*
June 26, 2001
[ 1, 2, 3 ]
\)
LeCroy Corporation 3
Chapter 2: Values File-based Decoding User Manual
Escape Sequences
These are the available escape sequences in CSL:
Escape
Character
backslash
double quote
horizontal tab
newline
single quote
Sequence Example Output
\\ "This is a backslash: \\"
\" "\"Quotes!\""
\t "Before tab\tAfter tab"
\n "This is how\nto get a newline."
\' "\'Single quote\'"
This is a backslash: \
"Quotes!"
Before tab After tab
This is how to get a newline.
'Single quote'
Table 2.2 Escape Sequences
Lists
A list can hold zero or more pieces of data. A list that contains zero pieces of data is called an empty list. An empty list evaluates to false when used in an expression, whereas a non-empty list evaluates to true. List literals are expressed using the square bracket ( delimiters. List elements can be of any type, including lists.
[1, 2, 3, 4] [] ["one", 2, "three", [4, [5, [6]]]]
[])
Raw Bytes
Raw binary values are used primarily for efficient access to packet payloads. A literal notation is supported using single quotes:
'00112233445566778899AABBCCDDEEFF'
This represents an array of 16 bytes with values starting at 00 and ranging up to 0xFF. The values can only be hexadecimal digits. Each digit represents a nybble (four bits), and if there are not an even number of nybbles specified, an implicit zero is added to the first byte. For example:
'FFF'
is interpreted as
'0FFF'
null
null indicates an absence of valid data. The keyword null represents a literal null value and evaluates to false when used in expressions.
result = null;
4 LeCroy Corporation
File-based Decoding User Manual Chapter 2: Values

2.2 Variables

Variables are used to store information, or data, that can be modified. A variable can be thought of as a container that holds a value.
All variables have names. Variable names must contain only alphanumeric characters and the underscore ( variable names are
x _NewValue name_2
A variable is created when it is assigned a value. Variables can be of any value type, and can change type with re-assignment. Values are assigned using the assignment operator ( = ). The name of the variable goes on the left side of the operator, and the value goes on the right:
x = [ 1, 2, 3 ] New_value = x name2 = "Smith"
If a variable is referenced before it is assigned a value, it evaluates to null.
There are two types of variables: global and local.
_ ) character, and they cannot begin with a number. Some possible
Global Variables
Global variables are defined outside of the scope of functions. Defining global variables requires the use of the keyword set. Global variables are visible throughout a file (and all files that it includes).
set Global = 10;
If an assignment in a function has a global as a left-hand value, a variable is not created, but the global variable is changed. For example:
set Global = 10;
Function() {
Global = "cat"; Local = 20;
}
creates a local variable called Local, which is only visible within the function Function. Additionally, it changes the value of Global to "cat" This also changes its value type from an integer to a string.
, which is visible to all functions.
LeCroy Corporation 5
Chapter 2: Values File-based Decoding User Manual
Local Variables
Local variables are not declared. Instead, they are created as needed. Local variables are created either by being in a function's parameter list, or simply by being assigned a value in a function body.
Function(Parameter) {
Local = 20;
}
This function creates a local variable Parameter and a local variable Local, which has an assigned value of 20.

2.3 Constants

A constant is similar to a variable, except that its value cannot be changed. Like variables, constant names must contain only alphanumeric characters and the underscore ( _ ) character, and they cannot begin with a number.
Constants are declared similarly to global variables using the keyword const:
const CONSTANT = 20;
They can be assigned to any value type, but generates an error if used in the left-hand side of an assignment statement later on. For example:
const constant_2 = 3;
Function() {
constant_2 = 5;
}
generates an error.
Declaring a constant with the same name as a global, or a global with the same name as a constant, also generates an error. Like globals, constants can only be declared in the file scope.
6 LeCroy Corporation
File-based Decoding User Manual Chapter 3: Expressions

Chapter 3: Expressions

An expression is a statement that calculates a value. The simplest type of expression is assignment:
x = 2
The expression x = 2 calculates 2 as the value of x.
All expressions contain operators, which are described in Chapter 4, Operators, on page
9. The operators indicate how an expression should be evaluated in order to arrive at its
value. For example
x + 2
says to add 2 to x to find the value of the expression. Another example is
x > 2
which indicates that x is greater than 2. This is a Boolean expression, so it evaluates to either true or false. Therefore, if x = 3, then x > 2 evaluates to true; if x = 1, it returns false.
True is denoted by a non-zero integer (any integer except 0), and false is a zero integer (0). True and false are also supported for lists (an empty list is false, while all others are true), and strings (an empty string is false, while all others are true), and null is considered false. However, all Boolean operators result in integer values.
LeCroy Corporation 7
Chapter 3: Expressions File-based Decoding User Manual

3.1 select expression

The select expression selects the value to which it evaluates based on Boolean expressions. This is the format for a select expression:
select {
<expression1> : <statement1> <expression2> : <statement2> ...
};
The expressions are evaluated in order, and the statement that is associated with the first true expression is executed. That value is what the entire expression evaluates to.
x = 10 Value_of_x = select {
x < 5 : "Less than 5"; x >= 5 : "Greater than or equal to 5";
};
The above expression evaluates to “Greater than or equal to 5” because the first true expression is x >= 5. Note that a semicolon is required at the end of a select expression because it is not a compound statement and can be used in an expression context.
There is also a keyword default, which in effect always evaluates to true. An example of its use is
Astring = select {
A == 1 : "one"; A == 2 : "two"; A == 3: "three"; A > 3 : "overflow"; default : null;
};
If none of the first four expressions evaluates to true, then default is evaluated, returning a value of null for the entire expression.
select expressions can also be used to conditionally execute statements, similar to C switch statements:
select {
A == 1 : DoSomething(); A == 2 : DoSomethingElse(); default: DoNothing();
};
In this case the appropriate function is called depending on the value of A, but the evaluated result of the select expression is ignored.
8 LeCroy Corporation
File-based Decoding User Manual Chapter 4: Operators

Chapter 4: Operators

An operator is a symbol that represents an action, such as addition or subtraction, that can be performed on data. Operators are used to manipulate data. The data being manipulated are called operands. Literals, function calls, constants, and variables can all serve as operands. For example, in the operation
x + 2
the variable x and the integer 2 are both operands, and + is the operator.

4.1 Operations

Operations can be performed on any combination of value types, but results in a null value if the operation is not defined. Defined operations are listed in the Operand Types column of Table 4.2 on page 11. Any binary operation on a null and a non-null value results in the non-null value. For example, if
x = null
then
3 * x
returns a value of 3.
A binary operation is an operation that contains an operand on each side of the operator, as in the preceding examples. An operation with only one operand is called a unary operation, and requires the use of a unary operator. An example of a unary operation is
!1
which uses the logical negation operator. It returns a value of 0.

4.2 Operator Precedence and Associativity

Operator rules of precedence and associativity determine in what order operands are evaluated in expressions. Expressions with operators of higher precedence are evaluated first. In the expression
4 + 9 * 5
the * operator has the highest precedence, so the multiplication is performed before the addition. Therefore, the expression evaluates to 49.
The associative operator () is used to group parts of the expression, forcing those parts to be evaluated first. In this way, the rules of precedence can be overridden.
For example,
( 4 + 9 ) * 5
causes the addition to be performed before the multiplication, resulting in a value of 65.
LeCroy Corporation 9
Chapter 4: Operators File-based Decoding User Manual
When operators of equal precedence occur in an expression, the operands are evaluated according to the associativity of the operators. This means that if an operator's associativity is left to right, then the operations is done starting from the left side of the expression. So, the expression
4 + 9 - 6 + 5
would evaluate to 12. However, if the associative operator is used to group a part or parts of the expression, those parts are evaluated first. Therefore,
( 4 + 9 ) - ( 6 + 5 )
has a value of 2.
In Table 4.1, Operator Precedence and Associativity, the operators are listed in order of precedence, from highest to lowest. Operators on the same line have equal precedence, and their associativity is shown in the second column.
Operator Symbol Associativity
++ --
[] ()
~ ! sizeof head tail first next more
last prev
*/%
+-
<< >>
< > <= >=
== !=
&
^
|
&&
||
= += -= *= /= %= >>= <<= &= ^= |=
Table 4.1 Operator Precedence and Associativity
Right to left
Left to right
Right to left
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Right to left
10 LeCroy Corporation
File-based Decoding User Manual Chapter 4: Operators
Operator Symbol Description Operand Types
Result Types Examples
Index Operator
[ ] Index or subscript Raw Bytes Integer Raw = '001122'
Raw[1] = 0x11
List Any List = [0, 1, 2, 3, [4, 5]]
List[2] = 2 List[4] = [4, 5] List[4][1] = 5
*Note: if an indexed Raw value is assigned to any value that is not a byte ( > 255 or not an integer), the variable is promoted to a list before the assignment is performed.
Associative Operator
( ) Associative Any Any ( 2 + 4 ) * 3 = 18
2 + ( 4 * 3 ) = 14
Arithmetic Operators
* Multiplication Integer-integer Integer 3 * 1 = 3
/ Division Integer-integer Integer 3 / 1 = 3
% Modulus Integer-integer Integer 3 % 1 = 0
+ Addition Integer-integer Integer 2 + 2 = 4
String-string Strin g "one " + "two" = "one two"
Raw byte-raw byte Raw '001122' + '334455' = '001122334455'
List-list List [1, 2] + [3, 4] = [1, 2, 3, 4]
Integer-list List 1 + [2, 3] = [1, 2, 3]
Integer-string Strin g "number = " + 2 = "number = 2"
*Note: integer-string concatenation uses decimal conversion.
String-list List "one" + ["two"] = ["one", "two"]
- Subtraction Integer-integer Integer 3 – 1 = 2
Increment and Decrement Operators
++ Increment Integer Integer a = 1
-- Decrement Integer Integer a = 2
++a = 2
b = 1 b++ = 1
*Note that the value of b after execution is 2.
--a = 1
b = 2 b-- = 2
*Note that the value of b after execution is 1.
Table 4.2 Operators
LeCroy Corporation 11
Chapter 4: Operators File-based Decoding User Manual
Operator Symbol Description Operand Types
Result Types Examples
Equality Operators
== Equal Integer-integer Integer 2 == 2
String-string Integer "three" == "three"
Raw byte-raw byte Integer '001122' == '001122'
List-list Integer [1, [2, 3]] == [1, [2, 3]]
!= Not equal Integer-integer Integer 2 != 3
String-string Integer "three" != "four"
Raw byte-raw byte Integer '001122' != '334455'
List-list Integer [1, [2, 3]] != [1, [2, 4]]
Relational Operators
< Less than Integer-integer Integer 1 < 2
String-string Integer "abc" < "def"
> Greater than Integer-integer Integer 2 > 1
String-string Integer "xyz" > "abc"
<= Less than or equal Integer-integer Integer 23 <= 27
String-string Integer "cat" <= "dog"
>= Greater than or
equal
Integer-integer Integer 2 >= 1
String-string Integer "sun" >= "moon"
*Note: equality operations on values of different types evaluates to false.
*Note: equality operations on values of different types evaluates to false.
*Note: relational operations on string values are evaluated according to character order in the ASCII table.
Logical Operators
! Negation All combinations of types Integer !0 = 1 !"cat" = 0
!9 = 0 !"" = 1
&& Logical AND All combinations of types Integer 1 && 1 = 1 1 && !"" = 1
|| Logical OR All combinations of types Integer 1 || 1 = 1 0 || 0 = 0
1 && 0 = 0 1 && "cat" = 1
1 || 0 = 1 "" || !"cat" = 0
Table 4.2 Operators (Continued)
12 LeCroy Corporation
File-based Decoding User Manual Chapter 4: Operators
Operator Symbol Description Operand Types
Result Types Examples
Bitwise Logical Operators
~ Bitwise
complement
& Bitwise AND Integer-integer Integer 0b11111110 & 0b01010101 = 0b01010100
^ Bitwise exclusive ORInteger-integer Integer 0b11111110 ^ 0b01010101 = 0b10101011
| Bitwise inclusive ORInteger-integer Integer 0b11111110 | 0b01010101 = 0b11111111
Integer-integer Integer ~0b11111110 = 0b00000001
Shift Operators
<< Left shift Integer-integer Integer 0b11111110 << 3 = 0b11110000
>> Right shift Integer-integer Integer 0b11111110 >> 1 = 0b01111111
Assignment Operators
= Assignment Any Any A = 1
B = C = A
+= Addition
assignment
-= Subtraction assignment
*= Multiplication
assignment
/= Division
assignment
%= Modulus
assignment
>>= Right shift
assignment
<<= Left shift
assignment
Integer-integer Integer x = 1
x += 1 = 2
String-string Strin g a = "one "
a += "two" = "one two"
Raw byte-raw byte Raw z = '001122'
z += '334455' = '001122334455'
List-list List x = [1, 2]
x += [3, 4] = [1, 2, 3, 4]
Integer-list List y = 1
y += [2, 3] = [1, 2, 3]
Integer-string Strin g a = "number = "
a += 2 = "number = 2"
*Note: integer-string concatenation uses decimal conversion.
String-list List s = "one"
s + ["two"] = ["one", "two"]
Integer-integer Integer y = 3
y –= 1 = 2
Integer-integer Integer x = 3
x *= 1 = 3
Integer-integer Integer s = 3
s /= 1 = 3
Integer-integer Integer y = 3
y %= 1 = 0
Integer-integer Integer b = 0b11111110
b >>= 1 = 0b01111111
Integer-integer Integer a = 0b11111110
a <<= 3 = 0b11111110000
Table 4.2 Operators (Continued)
LeCroy Corporation 13
Chapter 4: Operators File-based Decoding User Manual
Operator Symbol Description Operand Types
Result Types Examples
Assignment Operators (continued)
&= Bitwise AND
assignment
^= Bitwise exclusive
OR assignment
|= Bitwise inclusive
OR assignment
Integer-integer Integer a = 0b11111110
a &= 0b01010101 = 0b01010100
Integer-integer Integer e = 0b11111110
e ^= 0b01010101 = 0b10101011
Integer-integer Integer i = 0b11111110
i |= 0b01010101 = 0b11111111
List Operators
sizeof() Number of
elements
head() Head List Any head([1, 2, 3]) = 1
tail() Ta i l List List tail([1, 2, 3]) = [2, 3]
first() Returns the first
element of the list and resets the list iterator to the beginning of the list
next() Returns the next
element of the list relative to the previous position of the list iterator
Any Integer sizeof([1, 2, 3]) = 3
sizeof('0011223344') = 5 sizeof("string") = 6 sizeof(12) = 1 sizeof([1, [2, 3]]) = 2
*Note: the last example demonstrates that the sizeof() operator returns the shallow count of a complex list.
*Note: the Head of a list is the first item in the list.
*Note: the Tail of a list includes everything except the Head.
List Any list = [1, 2, 3];
for( item = first(list);
more(list); item = next(list) )
{
ProcessItem( item );
}
List Any list = [1, 2, 3];
for( item = first(list);
more(list); item = next(list) )
{
ProcessItem( item );
}
Table 4.2 Operators (Continued)
14 LeCroy Corporation
File-based Decoding User Manual Chapter 4: Operators
Operator Symbol Description Operand Types
more() Returns a non-zero
value if the list iterator did not reach the bounds of the list
last() Returns the last
element of the list and resets the position of the list iterator to the end of the list
prev() Returns the
previous element in the list relative to the previous position of the list iterator
List Integer list = [1, 2, 3];
List Any list = [1, 2, 3];
List Any list = [1, 2, 3];
Table 4.2 Operators (Continued)
Result Types Examples
for( item = first(list);
more(list); item = next(list) )
{
ProcessItem( item );
}
for( item = last(list);
more(list); item = prev(list) )
{
ProcessItem( item );
}
for( item = last(list);
more(list); item = prev(list) )
{
ProcessItem( item );
}
LeCroy Corporation 15
Chapter 4: Operators File-based Decoding User Manual
16 LeCroy Corporation
File-based Decoding User Manual Chapter 5: Comments

Chapter 5: Comments

Comments may be inserted into scripts as a way of documenting what the script does and how it does it. Comments are useful as a way to help others understand how a particular script works. Additionally, comments can be used as an aid in structuring the program.
Most comments in CSL begin with a hash mark (#) and finish at the end of the line. The end of the line is indicated by pressing the Return or Enter key. Anything contained inside the comment delimiters is ignored by the compiler. Thus,
# x = 2;
is not considered part of the program. CSL supports only end-of-line comments of this type (comments that can be used only at the end of a line or on their own line). It's not possible to place a comment in the middle of a line using the hash mark.
Writing a multi-line comment requires either beginning each line with the hash mark (and ending that line with a Return or Enter) or using a comment block.
A comment block begins with "/*" and end with "*/". Everything inside of the comment block is ignored.
Example of a multi-line comment with comment delimiters on each line:
# otherwise the compiler would try to interpret # anything outside of the delimiters # as part of the code.
Example of a multi-line comment block:
/* The compiler ignores all contents of the block comment. */
The most common use of comments is to explain the purpose of the code immediately following the comment. For example:
# Add a profile if we got a server channel if(rfChannel != "Failure") {
result = SDPAddProfileServiceRecord(rfChannel,
"ObjectPush");
Trace("SDPAddProfileServiceRecord returned ", result, "\n"); }
LeCroy Corporation 17
Chapter 5: Comments File-based Decoding User Manual
18 LeCroy Corporation
File-based Decoding User Manual Chapter 6: Keywords

Chapter 6: Keywords

Keywords are reserved words that have special meanings within the language. They cannot be used as names for variables, constants or functions.
In addition to the operators, the following are keywords in CSL:
Keyword Usage
select select expression
set Define a global variable
const Define a constant
return return statement
while while statement
for for statement
if if statement
else if-else statement
default select expression
null Null value
in Input context
out Output context
Table 6.1 Keywords
LeCroy Corporation 19
Loading...
+ 57 hidden pages