Ask HN: How to get started developing with FPGA?

247 points by jason_slack ↗ HN
I've been doing a lot of GPU programming these last few years. Now, FPGAs are being used to accelerate tasks (algo trading, etc, etc).

Recommendations on how to get started with FPGA development? What cards are good? Do they make external cards to plug into a laptop like eGPUs? Popular SDKs?

85 comments

[ 2.6 ms ] story [ 172 ms ] thread
Not quite the response you wanted but I just wanted to mention project Oberon (http://www.projectoberon.com) by Niklaus Wirth. In 300 some pages, starting with an FPGA, you implement a CPU, a compiler for said CPU, a language targeting the CPU and an OS which includes a GUI and a networking stack.
Thanks for mention this, it looks very interesting.
Programming FPGAs by Simon Monk and the Mojo v3 have been what I've been getting started with. It might be a little basic if you've been working in-depth with GPUs already, but the Mojo v3 is a great board to learn on - connects directly to your laptop via USB. It takes a lot of the magic out and makes it more like you're just programming an Arduino.
Are these types of boards suitable for developers, writing code that eventually will run in a production financial environment?
It teaches the same first principles in a smaller format with less room for error, but this particular board won't be able to scale up to a prod environment.

Agree with another commenter that an AWS EC2 F1 instance might be closer to prod for your purposes.

Like, 8 years ago I got a Spartan 3E board and a book on VHDL programming that didn't exactly use the exact board I had. And that seemed to work -- you'd plug in via USB. I ran some Xilinx software on an EeePC. The act of learning was more about I/O to peripherals than just implementing algorithms on an FPGA.

So that's how my experience went. I don't know whether modern resources are more or less computation-heavy.

This is the board I used for two courses in college and I thought it was pretty good. I wasn't limited at all, but my designs weren't anything too complicated.

https://store.digilentinc.com/nexys-4-artix-7-fpga-trainer-b...

In my reconfigurable computing course we used the Xilinx Zybo board which has a SoC on it which includes two Arm processors and an fpga (I think the new xilinx boards also have a gpu). This was really cool but I wouldn't recommend starting with it since the dynamic reconfiguring has a big learning curve in itself.

I actually don't know what a good way to learn is since I just followed my professors notes which was helpful, but I'm sure there are sources online to help. What I can say is that fpga development isn't the same as software development. You have to think differently when implementing designs since you're literally describing the circuitry instead of designing code that runs on pre-determined hardware. I used Xilinx Vivado Webpack (it's free) throughout my fpga usage.

you can try the (~$15) upduino 2.0[0]. it's supported out of the box by the free (OSS) icestorm toolchain[1]. The upduino board itself is also OSS.

[0]: http://www.gnarlygrey.com

[1]: http://www.clifford.at/icestorm/

Quick glance reveals these run at around 12MHz, which may be a bit on the slow end for algo trading (?)
I mean, Algo traders I know are working on teams of 10-20 people with deep knowledge of $5k boards over a half-decade, so I think for "getting started" those might be pretty good.
If you have the v2 board you can use the PLL to change that 12MHz up to a high frequency (150 Mhz maybe?). You have to use a block and the icepll tool will generate the code for the frequency you want.
iCE40 ICs have both 10kHz and 48MHz oscillators built-in, as well as multiply/divide capable PLLs that work up to 250 MHz.
Since nobody mentioned it yet, I think AWS’s f1 instances starting at $1.65/hr are worth considering. The underlying board is fairly expensive, but given that you mentioned algorithmic trading, I assume you’re intending to do this professionally (in which case production will look more like the f1 instance than a small dev kit).
Maybe if you're already familiar with FPGA development and have a specific application in mind. The size and complexity of the F1 accelerator (and, in particular, the way it's interfaced to the computer) will be a major obstacle if you're still learning.
I recommend the pynq from digilent, it'll help ease your way into hardware design.
Can you really benefit from this new skill? Because it is very different from GPU programming. In fact, it is mostly describing hardware in some very low level language. You must develop everything by yourself to make that eGPU functionality. All cards are good, you just need to pick right one for your application. Terasic has a nice range boards starting with cheap ones for beginning to advanced ones with high end FPGAs.
I <3 TinyFPGA and also it's open source DO IT
I learn best fiddling first and theory later. Check out the DE0 Nano. Cyclone IV with ram, buttons, leds, eeprom, accelerometer, adc, header breakouts, under $100.

Any fpga dev kit in that class will work. I was able to jump right into it with the basic examples and had my own hardware uart up in a couple weeks.

The only downside is when I was using it the software was only for windows and very bloated.

I'd highly recommend starting with the TinyFpga BX and Project Icestorm:

https://tinyfpga.com/bx/guide.html

I used the lattice icestick (20 dollar board) and IceStorm (quick to install, open source toolchain) to get started a few years back and the community around the toolchain has really come a long way since (new boards and great documentation), check it out : )

