views:

3202

answers:

19

In next weeks probably I will have some little FPGA to play with. I have a programmer background (C, C++, Java mostly) and some (very) limited experience in electronics.

What are the best tools to know if you want to develop on FPGAs?

What are the best languages to study? (what HW description languages?)

Have you some examples of little "toy projects" that can be interesting, easy, and "eye-opener"?

Thanks in advance.

Edit:

More details: if I understood correctly, the device I will be playing on will have an ARM core (no idea which one) and a 300k gates FPGA

I'm looking specifically at some Linux free sw / open source tools...

+8  A: 

Verilog and VHDL are the two big Hardware description languages I know of.

Can't remember what basic projects I did in my classes, but I do remember my favorite project of all of college, building a CPU in VHDL, and then implementing a basic program in binary.

Nothing like having to debug hardware and software at the same time :). Might not be the most applicable toy project, but I personally had a blast doing it just for the paradigm shift. (Like exactly what fundamental operations do you need to implement a software multiple using a looping mechanism)

Guvante
Most people will need to walk before they run. CPU designs should be an end goal for learning.
NoMoreZealots
+1  A: 

edit: Didn't read ALL of your post. Sorry. Do you know which FPGAs you'll have do play with?

edit: This is what I posted BEFORE I carefully read the original question

I would suggest messing around with a PIC microcontroller. You can program them in C/Assembly and require basic knowledge of circuits. Great for hobby projects. You might not want to jump right into VHDL/Verilog until you're got a little bit of experience.

basszero
I've added some little detail. For the PICs, there are some interesting projects. I'll have a look
Myrrdyn
VHDL and verilog are EASIER than Assembly! An old Assembly hack would have a ball in FPGA design. All the same math techniques but cleaner syntax, and even MORE CONTROL. (And assembly coders are all about control and speed.)
NoMoreZealots
+4  A: 

When it comes to Hardware Description Languages, Verilog and VHDL are your choices.
Verilog is C like in its syntax.
VHDL is more like pascal. Whichever one you choose depends on your tastes.

Both Xilinx and Altera provide free tool chains that will allow you to build up programs for everything but their top of the line chips.

One of the big thing you will have to wrap your head around is that in an FPGA, since you are talking to hardware, things don't happen necessarily in discrete time increment.

For example, a simple assignment 'out <= A + B' will change continuously as the A and B signals change.

Also, you can have multiple things going at once, unlike most computers where you have the illusion of multiple things running, in an FPGA, they do run at the same time.

Benoit
Actually I think VHDL is patterned after ADA. (Which is very simalar to pascal.) Statements like 'out <= A + B' are continous, but the best practices type design techniques for FPGAs recommend doing everything synchronously. i.e. on rising edge
NoMoreZealots
+2  A: 

National Instruments Labview is available for a easier learning curve with a graphical language.

Geoffrey Chetwood
I think there isn't a gratis (free as in beer) Linux version of Labview, and my budget currently is dramatically close to "none"...
Myrrdyn
mmmk, just thought Labview should be mentioned. I know it isn't /my/ preferred solution, but certainly viable for some people.
Geoffrey Chetwood
The Labview FPGA page is probably the more relevant link: http://www.ni.com/fpga/
aem
+7  A: 

Check out http://www.fpga4fun.com/ for some interesting projects and tutorials.

Lance Richardson
+5  A: 

Back in college, I've programmed in VHDL. Its syntax is pretty much like Pascal. There are lots of softwares available from Altera and Xilinx (2 big VHDL companies that I can think of now) that allow you to drag and drop elements. The software also auto-generates the VHDL/Verilog code. So that's pretty cool. The software also has a simulation tool to ensure that you have programmed correctly. Flashing the VHDL code that you've written into a chip, now that's the big deal :) All the best!

Nikhil Kashyap
+3  A: 

A really neat open-source FPGA project is MiniMig - an implementation of the Amiga 500/600 in Verilog. There are a few people working on it to improve the reimplementation, or port other FPGA systems (Commodore One cores like the C64, Amstrad CPC, or even FPGA reimplemenations of arcade games) to it.

JeeBee
I keep looking at that sight, really good for stuff for geezers. (Like myself.)
NoMoreZealots
+1  A: 

Differences between VHDL and Verilog:

As mentioned, Verilog has a more C-like syntax whereas VHDL is based on ADA. I think the most important difference is that VHDL allows the programmer to define new data types, while in Verilog you're stuck with the ones built into the language. Programmers tend to prefer VHDL for this reason, while hardware engineers tend to prefer Verilog's simplicty and weak typing. VHDL is strongly typed, while Verilog is weakly typed similar to C.

aneccodeal
+2  A: 

At our school we are working on a very small CPU with a RISC architecture in VHDL which gives me a great insight in how a CPU internally works. It is really mind blowing when you find out that everything will run in parallel.

To create some test programs we also build an open source assembler and a simulator.

We used on of the Xilinx Sparta-3A boards, the Xiling tools, GHDL and GTKWave to test and run the CPU. The Xilinx tools are very good in code analyzing and can show you graphically how it will looks in FPGA. All together it's a good start for learning FPGA programming.

Mark Raddatz
+4  A: 

I'd recommend this board if you're starting out. It's 500k gates and I think it's around $100. If you do experiment with FPGAs though, beware of Xilinx. Xilinx crashes or mysteriously stops working all the time, which can make it very difficult to figure out if you did something wrong or if Xilinx is just being difficult.

devin
I have no experience with Xilinx (or FPGA altogether) but colleagues of mine have, and I never heard any complaints about crashes. Also odd then that you recommend the Nexys2 board, which is built around... a Xilinx FPGA.
stevenvh
@stevenvh: They must not have been using it very much then. :P I've actually found a repeatable process for Xilinx 10.1i that will not only crash the EDK, but completely and irreversibly corrupt your entire project.
Bob Somers
Through more experience since this post, I have found this to be true. If you work in VHDL always you will never have a problem, if you work in schematic mode at all, you will run into MANY problems.
devin
He already has a board in mind.
NoMoreZealots
try looking at the order these posts happened in.
devin
+5  A: 

I'd also recommend the Nexys 2 board from Digilent. Very good first FPGA board. Xilinx's software can be pesky on occasion though, so try to get your hands on the newest version you can.

I would say the #1 thing that trips up programmers moving into hardware description languages is that you need to remember that HDL's describe how a circuit operates, they are not a programming language in the traditional sense. Unless you're inside a sequential block (like a process statement in VHDL) the commands will not run sequentially. They're implemented as hardware, so it'll all run in parallel, at the same time.

A lot of newcomers tend to forget this and end up with tons of bus contention problems because they're treating busses like variables.

Bob Somers
+1  A: 

Start your designs on paper, not just sit down and start "programming." Although you can do "programming" you will run into problems with latches. What you need to wrap your head around is that you are describing hardware, and there are consequences you have to deal with when doing that. Look at the use of state machines, RTL(control/data path partitioning), and ASM chart design. After you describe what you want to do on paper using those design techniques, it should be easy to describe it in VHDL and/or Verilog.

+2  A: 

The easiest way to program FPGAs is using a high-level language, rather than an HDL (hardware description language) like VHDL or Verilog. (Full disclosure: I work for a C-to-FPGA compiler vendor.)

There are a number of commercial compilers that take C or C-like languages as input and generate either VHDL/Verilog or some other hardware representation. The output of these compilers may then be run through synthesis/mapping tools (Xilinx ISE, Altera Quartus II) to create a bitfile, analogous to an executable, for programming the FPGA device.

The book Practical FPGA Programming in C (ISBN: 978-0131543188) covers the basics of FPGA programming, using Impulse C as the design language.

These C-to-FPGA tools are quite expensive from a software developer's perspective, but some of the vendors have educational pricing and/or offer free evaluations (timed or feature-limited). There are free editions of the synthesis tools (Xilinx ISE WebPack and Altera Quartus II Web Edition), which are either time-limited or can only target smaller/older devices.

There are many cheap FPGA boards out there, for example:

Portable, PC-connected boards are also available from some vendors (Pico Computing, Opal Kelly, etc.). These connect to a PC with a USB cable or via a PC Card/ExpressCard slot, but are somewhat more expensive. The advantage is connectivity with the PC--you can more easily do I/O between system memory and FPGA than with the standalone boards listed above.

The interesting thing about FPGAs is their capacity for parallel processing. Certain parallelizable algorithms, running at ~100MHz in the FPGA, have shown performance improvements on the order of 100x over the same code on a 3GHz x86 CPU. So if you want to be impressed by these little low-power chips, implement Multiple Sequence Alignment, backprojection, image/signal filtering (DSP algorithms in general), or Monte Carlo simulation on an FPGA.

rkb
+1  A: 

Learn by example. Install Xilinx or Altera tools and complete a couple of tutorials.

OutputLogic
+3  A: 

Video controllers make good projects to start with.

My first test project controlled a 640x480 VGA monitor, with a mouse pointer that could be moved around with a serial mouse (PS2 & USB mice are harder so save those for when you have more experience.)

Later I added a simple background image (some solid rectangles) and an bit-mapped icon that could be dragged around.

I used one of these, but this can probably be done with most development boards with no hardware modifications.

A project like this will introduce you to quite a few essential concepts, e.g. counters, signed & unsigned binary comparators, multiplexing, shift registers (both SIPO and PISO), finite state machines etc.

Implementing a CPU is fun too but best done when you have a little experience already.

I would stick to Verilog at first as every FPGA manufacturer supports it. Avoid Xilinx's free schematic editor (there are better ones out there but they are expensive and not really necessary.)

Some things are slightly less fun but still worth learning if you are considering a career change:

  • Interfacing to DRAM
  • VHDL (more "bureaucratic" than Verilog, hence most large engineering firms prefer it.)
  • Low-level serial protocols: SPI, I2C etc.
finnw
+2  A: 

I know both Xilinx and Altera have free tools, and most of the cheap HW out there uses one of them. (Digilent has some of lowest price HW you can get, with a decent amount of built in functionality. They are a Xilinx house.) Xilinx tends to have more dev kits avaliable (that's who I use), but there are some really nice Altera kits that have almost a complete PDA type system put together. I've been told they have really nice tools (by nice, I mean better than xilinx). I THINK Actel also has some free tools, but the only place I've seen thier dev boards is Avnet. They have a neat like board based on their Igloo part that has an edge card connector, I thought it would be cool to integrate into a "cartridge" adaptor for an old video game console.

  • Start with simple examples to get a grasp on the design environment. Typical boards have LED and Switch examples to work with. Type them in rather than using prefab files, it improves the learning process.
  • The design workflow is much different than software and you want to get used to using the simulation tools.
  • Get used to the idea of testing with the simulator before you try burning flash. (Simulate to debug, once that works run it on hardware and test.)
  • Modify the examples as things start making sense. Use a hypothesis and test methodology.
  • Start working on TESTBENCH designs. Some simulations can get involved, you NEED to be able to automate your testing to quickly find bugs.
  • Move on to more complex examples and look for algorithms you already understand well from software. For example LZW decompression such as what is used in GIF images is well suited to FPGA designs.
  • Starting laying out designs of your own that integrate the example you've already done. Block it out on paper, then modify your examples and code the interconnects. (Concept reinforcement.)
  • If you choose to do something like a CPU design, start out simple with a small instruction set and write a "Emulator" in a programming language you already know for your CPU FIRST. This is something that you can use to generate expected results. (You'll want to do either a serial link, or a display of some sort before you do something like a CPU, it'll make testing much easier.)
NoMoreZealots
+1  A: 

http://www.kongregate.com/games/krispykrem/kohctpyktop-engineer-of-the-people

This game opened up my horizon to what hardware really is, and i like to think it made me understand vhdl alot better.

Never used verilog, but vhdl is a nightmare if you dont have any guidance, books or software that agrees with you.

Tore
A: 

Similar to rkb above me, I work for a C-to-FPGA compiler vendor, but unlike the tools he listed, ours is open-source and free.

http://roccc.cs.ucr.edu

Adrian Park
A: 

If you were to go for Altera, I would recommend the DE2 series from Terasic. www.Terasic.com. They have a huge number of peripherals and are pretty cheap at the academic prices. Also, its good cuz you get reference designs for all of their peripherals