EEVblog #496 - What Is An FPGA?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to fundamentals Friday today we're going to take a look at the FPGA or field programmable gate array that's what it stands for what is an FPGA well an FPGA is a programmable device a programmable chip which is pretty much the closest thing you can get to actually designing your own chip completely from scratch just like an ASIC you may have heard of or something like that that's what an FPGA allows you to do it allows you to design and implement any virtually any digital function you can possibly imagine all within the one universal chip they're pretty done flexible now the big difference between an FPGA and virtually every other chip you can buy on the market is that the FPGA doesn't do anything it has no intended function when you actually buy it I don't like say a microcontroller it's actually a computer building it's all the logic is all hardwired in there and it can actually do something useful all it needs as a program or an FPGA can't even do that you apply power of this thing and it's just going to sit there it's not going to do anything at all they are completely stupid but they make up for that with their extreme flexibility allowing you to design anything you can imagine in the digital domain they can't do analog digital only but in the digital domain you can program it into one of these FPGA chips if you want to turn an FPGA into an AVR microcontroller or a pic microcontroller you can do that if you want to turn it into a digital signal processor you can do that if you want to turn it into a thousand LED custom driver you can do that they're incredibly flexible limited only by your imagination so how do they do this well they do it by containing thousands tens of thousands hundreds of thousands or even more of individual logic elements let's call them Co bees or configurable a logic blocks they go into various names depending on the vendor and we won't go into that we'll call them CL B's configurable logic blocks that can implement pretty much any basic function you can imagine and because there's so many of them thousands tens of thousands hundreds of thousands you can configure them in any way you like to perform any complex or even simple digital function and those configurable logic blocks sit inside these red lines here this matrix of interconnecting lines they're basically exactly that they're just metal interconnects inside the chip that you can join up in any configuration possible so you might want to join this logic block over to this one over to this one and then to these i/o pins all over the place to implement whatever function you program into this thing so they're often called like a sea of gates for example because they're just all these configurable gates sitting on a sea of interconnecting logic and well that's a bit of an old term because these are these CLB is configurable logic blocks or logic elements are more than just individual gates they're pretty smart in their own right now in theory the most powerful and flexible FPGA or configurable logic chip you can imagine would contain millions of NAND gates and you know an infinite network of all these interconnect lines to join them all together because if you remember your basic digital logic theory and NAND gate you can if you have enough knee engage you can create anything you can create a microcontroller you can create a hundred microcontrollers or any RDSP or any function you like to do anything just from NAND gates unfortunately well those chips do actually exist they're called gate arrays and well they're not that much used anymore a similar sort of concept these FPGA or field programmable gate arrays with their more complex configurable logic blocks have taken over from that because in theory um yeah you could have all these configurable NAND gates in there but you just simply run out of room it's too complex you can't have an infinite network of all these tracers crossing everywhere plus an infinite number of gates in there and have them all configurable in every orientation you would quickly run into a routing just like routing a PCB you'd run into a routing nightmare within the FPGA and in the end of just choke on itself and you wouldn't be able to do anything so and if a modern FPGA is basically an optimization of more complex configurable logic blocks that do contain individual gates and elements but they also contain flip-flops and look-up tables and things like that I'm walking you know more complex block in there then surrounded by a limited number of interconnecting traces like this and then it's a balance a trade-off between you know what you can confer what logic function you can perform in one configurable logic block to all your routing resources to be able to get all your signals out to your i/o pins around here from your internal logic elements and we'll take an extremely brief look at what's inside one of these are configurable logic blocks here this is very generic in practice they are much more complicated than this but generally what you're going to get inside an FPGA is a lookup table a basic lookup table might be say four inputs like this you can get larger ones depending on the FPGA types and then we've got all the configuration fuses in there as well of course you could actually program that to perform a particular function so they're basically got gates in there and I won't go into lookup table details but then you typically have one or more flip-flops in here as well and you can use those flip-flops in various ways and they'll be connected to dedicated clock lines or you can or it can come from the fabric and there's more switching stuff in here in the reset line for the flip-flop and the Q and not Q outputs they can you can select which output you actually want to go out from the configurable logic block so you basically got a bunch of flexible imports a bunch of logic gates and some you know flip-flop latching stuff you can do latched logic within that clocked logic as well and then you basically got some outputs as well and if you've got thousands or tens of thousands of these things can become incredibly powerful and flexible now the other thing I've drawn inside here are these IO blocks around the outside of the chip that actually connect to the individual pins on the chip and these are fairly complicated little blocks in the of logic in their own right they're not just a buffer that goes out to the pin but they can perform it can be programmed to perform all sorts of functions our tri-state input they can be inputs just like a microcontroller you can program them to be inputs or outputs you can tri-state them you could have a you can turn them into differential pair drivers so not just single ended differential pairs you can have different load voltage logic standards as well on the various pins they can contain our flip-flops and latches in them for driving DDR memory and all sorts of complicated things like that contain within these io blocks so they can also be connected to the internal matrix as well so you've got lots of these powerful little logic elements in here that you can combine to do any function you want combined with pretty powerful IO as well and that all adds up to a very powerful and flexible chip they can do as I said anything you can imagine now when I said before that when you power up an FPGA it's completely stupid it doesn't know what to do I wasn't kidding because an FPGA are typically volatile devices what that means is that they have no ability to store their internal configuration or how you've programmed the device what you've programmed it to do they've got no ability to store that so as soon as you remove the power it forgets that FPGA just goes back to being factory fresh it doesn't know what to do is just a huge sea of these gates sitting there and programmed but the FPGA has built into it a little actually quite a complex our configuration logic here which then hooks which then you have to hook up to an external configuration flash memory so for any FPGA to be useful you can't just have the FPGA you've got it's mandatory to have an external configuration flash memory which is basically just a regular you know a four or eight Meg bit flash serial flash memory device they can be parallel as well except that it contains all of the information for all of these little fuses inside here which logic block connects to which and how and the fuses inside these configurable logic blocks here the fuses inside these IO blocks to tell what these i/o blocks down here and you know hundreds of other fuses for various functions which we'll talk about and that's why you need a quite a large even for a sort of you know a cheap medium you know smallish FPGA you really needed quite a large flash memory because there's a lot of fuses inside here which have to be programmed and when I say fuses they're not fuses like flash fuses they don't permanently store it they're actually just you know transistors or our latches that just switch on and store the function for that particular bit but you can think of them as our fuses except when you turn off the power boom they go on the FPGA forgets absolutely everything so when you turn on an FPGA it doesn't know what to do but this configuration logic up here when you first switch it on automatically know as well okay powers just switched on I need to load the data from the external flash memory here and program in all the fuses and that can take you know seconds sometimes to do so FPGAs are not instant on they do take some time to boot up and to configure or their logic so what are some of the advantages of FPGAs why would you want to use them well let's take a look at a few you can as I said you can do anything in the digital domain you could possibly imagine you can turn it into a micro control you can turn into say cray supercomputer you can drive a custom controller to drive a thousand LED matrix cube or anything like that you can do anything really anything it's amazing they're also super fast and uh some of the even the basic FPGAs have IO blocks and serial functionality which we'll get into they can go into the Giga you know the gig bits per second region they have our transceivers building that can actually do you know gig bits per second serial our decode and stuff like that incredibly incredibly quick now if you compare that to say a microcontroller for example even a really fast modern processor like use like the arm used on the Raspberry Pi you might be able to toggle the i/o pin at you know one hundred megahertz or something like that but really you know you'll be a bottleneck by the process you can't do any serious processing you know on a hundred megahertz input signal for example well as with FPGAs that's not a problem at all because you can dedicate the logic in here to just do that and we'll that'll come down into this massively parallel thing an advantage at the moment to do a specific function on just an i/o signal that you want so if you got an input signal coming in and you want to do some really fast processing of it in effectively real time and shoot it out another pin where you can dedicate a part of the FPGA to do that incredibly flexible from a speed point of view now there as their name suggests their field programmable their FPGAs how does that differ from a microcontroller which you can reprogram you can reflash in the field well this is different in that it's not just a fixed processor in fact it doesn't contain a processor at all unless your program one in there but so you can change anything in your design at all so let's say that you design your custom product and you use to micro control up for example and then you put it out in the field and you wait I know I've got to change something and I can't I have enough power or processing capability left in my processor to do it or it's not flexible enough to do this all that well with an FPGA if you ran your processor inside the FPGA and you had enough resources left over when your products gone out in the field you can go ah look I needed you know I fir filter or something like that to be implemented between this pin and this pin well you can just reconfigure it anything you want if you've got enough space left in there no worries you put a third filter in there or a PID you can tweak PID controllers or do whatever you can possibly imagine so they're more powerful in that respect than a field programmable micro controller because they're not just a processor they're not just a microcontroller they could do anything as we said anything at all and we talked about the massively parallel thing and this is one of the huge advantages of FPGA is in the main one of the main reasons why you would choose them over a microcontroller for certain projects because if you take your basic microcontroller it's effectively a bottleneck everything has to run through that processor call in sequence you know you got your individual line of code you execute each instruction code one by one and you have to rely on doing that fast enough even if you've got a real-time operating system it's not really real time you can't process these ten pins at the exact instant that you're processing these ten pins up here and toggling these outputs here it doesn't happen but with FPGAs you can because this all this logic block or all these logic blocks in here are completely configurable completely separate so you can be processing these pins down here and outputting something over here at the exact instant that you're processing these pins up here and outputted something else over here and you can do that if you've got enough i/o pins and enough logic blocks you can do that hundreds and hundreds of times so you can be processing hundreds of things in parallel take for example an analog to digital converter if you had 50 channels of a lot of ADC data coming in you know you had an external ADC chip of course because these are only digital they can't do anything in the analog domain well if you've got all this data coming from 50 analog to digital converters 50 channels and you wanted to process that or once well you can yet have a 50 channel sample and hold and then you processor to do it all well you know there's a real bottleneck speed-walk bottleneck there but in an FPGA you can have each one a particular bunch of logic blocks dedicated to that one channel and then you can just duplicate that 50 times or a hundred times or 500 times with inside your FPGA because remember we've got hundreds sometimes hundreds of thousands of these logic blocks to play with fantastic so that is the massively parallel advantage of FPGA is if you want to do a whole bunch of processing all at once in parallel then FPGA is of what you want to use over a micro controller and that brings us to one of the final advantage is the high i/o camp FPGAs specialize in hi I can't applications in fact the development of FPGA is really just pushed towards that high pin count capability and it's actually quite difficult to get a decent FPGA and by decent when you talk about a decent FPGA you're talking about how many logic blocks effectively it's got it's hard to get a decent FPGA with a small number of i/o pins you know it's not we can get an Esso 16 package or even oh you know a 44 pin quad flat-pack they're actually quite hard to get that's why most FPGAs are designed for high i/o applications so they contain hundreds of pins up to you know a thousand plus pins and because they've got so many pins they often come in a real pain in the arse to use packages like BGA so if you want to drive for example some huge LED matrix you know you had a you know a hundred leads by a hundred LED matrix or something like that yeah you can do it with a microcontroller and a whole bunch of external seven for hc5 9/5 latches or something to latch the individual row and columns and all that sort of thing that's sort of the traditional way to do it but then as I said you come into that real speed bottleneck the process has to drive all that in critical incredibly quickly just to get you know twenty five times per second updating on your lead matrix display well FPGAs can do all of that in parallel because they've got hundreds of i/o pins so you can choose one with hundreds of i/o pins you can do it all at once BAM straight in there so that's the huge advantage over microcontrollers so these FPGA is sound fantastic right why doesn't everyone use them they're so fantastic in programmer to do absolutely anything why are they not in every single product and every hobbyist toolkit well there's lots of disadvantages and I probably haven't even listed them all let's go through them these FPGAs are expensive why are they expensive well they're expensive relative to another chip which does that could do potentially a similar function I mean you can get FPGA is as little you know as a dollar or two but they don't contain many configurable logic blocks are they quite limited in what you can actually do with the things and so they're expensive in a relative sense for example if you wanted to duplicate an AVR microcontroller in an FPGA there is no way that you can get one big enough to put an AVR microcontroller in there that's going to be cheaper than just buying the AVR microcontroller on its own so if you're just looking to duplicate the functionality of a pre-existing dedicated hardwired chip you're wasting your time so that's why they are quite expensive in FPGAs they're really high-end ones you can pay many many thousands of dollars for just the one chip FPGAs are some of the most incredibly complex and bleeding-edge process technology chips on the market why because they have to contain millet sometimes millions of these logic elements and routing pars and and in configuration users and everything else just to give you that flexibility so they are very but so they are relatively expensive and because they're also contained all this flexibility it means that they're not optimized for power consumption so if you're after an ultra-low power designed to do something there's no way an FPGA or an equivalent FPGA is going to be the same as a lower power or nearly as lower power as a dedicated chip to do the function is just not possible due to the process technology and all the complexity so they're quite high power devices and they can chew a lot of power when they start up a surge current when they start up and program all these fuses for example so just got to be very careful you wouldn't use them in a low-power design their volatile as I said they completely forget everything these FPGA is a brain dead you have to have an external configuration flash memory in order to reprogram the FPGA every time you apply power and that can lead to boot time issues I mean some systems you want just to work instantly you can't just do that with FPGAs although there are some that do have configuration flash we'll talk about that maybe and as I said they are high pin count if you're looking for a hobbyist friendly or a really production friendly device and FPGA is not the best way to go about it as I said you can get low low pin count devices there are a few out there but they're generally not in easy to use packages most of them these days come in BGA packages which are not easy to use so often you have to take that into account and the other thing is because they're optimized for high pin count generally if you want a lot of configurable logic locks in here a lot of logic density then you generally have to go for a higher pin count device I sort of go hand in hand high logic density high pin count why it's annoying the manufacturers just do it because that's where they think the market is or the markets being driven by those sort of applications so it's not like you can get a million logic element device in a nice friendly you know tea QFP you know 44 pin package something is just not going to happen so they are and the other thing is they are complicated they are incredibly complicated go down go to the manufacturers datasheet Xilinx or our terror or one of the others and download a datasheet for an FPGA and you can spend the rest of your life reading that thing it's not just one datasheet then they have all these different data sheets and applications for how these configurable logic blocks work how the i/o works how the clock systems work how the serial interfaces work and how the DSP cause work in the things and and how to program them the best way best and quickest way and safest secure way to program them when they boot up and ah they got you know a dozens and dozens of data sheets and application notes for just the one device they are believe me when I say it the most incredibly complex chips on the market take my word for it or don't don't read it for yourself um and because they are so complicated they contain many traps for young players there's lots of things that can go wrong in this thing because you are effectively designing the chip yourself you have to take all the timing into account or the routing into account and the complexity of the device and how you configure the i/o blocks and I haven't even scratched the surface of the complexity of this thing this is incredibly simplistic what we've looked at here so far so they are many traps in terms of not only just configuring the things choosing the right clock pins for example because some in addition to these i/o blocks here they'll have dedicated clock pins which have faster routing paths through here and depending on if you want a really fast design you have to know how to use configure your logic in the correct correct part of the FPGA it can make a difference where you physically place all your stuff in the FPGA and the tools can sort of take care of some of that or a lot of that for you but you really have to be aware and there are a lot of traps just in configuring and choosing an FPGA and that's the thing the tools are incredibly complex I'm going download the tools for these FPGAs and it's like many gigabytes of downloads and it there are so many tools which come with these FPGAs they are incredibly complex yes you can get nice development kits which you know have example programs and you just install all the tools and even though there are tens of millions of lines of code in there at all just yet you can get these simple development kits to just work and you can get a simple application running in your FPGA and they look easy but from that aspect when you first use them but when you want to do your own professional design from scratch boy you can spend a year just choosing and selecting and programming and configuring and optimizing a you know a moderately complex FPGA design the tools are necessarily complex because these devices themselves are incredibly complex and as I said they're hard to choose and compare goto as I just to of the manufacturers the two top ones who are in like eighty percent of the market Xilinx and Altera and try and figure out and compare two different devices they'll call these logic blocks different things confederal configurable logic blocks they'll call on logic one manufacturer call and logic elements someone will call on something else they can contain different number look-up tables in them they might use terms like system gates and all sorts of stuff which confuse the issue and they don't have the industry does not have common terminology for the architecture inside these FPGAs and manufacturers all have their own architecture terminology the architecture is entirely different the terminology is entirely different between manufacturers and just being able to choose between you know you take Fred you take advantage of the fact that it's simple to chain compare microcontrollers for example between pic and app mill right yeah one contains you know X number of ABCs of ten bits who contains to you arts it contains X timers and you know they're all fairly generically are similar but PGA's totally different so good luck trying to choose and compare not only between manufacturers but choosing the correct size device for your project because when you start your project you might have an idea of what you want to do and you go ok I need an FPGA because of some of the advantage is we talked about but then you find that well like how many logic elements do I need because the device with you know 128 K logic elements might cost you know twice as much as one with 50000 logic elements or something like that how many do you need you don't know until you're actually design your code and then running and then compile it or synthesize it and try and get an estimate of how many logic elements you're going to use so sometimes you have to actually do your design first and then choose your design and then choose your chip last when you know what you know how many logic elements you're going to need and things like that maybe you use the power estimating program in the tools they contain you don't know how much this power this FPGA is going to draw don't bother going into the datasheet and going or how much current does this FPGA draw it draws nothing when you've got nothing in there or you know sort of you know just a quiescent current but when you're running it depends on how much logic you're running how many i/o blocks how fast how they're configured all sorts of stuff it's completely dynamic so the tools contain power estimating programs and so it's just it's amazingly complex these devices so you don't generally want to use FPGAs unless you're a really experienced them or B you absolutely need them for what some of the advantages we talked about the massively parallel nature of a project for example the really fast i/o processing or up something like that now here's something that we haven't talked about yet and it requires separate videos in fact everything I've talked about here and a whole lot more I could do a one or two hour video on each and every aspect of these FPGAs and these HDLs or hardware definition languages are no different so these are generally how most people program if PGA's these days they don't use the schematic capture anymore even though you can do that if you really want to these hardware definition languages the two major ones of VHDL and Verilog you may have heard of around the traps now I may get hauled over the coals for this one but I generally they are not easy and they're not intuitive like you're more sequential programming languages like C and basic that you're familiar with on your PC or your micro controller where you get the processor which execute each instruction line by line by line by line FPGAs don't contain a processor unless you pull out in there they just a sea of logic gates so using code to define things like multiplexers encounters and and gates and flip-flops and all that sort of thing is not really that intuitive to most people who've learned electronics or digital electronics the traditional way with gates and flip flops and muxes it's it's a real different world where you have to think that everything is executing in parallel you have to think about clock domains and all sorts of complicated stuff so HDL yeah you might be able to load your example program when you get your hundred dollar FPGA demo board but then trying to really understand it and that comes back to the traps as well there's not only traps and configure in the FPGA is but there's also many traps in how well you write or how well you can write your Hardware definition language in VHDL or Verilog there's lots of traps there that can cause all sorts of problems inside your FPGA race conditions and all sorts of stuff that we won't go into but there's an I've probably left off some other disadvantage but there's a lot of disadvantages there for agas and that's why they're not hugely popular except for the more niche applications where the advantages are really so compelling that you want to use an FPGA now I've been going on for like 30 minutes on just what n FPGA is and quite frankly I haven't even scratched the surface big is the simplistic architecture I've sort of explained here is not how modern FPGAs are well they are in a basic operational sense which is good introduction of how they actually work but you know in practice when you want to implement an FPGA they're incredibly more much more complex than this they haven't been sort of this simplistic with just what the CEO be and just the rounding paths and just the i/o block and that's pretty much it they haven't been that way since the dawn of FPGAs many decades ago all of your modern FPGA is contain a whole slew of functionality in these things no pun intended because there's things like a slew rate control in the i/o blocks memory is a big thing in FPGA s these days almost all decent FPGAs will have various forms of memory in them in terms of our distributed memory which you can utilize in different ways depending on your architecture that your internal architecture you're trying to design or they can have dedicated RAM blocks and you can implement dual port memory you can do all sorts of stuff because a lot of processing happens inside modern FPGA that's what a lot of people use them for so they'll even contain these days the manufacturers realized well people were all implementing what's called these soft processor cores which means you might get like an i/o score which is or the manufacturers have their own types of you know 8 16 32 bit or more processor cores you can just drop them in there and they're a soft core soft because they can you could just configure it sort of anywhere within the FPGA you want as well as a lot of other functionality but a lot of manufacturers are going well a lot of people use these cores and they use other functions within the FPGA basic stuff like might be an Ethernet controller for example so they go okay well let's put hard logic inside these FPGAs as well so they'll embed like an ARM processor and that's actually not in the FPGA fabric it's not a soft function it's a hard function so it's you know they might have a little ARM processor over here or a couple of them and they might have you know ethernet transceivers or big sur des serial controllers and all sorts of things implemented as all this hard logic around what traditionally was a soft FPGA fabric the advantage of having that hard processor and hard logic in there is that if you know you want to process it in this thing we are better off going for a hard processor with the FPGA fabric around it because it's going to be more optimized it's lower power you don't have to worry about designing that aspect of the processor in you don't have to recompile the processor each time you want to you know recompile the design for your FPGA it's all hard in there just like a microcontroller or microprocessor and you know it's guaranteed to work because the disadvantage of these FPGA is nothing is guaranteed to work because you've designed it all you've written all the code you've dropped in all the blocks even if you might pull these are you know modules off the internet how do you know if they work how do you know how the software is routed it within here because that's the other thing with FPGAs routing is a huge part of this thing and actually fit in all of your design and optimizing that's why these tools are incredibly complex and it can actually take sometimes you know a long to like days to actually really fit and compile a real huge design and optimize it inside one of these FPGAs and get the correct timing and routing cars and that's the other thing clocks these things will have dedicated clock pins and dedicated clock routing paths I think I said before dedicate take what clock quadrants so you can't just start utilize this logic over here with a clock that you're using on this pin over this side of the FPGA and they'll come with DSP blocks that's another very common thing you'll see that are this FPGA contains a multipliers accumulators and Max and DSP cores or scattered around a typical FPGA these days might have you know 50 or 100 DSP little cores or scattered around the place and on top of all that complex are clock routing structure inside modern FPGA they'll container digital clock management systems they go under various names at PLL's and all sorts of things to multiply the external clocks that's why you might typically find one of these FPGA is working like the external crystal is only 20 megahertz for example but the process but all the logic inside might be around a couple of hundred megahertz because they mark those parallels and digital clock managers you can multiply the external clocks and you can do phase shifting and you can do very complicated timing and clocking arrangements with inside your fpga architecture but that opens up a whole can of worms in terms of clock timing for your entire system and you can really goof that up if you don't know what you're doing and I haven't even started on the complexity and the limitations as well of designing I can compile in your designs into an FPGA but this is the basic architecture of them and well you don't be afraid because you can't get simple development kits start up using the FPGA so are an important part of the electronics design toolkit so they are definitely worth learning so don't be afraid because there are some powerful advantages to FPGAs so I recommend you actually go to the manufacturers websites our terrors I links for starters are for example and check out all the range of FPGAs they've got available there's basically one available for every niche applications ones are designed for really fast serial processing others are designed for massive i/o others are designed for DSP type work and others a design for a whole combination of those things incredibly complex devices and well I haven't even scratched the surface really I could do another hundred videos on FPGA will I I don't know geez catch you next time you you
Info
Channel: EEVblog
Views: 622,518
Rating: 4.9465647 out of 5
Keywords: fpga, Field-programmable Gate Array (Consumer Product), fpga tutorial, how to, cpld, gate array, microcontroller, comparison, clb, configurable logic block, logic element, sea of gates, io block, what is an fpga, hdl, advantage, disadvantage, field programmnable gate array, configuration prom, configuration flash, xilinx, altera, actel, lattice, avr, atmel, pic, microchip
Id: gUsHwi4M4xE
Channel Id: undefined
Length: 37min 44sec (2264 seconds)
Published: Fri Jul 19 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.