![]() |
![]() |
![]() |
![]() |
![]() |
Differences between Cmicro and Cadvanced
General
This description deals with the differences between the generated C code of the Cadvanced SDL to C Compiler and the Cmicro SDL to C Compiler and the run-time libraries. There are differences because the main application area for the code generators differ.
Some of the differences discussed in the following are of interest for SDL users, while others are not.
SDL Restrictions
The Cmicro SDL to C Compiler has more SDL restrictions than the Cadvanced SDL to C Compiler. The additional restrictions are described in the subsection SDL Restrictions.
Furthermore, there are restrictions within the Cmicro Library that may affect the user's SDL system design. These restrictions are listed in the following. More technical information can be found in the section Generation of Identifiers.
- The run time model in Cmicro is such that there are global variables used in the generated C code and the Cmicro Library. The code generation uses "Auto initialization in C" quite extensively because the C compiler then can produce code that is more efficient than if initialization would take place within a generated C function (like yInit).
- The run-time model of the preemptive kernel requires function recursion from the C compiler.
Scheduling
First, it must be emphasized that both schedulers conform fully with SDL, although the schedulers introduce a different behavior.
Cadvanced uses a process ready queue together with signal queues in order to schedule processes. Cmicro does not use a process ready queue but all scheduling is derived from one physical queue. This physical queue represents all SDL process input ports. Logically, or seen from SDL, each SDL process has its own input port.
Another difference is the preemptive scheduler of Cmicro, if it is used.
Thus, different execution of processes will occur.
It is also a question of SDL design whether the differences between Cadvanced and Cmicro can be externally recognized.
If no SDL process assumes a particular real-time behavior from its communicating partner process then the behavior - as seen from a black box view - is always the required one.
Generation of Files
The Cmicro SDL to C Compiler generates some more files. This is of interest when implementing build scripts, makefiles and so on.
It is important that after each change in the SDL system the Cmicro Library is re-compiled. The reason for this is the automatic scaling facility. Please view Automatic Scaling Included in Cmicro.
Environment Handling Functions
The main differences arise when considering the environment handling functions. However, this only has consequences if the SDL environment is the same in both cases (if Cadvanced is used for simulation only and Cmicro for targeting, then the environment functions are to be implemented twice in any case).
Instead of including scttypes.h as in Cadvanced, for Cmicro the following include statements are to be introduced in the header of the environment module:
#include "ml_typ.h"#include "<systemname>.ifc"In general (for Cmicro as well as Cadvanced) four C functions are used to represent the SDL environment, namely
The functions have the same general meaning for Cadvanced and Cmicro, but there are a few differences so that it is necessary to implement the environment twice.
For Cmicro, each of the above C functions is compiled only if it is required (selected by XMK_USE_xInitEnv, XMK_USE_xInEnv...)
Differences occur in the declaration of the C functions xInEnv() and xOutEnv().
The xInEnv() function of Cmicro carries no parameters.
The xOutEnv() function of Cmicro carries a few parameters which represent the signal which is to be output to the environment, including the signal parameters. It is recommended that the definition of the C function xOutEnv() should be written twice, once for Cadvanced and once for Cmicro.
The environment functions can also be generated with the help of the Targeting Expert.
Another difference is that signals and processes are identified in different ways. Cmicro does not use identifications like xIdNode. Instead, it uses fixed C defines to identify signals and processes. This is beneficial in reducing the amount of memory but has the consequence that each access to any signal and any process is to be implemented differently. Process type IDs are generated into the file sdl_cfg.h, signal IDs and type definitions are generated into the <systemname>.ifc file. The chapter about the Cmicro SDL to C Compiler gives more details on how identifiers are generated and can be used.
Including C Code in SDL by User
C code may be included in SDL by the user in the following cases:
- In order to connect SDL to the environment in a way other than via the C functions xInEnv() / xOutEnv()
- To use C constructs, which do not exist in SDL
- To use existing C code (e.g. C library functions)
- To implement the body of ADTs
- In an SDL task.
If any C code or C identifiers are used, then users must use the right identifiers and functions.
Generated C Code
Of course, the generated C code is different when comparing Cmicro with Cadvanced. It would take too much room to list all the details in this subsection. In any case these differences are of interest for certain technical reasons only and not for pure SDL users.
To compare the different code generator outputs, the user should refer to the subsection Output of Code Generation.
General Recommendations Regarding Compatibility
In order to reach full compatibility between Cadvanced and Cmicro, the following general recommendations should be followed:
- In general, C code should not be used in SDL diagrams.
- If there is no option other than to use C code, the C code should be written as compatible as possible, i.e. the C code should be written without using any C code generator or compiler specific commands. Also the C code should be placed at dedicated locations, and should not be distributed over the SDL diagrams.
- If it is not possible to reach full compatibility, then the C code must be written twice. A switch, which is used when invoking the C compiler, selects C code either for Cadvanced or for Cmicro. The macro XSCT_CMICRO will help to distinguish automatically.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |