essage in the Simulator trace window, the ObjectGeode-specific write and writeln procedures can be called, from a procedure call symbol (if you use a task symbol, you will get an error). Executing the example shown in Figure 8.15 produces the trace: *** n=0 * process test1 WRITE ('***') WRITELN ('n = ', n,' ***') Figure 8.15 Calling write and writeln 8.2.2 Calling external C code 8.2.2.1 Introduction You may want to reuse existing C code: for example, in the V.76 SDL model, instead of writing a complex CRC (a kind of checksum) computation in the procedure CRCok, you could call an existing C function. The ObjectGeode Simulator provides several ways to call external C (or C++) code: SDL operators and SDL procedures can be implemented as C functions. The same interfacing mech- anism is provided in the ObjectGeode C application generator. 8.2.2.2 Example of SDL procedure implemented as a C function We will modify our SDL V.76 model to replace the SDL procedure CRCok by the C function crcok. A. In a new empty directory, make a copy of any version of v76.pr (copy also v76. startup and the files it loads), and load it into the SDL Editor. 280 Validation of Communications Systems with SDL package V76 procedure CRCok FPAR crc1 Integer RETURNS Boolean Simplified version, returns True if crc1 This procedure CRCok is positive or null. checks the CRC crc1 >= 0 Figure 8.16 The procedure CRCok in SDL B. In the package V76, delete the procedure CRCok shown in Figure 8.16. C. In the package V76, create a text symbol containing the external declaration of procedure CRCok, as shown in Figure 8.17. package V76 PROCEDURE CRCok; FPAR crc1 Integer; RETURNS Boolean; EXTERNAL Figure 8.17 The procedure CRCok declared external D. Select Tools > SDL & MSC Simulator, and check that the working directory is correct. E. In the ObjectGeode Launcher, remove any file other than v76.pr, and press the Build button: as the keyword EXTERNAL has been used in the procedure declaration, the Simulator has generated the file v76.h, shown in Figure 8.18, c