lainchan / λ
/fpg/ FPGA Programming
Davis · 2024-04-17 05:43
Cool as iCE edition
>What is this and why would I care?
Field Programmable Gate Arrays (FPGA) allow developers to design complex Integrated Circuits (IC) and test them out.
You can design a fairly complicated IC for a small project and use the FPGA as an ASIC-lite (with a flash-storage PCB) or to even have your designed actual IC etched in a group-funded chip print.
The basic process is: Program logic in an HDL -> Synthesis with Yosys -> nextpnr for routing/placing -> FASM to make .bit file.
>SImulator
https://steveicarus.github.io/iverilog/
>Open Source Toolchain
https://f4pga.readthedocs.io/en/latest/getting-started.html
Icestorm - Lattice Ice FPGAs, ice40 is very cheap and lots of dev boards.
Trellis - Lattice ECP5, relatively cheap with more power
X-Ray - Xilinx 7 series, Much more money, but lots of advanced features. Not 100% functionality supported with FOSS.
>Verilog/VHDL
Both work, Verilog is said to be easier to learn but VHDL is strongly-typed and harder to make soykaf code with. (So the saying goes)
General guides and references:
https://www.fpga4fun.com/HDLtutorials.html
Tutorial for cheaper boards (zero to risc-v):
https://github.com/BrunoLevy/learn-fpga/tree/master/FemtoRV/TUTORIALS
>Boards
Xilinx Artix-7: Digilent Arty A7, Basys 3, Nexys A7
ECP5: ECP5 Versa, TinyFPGA, ULX3S
Ice40: iCEstick, iCE40-HX8K, iCEVision Board
Other boards will work, but flashing them will be a few extra steps with openFPGALoader
Personally I have been using Icarus Verilog to make a microcoded stack machine.
druss · 2024-04-17 17:12
I don't get what FPGAs are really for. Are they just microcontrollers? Why don't you program them in assembly?
Unsigned · 2024-04-17 22:59
>>38869
They are reconfigurable digital circuit. Whatever you can make out of logic gates, you can make with an FPGA (but bigger, slower and more power hungry).
There are a couple open-source micro-processors that can be built for FPGA, even complete SOCs.
https://github.com/openhwgroup/cv32e40p (RISC-V, SystemVerilog)
https://github.com/chipsalliance/rocket-chip (RISC-V, Chisel)
https://opencores.org/projects/core_arm (Arm, VHDL)
Lukasiewicz · 2024-04-17 23:55
Can these be used for making ASICs for certain tasks?
Motoko Kusanagi · 2024-04-18 06:52
>>38869
It's three things: a bunch of PROM that can be turned into logic gates, memory, and configurable interconnects. The PROM is turned into lookup tables where the index is the inpur and the value is the output. (e.g, An AND gate would be an table with 4 bit values: {00: 0, 01: 0, 10: 0, 11; 1}.) The memory is used to make registers. The interconnects wire things together. It's configurable hardware.
>>38878
Yes, it'll be much cheaper, but slower, then a fab chip.
cdr · 2024-04-18 08:52
>>38869
The main advantage of a FPGA is that it is "massively parallel". Instead of executing instructions one-by-one all logic is evaluated at the same time (at least conceptually).
This makes it especially good for algorithms that are easily parallelized and/or pipelined, especially on the bit level.
protected · 2024-04-19 08:26
I've played with icestorm since it came out, but does anyone have experience with quicklogic here? Their combined FPGA/MCU tempts me.
>>38869
Try to bit bang a high speed protocol on a microcontroller and you'll get it.
Hacker · 2024-04-19 11:25
I bought one of the BeagleV-fire FPGA's because they're pretty low cost, have a decent embedded CPU, and I like the microchip technology. But holy soykaf the process of flashing it is like kicking dead whales down the beach. I have to run everything in an Ubuntu VM because they very much don't support any other linux distro.
I've owned it for months and haven't managed to flash it once because I don't have enough RAM on my PC.
XERXES · 2024-05-22 07:29
>>38893
Shoot, I'll ask: how much RAM do you have on your PC, anon?
Meddler · 2024-05-23 01:04
>>39164
Used to have a measly 8 GB, now I am sitting comfy at 64GB. Just waiting to get a few days to sit around and mess with it.
I have some ideas of what to do with it, I am thinking of turning the FPGA fabric into a linear algebra coprocessor, especially for sparse linear algebra. I've got a vague idea of an ISA with special addressing modes for sparse vectors and matrices, and pretty much only having MAC for its arithmetic instructions. It would have minimal/no branching to make it easier to go superscalar without needing branch prediction.
Nanashi No Gombe · 2024-05-23 01:28
>>39171
>running out of ram
That's strange. I've been using vivado just fine on 12GB, 64GB should be plenty, even with the ubuntu VM. Did you try with docker? It might work better than a full VM.
Eldon Tyrell · 2024-05-23 13:33
>>39172
Yes 64GB will be enough, it's the amount that they recommend.
You have to use their proprietary IDE thing to actually program the FPGA. It's really annoying.
Spike Spiegel · 2024-05-23 15:02
>>38893
A few years ago it used to be only compatible with Redhat, and people on support forums would deny help to people using CentOS.
You can run it in a chroot too, if I remember right I did that so I could run it “inside” another distro.
Anyone looking into buying some kit should consider the DE10-nano as it has other uses in case you decide to move on learning something else.
roll · 2024-12-01 06:06
>>38863
That seems very interesting. Any books recommendation for a software engineer that has 0 knolwedge about FPGA that want to pick this up as a hobby
Torvalds · 2024-12-01 07:52
>>40527
You don't really need to know FPGAs to use them. the basics of digital electronics is enough (stuff like logic gates, latches, ...). Although knowing the architecture can help you optimize your designs.
I don't know of any book on the matter though. I do have a couple courses in French if you'd like.
string · 2024-12-24 05:05
>>40529
i speak french i would appreciate that
藤原純一 · 2024-12-30 01:21
>>38863
I want to get into FPGA. Would Digital Design and Computer Architecture by Harris be a good start? I only know some Python and C#.
藤原純一 · 2024-12-30 11:18
>>40827
I would start with https://nandgame.com/. It makes you implement the basic components of a CPU.
Then I would mess around with https://github.com/logisim-evolution/logisim-evolution, try to create a small (4 to 12 bits, give or take) CPU in it.
The goal of the above is to get an intuition for how circuits work. A very important difference to be aware of is that all logic is evaluated simultaneously, unlike most programming languages like Python and C# which are serial.
After that I'd learn a bit of both Verilog and VHDL. There's a good chance you'll end up hating both, but there are other tools like SpinalHDL, Chisel ... which allow you to program in a much nicer language.
You can simulate designs in HDLs too, so you can test your designs before you get a FPGA.
Actually getting your design on a FPGA might be difficult depending on the tools you use. I have managed to load simple designs on an A7-100T with FOSS tools (Yosys and NextPNR-xilinx) with much effort, but I think there's a synthesis bug that causes my more complex designs to lock up. At least, a very simple Ethernet state machine I made would work fine in the simulator but only be able to reply to a single ARP request when on the FPGA (or perhaps I misunderstood a part of the protocol, I should try again, it's been a while).
JARGON · 2024-12-31 07:01
>>40827
>Harris
Great book, every newbie software programmer should read it, but there's nothing about synthesis for FPGA in it.