National Instruments NI MATRIX - Manuals
National Instruments NI MATRIX – Manual in PDF format online.
Manuals:
Manual National Instruments NI MATRIX
Summary
Important Information Warranty The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. Nati...
Conventions The following conventions are used in this manual: < > Angle brackets that contain numbers separated by an ellipsis represent a range of values associated with a bit or signal name—for example, DIO<3..0>. » The » symbol leads you through nested menu items and dialog box optio...
© National Instruments Corporation v AutoCode Reference Contents Chapter 1Introduction Manual Organization ..................................................................................................... 1-1General Information .......................................................................
Contents © National Instruments Corporation xiii AutoCode Reference Variable Block Aliasing .................................................................... 9-4Monitored Signals within a Procedure SuperBlock .......................... 9-4Monitoring Procedure External Outputs .......................
© National Instruments Corporation 1-1 AutoCode Reference 1 Introduction This manual provides reference material for using AutoCode to write production quality code using graphical tools. Together with the AutoCode User Guide and the Template Programming Language User Guide , AutoCode documentation ...
Chapter 1 Introduction AutoCode Reference 1-2 ni.com • Chapter 8, AutoCode Sim Cdelay Scheduler , discusses the Sim Cdelay low-latency scheduler. • Chapter 9, Global Scope Signals and Parameterless Procedures , discusses additional signals and procedures. This guide also has an Index . General Infor...
Chapter 1 Introduction © National Instruments Corporation 1-3 AutoCode Reference Structure and Content of the Generated Code This reference includes detailed descriptions about what is generated for many of the blocks used within a model. Also, the framework of the generated code is discussed to sho...
Chapter 1 Introduction AutoCode Reference 1-4 ni.com Related Publications National Instruments provides a complete library of publications to support its products. In addition to this guide, publications that you may find particularly useful when using AutoCode include the following: • AutoCode User...
© National Instruments Corporation 2-1 AutoCode Reference 2 C Language Reference This chapter discusses files used to interface AutoCode and the generated C code to your specific platform and target processor. This chapter also describes target-specific utilities needed for simulation and testing. S...
Chapter 2 C Language Reference AutoCode Reference 2-2 ni.com Stand-Alone Library This section describes the system-specific and target-specific stand-alone ( sa ) files supplied with your system. System-Specific Files National Instruments furnishes files to interface AutoCode and the generated code ...
Chapter 2 C Language Reference © National Instruments Corporation 2-3 AutoCode Reference • The principal file is sa_utils.c , the stand-alone utilities file. At the time that you compile sa_utils.c and your generated code program, you must make the following header files available locally: sa_sys.h ...
Chapter 2 C Language Reference AutoCode Reference 2-4 ni.com Data Types Several of the target-specific utilities are involved with data types (in the sa_types.h file). The three following data types are defined for the C Code Generator: RT_FLOAT Corresponds to C type double or float, depending on yo...
Chapter 2 C Language Reference © National Instruments Corporation 2-5 AutoCode Reference to. For example, RT_INTEGER can be redefined as long int if arithmetic overflow becomes a problem on a given platform. Target-Specific Utilities Target-specific utilities (in sa_utils.c ) perform hardware, appli...
Chapter 2 C Language Reference AutoCode Reference 2-8 ni.com the comments there and adjust the limits accordingly, then recompile and relink the sa_utils.c file. ERROR OPENING THE INPUT FILE ERROR OPENING THE OUTPUT FILE A problem was encountered opening the input or output file. Possible causes inc...
Chapter 2 C Language Reference AutoCode Reference 2-10 ni.com External_Input ( ) Function RT_INTEGER External_Input(void) External_Input( ) is for use in the simulation comparison mode; it reads in external input data from your specified FSAVE input file. The data appears in XINPUT , an array of typ...
Chapter 2 C Language Reference © National Instruments Corporation 2-11 AutoCode Reference Linking Handwritten UCBs with AutoCode Applications To write code for UserCode Blocks (UCBs), refer to the sa_user.c file, which is provided in your src distribution directory. The sa_user.c file contains an ex...
Chapter 2 C Language Reference © National Instruments Corporation 2-13 AutoCode Reference Implementing Handwritten UCBs Arguments are passed for each call to the UCB in the following order: INFO, T, U, NU, X, XDOT, NX, Y, NY, R_P, and I_P Pointers to all of the arrays ( U , X , XD , Y , R_P , I_P ) ...
Chapter 2 C Language Reference AutoCode Reference 2-16 ni.com Linking Handwritten UCBs (for AutoCode) with SystemBuild After you have written a UCB to create an AutoCode application, you can use the same UCB for simulation. SystemBuild can automatically compile and link your UserCode function into t...
Chapter 2 C Language Reference AutoCode Reference 2-18 ni.com applications, make sure you adapt the same algorithm in the body of a function using the AutoCode UCB arguments as in sa_user.c . Variable Interface UCB The preceding sections described the fixed interface; however, a UCB can also use the...
Chapter 2 C Language Reference © National Instruments Corporation 2-19 AutoCode Reference As previously stated, the inputs and outputs of the UCB will have the same data type as specified in the model diagram. Inputs are passed by value while outputs are passed by reference. In addition, the “shape”...
Chapter 2 C Language Reference AutoCode Reference 2-20 ni.com Linking a Variable Interface UCB with the Simulator Unlike the fixed interface which provides an automatic method for linking with the Simulator, the variable interface is too complicated for that method. As a result, you are required to ...
Chapter 2 C Language Reference AutoCode Reference 2-22 ni.com Linking Procedures with Real-Time Applications or Simulator Generate reusable procedures from your Procedure SuperBlocks as described in this chapter and in Chapter 3, Ada Language Reference . To link generated reusable procedures with yo...
Chapter 2 C Language Reference AutoCode Reference 2-26 ni.com data-typed variables reflecting each subsystem input signal and type. The outputs to the subsystem are provided by the argument Y , a pointer to a structure named _Subsys_ number_out . This structure has mixed data-typed variables reflect...
Chapter 2 C Language Reference AutoCode Reference 2-28 ni.com language and replace the supplied macros (or functions) with your (assembly) functions so that you can take full advantage of the processor’s arithmetic capabilities. Generated Code with Fixed-Point Variables Code generated for models usi...
Chapter 2 C Language Reference AutoCode Reference 2-30 ni.com RT_SSHORT05 SS5; RT_SSHORT SS0; RT_SSHORT05 SS5_1; }; struct _Sys_ExtIn { RT_USHORT13 US13; RT_SSHORT14 SS14; }; /******* System Ext I/O type definitions. *******/ struct _Subsys_1_out subsys_1_out; struct _Sys_ExtIn sys_extin; static RT_...
Chapter 2 C Language Reference © National Instruments Corporation 2-31 AutoCode Reference The UTs appear as typedef statements in the generated C code. For example: typedef volts RT_SBYTE03; This code defines the data type called volts to be a signed byte with radix position 3. Overflow Protection O...
Chapter 2 C Language Reference AutoCode Reference 2-32 ni.com Macro Interface The macro interface files are: sa_types.h Updated to include fixed-point types. sa_fx.h Contains fixed-point conversion macros. sa_fxp.h Contains fixed-point conversion macros with overflow protection. sa_fxr.h Contains fi...
Chapter 2 C Language Reference © National Instruments Corporation 2-33 AutoCode Reference sa_fx_externs.c Contains definitions for extern variables such as mask buffers that are read only. Function Interface The function interface files are: sa_types.h Updated to include fixed-point types. sa_fxp.h ...
Chapter 2 C Language Reference © National Instruments Corporation 2-35 AutoCode Reference Fixed-Point Conversion and Arithmetic Macros Although this section explains different fixed-point operations in terms of macros, all of these operations are supported as functions in the function interface. Hen...
Chapter 2 C Language Reference AutoCode Reference 2-38 ni.com Arithmetic Macros The arithmetic macros perform addition, subtraction, multiplication, and division. The top level macros for arithmetic operations are present in the sa_fxm.h and sa_fxmp.h files. These macros in turn call the ALIGN macro...
Chapter 2 C Language Reference © National Instruments Corporation 2-39 AutoCode Reference Table 2-7 shows permissible operand and result sizes for the arithmetic macros. For example, the macro to add two 8-bit unsigned numbers with overflow protection and produce an unsigned 8-bit result is: ubADD_u...
Chapter 2 C Language Reference AutoCode Reference 2-40 ni.com Implementation of the Addition and Subtraction Macros AutoCode has two implementations of the addition and subtraction macros: • Macros that apply wordsize extension (also called extended intermediate types) to the two operands before ali...
Chapter 2 C Language Reference © National Instruments Corporation 2-41 AutoCode Reference Align the radix positions of n1 and n2 to the radix position of the result before subtracting (that is, shift n1 left by three bits, and shift n2 left by two bits). Place the aligned results in n1' and n2' and ...
Chapter 2 C Language Reference AutoCode Reference 2-42 ni.com 0^1111111 (n2' = (127,r7) , decimal value = .9921875) ___________ 0^0000000 (n3 = (0,r7) , decimal value = 0.0) In Example 2-3, method 1 is more accurate than method 2, but it is also less efficient because it involves a 16-bit subtractio...
Chapter 2 C Language Reference AutoCode Reference 2-44 ni.com in terms of speed, but is needed to compute an accurate result. By changing this behavior, you can speed up the operation if you are willing to give up some accuracy. Note For more information on the implementation of multiplication and d...
Chapter 2 C Language Reference © National Instruments Corporation 2-45 AutoCode Reference For example, the macro to check an 8-bit unsigned number and an 8-bit signed number for equality and produce a Boolean result is: boolEQ_ub_sb(n1,n2,rp1,rp2) Some Relevant Issues • The fixed-point macros used b...
© National Instruments Corporation 3-1 AutoCode Reference 3 Ada Language Reference This chapter discusses files used to interface AutoCode and the generated Ada code to your specific platform and target processor. This chapter also discusses target-specific utilities needed for simulation and testin...
Chapter 3 Ada Language Reference AutoCode Reference 3-2 ni.com Supplied Templates ada_rt.tpl Template The ada_rt.tpl template is the default when generating Ada code. This template uses Ada tasks to implement the scheduling mechanism for the model. This template supports fixed-point arithmetic. ada_...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-3 AutoCode Reference Stand-Alone Library This section describes the system-specific and target-specific stand-alone ( sa_* ) files supplied with your system. System-Specific Files Header and source files are supplied to interface ...
Chapter 3 Ada Language Reference AutoCode Reference 3-16 ni.com Ada Fixed-Point Arithmetic This section describes the implementation of fixed-point arithmetic in AutoCode/Ada. It is assumed that you are familiar with the Ada programming language. Note The SystemBuild User Guide has a fixed-point ari...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-17 AutoCode Reference Fixed-Point Data Types Fixed-point type declarations exist in the file named: sa_fxptypes_.a and is provided in the System-Specific Files src (source) directory. 1 This file contains the specification of the ...
Chapter 3 Ada Language Reference AutoCode Reference 3-18 ni.com Package Dependencies The fixed-point AutoCode/Ada architecture forces a dependency among the supplied and generated code for a model that uses any fixed-point types. This dependency affects compilation order within an Ada Library. Figur...
Chapter 3 Ada Language Reference AutoCode Reference 3-20 ni.com System-Level Parameters to Generate User Types Table 3-6 describes new system-level parameters that are used to generate the USER_TYPES package. Overflow Protection Overflow is defined as loss of significance—that is, a computation resu...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-21 AutoCode Reference frequently overflowing, a different data type should be selected. If you are concerned about performance and the use of an exception handler for detecting overflow, the generic functions can be changed. These...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-23 AutoCode Reference 4. Compile the generated files —Two source files are generated, gaintest.a and fxp_gaintest_.a , as shown in Figure 3-1. The imposed package dependencies (refer to the Package Dependencies section) require th...
Chapter 3 Ada Language Reference AutoCode Reference 3-24 ni.com Table 3-9. Generic Function Summary Function Name Purpose FIXED_ADD Addition of two fixed-point values. FIXED_SUB Subtraction of two fixed-point values. FIXED_MUL Multiplication of two fixed-point values. FIXED_DIV Division of two fixed...
Chapter 3 Ada Language Reference AutoCode Reference 3-26 ni.com Bit-Wise Functions A restricted set of bit-wise operations have been defined for certain fixed-point types. These functions exist in the SA_FIXED_BITWISE_FUNCTIONS package found in the sa_fxpbit_.a and sa_fxpbit.a files. The set of bit-...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-27 AutoCode Reference Conversion Function Instantiations The RT_FIXED_OPERATORS package contains instantiations of functions that represent conversion of values to and from a fixed-point type. The appropriate generic function from...
Chapter 3 Ada Language Reference AutoCode Reference 3-28 ni.com Sample Package Example 3-3 shows a generated RT_FIXED_OPERATORS package. Example 3-3 Generated RT_FIXED_OPERATORS Package --------------------------------------------------------------------------- -- AutoCode/Ada (TM) Code Generator 7....
Chapter 3 Ada Language Reference © National Instruments Corporation 3-29 AutoCode Reference function “>=” is new SA_FIXED_GENERICS.GREATEREQUAL(SA_FIXED.RT_SSHORT14, SA_FIXED.RT_SSHORT08); --pragma inline (">="); function ">=" (LEFT, RIGHT : SA_FIXED.RT_SSHORT13) return BOOL...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-31 AutoCode Reference Multiplication and Division Functions The predefined multiplication and division operators for fixed-point type based arguments are defined in Ada for any combination of fixed-point arguments. The result of t...
Chapter 3 Ada Language Reference AutoCode Reference 3-32 ni.com no chance of overflow. To support these issues there are three types of conversion functions: • Language-defined conversion • Truncation conversion • Explicit rounding conversion These conversions are described in the following sections...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-33 AutoCode Reference For these types of conversions, the language-defined conversion is used. In general, when an explicit conversion is required and there is no specification of which to choose, AutoCode/Ada will select the expl...
Chapter 3 Ada Language Reference AutoCode Reference 3-34 ni.com The data in the sp_fxp parameters represent the operators and conversion used in the currently scoped subsystem or procedure. No assumptions can be made about the order within a given list parameter. However, the n th element in one lis...
Chapter 3 Ada Language Reference © National Instruments Corporation 3-35 AutoCode Reference Known Ada Compiler Problems The architecture of AutoCode/Ada Fixed-Point heavily relies upon overloaded operators and generic function instantiation. For a large and complex model, the number of overloads and...
Chapter 3 Ada Language Reference AutoCode Reference 3-36 ni.com • Floating-Point Textual Representation —The values generated from a stand-alone simulation are converted to a textual (ASCII) representation. That representation in textual form might not quite be as accurate as possible. That is, the ...
© National Instruments Corporation 4-1 AutoCode Reference 4 Generating Code for Real-Time Operating Systems This chapter describes the RTOS configuration file and functionality provided for generating code for real-time operating systems. Real-Time Operating System Configuration File Code that is to...
Chapter 4 Generating Code for Real-Time Operating Systems AutoCode Reference 4-2 ni.com Configuration Items The following is a list of configuration attributes for each type of AutoCode component. • Number of processors • Scheduler priority • Subsystem Tasks – Priority – Stack Size – Processor – Mod...
Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporation 4-3 AutoCode Reference Table Naming Convention Tables are given a name to identify the contents of the data contained therein. Table names are specified in the same form as Xmath variables, partition.name . ...
Chapter 4 Generating Code for Real-Time Operating Systems AutoCode Reference 4-4 ni.com Example 4-1 Processors Table Example rtos.processors = 2 Scheduler Priority Table Table 4-2 is a single element table consisting of the priority assigned to the scheduler task. The table is named: scheduler_prior...
Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporation 4-5 AutoCode Reference Example 4-3 Subsystem Table Example rtos.subsys = Subsystem | Priority Stack Size Processor Mode Flags ------------------------------------------------------------------- 1 | 200 4096 ...
Chapter 4 Generating Code for Real-Time Operating Systems AutoCode Reference 4-6 ni.com Example 4-4 Interrupt Table Example rtos.intrsupblk = Interrupt | Priority Stack Size Processor Vector Mode Flags ---------------------------------------------------------------------- catch_it | 200 4096 1 255 N...
Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporation 4-7 AutoCode Reference Startup Procedure SuperBlock Table Table 4-6 consists of configuration information for all startup procedure SuperBlocks in the model. Each row is identified by the name of the SuperBl...
Chapter 4 Generating Code for Real-Time Operating Systems AutoCode Reference 4-8 ni.com Example 4-7 Processor IP Table Example rtos.IPprsrmap = Processor | IP Name -------------------------------------------------------------------- 1 | 127.0.0.1 2 | 133.65.32.111 Version Table Table 4-8 is a single...
© National Instruments Corporation 5-1 AutoCode Reference 5 Generated Code Architecture This chapter supplies more details about the content and framework of the generated code. This includes storage usage, various procedures, specialized blocks, and subsystems. This chapter is directed toward someo...
Chapter 5 Generated Code Architecture AutoCode Reference 5-2 ni.com Signal Naming A signal in the diagram is represented as a variable in the generated code. Within the diagram, signals can have two names: a label and a name . The signal’s label can appear in the diagram while a signal’s name does n...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-3 AutoCode Reference Global Storage In a strict modular programming paradigm, global storage is strictly avoided. However, global storage can be used safely and provides significant benefits in terms of code size and speed. T...
Chapter 5 Generated Code Architecture AutoCode Reference 5-4 ni.com • Write-To Variable Block (ALL Addressing mode) —These blocks execute after all other types of blocks within the subsystem, procedure or sequence frame. • Read-From/Write-To Variable Block (Element/Bit Addressing modes) —These varia...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-5 AutoCode Reference Subsystems This section describes the design and operation of subsystems. This includes: • Discrete and Continuous SuperBlocks Versus Subsystems • Block Ordering • Interface Layers • Scheduler External In...
Chapter 5 Generated Code Architecture AutoCode Reference 5-6 ni.com Top-Level SuperBlock The term Top-Level SuperBlock is often used. This term describes the SuperBlock that was the root of the Analyzer’s processing of the SuperBlock hierarchy into subsystems, that is, a starting point for the trans...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-7 AutoCode Reference Figure 5-1 illustrates the interface layers. The layers are described in the subsections shown in the figure. Figure 5-1. Interface Layering Diagram Scheduler External Interface Layer This layer refers to...
Chapter 5 Generated Code Architecture AutoCode Reference 5-8 ni.com Discrete Subsystem Interface Layer This layer comes in two variations to allow for both an optimized and general solution. The external interface to a discrete subsystem is represented by two structures, one representing the subsyst...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-9 AutoCode Reference This sample and hold mechanism guarantees deterministic behavior for all possible connectivities and is implemented using a technique called double buffering. Double buffering involves swapping of pointer...
Chapter 5 Generated Code Architecture AutoCode Reference 5-10 ni.com Procedure Data Procedure SuperBlocks have inputs, outputs and states independent of the subsystem from which the procedure is called. This is required to properly implement the characteristics of a procedure; those characteristics ...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-11 AutoCode Reference system, because ordering of the outputs in a single-rate system is maintained. In a multi-rate system, duplicates can be safely eliminated because of the sample and hold mechanism. The code to perform bo...
Chapter 5 Generated Code Architecture AutoCode Reference 5-12 ni.com Unrolled Interface There is another form of the procedural interface, the unrolled interface ( No-UY ). This interface does not use U - and Y -structures to pass the inputs and outputs. The input/output signals are passed as separa...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-15 AutoCode Reference foo_2_u.foo_1 = U->t_l_1; foo(&foo_2_u, &foo_2_y, &foo_2_i); foo_2_1 = foo_2_y.foo_2_1; iinfo[0] = foo_2_i.iinfo[0]; if( iinfo[0] != 0 ) { foo_2_i.iinfo[0] = 0; goto EXEC_ERROR; } /* -----...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-17 AutoCode Reference The parameter arrays RP (real parameters) and IP (integer parameters) in structure _ procedure name_i are used for storing parameter values used by algorithms of blocks in the procedure. During initializ...
Chapter 5 Generated Code Architecture AutoCode Reference 5-18 ni.com Extended Procedure Information Structure The -epi option specifies that additional elements to all standard procedure SuperBlock’s info structure are to be generated. Currently, only one additional element is generated. It is named...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-19 AutoCode Reference Notice the relative numbering within a task/procedure type. Also, be aware that standard procedures are not given a unique identifier for the purposes of the caller_id element. A standard procedure Super...
Chapter 5 Generated Code Architecture AutoCode Reference 5-20 ni.com however, is to create additional space when declaring a variable of the info structure’s type and for the new code generated with the -epi option, which assumes the field exists in all procedure info structures. However, the old pr...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-21 AutoCode Reference Asynchronous Procedures Asynchronous Procedures are procedures that are not regularly scheduled to be executed or directly called from a subsystem or Standard Procedure. In other words, these procedures ...
Chapter 5 Generated Code Architecture AutoCode Reference 5-22 ni.com Changing %var Values During Startup A special feature of the Startup allows the value of a %var to be set at run-time through a Global Variable Block that has the same name as the %var. Condition Block SystemBuild provides three va...
Chapter 5 Generated Code Architecture AutoCode Reference 5-24 ni.com In Example 5-5, alpha, beta, and gamma are the variables to be used as representations for the inputs. Alpha is a scalar representing the input from pin 1. Beta is an array of integers representing inputs pins 2 through 6. Gamma fo...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-25 AutoCode Reference Init, Output, and State Phases A subsystem has phases because the blocks within the subsystem need phases of computation. The three phases are intended to be used in a consistent way, just like the stand...
Chapter 5 Generated Code Architecture AutoCode Reference 5-26 ni.com Default Phase If you do not specify a phase and/or all code is not contained within an IF statement guarded by a phase environment variable, that code is generated in the Output phase and, if there is a State phase, that code also ...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-27 AutoCode Reference Local Variables and Phases A local variable cannot be used to pass data between phases, because the different phases occur at different locations in the execution order of the whole subsystem or procedur...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-29 AutoCode Reference Continuous Semantics The state data within a continuous subsystem are called States and State Derivatives. These look very similar to the discrete equivalents, except that State data is integrated by the...
Chapter 5 Generated Code Architecture AutoCode Reference 5-30 ni.com In Example 5-9, a hard-subscript, i , is used to access both inputs and outputs. The reason i is a hard-subscript is that the range of i —that is, the values of 1 through to the number of inputs ( u.size )—is known when the code is...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-31 AutoCode Reference Example 5-11 Local Variables Used to Allow Loops in Scalar Code Generation Inputs: u; Outputs: y; float u(:), y(u.size), local_u(u.size), local_y(y.size); integer i,j; for i = 1:u.size do local_u(i) = u(...
Chapter 5 Generated Code Architecture AutoCode Reference 5-32 ni.com • FOR Loop—Can generate either a rolled or unrolled loop depending upon the range of the loop subscript and whether or not scalar code is generated. Examples of Rolled and Unrolled Loops Example 5-12 Unrolled Loop from Example 5-9 ...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-33 AutoCode Reference Parameters Parameters represent data that can be used to provide data to tune the algorithm by representing coefficients in equations or persistent data somewhat like states. Parameters are implemented a...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-35 AutoCode Reference else { total = U->bsb_1; } Y->bsb_22_1 = total; INIT = 0; Optimizations When translating a BlockScript block into source code, certain optimizations are automatically done. These optimization can r...
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+...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-37 AutoCode Reference UserCode Block The purpose of the UserCode Block (UCB) is to interface your existing code with AutoCode-generated source code. A UCB is typically used to access low-level device drivers or any algorithm ...
Chapter 5 Generated Code Architecture AutoCode Reference 5-38 ni.com Parameterized UCB Callout A UCB can be defined with %var parameterized data for the UCB’s real parameters ( RP ) and integer parameters ( IP ). When used, AutoCode generates code that passes the % var var iable as the actual of the...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-39 AutoCode Reference Software Constructs These blocks provide the software constructs that are typically found in any imperative programming language such as C, Pascal, and FORTRAN. The following software constructs are supp...
Chapter 5 Generated Code Architecture AutoCode Reference 5-40 ni.com BREAK Block The WHILE construct indefinitely iterates unless a BREAK Block is executed within the loop. You are responsible for properly detecting an exit condition and using it as an input to a BREAK Block inside the loop. If the ...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-41 AutoCode Reference The Read from Variable Block optimization also is supported for Local Variable Blocks. Refer to Chapter 7, Code Optimization , for more details on optimization. Also, the sequencing of local variable blo...
Chapter 5 Generated Code Architecture AutoCode Reference 5-42 ni.com representative of a sequence of equations. These equations are sensitive (that is, potentially numerically unstable) to the integration algorithm and order in which the equations are computed. Introducing multiple continuous subsys...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-43 AutoCode Reference • Algebraic loops are not supported. • AutoCode only performs a single initialization pass at time = 0.0. This corresponds to the SystemBuild Simulation options of INITMODE=0 or ACTIMING . Multiprocessor...
Chapter 5 Generated Code Architecture AutoCode Reference 5-44 ni.com Distributed Memory Architecture AutoCode also supports a multiprocessor architecture that uses distributed memory instead of shared memory. AutoCode does this by generating callouts (that is, macros) instead of the explicit code, a...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-45 AutoCode Reference 3. Copy a block of local data into shared data: UPDATE_MBUF_WITH_LOCBLK(dest,src,size) 4. Copy shared data into local data: GET_LOCF_FROM_MBUFF(dest,src) GET_LOCB_FROM_MBUFB(dest,src) GET_LOCI_FROM_MBUFI...
Chapter 5 Generated Code Architecture AutoCode Reference 5-46 ni.com • SLONG stands for signed long. • ULONG stands for unsigned long. The naming convention of the callouts uses the terms listed above and associates from right to left. The following is an example of a callout. UPDATE_MBUFSBYTE_WITH_...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-47 AutoCode Reference UPDATE_MBUFF_WITH_MBUFUSHORT(x, y, convert_macro_name) UPDATE_MBUFSLONG_WITH_MBUFF(x, y, convert_macro_name) UPDATE_MBUFF_WITH_MBUFSLONG(x, y, convert_macro_name) UPDATE_MBUFULONG_WITH_MBUFF(x, y, conver...
Chapter 5 Generated Code Architecture AutoCode Reference 5-50 ni.com Shared Memory Callout Option AutoCode supports a shared memory callout for all access to elements in shared memory. Callouts are generated when the -smco option is specified. The previous discussion about shared variable blocks sti...
Chapter 5 Generated Code Architecture AutoCode Reference 5-52 ni.com The formal argument represents the global reference number for which the variable block is being accessed. The default implementation of those simply calls the Disable( ) function. Leaving Non-Shared (Local) Critical Section The pr...
Chapter 5 Generated Code Architecture © National Instruments Corporation 5-53 AutoCode Reference The formal argument represents the global reference number for which the variable block is being accessed. The second formal argument, caller_id , represents a unique identifier for the caller. The defau...
© National Instruments Corporation 6-1 AutoCode Reference 6 Vectorized Code Generation This chapter discusses various ways to generate vectorized code. This includes describing the options available, design guidelines, and implementation details about the vectorized code. Introduction AutoCode has t...
Chapter 6 Vectorized Code Generation AutoCode Reference 6-2 ni.com Scalar Gain Block Example Example 6-1 shows the scalar code generated for a gain block. Example 6-1 Scalar Code Generated for Gain Block Example void subsys_1(U, Y) struct _Sys_ExtIn *U; struct _Subsys_1_out *Y; { static RT_INTEGER i...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-3 AutoCode Reference where Y ( i ) is the i th output U ( i ) is the i th input GainParameter ( i ) is the i th gain value i is the range <1.. x >, where x is the number of outputs of the block As you can see from the co...
Chapter 6 Vectorized Code Generation AutoCode Reference 6-4 ni.com if (SUBSYS_PREINIT[1]) { iinfo[0] = 0; iinfo[1] = 1; iinfo[2] = 1; iinfo[3] = 1; for( cnt=0;cnt<10;cnt++ ) { R_P[cnt] = _R_P[cnt]; } SUBSYS_PREINIT[1] = FALSE; return; } /***** Output Update. *****/ /* ----------------------------...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-5 AutoCode Reference addition to issues with the standard block library, all general BlockScript Blocks within the diagram are implemented as 1-based arrays. If the subscript can be evaluated at generation-time, the 0-based su...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-7 AutoCode Reference /* ---------------------------- Gain Block */ /* {gain..2} */ Y->gain_2_1[0] = 1.2*U->gain_1[0]; Y->gain_2_1[1] = 2.3*U->gain_1[2]; Y->gain_2_1[2] = 3.4*U->gain_1[3]; Y->gain_2_1[3] = ...
Chapter 6 Vectorized Code Generation AutoCode Reference 6-8 ni.com Vector Labels and Names The SuperBlock Editor lets you give a name to a range of signals using a special notation. The Editor then repeatedly applies that name to the range. AutoCode interprets this type of labeling as a definition o...
Chapter 6 Vectorized Code Generation AutoCode Reference 6-14 ni.com k = k + 1; } } k = 1; for (i=1; i<=5; i++) { Y->delayed_pulse[-1+i] = X->sensor_delay[-1+k]; k = k + 1; } /* ---------------------------- Gain Block */ /* {VecEx..2} */ Throttle = -8.7*U->sensor_5; Pedal = -7.6*U->sen...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-15 AutoCode Reference Note The examples within this section assume maximal vectorization unless otherwise noted. Multiple Arrays within a Block All blocks support multiple vectors (arrays) as both outputs and inputs. However, ...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-17 AutoCode Reference The interesting part is that of the last gain block ( gain..99 ). Notice that although two distinct arrays are used as input, because the input arrays are connected contiguously, the code is rolled into t...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-19 AutoCode Reference The two producer gain blocks (top, bottom) vectorize as expected. The (gain..99) does not vectorize well. Notice that AutoCode was only able to vectorize two inputs while the remaining four were unrolled....
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-21 AutoCode Reference You should notice two things in the code shown in Example 6-8. First, the gain block added to merge the data is generated as copies from the respective inputs into the single array. Second, the integrator...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-23 AutoCode Reference Eliminating Copy-Back There are many design ways to eliminate or hide the extra copies of the copy-back. All of them can be categorized into two groups: • Use Mixed Vectorization mode and force scalars to...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-25 AutoCode Reference top[-1+i] = R_P[-1+i]*U->gain_1[-1+i]; } /* ---------------------------- Procedure Super Block */ /* {vecproc.3} */ vecproc(&top[0], &Y->vecproc_3_1[0], &vecproc_3_i); iinfo[0] = vecproc...
Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-27 AutoCode Reference ------ Swap state pointers. ------ XTMP := X; X := XD; XD := XTMP; INIT := FALSE; end; Vectorization of the BlockScript Block The general BlockScript block is commonly used to implement very complicated o...
Chapter 6 Vectorized Code Generation AutoCode Reference 6-28 ni.com Matrix Outputs When you provide matricized output labeling for a block, AutoCode generates the resulting “matrix” as a single-dimensional array, even in Ada. This means that the output of a matrix-labeled block and the output of a v...
© National Instruments Corporation 7-1 AutoCode Reference 7 Code Optimization This chapter explains the details of generating production quality code for micro controller-based applications. Generally, micro controller-based applications have stringent requirements for code size and execution speed....
Chapter 7 Code Optimization © National Instruments Corporation 7-5 AutoCode Reference Write to the same variable block. Due to the cyclic nature of loops, any Write to Variable block inside the loop appears in between the Read from Variable block outside the loop and its use inside the loop. Restart...
Chapter 7 Code Optimization AutoCode Reference 7-8 ni.com Merging INIT Sections Most of the dynamic blocks have explicit initialization, output update and state update sections. The initialization section is guarded by an INIT Boolean variable that is TRUE only for the first time a subsystem or a pr...
Chapter 7 Code Optimization © National Instruments Corporation 7-11 AutoCode Reference In Example 7-5, both time delay blocks have separate INIT sections. In Example 7-6, the initialization code for these blocks is merged along with the subsystem initialization section. Reuse of Temporary Block Outp...
Chapter 7 Code Optimization © National Instruments Corporation 7-13 AutoCode Reference } Y->model_5_1 = X->model_5_S1; /* ---------------------------- Gain Block */ /* {model..2} */ model_2_1 = 2.0*U->model_1; /* ---------------------------- Sum of Vectors */ /* {model..3} */ model_3_1 = mo...
Chapter 7 Code Optimization AutoCode Reference 7-16 ni.com input of the gain block and the expression 2.0 * const_2 is evaluated to 4 as the value of const_2_1 is 2. Hence, the subsystem output gets the value 4. The command-line option for invoking this optimization is -Opc . Optimizing with Matrix ...
Chapter 7 Code Optimization © National Instruments Corporation 7-17 AutoCode Reference constant block is optimized away, including the output variable. Also notice that the existing Constant Propagation optimization can be used with the constant block, but will only operate on scalar pieces of the c...
Chapter 7 Code Optimization © National Instruments Corporation 7-19 AutoCode Reference Summary All of the optimizations discussed so far can be used at the same time without limitations. All of these optimizations can work together and potentially bring about a cumulative effect in reducing the code...
Chapter 8 AutoCode Sim Cdelay Scheduler AutoCode Reference 8-2 ni.com real-time hardware. It assumes the reader is familiar with the concepts of AutoCode’s default scheduler. Refer to the AutoCode User Guide for more information about the scheduler, task types, and output posting. Task Posting Polic...
Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-3 AutoCode Reference Standard AutoCode Scheduler To illustrate the behavior of the standard AutoCode scheduler with triggered and enabled SuperBlocks, it is helpful to consider the diagnostic model shown in Figure 8-1, whic...
Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-5 AutoCode Reference Scheduler Pipeline section that these latencies are caused by the single posting stage per scheduler invocation in the default AutoCode scheduler, and by the output posting policy assigned to enabled bl...
Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-7 AutoCode Reference queue tasks stage for that scheduler invocation has already passed; thus, the triggered task cannot be queued for execution until 0.7 sec. At the time that it is queued, it sets its time delay for 0.1 s...
Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-9 AutoCode Reference Sim Cdelay Scheduler As stated at the outset, the goal of this project was to develop a new AutoCode scheduler, runnable on real-time targets, which mimics the behavior of Sim with Cdelay ( actiming off...
Chapter 8 AutoCode Sim Cdelay Scheduler AutoCode Reference 8-10 ni.com triggers arriving too quickly can prevent a task from ever posting any output. You must build an alternative AutoCode scheduler incorporating the new pipeline stages presented above, and change the transition diagrams of many of ...
Chapter 8 AutoCode Sim Cdelay Scheduler AutoCode Reference 8-12 ni.com These transition diagrams, together with the diagrams in Chapter 4, Managing and Scheduling Applications , of the AutoCode User Guide , define the behavior of tasks under the Sim with Cdelay scheduler. They encompass all of the c...
Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-13 AutoCode Reference DataStore Priority Problem As mentioned, you must find some way to enforce the priority of writers to DataStores in the generated code. Each DataStore register can be written to independently, so each ...
Chapter 8 AutoCode Sim Cdelay Scheduler AutoCode Reference 8-14 ni.com for tsk <- low_prio_tsk..high_prio_tsk do { /* loop from low to high priority */ if tsk.ready_to_post_outputs() if tsk.prio() > reg_prio /* higher priorities are larger */ write_register(tsk.output()); /*write to datastore ...
Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-15 AutoCode Reference Figure 8-8. Latencies Present in the AutoCode Scheduler Template Configuration for Enhanced Performance As mentioned in a previous section, there are drawbacks to re-executing an ATR task when it is re...
Chapter 8 AutoCode Sim Cdelay Scheduler AutoCode Reference 8-16 ni.com At the template level, the default Sim with Cdelay ATR triggered task behavior of re-queueing a task for execution on receipt of a new trigger before the outputs have been posted can be turned off by replacing the segment call Si...
Chapter 9 Global Scope Signals and Parameterless Procedures AutoCode Reference 9-2 ni.com These new features address the following two uses: • Data Monitoring/Injection —The safe access to local subsystem signals for the purpose of monitoring the signal’s value during the execution of the model. Thi...
Chapter 9 Global Scope Signals and Parameterless Procedures © National Instruments Corporation 9-3 AutoCode Reference memory address, and that string is accessible through template tokens during code generation. Note Be careful when selecting only a partial subset of block outputs as Global Scope wh...
Chapter 9 Global Scope Signals and Parameterless Procedures © National Instruments Corporation 9-5 AutoCode Reference Parameterless Procedure A parameterless (argument-less) procedure is a procedure that uses global variable(s) to pass input(s) into and/or output(s) out of the procedure. Each input ...
Chapter 9 Global Scope Signals and Parameterless Procedures AutoCode Reference 9-6 ni.com Note NI suggests that you adopt a naming convention for all of your global variables used for parameterless procedure signals. For example, specify all of the names with a leading “g,” like gThrottleValue . Out...
Chapter 9 Global Scope Signals and Parameterless Procedures © National Instruments Corporation 9-7 AutoCode Reference Condition Block Code Generation The Condition Block supports the use of parameterless procedures. In the nodefault and sequential modes, the Condition Block will not buffer the globa...
Chapter 9 Global Scope Signals and Parameterless Procedures AutoCode Reference 9-8 ni.com Note You must write template code to customize the declarations of these variables, which includes usage of the Memory Address string because this is target/compiler specific information. Issues and Limitations...
Chapter 9 Global Scope Signals and Parameterless Procedures © National Instruments Corporation 9-9 AutoCode Reference Connection to External Output If a signal that is used as input to a Global Scope procedure input or a Global Scope procedure output is connected to a external output pin, be aware t...
Chapter 9 Global Scope Signals and Parameterless Procedures AutoCode Reference 9-10 ni.com Analyzer and AutoCode Warnings The Analyzer reports questionable connectivities or situations regarding usage of the Global Scope signals. Also, AutoCode might report additional warnings during code generation...
National Instruments Manuals
-
National Instruments SCC-AI01
Manual
-
National Instruments USB-6008/6009
Manual
-
National Instruments 7334
Manual
-
National Instruments NI 9403E
Manual
-
National Instruments DIO 6533
Manual
-
National Instruments NI PCI-5114
Manual
-
National Instruments 1000DC
Manual
-
National Instruments 321518A-01
Manual
-
National Instruments NI 5672
Manual
-
National Instruments USB-9221
Manual
-
National Instruments PCI
Manual
-
National Instruments NI 9229
Manual
-
National Instruments 6211
Manual
-
National Instruments NI 9217
Manual
-
National Instruments NI USB-6009
Manual
-
National Instruments NI sbRIO-960x
Manual
-
National Instruments 6024E
Manual
-
National Instruments 3.x
Manual
-
National Instruments NI 784xR
Manual
-
National Instruments NI-Motion
Manual