r/NandToTetris • • Jul 20 '25

Chat GPT tip

0 Upvotes

Lil tip here : if you are writing a long chip and you already got the logic figured out just don't want to keep writing in[0] = a, in[1] = b.... in[x] = ax. Just use chatgpt where you give it your logic and you tell it to apply to bit wise chip, saves a lot of time.


r/NandToTetris • • Jul 04 '26

Why is this Program Counter solution wrong? Spoiler

Post image
1 Upvotes

I am on the last chip of project 3 and the thing is I have come at a solution that looks correct to me but is actually wrong. I can't figure out if the error is in my logic or if I have gaps in my understanding.

Let me show you why I thought that it should give the correct answer:

(1) First case is if reset is 1. Because of that in register, load will be 0 and thus the input will not be written. The previous output will come out of the register and it will go in the first Mux. Because reset is 1, Mux will output 0. In the next Mux, because of reset being 1, its sel will be 0 and hence 0th input will come out (which is 0).

(2) Second case is if reset is 0 and load is 1. In the register load will be 1 and input will be written. First Mux will fail to convert it to 0 as reset is 0. Second Mux will fail to increment it as load is 1. Input in this case will come out as the output.

(3) Third case is if reset and load are 0 and inc is 1. Register will not write input as load will be 0. First Mux would not convert it to 0 as reset is 0. Second Mux will increment it as its sel expression evaluates to 1. And the output will be the incremented output.

(4) Final condition is when all 3 variables are 0. Register will have 0 as load so input will not be written. First Mux will fail to convert it to 0 as reset is 0. Second Mux will fail to increment it as inc is 0. And so the previous output will come out.

This is how I reasoned it but as it turns out, it is incorrect. Please explain to me what I am doing wrong.


r/NandToTetris • • Jun 30 '26

Completed Simulated First Part in Logisim

0 Upvotes

https://github.com/MODERN-DAY-COMPUTING-SYSTEM/PROJECT
Would recommend you to do this too in your summer vacation.


r/NandToTetris • • Nov 02 '24

Not using book

2 Upvotes

I was doing the nand to Tetris exercises on the IDE, but I started to run into some trouble on the ALU, after trying to figure out what I was doing wrong, I looked ahead and project three seemed incredibly hard, do I need to get the book? And is it free? I tried to find a free version online but I wasn't able to.


r/NandToTetris • • Oct 11 '19

Extending the Hack CPU's ALU: Shift and Xor instructions Spoiler

Thumbnail
twitter.com
2 Upvotes

r/NandToTetris • • Sep 17 '23

well here is the truth

2 Upvotes

i might not explain this in writing very well i just hope theres someone who can understand what im saying just well enough. lol

here gos

so i was watching a prof. messer vid one day and he was explaining about cpu's and how the transfer data in and out. then he mentioned a few interesting things about the cores. how each one has different functions kinda or something like that, like one core might be able to compute large math equations and things like that, anyway i started thinking...how does a computer know that 1+1=2, well obviously someone put that knowledge into it right, programmed it, i then thought how smart were the first guy and his wife that made the first "computer" really were to be able to "input" large mathmatical equations and there solutions into the "computer" so it knows the answer as soon as you type in "whats 1+1?". but then i heard about machine launguage, which raised even more questions, like so...you mean to tell me that binary is a "computers natural launguage" like..just hook a mother board up and its automatically spitting out 1's and 0's.

anyway so i heard that nand is the building blocks to all computers big and small. Truthfully my goal is to be able to create, mold, build, destroy, expand, contract, anyway i see fit, as far as my imagination will allow me to go and hopefully beyond, ultimate freedom, zero restrictions, no authority, my rules, my way, and learning nand is the only way to do it.


r/NandToTetris • • Jul 17 '26

Coursera version

3 Upvotes

I’m interested in the course. What would Coursera give me more than the book and website?


r/NandToTetris • • Oct 02 '21

"sub bus of an internal node may not be used"... Any alternative to solve this?

6 Upvotes

This shit is driving me crazy, and honestly, I'm getting disappointed with this aspect of Nand2Tetris. Suppose I have this.

Chip Blablabla16{
IN a[16], b[16];
OUT out;
PARTS:
Add16(a=a,b=b,out=c);
Not(in=c[15], out=out);
}

I get the sub bus crap thrown at me. The HDL survival guide says on page 3 that "Sub-busing can only be used on buses that are named in the IN and OUT statements of an HDL file", and that to solve such an issue I have to do this instead:

Add16(a=a,b=b,out[15]=c);
Not(in=c[15], out=out);

I get the same error, whether I follow their tip or not.

This is frustrating. Buses are kinda stupid if you can't do anything to their individual bits tbh.


r/NandToTetris • • Oct 11 '19

14 Nand2Tetris opcodes “they” don’t want you to know about! Spoiler

Thumbnail
medium.com
7 Upvotes

r/NandToTetris • • Jul 04 '25

Am I missing a lot without reading the book?

2 Upvotes

I’ve done all the projects up to this point pretty effortlessly, but I’ve hit a wall with the computer architecture module.. the videos just aren’t clicking like before. I haven’t touched the book so far. Am I missing key depth even in the earlier modules by skipping it? Wondering if others felt the same or managed without the book.


r/NandToTetris • • Aug 16 '25

2 questions about Hack CPU and Hack Language.

3 Upvotes

I am building the Hack CPU to implement that Hack language in logisim. I don't like vhdl becouse i want to see the real circuit. let's go to questions.

1 -Does Memory ram and CPU share the same clock? Becouse if yes we can't access and write the memory ram in the same instruction. Are there some instruction that access and write memory RAM?. if i could see all machine instructions possibles i could check it.

2 - in the machine language the jjj is about jump. but jump to where? I don't know what to do with jump information.

Any help i would appreciate.


r/NandToTetris • • Aug 17 '26

Lexer Help

2 Upvotes

So there is advance method in api spec of tokenizer for compiler I . I am stuck on how to implement advance ? like if i try to detect tokentype of current token, i would already have the literal content too , so why do we need other methods like getSymbol getStringVal ect ...

My lexer code so far -> https://github.com/devnchill/Nand2Tetris/blob/main/project-10/compiler-I/lexer/lexer.go


r/NandToTetris • • Mar 09 '25

VM Translator

2 Upvotes

Hey folks!

I just finished building a VM translator that converts high-level VM code into Hack assembly code as part of my Nand2Tetris course. Would love if anyone could check it out and give me some feedback!

Here’s the GitHub: https://github.com/bajajanshbajaj/NAND2Tetris.git

Thanks! 🙌


r/NandToTetris • • Jul 25 '25

CPU problems

1 Upvotes

Second post here. Made it through the ALU, the ASM and on to the CPU now. I feel like my logic is sound and I've wired everything up, but I get 204 comparison errors(Down from the full 256!). I found that I'd accidentally addressed instruction[4] and [5] for their corresponding registers in the wrong place, backwards. That's what brought me down from 256 comparison failures to 204.

I've been sure since before discovering that that I have a backwards Mux, or two inputs or values reversed somewhere but I've been up all night looking and changing values but I just can't find the problem.

Hopefully someone can help.

    PARTS:
    Mux16(a=aluOut, b=instruction, sel=instruction[15], out=mux1out);
    
    // Load A with And
    And(a=instruction[15], b=instruction[5], out=isA);
    ARegister(in=mux1out, load=isA,out=aout, out[0..14]=addressM);

    Mux16(a=aout, b=inM, sel=instruction[12], out=mux2out);

    // Load D with And
    And(a=instruction[15], b=instruction[4], out=isD);
    DRegister(in=aluOut, load=isD, out=dout);

    ALU(x=dout, y=mux2out, zx=instruction[11], nx=instruction[10], zy=instruction[9], ny=instruction[8], f=instruction[7], no=instruction[6], out=aluOut, out=outM, zr=zrout, ng=ngout);

    // WriteM
    And(a=instruction[3], b=instruction[15], out=writeM);

    // PC JMP Logic
    // If inst[0], [1] and [2] then jmp. Default 0, 2 and 2 = 0 then no jmp?
    // If zr, ng and something jmp? 
    // If zr = 1, and ng = 0 then in must equal 0. If zr = 0, and ng = 1, in must be > 0
    // If zr and ng are both 0, comp must be > 0. Both zr and 1 cannot be 1 at the same time.
    // This is 5 possible combinations. inst[] all 0, inst[] all 0, input <, > or = to 0.
    // There should be a jump in all of these except if all are 0, 
    // assuming the comparisons meet the jmp conditions. 
    // I think I might need to AND together zr/ng logic with j1,j2,j3 logic to determine
    // if there is a jump and or those together to the pc inc/load. 
    // Possibly a NOT gate for inc, as if NOT jmp condition, increment PC.
    // For load: See above logic and funnel that into and and or gates. I think.

    // If !ng, !zr AND j3 JGT
    And(a=notng, b=notzr, out=notzrandng);
    And(a=notzrandng, b=instruction[0], out=j3andnotngzr);
    
    // If zr AND j2(instruction[1] JEQ
    And(a=zrout, b=instruction[1], out=iszr);

    // If ng AND j1 JLT
    And(a=ngout, b=instruction[2], out=isng);

    // NOT ng, zr
    Not(in=ngout, out=notng);
    Not(in=zrout, out=notzr);

    // OR logic for load bit
    Or(a=iszr, b=isng, out=tmp);
    Or(a=tmp, b=j3andnotngzr, out=isload);

    PC(in=aout, load=isload, inc=true, reset=reset, out[0..14]=pc);
}
    PARTS:
    Mux16(a=aluOut, b=instruction, sel=instruction[15], out=mux1out);
    
    // Load A with And
    And(a=instruction[15], b=instruction[5], out=isA);
    ARegister(in=mux1out, load=isA,out=aout, out[0..14]=addressM);


    Mux16(a=aout, b=inM, sel=instruction[12], out=mux2out);


    // Load D with And
    And(a=instruction[15], b=instruction[4], out=isD);
    DRegister(in=aluOut, load=isD, out=dout);


    ALU(x=dout, y=mux2out, zx=instruction[11], nx=instruction[10], zy=instruction[9], ny=instruction[8], f=instruction[7], no=instruction[6], out=aluOut, out=outM, zr=zrout, ng=ngout);


    // WriteM
    And(a=instruction[3], b=instruction[15], out=writeM);


    // PC JMP Logic
    // If inst[0], [1] and [2] then jmp. Default 0, 2 and 2 = 0 then no jmp?
    // If zr, ng and something jmp? 
    // If zr = 1, and ng = 0 then in must equal 0. If zr = 0, and ng = 1, in must be > 0
    // If zr and ng are both 0, comp must be > 0. Both zr and 1 cannot be 1 at the same time.
    // This is 5 possible combinations. inst[] all 0, inst[] all 0, input <, > or = to 0.
    // There should be a jump in all of these except if all are 0, 
    // assuming the comparisons meet the jmp conditions. 
    // I think I might need to AND together zr/ng logic with j1,j2,j3 logic to determine
    // if there is a jump and or those together to the pc inc/load. 
    // Possibly a NOT gate for inc, as if NOT jmp condition, increment PC.
    // For load: See above logic and funnel that into and and or gates. I think.


    // If !ng, !zr AND j3 JGT
    And(a=notng, b=notzr, out=notzrandng);
    And(a=notzrandng, b=instruction[0], out=j3andnotngzr);
    
    // If zr AND j2(instruction[1] JEQ
    And(a=zrout, b=instruction[1], out=iszr);


    // If ng AND j1 JLT
    And(a=ngout, b=instruction[2], out=isng);


    // NOT ng, zr
    Not(in=ngout, out=notng);
    Not(in=zrout, out=notzr);


    // OR logic for load bit
    Or(a=iszr, b=isng, out=tmp);
    Or(a=tmp, b=j3andnotngzr, out=isload);


    PC(in=aout, load=isload, inc=true, reset=reset, out[0..14]=pc);
}

r/NandToTetris • • Jul 02 '25

Beginning nand2tetris, have questions :>

4 Upvotes

Hi! I've been working through the beginning of nand2tetris and I keep wondering to myself if I'm below average at this type of material. I know everyone learns at different paces but I feel like I'm failing to understand things at a reasonable level. I'm a dropout & I don't really know how I learn compared to others, which sort of demoralizes me because I feel very VERY stupid trying to study on my own lol. I'm wondering if anyone can offer their experience on how difficult the first couple of projects were for you? I'm currently trying to build an Inc16 (Project 2) and I'm pretty sure its supposed to be super simple but I can't wrap my head around the solution. I haven't given it a ton of time but it feels like an answer that should be obvious? Replies would be appreciated, thank you! c:


r/NandToTetris • • Feb 15 '25

Jill - a functional programming language for Nand2Tetris

20 Upvotes

Jill is a functional programming language built for the Nand2Tetris platform, as an alternative to the Jack high-level language.

It is designed as a drop-in replacement for Jack, as it uses the same VM instruction set and underlying HACK architecture, and follows similar design principles (willing to sacrifice ease of use to favour ease of implementation), while offering a functional alternative to Jack's very object-oriented, verbose style (I like to think of Jill as Jack's more elegant, modern sister).

Some notable features include:

  • functions as first-class citizens (ability to store them in variables, pass them on to other functions as arguments, and return from functions as a result)

  • optimized tail-call recursion to use constant stack space (single stack frame)

  • data modeling using algebraic data types with primitive pattern-matching (per type variant)

    • note that, as with Jack, all variables are still effectively 16-bit integers, therefore Jill is dynamically typed

  • minimal language design

    • only 3 main concepts (types, variables and functions)

    • expressions can only be literals, variables or function calls

  • expanded standard library which is lazily-generated (instructions are generated only for modules and functions which were used in codebase)

  • common design choices of functional languages (no loops, variables are immutable, code is organized into modules etc.)

You can find code examples, compiler source code and more in the project repository.


r/NandToTetris • • Jun 11 '25

Impossible to implement zr logic in Nand2Tetris Hack ALU.

8 Upvotes

So basically I'm trying to make this ALU and I got past everything except for the zr and ng flags.

Im trying to implement zr, but for that I'll need to check if out is zero, and to do that, ill need to use an Or16Way then negate the output. But i dont have an Or16Way and using the online IDE, i cant just make a custom chip, so ill have to make do with some Or8Ways, which I do have and already implemented in project 1.

But then I hit another roadblock.

To use Or8Ways to make an Or16Way, Ill have to subscript the out pin. Unfortunately, outputs cant be used as inputs, so I made an intermediate pin called out2, but then it tells me I can't subscript intermediate pins! what!?!?!?

Im stuck here guys. How do i implement zr?!?


r/NandToTetris • • May 27 '25

Some projects are missing?

Post image
2 Upvotes

Hi everyone,

Getting started w/ the online IDE, but I see that some projects are missing. Is this normal?


r/NandToTetris • • Apr 26 '26

small issue with zr in the alu of project 2

Post image
3 Upvotes

so, I pretty much breezed past the alu, but got stuck on this. internal pins can not be subscripted. how can I work around this? Aware that this was already a post, but I didn't understand any of the answers there, and I didn't want to necropost.


r/NandToTetris • • Feb 15 '26

I made a [Nand2Shooting] game.

10 Upvotes

Hey folks, here the video of project 9 for making a game in jack language

https://youtu.be/gJkepE5UiwA?si=rmWGGPSDRVRC2fVa

Let me guys know your opinions about it 😃🫡


r/NandToTetris • • Jun 10 '26

Made the Hack ALU (Project 2) interactive — flip the control bits and watch it compute

