Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/newdedyk/domains/bkmanuals.com/public_html/includes/pages/manual_inc.php on line 26
National Instruments NI MATRIX manuale d’uso - BKManuals

National Instruments NI MATRIX manuale d’uso

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250

Vai alla pagina of

Un buon manuale d’uso

Le regole impongono al rivenditore l'obbligo di fornire all'acquirente, insieme alle merci, il manuale d’uso National Instruments NI MATRIX. La mancanza del manuale d’uso o le informazioni errate fornite al consumatore sono la base di una denuncia in caso di inosservanza del dispositivo con il contratto. Secondo la legge, l’inclusione del manuale d’uso in una forma diversa da quella cartacea è permessa, che viene spesso utilizzato recentemente, includendo una forma grafica o elettronica National Instruments NI MATRIX o video didattici per gli utenti. La condizione è il suo carattere leggibile e comprensibile.

Che cosa è il manuale d’uso?

La parola deriva dal latino "instructio", cioè organizzare. Così, il manuale d’uso National Instruments NI MATRIX descrive le fasi del procedimento. Lo scopo del manuale d’uso è istruire, facilitare lo avviamento, l'uso di attrezzature o l’esecuzione di determinate azioni. Il manuale è una raccolta di informazioni sull'oggetto/servizio, un suggerimento.

Purtroppo, pochi utenti prendono il tempo di leggere il manuale d’uso, e un buono manuale non solo permette di conoscere una serie di funzionalità aggiuntive del dispositivo acquistato, ma anche evitare la maggioranza dei guasti.

Quindi cosa dovrebbe contenere il manuale perfetto?

Innanzitutto, il manuale d’uso National Instruments NI MATRIX dovrebbe contenere:
- informazioni sui dati tecnici del dispositivo National Instruments NI MATRIX
- nome del fabbricante e anno di fabbricazione National Instruments NI MATRIX
- istruzioni per l'uso, la regolazione e la manutenzione delle attrezzature National Instruments NI MATRIX
- segnaletica di sicurezza e certificati che confermano la conformità con le norme pertinenti

Perché non leggiamo i manuali d’uso?

Generalmente questo è dovuto alla mancanza di tempo e certezza per quanto riguarda la funzionalità specifica delle attrezzature acquistate. Purtroppo, la connessione e l’avvio National Instruments NI MATRIX non sono sufficienti. Questo manuale contiene una serie di linee guida per funzionalità specifiche, la sicurezza, metodi di manutenzione (anche i mezzi che dovrebbero essere usati), eventuali difetti National Instruments NI MATRIX e modi per risolvere i problemi più comuni durante l'uso. Infine, il manuale contiene le coordinate del servizio National Instruments in assenza dell'efficacia delle soluzioni proposte. Attualmente, i manuali d’uso sotto forma di animazioni interessanti e video didattici che sono migliori che la brochure suscitano un interesse considerevole. Questo tipo di manuale permette all'utente di visualizzare tutto il video didattico senza saltare le specifiche e complicate descrizioni tecniche National Instruments NI MATRIX, come nel caso della versione cartacea.

Perché leggere il manuale d’uso?

Prima di tutto, contiene la risposta sulla struttura, le possibilità del dispositivo National Instruments NI MATRIX, l'uso di vari accessori ed una serie di informazioni per sfruttare totalmente tutte le caratteristiche e servizi.

Dopo l'acquisto di successo di attrezzature/dispositivo, prendere un momento per familiarizzare con tutte le parti del manuale d'uso National Instruments NI MATRIX. Attualmente, sono preparati con cura e tradotti per essere comprensibili non solo per gli utenti, ma per svolgere la loro funzione di base di informazioni e di aiuto.

