Hi Jon, > > I am attempting to write a multithreaded application in VHDL, using GHDL > as the compiler. I need to call from C a function written in VHDL and > compiled into object form using GHDL back into the VHDL code somehow, > since I can't get direct access to pthreads from VHDL.
Did you check the VHPI interface? You can call C stuff from VHDL, but maybe you've run into issues with pointers? I'd imagine calling VHDL routines from C a little riskier. See below about comments to linking. > > I see that my main function work.init_pkg.init shows up in the symbol > table of the VHDL object file: > > 000000000000008b g F .text00000000000000d0 work__init_pkg__init > > I have tried using: > > extern void work__init_pkg__init(); > > in my C code, but at link time the compiler claims that it can't find > the symbol: > > ghdl -e --workdir=../../work -Wl,-l:../lib/libc_scandir_.o > -Wl,-l:../lib/clock_posix_.o -Wl,-l:../lib/threader_.o -Wl,-ldl > -Wl,-lpthread controlix > ../lib/threader_.o: In function `thread': > /home/jon/controlix-code-0/src/lib/threader_.c:20: undefined reference > to `work__init_pkg__init' > > Any ideas what's wrong, or what I should be doing differently? > The symbol have a prepended '_' to be called from C directly. You'd have to probably develop some sort of wrapper and/or use nasty inline assembler hacks. BTW, GHDL does not appear to be thread safe. I've been calling the VHDL side from a C thread via VPI which randomly quits or does other funny things. The only stable way exchanging data between a C and a GHDL simulation thread I found so far was using a software FIFO. It's all covered up in the ghdlex code posted here somewhere. Cheers, - Martin _______________________________________________ Ghdl-discuss mailing list [email protected] https://mail.gna.org/listinfo/ghdl-discuss
