FPGAs

wolfofone

Gawd
Joined
Aug 15, 2010
Messages
725
So I'm working on an article and the topic of Field Programmable Gate Arrays came up in discussion, and although intrigued I'm having a hard time wrapping my head around exactly what the heck they are :p. From my searching around the internet I've gathered that they are made up of logic blocks and circuitry, and can be reprogrammed. Also, they are apparently extremely fast at certain workloads. But what the heck is a logic block? One thing I'm trying to figure out is how it compares to a CPU. It seems like it is designed and then purpose built to do tasks very fast whereas a CPU is more general purpose but... :confused:

Can anyone help this [H] lurker out and explain to me in terms of someone that can't program a loop in Python (lol) what an FPGA is and what it's made of?

So far I've found this to be interesting reading, but some of it is going over my head :p (PDF) http://research.microsoft.com/pubs/70636/tr-2008-130.pdf

Thanks and stay awesome [H]!

EDIT: aha, this does a bit better job of explaining it heh. http://revision3.com/tbhs/fpga. So it's software/code that's represented using hardware..?
 
Last edited:
Don't compare a CPU with an FPGA; you could build a CPU with an FPGA (and many students do in their CompSci Computer Architecture class)

Electronic circuits (and CPUs) are basically made up of logic gates (built from transistors), and circuits connecting the gates together. With a traditional circuit, you layout all the gates and the circuits, and etch it into the chip in the foundry. With a FPGA (or similar devices), the circuit built at the factory has a lot of gates, and lots of optional routing between the chips, and somehow later set (program) the exact routing. With an FPGA, the routing is usually read from a rom connected to the chip, with other similar devices, you may need to use special equipment to set it up and it may be permanent.

There are benefits and drawbacks of this method. If you use a FPGA (probably built by someone else), you don't need to go through expensive, and time consuming physical layout work (and revisions etc), but the FPGA will be bigger than your equivalent traditional circuit, and the max clock rate will be slower, because the circuits aren't optimized exactly for your case.

In theory, you could have adaptive FPGAs, where the system would automatically reconfigure the chip for your current workload, but I don't think that actually happens anywhere. The closest thing is some high performance computing work where the developers will do some computing with banks of FPGAs. A purpose built circuit (even if implemented with an FPGA) can often do better than a general purpose CPU.

I was taught to configure FPGA circuits using VHDL, which is a descriptive way of saying what the circuit should do (instead of doing a circuit diagram with all the gates and stuff). You can compile VHDL into something for a simulation, or something to put on your FPGA, and I think you can also compile them to traditional circuit layouts to make a traditional IC.
 
Hi toast0, thanks for the response! Its starting to make a bit more sense :).

I'm still murky on the how of the routing through the gates works and how it's able to run and give out an output for the data, though I think I can chalk that up to being a programming "noob" :). So the code.. or the way that it is supposed to manipulate and compute the input data to give an output is actually a physical path programmed into the FPGA instead of a piece of software running on a general purpose processor?

Will do some more searching around and reading as it seems interesting :).
 
The actual FPGA IC is divided into many mostly identical logic blocks. These contain IO muxes, programmable LUTs to implement combinational logic,and optional flop output stages.

Routing wires exist between the logic blocks so their IO can be connected to each other according to the design requirements. The desired routing path is controlled by switching circuitry which can "connect" or "disconnect" wires at the routing intersections.

You can see a diagram (and article) here:
http://www.tutorial-reports.com/computer-science/fpga/routing.php
 
Last edited:
As far as the code is concerned, you may want to look into VHDL and Verilog. Those are the most common languages used to program FPGAs. Using the code, you describe the behavior of your circuit. There are different styles of coding, but all will generate an actual circuit design that could then be transferred to a PCB. If you are really interested, you might want to check out Xilinx and Altera, as they are two of the biggest players in the FPGA market.

Edit: Thought I would post an example.


module mux_4_to_1(S1,S0,D0,D1,D2,D3,Y);
input D0,D1,D2,D3,S1,S0;
output Y;
wire m,n,o,p;

assign m = D0&~S1&~S0;
assign n = D1&~S1&S0;
assign o = D2&S1&~S0;
assign p = D3&S1&S0;
assign Y = m|n|o|p;

endmodule
The above code will generate the circuit shown below.

vzj0p3.jpg
 
Last edited:
So the code.. or the way that it is supposed to manipulate and compute the input data to give an output is actually a physical path programmed into the FPGA instead of a piece of software running on a general purpose processor?
Yes roughly. To be clear, there is no code running on the FPGA - it is an actual circuit operating, just like a CPU or other IC. The difference here is that the hardware is very configurable.

svet-am works (worked?) for Xilinx so he is probably the best resource on these forums.
 
Aha, it's starting to make sense now, thanks for the help :). Been doing a lot of reading and such and am still letting it all sort of sink in so I can't think of any other questions off the top of my head heh. :thumbs up for you guys for the help :cool:
 
Back
Top