Sommario del manuale d’uso

  • Pagina 1

    NI MA TRIXx TM AutoCode TM Reference AutoCode Reference April 2007 370768C-01[...]

  • Pagina 2

    Support Worldwide Technical Support and Product Info rmation ni.com National Instruments Corporate Headquarters 11500 North Mopac Expressway Aust in, Texas 78759-3504 USA Tel: 512 683 0100 Worldwide Offices Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599, Canada 800 433 3488, China 86 21 5050 9800,[...]

  • Pagina 3

    Important Information Warranty The media on which you receive Natio nal In struments software are warranted not to fail to execute programming instructi ons, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as eviden ced by receipts or other documentat ion. N ational Instruments will , at its option, repai[...]

  • Pagina 4

    Conventions The follo wing con ventions are used in this manual: < > Angle brackets that cont ain numbers s eparated by an ellipsis represent a range of v alues 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. The sequence File»[...]

  • Pagina 5

    © National Instruments Corporatio n v AutoCode Reference Contents Chapter 1 Introduction Manual Organization .................... ............... .............. .............. .............. .............. .......... 1-1 General Information ......................... .............. .............. ................. ............... .............. ...[...]

  • Pagina 6

    Contents AutoCode Reference vi ni.com Linking Procedures with R eal-Time Applications or Si mulator ........ ............ 2-22 Invoking Generated Proc edures Directly ............. ............ ........... ...... 2-22 Invoking Procedures Using Generat ed UCB Wrapper Function ...... 2-24 Invoking Procedures Using Generat ed Subsystem Function ......[...]

  • Pagina 7

    Contents © National Instruments Corporatio n vii AutoCode Reference External_Input ( ) Proced ure .................... .............. .............. ............. 3-10 External_Output( ) Procedure ......... ............... .............. .............. ....... 3-11 UserCode Blocks ..................... .............. .............. .............. [...]

  • Pagina 8

    Contents AutoCode Reference viii ni.com Chapter 4 Generating Code for Real -Time Operating Systems Real-Time Operating System Conf iguration File....... .............. .............. .............. ......... 4-1 Configuration Items ................. .............. .............. .............. ............... .............. 4-2 Table Syntax ...... [...]

  • Pagina 9

    Contents © National Instruments Corporation ix AutoCode Reference System External Interface Laye r ..................................................... ............ .... 5-7 Discrete Subsystem Interface Layer ............ .................................... ............ .... 5-8 Single-Rate System .............. .............. .............. ...[...]

  • Pagina 10

    Contents AutoCode Reference x ni.com States ............ .............. .............. .............. .............. .............. ............... .............. 5-26 Local Variables and Phases ................ ............... .............. .............. ... 5-27 Discrete Semantics .......... .............. .............. .............. ........[...]

  • Pagina 11

    Contents © National Instruments Corporation xi AutoCode Reference Definitions and Conventions ................. .............. .............. .............. .............. .. 5-45 Shared Memory Fixed-Point Callouts in AutoCode/C ................. .... 5-46 Shared Variable Block Support ....... ................. .............. ............... .....[...]

  • Pagina 12

    Contents AutoCode Reference xii ni.com Chapter 7 Code Optimization Read from Variable Blocks ....................... .............. .............. .............. .............. ............ 7-1 Restart Capability ....... .............. .............. .............. .............. .............. ............... .............. 7-5 Merging INIT Sectio[...]

  • Pagina 13

    Contents © National Instruments Corporation xiii AutoCode Reference Variable Block Aliasing ................ .............. ................. .............. ....... 9-4 Monitored Signals within a Procedur e SuperBlock .......... ................ 9-4 Monitoring Procedure External Output s ......................... .............. .... 9-4 Parameterl[...]

  • Pagina 14

    © National Instruments Corporatio n 1-1 AutoCode Reference 1 Introduction This manual provides referen ce material for using AutoCode to wr ite production quality code using gra phical tool s. Together with the AutoCode User Guide and the Template Programmin g Language U ser Guide , AutoCode documentation describes how to generate robust, high-qua[...]

  • Pagina 15

    Chapter 1 Introduction AutoCode Reference 1-2 ni.com • Chapter 8, AutoC ode Sim Cdelay Scheduler , discusses the Sim Cdelay low-latency scheduler. • Chapter 9, Global Scope Signals and Param eterless Procedures , discusses additional signals and procedures. This guide also has an Index . General Information As an integral part of the rapid prot[...]

  • Pagina 16

    Chapter 1 Introduction © National Instruments Corporatio n 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 framew ork of the generated code is discussed to show how all of the pieces work together to form a[...]

  • Pagina 17

    Chapter 1 Introduction AutoCode Reference 1-4 ni.com Related Publications National Instruments provides a complete library of publications to suppo rt its products. In addition to this gui de, publication s that you may find particularly useful when using AutoC ode include the following: • AutoCode User Guide • Template Programmi ng Language Us[...]

  • Pagina 18

    © National Instruments Corporatio n 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 si mulation and testing. Stand-Alone Simulation The template provided for[...]

  • Pagina 19

    Chapter 2 C La nguage Reference AutoCode Reference 2-2 ni.com Stand-Alone Librar y This section describes the system-sp ecific and target-specific s tand-alone ( sa ) files supplied with your system. System-Specific Files National Instruments furnishes file s to interface AutoCode and the generated code to your development platform (AIX, Compaq, HP[...]

  • Pagina 20

    Chapter 2 C La nguage Referenc e © National Instruments Corporatio n 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 follo wing header f iles a v ailable locally: sa_sys.h sa_defn.h sa_utils.h sa_math.h sa_types.[...]

  • Pagina 21

    Chapter 2 C La nguage Reference AutoCode Reference 2-4 ni.com Data T ypes Several of the target-specifi c utilities are inv olved with d ata 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 your C compiler . RT_INTEGER Corresponds to C t[...]

  • Pagina 22

    Chapter 2 C La nguage Referenc e © National Instruments Corporatio n 2-5 AutoCode Reference to. For example, RT_I NTEGER can be redefined as long int if arithmetic ov erflow becomes a problem on a giv en platform. T arget-Specific Utilities Target-specific uti lit ies (in sa_utils.c ) perform hardware, app lication, and C-specific tasks that are r[...]

  • Pagina 23

    Chapter 2 C La nguage Reference AutoCode Reference 2-6 ni.com The sa_utils.c f ile contains comm ents about each of th e routines as they are used for comparing simulation wi th generated code results. After you generate code, link the generated code wit h sa_*.o object files (refer to Chapter 2, Using AutoCode , of the AutoCode User Guide) . For e[...]

  • Pagina 24

    Chapter 2 C La nguage Referenc e © National Instruments Corporatio n 2-7 AutoCode Reference T wo error functions are provided, fatalerr( ) and error( ) . The fatalerr( ) function reports exception conditions detected by the functions in the sa_utils.c file. error( ) reports conditions detected by the generated code during ex ecution. Not all repor[...]

  • Pagina 25

    Chapter 2 C La nguage Reference AutoCode Reference 2-8 ni.com the comments there and adjust the limi ts accordingly , then recompile and relink the sa_utils.c fil e . 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 ERR[...]

  • Pagina 26

    Chapter 2 C La nguage Referenc e © National Instruments Corporatio n 2-9 AutoCode Reference Implementation_Initialize( ) Function void Implementation_Initialize (RT_F LOAT *BUS_IN RT_INTEGER, NI, RT_FLOAT BUS_OUT, RT _INTEGER NO, RT_FLOAT SCHEDULER_FREQ); In the default version of sa_utils.c (simulation comparison) , this function initializes the [...]

  • Pagina 27

    Chapter 2 C La nguage Reference AutoCode Reference 2-10 ni.com External_Input ( ) Function RT_INTEGER External_Input(void) External_Input( ) is for use in the simu lation compari son mode; it reads in external in put data from your specified FSAVE input file. The data appears in XINPUT , an array of type RT_FLOAT , dimensioned eq ual to the input v[...]

  • Pagina 28

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-11 AutoCode Reference Linking Handwritten UCBs wi th 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 e xample of a UCB function declaratio n (refer t[...]

  • Pagina 29

    Chapter 2 C La nguage Reference AutoCode Reference 2-12 ni.com Figure 2-1. Example UserCo de Func tion File (sa_user .c) The $ucb directi ve is recognized and inte rpreted by the automatic linking facility of the simul ator in Syst emBuild to d istinguish be tween UCBs written for simulat ion purposes usin g SystemBuil d only and UCBs written for l[...]

  • Pagina 30

    Chapter 2 C La nguage Referenc e © 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 ) and scalers corresponding to array sizes ( NU ,[...]

  • Pagina 31

    Chapter 2 C La nguage Reference AutoCode Reference 2-14 ni.com The operations within UCBs are controlled by the ar gument INFO , a pointer to a structure of type STATUS _RECORD that is passed as part of the argument list for each UCB (located in sa_types ): typedef struct STATUS_RECORD { RT_INTEGER ERROR; RT_BOOLEAN INIT; RT_BOOLEAN STATES; RT_BOOL[...]

  • Pagina 32

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-15 AutoCode Reference Figure 2-2. Linking Handwritten UCBs with AutoCode Applications Generate A utoCode Application dsp . c usr_dsp. c (Handwritten UCB usin g sa_user . c example) compile and link Fil e Na me: usr_d sp.c y (k) = -1/ 2*y(k-2) + 3* u(k) + u(k-2); which le ads to [...]

  • Pagina 33

    Chapter 2 C La nguage Reference AutoCode Reference 2-16 ni.com Linking Handwritten UCBs (for AutoCode) with SystemBuild After you have w ritten a UCB to cr eat e an AutoCode appl ication, you can use the same UCB for simulat ion. Sy stemBuild can automatically compile and link your UserCode functio n into the simulation engine (release 4.0 and late[...]

  • Pagina 34

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-17 AutoCode Reference Figure 2-3. Linking Handwritten UCBs with the SystemBuild Simulator The arguments to a UCB written onl y for linking wi th the SystemBuild simulator (usi ng usr01.c ) are inherently dif ferent than the arguments to a UCB written for linking wi th an AutoCod[...]

  • Pagina 35

    Chapter 2 C La nguage Reference AutoCode Reference 2-18 ni.com applications, make sure you adapt th e same algorithm in the body of a function using the AutoCode UCB arguments as in sa_user.c . V ariable Interface UCB The preceding sections described the fixed interface; however, a UCB can also use the variable interface option. For information on [...]

  • Pagina 36

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-19 AutoCode Reference As previously stated, the inputs and outputs of the UCB will hav e the same data type as specified in the model diagram. Inputs ar e passed by v alue while outputs are passed by reference. In addition, the “shape” of an argument describes whether it is [...]

  • Pagina 37

    Chapter 2 C La nguage Reference AutoCode Reference 2-20 ni.com Linking a V ariable Interfac e UCB with the Simulator Unlike the fixed interface which provide s an automatic method for linking with the Simulator, the variable int erface is too complicated for that method. As a result, you are required to create a “wrapper” function that interfac[...]

  • Pagina 38

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-21 AutoCode Reference proc_ucb_hook . Refer to the T emplate Pr ogr amming Language User Guide . Figure 2-4. Lin king Generated Re usable Procedures Procedure Generate Reusable Procedure Filename: myproc.c Function Name: simex e.lnx myproc.c simulation (automatic compiling and l[...]

  • Pagina 39

    Chapter 2 C La nguage Reference AutoCode Reference 2-22 ni.com Linking Procedures with Real-T ime Applications or Simul ator Generate reusable procedures from your Procedure SuperBlo cks as described in this chapter and in Chapter 3, Ada Language Reference . To link generated reusable procedures wit h your own applic ation or simulator you have the[...]

  • Pagina 40

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-23 AutoCode Reference 3. Create an object of type _ procedure name _s where the states of the procedure will be stored and initialize all members of the object to 0.0. This should be done during ini tialization only . A po inter to this object will be passed as ar gument S to th[...]

  • Pagina 41

    Chapter 2 C La nguage Referenc e AutoCode Reference 2-24 ni.com point to the ap propriate global variables. A pointer to this o bject will be passed as argument I to the procedure. 5. In v oke the procedure using po inters to the objects created in steps 1 through 4. 6. T oggle the state flag of the states ob ject of the procedure—that is, if the[...]

  • Pagina 42

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-25 AutoCode Reference properly . Refer to the SystemBuild User Guide for an explanation of rinfo . Only the first four elements of this array will be used by the generated procedure. This array will be passed as ar gument rinfo . 3. Create an array sized by the number of inputs [...]

  • Pagina 43

    Chapter 2 C La nguage Reference AutoCode Reference 2-26 ni.com data-typed v ariables re flecting each subsystem in put signal and type. The outputs to the subsystem are pro vided by the argument Y , a pointer to a stru cture named _Subsys_ number _out . This structure has mixed data-typed v ariables re flecting each subsystem ou tput signal and typ[...]

  • Pagina 44

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-27 AutoCode Reference number—for each integer item and the sign are ma naged by the code generator. Arithmetic expressions ar e scaled to emulate a fixed-point capability, and all expressi ons involving the item are coded to be consistent with the chosen radix position. AutoCo[...]

  • Pagina 45

    Chapter 2 C La nguage Reference AutoCode Reference 2-28 ni.com language and replace the supplied macros (or functions) with your (assembly) functions so that you can ta ke full advantage of the processor’ s arithmetic capabilities. Generated Code with Fixed-Point V ariables Code generated for models using fixed-point vari ables—such as the exam[...]

  • Pagina 46

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-29 AutoCode Reference A typical fix ed-point type looks like the following: R T_USHOR T06 where USHOR T stands for unsigned short, and 06 indicates the radix position. Fixed-point v ariables that are al ways pos iti ve in nature can be declared as unsigned. This has the advantag[...]

  • Pagina 47

    Chapter 2 C La nguage 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 definit ions. *******/ struct _Subsys_1_out subsys_1_out; struct _Sys_ExtIn sys_extin; static RT_FLOAT ExtIn [NUMIN+1]; static RT_FLOAT ExtOut [N[...]

  • Pagina 48

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-31 AutoCode Reference The UTs appear as typedef statements in the ge nerated C code. Fo r example: typedef volts RT_SBYTE03; This code defines the data type called v olts to be a signed byte with radix positi on 3. Overflow Protection Overflow is defined as loss of signif i canc[...]

  • Pagina 49

    Chapter 2 C La nguage 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 fix ed-point con version macros. sa_fxp.h Contains fix ed-point con version macros with ov erflow protection. sa_fxr.h Contains fix ed-point relational macros. sa_fxm.h Conta[...]

  • Pagina 50

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-33 AutoCode Reference sa_fx_externs.c Contains def initions for extern variables such as mask b uf fers that are read only . Function Interface The function interface files are: sa_types.h Updated to include fixed-point types. sa_fxp.h Contains fix ed-point con version macros wi[...]

  • Pagina 51

    Chapter 2 C La nguage Reference AutoCode Reference 2-34 ni.com sa_fxsub_byte.c Contains f ixed-point subtraction functions for byte data type. sa_fxsub_short.c Contains f ixed-point subtraction functions for short data type. sa_fxsub_long.c Contains f ixed-point subtraction functions for long data type. sa_fxmul_byte.c Contains f ixed-point multipl[...]

  • Pagina 52

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-35 AutoCode Reference Fixed-Point Conversion and Arithmetic Macros Although this section explains differen t fi xed-point operations in terms of macros, all of these operations are su pported as fun ctions in the function interface. Hence, in the fo llowing sections the term mac[...]

  • Pagina 53

    Chapter 2 C La nguage Reference AutoCode Reference 2-36 ni.com Figures 2-6 through 2-8 show ho w th e con version macros are named. Notice that macro names ha ve no embedded spaces. Figure 2-6. AutoCode/C Conversion Macros fo r Fixed-to-Fixed Conversions For e xample, the macro to con v ert an unsigned 8-bit number to a signed 8-bit number with a s[...]

  • Pagina 54

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-37 AutoCode Reference Figure 2-7. AutoCode/C Conversion Macros for Fixed-to-Integer Conversions For e xample, the macro to con v ert an unsigned 8-bit number to an integer number with a shift of rp bits, and with overflo w protection is: iALIGNubp(n,rp) Figure 2-8. AutoCode/C Co[...]

  • Pagina 55

    Chapter 2 C La nguage Reference AutoCode Reference 2-38 ni.com Arithmetic Macros The arithmetic macros perform additi on, subt raction, multiplication, and division. The top level macros for arith metic operations are present in the sa_fxm.h and sa_fxmp.h files. These macros in turn call the ALIGN macros that are defined either in sa_fx.h or sa_fxp[...]

  • Pagina 56

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-39 AutoCode Reference T ab le 2-7 sho ws permissible operand and result sizes for the arithmetic macros. For e xample, the macro to add two 8- bit unsig ned numbers with o verfl ow protection and produce an unsigned 8-bit resul t is: ubADD_ub_ubp(n1,n2,rp1,rp2,rp3) The macro to [...]

  • Pagina 57

    Chapter 2 C La nguage Reference AutoCode Reference 2-40 ni.com Implementation of the Ad dition and Subtraction Macros AutoCode has two implem entations of the addition and subtraction macros: • Macros that apply wordsize e x tension (also called extended intermediate ty pes) to the tw o op erands before aligning the radix positions and addin g or[...]

  • Pagina 58

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-41 AutoCode Reference Align the radix positions of n1 and n2 to the r adix 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 perform a 16-bit subtraction of n1&a[...]

  • Pagina 59

    Chapter 2 C La nguage Reference AutoCode Reference 2-42 ni.com 0^1111111 (n2' = (127,r7) , decimal v alue = .9921875) ___________ 0^0000000 (n3 = (0,r7) , decimal v alue = 0.0) In Example 2 -3, method 1 is more accurate than method 2, but it is also le ss ef ficient because it in v olves a 16-bit sub t ra c t io n . T h is i s i m po r t an t [...]

  • Pagina 60

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-43 AutoCode Reference the maximum possible value representa ble in 32 bits—is returned. This multiplication process can be expe nsive because it involves several multiplication an d addition operations to produce an i ntermediate result. This procedure strives for accuracy, bu[...]

  • Pagina 61

    Chapter 2 C La nguage Reference AutoCode Reference 2-44 ni.com in terms of speed, but is needed to co mpute 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 o f multiplication and division macros, refer to the SystemBuild User[...]

  • Pagina 62

    Chapter 2 C La nguage Referenc e © National Instruments Corporation 2-45 AutoCode Reference For e xample, the macro to check an 8-bit unsigned number and an 8-bit signed number for equality an d produce a Boolean result is: boolEQ_ub_sb(n1,n2,rp1,rp2) Some Relevant Issues • The fix ed-point macros used by Au toCode-generated files are defi ned i[...]

  • Pagina 63

    © National Instruments Corporatio n 3-1 AutoCode Reference 3 Ada Language Reference This chapter discusses files used to interface AutoCode and the generated Ada code to your specific pl atform and target proce ssor. This chapter also discusses target-specific utilities needed fo r simulation and testing. Stand-Alone Simulation The templates provi[...]

  • Pagina 64

    Chapter 3 Ada Language Reference AutoCode Reference 3-2 ni.com Supplied T emplates ada_rt.tpl T emplate The ada_rt.tpl templa te is the default when gener ating Ada code. This template uses Ada tasks to implement the scheduling mechanism for the model. This template suppo rts fixed-point arithm etic. ada_sim.tpl T emplate The ada_sim.tpl template d[...]

  • Pagina 65

    Chapter 3 A da Language Refe rence © National Instruments Corporatio n 3-3 AutoCode Reference Stand-Alone Librar y This section describes the system-sp ecific and target-specific s tand-alone ( sa_* ) files supplied with your system. System-Specific Files Header and source files are supplied to interface AutoCode generated code to your development[...]

  • Pagina 66

    Chapter 3 Ada Language Reference AutoCode Reference 3-4 ni.com • The principal file is sa_utils.a (or sa_utils.ada ), the stand-alone utilities fi le. When you compile sa_utils.a/.ada , you must make the following f iles from the source distribution directory av ailable locally: – sa_utils_.a/.adasa_utils.a/.ada – sa_time_.a/.adasa_time.a/.ad[...]

  • Pagina 67

    Chapter 3 A da Language Refe rence © National Instruments Corporatio n 3-5 AutoCode Reference floating-point MATH_LIB . The sa_time.a/.ada file provides the Elapsed_Time_Of( ) function. The purposes of the more important specification f iles are listed in Ta b l e 3 - 3 . . Data T ypes Several of the target-specifi c utilities are inv olved with d[...]

  • Pagina 68

    Chapter 3 Ada Language Reference AutoCode Reference 3-6 ni.com T arget-Specific Utilities The target-specific utilities in the sa_utils.a or sa_utils.ada file perform hardware-, application-, and Ada-specific tasks th at are required for simulation and testing. Th ey can be modified to support the generat ed code on the target comp uter. As furnish[...]

  • Pagina 69

    Chapter 3 A da Language Refe rence © National Instruments Corporatio n 3-7 AutoCode Reference The sa_utils.a or sa_utils.ada f ile contains comm ents about each of the routines as they are used for com paring simulation w ith generated code results. Enable( ), Disable( ), and Background( ) Procedures Enable, disable, and background r outines are n[...]

  • Pagina 70

    Chapter 3 Ada Language Reference AutoCode Reference 3-8 ni.com Refer to the Chapter 14, UserCode Blocks , of the SystemBuild User Guide or the source listing of th e USR01 rout ine for meanings of UCB errors. Y ou are allowed to e xtend the scope of these messages, so it might be one of yours. Unknown error encountered in task n A possible cause is[...]

  • Pagina 71

    Chapter 3 A da Language Refe rence © National Instruments Corporatio n 3-9 AutoCode Reference By default, sev eral error conditio ns are trapped in the procedure Implementation_Initialize of sa_utils.a/.ada , b ut you can expand this capability in your own v ersions of the program, detecting your own error conditions and adding your own messages. [...]

  • Pagina 72

    Chapter 3 Ada Language Reference AutoCode Reference 3-10 ni.com These messages indicate that the sizes of the time vector and input array hav e exceeded one or more of the stor age allocation size l imits established by sa_utils.a/.ada . These limits are established as constants at the very beginning of the stand-alone uti lities file, just after t[...]

  • Pagina 73

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-11 AutoCode Reference External_Input( ) is much the same; it returns an input vector from the software data bus. External_Input ( ) returns the value of SCHEDULER_STATUS , which is passed to it b y the scheduler . External_Output( ) Procedure procedure External_Output(Bus: in [...]

  • Pagina 74

    Chapter 3 Ada Language Reference AutoCode Reference 3-12 ni.com 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 W ithin the UCB, the elements of all the array v ariables ( U , X , XD , Y , R_P , I_P ) must be accessed as in the follo wing e[...]

  • Pagina 75

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-13 AutoCode Reference The operations within U CBs are controlled by the INFO ar gument, a record of RT_STATUS_RECORD type that is passed as part of the ar gument list for each UCB: type RT_STATUS_RECORD is record ERROR: RT_INTEGER; INIT: RT_BOOLEAN; STATES: RT_BOOLEAN; OUTPUTS[...]

  • Pagina 76

    Chapter 3 Ada Language Reference AutoCode Reference 3-14 ni.com Procedure SuperBlocks This section describes how to generate an d link Procedure Supe rBlocks. Generating Reusable Procedures Generate reusable procedures from your Procedure SuperBlo cks as described in Chapter 2, Using AutoCode , of the AutoCode User Guide . You have an option to cal[...]

  • Pagina 77

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-15 AutoCode Reference ------------------------------------ -------------------------------- --- -- Wrapper around the procedure to s upport UCB (Fixed calltype) inte rface -- This routine can be called as a U CB either from SystemBuild or Au toCode ----------------------------[...]

  • Pagina 78

    Chapter 3 Ada Language Reference AutoCode Reference 3-16 ni.com Ada Fixed-Point Arithmetic This section describes the implement ation of fixed-point arithm etic in AutoCode/Ada. It is assumed that you are familiar with the Ada programming languag e. Note The SystemBuild User Guide has a fix ed-point arithmeti c chapter that explains the basics of f[...]

  • Pagina 79

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-17 AutoCode Reference Fixed-Point Data T ypes Fixed-point type declaration s exist in the file named: sa_fxptypes_.a and is provided in the System-Specific Files src (source) directory. 1 This file contains th e specification of the SA_FIXED package. The package specification [...]

  • Pagina 80

    Chapter 3 Ada Language Reference AutoCode Reference 3-18 ni.com Package Dependencies The fixed-point AutoCode/ Ada archit ecture forces a dependency among the supplied and gen erated code for a mod el that uses any fixed-po int types. This dependency affects compilation order within an Ada Library. Figure 3-1 illustrates the imposed depend ency. In[...]

  • Pagina 81

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-19 AutoCode Reference Generated Code with Fixed-Point V ariables Fixed-point arithmetic operations are accomplis hed by overloading the standard arithmetic oper ator s for the fi xed-point types. Therefore, the generated code with fixed-point variab les uses the same infix exp[...]

  • Pagina 82

    Chapter 3 Ada Language Reference AutoCode Reference 3-20 ni.com System-Level Parameters to Generat e User T ypes Table 3-6 describes new sy stem-level pa rameters that are used to generate the USER_TYPES package. Overflow Protection Overflow is defined as loss of significance—that is, a comp utation resulting in a value that cannot be re presente[...]

  • Pagina 83

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-21 AutoCode Reference frequently overflo wing, a di ff erent data type shoul d be selected. If you are concerned about performance and th e use of an e xception handle r for detecting overflo w , the g eneric functio ns can be changed. These changes do not affect the generated[...]

  • Pagina 84

    Chapter 3 Ada Language Reference AutoCode Reference 3-22 ni.com 1. Build a model —Use th e SuperBlock Editor to construct a model that uses fix ed-point types for input/o utput signals. Refer to the SystemBuild User Guide for more information. 2. Generate real-time code —Fro m the SystemBuild pull -down menus, select Build»Generate Real-Time C[...]

  • Pagina 85

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-23 AutoCode Reference 4. Compile the generated files —T wo source files are generated, gaintest.a and fxp_gaintest_.a , as sho wn in Figure 3-1. The imposed package dependen cies (refer to the Package Dependencies section) require that the RT_FIXED_OPERATORS package be compi[...]

  • Pagina 86

    Chapter 3 Ada Language Reference AutoCode Reference 3-24 ni.com Table 3-9. Generic Functio n Summary Function Na me Purpose FIXED_ADD Addition of two f ixed-point values. FIXED_SUB Subtraction of two fix ed-point values. FIXED_MUL Multiplication of two fixed-point v alues. FIXED_DIV Di vision of two fix ed-point values. FIXED_IDENTITY The identity [...]

  • Pagina 87

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-25 AutoCode Reference LONGINTCAST Fix ed-poin t v alue to RT_LONG_INTEGER con version. LONGINTCAST_TRUNC Fix ed-poi nt v alue to RT_LONG_INTEGER con version using truncation. LONGINTCAST_ROUND Fix ed-poi nt v alue to RT_LONG_INTEGER con version using rounding. BOOLEANCAST Fix [...]

  • Pagina 88

    Chapter 3 Ada Language Reference AutoCode Reference 3-26 ni.com Bit-Wise Functions A restricted set of bit-wise operatio ns 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- wise operations are the following three function[...]

  • Pagina 89

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-27 AutoCode Reference Conversion Function Instantiations The RT_FIXED_OPERATORS package contains instan tiations of functio ns that represent conversion of values to and from a fixed-point type. The appropriate generic function from the SA_FIXED_GENERICS package is chosen to i[...]

  • Pagina 90

    Chapter 3 Ada Language Reference AutoCode Reference 3-28 ni.com Sample Package Example 3-3 shows a gener ated RT_FIXED_OPERATORS package. Example 3-3 Generated RT_FI XED_OPERATORS Package ------------------------------------ -------------------------------- ------- -- AutoCode/Ada (TM) Code Generator 7.X -- -- National Instruments Co rporation, Aus[...]

  • Pagina 91

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-29 AutoCode Reference function “>=” is new SA_FIXED_GENERI CS.GREATEREQUAL(SA_FIXED.RT_SSHO RT14, SA_FIXED.RT_SSHORT08); --pragma inline (">="); function ">=" (LEFT, RIGHT : SA_ FIXED.RT_SSHORT13) return BOOLEA N renames SA_FIXED.">=&qu[...]

  • Pagina 92

    Chapter 3 Ada Language Reference AutoCode Reference 3-30 ni.com The selection of the intermediate type is perfo rmed by the code generator . The selection in volves a set of rules that rely upon w ord size extens ion. W ord size extension is selecting a f ixed- point type with a larger number of bits that can be used to represent model numbers. Als[...]

  • Pagina 93

    Chapter 3 A da Language Refe rence © 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 combinati on of fixed-point arguments. The result of the computat ion is exact and of arbitrary accu[...]

  • Pagina 94

    Chapter 3 Ada Language Reference AutoCode Reference 3-32 ni.com no chance of overflow. To support thes e issues there are three types of conversion functions: • Language-defined con version • T runcation con v ersion • Explicit rounding conv ersion These con versions are describe d in the following sections. Language-Defined Conversion The Ad[...]

  • Pagina 95

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-33 AutoCode Reference For these types of con versions, the la nguage-defined con version is used. In general, when an explicit con ver sion is required and there is no specification of which to choose, AutoCode/Ada will select the explicit rounding conv ersion. Using System-Le[...]

  • Pagina 96

    Chapter 3 Ada Language Reference AutoCode Reference 3-34 ni.com The data in the sp_fxp parameters represent th e operators and con version used in the currently scoped subsyste m or procedure. No assumptions can be made about the order within a given list parameter . Howe ver , the n th element in one list does relate to the n th element in another[...]

  • Pagina 97

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-35 AutoCode Reference Known Ada Compiler Problems The architecture of Au toCode/Ada Fixed-Point heavil y relies upon overloaded operators and generic function inst antiation. For a large and complex model, the number of ov erloads and instantiations might overwhelm some older [...]

  • Pagina 98

    Chapter 3 Ada Language Reference AutoCode Reference 3-36 ni.com • Floating-Point T extual Representation —The values generated from a stand-alone simulation are con verted to a textual (ASCII) representation. That representation in t extual form might no t quite be as accurate as possible. That is, the la st fe w digits in the mantissa might be[...]

  • Pagina 99

    Chapter 3 A da Language Refe rence © National Instruments Corporation 3-37 AutoCode Reference Example 3-6 Example Code C ausing Ambiguous Selection of Overloaded Operators function "*" (left:SB0; right:SB1) r eturn SL0; function "*" (left:SB0; right:SB1) r eturn SS0; function "*" (left:SL0; right:SL0) r eturn SL0; fun[...]

  • Pagina 100

    © National Instruments Corporatio n 4-1 AutoCode Reference 4 Generating Code for Real-T ime Operating Systems This chapter describes the RTOS c onfiguration file and functionality provided for generating co de for real-time operating systems. Real-T ime Operating System Configuration File Code that is to execute under the co ntrol of a real-time o[...]

  • Pagina 101

    Chapter 4 Generating Code for Real-Time Operating Systems AutoCode Reference 4-2 ni.com Configuration Items The following is a list of configuratio n attributes for each type of AutoCode component. • Number of processors • Scheduler priority • Subsystem T asks –P r i o r i t y – Stack Size – Processor – Mode Flags • Interrupt Proced[...]

  • Pagina 102

    Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporatio n 4-3 AutoCode Reference T able Naming Convention Tables are given a name to identify the contents of the data co ntained therein. Table names are specified in the same form as Xmath variables, partition.name . RTOS does not look at the partition specifier.[...]

  • Pagina 103

    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 T able Table 4-2 is a single element table cons isting of the p riority assigned to the scheduler task. The table is nam ed: scheduler_prio rity. Example 4-2 shows an example of a sche d[...]

  • Pagina 104

    Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporatio n 4-5 AutoCode Reference Example 4-3 Subsys tem Table Example rtos.subsys = Subsystem | Priority Stack Size Processor Mode Flags ------------------------------------ ------------------------------- 1 | 200 4096 1 K_NOFATAL 2 | 150 4096 1 K_IO | K_ER 3 | 150[...]

  • Pagina 105

    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 NONE sigio_io | 150 4096 1 127 I_IO keypad | 150 [...]

  • Pagina 106

    Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporatio n 4-7 AutoCode Reference Startup Procedure SuperBlock T able Table 4-6 consists of configuration information for all start up procedure SuperBlocks in th e model. Each row is identi fied by the nam e of the SuperBlock. The table is named stupsupb lk . Examp[...]

  • Pagina 107

    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 Ve r s i o n T a b l e Table 4-8 is a single element table consisting of the version[...]

  • Pagina 108

    Chapter 4 Generating Code for Real-Time Operating Systems © National Instruments Corporatio n 4-9 AutoCode Reference configuration f ile is updated. Also, the updated configuration file is stored in the same directory where the gene rated code is placed. Refer to the -o option. Caution Comments are not preserv ed in the def ault configur ation fi [...]

  • Pagina 109

    © National Instruments Corporatio n 5-1 AutoCode Reference 5 Generated Code Architecture This chapter supplies more details about the content and framework of the generated code. This includes st orage usage, various procedures, specialized blocks, and subsystems. This chapter is directed toward someone writing his/her own template, interfacing ge[...]

  • Pagina 110

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-2 ni.com Signal Naming A signal in t he diagram is represented as a variable in the ge nerated code. Within the diagram, signals can have two names: a label and a name . The signal’s label can appear in the diag ram while a signal’s name does not appear. If a signal has both a label an[...]

  • Pagina 111

    Chapter 5 Generated Code Architecture © National Instruments Corporatio n 5-3 AutoCode Reference Global Storage In a strict modular programming paradig m, global storage is strictly avoided. However, global storage can be used safely and provid es significant benefits in terms of code size and speed. Tradi tionally, AutoCode generates code that en[...]

  • Pagina 112

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-4 ni.com • Write-T o V ariable Block (ALL Addressing mode) —These blocks ex ecute after all other types of blocks within the subsystem , procedure or sequence frame. • Read-From/Write-T o V ariable Block (Element/Bit Addressing modes) —These v ariants to access v ari able block inf[...]

  • Pagina 113

    Chapter 5 Generated Code Architecture © National Instruments Corporatio n 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 Interface Layer • System External Interf[...]

  • Pagina 114

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-6 ni.com T o p-Level SuperBlock The term Top-Level SuperBlock is often used . This term describes the SuperBlock that was the root of the Analyzer’s pr ocessing of the SuperBlock hierarchy into su bsystems, that is, a starting point for the translation. AutoCode uses this Top- Level Sup [...]

  • Pagina 115

    Chapter 5 Generated Code Architecture © National Instruments Corporatio n 5-7 AutoCode Reference Figure 5-1 illustrates the interface laye rs. The layers are described in the subsections shown in the f igure. Figure 5-1. Interface Layering Diagram Scheduler External Interface Layer This layer refers to the data directly interfacing with hardware o[...]

  • Pagina 116

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-8 ni.com Discrete Subsystem Interface Layer This layer comes in two variations to allow for bot h an optimized and general solution. The external inte rface to a discrete subsystem is represented by two structures, one re presenting the subsystem external inputs and the ot her the subsyste[...]

  • Pagina 117

    Chapter 5 Generated Code Architecture © National Instruments Corporatio n 5-9 AutoCode Reference This sample and hold mechani sm guarantees determini stic behavior for all possible connectivities and is implemented using a technique called double buf fering. Double buf fering in v olves sw apping of pointers. Static Data Within Subsystems The impl[...]

  • Pagina 118

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-10 ni.com Procedure Data Procedure SuperBlocks have inp uts, outputs and states ind ependent of the subsystem from which the procedure is cal led. This is required to properly implement the characteristics of a pro cedure; those characteristics include reusability and reentrancy. Therefor [...]

  • Pagina 119

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-11 AutoCode Reference system, because ordering of the outp uts in a single-rate system is maintained. In a multi-rate system, du plicates can be safely eliminated because of the sample and hold mechan ism. The code to perform both of these activities represent a copy from o[...]

  • Pagina 120

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-12 ni.com Unrolled Interface There is another form of the proced ural interface, th e unrolled interface ( No-UY ). This interface does not use U - and Y -structures to pass the inputs and outputs. The input/output sign als are passed as separate arguments to the function. • Inputs —Ea[...]

  • Pagina 121

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-13 AutoCode Reference Note I f you specify a specific parti tion with the %var name in the block form (that is, A.GAIN ), that %v ar is directly us ed, not indirectly referenced. Example 5-1 Relevant Code to Support Partitioned %vars Within a Procedure /* Xmath variable def[...]

  • Pagina 122

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-14 ni.com EXEC_ERROR: return; } /******* Subsystem 1 *******/ void subsys_1(U, Y) struct _Sys_ExtIn *U; struct _Subsys_1_out *Y; { static RT_INTEGER iinfo[4]; /***** Local Block Outputs. ** ***/ RT_FLOAT foo_2_1; static struct _foo_u foo_2_u; static struct _foo_y foo_2_y; static struct _fo[...]

  • Pagina 123

    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; } /* --------------------------- - Procedure SuperBlock */[...]

  • Pagina 124

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-16 ni.com mixed data-typed v ariables reflecti ng each procedure output signal and type. The states of the procedur e are prov ided by the ar gument S, a pointer to a structu re named _ procedure name _s . This structure contains the double-buf fered pri v ate states used in the procedure,[...]

  • Pagina 125

    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 v alues used by algorithms of blocks in t he procedure. During initialization (tha t is, INIT mode is 1), the pro cedu[...]

  • Pagina 126

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-18 ni.com Extended Procedure Information Structure The -epi option specifies that additiona l elements to all standard procedure SuperBlock’s info structure are to be generated. Currently, only one additional element is generate d. It is named caller_id and is of type RT_INTEGER . Exampl[...]

  • Pagina 127

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-19 AutoCode Reference Notice the relativ e numbering within a task/pro cedure type. Also, be aware that standard procedures are not given a unique identif ier for the purposes of the caller_id element. A standard proce dure SuperBlock uses the id of its caller as its own wh[...]

  • Pagina 128

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-20 ni.com ho wev er , is to create additional sp ace when declaring a variable of the info structure’ s type and for the new code generated with the -epi option, which assumes the f iel d ex ists in all proc edure info structures. Howe v er , the old procedure cannot cal l a procedure ge[...]

  • Pagina 129

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-21 AutoCode Reference Asynchronous Procedures Asynchronous Procedures are procedures th at are not regularly scheduled to be executed or directly called from a subsystem or St andard Procedure. In other words, these procedures require some entity outside of the scope of the[...]

  • Pagina 130

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-22 ni.com Changing %var V alu es During Startup A special feature of the Startup allows the value of a %var to be set at run-time through a Global Vari able Block that has the same name as the %var. Condition Block SystemBuild provides thr ee variations of the Condition Blo ck: Default, No[...]

  • Pagina 131

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-23 AutoCode Reference The BlockScript block allows you to specify conditions and actio ns, define block inputs, ou tputs, and paramet ers, and specify thei r data types and dimensions. BlockScrip t then writes th e update equat ions that process the inputs and parameters to[...]

  • Pagina 132

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-24 ni.com In Example 5-5, alpha, beta, and g amma are the variables to be used as representations for the inpu ts. Alpha is a scalar re presenting th e input from pin 1. Beta is an array of integers representing inputs pins 2 through 6. Gamma follo ws as an array of floa ts representing pi[...]

  • Pagina 133

    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 phase s are intended to be used in a consistent way, just like the standard blocks. There are environment variables that[...]

  • Pagina 134

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-26 ni.com Default Phase If you do not specify a ph ase and/or all code i s not contained within an IF statement guarded by a phase environmen t variable, that code is generated in the Output phase and, if there is a St ate phase, that code also is generated in the State phase. Exam ple 5-6[...]

  • Pagina 135

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-27 AutoCode Reference Local Va riables and Phases A local variable cannot be used to pass data between phases, because the different phases occur at different lo cations in the execution orde r of the whole subsystem or procedure. That is, local variables can be reused for [...]

  • Pagina 136

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-28 ni.com new_total = y; endif; Example 5-8 Generated C ode from Example 5-7 void subsys_1(U, Y) struct _Sys_ExtIn *U; struct _Subsys_1_out *Y; { /***** States Array. *****/ static struct _Subsys_1_states ss _1_states[2] = {{0.0}, {0.0}}; /***** Current and Next States Po inters. *****/ st[...]

  • Pagina 137

    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 simil ar to the discrete equivalents, except that State data is integrated by the integrato r algorithm. This is what is intended[...]

  • Pagina 138

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-30 ni.com In Example 5-9, a hard-subscript, i , is used to access both inputs an d outputs. The reason i is a hard-subscript is that the range of i —that is, the val ues of 1 thro ugh to the numb er of inputs ( u.size )—is known when the code is generated. AutoCode then can unroll the [...]

  • Pagina 139

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-31 AutoCode Reference Example 5-11 Local Variables Used to Al low Loops in Scalar Code Generation Inputs: u; Outputs: y; float u(:), y(u.size), local_u(u.siz e), local_y(y.size); integer i,j; for i = 1:u.size do local_u(i) = u(i); endfor; for i = 1:u.size do for j = i:u.siz[...]

  • Pagina 140

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-32 ni.com • FOR Loop—Can generate either a rolled or unrolled loop depending upon the range of the lo op subscript and wheth er or not scalar code is generated. Examples of Rolled and Unrolled Loops Example 5-12 Unrolled Loop from Example 5-9 /***** Output Update. *****/ /* -----------[...]

  • Pagina 141

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-33 AutoCode Reference Parameters Parameters represent data that can be used to pr ovide data to tun e the algorithm by representing coefficients in equations or persistent data somewhat like states. Parameters are imp lemented as persistent data when generated into code. Pa[...]

  • Pagina 142

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-34 ni.com Example 5-14 BlockScript Block Exam ple 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; y = total; endif; Notice that you also must pre vent[...]

  • Pagina 143

    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 reduce direct traceability from the scri pt to the[...]

  • Pagina 144

    Chapter 5 Generate d 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 Bl ockScript Block Example 5-16 /***** Output Update. *****/ /* ---------------------------- Blo ckScript Block */ /* {deadbsb..2} */ for (i=1; i<=5; i++) { deadbsb[-1+i] = U->deadbsb[-1+i]/0 .001[...]

  • Pagina 145

    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 not easily modeled within the diagram. Unfortunat[...]

  • Pagina 146

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-38 ni.com Parameterized UCB Callout A UCB can be defined with %var para meterized data for the UCB’s real parameters ( RP ) and inte ger parameters ( IP ). When used, AutoCode generates code that p a s s e s t h e % v a r variable as the actual of the UCB callout. A new option, -ucbparam[...]

  • Pagina 147

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-39 AutoCode Reference Software Constructs These blocks provide the software constructs that are ty pically found in any imperative programming language su ch as C, Pascal, and FORTRAN. The following software constructs are supported in SystemBuild and AutoCode: • IfThenEl[...]

  • Pagina 148

    Chapter 5 Generate d 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 respons ible for properly detecting an exit condition and using it as an input t o a BREAK Block insid e the loop. If the input to the BREAK Block is TRUE, then the loo[...]

  • Pagina 149

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-41 AutoCode Reference The Read from V ariable Block optimi zat ion also is support ed for Local V ariable Blocks. Refer to Chapter 7, Code Optimizat ion , for more detail s on optimization. A lso, the sequencing of lo cal variable blocks is similar to that of global variabl[...]

  • Pagina 150

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-42 ni.com representative of a sequence of equations. These equations are sensitive (that is, potentially numerically un stable) to the integration algorithm and order in which the equations ar e computed. Intro ducing multiple continuous subsystems or pro cedur es introduces arbitrary bou [...]

  • Pagina 151

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-43 AutoCode Reference • Algebraic loop s are not supported . • AutoCode only p erforms a single initi alization pass at time = 0.0. This corresponds to the Syst emBuild Simulation options of INITMODE=0 or ACTIMING . Multiprocessor Code Generation Generation for a mult i[...]

  • Pagina 152

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-44 ni.com Distributed Memor y Architecture AutoCode also suppor ts a multiprocesso r architecture that uses distributed memory instead of shared memo ry. AutoCode does this by generatin g callouts (that is, macros) instead of the explicit code, and passes all of the necessary data to the c[...]

  • Pagina 153

    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,siz e) 4. Copy shared data into local data: GET_LOCF_FROM_MBUFF(dest,src) GET_LOCB_FROM_MBUFB(dest,src) GET_LOCI_FROM_MBUFI(dest,src) GET_LOCF_FROM_MBUFI(dest,src) Mapping[...]

  • Pagina 154

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-46 ni.com • SLONG stands for signed long. • ULONG stands for unsigned long. The naming con vention of the callout s uses the terms listed abov e and associates from right to left. The fo llo wing is an example of a callout. UPDATE_MBUFSBYTE_WITH_LOCSBYTE(x, y) The v alue of the local v[...]

  • Pagina 155

    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, convert_macro_name ) UPDATE_MBUFF_WITH_MBUFULONG(x, [...]

  • Pagina 156

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-48 ni.com Example 5-21 shows template code to generate the required structure and pointer . All of the necessary informatio n about the shared variable blocks is accessible from within the template usin g parameter information. Example 5-21 Template Code to Generate Required Shared Variabl[...]

  • Pagina 157

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-49 AutoCode Reference /**** declare pointer to shared vari ables ****/ volatile struct _shared_varblk *isi_ varblk[1] = {&shared_var_blks}; @ENDIFF@ Example 5-21 assumes the existence of a f ictional shared memory tar get such that the compiler supports #pragmas to decl[...]

  • Pagina 158

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-50 ni.com Shared Memor y Callout Option AutoCode supports a shared memory cal lout for all acc ess to elements in shared memory. Callouts are generated when the -smco option is specified. The previous discussion about shared variable blocks still applies. However, the generated code is dif[...]

  • Pagina 159

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-51 AutoCode Reference proc2_4_2 = Read_Shared_Varblk_Fl oat(&isi_varblk[0]->block5[1]); Leave_Shared_Varblk_Section(4); /* ------------------------------- W rite to Variable */ Enter_Shared_Varblk_Section(4); Write_Shared_Varblk_Float(&isi_va rblk[0]->block5[0[...]

  • Pagina 160

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-52 ni.com The formal argument represents the gl obal reference number for which the v ariable block is being accessed. Th e default implementation of those simply calls the Disable( ) function. Leaving Non-Shared (Local) Critical Section The prototype of the callo ut for leaving a non-shar[...]

  • Pagina 161

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-53 AutoCode Reference The formal argument represents the gl obal reference number for which the v ariable block is being accessed. The second formal argume nt, caller_id , represents a unique identif ier for the caller . The default implementation of those simply calls the [...]

  • Pagina 162

    Chapter 5 Generate d Code Architecture AutoCode Reference 5-54 ni.com The first formal argument represents which processor the access is taking place on. Processor numbers are 1-based. The second formal ar gument represents the global reference number for which the variable block is being accessed. The following code uses the En ter_Shared_Varblk..[...]

  • Pagina 163

    Chapter 5 Generated Code Architecture © National Instruments Corporation 5-55 AutoCode Reference The following code uses the En ter_Shared_Varblk... syntax for shared variable block generated code with callouts, using t he -vbco and -epi options. Enter_Shared_Varblk_Section(4, 1); proc2_4_1 = isi_varblk[0]->block5[0] ; proc2_4_2 = isi_varblk[0][...]

  • Pagina 164

    © National Instruments Corporatio n 6-1 AutoCode Reference 6 V ectorized Code Generation This chapter discusses various w ays to generate vectorized code. This includes describing the options availab le, design gui delines, and implementatio n details ab out the vectorized code. Introduction AutoCode has the capabili ty to generate vectorized code[...]

  • Pagina 165

    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 Gener ated for Gain Block Example void subsys_1(U, Y) struct _Sys_ExtIn *U; struct _Subsys_1_out *Y; { static RT_INTEGER iinfo[4]; /******* Initialization. ***** **/ if (S[...]

  • Pagina 166

    Chapter 6 Vectorized Code Generation © National Instruments Corporatio n 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 v alue i is the range <1.. x >, where x is the number of outputs of the block As you can see from the code generation, each of the i th elements of the[...]

  • Pagina 167

    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. *****/ /* --------------------------- - Gain Block */ /* {gain..2} */ for (i=1; i<=10[...]

  • Pagina 168

    Chapter 6 Vectorized Code Generation © National Instruments Corporatio n 6-5 AutoCode Reference addition to issues w ith the standard block library, all general BlockScript Blocks within the diagram are impl emented as 1-based arrays. If the subscript can be evaluated at generation-time, the 0-based subscript wi ll be used. Note The extra computat[...]

  • Pagina 169

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-6 ni.com Figure 6-1. Poorly Connected Gain Block Example 6-3 Generated Code fo r Poorly Connected Gain Block (for Figure 6-1) void subsys_1(U, Y) struct _Subsys_1_in *U; struct _Subsys_1_out *Y; { static RT_INTEGER iinfo[4]; /***** Parameters. *****/ static RT_FLOAT R_P[5]; RT_INTEGER cnt; s[...]

  • Pagina 170

    Chapter 6 Vectorized Code Generation © National Instruments Corporatio n 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] = 4.5*U->gain_1 [5]; Y->gain_2_1[4] = 5.[...]

  • Pagina 171

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-8 ni.com V ector 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 th is type of labeling as a definition of which pins are to be an array. For more i nfor[...]

  • Pagina 172

    Chapter 6 Vectorized Code Generation © National Instruments Corporatio n 6-9 AutoCode Reference Figure 6-2. Example Model Diagram Example 6-4 Maximal Vectorized Code Generation (for Figure 6-2) /******* System Ext I/O type declara tions. *******/ struct _Subsys_1_out { RT_FLOAT delayed_pulse[5]; }; struct _Sys_ExtIn { RT_FLOAT sensor_5[5]; }; /***[...]

  • Pagina 173

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-10 ni.com static struct _Subsys_1_states *X; static struct _Subsys_1_states *XD; static struct _Subsys_1_states *XTMP; static RT_INTEGER iinfo[4]; static RT_INTEGER INIT; /***** Parameters. *****/ static RT_FLOAT R_P[11]; RT_INTEGER cnt; static const RT_FLOAT _R_P[11] = {0.1, 0.0, 0.0, 0.0, [...]

  • Pagina 174

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-11 AutoCode Reference } SUBSYS_PREINIT[1] = FALSE; return; } /***** Output Update. *****/ /* --------------------------- - Time Delay */ /* {VecEx..12} */ if (INIT) { k = 0; for (i=1; i<=5; i++) { X->sensor_delay[k] = R_P [i]; k = k + 1; } } k = 1; for (i=1; i<=5; i[...]

  • Pagina 175

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-12 ni.com Example 6-5 Mixed Vectorized Code Generation (for Figure 6-2) /******* System Ext I/O type declara tions. *******/ struct _Subsys_1_out { RT_FLOAT delayed_pulse[5]; }; struct _Sys_ExtIn { RT_FLOAT sensor_5; RT_FLOAT sensor_11; RT_FLOAT sensor_12; RT_FLOAT sensor_4; RT_FLOAT sensor_[...]

  • Pagina 176

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-13 AutoCode Reference RT_FLOAT Brake; RT_FLOAT Gear; RT_FLOAT Clutch; /***** Algorithmic Local Varia bles. *****/ RT_INTEGER i; RT_INTEGER j; RT_INTEGER k; /******* Initialization. ***** **/ if (SUBSYS_PREINIT[1]) { iinfo[0] = 0; iinfo[1] = 1; iinfo[2] = 1; iinfo[3] = 1; INI[...]

  • Pagina 177

    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->sensor_11; Brake = -6.5*U->sensor_12; Gear = -5.[...]

  • Pagina 178

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-15 AutoCode Reference Note The examples within this section assume maximal vectorization unless otherwi se noted. Multiple Arrays within a Block All blocks support multiple vectors (arrays) as both outputs and inpu ts. However, depending on ex actly how the signals are co nn[...]

  • Pagina 179

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-16 ni.com 1.2, 2.3, 3.4, 4.5, 5.6, 1.0, 1.0, 1.0, 1.0, 1.0}; /***** Local Block Outputs. ** ***/ RT_FLOAT top[5]; RT_FLOAT bottom[5]; /***** Algorithmic Local Varia bles. *****/ RT_INTEGER i; /******* Initialization. ***** **/ if (SUBSYS_PREINIT[1]) { iinfo[0] = 0; iinfo[1] = 1; iinfo[2] = 1[...]

  • Pagina 180

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-17 AutoCode Reference The interesting part is that of the last gain blo ck ( gain..99 ). Notice that although two distinct arrays are used as input, because the input arrays are connected contiguously , the code is rolled into two separate loops. The generalized capability c[...]

  • Pagina 181

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-18 ni.com Figure 6-4. Example of a Split Vector Example 6-7 Generated Code for Sp lit Vector (for Figure 6-4) /***** Output Update. *****/ /* --------------------------- - Gain Block */ /* {gain.top.2} */ for (i=1; i<=5; i++) { top[-1+i] = R_P[-1+i]*U->ga in_1[-1+i]; } /* -------------[...]

  • Pagina 182

    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. No tice that AutoCode was only able to vectorize two inputs while th e remaining fou r were unrolled. AutoCode does not att empt to reconnect your [...]

  • Pagina 183

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-20 ni.com Example 6-8 Generated Code (for Figure 6-5) /***** Output Update. *****/ /* --------------------------- - Gain Block */ /* {gain.top.2} */ for (i=1; i<=5; i++) { top[-1+i] = R_P[-1+i]*U->ga in_1[-1+i]; } /* --------------------------- - Gain Block */ /* {gain.bottom.1} */ for[...]

  • Pagina 184

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-21 AutoCode Reference Y ou shou ld notice two things in the code shown in Example 6-8. First, the gain block added to mer ge the data is generated as copies from the respectiv e inputs into the single arra y . Second, the integrator block is tightly rolled. I f the merge was[...]

  • Pagina 185

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-22 ni.com Figure 6-6. Copy-Back Example Example 6-9 Generated Code (for Figure 6-6) void subsys_1(U, Y) struct _Sys_ExtIn *U; struct _Subsys_1_out *Y; { /**** some code deleted ****/ /***** Output Update. *****/ /* --------------------------- - Gain Block */ /* {gain.top.2} */ for (i=1; i<[...]

  • Pagina 186

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-23 AutoCode Reference Eliminating Copy-Back There are many design ways to eliminat e or hide the extra copies of the copy-back. All of them can be categorized into two groups: • Use Mixed V ectorization mod e and force scalars to be used for the block is sparse external ou[...]

  • Pagina 187

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-24 ni.com Figure 6-7. Vectorized Procedure Interface Example 6-10 Generated Code (for Figure 6-7) /******* Procedure: vecproc *******/ void vecproc(vecproc_1, vecproc_2_1, I) RT_FLOAT vecproc_1[5]; RT_FLOAT vecproc_2_1[5]; struct _vecproc_info *I; { /**** some code deleted ****/ /***** Outpu[...]

  • Pagina 188

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-25 AutoCode Reference top[-1+i] = R_P[-1+i]*U->ga in_1[-1+i]; } /* --------------------------- - Procedure Super Block */ /* {vecproc.3} */ vecproc(&top[0], &Y->vecproc_3 _1[0], &vecproc_3_i); iinfo[0] = vecproc_3_i.iinfo[0 ]; if( iinfo[0] != 0 ) { vecproc_[...]

  • Pagina 189

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-26 ni.com INIT := TRUE; X := ptr_of(ss_1_states(0)’ address); XD := ptr_of(ss_1_states(1) ’address); X.sensor_delay := (others = > 0.0); XD.sensor_delay := (others => 0.0); for cnt in RT_INTEGER range 0..10 loop R_P(cnt) := RP(cnt); end loop; SUBSYS_PREINIT(1) := FALSE; return; end[...]

  • Pagina 190

    Chapter 6 Vectorized Code Generation © National Instruments Corporation 6-27 AutoCode Reference ------ Swap state pointers. ------ XTMP := X; X := XD; XD := XTMP; INIT := FALSE; end; V ectorization of the BlockScript Block The general BlockScript block is commonly used to im plement very complicated or custo m algorithms w ithin a single blo ck. A[...]

  • Pagina 191

    Chapter 6 Vectorized Code Generation AutoCode Reference 6-28 ni.com Matrix Outputs When you provide matricized output labeli ng for a block, AutoCode generates the resulting “matrix” as a si ngle-dimensional array, even in Ada. This means that the output of a matrix -labeled block and the output of a vector-labeled block are id entical, provide[...]

  • Pagina 192

    © National Instruments Corporatio n 7-1 AutoCode Reference 7 Code Optimization This chapter explains the details of generating pro duction quality code for micro controller-based applications. Generally, micro con troller-based applications have stringent requirements for code size and execu tion speed. AutoCode supports various optimizatio ns tha[...]

  • Pagina 193

    Chapter 7 Code Optimization AutoCode Reference 7-2 ni.com static RT_INTEGER iinfo[4]; /***** Local Block Outputs. *****/ RT_FLOAT new_11_1; RT_FLOAT new_1_1; RT_FLOAT new_12_1; /******* Initialization. *******/ if (SUBSYS_PREINIT[1]) { iinfo[0] = 0; iinfo[1] = 1; iinfo[2] = 1; iinfo[3] = 1; SUBSYS_PREINIT[1] = FALSE; return; } /***** Output Update.[...]

  • Pagina 194

    Chapter 7 Code Optimization © National Instruments Corporatio n 7-3 AutoCode Reference Example 7-2 Code Generated with Va riable Block Optimization Turned On /* Model variable definitions */ RT_FLOAT var; RT_FLOAT var1; void subsys_1(U, Y) struct _Sys_ExtIn *U; struct _Subsys_1_out *Y; { static RT_INTEGER iinfo[4]; /***** Local Block Outputs. ****[...]

  • Pagina 195

    Chapter 7 Code Optimization AutoCode Reference 7-4 ni.com iinfo[1] = 0; } return; EXEC_ERROR: ERROR_FLAG[1] = iinfo[ 0]; iinfo[0]=0;}} AutoCode performs this opt imization only if it is safe to do so. There could be circumstan ces that could po tentially prevent this optimization from taking place. AutoCode looks for the presence of a write-to-the-[...]

  • Pagina 196

    Chapter 7 Code Optimization © National Instruments Corporatio n 7-5 AutoCode Reference Write to the same variable block. Due to the cyclic nature of loops, any Write to V a riable block inside the loop appears in between the Read from V ariable block out side the loop and its use inside the loop. Restart Capability AutoCode generates cod e that su[...]

  • Pagina 197

    Chapter 7 Code Optimization AutoCode Reference 7-6 ni.com static const RT_FLOAT _R_P[8] = {-1.0, 1.0, 1.5, 2.0, -1.0, 1.0 , 1.25,1.4}; /***** Local Block Outputs. *** **/ RT_FLOAT proc_2_1; RT_FLOAT proc_14_1; RT_FLOAT proc_12_1; /***** Algorithmic Local Varia bles. *****/ RT_INTEGER ilower; RT_INTEGER iupper; RT_FLOAT uval; RT_INTEGER k; RT_FLOAT [...]

  • Pagina 198

    Chapter 7 Code Optimization © National Instruments Corporatio n 7-7 AutoCode Reference the buf fer _R_P and the initialization code are optimized aw ay . Instead, the buff e r R_P (parameter array), states, deriv ati ves, and info structures are initialized directly in the declaratio n portion. After these structures are modified by computations, [...]

  • Pagina 199

    Chapter 7 Code Optimization AutoCode Reference 7-8 ni.com Merging INIT Sections Most of the dynamic blocks have explicit ini tialization, output update and state update sections. The initializat ion section is guarded by an INIT Boolean variable that is TRUE only for the first time a subsystem or a procedure is called. Each initializati on section [...]

  • Pagina 200

    Chapter 7 Code Optimization © National Instruments Corporatio n 7-9 AutoCode Reference /* ---------------------------- Time Delay */ /* {proc..22} */ if (INIT) { X->proc_22_S1 = 0.0; } proc_22_1 = X->proc_22_S1; /* ---------------------------- Time Delay */ /* {proc..24} */ if (INIT) { X->proc_24_S1 = 0.0; } proc_24_1 = X->proc_24_S1; [...]

  • Pagina 201

    Chapter 7 Code Optimization AutoCode Reference 7-10 ni.com X->proc_22_S1 = 0.0; X->proc_24_S1 = 0.0; XD->proc_22_S1 = 0.0; XD->proc_24_S1 = 0.0; /* ---------------------------- Time Delay */ /* {proc..22} */ X->proc_22_S1 = 0.0; /* ---------------------------- Time Delay */ /* {proc..24} */ X->proc_24_S1 = 0.0; SUBSYS_PREINIT[1] =[...]

  • Pagina 202

    Chapter 7 Code Optimization © National Instruments Corporation 7-11 AutoCode Reference In Example 7-5, both time delay block s hav e separate INIT sect ions. In Example 7-6, the initialization code for these blocks is m erged along with the subsystem initialization sect ion. Reuse of T emporar y Block Outputs Subsystems and procedures g enerated b[...]

  • Pagina 203

    Chapter 7 Code Optimization AutoCode Reference 7-12 ni.com Example 7-7 shows code generated wit hout the reuse opt ion, and Example 7-8 shows code generated from the same models wi th the maximal reuse option. Example 7-7 Code Fragment wi thout Reuse Optimization /***** Local Block Outputs. *** **/ RT_FLOAT model_2_1; RT_FLOAT model_3_1; RT_FLOAT m[...]

  • Pagina 204

    Chapter 7 Code Optimization © National Instruments Corporation 7-13 AutoCode Reference } Y->model_5_1 = X->model_5_S1; /* ---------------------------- Gai n Block */ /* {model..2} */ model_2_1 = 2.0*U->model_1; /* ---------------------------- Sum of Vectors */ /* {model..3} */ model_3_1 = model_2_1 - U->model_1; /* --------------------[...]

  • Pagina 205

    Chapter 7 Code Optimization AutoCode Reference 7-14 ni.com All of the blocks can accept constants as inputs. If any input is a v ailable during code generation time as a co nstant , the constant is used instead of a symbol name (or variable name). This applies to blocks of both categories. One limitation to this optim ization is that a block cannot[...]

  • Pagina 206

    Chapter 7 Code Optimization © National Instruments Corporation 7-15 AutoCode Reference /* {const..4} */ Y->const_4_1 = 2.0*const_2_1; .. .. Example 7-10 Code Generated with the Constant Propagation Option void subsys_1(Y) struct _Subsys_1_out *Y; { static RT_INTEGER iinfo[4]; /***** Local Block Outputs. ***** / /******* Initialization. *******/[...]

  • Pagina 207

    Chapter 7 Code Optimization AutoCode Reference 7-16 ni.com input of the gain blo ck and the expression 2.0 * const_2 is ev aluated to 4 as the value of const_2_1 is 2. Hence, the subsystem output gets the va lu e 4 . The command-line opti on for in voking this optimization is -Opc . Optimizing with Matrix Blocks Outputs labeled as matrices are gene[...]

  • Pagina 208

    Chapter 7 Code Optimization © National Instruments Corporation 7-17 AutoCode Reference constant block is optimized away , including the ou tput variable. Also notice that the existing Constant Propag atio n optimization can be used with the constant block, but will only operate on scalar pieces of the constant block output. Optimizing with Callout[...]

  • Pagina 209

    Chapter 7 Code Optimization AutoCode Reference 7-18 ni.com If you hav e decided on the MatrixRigh tDi vide block, the tips for op timizing the inputs are much the same as for th e MatrixIn verse block. In this case there are two inputs, A and B, and both are modified by the callout algorithm. Thus, a copy-in must o ccur for each input. Again, you c[...]

  • Pagina 210

    Chapter 7 Code Optimization © National Instruments Corporation 7-19 AutoCode Reference Summar y All of the optimizations discussed so far can be used at the same time without limitations. All of these optimizations can work togeth er and potentially bring about a cumulative ef fect in reducing the code size or improving the execution speed of an a[...]

  • Pagina 211

    © National Instruments Corporatio n 8-1 AutoCode Reference 8 AutoCode Sim Cdelay Scheduler This chapter discusses the Sim Cdelay low-latency sched uler. Introduction The default AutoCode scheduler is based on high throughp ut. Latency is acceptable as long as scheduler interrup t times are frequent. Because of this emphasis, each scheduler cycle i[...]

  • Pagina 212

    Chapter 8 AutoCode Sim Cdelay S cheduler 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. T ask Posting Policies The task characteristics that have th e [...]

  • Pagina 213

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporatio n 8-3 AutoCode Reference Standard AutoCode Scheduler To illustrate the behavior of the standard AutoCode schedu ler with triggered and enabled Su perBlocks, it is helpful to consider the diagno stic model shown in Figure 8-1, which featu res such SuperBlocks driven by a 5 Hz[...]

  • Pagina 214

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-4 ni.com Figure 8-1. Model with Enabled and T riggered T asks 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 relati ve to its trigger input (immediately below), [...]

  • Pagina 215

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporatio n 8-5 AutoCode Reference Scheduler Pipeline section that these latencies are caused by the single posting stage per scheduler in v ocation in the default AutoCode scheduler , and by the output posting policy assigned to enabled blocks in the default scheduler . Figure 8-2. L[...]

  • Pagina 216

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-6 ni.com triggers/enables have gone hig h are que ued 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. 1, 2 Datastores are written fr om ex[...]

  • Pagina 217

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporatio n 8-7 AutoCode Reference queue tasks stage for that scheduler in v ocation 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 sec. Thus, its outp ut is not po sted until th[...]

  • Pagina 218

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-8 ni.com Now the inherent problem in the standard scheduler is clear . From launch to output posting, you suffer a two-c ycle delay for triggered tasks, and a three-cycle delay for enabled tasks, in stead of the standard unit cycle delay present on real-time hardware for free-running per[...]

  • Pagina 219

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporatio n 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-tim e targets, which mimics th e behavior of Sim with Cdelay ( actiming off). Sim with Cdelay differs from Sim with actim[...]

  • Pagina 220

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-10 ni.com triggers arriving too quickly can pr ev ent a task from e ver posting an y output. Y ou must build an alternative AutoCode scheduler incorporating the new pipeline stages presented abo ve, and change the transition diagrams of many of the task types to reflect changed output po[...]

  • Pagina 221

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-11 AutoCode Reference Figure 8-6. New STD for A TR T riggered T asks Figure 8-7. New STD for A TR T riggered T asks IDLE RUNNING BLOCKED task done Timer is zero and enable , reset timer and post outputs Timer is zero and !enable , reset timer and post outputs Timer greate[...]

  • Pagina 222

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-12 ni.com These transition diagrams, together with the diagrams in C hapter 4, Managing and Scheduling Appli cations , of the AutoCode User Guide , define the behavior of tasks under the Sim with Cdelay schedul er . They encompass all of the changes to the de fault scheduler outside the [...]

  • Pagina 223

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-13 AutoCode Reference DataStore Priority Problem As mentioned, you must fin d some way to enforce the priori ty of writers to DataStores in the generated code. Each DataStore register can be written to independently, so each one needs to be independently subjected to the [...]

  • Pagina 224

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-14 ni.com for tsk <- low_prio_tsk..high_prio_t sk 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 cod e, the prioriti[...]

  • Pagina 225

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-15 AutoCode Reference Figure 8-8. Latencies Present in the AutoCode Scheduler T emplate Configuration for Enhanced Performance As mentioned in a previous section, th ere are drawbacks to re-executing an ATR task when it is re-triggered befo re its out puts have been poste[...]

  • Pagina 226

    Chapter 8 AutoCode Sim Cdelay S cheduler AutoCode Reference 8-16 ni.com At the template level, the def ault Sim with Cdelay A TR triggered task behavior of re-queueing a task for ex ecution on receipt of a new trigger before the outputs hav e been poste d can be turned of f by replacing the segment call Sim_style_ATR_Idle by a call to NoRetrigger_s[...]

  • Pagina 227

    Chapter 8 AutoCode Sim Cdelay Scheduler © National Instruments Corporation 8-17 AutoCode Reference that repeated until no new tasks wher e queued for execution. Given such an implementation, the chained ANC problem would disappear. However, under such a design, scheduler executi on time would be variable and data dependent—undesirable attributes[...]

  • Pagina 228

    © National Instruments Corporatio n 9-1 AutoCode Reference 9 Global Scope Signals and Parameterless Procedures This chapter discusses global scope signals and parameterless procedures. Introduction The memory and performance requirem ents of real-time production code force the issue of glo bal variables. AutoCode does not generally use global vari[...]

  • Pagina 229

    Chapter 9 Global Scope Signals and Paramete rless Procedures AutoCode Reference 9-2 ni.com These ne w features address the following two uses: • Data Monitoring/Injection —The safe access to local subsystem signals for the purpose of monitoring th e signal’ s value during the ex ecution of the model. This is intend ed as a way to pro vide deb[...]

  • Pagina 230

    Chapter 9 Global Scope Signal s and Parame terless Procedures © National Instruments Corporatio n 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 out puts as Global Scope when generating vectorized code . NI recommends[...]

  • Pagina 231

    Chapter 9 Global Scope Signals and Paramete rless Procedures AutoCode Reference 9-4 ni.com Limitations This section identifies some of the limitations of scoped output . Unsupported Blocks The following list presents the bl ocks that do not support scoped outputs. • Blocks that are not supported by AutoCode • Write-to V ariable Block • DataSt[...]

  • Pagina 232

    Chapter 9 Global Scope Signal s and Parame terless Procedures © National Instruments Corporatio n 9-5 AutoCode Reference Parameterless Procedure A parameterless (argument-less) procedur e is a procedure that uses global variable(s) to pass input(s) into and/or ou tput(s) out of the procedure. Each input and output can be individu ally selected to [...]

  • Pagina 233

    Chapter 9 Global Scope Signals and Paramete rless Procedures AutoCode Reference 9-6 ni.com Note NI suggests that you adopt a naming conv ention for all of your global v ariables used for parameterless procedure signals. For exampl e, specify all of the names with a leading “g, ” like gThrottleValue . Output Specification Procedure outputs are s[...]

  • Pagina 234

    Chapter 9 Global Scope Signal s and Parame terless Procedures © National Instruments Corporatio n 9-7 AutoCode Reference Condition Block Code Generation The Condition Block supports the use of parameterless procedures. In the nodefault and sequential modes, the Conditio n Block will not buffer the global outputs of the procedure into the R_P (real[...]

  • Pagina 235

    Chapter 9 Global Scope Signals and Paramete rless Procedures AutoCode Reference 9-8 ni.com Note Y ou mu st write template code to customi ze the declarations of these variables, which includes usage of the Memory Address st ring because this is tar get/compiler specif ic information. Issues and Limitations This section identifies some other it ems [...]

  • Pagina 236

    Chapter 9 Global Scope Signal s and Parame terless Procedures © National Instruments Corporatio n 9-9 AutoCode Reference Connection to External Output If a signal that is used as input to a Global Scop e procedure input or a Global Scope procedure output is connected to a extern al output pin, be aware that the external output pins will be updated[...]

  • Pagina 237

    Chapter 9 Global Scope Signals and Paramete rless Procedures AutoCode Reference 9-10 ni.com Analyzer and AutoCode W arnings The Analyzer reports questionable connect ivities or situations regarding usage of the Global Scope signals. Also, AutoCod e might report additional warnings during code generation. Evaluate these warnings and verify that the [...]

  • Pagina 238

    © National Instruments Corporatio n A- 1 AutoCode Refer ence A T echnical Support and Professional Ser vices Visit the following sections of the National Instruments Web site at ni.com for technical support an d professional services: • Support —Online technical support resources at ni.com/support include the following: – Self-Help Resources[...]

  • Pagina 239

    © National Instruments Corporatio n I-1 AutoCode Reference Index A add and subtract macros, 2-40 arguments UCB-Ada fixed calling, 3-12 UCB-C fixed calling, 2 -13 arithmetic macros, 2-35 array iinfo, 5-17 IP, 5-16, 5-17 R_P for vectorized code, 6-4 rinfo, 5-17 RP, 5-16, 5-17 subscripts vectorized code, 6-4 asynchronous procedures. See g enerated co[...]

  • Pagina 240

    Index AutoCode Reference I-2 ni.com compile_ada_sa.sh compilation script, 3-11 compile_c_sa.sh compilation script, 2-11 compiling, 2-1 condition block. See generated code architecture, condition code Condition SuperBlock, 9-7 conditions and actions, 5-23 configuration file. See RTOS, configuration file CONTINUE Block, 5-40 continuous subsystems. Se[...]

  • Pagina 241

    Index © National Instruments Corporatio n I-3 AutoCode Reference _.a extension (Ada), 3-3 compile_ada_sa.sh, 3-11 compile_c_sa.sh, 2-11 sa_defn.a, 3-4 sa_defn.h, 2-3, 2-4 sa_defn_.a, 3-5 sa_fmath.a, 3-4 sa_fmath_.a, 3-4, 3-5 sa_fuzzy.a, 3-4 sa_fuzzy.h, 2-4 sa_fuzzy_.a, 3-4 sa_fx.h, 2-32 sa_fx_externs.c, 2-33, 2-34 sa_fx_f.c, 2- 34 sa_fx_f.h, 2-33 [...]

  • Pagina 242

    Index AutoCode Reference I-4 ni.com bitwise functions, 3-26 comparing to sim results, 3-35 compilation example, 3-21 compiler problems, 3-35 conversion functions, 3-27, 3-31 creating instances of functio ns, 3-17 data types, 3-17 division function, 3-31 explicit rounding co nversion, 3-32 files in the src directory, 3-21 fixed-point data types, 3-2[...]

  • Pagina 243

    Index © National Instruments Corporatio n I-5 AutoCode Reference Olvarblk option, 7-4 Onorestart option, 7-5 propagating constants (O pc option), 7-13 removing restart capability, 7-5 reusing temporary block outputs, 7-11 reusing temporary block outputs as specified, 7-11 variable block optimization, 7-1 vbco opt ion, 7-4 real-time operating syste[...]

  • Pagina 244

    Index AutoCode Reference I-6 ni.com distributed memory architecture, 5-44 mapping command optio ns, 5-45 shared memory architecture, 5-43 callouts, 5-44 optimization for read-from variable blocks, 5-4 Sequencer Block, 5-41 similarities to compiler, 5-1 single-rate system, 5-8 software constructs, 5-39 subsystems. See subsystems symbolic names defau[...]

  • Pagina 245

    Index © National Instruments Corporatio n I-7 AutoCode Reference L local variabl e blocks, 5-40 , 5-41 local variables, 5-27 M macro interface, 2-27 files needed, 2-27 Macro Procedure SuperBlocks. See generated code architecture, Macro Procedure SuperBlocks MATH_LIB (Ada), 3-5 MatrixInverse, 7-17 MatrixLeftDi vide, 7-17 MatrixRightDivide, 7-17 N N[...]

  • Pagina 246

    Index AutoCode Reference I-8 ni.com R R_P, 5-9 UCB fixed call argument, Ada, 3-12 rapid prototyping, 1-2 real-time code generating, 3-16 real-time file, 3-16 related publications, 1-4 reusable procedure s example, 2-22 generated subsystem function, 2-25 generated UCB wrapper function, 2-24 generating, 3-14 linking, 2-15, 2-17, 2-21, 2-22 (Ada), wit[...]

  • Pagina 247

    Index © National Instruments Corporatio n I-9 AutoCode Reference sa_fxdiv_long.c file, 2-32, 2-34 sa_fxdiv_short.c file, 2-34 sa_fxlimit.h file, 2-32, 2-33 sa_fxm.h file, 2-32, 2-33 sa_fxm_f.c file, 2-34 sa_fxm_f.h file, 2-33 sa_fxmp.h file, 2-32, 2-33 sa_fxmp_f.h file, 2-33 sa_fxmul_byte.c file, 2-3 4 sa_fxmul_long.c file, 2-32, 2-3 4 sa_fxmul_sh[...]

  • Pagina 248

    Index AutoCode Reference I-10 ni.com shared memory callouts, 5-50 fixed-point callouts Ada, 5-47 C, 5-46 shared variable block sup port, 5-47 simulation, stand-alone, 2-1 soft-subscript, 5-29 software (NI resources), A-1 software constructs. See generated code architecture, software constructs stand-alone simulation, 2-1 stand-alone utility file, 2[...]

  • Pagina 249

    Index © National Instruments Corporation I-11 AutoCode Reference template code for variable block structures, 5-48 timing overflow, 2-8 training and certificatio n (NI resources), A-1 troubleshooting (NI resources), A-1 U U (UCB fixed call argument) Ada, 3-12 C, 2-13 UCB, 2-3, 2-20, 3-4 argument s C, 2-13 calling C, 2-13 categories of, 5-37 code f[...]

  • Pagina 250

    Index AutoCode Reference I-12 ni.com X X (UCB fixed call argument) Ada, 3-12 C, 2-13 XD (UCB fixed call argumen t) Ada, 3-12 C, 2-13 XINPUT array, 2-10 Xmath {matrixx,ascii}, 2-7 XOUTPUT array, 2-10 Y Y (UCB fixed call argument) Ada, 3-12 C, 2-13[...]