{"id":3509,"date":"2014-12-12T12:07:15","date_gmt":"2014-12-12T20:07:15","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=3509"},"modified":"2021-06-17T08:27:52","modified_gmt":"2021-06-17T15:27:52","slug":"what-are-muxes-and-demuxes","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/what-are-muxes-and-demuxes\/","title":{"rendered":"What Are Muxes and Demuxes?"},"content":{"rendered":"<p>Any student that takes any sort of digital design class will learn about multiplexers (muxes) early in their studies. At Washington State University, \u00a0students learn about muxes in EE214. EE214 is a class that students in electrical or computer engineering generally take in their first or second year of school that covers introductory FPGA design.<\/p>\n<p>&nbsp;<\/p>\n<p>A huge part of FPGA design is using logic blocks in design. With logic blocks, you can compartmentalize your design, rather than trying implement everything in one shot. Designing without smaller blocks would be like trying to design a car without subsystems like the braking system or engine. About half of the way through the course there is a project that covers a variety of basic logic blocks, including muxes and demultiplexers (demuxes). A mux is one of the more recognizable logic blocks simply because of its block diagram.<\/p>\n<figure id=\"attachment_3570\" aria-describedby=\"caption-attachment-3570\" style=\"width: 200px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/11\/Mux-e1416515189478.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3570\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/11\/Mux-e1416515189478.png\" alt=\"The block diagram for a 4 to 1 multiplexer.\" width=\"200\" height=\"353\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/11\/Mux-e1416515189478.png 450w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/11\/Mux-e1416515189478-340x600.png 340w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a><figcaption id=\"caption-attachment-3570\" class=\"wp-caption-text\">The block diagram for a 4 to 1 multiplexer.<\/figcaption><\/figure>\n<p>The block diagram allows users to design large designs using a mux without having to worry about the logic inside of it. All they have to worry about is what it does. So what does it do?<\/p>\n<p>&nbsp;<\/p>\n<p>The easiest way to think about a mux is that it is an input selector. Based on the select code you apply so the S inputs, it will connect only one input to the output. For a more formal definition, I&#8217;ve presented a truth table. A truth table shows all the possible outputs of a circuit for every possible combination of inputs.<\/p>\n<figure id=\"attachment_3573\" aria-describedby=\"caption-attachment-3573\" style=\"width: 200px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/11\/muxtruth.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3573\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/11\/muxtruth.png\" alt=\"The truth table defining the operation of a mux.\" width=\"200\" height=\"105\" \/><\/a><figcaption id=\"caption-attachment-3573\" class=\"wp-caption-text\">The truth table defining the operation of a mux.<\/figcaption><\/figure>\n<p>You can also think of a mux as a switchboard. You are the output Y and the operator is the mux. Depending on the extension (S inputs) you give the operator, you will be connected to a different person (I inputs).<\/p>\n<p>&nbsp;<\/p>\n<p>For those with a coding background it may be better understood in code. Muxes are built off of case statements. In Verilog, a mux would look like this:<\/p>\n<figure id=\"attachment_3726\" aria-describedby=\"caption-attachment-3726\" style=\"width: 250px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/muxcode.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3726\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/muxcode.png\" alt=\"A Multiplexer coded in Verilog as shown in Vivado 2014.4.\" width=\"250\" height=\"357\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/muxcode.png 354w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/muxcode-157x225.png 157w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><figcaption id=\"caption-attachment-3726\" class=\"wp-caption-text\">A multiplexer coded in Verilog as shown in Vivado 2014.4.<\/figcaption><\/figure>\n<p>Now what is a demux? You can think of a demux as sort of the opposite of a mux. Instead of routing one of four inputs to 1 output, it takes one\u00a0input and routes it to one of four outputs. Here is the block diagram of a demux.<\/p>\n<figure id=\"attachment_3728\" aria-describedby=\"caption-attachment-3728\" style=\"width: 200px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3728\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demux.png\" alt=\"The block Diagram of a demux. En is enable. \" width=\"200\" height=\"248\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demux.png 437w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demux-181x225.png 181w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a><figcaption id=\"caption-attachment-3728\" class=\"wp-caption-text\">The block diagram of a demux. EN is enable.<\/figcaption><\/figure>\n<p>The signal EN is the input that you are trying to pass, and I0 and I1 create the select code for the output that you want to pass it to. If you want to pass a 1 to Y1. Then you need to hold EN high at a 1 and pass a 0 to I1 and a 1 to I0. In binary 01 is equivalent to 1, so\u00a0if you want to\u00a0select an output, pass the binary value to the I inputs.<\/p>\n<p>&nbsp;<\/p>\n<p>To clarify, here is the truth table for a demux:<\/p>\n<figure id=\"attachment_3729\" aria-describedby=\"caption-attachment-3729\" style=\"width: 364px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demuxtable.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3729\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demuxtable.png\" alt=\"The truth table outlining how the demux functions. \" width=\"364\" height=\"131\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demuxtable.png 364w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/demuxtable-225x80.png 225w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/a><figcaption id=\"caption-attachment-3729\" class=\"wp-caption-text\">The truth table outlining how the demux functions.<\/figcaption><\/figure>\n<p>If you would like to see a mux in action you can visit\u00a0<a href=\"http:\/\/learn.blog.digilentinc.com\">learn.blog.digilentinc.com<\/a> and try out the\u00a0<a href=\"http:\/\/learn.blog.digilentinc.com\/Documents\/292\">Multiplexer Guessing Game<\/a>\u00a0(using the Uno32) and\u00a0\u00a0<a href=\"http:\/\/learn.blog.digilentinc.com\/Documents\/253\">the simple communication system<\/a>\u00a0(using FPGA) projects.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-3509 jlk' data-task='like' data-post_id='3509' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-3509 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-3509 jlk' data-task='unlike' data-post_id='3509' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-3509 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-3509 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>A huge part of FPGA design is using logic blocks in design. With logic blocks, you can compartmentalize your design, rather than trying implement everything in one shot. Designing without smaller blocks would be like trying to design a car without subsystems like the braking system or engine. About half of the way through the course there is a project that covers a variety of basic logic blocks, including multiplexers (muxes) and demultiplexers (demuxes). So what are muxes and demuxes?<\/p>\n","protected":false},"author":18,"featured_media":3726,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,1563],"tags":[1662],"ppma_author":[4466],"class_list":["post-3509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fpga","category-guide","tag-fpga"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/12\/muxcode.png","authors":[{"term_id":4466,"user_id":18,"is_guest":0,"slug":"kaitlyn","display_name":"Kaitlyn Franz","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/3f16f6159d3666c6fd05a4b73a18c286?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Franz","last_name_2":"","first_name":"Kaitlyn","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/3509","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=3509"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/3509\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/3726"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=3509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=3509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=3509"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}