Newsroom > Blog

FPGAs, Microcontrollers and Embedded Processors

Oct 19, 2023

Within the embedded space, we are typically interested in taking in data from the outside world, performing processing, and outputting data for consumption. For the processing we use a processing element capable of interfacing with hardware, such as sensors or buttons, and engineers typically choose between a microcontroller and an FPGA. However, could it be possible to achieve both within an FPGA? We will explore both technologies and answer this question.

Fpga vs microcontrollers

Microcontrollers Overview

A microcontroller is a microprocessor with memory and peripherals capable of handling inputs and outputs within a single chip. See the figure below for a typical block diagram of a microcontroller noting the peripherals such an I2C module, ADC, PWM, and timers.

Microcontrollers

Figure 1: Microcontrollers

Microcontrollers having CPUs run sequentially where instructions are executed line by line within a fetch-decode-execute loop. They are also typically programmed in languages such as C, C++ and most recently Rust, where the code is compiled down to machine level code targeting the specific microcontroller architecture.

The primary benefit of a microcontroller is ease of use. At the hardware level it typically only requires a single voltage rail for power, as well as reference voltages and a clock — which is all trivial on a two-layer printed circuit board (PCB). From the software perspective we can also use commonly learned languages and apply computer science principles with an awareness that the CPU frequency and memory capabilities will be significantly less than a desktop application.

In terms of applications, microcontrollers are a great fit when the number of I/Os aren’t too large, accuracy in timing below the order of microseconds is not required, and data is processed sequentially. For example, a microcontroller could be used within a washing machine, oven, or water sensor system. In this final application example, a suitable sensor is selected to measure the water depth, and a microcontroller assists by performing calculations and updating the LCD on the order of hundreds of milliseconds.

FPGA Overview

Field Programmable Gate Arrays are a completely different beast to microcontrollers. They can be considered as a silicon canvas composed of building blocks for configuring digital circuits in a programmable way. We can think of the internals as a “sea of gates” where all the gates are running in parallel, as shown below:

FPGA Ssea of Gates

Figure 2: FPGA Sea of Gates

With FPGAs we configure the logic within them using hardware description languages such as VHDL or Verilog and use a design flow involving steps that include synthesis and place and route with a final step of sending a bitstream. Conceptually speaking, the design flow considers data transfer taking place on clock edges of flip flops with elements such as lookup tables or multipliers in between known as the Register Transfer Level. This is a complete paradigm shift to the software world, where now everything happens in parallel since we are dealing with hardware.

FPGAs are advantageous for high throughput applications such as video streaming as well as low latency requirements where signals must change within nanoseconds. They are also the natural fit for applications which benefit from parallel processing such as AI neural networks. FPGAs also offer considerably more I/Os than a microcontroller, in the order of hundreds, with more flexible arrangements.

Microcontrollers Within FPGAs

If an FPGA can be considered as a blank sea of gates onto which a desired circuit can be configured, then there is nothing stopping us from instantiating a microcontroller within the FPGA. The latest FPGA architectures from companies such as Efinix provide a sufficiently cost-effective solution that microcontrollers can be emulated alongside other circuit elements to produce a highly integrated end product in a small, low power footprint. The flexibility of the FPGA architecture allows unique and highly specific peripherals to be instantiated alongside the microcontroller, customizing it for the particular application. In this way, an FPGA can be used to displace an existing microcontroller with a more integrated and cost-effective solution while retaining code backward compatibility.

We can extend this line of thinking to further enhance the capabilities of the microcontroller with accelerators instantiated in hardware that can be called under software control from the microcontroller. The processing element can therefore take advantage of the parallel capabilities of the FPGA hardware to enhance its performance.

No discussion of processing elements within FPGAs would be complete without mentioning RISC-V . RISC-V is an open architecture processor that is scalable from microcontroller type performance levels up to very capable microprocessor performance points. The scalability of the architecture lends itself very well to FPGA instantiation where it can be defined in software and placed within the FPGA alongside required peripherals. Several of the RISC-V instructions are left undefined so that they can be customized for the final application. This of course is a natural fit for FPGAs where the custom instructions can be used to call hardware acceleration units instantiated within the hardware of the FPGA.

The appeal of RISC-V is that it can be scaled in size and performance to meet the application requirements while it retains compatibility with an open, defined standard. A designer can therefore innovate creating a cost-effective solution while benefiting from a vibrant ecosystem of designers contributing to the open source standard.

Efinix has a software defined and fully configurable RISC-V processor core called Sapphire that is free to use on Efinix Trion and Titanium FPGA families. An open-source framework of accelerators and custom instructions speeds time to market and reduces the barrier to entry for the designer. Reference designs are freely available for video processing and artificial intelligence applications to guide the developer.

Sapphire is fully configurable using a graphical user interface within the Efinix Efinity design tools and once configured can simply be dropped into the final design. It can be configured with embedded memory management units and run operating systems such as Linux giving the designer access a higher level of software abstraction and access to the larger Linux community.

The advent of an efficient and cost-effective FPGA fabric is creating truly heterogeneous compute environments. Traditional microcontroller architectures as well as new architectures such as RISC-V are being embraced within the FPGA ecosystem where they are being enhanced and accelerated in the parallel FPGA fabric to new cost and performance points. Open standard and highly integrated designs are blurring the traditional lines between microcontrollers and FPGAs, redefining the established approaches to system design.

Get Started with Efinix

To get started with Efinix FPGAs, take a look at our development kits and developer resources.