![]() |
![]() |
![]() |
![]() |
![]() |
Exceptions for Directives
Selecting File Structure for Generated Code - Directive #SEPARATE
The purpose of the separate generation feature is to specify the file structure of the generated program. Both the division of the system into a number of files and the actual file names can be specified. There are two ways this information can be given.
- Normally this information is set up in the Organizer, using the command in The Organizer. Here file names for the generated files can also be specified. In the Make dialog in the Organizer (see Generated Files) it is possible to select full separate generation, user-defined separate generation, or no separate generation.
- For an SDL/PR file that is generated by running the SDL Analyzer as a stand-alone tool, the same information can be entered by #-SEPARATE directives directly introduced in the SDL program. Full separate file generation, user-defined separate file generation, or no separate file generation can be set up in the command interface of a stand-alone Analyzer, see Set-Modularity.
The Cmicro SDL to C Compiler can generate a separate file for:
Example 580 : #SEPARATE Directive
system S; /*#SEPARATE 'filename' */block B; /*#SEPARATE */process type P1 inherits PType; /*#SEPARATE */process P2 (1, ); /*#SEPARATE */procedure Q; /*#SEPARATE */In the example above the two versions of separate directive, with or without file name, are shown. As can be seen a file name should be enclosed between quotes. The Cmicro SDL to C Compiler will append appropriate extensions to this name when it generates code.
If no file name is given in the directive, the name of the system, block, process, or procedure will be used to obtain a file name. In such a case the file name becomes the name of the unit with the appropriate extension (.c .h) depending on contents. The file name is stripped of characters that are not letters, digits or underscores.
The possibility to set up full, user-defined, or no separation in the Organizer's Make dialog and in the user-interface of a stand-alone Analyzer (see Generated Files), can be used in a simple manner to select certain default separation schemes. This setting will be interpreted in the following way:
- No separation.
The whole system will be generated into one file.- User defined separation.
The system, each package, and each unit that the user has specified as separate will become a separate file.- Full separation.
The system, each package, each block, block type, and process, and process type will become a separate file. Note that even in this case a procedure is separate only if the user has specified it as separate.Independently if No, User defined, or Full separation has been selected, the Cmicro SDL to C Compiler will use the file name specified in the Edit Separation dialog or the #SEPARATE directive, for a file that is to be generated.
An Example of the Usage of the Separate Feature
In the following example a system structure and the #SEPARATE directives are given. The same information can easily be set up in the Organizer as well. This example is then used to show the generated file structure depending on selected generation options.
Example 581 : #SEPARATE Directive
system S; /*#SEPARATE 'Sfile' */block B1; /*#SEPARATE */process P11; /*#SEPARATE 'P11file' */process P12;block B2;process P21;process P22; /*#SEPARATE */Applying Full Separate Generation
If Full separate generation is selected then the following files will be generated:
Sfile.c Sfile.h B1.c B1.h P11file.c P12.c B2.c B2.h P21.c P22.cThe .c files contain the C code for the corresponding SDL unit and the .h files contain the module interfaces.
Applying Separate Generation
If User defined separate generation is selected then the following files will be generated:
Sfile.c Sfile.h B1.c B1.h P11file.c P22.cThe user defined separate generation option thus makes it possible for a user to completely decide the file structure for the generated code. The comments on files and extensions given above are, of course, also valid in this case.
Applying No Separate Generation
If the separation option No is selected, only the following file will be generated:
The comments on files and extensions earlier are valid even here.
Guidelines
Generally a system should be divided into manageable pieces of code That is, for a large system, full separate generation should be used, while for a small system, no separate generation ought to be used. The possibility to regenerate and re-compile only parts of a system usually compensate for the overhead in generating and compiling several files for a large system.
A file name has to be specified, using the Organizer Edit Separation command or the #SEPARATE directive, if two units in the system have the same name in SDL and should both be generated on separate files. Otherwise the same file name will be used for both units.
Assigning Priorities - Directive #PRIO
#PRIO for Processes
Priorities can be assigned to processes using the directive #PRIO. The process priorities will affect the scheduling of processes, see Scheduling. A priority is a positive integer, where low value means high priority. #PRIO directives should be placed directly after the process heading in the definition of the current process.
Example 582 : #PRIO Directive .
Process P1; /*#PRIO 0 */Process P2(1,1); /*#PRIO 1 */Process P3 : P3Type; /*#PRIO 0 */Process P4(1,1) : P4Type; /*#PRIO 1 */Processes that do not contain any priority directive will have a user defined default priority with the name xDefaultPrioProcess.
There are some things to be kept in mind when using process priorities:
- Priorities have to begin with zero.
- Priorities have to be consecutive (0,1,2,3,4,5).
- All instances of a type have the same priority.
- Priority decreases with increasing numbers (zero is the highest priority level).
- The default priority is to be in the range of zero to the highest priority number, that is 0 or 1 in the example above.
#PRIO for Signals
Priorities can be assigned to signals using the directive #PRIO. The signal priorities will also effect the scheduling of processes, see Scheduling.
Signal priorities can be specified, either:
It is impossible to specify #PRIO in a SDL input. Cmicro will ignore any occurrence of #PRIO in SDL input.
Signal priorities do affect the SDL output and the SDL create actions only.
The following rules are to be considered here:
- Signal priorities have to be in the range from 0 to 255.
- Signal priorities do not have to be consecutive, as process priorities have to be.
- If not specified otherwise (in SDL output) all instances of a signal have the same priority.
- Signal priority decreases with increasing numbers (zero is the highest priority level).
- The signal default priority is to be specified by the user (-xDefaultPrioSignal), and must in the range of 0 to 255. As a recommendation, this value should be set to 100, so that both higher, as well as lower priorities can be declared with #PRIO.
- Signal priorities come after process priorities.
- If no #PRIO is specified for a signal, neither in its declaration, nor in any output, Cmicro uses xDefaultPrioSignal for each occurrence of that signal in an output.
- If #PRIO is specified only in the declaration of a signal, Cmicro uses this specified priority in each occurrence of that signal in an output.
- If #PRIO is specified in a specific output of a signal, but not in its declaration, then the specified #PRIO value is taken from the output. If the signal is output without #PRIO, in that case -xDefaultPrioSignal will be used.
- For dynamic process creation, an internal create signal is used. This signal carries the priority defined by XMK_CREATE_PRIO. As a general recommendation, this priority should be higher than any other signal priority.
The following example will give more explanations (note, that the values PA, PB are of sort pid):
Example 583 : #PRIO Directive .
SignalS1, /*#PRIO 11 */S2, /*#PRIO 22 */S3,S4; /*#PRIO 44 */....output S1 to PAoutput S1 to PB; /*#PRIO 55*/....output S3 to PC;output S3 to PD; /*#PRIO 66*/Assuming the following C definition:
#define xDefaultPrioSignal 100the following priorities will then be generated:
output S1 to PA --->use of prio 11output S1 to PB--->use of prio 55....output S3 to PC--->use of prio 100output S3 to PD--->use of prio 66Modifying Outputs - Directive #EXTSIG, #ALT, #TRANSFER
There is no difference for the #EXTSIG, #ALT and #TRANSFER directives for Cmicro compared with Cadvanced, except that the use of it will sometime lead to a better performance. This is because if #EXTSIG for example is used in the case of an output to the environment, the user can prevent the Cmicro Kernel to be called (and the xOutEnv function to be executed).
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |