Electronic – Dynamically Configure FPGA From Host Program

cfpgapsocxilinx

I was wondering if anyone knows an efficient way to program the FPGA(PL) for a Xilinx Zynq-7 series or related devices,from a host C program (not on the SoC, but from the host PC). Is there an Xilinx API I can use/include in my program. As the only way I can think of doing it at the moment is invoking command line programming via Impact (which is not very elegant).

Basically I want to put the SDK "Program FPGA" functionality in my host C program where the user selects a prebuilt .bit file (and .elf file if possible) to program the FPGA/(SoC). This is just for a test of concept, later I would like to put this dynamic configuration onto one of the ARM CPU's.

Many Thanks
Sam

Best Answer

Depends on how you're connecting the FPGA to the host. If you're using the Xilinx JTAG cable, you're pretty much stuck with Impact. However, if you have a different interaface to the host, then it would not be too difficult to, say, write a loader interface that can accept a bit file and overwrite the configuration flash. Then all you need to do is reboot the board, and you're good to go. I would suggest loking at the Xilinx configuration guide for the part you're using; it will have more specific information about the various configuration interfaces.

Edit: Interesting; there isn't a separate config guide for the Zynq parts. Take a look at chapter 6 of the technical reference manual, Xilinx ug585. Loks like the procedure is to boot one core from flash, then have the core load the FPGA config. If you can load a new config into RAM over any arbitrary interface, then as long as resetting the programmable logic portion does not stop the core from accessing the image in RAM, you can reset the FPGA and load the new configuration from RAM. Looks like you need to use AXI-PCAP. I would imagine that you can also update the ARM core software, but I am not sure what the proper prcedure would be. Do you have any external program memory, or are you only utilizing on-chip memory? If you can use external memory, then maybe you can 'stage' a new image in external memory, then copy it back into internal memory before starting it. Bascally, you just need a way to squirrel away a little bit of code that can reload the FPGA configuration and then reload and/or start the ARM core software.