Implementing Overriding Routines


Although the SansGUI Development Environment is not required, you become a developer when you start to override some simulator routines. You will need to consult the SansGUI Reference Manual and the documentation of your specific simulator. In this section, we will discuss the necessary information for implementing overriding routines in DLLs and provide some pointers for your further investigation.

Understanding SansGUI Data Types

SansGUI uses a unique data type system that contains three sections used in different times:

You need to be familiar with the data types used in the SansGUI environment and in your particular simulator, especially those used in the classes that you will implement overriding functions.

Understanding SansGUI Data Object Format

Two data structures, SG_VALU and SG_OBJ, specify the internal representation of SansGUI Data Objects that is essential to implementing and communicating among class functions and overriding routines. They can be found in the chapter titled SansGUI Data Object Format in the SansGUI Reference Manual.

Understanding SansGUI API

One great feature in programming the overriding routines for your simulator in the SansGUI environment is that you have only one application programming interface (API) to learn. All the class functions use the same function prototypes with the same set of function arguments and return values. There are different times the class functions will be called, but the function prototype remains the same. For more details, consult the SansGUI Application Programming Interface section in the SansGUI Reference Manual.

Creating Overriding DLLs with Visual C++

Although there is no limitation in how you should break down the overriding functions into different dynamic-linked libraries (DLLs), we recommend that the overriding functions for a class should be contained in a single DLL. Reasons for it is that the overriding functions in different classes share the same set of function names and it is easier to maintain the class functions and keep track of the class attributes of the same class in one DLL module.

A skeleton source file SGover.cpp, located in the inc subdirectory of the SansGUI installation directory, is provided for you as a starting point to create an overriding DLL for a class. It defines all the DLL function entry points in the class. Although you may not implement all the functions, you do not need to remove the unused functions. They just return SG_R_OK by default. What you will need to do in the DLL creation procedure is to open the SGover.cpp file and save it to the source directory where your DLL project is located before inserting your own code to the source file.

Configuring Visual C++ IDE

You need to configure the Visual C++ interactive development environment (IDE) only once to include SansGUI's inc directory in the include file path. To do so, use Tools>Options... from the pull-down menu. In the Options dialog, click on the Directories tab and in the Show Directories for: field, select Include files. If the inc subdirectory in your SansGUI installation directory is not listed in the Directories, you need to add a new entry and select the inc subdirectory to include it. You can enter the directory path directly or use the Browse button (labeled with ...) to locate it. Click on the OK button to commit the addition.

Creating DLL

To create a DLL for the overriding routines in a class, do the following:

The DLL is created under the Release subdirectory of your project directory. Now, you can run SansGUI and specify the overriding DLL path in the Object, or Part Properties dialog. See the previous section on Locating Dynamic-Linked Library.

Tracing and Debugging DLL code

For debugging your overriding DLL code, a new configuration based upon the Release build can be created and modified to include debug information. We recommend that you create a Win32 Trace configuration as following:

If you have other instances of SansGUI environment opened, make sure that they do not have the test Project Model loaded. Now, you can start the debugging session by invoking SansGUI from within the Visual C++ IDE:

Creating Overriding DLLs with Visual Fortran

Similar to C/C++ DLL creation, there is no limitation in how you should break down the overriding functions into different dynamic-linked libraries (DLLs), we recommend that the overriding functions for a class should be contained in a single DLL.

A skeleton source file SGover.f, located in the inc subdirectory of the SansGUI installation directory, is provided for you as a starting point to create an overriding DLL for a class. It defines all the DLL function entry points in the class. Although you may not implement all the functions, you do not need to remove the unused functions. They just return SG_R_OK by default. What you will need to do in the DLL creation procedure is to open the SGover.f file and save it to the source directory where your DLL project is located before inserting your own code to the source file.

Configuring Compaq Visual Fortran IDE

You need to configure the interactive development environment (IDE) only once to include SansGUI's inc directory in the include file path. To do so, use Tools>Options... from the pull-down menu. In the Options dialog, click on the Directories tab and in the Show Directories for: field, select Include files. If the inc subdirectory in your SansGUI installation directory is not listed in the Directories, you need to add a new entry and select the inc subdirectory to include it. You can enter the directory path directly or use the Browse button (labeled with ...) to locate it. Click on the OK button to commit the addition.

Building DLL

To create a DLL for the overriding routines in a class, do the following:

The DLL is created under the Release or Debug subdirectory of your project directory. Now, you can run SansGUI and specify the overriding DLL path in the Object, or Part Properties dialog. See the previous section on Locating Dynamic-Linked Library.

Tracing and Debugging DLL code

For debugging your overriding DLL code, you will use the Debug build of the DLL.

If you have other instances of SansGUI environment opened, make sure that they do not have the test Project Model loaded. Now, you can start the debugging session by invoking SansGUI from within the Visual Fortran IDE:

 



C:\FH_Suite\htmlgifs\home.gif Locating Dynamic-Linked Library Customizing SansGUI Environment

SansGUI Modeling and Simulation Environment Version 1.2

Copyright © 2000-2003 ProtoDesign, Inc. All rights reserved.

http://protodesign-inc.com