C API for the Pynq

Hi all,

We have written a C API for the Pynq which is available at GitHub - mesham/pynq_api: C API drivers for PYNQ FPGA board and fairly well documented.

Whilst the Python API is fantastic, we have been working on a number of projects interacting with the Zynq from compiled C code executed via the command line. As such calling out to Python from these C codes isn’t ideal, and-so we put together a C based API to avoid this (and also many other languages interact with C a bit easier than they do with Python.) We have found this helpful in our work, so I thought I would post it on here in-case it is of interest or use to other people working with the Pynq too.

Cheers,
Nick

3 Likes

Hi Nick,

Great work on this.

It appears that this API does not make use of the HWH file. Is that correct?

The interrupt API seems to require polling. Do you plan on providing an asynchronous API?

Cheers,
Rob

Hi Rob, thanks for the reply. Yes you are right, the design decision we took is that the user provides the bitstream which the API will deploy, but they are responsible for knowing aspects such as IRQ numbers, memory addresses etc from the block design which are provided to the calls (in this manner the level of abstraction provided by the API is lower than the approach taken by the Python API). I think there is a more general point here too, that some software to parse the HWH file and display all the information would be quite nice to develop (and indeed Xilinx might have already done this) - not only in this situation, but for other boards also.

Good point on the interrupt polling, I hadn’t though about making it interrupt driven but we could absolutely do that (either at the API level using pthreads and a user provided callback, or I wonder if Linux provides a mechanism we could hook into to do this.)

Cheers,
Nick

Hi Nick, I’m a student and i dont have much experience on this field, my question is:
Can this API be used on Zynq ultrascale? I have an idea about using this API on my Kria Kv260, but i see on github that the API are used for 7-series.

Hi - I haven’t tried it but I suspect it might (maybe with a few minor changes). Please let us know, it is pretty simple so if it needs some tweaks to support the Kria then that should be OK if Pynq supports the Kria which I think it does (I guess it might need some of the paths etc tweaked at lines 48 to 69 and Python Pynq will have these so it’s a matter of extracting them out).

Cheers,
Nick