views:

291

answers:

6

I'm an old, old, old coder. (How old? I've used paper tape in anger.) I've programmed in a lot of languages and under a lot of paradigms (spaghetti, structured, object-oriented, functional and a smattering of logical).

I'm getting bored.

FPGAs look interesting to me. I have the crazy notion of resurrecting some of the ancient hardware I worked on in the days using FPGAs. I know this can be done because I've seen PDP-10 and PDP-11 implementations in FPGAs. I'd like to do the same for a few machines that are perhaps not as popular as those two, however.

While I am an old, old coder, what I am not is an electronics or computer systems engineer. I'll be learning from scratch if I go down this path. My question, therefore, is two-fold:

  1. How difficult will it be for this old dinosaur to pick up and learn FPGAs to the point that interesting (not necessarily practical -- more from a hobbyist perspective) projects can be made?
  2. What should I start with learning-wise to go down this path? I know where to get FPGA kits, but I haven't found anything like "FPGAs for Complete Dinosaurs" yet anywhere out there.
+2  A: 

I've played around with Alteras DE2 board, which comes with lots of fun components (memory, leds, buttons, and more advanced stuff like video in and out, USB, sound and serial). It has great software for making circuits, either in GUI mode (line drawings between logic gates) or coded as components.

The language is pretty verbose, unlike C or modern languages, so it might fit dinosaurs well. For example, here is an example of how to translate a 4 bit number into active-low 8 bit value for a 7 segment display:

library  ieee;

use  ieee.std_logic_1164.all;

entity SEVENSEGMENT is
   port(
      A:            in  std_logic_vector (3 downto 0);
      dot:          in  std_logic;
      B:            out std_logic_vector (7 downto 0));
end SEVENSEGMENT;

architecture RTL of SEVENSEGMENT is
begin
    B(7) <= not(dot);
    process(A)
        begin
            case A is

            when "0000" =>
                B(6 downto 0) <= "1000000";
            when "1000" =>
                B(6 downto 0) <= "1111001";             
            when "0100" =>
                B(6 downto 0) <= "0100100";
            when "1100" =>
                B(6 downto 0) <= "0110000";
            when "0010" =>
                B(6 downto 0) <= "0011001";
            when "1010" =>
                B(6 downto 0) <= "0010010";
            when "0110" =>
                B(6 downto 0) <= "0000010";
            when "1110" =>
                B(6 downto 0) <= "1111000";
            when "0001" =>
                B(6 downto 0) <= "0000000";
            when "1001" =>
                B(6 downto 0) <= "0011000";
            when "0101" =>
                B(6 downto 0) <= "0001000";
            when "1101" =>
                B(6 downto 0) <= "0000011";
            when "0011" =>
                B(6 downto 0) <= "1000110";
            when"1011" =>
                B(6 downto 0) <= "0100001";
            when "0111" =>
                B(6 downto 0) <= "0000110";
            when "1111" =>
                B(6 downto 0) <= "0001110";
            end case;
    end process;

