Hello,i want to share my experience with VHPIDIRECT (standard direct binding) to call subprograms in vhdl. The algorithm is mentioned in the GHDL guide for GHDL version 0.22 (Interfaceing to other languages). So with the help of these examples, i just want to make things clear and improve a better understanding with VHPIDIRECT in VHDL and C.
I used the gcc-version 4.7.2-5 and the ghdl-version 0.29 with debian 7.8 (wheezy) on a 32bit machine.
1) struct <-> record"Records are represented like a C Structure and are passed by reference to subprogramms" (chapter 5.8.2@page 26)
_algorithm_: a) create a record variable, initialize the two integer values of the record
and print them in vhdl
b) pass the record to c (it is now represented as struct)
and print them again (to be sure that they are equal)
c) get new values (by the user) for the struct and print
them again in c and after that in vhdl
to be sure that the changes are done and they are equal
d) success >> purpose is to demonstrate the flow of data
from vhdl to c
e) create a new struct in c, initialize the two integer
values of the struct,
print them in c and pass the struct to vhdl
f) in vhdl print the integer values again, change them,
print them again and pass the struct back to c
g) success >> purpose is to demonstrate the flow of data
from c to vhdl
2) char array[][] <-> array (..) of std_ulogic_vector(..) a.k.a. two dimensional field
_algorithm_: a) create in vhdl a array (..) of std_ulogic_vector(..) (lets call it just "_vhdl_array_") and pass it to c i use the *inout* parameter in the vhdl procedure, because the value of a *inout* parameter is variable b) print the default\empty vhdl_array in c and fill it within two for-loops in c c) print the changed vhdl_array in vhdl within two for-loops (just to be sure they are equal) d) change the value of some fields in vhdl, pass it to c and print it again inc to be sure the changes are done e) success ;-) >> purpose is to demonstrate the flow of data from vhdl to c so in c you can change the vhdl_array.
sry for my bad english and i hope could help someone. in the end it`s something :) i want to know more about vhpi/vhpidirect/interfacing to other languages in ghdl so just let me know if you have a hint for me.
cheers
VHPIDIRECT.tar.gz
Description: GNU Zip compressed data
_______________________________________________ Ghdl-discuss mailing list [email protected] https://mail.gna.org/listinfo/ghdl-discuss
