{"id":37347,"date":"2025-06-25T17:16:23","date_gmt":"2025-06-25T17:16:23","guid":{"rendered":"https:\/\/gaviki.com\/blog\/?p=37347"},"modified":"2025-06-26T07:54:24","modified_gmt":"2025-06-26T07:54:24","slug":"the-elements-of-computing-systems","status":"publish","type":"post","link":"https:\/\/gaviki.com\/blog\/the-elements-of-computing-systems\/","title":{"rendered":"The Elements of Computing Systems"},"content":{"rendered":"\n<p>Mux8Way16.hdl &#8211; Notepad File Edit Format View Help \/\/ This file is part of www.nand2tetris.org \/\/ and the book &#8220;The Elements of Computing Systems&#8221; \/\/ by Nisan and Schocken, MIT Press. \/\/ File name: projects\/01\/Mux8Way16.hdl \/** 8-way 16-bit multiplexor: * out = a if sel == 000 * * * b if sel == 001 etc. h if sel == 111 *\/ CHIP Mux8Way16 { IN a[16], b[16], c[16], d[16], e[16], f[16], g[16], h[16], sel[3]; OUT out[16]; } PARTS: Mux4Way16(a=a, b=b, c=c, d=d, sel=sel[0..1], out=muxAD); Mux4Way16(a=e, b=f, c=g, d=h, sel=sel[0..1], out=muxEH); Mux16(a=muxAD, b=muxEH, sel=sel[2], out=out); }<\/p>\n\n\n\n<pre id=\"preorder-ask-header-text\" class=\"wp-block-preformatted\">Mux8Way16.hdl - Notepad File Edit Format View Help \/\/ This file is part of www.nand2tetris.org \/\/ and the book \"The Elements of Computing Systems\" \/\/ by Nisan and Schocken, MIT Press. \/\/ File name: projects\/01\/Mux8Way16.hdl \/** 8-way 16-bit multiplexor: * out = a if sel == 000 * * * b if sel == 001 etc. h if sel == 111 *\/ CHIP Mux8Way16 { IN a[16], b[16], c[16], d[16], e[16], f[16], g[16], h[16], sel[3]; OUT out[16]; } PARTS: Mux4Way16(a=a, b=b, c=c, d=d, sel=sel[0..1], out=muxAD); Mux4Way16(a=e, b=f, c=g, d=h, sel=sel[0..1], out=muxEH); Mux16(a=muxAD, b=muxEH, sel=sel[2], out=out); }<\/pre>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">The Correct Answer and Explanation is:<\/mark><\/strong><\/p>\n\n\n\n<p><strong>Correct Answer: The given HDL code for <code>Mux8Way16<\/code> is correct and implements an 8-way 16-bit multiplexor using two <code>Mux4Way16<\/code> gates and one <code>Mux16<\/code> gate.<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<p>This Hardware Description Language (HDL) file defines a chip called <code>Mux8Way16<\/code>, which is an 8-input, 16-bit-wide multiplexer. A multiplexer selects one of several input buses and forwards it to the output based on a selection signal. In this case, there are 8 input buses labeled <code>a<\/code> through <code>h<\/code>, each 16 bits wide. The <code>sel<\/code> input is a 3-bit selection signal that determines which input gets passed to the output.<\/p>\n\n\n\n<p>Here is how the design works:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The 8 inputs are divided into two groups of four:\n<ul class=\"wp-block-list\">\n<li>The first group includes <code>a<\/code>, <code>b<\/code>, <code>c<\/code>, and <code>d<\/code>.<\/li>\n\n\n\n<li>The second group includes <code>e<\/code>, <code>f<\/code>, <code>g<\/code>, and <code>h<\/code>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Two <code>Mux4Way16<\/code> chips are used:\n<ul class=\"wp-block-list\">\n<li>The first <code>Mux4Way16<\/code> receives inputs <code>a<\/code> to <code>d<\/code> and selects one based on the lower two bits of <code>sel<\/code> (<code>sel[0..1]<\/code>). The output of this multiplexer is stored in a temporary wire named <code>muxAD<\/code>.<\/li>\n\n\n\n<li>The second <code>Mux4Way16<\/code> does the same for inputs <code>e<\/code> to <code>h<\/code>, and its output is stored in <code>muxEH<\/code>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Finally, a regular <code>Mux16<\/code> is used to choose between <code>muxAD<\/code> and <code>muxEH<\/code>. This selection is based on the most significant bit of <code>sel<\/code> (<code>sel[2]<\/code>).<\/li>\n<\/ol>\n\n\n\n<p>The full selection process is as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If <code>sel[2]<\/code> is 0, the output comes from the first group (<code>a<\/code> to <code>d<\/code>).<\/li>\n\n\n\n<li>If <code>sel[2]<\/code> is 1, the output comes from the second group (<code>e<\/code> to <code>h<\/code>).<\/li>\n\n\n\n<li>Within each group, <code>sel[1]<\/code> and <code>sel[0]<\/code> determine which specific input is selected.<\/li>\n<\/ul>\n\n\n\n<p>This modular approach makes the design readable, scalable, and easy to debug.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"1024\" src=\"https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-881.jpeg\" alt=\"\" class=\"wp-image-37348\" srcset=\"https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-881.jpeg 852w, https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-881-250x300.jpeg 250w, https:\/\/gaviki.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner8-881-768x923.jpeg 768w\" sizes=\"auto, (max-width: 852px) 100vw, 852px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Mux8Way16.hdl &#8211; Notepad File Edit Format View Help \/\/ This file is part of www.nand2tetris.org \/\/ and the book &#8220;The Elements of Computing Systems&#8221; \/\/ by Nisan and Schocken, MIT Press. \/\/ File name: projects\/01\/Mux8Way16.hdl \/** 8-way 16-bit multiplexor: * out = a if sel == 000 * * * b if sel == 001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37347","post","type-post","status-publish","format-standard","hentry","category-quiz-questions"],"_links":{"self":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts\/37347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/comments?post=37347"}],"version-history":[{"count":2,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts\/37347\/revisions"}],"predecessor-version":[{"id":38063,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/posts\/37347\/revisions\/38063"}],"wp:attachment":[{"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/media?parent=37347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/categories?post=37347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gaviki.com\/blog\/wp-json\/wp\/v2\/tags?post=37347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}