I'm just starting to learn about this field as well, so thanks for posting! This video seems like it's a pretty good introduction: https://www.youtube.com/watch?v=0zrqYy369NQ

Another specific question that comes to my mind -- does anyone have anything to say on languages? VHDL vs Verilog? Others? Which is best for beginners?

I see that as being a religious war with both factions sticking to their resp guns. Its a means to an end. VHDL is more popular across the Atlantic Ocean than its here. In the US more regulated companies(Medical, Mil-Aero,Automotive) prefer VHDL while the consumer(FAANG) prefers verilog. Syntactically, VHDL is more verbose owing to its ADA origins while Verilog attributes its orignis to C. So read through some sample code on github and see which one piques your iterest. If you choose verilog(FPGA4Fun) has you covered.
You should start by learning VHDL or Verilog and the best environment to do that in is simulation, not FPGAs. FPGAs are hard and annoying to debug, so you'll be spending a lot of your time writing test benches that run in simulation anyway.

A nice free one for Verilog is Icarus Verilog. The FPGA vendors have toolchains that include simulation, so you could also download Xilinx or Altera's free tools and start there.

Icarus is great, but I'd still recommend the free to use simulators from the fpga vendors (e.g. xilinx xsim) as they support more of the modern system verilog and VHDL language. Restricting yourself to the older subset of verilog icarus supports is going to be frustrating in the long run.
Is modern Verilog not frustrating? I don't know much about it, but you're certainly right that the older stuff can be.
It's different for sure. It has a lot of very nice features that make it less easy to shoot yourself in the foot for design. It is more expressive, especially woth multidimensional types and real number modelling, plus a whole host of verification features like constrained random verification, classes, coverpoints, assertions, etc.

I have to say I like it, but the learning curve is steeper and you can still code 'foot shooting solutions as it is backward compatible - so better to learn the new, more correct way than to start with the old verilog and then learn the new features.

I am only half way through it, but you get a lattice icestick for less than $30 and open source tools. I've started the hackaday.io bootcamps which so far have been really good.

https://hackaday.io/list/160076-fpga-tutorials

They had a chat with the guy who wrote them a few weeks ago and there are more coming. Very accessible and you don't have to use the icestick very much -- most of it is done with free tools.

I'd actually recommend learning digital design first. Go through a course like nand2tetris. If you are writing HDL without a solid idea of what RTL logic you expect to get back you're in for a hard time.
Hi, professional FPGA developer here. A couple of things I would advise:

Firstly, development kits are great - they provide the hardware you need and all of the IP to drive that hardware. Grab a dev kit - there are lot's of other posts advising you which one. The IP that actually interacts with the real world is by far the most difficult bit.

Secondly, 99% of hardware design is simply know what actually maps to hardware. It's important to understand that hardware languages fit: FPGAs, ASICs, simulators. So what can be coherently written in VHDL/Verilog can't necessarily work if it doesn't map to the hardware platform you're writing for. So you need to actually understand the structures of an FPGA - LUTs, Registers, DSPs and Memories. Once you know what you're writing you're 90% of the way there. Real FPGA devs spend months in simulators before they get to actually hardware test. The simulator will allow you to do things that the compiler will warn you about and the hardware will simply do wrong. Each compiler (modelsim, Vivado, Quartus, VCS etc.) will have a unique interpretation of the language you're using.

Finally, in terms of tools, use whatever comes with your dev kit, but in terms of simulators Modelsim is industry standard and Intel (Altera) ships a free version.

I don't really have advise for learning material- I learnt at Uni.

It’s so surreal that people in the FPGA industry refer to libraries/components as “Intellectual Property”.
I think it's because so many of them are sold/licensed that way. You buy an Arm core, an Ethernet, USB or BT interface, etc. Often you do it from your EDA (electronic design automation) vendor so that it fits into your design/test/layout flow. Even the ones you don't pay for often can't be redistributed. Lots of them are literally black box or "hard" IPs that you can't change or test except through defined interfaces... but they often have been validated much more than anything you can write and may be much smaller or lower power than you would naively write.
I would attribute the weird FPGA dev attitudes to Stockholm syndrome. I always get the most mind boggling replies in defense of the evil vendors when I criticize FPGA’s embarrassingly small amount of freedom.

> [black box components] often have been validated much more than anything you can write and may be much smaller or lower power than you would naively write.

Sure but if an entire community was validating and improving these common components, they’d be way better still. (See gcc/llvm, linux, git, etc).

You are absolutely correct. Keep fighting the good fight :-)
Hardware validation is like hardware startups, much harder to do. With software, all you need is a computer, time, and will. With hardware, your toolchains have a material cost, a calibration cost, shipping cost, shipping schedules, in addition to a computer, time, and will. If you screw up your equipment or prototype, thats at least another week or month of waiting for replacement parts.

