Electronic – standard way to put compiled code onto a processor embedded in an FPGA


If you use a standalone microcontroller (ARM/Atmel/PIC etc), you typically (these days) use an in-circuit programmer. Then you can either use a debugger or "crash and burn" methods (probably with a terminal interface) to develop your code.

I can get that with the correct HDL code, you might integrate a microprocessor or controller with your FPGA hardware design.

But how do you then get your code onto it? and how do you debug it? do you also synthesise a way to load compiled code? or is the code somehow build into the bitstream that you load onto the FPGA? is there a standard method, or does it vary by platform?

Best Answer

The answer depends on where you plan to store your code. Some examples:

  1. For small programs you may use on-chip memory in the FPGA for the instruction memory of the processor. You might choose to use a power-up memory initialisation file for the memory. Most major FPGA vendors allow this. However in the event of memory corruption, you would have to reconfigure the FPGA to recover.

  2. For testing you can typically use a JTAG programmer to load software into the instruction memory of the processor and boot it. However this is rarely useful for production, but is really useful for debugging.

  3. For larger programs you might, if your processor design allows, execute programs directly from some external non-volatile flash memory. Commonly CFI flash memories are used.

  4. You could use DDR memory for large software (e.g. embedded OS's). The memory would be initialised from a non-volatile source (e.g. CFI Flash, SD Card, etc.). Typically you would need some preloader software to achieve this (a small program that runs when the processor is reset to copy the software to the DDR memory).

There are many forms of FPGA, and embedded processors (including the now common place SoC devices that have hard IP ARM cores). As such there is no "standard" way to achieve this, but rather application specific ways. More specific examples include:

  • Intel/Altera NIOS processors come with a preloader software to allow copying instruction software from CFI or EPCQ flash devices to on-chip or DDR memory each time the device is reset.

  • Embedded ARM processors typically have a built in boot ROM that contains a small piece of software to initialise the processor and load software (e.g. preloader, application, etc.) from a predefined source. Some even allow booting from a source within the FPGA side of the SoC device.