{"id":7402,"date":"2015-06-09T09:16:56","date_gmt":"2015-06-09T16:16:56","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=7402"},"modified":"2025-06-03T06:46:32","modified_gmt":"2025-06-03T13:46:32","slug":"building-logic-gates-with-transistors","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/building-logic-gates-with-transistors\/","title":{"rendered":"Building Logic Gates with Transistors"},"content":{"rendered":"<p>Earlier you read about <a href=\"https:\/\/digilent.com\/blog\/index.php\/logic-gates\/\">logic gates and their functions<\/a>. Then you read about how to <a href=\"https:\/\/digilent.com\/blog\/index.php\/coding-logic-gates\/\">code logic gates<\/a> in Verilog, VHDL, and C. Now its time to learn about creating logic gates with transistors. After reading all of these posts you will have learned about logic gate theory, coding logic gates in both hardware and software, and the physical hardware design of logic gates.<\/p>\n<p>&nbsp;<\/p>\n<p>The first thing to know before we get into the structure of logic gates is the two types of transistors that will be used. There are NFETs (n-type or n-channel mosfet) and PFETs (p-type or p-channel mosfet.)<\/p>\n<figure id=\"attachment_7404\" aria-describedby=\"caption-attachment-7404\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/mosfet.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7404\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/mosfet-600x397.png\" alt=\"NFETs pass a signal when given a 1, and PFETs pass a signal when given a 0.\" width=\"600\" height=\"397\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/mosfet-600x397.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/mosfet-225x149.png 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/mosfet.png 679w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-7404\" class=\"wp-caption-text\">NFETs pass a signal when given a 1, and PFETs pass a signal when given a 0.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>PFETs are like switches that are closed when the gate is given a 0 and are open when the gate is given a 1. In other words, a PFET will pass a value through it when it receives a 0.<\/p>\n<p>&nbsp;<\/p>\n<p>NFETs are like switches that are closed when the gate is given a 1 and are open when the gate is given a 0. In other words, a NFET will pass a value through it when it receives a 1.<\/p>\n<p>&nbsp;<\/p>\n<p>To make our logic gates we can use a combination of NFETs and PFETs.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7411\" aria-describedby=\"caption-attachment-7411\" style=\"width: 305px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7411\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenot-305x600.png\" alt=\"A NOT gate made out of transistors.\" width=\"305\" height=\"600\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenot-305x600.png 305w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenot-114x225.png 114w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenot.png 405w\" sizes=\"auto, (max-width: 305px) 100vw, 305px\" \/><\/a><figcaption id=\"caption-attachment-7411\" class=\"wp-caption-text\">A NOT gate made out of transistors.<\/figcaption><\/figure>\n<p>The NOT\u00a0gate only uses two transistors. If A is 1, then the PFET is off and the NFET is on, so GND or 0 gets passed. If A is 0 the PFET is on and the NFET in off so VDD or 1 gets passed.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7408\" aria-describedby=\"caption-attachment-7408\" style=\"width: 405px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateand.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7408\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateand.png\" alt=\"An AND gate made out of transistors. \" width=\"405\" height=\"460\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateand.png 405w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateand-198x225.png 198w\" sizes=\"auto, (max-width: 405px) 100vw, 405px\" \/><\/a><figcaption id=\"caption-attachment-7408\" class=\"wp-caption-text\">An AND gate made out of transistors.<\/figcaption><\/figure>\n<p>The AND gate is slightly more complicated and requires six transistors. You can still go through the same process as before to see how it works. Give A and B values and see which transistors are on, and what values get passed.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7409\" aria-describedby=\"caption-attachment-7409\" style=\"width: 392px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenand.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7409\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenand-392x600.png\" alt=\"A NAND gate made out of transistors. \" width=\"392\" height=\"600\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenand-392x600.png 392w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenand-147x225.png 147w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenand.png 450w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/a><figcaption id=\"caption-attachment-7409\" class=\"wp-caption-text\">A NAND gate made out of transistors.<\/figcaption><\/figure>\n<p>The NAND gate is very closely related to the AND gate. Notice that the NAND gate is an AND gate without the NOT gate at the end.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7412\" aria-describedby=\"caption-attachment-7412\" style=\"width: 525px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7412\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateor-525x600.png\" alt=\"An OR gate made out of transistors.\" width=\"525\" height=\"600\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateor-525x600.png 525w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateor-197x225.png 197w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gateor.png 603w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/a><figcaption id=\"caption-attachment-7412\" class=\"wp-caption-text\">An OR gate made out of transistors.<\/figcaption><\/figure>\n<p>The OR gate is very similar to the AND gate, except that the NFETs are in parallel rather than the PFETs being in parallel.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7410\" aria-describedby=\"caption-attachment-7410\" style=\"width: 366px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7410\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenor-366x600.png\" alt=\"A NOR gate made out of transistors. \" width=\"366\" height=\"600\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenor-366x600.png 366w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenor-137x225.png 137w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatenor.png 420w\" sizes=\"auto, (max-width: 366px) 100vw, 366px\" \/><\/a><figcaption id=\"caption-attachment-7410\" class=\"wp-caption-text\">A NOR gate made out of transistors.<\/figcaption><\/figure>\n<p>The NOR gate has the same relationship with the OR gate that the NAND gate has with the AND gate.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7414\" aria-describedby=\"caption-attachment-7414\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7414\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor-600x296.png\" alt=\"An XOR gate showing how it is built out of other gates. This is the way it was coded in the previous post.\" width=\"600\" height=\"296\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor-600x296.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor-1024x505.png 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor-225x111.png 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor-800x394.png 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexor.png 1124w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-7414\" class=\"wp-caption-text\">An XOR gate showing how it is built out of other gates. This is the way it was coded in the previous post.<\/figcaption><\/figure>\n<p>The XOR is quite a bit more complicated. It can be made up of five of the gates that we already described. You can see the block diagram describing how these gates are combined. In the transistor image I enclosed each gate in red dots.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7415\" aria-describedby=\"caption-attachment-7415\" style=\"width: 577px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexort.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7415\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexort-577x600.png\" alt=\"An XOR gate made up of two NOT gates, two AND gates, and an OR gate.\" width=\"577\" height=\"600\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexort-577x600.png 577w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexort-217x225.png 217w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexort.png 612w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/a><figcaption id=\"caption-attachment-7415\" class=\"wp-caption-text\">An XOR gate made up of two NOT gates, two AND gates, and an OR gate.<\/figcaption><\/figure>\n<p>The XNOR gate has the same relationship with the XOR gate that NAND has with AND and that NOR has with OR. Notice that in the XNOR gate the last NOT gate and the NOT gate in the OR gate can be cancelled out. Two negatives, in this case, do make a positive. So instead of the OR and NOT you could just use a NOR gate.<\/p>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_7413\" aria-describedby=\"caption-attachment-7413\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexnor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-7413\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexnor-600x508.png\" alt=\"An XNOR gate. Note that the last NOT gate and the NOT gate in the OR gate can cancel to be simplified.\" width=\"600\" height=\"508\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexnor-600x508.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexnor-225x191.png 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexnor.png 752w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-7413\" class=\"wp-caption-text\">An XNOR gate. Note that the last NOT gate and the NOT gate in the OR gate can cancel to be simplified.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>Now that you have an understanding of the basic logic gates used in digital design, check out the <a href=\"https:\/\/learn.blog.digilentinc.com\/list?category=Digital\">FPGA modules<\/a> on Digilent&#8217;s Learn site!<\/p>\n<p>And if you want to dig deeper, you can continue reading on <a href=\"https:\/\/digilent.com\/blog\/what-is-sequential-logic\/\" target=\"_blank\" rel=\"noopener\">sequential logic<\/a>, or <a href=\"https:\/\/digilent.com\/blog\/back-to-basics-with-transistors\/\" target=\"_blank\" rel=\"noopener\">go back to basics with transistors<\/a>.<\/p>\n<p>Are you ready to unleash your creativity and dive into the world of digital design? Explore the endless possibilities with Digilent <a href=\"https:\/\/digilent.com\/shop\/boards-and-components\/system-boards\/fpga-boards\/\">FPGA boards<\/a> and bring your ideas to life!<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-7402 jlk' data-task='like' data-post_id='7402' data-nonce='1c819b3974' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-7402 lc'>+7<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-7402 jlk' data-task='unlike' data-post_id='7402' data-nonce='1c819b3974' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-7402 unlc'>-2<\/span><\/a><\/div><\/div> <div class='status-7402 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>This is a continuation of previous blogs about logic gates. Earlier you read about logic gates and their functions. Then you read about how to code logic gates in Verilog, VHDL, and C. Now its time to learn about creating logic gates with transistors. After reading all of these posts you&#8217;ll have learned about logic gate theory, coding logic gates in both hardware and software, and the physical hardware design of logic gates.<\/p>\n","protected":false},"author":18,"featured_media":7415,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[18,4322],"tags":[],"ppma_author":[4466],"class_list":["post-7402","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-academia","category-accessories"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/06\/gatexort.png","authors":[{"term_id":4466,"user_id":18,"is_guest":0,"slug":"kaitlyn","display_name":"Kaitlyn Franz","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/9276021eaa44781ce19f364cfca46ada25e1500769cf4803a095a5bae83c912a?s=96&d=mm&r=g","1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":"","9":"","10":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/7402","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\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=7402"}],"version-history":[{"count":6,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/7402\/revisions"}],"predecessor-version":[{"id":31632,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/7402\/revisions\/31632"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/7415"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=7402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=7402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=7402"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=7402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}