Software is like music, as long as the instrument is works, all you need is time and will to develop/create.

Yup. If you have an engineer who's paid $100 000 a year with three weeks vacation, that's 407.05 a day. It starts to make sense that you'd buy $4000 IP for an Ethernet core, unless by some ungodly powers they can write that in less than 10 days.
If you have an engineer who's paid $100 000 a year with three weeks vacation, that's 407.05 a day. It starts to make sense that you'd buy $4000 IP for an operating system, unless by some ungodly powers they can write that in less than 10 days.
(comment deleted)
I see what you're trying to say, but the analogy doesn't exactly work. Everyone still uses a COTS operating systems because the cost of building one from scratch is so high. We're lucky that the market provides multiple free options, but if it didn't the rational business move for most projects would be to license one.
It's also worth noting that are clear examples of closed-source software that essentially acted like malware. I've not heard of any such examples with IP cores.
This is ignoring the major part of hardware development that is actually just non-free software tooling.
This whole thread is frankly, so dumb. One of my best friends is a SoC designer at Apple and we talk about this stuff all the time.

First thing people need to understand: this whole world operates at scale. You don't bother making an ASIC unless you really need one -- you're either making millions/hundreds of millions of them, or the individual application is so high-value that the hassle, complexity, and expense of moving off a general-purpose CPU onto something completely custom is worth it.

Second, 4K is chump change. You need an entire team of people to do anything meaningful with FPGAs/ASICs. Less than that, just buy a $100 CPU that will do more, be immediately available, and have an entire software stack (OS, user-space programs, compilers, etc) for it. And teams that know how to build this stuff well cost MONEY. A lot of it. Not $100K/year. More like $250-300K minimum per person at Silicon Valley rates.

I get that the OP wants to do this as a sort of hobbyist undertaking, just realize, he's cutting against the grain of the entire ecosystem. Everything about this stuff is made for huge companies to do massive projects that will ship at gargantuan scale. Not hobbyists in a garage.

The major part of hardware development is NOT tooling. It is manufacturing the hardware.

Nice perspective taking. To the OP's defense, he was wondering about FPGAs for hobby endeavors.
> this whole world operates at scale. You don't bother making an ASIC unless you really need one

You are the first person in this thread about FPGAs to mention making an ASIC.

His point still stands as all the tooling and IPs are the same for FPGA and ASIC and ASIC drives developement of new IPs and tools. FPGA are still the minor market here by far
> * all the tooling and IPs are the same for FPGA and ASIC*

They're really, really not.

Place and route tool is different and IPs might use different memory and multiplier macros depending on technology. Serdes transceives will also be different. Ideally this is all hidden from the integrator by parameter selecting technology.

Linting tools, simulation tools, formal verification and synthesis tools are all the same. Verification methodology is also the same.

I disagree with this, you don't necessarily need a whole team of people and massive amounts of cash to do FPGA development and you don't necessarily need expensive tools. For my current company I created a complete FPGA based trading system from scratch on my own with free tools (apart from Vivado which I just used to turn my RTL into an actual design I could put onto the FPGA board). The board I used cost around £2k and the Vivado tools were £4k (athough if I was going to do it again, it appears you can just pay for your usage of Vivado using the cloud (nimbix has machines that have the Vivado suite on them). The cost to the company for this is pretty much my salary + the board costs.
Tooling is a blip on the radar of the cost of the designs I work on. Verification is usually the most expensive aspect. 10x tooling even if the tools were purchased for, that project alone, which would be very unusual.

However, for open source to flourish, high quality open source simulators are required. I think if we had that, synthesis and place&route would follow. You don't need synthesis or par to do design and verification, but you do need simulation.

I look into the state of OS simulators periodically. Some are impressive, but mostly just handle the design basics... an OS systemverilog, static and dynamic, simulator would be a game changer.

It's a Herculean task though. I don't know how much Xilinx makes off tooling. I have to think they would make more from FPGA sales if tooling were free, and if it were open source, it would no doubt be improved upon by degrees I can only fantasize about.

Simulators, and by extension synthesis and place & route tools, are complementary goods to FPGA hardware. Make your complementary goods cheap, and you make a lot of money.

But there are tool companies out there such as Mentor and Synopsys that make a lot of money from such proprietary tooling. I imagine simulators have a tough patent field to navigate.

> I would attribute the weird FPGA dev attitudes to Stockholm syndrome. I always get the most mind boggling replies in defense of the evil vendors when I criticize FPGA’s embarrassingly small amount of freedom.

I'm not sure you understand FPGA development. Until FPGA manufacturers do something like software vendors where they bundle actual malware with the closed-source hardware they sell, it doesn't really bother me.

Personally, I kind of prefer having detailed documentation of a black box rather than trying to read source code. The latter is all too common in software development.

I have multiple FPGA designs in use today. What does or doesn’t bother you is irrelevant.

I don’t really care to explain the obvious net win that open source designs (and tools) are for society. The only argument I’d consider reasonable is that the FPGA/hardware world is too small to justify the initial investment.

> when I criticize FPGA’s embarrassingly small amount of freedom.

It takes a critical mass of knowledgeable people who don't necessarily want to be compensated monetarily for their efforts for this to happen (think early GCC and Linux teams). It took a few decades of largely unpaid effort before GCC and Linux convincingly took over as the leading compiler and OS respectively and people started being paid to work on them. To achieve the end you have in mind, you will need to start building that community

Writing robust cores is usually substantially harder than writing the equivalent software library. You usually have to design the logic to satisfy various different criteria (area, performance, or power), and, especially when implementing high speed design, take into account the targeted device.

Unfortunately, the number of people who are competent to design, test, and implement these cores is fairly small, and usually well funded. Oftentimes, these cores represent very non-trivial time savings, especially when it comes to characterizing performance and closing timing, so there is tremendous value in the marketing and selling of these cores.

On the other hand, sites like opencores are great for finding useful IP that people have contributed and may be adapted to your device.

The books by Pong Chu are really good. You can choose either VHDL or Verilog and then the FPGA you are getting started with. I went through 'FPGA Prototyping by Verilog Examples' as my first starting point with Verilog and it was very easy to follow. This will give you a basic level of understanding of FPGA development, from there you can study more specific topics.

There was a good article yesterday on HN that went through the process of taking the Cordic algorithm and implementing it in Verilog, it's a good example of using FPGAs to implement a specific algorithm.

http://zipcpu.com/dsp/2017/08/30/cordic.html

Not an FPGA expert by any means, but I saw that make magazine published a booklet about FPGA development for beginners. Maybe you could use it as a very short intro.
Since you mention using FPGAs for algorithmic trading I can only guess that you wish to employ FPGAs as some sort of signal processor. I would suggest investing in an FPGA driven Software Defined Radio (SDR) You'll get the best of many worlds as an SDR does something that is immediately useful, and demonstrates how the FPGA fits into the larger picture as a part of a signal processing chain. Once you understand the complete signal flow from beginning to end mastered, building the signal processor you have in mind will be far easier. You will need to brace yourself to learning at least 6 different languages, including VHDL, Verilog, C, Python, Javascript, and Go.
Altera has the cyclone iv & v chips sold by terasic. Id start with one of those boards.
Great thread with lots of good answers and perfect timing too. As an HW(board level) guy pivoting into this space just recently here is my algorithm so to speak to get into this space. Please keep in my mind that I have always "worked with " FPGAs, just "Not worked on FPGAs". 1. Purcahsed Zynqberry FPGA from Trenz. Why? For the price you get the best documented FPGA dev kit on the planet. Thye have a great Wiki with good documentation. Do your own research but this is based on my own research. If you want to develope anything with FPGAs, then your options are down to the "X" and "A" companies. Solid toolchain and documentation and communities(Both official and SO). 2. work your way through the Vivado tutorials on the Xilinx wesite. They will walk you through creating a project from scratch all the way upto creating a variety of RTL projects integrting IPs(Xilinx or your custom that you created). It includes its own flavor of simulator where you learn to simulate your designs and perform timing analysis. 3. If you don't have the necessary Digital logic background either get a decent book or enroll in the Nand2tetris(someone else suggested that).
I'm not sure how programming FPGAs compares to GPU programming, but it's a completely different way of thinking compared to traditional software.

The last time I really did FPGAs was over 10 years ago, but unless the tools have gotten orders of magnitudes better, in addition to the other concepts mentioned you need to understand clock domains, metastability, pipelining, etc.

I preferred VHDL to Verilog because you shouldn't need a lint checker for your HDL. But unless it's changed, Verilog is a lot more popular.

Training is available, for example https://www.xilinx.com/training/atp.html . It probably costs more than you're interested in paying, and you should have the basics covered first.

Are these trainings worth the cost? Has anybody reading this done them / would be able to provide feedback?

Also seconding the need to understand clock domains and metastability, timing constraints, etc.

This is the core of a computer engineering degree.

You're looking for (1) probably a first course in the basics of circuits, (2/3) a first- and second-course in "digital design" or "logic design", (4) an operating systems course (emphasizes how this stuff all works with "The real world"), a basic programming class if you don't have one, and some domain-specific stuff such as digital signal processing, graphics, statistics, finance, or whatever else you're trying to do with this thing.

Probably 5-6 good university classes in total. If you could do these classes a la carte, it's probably the fastest way to learn this stuff (skip the gen eds and all other non-degree requirements). Frankly, it's a lot if you have no prior experience, but I'm not sure that's true.