Field-programmable gate arrays

maddog's Doghouse

Article from Issue 206/2018
Author(s):

Take some advice from Linus Torvalds and learn how to program an FPGA.

I was at LinuxCon in Beijing, China, this year, and Linus Torvalds was being interviewed onstage. During the interview, Linus said that if he were starting over in FOSS today, he might not create a kernel but instead, learn how to program a field-programmable gate array (FPGA). I found this interesting.

What is an FPGA? Traditional central processing units (CPUs) and graphics processing units (GPUs) are made of fixed circuits designed by computer engineers that form an "instruction set." This instruction set tells the hardware to do certain things when an instruction (designated by a program) is executed. All of this is controlled by a clock that acts like a drum keeping a beat and makes sure that everything works in harmony.

However, another way of building a computational unit is to build specialized circuitry that always processes data in a particular way – like "hard coding" the circuitry. Once the circuitry is set, there is only one thing that circuitry can do. Because the circuitry does not necessarily have to follow a "drumbeat," it can often solve that particular problem 10, 20, or even 100 times faster than a traditional CPU or GPU.

Of course, most of us do not want to buy a computer for every single problem we want to solve, so the programmer is able to change the program on the FPGA to solve different problems. One moment, the FPGA might be compressing an image; the next moment it might be encrypting (or decrypting) a stream of data. If you combine one (or more) FPGAs in a system along with a CPU and GPU, the FPGAs can offload a lot of processing from the main processing units, allowing them to do more varied tasks while the FPGA does the computation it was programmed to do.

Programming an FPGA does not follow the same procedural logic that programming a CPU or GPU normally does. Special languages and tool chains are used to build the program, and it does take some study to learn how to use them. Also, in the past, FPGAs were very expensive (and large), so not too many people learned how to program them. Now they are inexpensive and getting more inexpensive by the day. Some companies are now building FPGA functionality into their Systems on a Chip (SoCs).

FPGAs are not just about speed of computation; they can be used to reduce the cost of energy, as well. If your main CPU has to run for a long time to solve a problem, it may use a lot of electrical power. But if the FPGA can do the calculation quickly, then the main CPU might be able to go into "standby" mode and use less electrical power.

The Mars Rover was designed a long time ago, and although it does have regular CPUs on board, they are relatively slow and consume a lot of power. On the other hand, the Rover has a significant number of FPGAs on board that do the "heavy lifting," which allows it to reduce its overall use of electricity by turning the FPGAs off when they are not in use.

People are often confused by the term "real time." To me real time means that the computation occurs as the data comes in. If you are not doing the data processing in real time, then the data has to stop or be buffered until the processing element can "catch up." In most data processing, this causes a backlog that may never be overcome. FPGAs can be used to keep this data flowing, so you never have to stop the data flow.

FPGAs can have another useful function, particularly in embedded systems. Many GPUs have proprietary, binary-only firmware that can prevent new versions of the kernel from working unless the firmware is updated. I call these "binary blobs." I was lamenting to Professor Marcelo Zuffo of the University of Sao Paulo that many 3D functions (particularly "simple" ones) could be done by an FPGA and therefore eliminate the need for proprietary GPU binary blobs. Three months later, two graduate students had programmed an FPGA to run all of the OpenGL test suites. By using an FPGA for simple 3D and 2D graphics processing, embedded systems do not suffer when companies drop support for their GPUs (or the operating system that is using the GPUs).

One last idea on GPUs is using them for crypto-currency mining. While your main CPU is running the system, your FPGA can be taking care of the mining process.

Therefore, I recommend finding an inexpensive FPGA and learning to program it. Don't let Linus have all the fun!

The Author

Jon "maddog" Hall is an author, educator, computer scientist, and free software pioneer who has been a passionate advocate for Linux since 1994 when he first met Linus Torvalds and facilitated the port of Linux to a 64-bit system. He serves as president of Linux International®.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Introduction to FPGA Design

    Learn what FPGAs are, how they work, and how to design FPGA integrated circuits on Linux.

  • Doghouse: Performance Improvements

    "maddog" looks at some of Linaro's efforts to improve GNU/Linux performance on ARM architectures.

  • Kernel News

    Chronicler Zack Brown reports on the latest news, views, dilemmas, and developments within the Linux kernel community.

  • Sustainability by Design

    Sustainability studies for the IT industry often ignore the contributions of software. This article explores what developers and admins can do to create and maintain more energy-efficient systems.

  • maddog's Doghouse

    Watching the Mars rover, maddog is delighted to observe that the small helicopter it carries named Ingenuity has many off-the-shelf components and runs under Linux using free and open source software.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News