This is pretty great. I have been wanting to get into FPGA programming so it's nice to know how low the "basement" price is for the essential equipment.
Can anyone else recommend any other cheap entry level boards?
Pretty much anything from Digilent. I've got an old Spartan6 board that has a boatload of horsepower. If you want to get fancy, look at the Zedboard family -- FPGA wrapped around ARM cores.
I also recommend Digilent, but they are not bargain basement. They're education targeted, often focused on the lab, rather than non-hobbyist R&D boards, but not $10.
I always recommend the DE0-Nano. It's getting a little old, but it's basically all right there, open for use. I'm a fan of the Arrow DECA which has a complete assortment of neat odds and ends. Lastly Digilent's Arty and CMOD series are awesome depending on what you need.
I know this makes a few assumptions on what you mean by "Cheap", but I find sub $200 for FPGA boards to be pretty affordable when compared to the gamut.
Well... "cheap" is relative, but the Ice40 boards from Lattice are reasonably priced IMO. And more to the point, there is a complete Open Source toolchain available for programming them. That's a big plus in my book.
It would be very nice to bring the cost of experimentation in CPU cores down to something easily accessible to even students. In the same way that RPI brought computing and hardware interfacing down to basically anyone who can afford a cup of coffee.
Word of warning: my UPDuino v2 (these have a USB connector so you don't need a separate programmer) worked, but it heats up a lot immediately. I suspect a short circuit somewhere due to bad soldering. Requests to have it replaced were never answered.
Most companies will replace a faulty device with a new one or fix it if it's broken due to manufacturing issues. Maybe the price should be increased a bit to allow for further testing.
If you have an issue the solution shouldn't be to throw it away and buy a new one, that's incredibly wasteful and it encourages bad behavior by the manufacturer.
There isn't really a go-to IDE that everyone uses. Each vendor have a proprietary IDE and they're all very bad. Lattice FPGAs have an open-source toolchain, but it's all command-line tools so you're left to build your own workflow of choice.
You can write Verilog or VHDL (the two main hardware description languages used to design circuits) in any text editor you choose and verify the basic functional correctness (verifying that it implements the logical behavior you want) in a simulator like Icarus Verilog.
However to verify the behavior on the FPGA and actually program it into the device you'll usually need some vendor specific tools, for Xilinx (what I'm familiar with) you'll need a software package called Vivado. It provides information on whether or not the timing you've requested is possible, whether any part of the chip will get too hot, whether the design actually fits in the limited resources of the FPGA, as well as implementing, optimizing and outputting the design to the FPGA.
Lattice has an open source toolchain available at least for some of their devices, for Xilinx there are efforts to produce a reverse engineered toolchain but I don't know how functional they are, there are free (but not libre) versions of Vivado as well but you'll need to fill out US export paperwork and it doesn't support all Xilinx FPGAs unless you pay. I don't know what the story is with Altera.
The equivalent tooling for FPGA programming is starting with a high level hardware description (typically Verilog or VHDL) then
- synthesis -- this converts the text description from HDL into gates (fun fact you can write valid HDL which cannot be synthesized into hardware)
- place & route -- this takes what is essentially a schematic from the first step and assigns it to resources within the FPGA. This is also where you specify which pins on the FPGA you want to be connected to the schematic outputs.
- timing closure and simulation -- This is the process where the FPGA place and route core is trying to either make your design fit in as few gates as possible or run as fast as possible (these choices often conflict so you have to prioritize one over the other)
- bitstream generation -- This is where an often encrypted stream of bits are generated such that if they are fed into the FPGA they will set all the internal switches etc to realize the design you've put together.
- programming/flashing -- most systems use JTAG to do this.
When I started doing FPGA designs the hardest part for me was to break the notion of "software" when I was writing VHDL. You have to keep your head in the 'one clock' every variable gets to change exactly once in this block.
Good write up. However, I think saying synthesis turns hdl into gates is tangling with our digital design lingo.
Netlist is better, but to someone outside of digital design but with software background, I think I would call it a textual listing of the gates of the design and their interconnection. A graph.
I agree, and I struggled with calling out EDIF or just netlists. My choice was that the OP was "absolute noob just figured out Arduino" level and so netlists which are pretty obvious to anyone who has done schematic design are kind of a foreign concept to software only folks. But everyone seems to "get" that an FPGA dynamically wires together "gates" (even if they may be called LUTs, CLUTs, CLBs, or ALAs internally).
One of the ways I've helped SW types understand FPGAs was to describe the basic CLB as a subroutine that you program by setting very specific parameters and it has an input of some number of bits and a "clock" bit, and outputs the same number of bits. And the "program" is similar to the calling sequence of all these subroutines tied together.
Yeah, I didn’t really do any better. It just felt wrong to say gates at synthesis when it’s still a file on a computer instead of something physical like a transistor.
Although now that I said that, I guess with fpgas that is sort of always true. Programming fpgas is the equivalent of sending a file via FTP. Nowadays at least.
For FPGAs you generally have to use the IDE that the vendor gives be it Xilinx, Altera or Lattice. You can do the coding in Verilog, VHDL or component layout. You can also start with simulation using free stuff like Icarus Verilog or TKCircuit. Those tools are much simpler to get started.
"On board quality - I paid a High School/College kid in Sri Lanka to do the board; I will give him your feedback." the most beautiful thing i'll read today.
At once very cool and potentially very sad to me. Sad to think that skilled engineers are being underpaid because they lost the geographic birthplace lottery.
On the other hand relatively low amount of money makes this person wealthy. It's not just absolute amount that matters, it's where you spend it too. (saying as someone who is not from US, and wouldn't trade)
That was my first thought as well... I've worked with a handful of extremely skilled developers/engineers over the years in China, Russia and India that would be impossible to pay for at U.S. prices, but able to offer very competitive money for where they are located.
On the flip side, I've also had more very bad experiences with outsourcing overseas and communication barriers. Cultural differences are often underestimated, and without dedicated oversight/management things can go off the rails pretty badly. It really depends on a lot of variables.
I have mixed feelings about globalization myself, living in a higher paying country for the work I do. But I don't fault anyone for offering or taking a good wage for one's circumstances. I just wish it worked a bit better for the consumer in some protective markets (medications mostly, but others too).
I pay some overseas developers way below the median faang salary, and yet, their quality of life is likely much better than your average faang employee due to the much lower cost of living.
In other words, they aren't making six figures and yet still sharing a 2 bedroom apartment with 6 other developers.
This was my grand scheme all along - after having a comically high quality of life on 2k/month in Taipei as an English teacher, I moved back to the states to learn frontend. Now I'm building out my resume and network so I can eventually fuck off back to Taipei, work a couple contract roles, pull in a cool ~4kish a month, and live like a king while having far more time for my own projects.
It was inspired when me and my dirty, sweaty, budget beer-drinking buddies were hanging out at a 7/11 with a foreign engineer we had just met. He said he wanted to go to the club, we were like "dude cover is pretty expensive, let's just drink our 50 cent beers." He did a quick count of us, then said "ok, I'll pay for everyone's cover."
Rent was 250USD a month, 100mbps internet 20 USD... this on top of the fact that you're getting nearly equal healthcare because all the doctors are US school trained anyway, way better public transit (trains are automated! and CLEAN!!). I mean, it's the dream.
Just kidding haha. I mean their main language is Mandarin, so that can be a challenge, even though tons of people speak English.
If you want to work in a Taiwanese company, you may have to deal with a really shitty arbitrary work culture. Sitting on your phone till 8pm cause it looks good, such bullshit.
It can get absurdly hot in the summer, 40c levels, with high humidity, and usually you gotta get your own AC installed unless you're in a super new building (few places have central AC). Also taifun (how do you spell that in English...) can be really intense. Also the mosquitoes are a fucking nightmare.
If you're a vegetarian, forget about it lol. Nobody there understands or really cares. You'll only ever be able to eat at foreign restaurants which pretty much restricts you to Taipei or maybe kenting.
Hmm other than that it is literally paradise to me. Whatever you want is an hour train ride (for one USD) away. Surfing, hiking, bicycling through mountains, rock climbing, art meetup things, entrepreneurship stuff, hackerspaces, hackers... It's such an amazing country.
Oh you do have the constant fear that north Korea or China will nuke you.
> If you're a vegetarian, forget about it lol. Nobody there understands or really cares. You'll only ever be able to eat at foreign restaurants which pretty much restricts you to Taipei or maybe kenting.
This is NOT the case. Compared to mainland China (where it's like you say), Taiwan didn't have a cultural revolution and therefore more of the local Buddhist culture where veganism is strong.
At most places when I say I am vegetarian or vegan they will ask me if I eat onion and garlic (since local Buddhist vegans will often not eat those either). Of course you'll find nothing vegan in a beef-noodle restaurant. It's not like in the west where all restaurants have at least one lacto-ovo-vegetarian option on the menu, but there are still plenty of options.
There are cheap local vegan restaurants littered across the city. Just look for the 素 sign.
I would also add pollution to the downsides, if you're near or in a big city. Nowhere NEAR as bad as cities in the mainland, but on the bad days you can definitely feel it.
Taipei is going to be SUCH a nicer place once most scooters are replaced with electric ones.
How do the doctors get US school trained yet can afford a lower income? Medical school is quite expensive in the US. Do they get funding from their government to learn abroad?
Sometimes, yea. There's tons of scholarships. Also exchange programs etc. But it's a family oriented culture so oftentimes it's just the family pooling resources. low cost of living doesn't necessarily mean low comparative income, engineers can pull up to 60k USD yearly there which is a huge sum compared to cost of living.
There's a limited number of US residency spots, less than the number of med school graduates. If you don't get a residency there, you gotta do something.
The quality of life there isn't as high imo. Taipei has a better funded education and healthcare system. Bali hospitals, first hand experience, don't even come close.
Taiwan is essentially a first world country at a discount. Their populace is largely well educated (last I checked at 99% literate) and there are tons of engineers and entrepreneurs for me to engage with.
Oooh you'd love the hacker culture there, lots of builders. There's a little town devoted to their art, near ntu, can't recall the name.
You can get buy with just English but you'd be doing yourself a disservice if you didn't spend your time picking up Mandarin. There's often free classes, plus everyone is friendly.
Here, I found some of my old blog posts. The articles are relatively short and go over some of the details:
"Investing in property" is not something I would include in "live well". It sounds like you are assuming everyone should be aspiring for wealth.
Regardless, I was based in Taipei for about 1.5 years and if you just adapt your lifestyle it's still definitely doable to even save a significant portion of a $2k salary. Rough calculations below assuming a single person on a conscious but not frugal lifestyle:
* Rent: ~10000 NTD per month if you're not sharing (you can still find decent places for cheaper). This will put you central enough to have easy access to everywhere but not smack in Da'an.
* Food: ~8000 NTD per month
* Transportation: ~4000 NTD per month
* Other: ~20000 NTD per month
That leaves > 30% of your salary left over. If you regularly splurge on coffee shops and western-style bars and restaurants (all of which are relatively ridiculously pricey) you will have less of course.
I am guessing that in 2 months you might still have had a more of a "tourist life-style" (eating out at expensive places, paying much more for accommodation than if you have a proper contract or own your place, going to work at Starbucks, etc).
It's kind of ridiculous just how much of a luxury coffee shops really are. One coffee at hipster cafe will be more than twice of a good meal at the delicious vegan buffet next door.
Median salary in Taipei is somewhere around 2k USD IIRC.
I love Taiwan and only reason I left was relocating for building a team in Europe.
You might also invest in property to retire (unless you are sure your pension will cover it) and so that you are not as susceptible to fluctuation in rental costs.
I was there to take part in MOX accelerator. Company paid for accommodation, MOX provided work space. Day to day was cheap but property is damn expensive for what people earn. Ypu buy property because you have responsibilities towards your family and living hand to mouth and at risk of being booted out of your apartment by a dickhead landlord is not fulfilling your duties as a parent. You can live like a teenager all you like but you will eventually face reality.
I might be missing something here, but how does not owning property necessarily mean "living hand to mouth and at risk of being booted out of your apartment by a dickhead landlord"?
In short, my expenses were under 1,000usd monthly.
Like the other person that replied, I did that by not really eating out often, not going to foreign restaurants, and choosing cheap activities, which Taipei has plenty of. Rock climbing was 30c at the gym, hiking was free, a day trip to fulong for bicycling was like five bucks total. Etc.
So yea, putting 50% of income away to savings isn't exactly ideal I guess (we're supposed to do 70% right?) Hence my plans to move back as an engineer.
Edit: in hindsight, I don't know how the fuck I was spending 200$ on groceries lol. That's how much I spend here. I could definitely optimize that budget. Probably wasn't leveraging the morning markets enough and buying too much Nutella or something.
Have you presented your developers the opportunity to move to higher cost of living area for in increased salary (or vice versa, supposing you pay some developers much higher wages and you deem this a good deal)? Just because discriminating on geographical location is widely accept practice we should not pretend it is OK or worse, feel good about it.
I don't have to know the cost of living. But I can make a salary offer, and if they accept it, I can assume it's good for them. At the same time, I am always aware of the cost of living in an area, because I want to make sure my employees are comfortable and not encumbered by worrying about where their next meal is coming from. It isn't good for productivity.
In other words, salaries are set by supply and demand in that market, not by the arbitrary value that one might assign to a specific job.
So I should feel bad for paying employees above market rate in their area and giving them a better life than they could ever get by getting a local job? Sorry, not going to happen (me feeling bad about it, that is).
Do you think everyone should pay San Francisco salaries to developers no matter where in the world they live? Seems absurd.
What is so absurd about getting the same payment for the same job? In fact, there are plenty of legislation that underpins this very concept for various groups of people, overseas workers not being one of them, so? I don't really buy the rational market argument, surely that would mean no fungible roles for SV developers.
How one should feel about discriminating people slightly less than socially accepted is indeed complex and somewhat up to taste, I can give you that.
Indeed, but I'm less interested in finding what should be the right salary for a particular role at a particular company than actually addressing the disparities.
> Sad to think that skilled engineers are being underpaid because they lost the geographic birthplace lottery.
How do you know they were underpaid?
It's cheaper for me to have boards made in Colorado than in Santa Clara, and I'm certain the Colorado workers are paid less (the parts come from Digit-Key either way). Would you consider your statement true in that case too?
They amount paid (whatever it was) might have been enough for a nice lifestyle in Sri Lanka -- perhaps more so than the Colorado case.
High school kids everywhere appreciate the chance to make money doing interesting work. This kid will continue building skills and will join the modern economy. I’m more worried about all his peers who ARE NOT doing this.
The terrible routing of the board does actually impact the device though - the decoupling and power distribution is so messed up that PLLs do not lock on it [1]. Also the lack of a proper external clock means you have to rely on the +/- 10% internal 48MHz oscillator.
Start with digital logic fundamentals(not, or, and, xor, xnor gates, flip-flops(d, jk, etc). It helps to know some analog theory so you understand propagation delay and such. Then you'll probably want to learn a language like Verilog or VHDL. From my experience, most people like Verilog and VHDL is mostly used in the defense industry.
You could probably skip right to Verilog/VHDL, but I really suggest having a background in digital logic.
FWIW, I'm just an embedded software guy. I came from an EE background but it's been a long time since I've played with programmable logic.
if practicality is a concern at all, then you can get stm32's for about that which will have significantly more power than you'll be able to cram into a $5 FPGA, and the development environment will actually be pleasant.
(or just buy them, there's at least one on crowd supply, another was on kickstarter in the last couple years, etc)
I wanted to get into FPGA programming recently after feeling confident mastering my microcontroller skills and discovered that complex programmable logic devices (CPDLs) can be a stepping stone to full on FPGA prototyping. They somewhat of a similar high-level functional design and there are some nice guides online to get started on some projects.
You can synthesize a 6502 on an FPGA just fine and can probably do it on this specific chip. There is a project I've seen (https://danstrother.com/fpga-nes/) where someone did synthesize the 6502 along with the rest of the hardware on a Spartan 3 which does have more resources available to it. Looking at the utilization report in the comments on that page, it would be too much for this little Lattice chip. There are other FPGA development cards out there similar in size that would work better for your idea. You would be better off getting a larger development card for designing and then moving to some custom PCB that fit only the components you need at the size you want.
The FPGA seems to be a ICE40UP5K which has 5280 logic elements each configurable to any Boolean function of up to four inputs plus a flip-flop to store the result. Wikipedia gives two numbers for the transistor count of the 6502 namely 3,510 and 4,237 but both are smaller than the number of logic elements so fitting a 6502 should be easily possible. The FPGA has an integrated 48 MHz clock so a 2 MHz designs also seems quite achievable. I can not tell whether the remaining logic elements, the memory, and the I/O blocks are sufficient to build everything else because I know essentially nothing about the NES. It seems at least not wildly implausible to me but memory might become an issue because there is only about one megabit on the FPGA.
Remember that you also to implement need memory (the UP5K actually does have quite a bit of SPRAM, though), a memory controller, a ROM, the NES PPU (which was mixed signal) and that comparing transistors to LUT/DFFs is not really a fair comparison (as transistor based logic is not immediately always convertible to RTL logic, and that high-density FPGA designs are much more tougher to route while meeting timing).
Finally, the UP5K is actually fairly slow (when it comes to routing timing) compared to the iCE40 HX/LP, and especially compared to other, more modern FPGAs. The iCE40 routing in general also tends to be underwhelming at high density designs.
Can someone explain why someone would choose an FPGA over a standard microprocessor? What advantages could this UPDuino have over an Arduino? Also, how do ASIC's figure into this comparison?
My understanding is that microprocessors excel at executing logic using an onboard general-purpose ALU sequentially and quickly.
On the other hand, an FPGA excels at doing a specified task as the hardware (gates) are programmed/hooked up in a certain way to execute that one task.
ASIC's are processors that are designed from the factory to execute a specific task (kind of like pre-programmed, non-reprogrammable FPGA's).
Can someone please fill in the gaps please? I have a general idea, but I'm not sure I understand all the differences correctly.
CPU's like the ones that include Intel ME, AMD PSP or ARM TrustZone are not embedded in ASIC's. A ASIC is meant to perform a single task well, if you need or if there even could ever be a usecase for a OS or processor like those examples then by definition it isn't an ASIC anymore.
- because writing RTL is fun, while writing C code is boring. :-)
- because it's probably not possible to outputs VGA with your standard microprocessor. You can create a dinky 3-bit VGA output with very little hardware.
- because I may want to DMA data from an external sensor and feed it straight into a DSP for processing, and only use the CPU to deal with the post-processed result. Think multi-channel audio etc.
- because anything that requires fast real-time is probably not possible with the standard microprocessor.
I mostly agree with your post and its spirit. But I've dabbled enough with microcontrollers and custom consoles to say that vga is completely doable at 800x600 32k colors on a 7$ microcontroller : https://github.com/makapuf/bitbox
A Field Programmable Gate Array can be seen as the prototyping stage of Application Specific Integrated Circuits: ASICs are very expensive to manufacture, and once it's made there is no going back (as the most expensive fixed cost is the masks [sort of manufacturing "stencil"] and their development). FPGAs are reprogrammable many times, however because of the fact that a generic array of gates is connected to accomplish your goal, it is not optimised like ASICs. Also, FPGAs are natively dynamic devices in that if you power it off, you loose not only the current state but also your configuration. Boards now exist though that add a FLASH chip and/or a microcontroller to load the configuration at startup so this tends to be a less important argument. Both ASICs and FPGAs can be configured with Hardware Description Languages, and sometimes FPGAs are used for the end product. But generally ASICs kick in when the design is fixed.
FPGA VS microcontroller
As for the difference between a microcontroller and a FPGA, you can consider a microcontroller to be an ASIC which basically processes code in FLASH/ROM sequentially. You can make microcontrollers with FPGAs even if it's not optimised, but not the opposite. FPGAs are wired just like electronic circuits so you can have truly parallel circuits, not like in a microcontroller where the processor jumps from a piece of code to another to simulate good-enough parallelism. However because FPGAs have been designed for parallel tasks, it's not as easy to write sequential code as in a microcontroller.
For example, typically if you write in pseudocode "let C be A XOR B", on a FPGA that will be translated into "build a XOR gate with the lego bricks contained (lookup tables and latches), and connect A/B as inputs and C as output" which will be updated every clock cycle regardless of whether C is used or not. Whereas on a microcontroller that will be translated into "read instruction - it's a XOR of variables at address A and address B of RAM, result to store at address C. Load arithmetic logic units registers, then ask the ALU to do a XOR, then copy the output register at address C of RAM". On the user side though, both instructions were 1 line of code. If we were to do this, THEN something else, in HDL we would have to define what is called a Process to artificially do sequences - separate from the parallel code. Whereas in a microcontroller there is nothing to do. On the other hand, to get "parallelism" (tuning in and out really) out of a microcontroller, you would need to juggle with threads which is not trivial. Different ways of working, different purposes.
You can program an FPGA to work like a microprocessor, or pretty much any other digital circuit that fits. They are great for teaching students about computers and hardware design languages.
Most FPGAs are essentially grids of little devices which are programmed to map a certain input pattern to a certain output pattern. Like, 0000 -> 0101, 0101 -> 1111. They emulate logic gates. When you program an FPGA, you are both programming these maps, and setting the connections between them.
(Note: efficient means processing power / electrical power)
ASICs, on the other hand, are custom-built ICs which are designed to very efficiently perform one task, like performing SHA hashes or h.264 decoding.
FPGAs can be more efficient than full-fledged processors because they can make use of custom combinational (combinations of gates) logic along with sequential (clocked) logic. ASICs can be more efficient than FPGAs.
Essentially, there's a tradeoff between development cost, unit cost, efficiency, and flexibility.
I think scoring is not right because FPGA should be more flexible than processor and processor should be more efficient than FPGA. You might be considering a specific use case where FPGA would take over.
I disagree. Processors can be programmed in many sophisticated languages and have many built-in features that either don't come in similarly priced FPGA, or you'd have to program into the FPGA itself.
> processor should be more efficient than FPGA
It depends on the workload. Some things, processors might be more efficient at. But FPGAs have the upper hand at many things because they can use combinational logic.
> ASICs, on the other hand, are custom-built ICs which are designed to very efficiently perform one task, like performing SHA hashes or h.264 decoding.
ASICs aren't necessarily task specific, you can do whatever you want in an ASIC.
Your unit cost analysis isn't quite right either, because what really matters is scale. The primary cost tradeoff between an FPGA and an ASIC is strongly dependent on manufacturing scale. ASICs have high design and tooling costs, but low unit cost after that. FPGAs on the other hand have much lower initial cost, but higher unit cost. Whether or not it makes sense to use an ASIC depends largely on whether or not you're going to ship enough units to amortize the setup costs, hence why a lot of manufacturers often design a single ASIC to be used across multiple products.
Even then, FPGAs are now pretty inexpensive at scale. Open up your favorite $5000 oscilloscope and it will probably have a proprietary ASIC. Open up your favorite $400 oscilloscope and it just has an off-the-shelf FPGA. Mine even runs Linux, apparently.
(As an aside, I broke my $400 'scope about a month after purchasing it. One of the rotary encoders just stopped turning and is now jammed and it would be quite the undertaking to repair it. I learned my lesson.)
> ASICs aren't necessarily task specific, you can do whatever you want in an ASIC.
I mean, it's stands for "application specific" so it's really just a matter of semantics.
> Your unit cost analysis isn't quite right either
Yeah I realize now my unit cost analysis is confusing. `++` means "best unit cost" aka "least expensive". I forgot to go into the scale issue more, which is where FPGAs can really come into the equation as a good middle ground between unit cost at scale and development cost.
You chose fpga when you have yo handle bit streams with a precise clock to interface with a hardware, for example a screen or camera.
It is very difficult to have a precise timing with a microcontroller unless you have a good one with timers. It becomes impossible to do when you need to toggle several pins at the same time quickly (like a pci bus). You overcome the problem by adding a fpga to your microcontroller board, which will handle the bit flipping and communicate to the micro with a standard bus like spi or i2c.
You are correct enough here. The interesting question is not how they are different, but what the advantages are.
An FPGA is really good at doing a single task a ton of times. A microprocessor is good at doing a lot of tasks a ton of times. And an ASIC is just a more permanent and more efficient FPGA.
So when would I use an FPGA? Let me describe an example: Stream processing.
Let's say I have a stream of data. Like a camera producing a video feed. As each frame of data comes in, we want to compare it to the previous frame and take the average of the two values to create a blurring effect.
On a microprocessor we process each frame. We iterate over groups of pixels one at a time, compare it to the value at the pixel in the previous frame and divide by two. Our processing time is a function of the number of pixels we want to look at. If we're lucky we have multiple cores so we can do work in parallel. Maybe even do 32 groups of pixels in parallel on a ryzen or something. But if we have a 1 megapixel image, we're going to still have to visit ~30k pixels sequentially on each core and perform some math. We're probably adding at least a few ms of lag on the feed. And if we're trying to do any multitasking on this cpu, then we may not have very predictable performance.
On an FPGA we approach the problem very differently. Instead of having sequential logic for visiting each pixel, we have combinatorial logic. Supposed each pixel came through on a different wire. That wire goes into a component that holds the previous value for the pixel and outputs the average of the current and previous value. We then take that output and rebuild the video feed with it. On a 1 megapixel image, our unit of work is a single pixel and we have concurrency of 1 million units. We add a cycle or two of lag, which is negligible. Additionally, we have very predictable performance because our computation executes in lock step with the system clock.
FPGA's are expensive (per unit cost) and aren't always the most efficient. An ASIC will drop per unit cost and power requirements significantly but has a large up front capital investment.
>On a 1 megapixel image, our unit of work is a single pixel and we have concurrency of 1 million units.
Wouldn't that require 1 million input wires into the FPGA? Otherwise, you could use fewer input wires, but the input signals would need to be multiplexed to allow multiple bit streams to transit a single wire - significantly reducing your concurrency.
That's a detail the parent clearly skipped for tldr. On the kind of large (expensive) FPGA you might use for that kind of image you will find what are called deserialisers and serialisers which are hardware blocks that can take a serial bitstream as may come from a camera module or dvi bus and split it up onto your parallel processing streams.
The kind of small FPGA as is mentioned in the OT is typically used for "glue logic", that is performing relatively simple logic on multiple pins, often to adapt one hardware protocol (say mipi bus from a camera module) to another (say spi Bus understood by a cheap micro controller).
what was written is clearly a simplification, but outlines the high level architecture differences. Say you want to do this with a 10 megapixel image, clearly you are not going to fully parallelize that, but you could load the whole thing into BRAM divide it up into 100 regions and itterate over that. This also ignores that most FPGAs are not just a pile of flip-flops you wire together, but instead have a whole pile of specialized blocks in addition to look-up-tables.
I think you have it pretty close. Also FPGA are good for low volume custom circuitry. ASICs are good for high volume custom circuitry. And things are a hybrid of the three these days. Something like a cell phone has a ASIC with standard features like an ARM core, cellular communications, WiFI, display controllers.
FPGAs can have hardware parallelism. And not some specialized SIMD instructions, but the one kind of parallelism you need.
FPGAs can have deep pipelines, so instead of taking data from the memory, working on it, storing it back and moving to the next, you can take serial data, process it in multiple stages and only writing to memory at the end.
FPGAs can have deterministic timing (with a clock). So you can synchronize stuff in parallel, you can have it respond in nanoseconds, you can follow a signal without losing any sample.
FPGAs can have complex pipelines, so you can take an earlier response from the system, but continue processing your data for a more elaborated response later, without performance loss.
When you are talking about small ones like this a common reason I don't see mentioned here is peripheral flexibility. A processor is going to come with a fixed set of peripherals what happens if you need 10 UARTs but the processor only has 3? An FPGA can solve that problem.
An FPGA is not the same thing as a microcontroller.
Field Programmable Gate Array: An FPGA can be a microcontroller, but a microcontroller can only pretend to be an FPGA. Your microcontroller was probably prototyped on an FPGA.
ASICs are basically FPGA designs etched onto permanent silicon.
Thank you for linking to at least one page on the company site. The https://tinyletter.com/ article links to it only very obscurely around an image. There are many normal links in the article, so I assume the failure to link clearly to the product under discussion was just an oversight.
All these new affordable FPGA are getting really tempting to learn more about them. I've been debating for a while to get the TinyFPGA BX board from Sparkfun. Though I don't have a specific application yet. Are FPGA used in robotics often? Or is the response time so low (relatively) that it makes more sense to stick with a uC?
Side note, this might seem like stupid question, but can anyone explain what APIO[1] is (which TinyFPGA uses)? I'm kind of confused what it's used for.
As someone who just started getting into it, it's kinda hard to come up with an application until you have one and know how to use it a bit. I bought an icestick not knowing what I was going to do with it, but now I have quite a few ideas. They can be useful in robotics, as glue logic, for sensor fusion or for very precise real-time applications.
apio is a command line tool that automates installing the toolchain for your FPGA and running it. It just simplifies things, you don't have to use it if you'd rather call the individual tools for synthesis, P&R, simulation etc. It'd be reasonable to think of it as akin to a very smart Makefile combined with an automatic package manager, specialized to FPGAs (it's based on PlatformIO). It's nice when you're still kind of getting oriented, because you don't need to know how to set up and invoke the different tools... just call `apio build` or `apio simulate`.
Did you know Verilog or VHDL beforehand? I'm super interested in doing sensor fusion (or even just basic sensoring like a UKF). But it seems so overwhelming (compared to a uC like Arduino or ESP8266), I don't even know where to start. Do you have any tips or tutorials that you recommend?
Thank you for the explanation for APIO! Do you use it often? Or are there alternatives that people use when they get to a certain level (Like Atom/VScode --> vim)?
I'm loosely in a similar boat. I learned a little Verilog and implemented a MIPS CPU with pipelining, and did some small scale stuff based on papers about systolic arrays for matrix multiplication (a la TPU).
It feels to me like there is an enormous gap between the level of complexity in implementing a simple CPU like I did to something that would actually be useful to anyone, even something relatively small and basic. Things like integrating with other components or building up more complex designs feel outside my reach.
The resources I find are generally targeted either towards a very basic level of how electronics work or a very specific level of a particular task with a device. This seems like a really interesting area, but difficult to get comfortable with.
I totally agree. I followed a couple tutorials on how to make a LED blink but it doesn't really provide much substance. The other popular tutorial is a NTSC/PAL decoder that usually goes way over my head...I'm hoping with all these affordable FPGA, there will be boom like the early 2010s boom of Arduino!
I had some exposure to VHDL, but only from a workshop I attended and it wasn't really any more than you could get from watching YouTube tutorials. I prefer Verilog now anyway as it's way more concise.
The best place to start is to just grab a book and an FPGA kit and go. You'll probably have to try a bunch of tutorials until you find one that clicks for you and after that it gets easier. For iCE40 you can also check out IceStudio, which is a graphical block based IDE that can be helpful for getting your feet wet. Get some hardware to give you feedback and play with, e.g. a 7-segment display and implement a driver yourself. Watch YouTube videos to get an idea of the general flow of things and eventually it'll make sense. IMO it helps a lot if you have a background in electronics, if not you're gonna be in pretty deep.
I use apio because it's convenient. Hardcore FPGA devs are going to use the manufacturer's IDE. The official Lattice tools for the iCE40 are unbelievably awful and there's not much to gain from using their iCECube2 IDE versus open source ones, but in most cases you don't have any choice in the matter and have to use the manufacturers tools. This isn't so bad though, I've had some exposure to Xilinx's ISE and Vivado and they are pretty decent, plus Xilinx gives you access to a ton of free IP cores that you can drop into your design.
Yeah, the only downside is that it doesn't support simulation yet, which is super important for doing anything non-trivial. I think just a few minutes of playing with it and looking at the examples (it has a bunch of really good ones) is enough to help make a lot of progress. That's how it was for me, anyway. It was the little nudge I needed to start understand what was going on.
You aren't going to be able to build a super-fast CPU on an FPGA but there are plenty of other tasks you could give it. You can build a processor for analyze multiple sensors, looking for specific events that you could then feed to the uC or setup a DSP pipeline to filter the sensor data to look for patterns. The nice thing about an FPGA is that there is no interruption when it's running. The uC might be trying to feed data over wifi to the controller station and polling sensors/analyzing sensor data is going to bog things down really quick. Another task for an FPGA would be to act as a switch for a network within the robot. It would sit between all of the sensors/actuators and an ethernet-enabled uC located elsewhere in the robot. The FPGA would read command packets from the uC and translate tasks like "read temperature sensor #5" or "turn 15 degrees" into specific impulses on the pins while also turning sensor and feedback data into packets to send back to the uC. You could even run video feeds from cameras back to the uC over gigabit if the FPGA supports it. This way you can run a cheap, small uC to control things from a higher level while the i/o-plentiful FPGA does all the heavy lifting at 100Mb/s speeds.
Something like this sounds super interesting. Is it hard to get the FPGA to talk the uC? I own the DSP book by Proakis/Manolakis, but I picked it up only twice...so my understanding of DSP is pretty abysmal.
Typical uses for FPGAs in robotics include basic processing on the high bandwidth bitstreams from cameras or laser scanners into a format / representation more easily handled by the main CPU (building a depth map from the raw laser scanner photodiode stream, for example).
They are also used on the motor control side, though these days a motor control mcu may be more practical in most cases today.
Decoding rotary encoders is a common task, and very hard to do with Microcontrollers at either high event rates or multiple instances.
Maybe even turning a brushless motor with an encoder into a servo motor.
My main idea for using FPGAs would be talking to a couple of i2c/spi sensors and reducing the data rates. Some sensors only have one or two possible i2c addresses, some require multiple requests to get a limited amount of data, reducing the polling frequency.
A useful example project would be an FFT or OFDM accelerator for a microcontroller. Most microcontrollers really struggle with FFT so it is an example where a small uC and a small FPGA can be cheaper than a large uC. Sliding window FFT is going to be another good example where the FPGA option is competitive.
My complaint about this new breed of maker-level FPGA boards is that the information on shipping is a bit sketchy. I believe most ship from the US (I think one didn't even tell where from) and that often leads to hazzles with customs etc. which I would prefer to know beforehand...
A critical advantage of these new FPGA boards is not only are they at the same price point like Arduino clones and many other common maker components, but they are also small enough to be useful as permanent component in a project.
With earlier FPGA Learning boards, the designers tried to cram a ton of stuff into them, usually a gazillion pins, leds, input devices and connectors. You can't easily put that on a Raspberry Pi or Arduino.
this thread might be dead now but can someone please explain why an FPGA is such a big deal, I always see them mentioned but just don't have an idea of what they can be made into? Can anyone give project ideas of why it would be better to use on FPGA? (not sarcasm, I'm genuinely curious)
116 comments
[ 4.5 ms ] story [ 176 ms ] threadCan anyone else recommend any other cheap entry level boards?
You'll need a USB blaster to program them, which adds another $10 or so.
They are small, but they are still large enough to add a little CPU with a little RAM, plenty of hardware multipliers etc.
I know this makes a few assumptions on what you mean by "Cheap", but I find sub $200 for FPGA boards to be pretty affordable when compared to the gamut.
https://www.digikey.com/product-detail/en/lattice-semiconduc...
http://www.clifford.at/icestorm/
It would be very nice to bring the cost of experimentation in CPU cores down to something easily accessible to even students. In the same way that RPI brought computing and hardware interfacing down to basically anyone who can afford a cup of coffee.
https://www.cnx-software.com/2018/09/04/licheetang-anlogic-e...
If you have an issue the solution shouldn't be to throw it away and buy a new one, that's incredibly wasteful and it encourages bad behavior by the manufacturer.
Are there any go-to IDEs that everyone uses? Resources/tutorials towards a `blinkenlights 101` project that are especially useful?
Edit: thank you all for the very excellent answers! I'm going to lose so much productivity over this!
There isn't really a go-to IDE that everyone uses. Each vendor have a proprietary IDE and they're all very bad. Lattice FPGAs have an open-source toolchain, but it's all command-line tools so you're left to build your own workflow of choice.
However to verify the behavior on the FPGA and actually program it into the device you'll usually need some vendor specific tools, for Xilinx (what I'm familiar with) you'll need a software package called Vivado. It provides information on whether or not the timing you've requested is possible, whether any part of the chip will get too hot, whether the design actually fits in the limited resources of the FPGA, as well as implementing, optimizing and outputting the design to the FPGA.
Lattice has an open source toolchain available at least for some of their devices, for Xilinx there are efforts to produce a reverse engineered toolchain but I don't know how functional they are, there are free (but not libre) versions of Vivado as well but you'll need to fill out US export paperwork and it doesn't support all Xilinx FPGAs unless you pay. I don't know what the story is with Altera.
- synthesis -- this converts the text description from HDL into gates (fun fact you can write valid HDL which cannot be synthesized into hardware)
- place & route -- this takes what is essentially a schematic from the first step and assigns it to resources within the FPGA. This is also where you specify which pins on the FPGA you want to be connected to the schematic outputs.
- timing closure and simulation -- This is the process where the FPGA place and route core is trying to either make your design fit in as few gates as possible or run as fast as possible (these choices often conflict so you have to prioritize one over the other)
- bitstream generation -- This is where an often encrypted stream of bits are generated such that if they are fed into the FPGA they will set all the internal switches etc to realize the design you've put together.
- programming/flashing -- most systems use JTAG to do this.
When I started doing FPGA designs the hardest part for me was to break the notion of "software" when I was writing VHDL. You have to keep your head in the 'one clock' every variable gets to change exactly once in this block.
Netlist is better, but to someone outside of digital design but with software background, I think I would call it a textual listing of the gates of the design and their interconnection. A graph.
One of the ways I've helped SW types understand FPGAs was to describe the basic CLB as a subroutine that you program by setting very specific parameters and it has an input of some number of bits and a "clock" bit, and outputs the same number of bits. And the "program" is similar to the calling sequence of all these subroutines tied together.
Then I start rattling off VHDL books to read :-)
Although now that I said that, I guess with fpgas that is sort of always true. Programming fpgas is the equivalent of sending a file via FTP. Nowadays at least.
On the flip side, I've also had more very bad experiences with outsourcing overseas and communication barriers. Cultural differences are often underestimated, and without dedicated oversight/management things can go off the rails pretty badly. It really depends on a lot of variables.
I have mixed feelings about globalization myself, living in a higher paying country for the work I do. But I don't fault anyone for offering or taking a good wage for one's circumstances. I just wish it worked a bit better for the consumer in some protective markets (medications mostly, but others too).
In other words, they aren't making six figures and yet still sharing a 2 bedroom apartment with 6 other developers.
It was inspired when me and my dirty, sweaty, budget beer-drinking buddies were hanging out at a 7/11 with a foreign engineer we had just met. He said he wanted to go to the club, we were like "dude cover is pretty expensive, let's just drink our 50 cent beers." He did a quick count of us, then said "ok, I'll pay for everyone's cover."
Rent was 250USD a month, 100mbps internet 20 USD... this on top of the fact that you're getting nearly equal healthcare because all the doctors are US school trained anyway, way better public transit (trains are automated! and CLEAN!!). I mean, it's the dream.
Just kidding haha. I mean their main language is Mandarin, so that can be a challenge, even though tons of people speak English.
If you want to work in a Taiwanese company, you may have to deal with a really shitty arbitrary work culture. Sitting on your phone till 8pm cause it looks good, such bullshit.
It can get absurdly hot in the summer, 40c levels, with high humidity, and usually you gotta get your own AC installed unless you're in a super new building (few places have central AC). Also taifun (how do you spell that in English...) can be really intense. Also the mosquitoes are a fucking nightmare.
If you're a vegetarian, forget about it lol. Nobody there understands or really cares. You'll only ever be able to eat at foreign restaurants which pretty much restricts you to Taipei or maybe kenting.
Hmm other than that it is literally paradise to me. Whatever you want is an hour train ride (for one USD) away. Surfing, hiking, bicycling through mountains, rock climbing, art meetup things, entrepreneurship stuff, hackerspaces, hackers... It's such an amazing country.
Oh you do have the constant fear that north Korea or China will nuke you.
> If you're a vegetarian, forget about it lol. Nobody there understands or really cares. You'll only ever be able to eat at foreign restaurants which pretty much restricts you to Taipei or maybe kenting.
This is NOT the case. Compared to mainland China (where it's like you say), Taiwan didn't have a cultural revolution and therefore more of the local Buddhist culture where veganism is strong. At most places when I say I am vegetarian or vegan they will ask me if I eat onion and garlic (since local Buddhist vegans will often not eat those either). Of course you'll find nothing vegan in a beef-noodle restaurant. It's not like in the west where all restaurants have at least one lacto-ovo-vegetarian option on the menu, but there are still plenty of options.
There are cheap local vegan restaurants littered across the city. Just look for the 素 sign.
I would also add pollution to the downsides, if you're near or in a big city. Nowhere NEAR as bad as cities in the mainland, but on the bad days you can definitely feel it.
Taipei is going to be SUCH a nicer place once most scooters are replaced with electric ones.
Taiwan is essentially a first world country at a discount. Their populace is largely well educated (last I checked at 99% literate) and there are tons of engineers and entrepreneurs for me to engage with.
It really is just a different class of country.
i have a side hobby of machining. i will only buy taiwan or german equipment.
You can get buy with just English but you'd be doing yourself a disservice if you didn't spend your time picking up Mandarin. There's often free classes, plus everyone is friendly.
Here, I found some of my old blog posts. The articles are relatively short and go over some of the details:
http://taipeitips.blogspot.com
http://ablate.blogspot.com/2014/05/what-does-it-cost-to-live...?
http://taiwanhikes.blogspot.com
Regardless, I was based in Taipei for about 1.5 years and if you just adapt your lifestyle it's still definitely doable to even save a significant portion of a $2k salary. Rough calculations below assuming a single person on a conscious but not frugal lifestyle:
* Rent: ~10000 NTD per month if you're not sharing (you can still find decent places for cheaper). This will put you central enough to have easy access to everywhere but not smack in Da'an.
* Food: ~8000 NTD per month
* Transportation: ~4000 NTD per month
* Other: ~20000 NTD per month
That leaves > 30% of your salary left over. If you regularly splurge on coffee shops and western-style bars and restaurants (all of which are relatively ridiculously pricey) you will have less of course.
I am guessing that in 2 months you might still have had a more of a "tourist life-style" (eating out at expensive places, paying much more for accommodation than if you have a proper contract or own your place, going to work at Starbucks, etc).
It's kind of ridiculous just how much of a luxury coffee shops really are. One coffee at hipster cafe will be more than twice of a good meal at the delicious vegan buffet next door.
Median salary in Taipei is somewhere around 2k USD IIRC.
I love Taiwan and only reason I left was relocating for building a team in Europe.
Just going to put this here for people who are interested: https://www.numbeo.com/cost-of-living/in/Taipei
In short, my expenses were under 1,000usd monthly.
Like the other person that replied, I did that by not really eating out often, not going to foreign restaurants, and choosing cheap activities, which Taipei has plenty of. Rock climbing was 30c at the gym, hiking was free, a day trip to fulong for bicycling was like five bucks total. Etc.
So yea, putting 50% of income away to savings isn't exactly ideal I guess (we're supposed to do 70% right?) Hence my plans to move back as an engineer.
Edit: in hindsight, I don't know how the fuck I was spending 200$ on groceries lol. That's how much I spend here. I could definitely optimize that budget. Probably wasn't leveraging the morning markets enough and buying too much Nutella or something.
Have you presented your developers the opportunity to move to higher cost of living area for in increased salary (or vice versa, supposing you pay some developers much higher wages and you deem this a good deal)? Just because discriminating on geographical location is widely accept practice we should not pretend it is OK or worse, feel good about it.
https://elsajohansson.wordpress.com/2017/09/13/what-does-a-w...
In other words, salaries are set by supply and demand in that market, not by the arbitrary value that one might assign to a specific job.
So I should feel bad for paying employees above market rate in their area and giving them a better life than they could ever get by getting a local job? Sorry, not going to happen (me feeling bad about it, that is).
Do you think everyone should pay San Francisco salaries to developers no matter where in the world they live? Seems absurd.
How one should feel about discriminating people slightly less than socially accepted is indeed complex and somewhat up to taste, I can give you that.
How do you know they were underpaid?
It's cheaper for me to have boards made in Colorado than in Santa Clara, and I'm certain the Colorado workers are paid less (the parts come from Digit-Key either way). Would you consider your statement true in that case too?
They amount paid (whatever it was) might have been enough for a nice lifestyle in Sri Lanka -- perhaps more so than the Colorado case.
[1] - https://twitter.com/oe1cxw/status/950083493073178625?lang=en
(Or... perhaps they weren't refurbished/reused, and we just discovered one manufacturer's test image?!)
Ive never did FPGA design. what's good resources to start reading to get caught up with the basics? Figure I should ask those more in the know.. :)
You could probably skip right to Verilog/VHDL, but I really suggest having a background in digital logic.
FWIW, I'm just an embedded software guy. I came from an EE background but it's been a long time since I've played with programmable logic.
(or just buy them, there's at least one on crowd supply, another was on kickstarter in the last couple years, etc)
Finally, the UP5K is actually fairly slow (when it comes to routing timing) compared to the iCE40 HX/LP, and especially compared to other, more modern FPGAs. The iCE40 routing in general also tends to be underwhelming at high density designs.
My understanding is that microprocessors excel at executing logic using an onboard general-purpose ALU sequentially and quickly.
On the other hand, an FPGA excels at doing a specified task as the hardware (gates) are programmed/hooked up in a certain way to execute that one task.
ASIC's are processors that are designed from the factory to execute a specific task (kind of like pre-programmed, non-reprogrammable FPGA's).
Can someone please fill in the gaps please? I have a general idea, but I'm not sure I understand all the differences correctly.
Multiple reasons:
- because writing RTL is fun, while writing C code is boring. :-)
- because it's probably not possible to outputs VGA with your standard microprocessor. You can create a dinky 3-bit VGA output with very little hardware.
- because I may want to DMA data from an external sensor and feed it straight into a DSP for processing, and only use the CPU to deal with the post-processed result. Think multi-channel audio etc.
- because anything that requires fast real-time is probably not possible with the standard microprocessor.
But mostly because writing RTL is fun.
Very nice project!
ASIC VS FPGA
A Field Programmable Gate Array can be seen as the prototyping stage of Application Specific Integrated Circuits: ASICs are very expensive to manufacture, and once it's made there is no going back (as the most expensive fixed cost is the masks [sort of manufacturing "stencil"] and their development). FPGAs are reprogrammable many times, however because of the fact that a generic array of gates is connected to accomplish your goal, it is not optimised like ASICs. Also, FPGAs are natively dynamic devices in that if you power it off, you loose not only the current state but also your configuration. Boards now exist though that add a FLASH chip and/or a microcontroller to load the configuration at startup so this tends to be a less important argument. Both ASICs and FPGAs can be configured with Hardware Description Languages, and sometimes FPGAs are used for the end product. But generally ASICs kick in when the design is fixed.
FPGA VS microcontroller
As for the difference between a microcontroller and a FPGA, you can consider a microcontroller to be an ASIC which basically processes code in FLASH/ROM sequentially. You can make microcontrollers with FPGAs even if it's not optimised, but not the opposite. FPGAs are wired just like electronic circuits so you can have truly parallel circuits, not like in a microcontroller where the processor jumps from a piece of code to another to simulate good-enough parallelism. However because FPGAs have been designed for parallel tasks, it's not as easy to write sequential code as in a microcontroller.
For example, typically if you write in pseudocode "let C be A XOR B", on a FPGA that will be translated into "build a XOR gate with the lego bricks contained (lookup tables and latches), and connect A/B as inputs and C as output" which will be updated every clock cycle regardless of whether C is used or not. Whereas on a microcontroller that will be translated into "read instruction - it's a XOR of variables at address A and address B of RAM, result to store at address C. Load arithmetic logic units registers, then ask the ALU to do a XOR, then copy the output register at address C of RAM". On the user side though, both instructions were 1 line of code. If we were to do this, THEN something else, in HDL we would have to define what is called a Process to artificially do sequences - separate from the parallel code. Whereas in a microcontroller there is nothing to do. On the other hand, to get "parallelism" (tuning in and out really) out of a microcontroller, you would need to juggle with threads which is not trivial. Different ways of working, different purposes.
https://electronics.stackexchange.com/questions/150058/what-...
Most FPGAs are essentially grids of little devices which are programmed to map a certain input pattern to a certain output pattern. Like, 0000 -> 0101, 0101 -> 1111. They emulate logic gates. When you program an FPGA, you are both programming these maps, and setting the connections between them.
(Note: efficient means processing power / electrical power)
ASICs, on the other hand, are custom-built ICs which are designed to very efficiently perform one task, like performing SHA hashes or h.264 decoding.
FPGAs can be more efficient than full-fledged processors because they can make use of custom combinational (combinations of gates) logic along with sequential (clocked) logic. ASICs can be more efficient than FPGAs.
Essentially, there's a tradeoff between development cost, unit cost, efficiency, and flexibility.
I disagree. Processors can be programmed in many sophisticated languages and have many built-in features that either don't come in similarly priced FPGA, or you'd have to program into the FPGA itself.
> processor should be more efficient than FPGA
It depends on the workload. Some things, processors might be more efficient at. But FPGAs have the upper hand at many things because they can use combinational logic.
ASICs aren't necessarily task specific, you can do whatever you want in an ASIC.
Your unit cost analysis isn't quite right either, because what really matters is scale. The primary cost tradeoff between an FPGA and an ASIC is strongly dependent on manufacturing scale. ASICs have high design and tooling costs, but low unit cost after that. FPGAs on the other hand have much lower initial cost, but higher unit cost. Whether or not it makes sense to use an ASIC depends largely on whether or not you're going to ship enough units to amortize the setup costs, hence why a lot of manufacturers often design a single ASIC to be used across multiple products.
(As an aside, I broke my $400 'scope about a month after purchasing it. One of the rotary encoders just stopped turning and is now jammed and it would be quite the undertaking to repair it. I learned my lesson.)
I mean, it's stands for "application specific" so it's really just a matter of semantics.
> Your unit cost analysis isn't quite right either
Yeah I realize now my unit cost analysis is confusing. `++` means "best unit cost" aka "least expensive". I forgot to go into the scale issue more, which is where FPGAs can really come into the equation as a good middle ground between unit cost at scale and development cost.
It is very difficult to have a precise timing with a microcontroller unless you have a good one with timers. It becomes impossible to do when you need to toggle several pins at the same time quickly (like a pci bus). You overcome the problem by adding a fpga to your microcontroller board, which will handle the bit flipping and communicate to the micro with a standard bus like spi or i2c.
An FPGA is really good at doing a single task a ton of times. A microprocessor is good at doing a lot of tasks a ton of times. And an ASIC is just a more permanent and more efficient FPGA.
So when would I use an FPGA? Let me describe an example: Stream processing.
Let's say I have a stream of data. Like a camera producing a video feed. As each frame of data comes in, we want to compare it to the previous frame and take the average of the two values to create a blurring effect.
On a microprocessor we process each frame. We iterate over groups of pixels one at a time, compare it to the value at the pixel in the previous frame and divide by two. Our processing time is a function of the number of pixels we want to look at. If we're lucky we have multiple cores so we can do work in parallel. Maybe even do 32 groups of pixels in parallel on a ryzen or something. But if we have a 1 megapixel image, we're going to still have to visit ~30k pixels sequentially on each core and perform some math. We're probably adding at least a few ms of lag on the feed. And if we're trying to do any multitasking on this cpu, then we may not have very predictable performance.
On an FPGA we approach the problem very differently. Instead of having sequential logic for visiting each pixel, we have combinatorial logic. Supposed each pixel came through on a different wire. That wire goes into a component that holds the previous value for the pixel and outputs the average of the current and previous value. We then take that output and rebuild the video feed with it. On a 1 megapixel image, our unit of work is a single pixel and we have concurrency of 1 million units. We add a cycle or two of lag, which is negligible. Additionally, we have very predictable performance because our computation executes in lock step with the system clock.
FPGA's are expensive (per unit cost) and aren't always the most efficient. An ASIC will drop per unit cost and power requirements significantly but has a large up front capital investment.
Wouldn't that need at least 24M flip-flops in the FPGA (assuming 8 bits per channel color)? I don't think anybody makes one that big.
>On a 1 megapixel image, our unit of work is a single pixel and we have concurrency of 1 million units.
Wouldn't that require 1 million input wires into the FPGA? Otherwise, you could use fewer input wires, but the input signals would need to be multiplexed to allow multiple bit streams to transit a single wire - significantly reducing your concurrency.
The kind of small FPGA as is mentioned in the OT is typically used for "glue logic", that is performing relatively simple logic on multiple pins, often to adapt one hardware protocol (say mipi bus from a camera module) to another (say spi Bus understood by a cheap micro controller).
FPGAs can have deep pipelines, so instead of taking data from the memory, working on it, storing it back and moving to the next, you can take serial data, process it in multiple stages and only writing to memory at the end.
FPGAs can have deterministic timing (with a clock). So you can synchronize stuff in parallel, you can have it respond in nanoseconds, you can follow a signal without losing any sample.
FPGAs can have complex pipelines, so you can take an earlier response from the system, but continue processing your data for a more elaborated response later, without performance loss.
ASICs are basically FPGA designs etched onto permanent silicon.
[0]: http://gnarlygrey.atspace.cc/development-platform.html#updui...
Side note, this might seem like stupid question, but can anyone explain what APIO[1] is (which TinyFPGA uses)? I'm kind of confused what it's used for.
[1] https://github.com/FPGAwars/apio
apio is a command line tool that automates installing the toolchain for your FPGA and running it. It just simplifies things, you don't have to use it if you'd rather call the individual tools for synthesis, P&R, simulation etc. It'd be reasonable to think of it as akin to a very smart Makefile combined with an automatic package manager, specialized to FPGAs (it's based on PlatformIO). It's nice when you're still kind of getting oriented, because you don't need to know how to set up and invoke the different tools... just call `apio build` or `apio simulate`.
Thank you for the explanation for APIO! Do you use it often? Or are there alternatives that people use when they get to a certain level (Like Atom/VScode --> vim)?
It feels to me like there is an enormous gap between the level of complexity in implementing a simple CPU like I did to something that would actually be useful to anyone, even something relatively small and basic. Things like integrating with other components or building up more complex designs feel outside my reach.
The resources I find are generally targeted either towards a very basic level of how electronics work or a very specific level of a particular task with a device. This seems like a really interesting area, but difficult to get comfortable with.
The best place to start is to just grab a book and an FPGA kit and go. You'll probably have to try a bunch of tutorials until you find one that clicks for you and after that it gets easier. For iCE40 you can also check out IceStudio, which is a graphical block based IDE that can be helpful for getting your feet wet. Get some hardware to give you feedback and play with, e.g. a 7-segment display and implement a driver yourself. Watch YouTube videos to get an idea of the general flow of things and eventually it'll make sense. IMO it helps a lot if you have a background in electronics, if not you're gonna be in pretty deep.
I use apio because it's convenient. Hardcore FPGA devs are going to use the manufacturer's IDE. The official Lattice tools for the iCE40 are unbelievably awful and there's not much to gain from using their iCECube2 IDE versus open source ones, but in most cases you don't have any choice in the matter and have to use the manufacturers tools. This isn't so bad though, I've had some exposure to Xilinx's ISE and Vivado and they are pretty decent, plus Xilinx gives you access to a ton of free IP cores that you can drop into your design.
They are also used on the motor control side, though these days a motor control mcu may be more practical in most cases today.
Maybe even turning a brushless motor with an encoder into a servo motor.
My main idea for using FPGAs would be talking to a couple of i2c/spi sensors and reducing the data rates. Some sensors only have one or two possible i2c addresses, some require multiple requests to get a limited amount of data, reducing the polling frequency.
With earlier FPGA Learning boards, the designers tried to cram a ton of stuff into them, usually a gazillion pins, leds, input devices and connectors. You can't easily put that on a Raspberry Pi or Arduino.