Implicit type conversion, Special directives, Table 5-6. blockscript special directives – National Instruments AutoCode NI MATRIX User Manual

Page 144: Implicit type conversion -36, Special directives -36

Advertising
background image

Chapter 5

Generated Code Architecture

AutoCode Reference

5-36

ni.com

for i = 1:y.size do

y(i) = 0.0;

endif;

endif;

Example 5-17

Generated Code for BlockScript Block Example 5-16

/***** Output Update. *****/

/* ---------------------------- BlockScript Block */

/* {deadbsb..2} */

for (i=1; i<=5; i++) {

deadbsb[-1+i] = U->deadbsb[-1+i]/0.001;

}

Notice that in the generated code, only the true-branch of the BlockScript

if

statement is generated, and that the local variable threshold was

hard-coded.

Implicit Type Conversion

Compared to Ada and even C, BlockScript is a very loosely typed
language. Thus, you can ignore most data type issues and focus on the
algorithm. However, when translated to code, there might be excessive data
type conversions that severely penalize performance. NI recommends that
if you want to maximize the performance of the generated code, you
eliminate any implicit conversions in your BlockScript block.

Special Directives

The BlockScript language allows special directives that force certain
attributes or conditions to be applied. Table 5-6 describes the currently
supported directives.

For more information about BlockScript, refer to the BlockScript User
Guide
or the MATRIXx Help.

Table 5-6. BlockScript Special Directives

Directive

Description

Example

{volatile}

Forces the declaration of the listed variable(s)
in the generated code.

{volatile} integer data;

{unroll}

Forces the loop to be unrolled instead of
rolled. Only effective when vectorizing code
or when nesting beyond the 8-level limit.

{unroll} for i = 1:10 do

Advertising