<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Tech Cafe - Nand-to-Tetris</title>
    <subtitle>Dev adventures, epic bugs, tiny wins, and the occasional meltdown.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://golden-fox.dev/tags/nand-to-tetris/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://golden-fox.dev"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2025-05-09T00:00:00+00:00</updated>
    <id>https://golden-fox.dev/tags/nand-to-tetris/atom.xml</id>
    <entry xml:lang="en">
        <title>My Nand to Tetris Journey</title>
        <published>2025-05-09T00:00:00+00:00</published>
        <updated>2025-05-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Aakriti Agarwal
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://golden-fox.dev/blog/nand-to-tetris/"/>
        <id>https://golden-fox.dev/blog/nand-to-tetris/</id>
        
        <content type="html" xml:base="https://golden-fox.dev/blog/nand-to-tetris/">&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;&#x2F;h2&gt;
&lt;p&gt;In March 2025, I signed up for the Coursera course &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.coursera.org&#x2F;learn&#x2F;build-a-computer&quot;&gt;&lt;strong&gt;From Nand to Tetris: Building a Modern Computer&lt;&#x2F;strong&gt;&lt;&#x2F;a&gt; by Shimon Schocken and Noam Nisan. I thought “Why not learn how computers work from the basics?” Spoiler:- It’s not as easy as it sounds. The course promised to turn me into a computer-building wizard, and I got pretty far completing four out of six projects.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;logic-gates-from-nand&quot;&gt;Logic Gates from NAND&lt;&#x2F;h2&gt;
&lt;p&gt;The course starts with a simple idea: using only the elementary NAND gate, you can construct all other logic gates necessary for a modern computer. This concept blew my mind, the idea that complex systems ultimately reduce to this simple building block.&lt;&#x2F;p&gt;
&lt;p&gt;I started by implementing basic logic gates in the &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nand2tetris.github.io&#x2F;web-ide&#x2F;chip&#x2F;&quot;&gt;&lt;strong&gt;NAND2Tetris Hardware Simulator&lt;&#x2F;strong&gt;&lt;&#x2F;a&gt; using hdl:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;NOT gate&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#657B83, #839496); background-color: light-dark(#FDF6E3, #002B36);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; CHIP Not {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    IN in;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    OUT out;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    PARTS:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Nand (a = in, b = in, out = out);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;AND gate&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#657B83, #839496); background-color: light-dark(#FDF6E3, #002B36);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CHIP And {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    IN a, b;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    OUT out;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    PARTS:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Nand (a = a, b = b, out = aNandb);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Not (in = aNandb, out = out);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;OR gate&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#657B83, #839496); background-color: light-dark(#FDF6E3, #002B36);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CHIP Or {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    IN a, b;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    OUT out;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    PARTS:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Not (in = a, out = nota);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Not (in = b, out = notb);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    And (a = nota, b = notb, out = and);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Not (in = and, out = out);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;XOR gate&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#657B83, #839496); background-color: light-dark(#FDF6E3, #002B36);&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CHIP Xor {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    IN a, b;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    OUT out;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    PARTS:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Not (in = a, out = nota);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Not (in = b, out = notb);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    And (a = a, b = notb, out = temp1);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    And (a = nota, b = b, out = temp2);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    Or (a = temp1, b = temp2, out = out);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;Pro Tip&lt;&#x2F;strong&gt;: Use &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.nandgame.com&#x2F;&quot;&gt;&lt;strong&gt;NAND Game&lt;&#x2F;strong&gt;&lt;&#x2F;a&gt;! to understand how theses gates are formed using NAND.&lt;&#x2F;p&gt;
&lt;p&gt;As It transforms theoretical concepts into visuals that make implementation much easier than it seems.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;from-gates-to-chips&quot;&gt;From Gates to Chips&lt;&#x2F;h2&gt;
&lt;p&gt;Once I had a grip on basic gates, it was time to get serious and build some chips. Enter the realm of multiplexers and demultiplexers. These allow you to:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;MUX (Multiplexer): Choose which input signal to use.&lt;&#x2F;li&gt;
&lt;li&gt;DMUX (Demultiplexer): Route signals to different outputs based on selection bits.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I thought the difficulty would skyrocket when I started with the 16-bit and multi-way chips, but once I built the first 16-bit chip, the rest were a breeze, just a bit of grunt work, really.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Arithmetic Components&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Next came the exciting part which is creating chips that can actually compute! I implemented:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Half Adder (adding two bits)&lt;&#x2F;li&gt;
&lt;li&gt;Full Adder (adding three bits with carry)&lt;&#x2F;li&gt;
&lt;li&gt;Multi-bit Adder (for 16-bit )&lt;&#x2F;li&gt;
&lt;li&gt;The ALU (Arithmetic Logic Unit)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;from-bits-to-storage&quot;&gt;From Bits to Storage&lt;&#x2F;h2&gt;
&lt;p&gt;The next phase took me into the realm of computer memory, where I designed:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Registers: Flip-flop based storage units that hold data temporarily&lt;&#x2F;li&gt;
&lt;li&gt;RAM8: A small 8-register memory unit&lt;&#x2F;li&gt;
&lt;li&gt;RAM64: A memory unit of 64-register&lt;&#x2F;li&gt;
&lt;li&gt;RAM512, RAM4K and RAM16K: Increasing memory units&lt;&#x2F;li&gt;
&lt;li&gt;Program Counter (PC)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;This hierarchy of memory components taught me how computers are organized.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;challenges-and-limitations&quot;&gt;Challenges and Limitations&lt;&#x2F;h2&gt;
&lt;p&gt;While I successfully completed four projects, the two modules focused on assembly language programming were… let’s just say, less successful. I realized I’m a visual learner who prefers tools like simulators. Still, the struggle was part of the fun. Sort of.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;resources-that-helped-me&quot;&gt;Resources That Helped Me&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;The  NAND game (seriously, don’t skip it!)&lt;&#x2F;li&gt;
&lt;li&gt;Course forums where students swapped war stories about their challenges (misery loves company).&lt;&#x2F;li&gt;
&lt;li&gt;Drawing chips designs on paper before implementation&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;While I didn’t complete all six projects, the four I finished gave me a solid foundation in computer architecture that I’ll build upon.&lt;&#x2F;p&gt;
&lt;p&gt;If you’re curious about how computers really work from the ground up, I highly recommend this course. It’s tough, but incredibly rewarding. After all, who wouldn’t want to say, “I built a computer from scratch with just a NAND gate”?&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
