Author Topic: Getting started with FPGAs  (Read 7859 times)

0 Members and 1 Guest are viewing this topic.

Offline RCMR

  • Frequent Contributor
  • **
  • Posts: 405
Getting started with FPGAs
« on: October 11, 2012, 05:10:54 am »
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?
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1306
  • Country: 00
Re: Getting started with FPGAs
« Reply #1 on: October 11, 2012, 05:45:16 am »
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.
 

Offline Codemonkey

  • Regular Contributor
  • *
  • Posts: 223
  • Country: gb
Re: Getting started with FPGAs
« Reply #2 on: October 11, 2012, 07:43:33 am »
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  :)
 

Offline ptricks

  • Frequent Contributor
  • **
  • Posts: 670
  • Country: us
Re: Getting started with FPGAs
« Reply #3 on: October 11, 2012, 12:39:37 pm »
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-7300

After 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
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 3548
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Getting started with FPGAs
« Reply #4 on: October 12, 2012, 08:23:21 am »
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=item2c5ac1d40e

Cyclone 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.

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18925
  • Country: nl
    • NCT Developments
Re: Getting started with FPGAs
« Reply #5 on: October 12, 2012, 09:33:02 am »
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.
That 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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline saigai

  • Contributor
  • Posts: 15
Re: Getting started with FPGAs
« Reply #6 on: October 12, 2012, 12:04:37 pm »
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=item2c5ac1d40e

Cyclone 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.

Thumbs 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.
 

Offline jeremy

  • Frequent Contributor
  • **
  • Posts: 934
  • Country: au
Re: Getting started with FPGAs
« Reply #7 on: October 12, 2012, 01:12:18 pm »
That 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.
I 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 seen :P

Doing 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. See http://www.accelize.com/about-us/news.html

My 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.
 

Offline olsenn

  • Frequent Contributor
  • **
  • Posts: 993
Re: Getting started with FPGAs
« Reply #8 on: October 12, 2012, 01:30:02 pm »
Quote
That 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.

The 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.
 

Offline jeremy

  • Frequent Contributor
  • **
  • Posts: 934
  • Country: au
Re: Getting started with FPGAs
« Reply #9 on: October 12, 2012, 01:46:35 pm »
FPGA's do use more power than CPU's

Do 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.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18925
  • Country: nl
    • NCT Developments
Re: Getting started with FPGAs
« Reply #10 on: October 12, 2012, 04:16:05 pm »
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.html
Its 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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 3548
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Getting started with FPGAs
« Reply #11 on: October 12, 2012, 05:57:24 pm »
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.

Offline gxti

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: us
Re: Getting started with FPGAs
« Reply #12 on: October 12, 2012, 06:20:39 pm »
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.
 

Online free_electron

  • Super Contributor
  • ***
  • Posts: 7337
  • Country: us
    • SiliconValleyGarage
Re: Getting started with FPGAs
« Reply #13 on: October 12, 2012, 07:45:12 pm »
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 instruction
load address pointer for first number
copy data to accumulator
load 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 instruction
load address pointer for target address ( hoping you dont need to calculate it )
copy accumulator to address
increment 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.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18925
  • Country: nl
    • NCT Developments
Re: Getting started with FPGAs
« Reply #14 on: October 12, 2012, 09:37:53 pm »
You really should look into Cuda instead of FPGA if you need die-hard number crunching:
http://www.nvidia.com/object/cuda_home_new.html
Yesterday'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
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline RCMR

  • Frequent Contributor
  • **
  • Posts: 405
Re: Getting started with FPGAs
« Reply #15 on: October 12, 2012, 10:51:45 pm »
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.

 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18925
  • Country: nl
    • NCT Developments
Re: Getting started with FPGAs
« Reply #16 on: October 12, 2012, 11:32:38 pm »
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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline RCMR

  • Frequent Contributor
  • **
  • Posts: 405
Re: Getting started with FPGAs
« Reply #17 on: October 13, 2012, 02:12:39 am »
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.
 

Online free_electron

  • Super Contributor
  • ***
  • Posts: 7337
  • Country: us
    • SiliconValleyGarage
Re: Getting started with FPGAs
« Reply #18 on: October 13, 2012, 05:33:55 am »
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 ....
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1427
  • Country: dk
Re: Getting started with FPGAs
« Reply #19 on: October 13, 2012, 03:38:37 pm »
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 free
http://en.wikipedia.org/wiki/XCore_XS1-L1

/Bingo
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18925
  • Country: nl
    • NCT Developments
Re: Getting started with FPGAs
« Reply #20 on: October 13, 2012, 03:41:03 pm »
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.
The 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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf