Hackster - io-Hardware-as-Code Part I An Introduction
Hackster - io-Hardware-as-Code Part I An Introduction
hackster.io/sthibault/hardware-as-code-part-i-an-introduction-48bacb
Scott Thibault
Hardware components
× 1
UPduino
Story
1/4
In this multi-part series, we’ll take a look at how you, a software developer, can design
custom hardware without learning a new language or deep knowledge of logic design. This is
possible through a technology called high-level synthesis (HLS) which can generate hardware
logic from algorithms described in C/C++. Not only that, but we can download our custom
hardware into programmable logic without physically building anything! In this first
installment, we’ll cover some background on what "hardware-as-code" means, how is it
different from software, and most importantly answer the question: why would you want to
do that? In subsequent parts, we’ll get hands-on and build real custom hardware as we
progressively explorer different topics. Some embedded-systems experience (e.g., Arduino) is
helpful, but not required; you just need some familiarity with C/C++.
Turning completeness tells us what we can do, but it does not imply that we can do it
practically. In practice, there are many different CPUs out there because many different
hardware solutions are required to build practical solutions for different situations. Most
often we are trying to balance the tradeoffs between speed, cost and energy usage. In some
cases, you simply cannot meet resource constraints with any CPU. For example, the area of
tinyML involves using machine learning on resource-constrained devices. That can be very
hard to do with a general-purpose CPU.
Most developers don’t realize that CPUs are actually very inefficient. CPUs spend a large
amount of time and energy reading instructions from memory, decoding the instruction and
scheduling it to execute. An alternative is to build hardware that implements your specific
algorithm without instructions, completely eliminating the overhead found in a CPU. Beyond
that, custom hardware will typically also leverage parallelism not available with a CPU.
Here are some applications where people often find it useful to build custom hardware rather
than use an off-the-shelf CPU+software:
2/4
What is hardware?
The term hardware is used to mean many different things. In this series, as we explore
"hardware-as-code", we mean the type of hardware normally used to implement a CPU. More
specifically, synchronous digital logic circuits. Let’s break down what this means. It’s
probably pretty obvious, but we are talking electrical circuits here, not mechanical devices.
The most familiar term to the software developer is probably digital: manipulating data
represented by 0’s and 1’s (i.e., binary).
Another term you should be familiar with is logic. This means calculations are implemented
by combining logic operations (and, or, xor, not) which are each easily implemented in a
circuit. For example, addition, subtraction and multiplication can all be implemented by
combining various logic operations on binary values. For our purposes, we don’t really care
how; just like we don’t typically concern ourselves with how a compiler translates our code
into instructions.
Finally, you have likely encountered the term synchronous, but probably not with the same
meaning as it is used here. In this case, it means that the whole circuit it controlled by a
clock. The clock is an electric signal that oscillates between 0 and 1 with a fixed period. Each
period is a cycle and values are updated once per cycle. The number of cycles per second is
the clock frequency and this is exactly what we are talking about when we talk about
processor frequency. You’ll learn more about that in later articles when we discuss
performance.
In this series, we will be using Field Programmable Gate Arrays (FPGAs). These
programmable logic chips consist of an array of blocks that can be programmed in the field to
perform the various logic operations we discussed in the last section. FPGAs also include a
few other important elements beyond the basic logic blocks, but we’ll discover those as we go.
Next steps
At this point, you should have some idea of what I mean by "hardware-as-code", why you
might want to do such a thing, and hopefully, at least a little excitement about learning more?
For our next installment, we go hands-on with some hardware-as-code development tools.
3/4
The tools specifically target an inexpensive FPGA board from our hardware partner
tinyvision.ai. You won’t need the board to use the tools, but I’d encourage you to pick one up
so you can actually run your projects on the board, which is very rewarding. Use the
following link to make sure you get the correct board:
https://tinyvision.ai/products/upduino-v3-0?variant=39608867618919. This one has a pre-
soldered PMOD connector which we will use to connect sensors later in the series. Supplies
may be limited due to the silicon shortage and you'll want to have it when "Hardware-as-
Code Part II: Hello FPGA" drops, so it's a good idea to order now.
The tools do require Windows, so you will need access to a Windows machine.
Connect
Please follow me to stay up-to-date as I release new installments. There is also a Discord
server (public chat platform) for any comments, questions, or discussion you might have at
https://discord.gg/3sA7FHayGH
Credits
Scott Thibault
3 projects • 3 followers
Doctorate in programming languages + experience in FPGA, design automation, embedded
systems, and machine learning.
Contact
4/4