Why FPGA?

This will be the first post of 2022, and I want it to be some different. Time ago I have been thinking write about how I started to use FPGA and also what I expect of them for the future. Likely, the thoughts that I am going to write in this post, will change in the next year, but it would be interesting to see how my thoughts about the FPGA field change with the years.

Since I was started my degree in industrial electronics and automatics, I always had wanted to work as DSP developer for power electronics equipment. This area mixes 2 fields that I like, the embedded development and power electronics. Also, in my degree I coursed 2 subjects about FPGA. The first one, in the 4th year, was a purely theoretical and, although is true that we made some simulations, it was not something that caught my attention. In the 5th year I coursed the second subject based on FPGA and this time, and I think that is something obviously if you have no experience using FPGA, the subject was mostly practical but focused only on the digital side. The FPGA at this moment was turning interesting but the pure digital world that involves only digital protocols and a RGB screen management, it isn’t interesting enough to leave my purpose, the DSP development. Nevertheless, in my final degree project, I used an FPGA to make a proportional – integral control for a DC motor. This was my first contact with a project where I was made a design in FPGA to manage a power electronics equipment, but even with that, I took this project as a parentheses of my real purpose, to be a DSP developer. With this purpose, when I finish my degree I started to work as DSP developer for renewable energy equipment, first as a collaborator from the college, and then in a company as DSP developer to control power electronics equipment. One day, an FPGA designer left the company, and the team needed a new developer urgently. Since I had some experience using FPGAs, I was asked if I could do some of the modules that a new project would need while they were hiring a new FPGA designer. During this period I started to search a lot of documents, applications notes and many information about FPGA and how they work internally, the hardware that they use looks amazing for me. Finally, they didn’t found an FPGA designer for that project, and I left my job as DSP developer and I start to work as FPGA designer in the same company.

I have worked as full-time FPGA developer from 2015, and when I said full-time is full-time since I always loved to make projects and developments in home. From almost 2 years I write controlpaths in my free time, but some years ago I wrote another blog about microcontrollers and DSP in spanish named Mipsandchips, and it is still published, you can visit it if you want.

Focusing in the FPGAs, since 2015 I have notice that the FPGAs field has grown exponentially, and the articles, applications notes has been increased exponentially. Even the number of manufacturers has increased. This interest in the FPGAs is not only from the developers and companies side, also companies like INTEL, Microchip or AMD have shown that the FPGA is an emergent business. Part of the success of the FPGA come from the limitations that the conventional processors have, you need one processor to execute and instruction, even if this instruction is as simple as perform an addition, do you want to duplicate it? Great! add another processor, do you want to increase by 100 your capacity?, no problem, add 100 processors and you will make the energy companies very happy. The structure of the FPGA makes easy and efficient to execute an instruction, only you need to synthesize a hardware circuit capable to execute it, and multiply that by 100 is not a big deal if the entire circuit fits in your FPGA, I no going to talk about timing restrictions this time. If you are thinking about the high power consumption of the FPGAs, it is true that is high, but in case that you need to execute a lot of simple instructions, I am thinking in a large FFT, event if the clock of the FPGA is several times slower than the clock of the processor, you will be faster using an FPGA due to the parallelizing capability of this kind of algorithms. Obviously this is not free, you will need to design your hardware circuit in order to execute the instruction you need. This circuits are called kernels, and they are very common in hardware acceleration.

Talking about design your circuit, let’s talk about the synthesizer. I have several colleagues that asked me about how I design the circuit that make the FPGA execute a task. And by how I design, they thought that the design in the FPGA has been designed using an schematic where I put the logic gates and the flips-flops, but this is not true… in part. Starting by the part of that is not true, all the FPGA with a minimum of complexity are not designed by drawing the logic gates and the register. High level languages are used to describe the hardware (HDL), but is true that there is a big difference in the meaning of an instruction for an embedded developer and for an FPGA designer. If you are using Verilog, you will notice with some code lines that is based on C, the same with VHDL and Pascal, so can be tempted to think that an FPGA could be “programed” as a microcontroller, but it is very far from the reality. When you are using an if instruction, the processor execute a program memory jump to a certain address if the condition is true, and to another address when the condition is false. In FPGA, that if instruction is wrote as an electronic circuit, that has some limitations, for example, if the circuit is synthesized with a multiplexer, the output of this multiplexer cannot be connected to the output of other multiplexer, this will produce a short-circuit. In a microcontroller, there is no limitation if a variable is set in 2 different parts of the code. Also regarding the widths, in a microcontroller there is a physical memory with a certain width, 16 or 32 bits, and all the variables must be fitted in this widths, or a combination of these widths. In an FPGA there is no predefined width for the signals, so use 32 bits register to storage a 2 bit signals will be a misusing. Luckily for us, synthesizer have some intelligence, but in order to the synthesizer do that we want to do, we need to understand (at least at basic level), how they work, in order to write a code that they will understand, in other words, write a Verilog code is easy, mostly if you have a background developing C or C++, but do that the code will be synthesized exactly how you need is not easy, and not only is not easy, but is different for each vendor, or even for different families of the same vendor, the reason is the resources that each device has are different, so the synthesizer must translate your code with the resources that the device has available.

Regarding the different devices, until now I only have talked about FPGA, but for some years ago, there is another device in town, the System On Chip. I have to say that when I started with the FPGA, SoCs based in an FPGA and a processor are rare, at least that is what I see. Xilinx release the Zynq 7000 family in 2011, that is when I finish my project using an ALTERA Cyclone IV, and I don’t remember to hear about SoC. Before Zynq, there was other families based on Power PC and other processors but as I said, SoCs 10 years ago was rare. Now they are in many devices that you use in your day. Also, sometimes people asks me about a board to start with FPGA, and I always recommend the TUL Pynq Z2, a board that you can find for less than 130 Euros and is based on a big Zynq 7020. My relation with SoCs is a love-hate relationship. The reason is that something that I like a lot of the FPGAs, is that I develop the peripheral I need, with all and only the functionalities that I need. When I have to work with, i.e. an SmartFusion 2 SoC, and I want to use the SPI from the Cortex M3, I have to study the datasheet, and search between all the registers and the capabilities that the SPI peripheral has, when the only thing that I need is to send 16 bytes and receive 8. Many times is faster for me to add a AHB or AXI Lite interface to my Verilog module and use it from the processor. So, I know that the SoCs are very interesting devices, and I have to know them, but it is the part that I like least.

To finish, if something ask me about the future of the FPGAs, I have no doubts, FPGA will be used more and more because we will need devices that can handle many execution lines at the same time, and the FPGA will be there to help the processors. A limitation factor that the FPGAs have now, is that if you have a processor that needs to accelerate a function, you need to develop a design that satisfy this need, but maybe the processor in other moment needs to accelerate other function, so you have to develop other design for the FPGA. The goal for the next years could be that the processor that needs to accelerate a function, will be capable of develop a hardware design capable to perform the function that needs by itself, and then remake the design when a different function will be needed.

I promise that the next post will be a normal post… 🙂 Thanks to all for reading. Hope you be health and happy in 2022!

Leave a Reply