Hacker News new | past | comments | ask | show | jobs | submit login
FPGAs for fun & hacking (fpga4fun.com)
51 points by jacquesm on July 14, 2009 | hide | past | favorite | 21 comments



http://university.eve-team.com/ has a university program by now through which you can access some real high-end hardware, you can try to contact them.

The nice thing with using an emulation system versus a raw FPGA board for learning is the same as debugging software with a source code debugger versus only having access to the disassembly.

In my experience, great hardware designers automagically write Verilog but think schematics.

A classic:

  always @(posedge clk) begin
    q1 <= d;
    q2 <= q1;
  end
Do you visualize the back-to-back flip-flops, and immediately double-check that the code uses non-blocking assignments? If so, you're fine. If the code used blocking assignments, you'd have a major bug.

And finally, most senior designers still get puzzled by one of my favorite quizzes:

what is the functional difference between those pieces of code, that both represent a flip-flop with async set/reset, one expressed in Verilog and one expressed in VHDL:

  always @(posedge clk or negedge rst or posedge set) begin
    if(!rst) q <= 0;
    else if(set) q <= 1;
      else q <= d;
  end

  process begin
  if(not rst) q <= 0;
    else if(set) q <= 1;
      else if(clk'posedge) q <= d;
  end process;


I give up. Something to do with the use of literal ints without width designators?


Assuming the second one is supposed to be VHDL, there are so many syntax errors that I can't figure out what the OP's intent is...


After a think, ignoring the VHDL syntax,I think the Verilog example has edge sensitive set/reset, whereas the VHDL has level sensitive set/reset? I don't write Verilog mind so I'm guessing a bit...


You are correct in the edge sensitive set/reset from a simulation standpoint. If reset is asserted, then set is asserted, then reset is de-asserted, then the flip-flop will remain in reset. It's not truly asynchronous from a simulation standpoint.

This could be fixed by using:

always @(posedge clk or rst or set)

I am guessing the thing that throws a verilog designer off the trail is that "always @(posedge clk or negedge rst)" is commonly used for asynchronous reset in ASICs (if you are using it in FPGA's except for the DCM's and as input to a clk-rst module.... stop), and this works just fine but if you want to do a d flip flop with an asynchronous SR condition, you can't use "negedge" on the rst signal.

However, synthesis will probably treat it asynchronously. Of course this is also bad because there will be a simulation/synthesis mismatch.

At any rate, the question is a bit ambiguous due to the unclear vhdl code.


You found the problem, congratulations.

Both code samples are the recommended way to generate an asynchronous set/reset flip-flop for an ASIC flow (minus my bad memory about details of the VHDL syntax).

For years, Design Compiler has forced ASIC designers to describe level sensitive pins (set or reset) as if they were edge triggered, which is correct in most cases, except the case you outlined.

So those two codes generate the exact same logic after synthesis, but you can have mismatches with simulation. And there is actually nothing you could do about it to fix the Verilog since you need your synthesis tool to understand your intent. The correction you propose is the correct one from a simulation viewpoint, but DC would reject it.

Luckily, the case where you assert both set and reset on a flop to then deassert reset are fairly rare...

I was on the IEEE standardization committee for VHDL synthesis: since then I know why [some] standards don't make sense.


Does anyone here know a good entry-level book on FPGAs and VHDL or Verilog that covers best practices and implementing real world designs? In school I did some work with FPGAs and may have to brush up for an upcoming work project. I have "HDL Chip Design" by Douglas J. Smith from school but I am hoping there is something else out there that has helped people here.


I found this very helpful:

http://users.ece.gatech.edu/~hamblen/book/bookse.htm

There is a third edition written around QuartusII - the current Altera software:

http://users.ece.gatech.edu/~hamblen/book/bookte.htm

I also found "The Designer's Guide to VHDL" (Ashenden) to be very useful for a deeper understanding of VHDL vs. the somewhat cookbook approach of the first book.

Ashenden has also written "The Student's Guide to VHDL" - no idea how good that is.

Some other links:

http://www.opencores.org/ Lots of VHDL and Verilog to examine

http://www.fpgaarcade.com/ Re-creating arcade machines

http://www.xess.com/ Nice development board (lots of good app. notes.) (I'm a satisfied customer)


One book that I've seen recommend is A Verilog HDL Primer, Third Edition by J. Bhasker. Some books focus their attention on coding for simulation without giving synthesis its due. I have been told that this book does not make that mistake.


Steve Kilts' Advanced FPGA Design is good on tradeoffs between time and space - he works through examples where he optimizes for each.

Chandra Thimmannagari's CPU Design has a chapter on Verilog with many instructive short but nontrivial examples, in a novel compact format.


I've heard good things about that book by Douglas Smith but haven't looked at it yet.

Out of several (expensive) books I do have, these are the ones that've been most helpful:

- Verilog HDL Synthesis by Bhasker - FPGA Prototyping by Verilog Examples by Pong P. Chu - Advanced FPGA Design by Kilts - The two "Learning By Example using Verilog" books by Richard Haskell (these are actually written specifically for use with the Digilent Nexys2 board I mentioned in an earlier post)

Many of the others are impractical, academic junk that waste your time with things like gate-level design, Karnaugh maps and the like that are handled by the synthesis tool nowadays. Unless you are writing a synthesis tool you don't need 75% of what's in most HDL textbooks.


Well, thanks for swallowing carriage returns between lines that begin with "-". Maybe an elementary book on C programming would be a better starting point for whoever wrote this forum software.


http://news.ycombinator.com/formatdoc

Blank lines separate paragraphs. Leading hyphens don't do anything. And asking Paul Graham to rewrite a web forum in C is like sending Lance Armstrong to Paris on a unicycle.



Also, does anyone recommend a particular FPGA development board?


I'm still fairly new to FPGA stuff (been doing it for about 3 years but haven't done any big projects yet), but I absolutely love my SP3Dev board: http://www.celeritous.com/estore/index.php?main_page=product...

Had it for about a year and a half, works like a charm. Xilinx also had a kit for $100 (maybe $150) that had a Spartan 2 and a CoolRunner II board, which was great in the early days. I think it's since been superseded by a Spartan 3 kit, but I don't know the pricing.


I've had good results with www.xess.com ($199)

There is also http://www.xilinx.com/products/devkits/HW-SPAR3A-SK-UNI-G.ht... ($189)


I've bought recently a http://www.xilinx.com/products/devkits/HW-SPAR3E-SK-US-G.htm (Xilinx Spartan 3E starter kit).

Those Mac OSX users, what do you use for development? The Xilinx development software seems to work only in Windows and Linux.


There's fairly little choice in FPGA development software. Xilinx is what I've used, and it's easily the among the worst software I've ever encountered. But I've heard that the alternatives are no better. The fact that it works at all is no small accomplishment but it still lacks all elegance, usability, or reliability on the user end.


I've looked at several. fpga4fun.com's boards are actually among the worst deals, because they're (a) not exhaustively documented; and (b) expensive as heck.

The absolute best I've seen so far is the Nexys2 from Digilent. It's got the same Cypress FX2 high-speed USB chip and Spartan3E FPGA as the Xylo from fpga4fun.com/knjn.com but it costs $129 instead of $299, comes with full schematics, and gives you lots of switches, LEDs, and ports to work with too. Not to mention a good-sized external RAM (which I haven't played with yet).

I have an Analog Devices AD7760 eval board attached to my Nexys2's Hirose connector right now, and have had a lot of fun climbing the Verilog and JTAG learning curves with it.


Digilent also sells teaching materials to universities, but it might be possible to get a hold of them otherwise.

I actually know some of the Digilent guys--their cofounder is an adjunct professor at my school and teaches using Digilent boards and curricula. He's probably one of the most busy and productive people I've ever met. As it happens, there's enough crossover between his work as an adjunct professor and his work at Digilent that it's more of a benefit to him as a cofounder than a distraction. It also puts him in a convenient position to be his own first customer, though he has hundreds of universities using his stuff too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: