用户手册目录AutoCode Reference1Support2Worldwide Technical Support and Product Information2National Instruments Corporate Headquarters2Worldwide Offices2Important Information3Warranty3Copyright3Trademarks3Patents3WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS3Conventions4Contents5Chapter 1 Introduction14Manual Organization14General Information15Configuration File15Language-Specific Information15Structure and Content of the Generated Code16Using MATRIXx Help16Additional Netscape Information16Related Publications17Chapter 2 C Language Reference18Stand-Alone Simulation18Compiling on Various Supported Platforms18Table 2-1. Recognized C Preprocessor Defines for Supported Platforms19Stand-Alone Library19System-Specific Files19Table 2-2. Distribution Directories and Files19Table 2-3. Header Files21Target-Specific Utilities22Table 2-4. Target-Specific Utility Routines22enable( ), disable( ), and background( ) Functions23error( ) and fatalerr( ) Functions23fatalerr( ): Stand-Alone Utilities Detected Errors24ERROR: Conditions Detected in the Generated Code25Implementation_Initialize( ) Function26Implementation_Terminate( ) Function26External_Input ( ) Function27External_Output ( ) Function27UserCode Blocks27Linking Handwritten UCBs with AutoCode Applications28Figure 2-1. Example UserCode Function File (sa_user.c)29Implementing Handwritten UCBs30Table 2-5. UCB Calling Arguments and Data Types for the Fixed Interface30Figure 2-2. Linking Handwritten UCBs with AutoCode Applications32Linking Handwritten UCBs (for AutoCode) with SystemBuild33Figure 2-3. Linking Handwritten UCBs with the SystemBuild Simulator34Variable Interface UCB35Interface Ordering35Inputs and Outputs35Function Prototype36Linking a Variable Interface UCB with the Simulator37Procedure SuperBlocks37Generating Reusable Procedures37Linking Procedures with the SystemBuild Simulator37Figure 2-4. Linking Generated Reusable Procedures38Linking Procedures with Real-Time Applications or Simulator39Invoking Generated Procedures Directly39Figure 2-5. Arguments to Generated Procedure proc40Invoking Procedures Using Generated UCB Wrapper Function41Invoking Procedures Using Generated Subsystem Function42C Fixed-Point Arithmetic43Fixed-Point AutoCode/C Implementation43Generated Code with Fixed-Point Variables45Fixed-Point Data Types45Table 2-6. AutoCode/C Data Types45User Types47Overflow Protection48Stand-Alone Files48Macro Interface49Function Interface50Fixed-Point Conversion and Arithmetic Macros52Conversion Macros52Figure 2-6. AutoCode/C Conversion Macros for Fixed-to-Fixed Conversions53Figure 2-7. AutoCode/C Conversion Macros for Fixed-to-Integer Conversions54Figure 2-8. AutoCode/C Conversion Macros for Integer-to-Fixed Conversions54Arithmetic Macros55Figure 2-9. AutoCode/C Arithmetic Macros55Table 2-7. Arithmetic Macros-Operand and Result Sizes56Implementation of the Addition and Subtraction Macros57Selecting Wordsize Extension in the Preprocessor Macro5932-Bit Multiplication and Division Macros5932-Bit Multiplication5932-Bit Division6016-Bit by 8-Bit Division6032-Bit by 16-Bit Division60Fixed-Point Relational Macros61Figure 2-10. AutoCode/C Relational Macros61Some Relevant Issues62Chapter 3 Ada Language Reference63Stand-Alone Simulation63Supported Ada Compilers for the Stand-Alone Library63Table 3-1. Identified Ada Run-Time Versions of the Stand-Alone Library64Supplied Templates64ada_rt.tpl Template64ada_sim.tpl Template64ada_fxpt_sys.tpl Template64ada_fxpt_sub.tpl Template64Stand-Alone Library65System-Specific Files65Table 3-2. Distribution Directories and Files65Table 3-3. Target-Specific Utility Routines67Data Types67Target-Specific Utilities68Table 3-4. Target-Specific Utility Routines68Enable( ), Disable( ), and Background( ) Procedures69Error Procedure( ) Procedure69Implementation_Initialize( ) Procedure70Implementation_Terminate( ) Procedure72External_Input ( ) Procedure72External_Output( ) Procedure73UserCode Blocks73Linking Handwritten UCBs with AutoCode Applications73Calling UCBs74Table 3-5. UCB Calling Arguments and Data Types74Procedure SuperBlocks76Generating Reusable Procedures76Linking Procedures with Real-Time Applications or Simulator76Ada Fixed-Point Arithmetic78How to Generate Real-Time Code78Fixed-Point AutoCode/Ada Architecture78Fixed-Point Data Types79Generic Functions79Instantiated Functions79Package Dependencies80Figure 3-1. Package Dependency Graph80Generated Code with Fixed-Point Variables81User Types81System-Level Parameters to Generate User Types82Table 3-6. System-Level Parameters to Generate User Types82Overflow Protection82Stand-Alone Files83Table 3-7. Fixed-Point Stand-Alone Files83Compilation Example83Fixed-Point Type Declarations85Table 3-8. Fixed-Point Data Type Summary85Generic Functions85Table 3-9. Generic Function Summary86Bit-Wise Functions88Instantiated Functions Package88Operator Instantiations88Conversion Function Instantiations89Table 3-10. Conversion Function Naming Conventions89Sample Package90Addition and Subtraction Functions91Multiplication and Division Functions9332-Bit Multiplication9332-Bit Division93Conversion Functions93Language-Defined Conversion94Truncation Conversion94Explicit Rounding Conversion94Using System-Level Parameters to Generate Instantiations95Using Subsystem-Level Parameters to Generate Instantiations95System Scope Operators and Conversions96Known Ada Compiler Problems97Comparing Results to SystemBuild’s Simulator97Table 3-11. Possible Midpoint Round Modes98No-Op Conversion Function98Chapter 4 Generating Code for Real-Time Operating Systems100Real-Time Operating System Configuration File100Configuration Items101Table Syntax101Table Naming Convention102Table Column Contents102Table Orderings102File Comments102RTOS Configuration File Contents102Processors Table102Table 4-1. Processors Table Contents102Scheduler Priority Table103Table 4-2. Scheduler Priority Table Contents103Subsystem Table103Table 4-3. Subsystem Table Contents103Interrupt Procedure SuperBlock Table104Table 4-4. Interrupt Table Contents104Background Procedure SuperBlock Table105Table 4-5. Background Table Contents105Startup Procedure SuperBlock Table106Table 4-6. Startup Table Contents106Processor IP Name Table106Table 4-7. Processor IP Table Contents106Version Table107Table 4-8. Version Table Contents107Using the Configuration File107Chapter 5 Generated Code Architecture109Symbolic Name Creation109Default Names109Signal Naming110Duplicate Names110Selection of a Signal Name110Subsystem and Procedure Boundaries110Typecheck Feature and Data Types110Global Storage111Percent vars (%var)111Global Variable Blocks111Sequencing Variable Blocks111Global Variable Block and %var Equivalence112Optimization for Read-From Variable Blocks112Global Scope Signal Capability112Subsystems113Discrete and Continuous SuperBlocks Versus Subsystems113Top-Level SuperBlock114Block Ordering114Interface Layers114Figure 5-1. Interface Layering Diagram115Scheduler External Interface Layer115System External Interface Layer115Discrete Subsystem Interface Layer116Single-Rate System116Multi-Rate System116Sample and Hold116Static Data Within Subsystems117iinfo117R_P and I_P117State Data117Procedure Data118Pre-init Phase118Init, Output, and State Phases118Copy Back and Duplicates118Error Handling119Standard Procedures119Structure-Based Interface119Unrolled Interface120Phases and Error Handling120Referenced Percent Variables120Procedure Arguments123U, Y, S, and I123Table 5-1. Description of Element iinfo in Structure _procedure name_info125Table 5-2. Description of Element rinfo in Structure _procedure name_info125Extended Procedure Information Structure126Caller Identification126Table 5-3. Procedure Ordering127Compatibility Issues127Macro Procedure128Interface128Asynchronous Procedures129Interrupt129Background129Startup129Changing %var Values During Startup130Condition Block130Default Mode130No-Default Mode130Sequential Mode130BlockScript Block130Inputs and Outputs131Environment Variables132Local Variables132Init, Output, and State Phases133Default Phase134States134Local Variables and Phases135Discrete Semantics135Continuous Semantics137Looping Concepts137Terminology137Loops and Scalar Code137Rolling Loops with Scalar Code Generation138Vectorized Code139Types of Loops139Table 5-4. Scalar Code Semantics for the Loop Types140Table 5-5. Vectorized Code Semantics for the Loop Types140Examples of Rolled and Unrolled Loops140Parameters141Using Parameters Instead of States in a Discrete Model141Optimizations143Constant Propagation/Hard-Coding143Dead Code Elimination143Implicit Type Conversion144Special Directives144Table 5-6. BlockScript Special Directives144UserCode Block145Phases of the UCB145Indirect Terms145Parameterized UCB Callout146Software Constructs147IfThenElse Block147WHILE Block147BREAK Block148CONTINUE Block148Local Variable Block148Sequencer Block149Difference Between Local and Global Variable Blocks149Scope149Lifetime149Continuous Subsystem149Explicit Phases150Integrator150Limitations150Multiprocessor Code Generation151Shared Memory Architecture151Distributed Memory Architecture152Shared Memory Callouts152Callout Naming Convention152Mapping Command Options153Fixed-Point Support for Multiprocessor AutoCode153Definitions and Conventions153Shared Memory Fixed-Point Callouts in AutoCode/C154Shared Variable Block Support155Shared Memory Callout Option158Global Variable Block Callouts159Callout Pairs159Non-Shared (Local) Global Variable Blocks159Shared Global Variable Blocks161Chapter 6 Vectorized Code Generation164Introduction164How Code Is Generated164Scalar Gain Block Example165Vectorized Gain Block Example166Array Subscripts167Signal Connectivity168Block Outputs168Block Inputs168Figure 6-1. Poorly Connected Gain Block169Vectorization Modes170Maximal Vectorization170Mixed Vectorization170Vector Labels and Names171Example171Figure 6-2. Example Model Diagram172Vectorization Features177Multiple Arrays within a Block178Figure 6-3. Multiple Array Mode178Split-Merge Inefficiency180Split Vector180Figure 6-4. Example of a Split Vector181Merge182Figure 6-5. Complete Split-Merge Diagram182External Outputs184Copy-Back184Figure 6-6. Copy-Back Example185Eliminating Copy-Back186Other Copy-Back Scenarios186Vectorized Standard Procedure Interface186Figure 6-7. Vectorized Procedure Interface187Ada Array Aggregates and Slices188Vectorization of the BlockScript Block190Matrix Outputs191Chapter 7 Code Optimization192Read from Variable Blocks192Restart Capability196Merging INIT Sections199Reuse of Temporary Block Outputs202Reuse Temporaries as Specified202Maximal Reuse of Temporaries202Constant Propagation204Optimizing with Matrix Blocks207Optimizing with Constant Blocks207Optimizing with Callout Blocks208Optimizing with Inverse Blocks208Optimizing with Division Blocks208Table 7-1. Optimization Table for Callout Blocks210Summary210Chapter 8 AutoCode Sim Cdelay Scheduler211Introduction211Task Posting Policies212Standard AutoCode Scheduler213Figure 8-1. Model with Enabled and Triggered Tasks214Figure 8-2. Latencies Present in Default AutoCode Scheduler215Scheduler Pipeline215Figure 8-3. Scheduler Pipeline Stages in the Standard AutoCode Scheduler216Managing DataStores in the Scheduler217Figure 8-4. Scheduler Pipeline Stages in the Sim Cdelay AutoCode Scheduler218Sim Cdelay Scheduler219State Transition Diagrams of Tasks under Sim Cdelay220Figure 8-5. New STD for Free-Running Periodic Tasks220Figure 8-6. New STD for ATR Triggered Tasks221Figure 8-7. New STD for ATR Triggered Tasks221Implementing the Sim Cdelay AutoCode Scheduler222Implementation Details222DataStore Priority Problem223Using the Sim Cdelay Scheduler224Figure 8-8. Latencies Present in the AutoCode Scheduler225Template Configuration for Enhanced Performance225Figure 8-9. Alternative (Old Enable Policy) STD for an Enabled Task226Shortcomings of the Sim Cdelay Scheduler226Chapter 9 Global Scope Signals and Parameterless Procedures228Introduction228Data Monitoring/Injection229Specifying Monitored Signals229Generating Code for Monitored Signals230Limitations231Unsupported Blocks231Connection to External Output231Variable Block Aliasing231Monitored Signals within a Procedure SuperBlock231Monitoring Procedure External Outputs231Parameterless Procedure232Specifying Parameterless Procedure Interface232Input Specification232Output Specification233Using a Parameterless Procedure233Global-to-Global Input Connection233Global Output Connection233Condition Block Code Generation234Reusing a Parameterless Procedure234Generating Code for Parameterless Procedures234Issues and Limitations235Communication Between Subsystems235Variable Blocks Versus Global Scope235SystemBuild Simulator235Connection to External Output236Recommendations236Naming Convention236Model Documentation236Explicit Sequencing236Analyzer and AutoCode Warnings237Changing Scope Class237Command Options237Appendix A Technical Support and Professional Services238Index239A-C239D-F240G242H-K244L-P245R-S246T248U-W249X-Y250文件大小: 2.0 MB页数: 250Language: English打开用户手册