{"id":8500,"date":"2015-07-27T09:15:35","date_gmt":"2015-07-27T16:15:35","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=8500"},"modified":"2024-12-28T11:34:33","modified_gmt":"2024-12-28T19:34:33","slug":"fpgas-and-microcontrollers","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/fpgas-and-microcontrollers\/","title":{"rendered":"FPGA vs Microcontroller: When to Use Each?"},"content":{"rendered":"<p>In my first attempt\u00a0at writing on this\u00a0topic, I was wrestling with how to begin. I originally had it phrased as &#8220;FPGA vs. Microcontroller&#8221;, but the more I thought about it, the more I realized that the\u00a0title was an issue, as it seemed to imply that one was better than the other. And while there are circumstances where one has an advantage, they really are more just different rather than one being &#8220;better&#8221;. So with that, I&#8217;ll be presenting to you some information about FPGAs and microcontrollers, their similarities, differences, and\u00a0maybe a hypothetical or two.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Nexys4DDR.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-8501 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Nexys4DDR-600x561.png\" alt=\"Nexys4DDR\" width=\"545\" height=\"510\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Nexys4DDR.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Nexys4DDR-225x210.png 225w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/a><\/p>\n<p>A field programmable gate array (FPGA) is an integrated circuit (IC) that is built with a large number of logical processing resources, or logic blocks. These logic blocks consist of digital logic components such as multiplexers, flip-flops, lookup tables, and adders. These components are not unique to FPGAs by any means, as they are some of the basic pieces required for an IC to take input and process it into some meaningful output. What makes a FPGA unique is that the logic blocks within it are built with interconnections that can be reconfigured by the user using a hardware description language (HDL), allowing for the FPGA to take on variable functionality.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/chipKIT_WF32.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-8502 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/chipKIT_WF32-600x474.png\" alt=\"chipKIT_WF32\" width=\"543\" height=\"429\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/chipKIT_WF32.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/chipKIT_WF32-225x178.png 225w\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>A microcontroller is an IC that is essentially a tiny computer. It contains a dedicated processor core, a small amount of memory, and a specific number of I\/O ports and functionality. All of this functionality on the chip is made up of the same basic components you will find in the fabric of a FPGA (multiplexers, adders, flip-flops, etc.), however the interconnections between all of the elements in a microcontroller are fixed and cannot be reconfigured. The user can use one of a variety of software development tools for microcontrollers (provided they are compatible with the chip) to upload code to it which, similar to when you install something onto your computer, tells the microcontroller what to do.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1.png\"><img loading=\"lazy\" decoding=\"async\" class=\" aligncenter wp-image-8508 size-medium\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1-600x398.png\" alt=\"Diagram1\" width=\"600\" height=\"398\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1-600x398.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1-1024x680.png 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1-225x149.png 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1-800x531.png 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1.png 1115w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>They seem pretty similar, being made up of pretty much the same pieces. So they should be pretty similar in their usage right? Not so much.<\/p>\n<p>&nbsp;<\/p>\n<p>This is an instance where the microcontroller has a decided advantage: <strong>ease of use<\/strong>. Anybody who is familiar with writing code, such as C, C++, Java, etc., can fairly easily write some code for a microcontroller board, since there are compilers that can convert the high level code into machine code for the microprocessor to use. Pretty much every microcontroller you can find will have at least one program you can download that will allow you to program your device via some type of high level code. Another advantage microcontrollers have is that they are relatively <strong>cheap<\/strong>. Once a circuit design has been finalized, production runs of a chip benefit from economies of scale and manufacturing processes that have been refined for decades. So if you wanted to create some cool LED lighting for your room, you could just buy one of a number of microcontrollers, find some simple LED code online, plug all the pieces together correctly and voila, you&#8217;ve got a night club in your living room&#8230;..sort of. \u00a0To present an analogy for this task with a FPGA, it&#8217;s like buying a Caterpillar backhoe to dig a hole in a flower bed as opposed to just using a shovel.<\/p>\n<p>&nbsp;<\/p>\n<p>As with most good things however, the microcontroller has its drawbacks. For instance, the dedicated processor handles everything that you can program the microcontroller to do, meaning that all input processing and output functions go through it, creating an inherent bottle neck. This core may be very fast, and may have multiple paths to allow for some parallel processes to happen, but the bottom line is that since everything goes through it, there may be certain processes that have to wait for other things to resolve.<\/p>\n<p>&nbsp;<\/p>\n<p>Herein lies one of the biggest advantages of an FPGA: <strong>massive parallelism<\/strong>. Writing in an HDL for a FPGA lets you define\u00a0the behavior of its logic blocks, of which there are many thousands. So\u00a0if your design only uses a small percentage of the resources, you could create multiple instances of that design that are independent from each other, allowing you to multiply the productivity of the FPGA. For example, you could write a bit of HDL code that toggles an LED based on a combination of input signals, lets say it checks to see if a certain number of switches are on. You can create multiple instances of that module in your design, specifying a different output LED for each set of inputs. This could allow you to simultaneously monitor a handful, tens, hundreds, possibly even thousands of different input signals at the same time, independently, and none of them would have any delay in output due to the others.<\/p>\n<p>&nbsp;<\/p>\n<p>Another advantage to using an FPGA is the <strong>flexibility<\/strong> afforded to the user to make hardware changes later. This advantage can be seen from two sides in my opinion. From the perspective of an average user (enthusiast, student) it provides you a versatile platform from which you can create all kinds of designs, from audio signal processing to making a video game controller.\u00a0From the perspective of a company that makes electronic devices, the use of FPGAs can give you the ability to do things like prototyping a hardware design before mass production of an application specific integrated circuit (ASIC). Along similar lines to how car manufacturers make models in clay before any actual production runs. This kind of flexibility is pretty cool, but\u00a0it\u2019s also rather difficult to implement. The primary languages themselves (Verilog and VHDL), the slight change in mindset from writing software to writing for hardware, the large amount of variables that go into designing a circuit are all factors that make someone\u2019s first attempt at writing code for an FPGA difficult.<\/p>\n<p>&nbsp;<\/p>\n<p>.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-8522 size-medium\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram2-600x397.png\" alt=\"Diagram2\" width=\"600\" height=\"397\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram2-600x397.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram2-1024x678.png 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram2-225x149.png 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram2.png 1114w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>While this is by no means a complete list,\u00a0we now have slightly filled out our diagram of differences between the two. Hopefully this post helped clear some of the obscurity around what the differences are\u00a0between these two platforms. The main theme to be taken away is that where these two devices are concerned, the question of &#8220;Which one?&#8221; is actually a matter of selecting\u00a0the right tool for the job.<\/p>\n<p>&nbsp;<\/p>\n<p>Whether you have already taken the plunge with either FPGAs or microcontrollers, or are still debating on which you may want to start with, you can check out various resource materials for Digilent FPGAs and chipKIT microcontrollers <a href=\"https:\/\/digilent.com\/reference\/start\">here.<\/a> Check out the <a href=\"https:\/\/forum.digilent.com\/forum\/16-project-vault\/\">Project Vault<\/a> on our forums to see community projects, explore microcontroller projects in the wild at <a href=\"http:\/\/www.instructables.com\/howto\/microcontroller\/\">Instructables<\/a>, and check out demo projects for our FPGA boards like the <a href=\"https:\/\/digilent.com\/reference\/basys3:basys3\">Basys 3<\/a>, <a href=\"https:\/\/digilent.com\/reference\/nexys4-ddr:start\">Nexys 4 DDR<\/a>, and the <a href=\"https:\/\/digilent.com\/reference\/zybo:zybo\">ZYBO<\/a>\u00a0to get a glimpse of some of the things you can do with FPGAs!<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-8500 jlk' data-task='like' data-post_id='8500' data-nonce='a7fc8cf7e3' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-8500 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-8500 jlk' data-task='unlike' data-post_id='8500' data-nonce='a7fc8cf7e3' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-8500 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-8500 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>FPGA or microcontroller? Do I have to choose? We&#8217;re here with some of the differences between the two and appropriate times to use each.<\/p>\n","protected":false},"author":34,"featured_media":8508,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[1662],"ppma_author":[4486],"class_list":["post-8500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fpga","tag-fpga"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/Diagram1.png","authors":[{"term_id":4486,"user_id":34,"is_guest":0,"slug":"naeastland","display_name":"Nate Eastland","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/7de23bbc8005955a986e67e7e4d633a7?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Eastland","last_name_2":"","first_name":"Nate","first_name_2":"","job_title":"","description":"I am currently a student at Washington State University studying Electrical Engineering. I am originally from Southern California but I have spent most of my life in the Seattle area. Growing up I was always deeply \r\ninterested in the pure sciences like chemistry and physics. Throughout high school I began to look for ways that I could apply the theory I had learned. I chose to pursue engineering so that my interest in applied sciences could be used to solve real world problems."}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/8500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=8500"}],"version-history":[{"count":1,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/8500\/revisions"}],"predecessor-version":[{"id":31139,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/8500\/revisions\/31139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/8508"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=8500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=8500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=8500"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=8500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}