end RTL;
Marius
You think C is terse? Take a look at dinosaur languages like APL sometime.... ;)
JUST MY correct OPINION
I've added a code sample, so you can see how it works. Oh, and APL, what a language! It makes Perl seem friendly!
Marius
I'm taking a class now, also using the DE2 board. I haven't found it too difficult, and with your experience I think you'll do alright. Note that Marius's code is VHDL, but Quartus (Altera's software) also supports Verilog, which we're using.
Matthew Flaschen
A: 

National Instrument's LabView graphical programming environment can target FPGAs. Their FPGA module and hardware are quite interesting.

LabView can be quite expensive, but they offer free one day hands on seminars where you can actually program FPGAs. I attended one a couple of weeks age and learned a lot as well as having a great time.

JonnyBoats
+11  A: 

You do not actually need to incur any expense to learn how to program FPGAs and see if this is for you or not. You could download and install the free editions of Altera's or Xilinx's software, go through the exercises they have online, modify and enhance the circuits in the exercises, design your own circuits and play with them in the simulator software. You do not actually need to synthesise them into any FPGA to get feedback whether you did it right or wrong.

In fact, even if you get an FPGA development board, you still want to do your circuits first in the simulator because there is a chance that you can damage the hardware with untested designs.

There are also open source projects, the most well known ones are GHDL and Icarus.

And there are quite a number of online tutorials around, too. So you won't need to spend money on books while you are making your first steps either. Here are just a few ...

for VHDL

for Verilog

A good resource site is FPGA4Fun

If you need person to person assistance there is the FPGA channel at Freenode

  • irc://irc.freenode.net/#fpga

In any event, I am sure if you make use of any of these resources and play around with it some, you should be able to find out by yourself whether this is something that suits you and whether you want to spend any money on it.

trijezdci
Wow! That was an impressively long, detailed and resource-rich answer! Thanks.
JUST MY correct OPINION
+4  A: 

Others have recommended VHDL and Verilog as languages. I'd like to add some insight, being an embedded programmer that does C++, Verilog, and hardware design.

Describing Verilog and VHDL to a software programmer, especially one with a long track record, I generally tell them that Verilog's syntax reminds me of C and VHDL's reminds me of Pascal. Verilog, like C, is terse and to the point, but it also lets you shoot yourself in the foot incredibly well. VHDL makes you spell out everydangthing.

Regarding Verilog, there are three versions you'll encounter: Verilog 1995, Verilog 2001, and SystemVerilog (2005, IIRC). I recommend SystemVerilog because it adds a lot of stuff for logic synthesis folks like me.

I hear you now... "Logic synthesis? As opposed to what?" Welcome to the dark side of firmware, my friend: both VHDL and Verilog were originally designed to be simulation languages. In other words, they are intended to build models, so their focus is on describing the effects that inputs (and their associated events) have on outputs. Then one day, people had the bright idea that they should be able to "compile" their simulations into firmware. Hilarity ensued.

So, in your code, you don't say, "make me a D flip flop, use CLK as its clock, D as its input, and Q as its output." You say, "on the rising edge of CLK, D is copied into Q," and the synthesizer says, "oh, you want a flip flop!" There is no end of pain when, due to some incomplete case in your code, the synthesizer implies things (like latches) you don't want there.

For example, a D flip-flop in SystemVerilog looks like:

reg Q;
always_ff @(posedge RESET, posedge CLK) begin
    if(RESET)
        Q <= '0;
    else if(CLK_ENA)
        Q <= D;
end

(No, StackOverflow can't syntax-highlight Verilog. Oh well.)

always_ff means that the code in this block should be implemented with flip flops, not asynchronous logic or latches; this helps moot the "inferred the wrong logic" bug I mentioned above, and was added by SystemVerilog. posedge means rising edge (there's also negedge), @(event1, event2, ...) means that the block executes if any of the listed events occur.

'0 expands to enough 0 bits to fill whatever it is being put into (1 bit in this case), and is another SystemVerilog addition. (If you wanted to say "one bit only", then you'd write 1'b0, where 1 is the number of bits, b means binary (d and h work, too; forgot if o is in there), and 0 is the value. Be careful with sign-extension and truncation if the bit widths don't match.)

<= means an assignment that takes effect at the end of the block, and is the only kind of assignment you should use in an always_ff block. (Conversely, = means the assignment should take effect immediately, before evaluating the effect of the next statement, and works best in asynchronous, combinational logic, which uses always_comb.) What this means in practice is that if you want to, say, shift a bit through a series of registers, on the same clock edge, you can actually assign them to each other:

reg [3:1] Q;
always_ff @(posedge CLK) begin
    Q[1] <= D;
    Q[2] <= Q[1];
    Q[3] <= Q[2];
end

Expand this from one bit per step to several, and you've got a rudimentary pipeline.

Programming-by-inference and the fact that, unlike software, firmware code executes simultaneously and not sequentially, are the two big things that programmers have to get their head around when writing firmware.

I have yet to find a good book on synthesis for FPGAs with SystemVerilog. All the books I've found focus very heavily on the simulation side, since they're generally aimed at people who write Verilog for IC synthesis, i.e. microprocessor design. (Can't blame them, it's where the money's at.) There was one (Xilinx Design Series something) that was somewhat decent, but it's old and has gotten long in the tooth, and says nothing of SystemVerilog.

Welcome to the jungle. Watch your step! ^_^

Mike D.
+1  A: 

You've already got good, detailed answers, but I just thought I'd throw this book in for you:

The Design Warrior's Guide to FPGAs: Devices, Tools and Flows (Clive Maxfield)

It's written in a "chatty" style and has lots of history and asides, so if you're after a formal textbook, it's not for you. As well as the guts of FPGAs, it also cover some of the "real-world" electronics hassles that can come up.

Martin Thompson
I will look it up, thanks. And no, I'm not really big on formal book styles.
JUST MY correct OPINION
I really wouldn't recommend that book. It's good for a marketing teams who need to know buzz words. It's hard to learn anything useful or practical.
name
A: 

Hi,

Have a look on that book. It is very practical. Our students learn themselves from it and they really like it. We couldn't find anything better for beginners. I would recommend buying a starter kit since it's fun when you see how it's working.

If you are searching just something for fun, have a look on Altiums Designer. You can do much more there, from designing the PCB till Embedded systems on FPGA.

name
Thanks for the book reference. Another one for me to track down. :)
JUST MY correct OPINION
name