Linking foreign object files to GHDL
You may add additional files or options during the link of GHDL using
-Wl, as described in Passing options to other programs.
will create the
math_tb executable with the
c library is always linked with an executable.
The process for personal code is the same, provided the code is provided as a C source or compiled to an object file.
Analysis must be made of the HDL files, then elaboration with
-e -Wl,personal.c [options...] primary_unit [secondary_unit] as arguments.
Additional C or object files are flagged as separate
-Wl,* arguments. The elaboration step will compile the executable with the custom resources.
Further reading (particularly about the backend particularities) is at Elaboration [-e] and Run [-r].
Linking GHDL object files to Ada/C
As explained previously in Wrapping a simulation (ghdl_main),
you can start a simulation from an Ada or C program. However the build
process is not trivial: you have to elaborate your program and your
First, you have to analyze all your design files. In this example, we
suppose there is only one design file,
Then, bind your design. In this example, we suppose the entity at the
design apex is
Finally, compile/bind your program and link it with your VHDL
gcc my_prog.c -Wl,`ghdl --list-link design`
$ gnatmake my_prog -largs `ghdl --list-link design`
See GCC/LLVM only commands for further details about