2

I'm thinking about writing a C function which basically passes an array/vector of real numbers to a VHDL implementation as an argument and the VHDL code does some computation using the array in a FPGA and returns the result back to the C function. So, my question - How do I go about writing a C function to call the VHDL implementation? Can anyone guide me in the right direction like a tutorial,API or anything?

Any help will be appreciated. Thanks! :)

6
  • Probably not without a TON of work. There's nothing that can be done in software that can't be done in hardware, since eventually everything happens in the hardware anyway, but working with floating point numbers in any HDL is a huge pain. See if your FPGA vendor has some IP or libraries that can help - they may have a floating-point coprocessor that you can use. Commented Jun 18, 2015 at 22:10
  • 1
    Where is the C code running? How is that processor connected to the FPGA? Commented Jun 18, 2015 at 22:22
  • Do you mean a passing data to an actual FPGA running synthsized VHDL code or just some simulation that's running VHDL? Commented Jun 18, 2015 at 22:39
  • Yes, I mean passing data to an actual FPGA running synthsized VHDL code. Sry, I'm just getting started with FPGAs. Want to try something interesting. Commented Jun 18, 2015 at 23:17
  • 3
    You would need the FPGA to provide a register interface and use a driver to transfer the data to the FPGA. Or use DMA. That is definitively not a beginner's job, much less with PCIe. You seem to have a completely wrong idea how FGPA-design actually works. Note that VHDL is not a programming language, but a hardware description language. Try to do some blinking LED wiith an FPGA in VHDL first. The you might get an idea. Much later, you might think about synthesizing VHDL code from a program (I would not use C for that, however - think of e.g. Python, Ruby, etc.). Commented Jun 18, 2015 at 23:21

1 Answer 1

4

VHDL does not result in a run time routine, it turns into an actual implementation in HW. To be able to communicate with a VHDL routine to/from a high level lalnguage in a CPU, the CPU and the VHDL module must be connected and the VHDL code must have proper mean to provide data from the CPU.

In your case, there are 2 ways, one is that the VHDL is implemented in a way that the shared data can be accessed by both the CPU and the FPGA logic, in that case, you need to know what that address is. The other way is if the VHDL is providing data via serial port, or USB or ethernet to the CPU, but in both cases, this must be supported by the VHDL routine.

In any case, you need to know a lot more about the FPGA than just making a procedure call.

This article might help you a bit to understand who things works (might not be the right FPGA either, but probably helps anyway).

How to interface FPGAs to microcontrollers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.