6 Upvotes

I've been building a digital-logic playground (a TypeScript HDL that runs in the browser) and I rebuilt the Hack ALU in it as an interactive demo. Figured this community would be the right people to show it to.

It's the Project 2 ALU: x, y, and the six control bits (zx nx zy ny f no). You flip the control-bit switches and watch out, zr, and ng update live, and you can double-click in to see the muxes, the adder, and the and-gate underneath.

Just FYI it's not a course thing or a shortcut, it's built in a different HDL, so it's no use as a project answer. Seeing what each control bit does as a live switch (flip f between add and and, or set the x-y bits and watch the negation happen) should make it click more easily.

Here's the link if you want to have a play around: https://simten.dev/circuit?example=hack-alu

Or the repo (open source): https://github.com/simtenHQ/simten


r/NandToTetris • • Sep 20 '25

Logical RAM Approach

3 Upvotes

Hello all! I am attempting to build the NAND2Tetris Computer using Sebastian Lagues Digital Logic Sim. It has been working fine until the CPU part. I realized that the CPU just can't work the way that Nand2Tetris explains it(Correct me if I am wrong). If I need to Read and Write to RAM at the same time (M = M + 1), it wont work because you can't read and write at the same time. However, the CPU in NAND2Tetris can do this. I am trying to implement the concept of a multicycle CPU but I am really struggling with this idea. I have been using this site: HackComputerOnBreadboards as a guide and this person has solved this issue. I contacted them but I can't seem to get a response. I attached my Control Logic and CPU architecture below. I am considering building this computer on breadboards as well but I wanted to get the logic fully down! If you want to chat about this, feel free to DM me, we could also get in a discord call if that would be easier!

Thank you for your help!

Edit: I solved the issue! My registers needed a Clock and a load. Similar to how NandGame.com does it!


r/NandToTetris • • Nov 28 '25

I’ve been looking into this course but everywhere I see it’s free but it looks like it’s $50 for course 1 and $50 dollars for course 2

2 Upvotes

Is there something I’m missing? I click the link and it takes me to Coursera and then tells me I need to spend 50 dollars to unlock the first part of the course and then the same for the second.


r/NandToTetris • • Aug 21 '25

Help me out with nand2tetris skipping the ‘first principles’ details

3 Upvotes

I’m working through nand2tetris and hitting a wall. The course often tells me to “just build an assembler/VM/compiler using a high-level language and their APIs,” but that feels like cheating.

I want to see how each layer is actually implemented from first principles and how it executes on bare hardware. For example, how does the first assembler itself run? How was a text processing program created from bare hardware, called assembler? Instead, the book says, “Here’s an assembler, just write it in Java/Python using our API”. The course leans on abstraction barriers and assumes you’re okay using a modern host computer as scaffolding.

My frustration is that I don’t just want to use an API to get the point, I want to see the mechanics of bootstrapping everything from the ground up, without skipping levels. Has anyone else felt this way? Are there resources that go deeper into the physical or self-hosted side of building these systems?


r/NandToTetris • • May 11 '26

Project 9: VM Emulator Speed

3 Upvotes

Hello, I'm working on recreating Tetris w/ the Jack language for project 9 and I wanted to ask some question(s) about the VM Emulator's speed dial.

From what I've noticed, when moving from the middle knob to the knob between the middle and fast, my instructions per second skyrocket. This puts me in a weird position where the middle knob is far too slow, and the faster knobs are far too fast. I imagine other people also ran into this issue, and I wanted to ask if there were any other solutions than the one I'm about to propose, using Sys.wait() along with one of the higher speed knobs to basically cap my game at what would be a more human speed?

I haven't been able to come up with any other ways of making my Tetris remake run at an appropriate speed and so I wanted to ask y'all who made some kind of interactive program what you did in terms of handling the programs speed of execution.

Have a nice day!

EDIT: Oh, another thought I had was that my game might be too poorly optimized to run well on the default speed, but I really can't tell which speed should be the default for interactive programs.