Exploring FPGA: Can We Make It Arduino-Compatible?

FPGA stands for Field Programmable Gate Arrays. It allows the creation of custom hardware, eliminating vendor-related costs. Unfortunately, the complexity of most chip designs still exists, which is why most people prefer to use off-the-shelf chips, often accepting their limitations instead of taking on the challenge to achieve the hardware optimization and efficient design they need.

However, getting started with FPGA is not simple. The abstract HDL language, even for those who have already entered programming, is still as obscure as a foreign language, let alone mastering it. The Vidor4000 is a new development board launched by Arduino that attempts to hide the FPGA within a relatively simple Arduino framework, hoping to eliminate this barrier!

Exploring FPGA: Can We Make It Arduino-Compatible?

The Vidor4000 adopts a new MKR form factor for users, featuring a Cyclone 10 10CL016 FPGA, along with a low-power SAMD21 chip from Microchip Technology, based on Arm Cortex-M0+.

Exploring FPGA: Can We Make It Arduino-Compatible?

Most components are located on the front of the development board, while the back of the board lists the MKR compatible pins.

The Intel Cyclone 10CL016 FPGA used in the Vidor features 16,000 logic elements, 504 KB of embedded RAM, and hardware multipliers for DSP operations. The pins can operate at speeds up to 150 MHz (sometimes referred to as 150 megatransfers). This particular part is well-suited for audio and video processing. The main components on the development board are as follows:

Exploring FPGA: Can We Make It Arduino-Compatible?

In a small form factor, the Vidor4000 provides interfaces such as MicroHDMI, MIPI Camera, and MiniPIC Express, which are typically only found on high-end Cortex A series development boards. However, considering that the board has an FPGA chip, these configurations are reasonable. The main features of the Vidor4000 are as follows:

• 8 MB SRAM

• 2 MB QSPI flash chip – allocating 1 MB for user applications

• Micro HDMI connector

• MIPI camera connector

• Wi-Fi and BLE powered by U-BLOX NINA W10 series devices

• All pins are driven by SAMD21 (32-bit ARM CPU) and FPGA powered MKR interface

• Mini PCI Express connector with up to 25 user-programmable pins

• FPGA (Intel/Altera Cyclone 10CL016) containing 16K logic elements, 504 KB embedded RAM, and 56 18×18 bit HW multipliers

Before formally experiencing it, it is necessary to understand the differences between FPGA and MCU. The fundamental difference between FPGA and microprocessors is that in a microprocessor, internal hardware such as I2C, SPI, etc., is pre-designed and does not change after the product leaves the factory. Internal transistors have specific purposes and specific connections, although there are usually multiplexers and internal switches to make the chip easier to configure. However, it is still a fixed-function circuit. On the other hand, FPGAs can be configured (and reconfigured) to be almost any digital circuit. In practice, a microprocessor core is generally embedded in the FPGA design.

The hardware characteristics determine the fundamental differences in functional design (program development). For MCUs, we perform functional design through registers or accompanying SDKs, with the code compiled and uploaded to the device using a downloader like JTAG. For FPGAs, the mainstream design method now is to use HDL to describe hardware functions, with the final result of HDL being a Bitstream for the FPGA to execute.

So far, we have a blank slate when it comes to developing FPGA with Arduino! Perhaps the code will give us a deeper understanding.

Next, we prepare the Arduino development environment. According to the official documentation, we need to install several supporting libraries.

Exploring FPGA: Can We Make It Arduino-Compatible?

The first is support for the Arduino MKR Vidor4000 hardware platform.

Exploring FPGA: Can We Make It Arduino-Compatible?

These several software libraries are also needed, the first one is mainly for graphics-related support, the second is for FPGA peripheral-related libraries, and the last one is for WiFi-related software libraries.

Launch the Arduino IDE, open the Blink program, and configure the board type and product as follows:

Exploring FPGA: Can We Make It Arduino-Compatible?

After configuration, press Ctrl+U to upload the code to the Vidor4000 development board, and you can see the following content displayed:

Atmel SMARTdevice 0x10010005 found Device :ATSAMD21G18A Chip ID :10010005 Version :v2.0 [Arduino:XYZ] Aug 9 2018 11:17:30 Address :8192 Pages :-129 Page Size :64 bytes Total Size :4194295KB Planes : 1Lock Regions : 16 Locked :none Security :false Boot Flash :true BOD :true BOR : true Arduino :FAST_CHIP_ERASE Arduino :FAST_MULTI_PAGE_WRITE Arduino :CAN_CHECKSUM_MEMORY_BUFFER Erase flash done in 0.829 seconds Write 683844 bytes to flash (10686 pages) [ ] 0% (64/10686pages) [ ] 1% (128/10686pages)

After successfully uploading the code, you can see the LED on the development board starting to blink.

Are we already using FPGA to light up? The answer is no! The current code has nothing to do with FPGA. This segment of code is simply using SAM21 to light up an LED.

In general, to use FPGA, you need to design HDL code first and then compile it into Bitstream. However, Arduino has integrated all these cumbersome processes into the software library, implementing related functions through relevant C code. Arduino programs the SAMD21, and the SAMD21 issues commands to the FPGA through the JTAG interface. As follows:

Exploring FPGA: Can We Make It Arduino-Compatible?

This is the JTAG interface of the SAMD21, connected to the JTAG interface of the FPGA below for communication.

Exploring FPGA: Can We Make It Arduino-Compatible?

Having roughly understood the working principle of the Vidor4000, let’s look at a piece of code:

// Let’s configure pin A0 to be an output, controlled by the FPGAFPGA.pinMode(33, OUTPUT); FPGA.digitalWrite(33, HIGH); // The same pin can be read by the SAMD processor 🙂 pinMode(A0,INPUT); Serial.print(“Pin A0 is “); Serial.println(digitalRead(A0) == LOW ? “LOW” : “HIGH”); FPGA.digitalWrite(33, LOW); Serial.print(“Pin A0 is “); Serial.println(digitalRead(A0) == LOW ? “LOW” : “HIGH”);

Some ports of the SAMD21 and FPGA are actually connected together. For example, the FPGA port numbered 33 is connected to the A0 interface output from the SAM21. This segment of code uses FPGA to output a signal while using SAMD21 to read the signal, which can be seen as a collaboration between the two.

Using C code to control FPGA operations is encapsulated in the FPGA class, and the method to initialize the FPGA is called FPGA.begin()

Other methods to manipulate the FPGA, such as the FPGA.pinMode() method call, can be referenced in the previous segment of code.

It looks great!

But there are too many details involved! For example, for the most basic GPIO operations, the official documentation is still incomplete, and there is not a complete list. Users who need to use these functions can only refer to the schematic; additionally, the encapsulation of internal IP cores relies on the IP cores provided by the official, and perfecting these functions is still a big problem for users unfamiliar with FPGA!

The libraries provided by the official support currently include GPIO, I2C, SPI, etc. Additionally, operations such as WiFi, HDMI, and Camera have reference demos, but the supported devices are limited, for example, the MIPI Camera only supports Omnivision OV5647.

For users familiar with FPGA programming, the official has also provided a Git repository that offers FPGA IP modules compatible with the Arduino Vidor series products, aimed at users already familiar with the FPGA development process. The address is https://github.com/vidor-libraries/VidorFPGA.

In any case, at least FPGA has taken a step forward with Arduino. With the joint efforts of the official and the community, we have reason to believe that the future of FPGA will definitely not just be a highbrow pursuit!

Arduino once again proves to the world: there is nothing Arduino cannot do!

Exploring FPGA: Can We Make It Arduino-Compatible?

Leave a Comment