Questions tagged [nand2tetris]

For questions regarding the Nand2Tetris course assignments (and the accompanying book "The elements of computing systems") by Shimon Schocken and Noam Nisan. Including the Hack assembly language, the Jack VM and high level languages.

The Nand2Tetris course teaches how to build a modern computer from the first principles, and can be taken by each person with some programming knowledge in any language. All the CS related materials are taught and explained during the course.

The course can be taken in Coursera, and has two parts:

It has an accompanying software that can be found on the website, and a book named The Elements of Computing Systems: Building a Modern Computer from First Principles.

See also: Nand2Tetris forum

116 questions
0
votes
1 answer

D register is not updated, why is that?

To replicate the cpu.out file shown below (though without my comments), use this cpu.hdl, which passes all the tests. Now, my question is, at clock cycle 3+, 4, and 4+. Notice that DRegise (D register) is not updated, despite the command was…
xing Zì
  • 391
  • 4
  • 16
0
votes
1 answer

"Expression Expected" error on line 1. How to fix it?

I am getting the "In line 1, expression expected" error and I am not sure why. I am using the CPU Emulator from nand2tetris. I tried changing line 1 to 5, but it did not solve the problem. I just do not get what is the problem in the first place.…
Lili V.
  • 51
  • 1
  • 11
0
votes
3 answers

Subtraction implementation in Nand2tetris

I am currently working through Nand2tetris for an university course and it's mostly straightforward. But the alu can do subtraction in a single step and I absolutely do not understand how this works. opMinus = addition <> notX <> notOut I couldn't…
Taren
  • 674
  • 5
  • 11
0
votes
0 answers

Comparison Failure of Negative Numbers

The question I need answered is, why is there a comparison failure at line 9 but not at line 8? 2nd question: How could I fix this to support the multiplication of negative values? The program multiplies R0 and R1 and stores the result in R2. (R0,…
0
votes
1 answer

Mult.asm Comparison Failure

The question I need answered is, why is there a comparison failure at line 9 but not at line 8? I am new to Hack assembly language and am still learning the basics but am confused as to why the CPU Emulator would pass line 8 but not line 9. 2nd…
0
votes
1 answer

16-bit CPU design: Issues with implementing fetch-execute cycle

I am doing a computer architecture course on Coursera called NandtoTetris and have been struggling with my 16-bit CPU design. The course uses a language called HDL, which is a very simple Verilog like language. I have spent so many hours trying to…
0
votes
3 answers

Implementation of an AND chip in HDL

I'm working through this book http://nand2tetris.org/book.php that teaches fundamental concepts of CS and I got stuck where I'm asked to code an AND chip and test it in provided testing software. This is what I've got so far: /** * And gate: *…
Mark Alexa
  • 125
  • 2
  • 9
0
votes
1 answer

Nand2Tetris Jump Directive Excpected

I'm translating from .vm code to .asm code for project 7 but when I try to run the output code I get the error "in line 17, Jump directive expected" @7 D=A @255 M=D @8 D=A @256 M=D @256 D=M @255 M=M+D …
0
votes
1 answer

Logic Gates - Dmux (nand2tetris)

I'm just started to take the nand2tetris course ! In the first project, it's demanded to build logic gates with "Nand" starting with "Not". Well, it was easy at the beginning, building or, and, xor. But then came "Multiplexor". It took me a while…
log101
  • 17
  • 7
0
votes
1 answer

Nand to Tetris: string equality test isn't working

This is outputting false instead of true. Why is this? class Main { function void main() { var String foo; let foo = "bar"; if (foo = "bar") { do Output.printString("true"); } else { do…
Adam Zerner
  • 17,797
  • 15
  • 90
  • 156
0
votes
1 answer

Nand To Tetris (Jack): Simple if conditional with equality testing giving this error - "Expected - or ~ or ( in term"

class Main { function void main() { var String foo; let foo = "bar"; if (foo == "bar") { do Output.printString("true"); } else { do Output.printString("false"); } return; } } I get the error: Expected -…
Adam Zerner
  • 17,797
  • 15
  • 90
  • 156
0
votes
0 answers

Matching similar terms in ANTLR without capturing difference

As part of the nand2tetris challenge I'm trying to write a parser using ANTLR to generate machine code, having already implemented it using regex. However, I'm struggling to work out how to use ANTLR effectively. A subset of the problem is…
ginglymus
  • 51
  • 7
0
votes
1 answer

Nand2tetris ALU implementation without using Muxes

i am trying to implement Hack ALU without using muxes but i cant upload the hdl into the simulator. Any help would be appreciated. Thanks CHIP ALU { IN x[16], y[16], // 16-bit inputs zx, // zero the x input? …
0
votes
1 answer

NAND2Tetris VM Translator

If the pointer to the next location in the stack is raved in Ram[SP]/[0], How do I instruct the computer in hack to open the location? I have tried @0 D=M @D but it isn't opening the address in stored in Ram[0] How do I make it access the ram…
0
votes
1 answer

DFF in verilog with a delay

I'm trying to implement the nand2tetris project in verilog and am hitting a wall using icarus verilog. In the book they implement the DFF as so, q(t) = d(t-1). The output at the current time is the input at the previous posedge clk. Here is the DFF…
greut
  • 4,305
  • 1
  • 30
  • 49