![]() |
![]() |
![]() |
![]() |
![]() |
GR to PR Conversion
It is possible to convert diagrams from SDL/GR to SDL/PR. In the conversion, SDL diagrams are translated from the binary files into PR files, possibly containing CIF information. All graphical symbols in that diagram will be replaced by their corresponding keywords and any text in the symbols will be copied to the output file. When possible, the definitions in the output file will appear in the same order as in the input.
The conversion is used by the SDL Analyzer as the first step in the analysis process, and also by the SDT2CIF Converter to convert to PR that preserve the graphical layout information. You can also convert to PR by the Generate PR command in the Tools menu, or by using the Public Interface (see GRPR).
The PR/CIF files produced by the SDL Suite fill various purposes:
- As a way to export information to other SDL tools
- As a temporary storage format that is used as input to the static and semantic analyzer
- As a format that is suitable for reading by the user. To produce this format, the PR file should be pretty printed.
Mapping between GR and PR
The following list defines the mapping between the GR and PR forms:
- In general, when symbols of the same type are converted, symbols are ordered first of all by the page ordering within the diagram. Within the same page symbols are ordered such that a symbol with a low y-coordinate (closer to the top) will be converted first. If two symbols have the same y-coordinate the symbol with the lowest x-coordinate is treated first.
- When analyzing systems using macros, all macros are converted to PR before they are expanded. This restricts the usability of macros, for instance the number of inlets and outlets must be 0 or 1.
- A merge symbol (a flow line connected to another flow line) is translated to PR using join and label constructs. The labels introduced will be named grst0, grst1, and so on, starting on grst0 at each diagram. In macro diagrams, the labeling is grst0%MACROID... If the label already exists in the GR diagram, the sequential number is incremental until the label is unique.
- A block diagram may contain a block substructure diagram without its frame and heading if the block diagram does not contain any definitions but the substructure. This rule is applied to all the pages in the block diagram that are of the block interaction type.
- When specifying a header in GR, it must be specified according to the PR syntax and the valid input signal set should be written into the heading symbol and not in a text symbol as specified by the GR syntax.
- References to graphical symbols, which will be used by the Analyzer in error messages, are stored in the PR file using SDL comments beginning with the character "#". It is therefore recommended that you do not write comments beginning with "#".
- To be able to perform a correct conversion of SDL/GR Substructure diagrams to SDL/PR, the enclosing diagram type, block/channel or block type, must be known. For a channel going to the environment, a name outside the frame must be a gate name, generating the via construct, if the enclosing diagram is a block type, and a channel name, generating connect statements, for other cases.
- If nothing is known about the enclosing diagram type, it is assumed that the diagram is a block.
- To resolve the ambiguity, a qualifier can be used in the kernel heading to determine the enclosing diagram type. Alternatively the Analyzer directive #BLOCKTYPE can be used to indicate that the enclosing diagram is a block type diagram. This directive should be added to the diagram kernel heading.
Differences when generating CIF
In general the PR generated as input to the analyzer will be the same as generated for CIF but for some constructs there are differences due to language limitations or to get a better error detection.
- The conversion of a graphical comment symbol differs dependent on if the translation is made to CIF or not. When converting to CIF, the PR generated is the <comment> PR construct; in other cases, including when performing Analysis, the graphical comment is converted to "/* text inside graphical comment symbol */".
- The SDL editor supports the possibility to place the comment symbol without connecting it to another symbol. When generating PR without CIF this comment will be converted to PR as described above. When generating CIF the CIF comment will be
/* CIF Comment (500,100) Right */
/* text in unconnected comment */
This standalone nonstandard CIF construct will be recognized by the CIF2SDT application such that the original comment symbol will be restored in the diagram.- In the SDL editor you can connect many comments to the same symbol. This is an extension to the SDL language. For this graphical construct there is no immediate translation to PR. When generating PR without CIF the comments are generated according to the note above and there will be no problems. However, when generating CIF the comment will be generated using the <comment> PR construct. As there only can be one <comment> to each symbol there is no direct possible translation in PR for many comments. In this case the extra comment symbols are handled as if they were unconnected to the symbol. This means that when regenerating a diagram from the CIF code, the diagram will not be exactly the same as the original diagram as the extra comments will now be unconnected.
- When generating non-CIF all unattached comments will be attached to a symbol that is closest to the comment. In this way the comment text will be generated as if the text belongs to this symbol.
- There is a difference also for graphical connections. If a channel C1 has a graphical connector to the outer channel outerC and another channel C2 also has a graphical connector to outerC, but the points where outerC is drawn is not the same, the conversion for CIF will contain two connect statements:
/* CIF ... */
connect outerC and C1;
/* CIF ... */
connect outerC and C2;
- This PR will produce a semantic error according to SDL-92, but will be correct when using SDL-96.
- When using non-CIF conversion, the two graphical connections will be combined into one statement, provided that the two texts specifying outerC are lexically the same, thus writing outerC in one text and out_\nerC in the other (\n is a newline) will not be treated as the same text. They are still considered the same if only the case differs.
connect outerC and C1,C2;- When PR is generated for a macrodefinition the macro inlet and macro outlet symbols will differ whether CIF is generated or not. As there are no corresponding PR to these symbols nothing will be generated when generating CIF except of course for the CIF statements itself. For non-CIF a note will generated indicating that these symbols are present in the diagram.
/* Macro Inlet Symbol */
- A task having no text or having only a note/comment is allowed in GR. The correct PR correspondence is the compound statement construct having an empty statement
task { };
- As this PR will restrict the use of the simulator command Next-Symbol the PR generated for non-CIF is an empty informal text
task '';- CIF generation for the class symbol is not supported. The generation for non-CIF is described in Class Information.
Error and Warning Message
This section contains messages that may be produced during the GR to PR conversion.
When the Public Interface performs the conversion from GR to PR, the messages will be displayed in the Organizer log. The reply message on the service will indicate that the conversion has been done and it will also contain the number of errors produced.
If the conversion for some reason fails, the reply message will contain a text stating the kind of problem that has occurred. See further the GRPR service in the Public Interface.
ERROR 5001 Unexpected end of flow
This message indicates that a symbol has been found that has no following flowline and according to the SDL syntax there must be one. In addition to the error message the following line is generated in the PR:
***** Unexpected end of flow *****WARNING 5002 More than one line entering macro outlet
This message indicates that inside a macro there are more than one line entering the macro outlet symbol. This situation should be avoided as this can lead to syntax errors (which are hard to track) if this macro is expanded inside decision branches.
The easiest way to avoid this situation is to add a no-action task symbol with the text `' and use this as the last symbol in the macro. Let all lines enter this task symbol and add a single line between this task and the macro outlet.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |