Getting started with FPGAs - Page 1
Forum section: electronics / general

author: RCMR
author_rank: Frequent Contributor
timestamp: October 11, 2012, 05:10:54 am
content: I couldn't see a more apt place to post this so here we go...I've been doing digital hardware for many, many years -- in fact I built my first computer back in 1977 (yes, I *am* that old).So far I've only needed to use microprocessors and microcontrollers plus some glue logic to achieve what I need but now I have a project (a "Sense And Avoid" system for UAVs) that I'm thinking will benefit hugely from the use of FPGA technology.It needs to do some number crunching that would require a very powerful processor -- and I think I can define the necessary functions in FPGA logic which would allow for a much more practical system (cheaper, smaller, lower-power).However, I'm a total newbie in the FPGA world - never used one - ever.Several folk have suggested I go the Altera Cyclone route and doing some homework, this looks pretty good.So what do those who've been down this road before me recommend in terms of starter-kits, development kits and getting up to speed ASAP?

author: TerminalJack505
author_rank: Super Contributor
timestamp: October 11, 2012, 05:45:16 am
content: Once you've decided on the FPGA family you are going to use and have a development board you'll then need to decide whether you are going to use VHDL or Verilog as the hardware description language and get up to speed on it.If you're already comfortable with digital systems then buy a book on whichever language you decide on and start hacking on your development board. There are a lot of free resources online too, obviously. There's a free VHDL 'free range' book out there that looks pretty good. The FPGA manufacturer will have a bunch of reference code available so be sure to leverage it for learning purposes or reuse in your own projects.Something you might do before you decide to go with either Altera or Xilinx (or maybe Lattice) is download their development software and see if there are any showstoppers in the software.

author: Codemonkey
author_rank: Regular Contributor
timestamp: October 11, 2012, 07:43:33 am
content: I just did this recently. I bought a Terasic DE0-Nano board which has an Altera Cyclone IV device on it with about 22K logic elements, some external FLASH and SDRAM and a few other peripherals (accelerometer etc). Its got enough capacity to be able to synthesize the Altera NIOS cpu core + peripherals, or even the Openrisc device from the opencores website (I believe someone even had uCLinux running on it).I used the board in conjunction with the Altera Quartus software, and they also have a free version of Modelsim that you can use to simulate your design and view the logic states (like a logic analyser display but for simulation).As for learning, well I'm fortunate that I work with a number of IC designers who reccomended I use Verilog for the RTL code, and everything else I just looked online for examples/tutorials and was able to pick the basics up reasonably quickly, but as an embedded software engineer who uses C mostly, it took a bit of getting my head around some of the constraints!The dev board is excelent though, its tiny (size of a credit card), runs off the USB cable that you use to program it, and has everything on it that you need to start and most importantly, its cheap - I paid about £69 I think from Farnell in the uk. The only downside I see with it really is that if you then move on to doing your own board with an FPGA on it, you can't use the eval board as a programmer for it (as far as I can tell). But thats not really the end of the world, Altera Byteblaster clones are available on eBay for very little anyway.I implemented a time to digital converter as a SPI slave device which used up a just a few % of the device's capacity

author: ptricks
author_rank: Frequent Contributor
timestamp: October 11, 2012, 12:39:37 pm
content: I got my start on FPGA with a board I got for about $75 off ebay.The board is sort of unique for FPGA boards because it has a cyclone 2 fpga and an ARM920 as well as a maxII cpld on the board. The board runs linux on one side and you can use the fpga for whatever you want on the other, you don't even need external programmers because the board comes with a linux program where you just load the fpga from within linux. It also comes with a VGA port that the fpga can use. Really nice board overall.http://www.embeddedarm.com/products/board-detail.php?product=TS-7300After using that companies board for a while I have been really impressed with the support they offer. I wasn't even the original purchaser but they supported it anyway. They also have an ftp site with code examples, downloads, tool chains, etc.When I get the cash my next purchase will be their new board complete with sataII ports.http://www.embeddedarm.com/products/board-detail.php?product=TS-7800

author: AndyC_772
author_rank: Super Contributor
timestamp: October 12, 2012, 08:23:21 am
content: Engineers generally fall into two camps, Altera or Xilinx, and once they've taken the time to learn their preferred manufacturer's tools and silicon they rarely switch. A few go for one of the second tier manufacturers like Lattice or Actel, but I wouldn't waste your time unless you have a compelling reason. Similarly, we all end up choosing either VHDL (my preference) or Verilog as programming language of choice. I believe Verilog is more popular in the USA, while VHDL is more prevalent in Europe and elsewhere - and using the same language as your colleagues is probably much more important than any practical differences between the two.I'm in the Altera camp - more by accident / history than conscious decision - and I bought this for my home lab:http://www.ebay.co.uk/itm/Altera-CycloneII-EP2C5T144-FPGA-Board-USB-Blaster-JTAG-/190501213198?pt=LH_DefaultDomain_0&hash=item2c5ac1d40eCyclone II is an old family now, but this little dev board is quite good if all you want to do is get to grips with the absolute basics of how an FPGA is programmed. Depending on what you want to do with it, you might find that a board with a microcontroller or some other peripherals is ultimately more useful - but this one is so cheap it's a no-brainer IMHO. And you'll certainly need the download cable anyway.It's a great shame that Altera discontinued the internal simulator in Quartus a while ago, it was a bit simple but nevertheless a fantastic learning tool, and much more accessible than ModelSim. I honestly can't think of a nice, easy way to get started with the language any more - sorry.

author: nctnico
author_rank: Super Contributor
timestamp: October 12, 2012, 09:33:02 am
content: Quote from: RCMR on October 11, 2012, 05:10:54 amThat depends largely on what kind of processing you need. There are very few area's in which an FPGA is faster than a modern CPU or GPU. And a CPU or GPU will always consume less power than an FPGA solution.

author: saigai
author_rank: Contributor
timestamp: October 12, 2012, 12:04:37 pm
content: Quote from: AndyC_772 on October 12, 2012, 08:23:21 amThumbs up from me at this board, I have the same one from ebay. One thing that I've regretted about it was that I've seen some <$50 boards out there with SDRAM, which I will want to look into at some point. That stuff is still beyond my skill level, though...Cyclone II is considered an old chip, but afaik it's still well available, and for hobbyists making their own boards with simple designs, the pricetag may be a factor to consider.

author: jeremy
author_rank: Super Contributor
timestamp: October 12, 2012, 01:12:18 pm
content: Quote from: nctnico on October 12, 2012, 09:33:02 amI disagree. For example, I went to a talk a few weeks ago where they used FPGAs and micros to detect, triangulate (in 3 dimensions) and classify gunshot noises in realtime. FPGAs and MSP430s, ran off 1.5V cells and fit in your palm. No way you are getting that done with a modern CPU at that power level and small scale. Also, it was one of the most amazing projects I have ever seenDoing anything in a pipeline, very low latency or massively parallel fashion (so pretty much any realtime signal processing) on a high frequency FPGA will beat the pants off any CPU. Only exception is rendering/fast matrix ops for GPUs, because they have been designed specifically to do that!All of these high frequency traders (for whom money is no object) just get a bunch of Virtex or Stratix FPGAs and stick them on a PCI express bus with a 40Gb ethernet port on the other side because they are faster than standard CPUs. Seehttp://www.accelize.com/about-us/news.htmlMy for-fun FPGA board is a Terasic DE0, with Verilog. I'd love to play with one of the new Zynq boards though, they have a dual core A8 and FPGA fabric on the one chip.

author: olsenn
author_rank: Frequent Contributor
timestamp: October 12, 2012, 01:30:02 pm
content: QuoteThe second part is correct, but the first part is wrong. Since power is the rate at which energy is transferred, FPGA's do use more power than CPU's; however, FPGA's can accomplish complicated tasks in a much shorter period of time than a CPU can (since it's all being done in parallel), so FPGA's often use less energy overall. If you need to use a low voltage battery cell that can't source much current, then a CPU would be needed (like the MSP430), but if you have the power requirmeents for an FPGA, you'll probably get more usage out of an FPGA with the same number of mAh. Of course this is further complicated by the fact that FPGA's are also less power efficient.For the most part though, I'd say stick with CPU's where it's an option as they're (currently) cheaper and easier to program. However, if you can't afford the thousands of clock cycles that may be required from a CPU, FPGA's are an option.

author: jeremy
author_rank: Super Contributor
timestamp: October 12, 2012, 01:46:35 pm
content: Quote from: olsenn on October 12, 2012, 01:30:02 pmDo you have a reference for this? I'm not trying to argue, genuinely curious. I would imagine that it depends pretty significantly on the task.

author: nctnico
author_rank: Super Contributor
timestamp: October 12, 2012, 04:16:05 pm
content: Its simple: for calculation tasks a CPU uses a whole lot less transistors to do the same. Less transistors means less power.For example look at:http://www.nxp.com/products/microcontrollers/cortex_m4/lpc4000/LPC4072FBD80.htmlIts a 200MHz ARM CortexM4 (with FPU) microcontroller. In power down the current consumption is less than 300uA.FPGAs have their use if you need to handle odd-ball signals, really large amounts of data and/or need a high level of integration. But microcontrollers and SoCs also feature high levels of integration these days. I only use an FPGA or CPLD as a last resort.

author: AndyC_772
author_rank: Super Contributor
timestamp: October 12, 2012, 05:57:24 pm
content: Who cares about its power consumption when it's not doing anything? The core is switched off, all you're measuring is the internal leakage and the power required for features like the brown-out reset detector, RTC oscillator and wake-up timer.The valid comparison is between the power consumed by a CPU vs an FPGA to perform a given task at a given speed. Even then, normally an FPGA is used to perform certain types of computationally intensive work which is better suited to an FPGA architecture than it is to a general purpose CPU.

author: gxti
author_rank: Frequent Contributor
timestamp: October 12, 2012, 06:20:39 pm
content: As was already pointed out, peak current consumption is only part of the equation. A FPGA that uses more dynamic current but does the entire computation in a few clock cycles with custom RTL will beat the pants off a CPU that needs thousands of cycles to do the same thing. But the standby current on the CPU will be much lower, so depending on the quantity of the workload and how CPU-like it is one might do better than the other.For the same reason you should never set your laptop to run permanently at its lowest clock speed. You want it to do everything as fast as possible so it can get back to a low-power sleep state, which uses less total energy than running slower and needing more time to do the same work.

author: free_electron
author_rank: Super Contributor
timestamp: October 12, 2012, 07:45:12 pm
content: I use an FPGA as a coprocessor to do some really time critical stuff. FPGA is clocked at 48 MHz , as is the attached ARM7.Same system purely implemented in software needs a dual core arm A9 clocked at 1.5 GHz and it barely copes...Why ? simply because the fpga handles everything in parallel. what takes 1 clocktick on the FPGA takes hundreds on the cpu.if i need to do certain calculation the cpu needs to do them sequentially and is fighting against the deadline to get it done.I simply add more calculation engines in parallel in the fpga. Same 1 clocktick , multiple results.I use a 'peristaltic' process. i have a clock and an 'anti-clock' ( clocks are 270 degree out of phase ) the net effect is that data is crunched on both edges of the clock.... each clock has the same logic attached , they simply run out of phase. timing is tuned in such away that memory access is deterministic. i share multiport memories between bocks.Where a traditional cpu has to do :do this on 1000 numbers :load instructionload address pointer for first numbercopy data to accumulatorload address pointer for second number ( assuming the pointers were known. if it needs to calculate the pointer ... throw in a few more instructions here... )copy data to 'b register'execute instructionload address pointer for target address ( hoping you dont need to calculate it )copy accumulator to addressincrement the 3 pointers ...The fpga simply says : i set all three addresses in 1 shot on rising edge ( multiport memory has 2, 3 or 4 address and data busses. i can read simultaneously from multiple locations and write to another )The data outputs from the memory go to the ALU which already has the instruction loaded. i know the 'flight-time' in the alu.The output of the ALU is latched on the falling edge of the 'anti-clock' into the ram. ( multiport ram i synchronous )So handling a table is extremely fast. have 3/4 of the clock period for the ram to fetch the data and the ALU to prcocess it. the last 1/4 the result is written. i could actually simply use the falling edge of the main clock but there are other implications in my system ( i preload the address pointers 1/4 clock early to gain more time in another block. it's timing trickery. )on the cpu : 50 instruction to produce 1 output number. this loop needs to repeat 1000 times. ( once per number) gicing me 50000 instructions to process.On the fpga : Handling 1000 numbers takes 1000 ticks. And if i split this block in 4 ( each holding 1/4 of the table and each having its own ALU ) i crunch this in 250 clockticks...Net result: What takes 50000 clockticks on the cpu is done in 250 in the fpga...Modern FPGa's have lots of resources and it is very eay to simply replicate a block n times and run them in parallel. No cpu can beat that.

author: nctnico
author_rank: Super Contributor
timestamp: October 12, 2012, 09:37:53 pm
content: You really should look into Cuda instead of FPGA if you need die-hard number crunching:http://www.nvidia.com/object/cuda_home_new.htmlYesterday's super computer power is affordable for everyone today.And ofcourse there are embedded ARM based solutions as well:http://www.nvidia.com/object/carma-devkit.html

author: RCMR
author_rank: Frequent Contributor
timestamp: October 12, 2012, 10:51:45 pm
content: This application does a fair bit of signal processing including FFTs, has to work in real-time and needs to be as small/light as practical. Power consumption is an issue -- but not the over-riding one.

author: nctnico
author_rank: Super Contributor
timestamp: October 12, 2012, 11:32:38 pm
content: I'd try to get an idea on how much processing power you need first. Maybe even built a prototype of the software on a PC so you get a feel on where the bottlenecks are.

author: RCMR
author_rank: Frequent Contributor
timestamp: October 13, 2012, 02:12:39 am
content: Yes the basic design is being done on existing gear (because the testing can be done in a non-realtime environment). Then the "stuff that needs to go really fast" will be optimised and if an FPGA becomes a better proposition than an ARM or whatever, the change will be made.Of course to get a real feel for the strengths/weaknesses and suitability of FPGA so I can make that decision, need to get my hands dirty first -- hence the OP.

author: free_electron
author_rank: Super Contributor
timestamp: October 13, 2012, 05:33:55 am
content: While cuda and gpus have fenomenal crunching power ... Good luck integrating that stuff into a small device. For starters you need a host processor and an operating system... And those nvidia chips arent exactly easy to handle either.. Take an fpga in tqfp package and things change rapidly ....

author: bingo600
author_rank: Super Contributor
timestamp: October 13, 2012, 03:38:37 pm
content: Just as an option ... I have seen Xmos mentioned as a possible FPGA replacment if the need is correct.Ie. 8 x Cores , but i think there are other models , and afaik tools are freehttp://en.wikipedia.org/wiki/XCore_XS1-L1/Bingo

author: nctnico
author_rank: Super Contributor
timestamp: October 13, 2012, 03:41:03 pm
content: Quote from: RCMR on October 13, 2012, 02:12:39 amThe biggest problem when using FPGAs for signal processing is that libraries for doing complex stuff like image compression, FFT, etc are not for free. So you either have to develop those yourself or buy them. Both options are not cheap. A DSP is more likely to fit the bill. And you can get ARM SoCs with an integrated DSP. TI has several of those in their portfolio. Depending on your application you may not need an OS. Most bootloaders offer enough functionality to run an application.