Download 20-Sim code generation for ADSP-21990 EZ-KIT
Transcript
20-Sim code generation for ADSP-21990 EZ-KIT /* the global variables */ XXDouble %VARPREFIX%start_time = %START_TIME%; XXDouble %VARPREFIX%finish_time = %FINISH_TIME%; XXDouble %VARPREFIX%step_size = %TIME_STEP_SIZE%; XXDouble %VARPREFIX%%XX_TIME%; XXInteger %VARPREFIX%steps; XXBoolean %VARPREFIX%%XX_INITIALIZE%; XXBoolean %VARPREFIX%major = XXTRUE; Fig. 3: Part of standard 20-sim code generation template The template files connection to the real world: DLL-calls Virtually every possible target (robots, I/O-devices, micro-controllers etc.) has connections to the physical world, like AD-converters (for sensor readings) and DA-converters (to excite actuators). These functions (as components of the used target) have to be simulated in 20-Sim. When generating code, however, the simulation code has to be replaced by target specific function calls. These program functions contain drivers for the components. These drivers have to be designed by the user. For testing purposes, 20-Sim makes use of dll-function calls in 20-Sim submodels: Y = dll(filename, functionname, X); This dll-call invokes a certain function in a certain dynamic link library on an input matrix X. The output of this function is matrix Y. The function also returns 20-Sim an integer, which can be either 0 or 1. When a 1 is returned (meaning an error has occurred), 20-Sim immediately stops simulating and reports an error. Summarizing: to simulate certain target specific functions, a dynamic link library has to be created (and put in the directory …\20-Sim\bin). When generating code, the dll-call above will be replaced by an ANSI-C function-call: void filename_functionname(double *inarr, int inputs, double *outarr, int outputs, int major) This statement is put into a token and then placed into the template. This means that the user has to add a target specific template file (with the same filename as the dll has) to standard template files (see Section 5.3.3), which contains the implementation of the target specific functions, like the function “functionname” in previous example. Pre- and postprocessing When 20-Sim has finished generating code, all generated files are placed (default; it is also possible to specify the destination path in the code generation dialog window) in the directory C:\temp\%MODEL_NAME%. Now it is possible for the user to add postcommands to his design (Error! Reference source not found.: Targets.ini), which, for example, could invoke a compiler and a linker, so that the generated code can be uploaded to the target. These postcommands are treated as DOS commands. It is also possible to add precommands, which enables the user to execute a program before 20-Sim generates code. 31