VXi VT1422A 사용자 설명서

다운로드
페이지 529
210 Creating and Running Algorithms  
Program Flow
Control
Program flow control is limited to the conditional execution construct using 
if
 and else and return. Looping inside an algorithm function is not 
supported. The only "loop" is provided by repeatedly triggering the 
VT1422A. Each trigger event (either external or internal Trigger Timer) 
executes the main() function which calls each defined and enabled 
algorithm function. There is no goto statement.
Conditional Constructs
The VT1422A Algorithm Language provides the if-else construct in the 
following general form:
if (expressionstatement1 else statement2
If expression evaluates to non-zero statement1 is executed. If expression 
evaluates to zero, statement2 is executed. The else clause with its associated 
statement2 is optional. Statement1 and/or statement2 can be compound 
statement. That is { statement; statement; statement; ... }.
Exiting the Algorithm
The return statement allows terminating algorithm execution before 
reaching the end by returning control to the main() function. The return 
statement can appear anywhere in an algorithm. It is not required to include 
return statement to end an algorithm. The translator treats the end of an 
algorithm as an implied return.
Data Types
The data type for variables is always static float. However, decimal constant 
values without a decimal point or exponent character (".", "E" or "e"), as 
well as Hex and Octal constants are treated as 32-bit integer values. This 
treatment of constants is consistent with ANSI 'C'. To understand what this 
can mean, it is necessary to understand that not all arithmetic statements in 
an algorithm are actually performed within the VT1422A's DSP chip at 
algorithm run-time. Where expressions can be simplified, the VT1422A's 
translator (a function of the driver invoked by ALG:DEF) performs the 
arithmetic operations before downloading the executable code to the 
algorithm memory in the VT1422A. For example, look at the statement:
a = 5 + 8;
When the VT1422A's translator receives this statement, it simplifies it by 
adding the two integer constants (5 and 8) and storing the sum of these as the 
float constant 13. At algorithm run-time, the float constant 13 is assigned to 
the variable "a." Now, analyze this statement:
a = ( 3 / 4 ) * 12;
Again, the translator simplifies the expression by performing the integer 
divide for 3 / 4. This results in the integer value 0 being multiplied by 12 
which results in the float constant 0.0 being assigned to the variable "a" at 
run-time. This is obviously not what was wanted, but is exactly what the 
algorithm instructed.