![]() |
![]() |
![]() |
![]() |
Compiling and linking FLI applications
The following platform-specific instructions show you how to compile and link your FLI applications so they can be loaded by ModelSim. Microsoft Visual C/C++ is supported for creating Windows DLLs while gcc and cc compilers are supported for creating UNIX shared libraries.
Although compilation and simulation switches are platform-specific, references to load shared objects are the same for all platforms. For information on loading objects see "Using the VHDL FLI with foreign architectures" and "Declaring a foreign subprogram in VHDL" .
Windows platforms
Under Windows ModelSim loads a 32-bit dynamically linked library for each FLI application. The following compile and link steps are used to create the necessary.dll file (and other supporting files) using the Microsoft Visual C/C++ compiler.
cl -c -I<install_dir>\modeltech\include app.c link -dll -export:<C_init_function> app.obj \ <install_dir>\modeltech\win32\mtipli.libMultiple -export options can be specified, one for each different FOREIGN attribute function name. <C_init_function> is the function name specified in the FOREIGN attribute.
The FLI interface has been tested with DLLs built using Microsoft Visual C/C++ compiler version 4.1 or greater.
Note: The gcc compiler cannot be used to compile FLI applications under Windows. This is because gcc does not support the Microsoft .lib/.dll format. 32-bit Linux platform
Under Linux, ModelSim loads shared objects. Use these gcc or cc compiler commands to create a shared object:
gcc -c -I/<install_dir>/modeltech/include app.c ld -shared -E -o app.so app.occ -c -I/<install_dir>/modeltech/include app.c ld -shared -E -o app.so app.o
Note: The compiler switch -freg-struct-return must be used when compiling any FLI application code that contains foreign functions that return real or time values. 32-bit Solaris platform
Under SUN Solaris, ModelSim loads shared objects. Use these gcc or cc compiler commands to create a shared object:
gcc -c -I/<install_dir>/modeltech/include app.c ld -G -B symbolic -o app.so app.occ -c -I/<install_dir>/modeltech/include app.c ld -G -B symbolic -o app.so app.o
Note: When using -B symbolic with ld, all symbols are first resolved within the shared library at link time. This will result in a list of undefined symbols. This is only a warning for shared libraries and can be ignored. If app.so is not in your current directory you must tell Solaris where to search for the shared object. You can do this one of two ways:
- Add a path before app.so in the foreign attribute specification. (The path may include environment variables.)
- Put the path in a UNIX shell environment variable:
LD_LIBRARY_PATH= <library path without filename>64-bit Solaris platform
See "Using 64-bit ModelSim with 32-bit FLI Applications" for more information on 64-bit platforms.
On a 64-bit Sun system, use the following cc compiler commands to prepare FLI code for dynamic linking with ModelSim:
cc -v -xarch=v9 -O -I/<install_dir>/modeltech/include -c app.c ld -G app.o -o app.so32-bit HP700 platform
ModelSim loads shared libraries on the HP700 workstation. A shared library is created by creating object files that contain position-independent code (use the +z or -fpic compiler option) and by linking as a shared library (use the -b linker option). Use these gcc or cc compiler commands:
gcc -c -fpic -I/<install_dir>/modeltech/include app.c ld -b -o app.sl app.o -lccc -c +z -I/<install_dir>/modeltech/include app.c ld -b -o app.sl app.o -lcNote that -fpic may not work with all versions of gcc.
for HP-UX 11.0 users
If you are building the FLI shared library under HP-UX 11.0, you should not specify the "lc" option to the invocation of ld, since this will cause an incorrect version of the standard C library to be loaded.
In other words, build shared libraries like this:
cc -c +z -I/<install_dir>/modeltech/include app.c ld -b -o app.sl app.oIf you receive the error "Exec format error" when the simulator is trying to load an FLI shared library, then you have most likely built under 11.0 and specified the
"-lc" option. Just rebuild without "-lc" (or rebuild on an HP-UX 10.0 machine).64-bit HP platform
See "Using 64-bit ModelSim with 32-bit FLI Applications" for more information on 64-bit platforms.
On a 64-bit HP system, use the following cc compiler commands to prepare FLI code for dynamic linking with ModelSim:
cc -v +DA2.0W -O -I/<install_dir>/modeltech/include -c app.c ld -b app.o -o app.so32-bit IBM RS/6000 platform
ModelSim loads shared libraries on the IBM RS/6000 workstation. The shared library must import ModelSim's C interface symbols and it must export the C initialization function. ModelSim's export file is located in the ModelSim installation directory in
modeltech/rs6000/mti_exports.If your foreign module uses anything from a system library, you'll need to specify that library when you link your foreign module. For example, to use the standard C library, specify `-lc' to the `ld' command. The resulting object must be marked as shared reentrant using these gcc or cc compiler commands for AIX version 4.x:
gcc -c -I/<install_dir>/modeltech/include app.c ld -o app.sl app.o -bE:app.exp \ -bI:/<install_dir>/modeltech/rs6000/mti_exports -bM:SRE -bnoentry -lccc -c -I/<install_dir>/modeltech/include app.c ld -o app.sl app.o -bE:app.exp \ -bI:/<install_dir>/modeltech/rs6000/mti_exports -bM:SRE -bnoentry -lcThe app.exp file must export the C initialization functions named in all FOREIGN attributes.
64-bit IBM RS/6000 platform
See "Using 64-bit ModelSim with 32-bit FLI Applications" for more information on 64-bit platforms.
Only version 4.3 of AIX supports the 64-bit platform. A gcc 64-bit compiler is not available at this time. The cc commands are as follows:
cc -c -q64 -I/<install_dir>/modeltech/include app.c ld -o app.s1 app.o -b64 -bE:app.exports \ -bI:/<install_dir>/modeltech/rs64/mti_exports \ -bM:SRE -bnoentry -lc
Note: When using AIX 4.3 in 32-bit mode, you must add the switch -DUSE_INTTYPES to the compile command lines. This switch prevents a name conflict that occurs between inttypes.h and mti.h.
![]() Model Technology Inc. Voice: (503) 641-1340 Fax: (503)526-5410 http://www.model.com sales@model.com |
![]() |
![]() |
![]() |
![]() |