Instruments Corporation. National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.
Page 4
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 options to a final action.
Chapter 1 Introduction • • This guide also has an Index. General Information As an integral part of the rapid prototyping concept, AutoCode lets you generate high-level language code from a SystemBuild block diagram model quickly, automatically, and without programming skills. The AutoCode User Guide describes the processes for generating code, including the parameters that you must use.
Chapter 1 Introduction 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: • • • • •...
This section describes the system-specific and target-specific stand-alone System-Specific Files National Instruments furnishes files to interface AutoCode and the generated code to your development platform (AIX, Compaq, HP, SGI, Solaris, Windows) and to the target processor in your test bed or rapid-prototyping system.
Page 21
Chapter 2 C Language Reference sa_sys.h sa_types.h sa_defn.h sa_intgr.h sa_fuzzy.h sa_utils.h sa_math.h sa_time.h sa_user.h Data Types Several of the target-specific utilities are involved with data types (in the the C Code Generator: RT_FLOAT RT_INTEGER RT_BOOLEAN At compilation, you must make available the which declares these types.
Chapter 2 C Language Reference Implementation_Terminate( ) External_Input( ) External_Output( ) Signal_Remote_Dispatch( ) are used for comparing simulation with generated code results. After you generate code, link the generated code with (refer to Chapter 2, Using AutoCode, of the AutoCode User Guide). For example, on UNIX platforms: cc -o gen_ap gen_ap .c $ISI/ACC/src/sa_*.o -l other libraries...
Chapter 2 C Language Reference the comments there and adjust the limits accordingly, then recompile and relink the ERROR OPENING THE INPUT FILE ERROR OPENING THE OUTPUT FILE A problem was encountered opening the input or output file. Possible causes include a file protection violation. UNKNOWN ERROR A value of the for the switch-case statement.
Chapter 2 C Language Reference External_Input ( ) Function RT_INTEGER External_Input(void) External_Input( ) reads in external input data from your specified appears in input vector ( conversion is required in this version of the generated code, because all data is passed as arrays of type SCHEDULER_STATUS and is passed to the target version of...
Page 29
Chapter 2 C Language Reference facility of the simulator in SystemBuild to distinguish between UCBs written for simulation purposes using SystemBuild only and UCBs written for linking with AutoCode applications. The exact name of the UCB function must be specified in the used for simulation using SystemBuild.
Page 31
Chapter 2 C Language Reference The operations within UCBs are controlled by the argument to a structure of type argument list for each UCB (located in typedef struct STATUS_RECORD The following example shows the general form of UCB equations for AutoCode and indicates how the control the computations.
Chapter 2 C Language Reference 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 the simulation engine (release 4.0 and later).
Chapter 2 C Language Reference applications, make sure you adapt the same algorithm in the body of a function using the AutoCode UCB arguments as in Variable Interface UCB The preceding sections described the fixed interface; however, a UCB can also use the variable interface option.
UCB. Function Prototype National Instruments recommends that you create a function prototype for your variable interface UCB functions. This will provide some additional checking that the compiler can do to ensure that the generated interface matches what you expected without your implementation of the UCB function.
Chapter 2 C Language Reference 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 create a “wrapper” function that interfaces between the Simulator and your code.
Chapter 2 C Language Reference Linking Procedures with Real-Time Applications or Simulator Generate reusable procedures from your Procedure SuperBlocks as described in this chapter and in Chapter 3, link generated reusable procedures with your own application or simulator you have the three following options: •...
Chapter 2 C Language Reference Several of the previous steps are exercised by the other two methods for invoking generated procedures described in the Real-Time Applications or Simulator Invoking Procedures Using Generated UCB Wrapper Function section and Use the generated UCB wrapper and subsystem code as a guide. The UCB wrapper is generated for the purpose of re-entrancy, thus producing extra copy in and out of parameter and states variables and control and status arrays, while the subsystem code is not re-entrant—that is, the states and...
Chapter 2 C Language Reference data-typed variables reflecting each subsystem input signal and type. The outputs to the subsystem are provided by the argument to a structure named data-typed variables reflecting each subsystem output signal and type. The following overall steps need to be taken to invoke the subsystem function: C Fixed-Point Arithmetic Fixed-point calculations provide significant advantages over floating-point...
Chapter 2 C Language Reference 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 using fixed-point variables—such as the examples provided in this chapter—will differ from code generated for models using floating-point, integer, or logical signals in the following areas:...
Page 51
Chapter 2 C Language Reference sa_fxsub_byte.c sa_fxsub_short.c sa_fxsub_long.c sa_fxmul_byte.c sa_fxmul_short.c sa_fxmul_long.c sa_fxdiv_byte.c sa_fxdiv_short.c sa_fx_f.c sa_fxp_f.c sa_fxm_f.c sa_fxdiv_long.c sa_fx_externs.c These stand-alone files have naming conventions based on the functionality of the macros and whether or not the macros support overflow protection. Refer to the contains macros performing arithmetic functions that do not have overflow protection, but file...
Page 53
Chapter 2 C Language Reference Figures 2-6 through 2-8 show how the conversion macros are named. Notice that macro names have no embedded spaces. sr wr ALIGN so wo p q(n, rp) For example, the macro to convert an unsigned 8-bit number to a signed 8-bit number with a shift of sbALIGNubp(n,rp) AutoCode Reference...
Chapter 2 C Language Reference 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 macros that are defined either in whether or not they are overflow protected. The macros for addition and subtraction also make use of addition and subtraction functions defined in sa_fxmp.c Figure 2-9 shows how the arithmetic macros are named.
Chapter 2 C Language Reference Implementation of the Addition and Subtraction Macros AutoCode has two implementations of the addition and subtraction macros: • • For example, when using wordsize extension in an 8-bit processor, addition of two 8-bit operands results in a 16-bit addition operation, because the 8-bit addition macro internally extends the wordsize of the operands from 8 bits to 16 bits.
Chapter 2 C Language Reference 0^1111111 (n2' = (127,r7) ___________ 0^0000000 (n3 = (0,r7) In Example 2-3, method 1 is more accurate than method 2, but it is also less efficient because it involves a 16-bit subtraction. This is important for those using 8-bit processors but will probably not be as significant for those using 16-bit or 32-bit processors.
Chapter 2 C Language Reference 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 division macros, refer to the SystemBuild User Guide.
Chapter 3 Ada Language Reference Solaris, UNIX HP-UX/DOS Windows 2000/NT/9x/DOS Supplied Templates ada_rt.tpl Template template uses Ada tasks to implement the scheduling mechanism for the model. This template supports fixed-point arithmetic. ada_sim.tpl Template scheduler. The subsystems and procedures of a model execute as fast as possible.
Page 66
Chapter 3 Ada Language Reference Table 3-2. Distribution Directories and Files (Continued) Category Templates Directory: $CASE/ACA/templates Templates: ada_intgr.tpl Compiled Template: ada_sim.dac Demos Directory: • • • • • For use with generated Ada code, mathematical functions are supplied in functions that are needed to support AutoCode/Ada generated programs can be found in the AutoCode/Ada supplied package These functions are required even if they are supported by your native Ada AutoCode Reference...
Chapter 3 Ada Language Reference Target-Specific Utilities The target-specific utilities in the perform hardware-, application-, and Ada-specific tasks that are required for simulation and testing. They can be modified to support the generated code on the target computer. As furnished, these routines simulate I/O operations that would occur in a simulation environment, using import files created using MATRIXx.
Chapter 3 Ada Language Reference Refer to the Chapter 14, UserCode Blocks, of the SystemBuild User Guide or the source listing of the USR01 routine for meanings of UCB errors. You are allowed to extend the scope of these messages, so it might be one of yours.
Chapter 3 Ada Language Reference These messages indicate that the sizes of the time vector and input array have exceeded one or more of the storage allocation size limits established very beginning of the stand-alone utilities file, just after the trademark notice.
Chapter 3 Ada Language Reference Calling UCBs Every one of the following arguments will be passed for each call to the UCB in the following order: INFO, T, U, NU, X, XD, NX, Y, NY, R_P, I_P Within the UCB, the elements of all the array variables ( U(U'first), U(U'first+1), ...
Chapter 3 Ada Language Reference Procedure SuperBlocks This section describes how to generate and link Procedure SuperBlocks. Generating Reusable Procedures Generate reusable procedures from your Procedure SuperBlocks as described in Chapter 2, Using AutoCode, of the AutoCode User Guide. You have an option to call the generated algorithmic procedures directly (refer to Example 3-1), passing it pointers to record objects as arguments, or you can call the hook routine with a fixed UCB calling style interface, passing it arguments, which are arrays and values.
Chapter 3 Ada Language Reference 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 arithmetic chapter that explains the basics of fixed-point arithmetic and the use of fixed-point arithmetic in SystemBuild models.
Chapter 3 Ada Language Reference 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. Figure 3-1 illustrates the imposed dependency. In the figure, a package that is beneath a package and connected to a package above it by an arrow is said to be dependent on the package that is above.
Chapter 3 Ada Language Reference System-Level Parameters to Generate User Types Table 3-6 describes new system-level parameters that are used to generate n_user_defined_type_i usertype_name_ls usertype_basename_ls Overflow Protection Overflow is defined as loss of significance—that is, a computation resulting in a value that cannot be represented in the range of a specific fixed-point type.
Page 84
Ada Code Generation and continue. Example 3-2 shows a sample transcript that should appear in the Xmath window during code generation. National Instruments Corporation.* Portions U.S. Patent. Compile the stand-alone files—Before compiling the generated Ada code, all of the stand-alone files must be compiled into the Ada Library.
Page 86
Chapter 3 Ada Language Reference FIXED_ADD FIXED_SUB FIXED_MUL FIXED_DIV FIXED_IDENTITY SIGNEDNEGATION UNSIGNEDNEGATION SIGNEDABS UNSIGNEDABS LESSTHAN GREATERTHAN LESSEQUAL GREATEREQUAL INTCAST INTCAST_TRUNC INTCAST_ROUND AutoCode Reference Table 3-9. Generic Function Summary Function Name Addition of two fixed-point values. Subtraction of two fixed-point values. Multiplication of two fixed-point values.
Chapter 3 Ada Language Reference 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 three functions: value. The functions are overloaded to accept values that are of a fixed-point type with radix 0.
Page 92
Chapter 3 Ada Language Reference The selection of the intermediate type is performed by the code generator. The selection involves a set of rules that rely upon word size extension. Word size extension is selecting a fixed-point type with a larger number of bits that can be used to represent model numbers.
Chapter 3 Ada Language Reference no chance of overflow. To support these issues there are three types of conversion functions: • • • These conversions are described in the following sections. Language-Defined Conversion The Ada language provides four data type conversions. The rules in Ada that govern the conversion are explicit except for one detail.
Chapter 3 Ada Language Reference The data in the used in the currently scoped subsystem or procedure. No assumptions can be made about the order within a given list parameter. However, the nth element in one list does relate to the nth element in another list, depending on the purpose of the lists.
Chapter 3 Ada Language Reference Toward 0 Away from 0 Positive Infinity Negative Infinity To Odd To Even • • No-Op Conversion Function The purpose of the so-called no-op conversion function is to provide a hint to the compiler to select the proper overloaded operator. Without such a hint, there can be situations where the selection of the appropriate overloaded operator is ambiguous.
Chapter 4 Generating Code for Real-Time Operating Systems Configuration Items The following is a list of configuration attributes for each type of AutoCode component. • • • • • • • • Table Syntax This section provides information about the RTOS configuration tables. AutoCode Reference Number of processors Scheduler priority...
Chapter 4 Generating Code for Real-Time Operating Systems Example 4-1 Processors Table Example rtos.processors = 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_priority. Example 4-2 shows an example of a scheduler priority table.
Chapter 4 Generating Code for Real-Time Operating Systems Example 4-4 Interrupt Table Example rtos.intrsupblk = Interrupt Priority ---------------------------------------------------------------------- catch_it sigio_io keypad Background Procedure SuperBlock Table Table 4-5 consists of configuration information for all background procedure SuperBlocks in the model. Each row is identified by the name of the SuperBlock.
Chapter 4 Generating Code for Real-Time Operating Systems Example 4-7 Processor IP Table Example rtos.IPprsrmap = Processor | IP Name -------------------------------------------------------------------- 127.0.0.1 133.65.32.111 Version Table Table 4-8 is a single element table consisting of the version number of the format of the configuration tables. The table is named Example 4-8 shows a version table.
Chapter 5 Generated Code Architecture 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 not appear.
Chapter 5 Generated Code Architecture • • Global Variable Block and %var Equivalence If a Global Variable Block and a %var use the same name, only one variable is generated and that variable will be used for all instances of the %var and Variable Block.
Chapter 5 Generated Code Architecture 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 translation.
Chapter 5 Generated Code Architecture 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 subsystem external inputs and the other the subsystem external outputs.
Chapter 5 Generated Code Architecture 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 include reusability and reentrancy. Therefore, for each instance of a call to a procedure SuperBlock within a subsystem, a set of static variables is created for each of the structures that describe the definition of the procedure.
Chapter 5 Generated Code Architecture Unrolled Interface There is another form of the procedural interface, the unrolled interface No-UY and outputs. The input/output signals are passed as separate arguments to the function. • • • Phases and Error Handling The phases and error handling within a Standard Procedure is equivalent to the implementation within a subsystem.
Page 124
Chapter 5 Generated Code Architecture mixed data-typed variables reflecting each procedure output signal and type. The states of the procedure are provided by the argument S, a pointer to a structure named double-buffered private states used in the procedure, a flag to toggle the private states from one buffer to another, and the states structures of all procedures nested in the procedure.
Chapter 5 Generated Code Architecture Extended Procedure Information Structure procedure SuperBlock’s only one additional element is generated. It is named type declaration (in C) with and without the are declared when generating Ada code. Example 5-2 Regular Procedure struct _proc1_info { RT_INTEGER iinfo[5];...
Chapter 5 Generated Code Architecture however, is to create additional space when declaring a variable of the structure’s type and for the new code generated with the which assumes the field exists in all procedure the old procedure cannot call a procedure generated with the extended field in the without the extended structure, it is not possible to generate valid code if Macro Procedure...
Chapter 5 Generated Code Architecture 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 variations of the Condition Block: Default, No-Default, and Sequential.
Chapter 5 Generated Code Architecture 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 follows as an array of floats representing pins 7 through 10.
Chapter 5 Generated Code Architecture 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 is generated in the State phase.
Chapter 5 Generated Code Architecture In Example 5-9, a hard-subscript, outputs. The reason the values of 1 through to the number of inputs ( the code is generated. AutoCode then can unroll the loop so as to translate y(i) Example 5-9 Hard-Subscript Used to Access an Array Inputs: Outputs: y;...
National Instruments does not recommend that you replace all uses of states with Note parameters. Rather, this section points out a special-case method to code a BlockScript block to produce more efficient code for simple cases of persistent data.
Page 142
Chapter 5 Generated Code Architecture Example 5-14 BlockScript Block Example with Updating of a Parameter Inputs: u; Outputs: y; Environment: (OUTPUT, INIT); Parameters: total; float u,y,total; if OUTPUT then if !INIT then total = total + u; else total = u; endif;...
Chapter 5 Generated Code Architecture 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. *****/ /* ---------------------------- /* {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 hard-coded.
Chapter 5 Generated Code Architecture Parameterized UCB Callout A UCB can be defined with %var parameterized data for the UCB’s real parameters ( generates code that passes the %var variable as the actual of the UCB callout. A new option, subsystem code and passes the temporary arrays as actuals of the UCB callout.
Chapter 5 Generated Code Architecture 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 input to the BREAK Block is TRUE, then the loop that is immediately enclosing the BREAK Block is exited.
Chapter 5 Generated Code Architecture 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 subsystems or procedures introduces arbitrary boundaries within the equation sorting that can affect the stability of the total system.
Chapter 5 Generated Code Architecture 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, and passes all of the necessary data to the callout.
Chapter 5 Generated Code Architecture • • 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_LOCSBYTE(x, y) The value of the local variable shared memory variable assume that the data type of Shared Memory Fixed-Point Callouts in AutoCode/C...
Page 156
Chapter 5 Generated Code Architecture Example 5-21 shows template code to generate the required structure and pointer. All of the necessary information about the shared variable blocks is accessible from within the template using parameter information. Example 5-21 Template Code to Generate Required Shared Variable Block Structures @IFF multiprocessor_b@@ @shared_count = 0@@ /****...
Chapter 5 Generated Code Architecture Shared Memory Callout Option AutoCode supports a shared memory callout for all access to elements in shared memory. Callouts are generated when the The previous discussion about shared variable blocks still applies. However, the generated code is different, and you must supply the definitions of the callouts.
Page 160
Chapter 5 Generated Code Architecture The formal argument represents the global reference number for which the variable block is being accessed. The default implementation of those simply calls the Leaving Non-Shared (Local) Critical Section The prototype of the callout for leaving a non-shared global variable block critical section is: void Leave_Local_Varblk_Section(RT_INTEGER index);...
Page 162
Chapter 5 Generated Code Architecture The first formal argument represents which processor the access is taking place on. Processor numbers are 1-based. The second formal argument represents the global reference number for which the variable block is being accessed. The following code uses the shared variable block generated code with callouts, using the Enter_Shared_Varblk_Section(1, 4);...
Chapter 6 Vectorized Code Generation 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 iinfo[4]; /******* Initialization.
Chapter 6 Vectorized Code Generation 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 of which pins are to be an array.
Chapter 6 Vectorized Code Generation 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 vector-labeled block are identical, provided the number of elements in the matrix matches the number in the vector.
Page 195
Chapter 7 Code Optimization iinfo[1] = 0; return; EXEC_ERROR: ERROR_FLAG[1] = iinfo[0]; iinfo[0]=0;}} AutoCode performs this optimization only if it is safe to do so. There could be circumstances that could potentially prevent this optimization from taking place. AutoCode looks for the presence of a write-to-the-same-variable block between the Read from Variable block statement and its use in later computations.
Chapter 7 Code Optimization 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 procedure is called.
Page 203
Chapter 7 Code Optimization Example 7-7 shows code generated without the reuse option, and Example 7-8 shows code generated from the same models with the maximal reuse option. Example 7-7 Code Fragment without Reuse Optimization /***** Local Block Outputs. *****/ RT_FLOAT model_2_1;...
Page 205
Chapter 7 Code Optimization All of the blocks can accept constants as inputs. If any input is available during code generation time as a constant, the constant is used instead of a symbol name (or variable name). This applies to blocks of both categories. One limitation to this optimization is that a block cannot propagate constants or even accept constants as inputs if its inputs or outputs contain vectors.
Chapter 7 Code Optimization input of the gain block and the expression 4 as the value of value 4. The command-line option for invoking this optimization is Optimizing with Matrix Blocks Outputs labeled as matrices are generated as vectors, so most matrix blocks can be optimized by following the rules you would follow for any other vectorized block: •...
Page 209
Chapter 7 Code Optimization If you have decided on the MatrixRightDivide block, the tips for optimizing the inputs are much the same as for the MatrixInverse block. In this case there are two inputs, A and B, and both are modified by the callout algorithm.
Chapter 8 AutoCode Sim Cdelay Scheduler 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 Policies The task characteristics that have the most impact on scheduler design are task type, and output posting policy.
Page 214
Chapter 8 AutoCode Sim Cdelay Scheduler Under the default AutoCode scheduler, the output of this system is as shown in Figure 8-2. The top signal (corresponding to the triggered task) shows a latency of two cycles relative to its trigger input (immediately below), while the lower signal (corresponding to the enabled task) shows a latency of three cycles relative to its enable input.
Page 216
Chapter 8 AutoCode Sim Cdelay Scheduler triggers/enables have gone high are queued for execution. Then, in stage D, ATR tasks whose output posting times have arrived and ANC tasks that have just been queued for execution in stage C are marked for output posting, which is stage E.
Page 218
Chapter 8 AutoCode Sim Cdelay Scheduler Now the inherent problem in the standard scheduler is clear. From launch to output posting, you suffer a two-cycle delay for triggered tasks, and a three-cycle delay for enabled tasks, instead of the standard unit cycle delay present on real-time hardware for free-running periodic tasks.
Chapter 8 AutoCode Sim Cdelay Scheduler 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 the task types to reflect changed output posting, enable, and retriggering policies.
Chapter 8 AutoCode Sim Cdelay Scheduler 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 changes to the default scheduler outside the scheduler pipeline, and embody the new output posting, enable, and retriggering policies.
Chapter 8 AutoCode Sim Cdelay Scheduler 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 register*/ In the generated code, the priorities of all DataStore registers in Alpha are stored in a single, file-scoped array called optimized away if Alpha is empty.
Chapter 8 AutoCode Sim Cdelay Scheduler 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 NoRetrigger_style_ATR_Idle global timeline enable policy, replacing it with the default sync...
Chapter 9 Global Scope Signals and Parameterless Procedures These new features address the following two uses: • • Data Monitoring/Injection Data monitoring is the ability to have read-only access signals within a subsystem from outside the subsystem by some external agent outside the scope of the SystemBuild model.
Chapter 9 Global Scope Signals and Parameterless Procedures Limitations This section identifies some of the limitations of scoped output. Unsupported Blocks The following list presents the blocks that do not support scoped outputs. • • • • Connection to External Output It is possible to connect a Global Scope output to a subsystem/system external output pin.
Carefully consider using this type of procedure, as it requires significant effort to design your model correctly without the safety net of AutoCode managing the generated variables. National Instruments recommends that only advanced users of SystemBuild and AutoCode use this feature.
Chapter 9 Global Scope Signals and Parameterless Procedures NI suggests that you adopt a naming convention for all of your global variables used Note for parameterless procedure signals. For example, specify all of the names with a leading “g,” like gThrottleValue Output Specification Procedure outputs are specified from the basic blocks that connect to the...
Chapter 9 Global Scope Signals and Parameterless Procedures You must write template code to customize the declarations of these variables, Note which includes usage of the Memory Address string because this is target/compiler specific information. Issues and Limitations This section identifies some other items that you should be aware of if you intend to use parameterless procedures.
Chapter 9 Global Scope Signals and Parameterless Procedures 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. Evaluate these warnings and verify that the generated code is what you expect.
Technical Support and Professional Services Visit the following sections of the National Instruments Web site at ni.com • • • If you searched your local office or NI corporate headquarters. Phone numbers for our worldwide offices are listed at the front of this manual. You also can visit...
Need help?
Do you have a question about the AutoCode NI MATRIX and is the answer not in the manual?
Questions and answers