nand2tetris | Computer System Elements - Building a Modern Computer
kandi X-RAY | nand2tetris Summary
kandi X-RAY | nand2tetris Summary
Computer System Elements - Building a Modern Computer from Scratch
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nand2tetris
nand2tetris Key Features
nand2tetris Examples and Code Snippets
Community Discussions
Trending Discussions on nand2tetris
QUESTION
I followed the nand2tetris course (https://www.nand2tetris.org/course) with the main intent to learn how to build a soft processor on a real FPGA.
While the course was simple enough, now that I am starting with the FPGA implementation I feel a bit lost.
I bought an Intel de10 nano FPGA(http://de10-nano.terasic.com/), and, having some Verilog knowledge from Uni, I was able to download "Quartus Prime Lite" and bootstrap with simple things like led blinking, etc...
However, when it comes to implement the processor there are several things that are not clear to me:
- How do I implement data memory? I saw there is a DDR3 module attached to the HPS of the FPGA. Is this something I need to directly use? Could I simply use a big 16bit register vector in HDL?
- How do I implement the ROM from where the program is read? And how can I store the binary I assembled to then bootstrap the fetch-decode-execute loop?
- How do I implement the screen and the keyboard? Indeed, there is also an HDMI controller on the board: do I have to implement all the logic myself?
Those are the main questions I am struggling with at the moment. Could you point me out to any resource useful for a complete novice?
Thanks,
...ANSWER
Answered 2021-Mar-16 at 16:41For something as simple as a CPU from nand2tetris you'll be just ok with block RAMs, there's plenty of it on DE10Nano, likely enough for all your needs. Plus some more distributed memory.
In case if you still want an access to DDR, DE10Nano is an SoC, with a hard DDR controller managed by the processor subsystem. It's very easy to interface with it over an Avalon bus (don't bother with AXI unless you really need maximum possible performance).
For the ROM, just use LUTs. A simple static case in Verilog will be translated into an efficient LUT-based ROM.
For accessing HDMI on DE10Nano, you can take a look at this example: https://github.com/combinatorylogic/soc/blob/a1d282d793548030cba940496bed90ff3a29c0ba/backends/c2/hw/de10nano/vga1080p.v (you can also take a look at the DDR access in the same project). Before you can use HDMI you'll need to set up the ADV7513 chip over i2c, see a copy of a library from Terasic under the same project.
For a monochrome 800x600 video you'll be ok with a block RAM. For higher resolutions, as in the example above, you'll have to use DDR.
QUESTION
I am taking the nand2tetris coursera course. I am trying to understand how you guys, can design the underlying mental process of finding the HDL core parts. For exemple, let's take the DMUX4way. What is the complete mental process to achieve the parts? I understand the logic behind once I see the result but I have difficulties to find out by myself Thanks
...ANSWER
Answered 2021-Feb-25 at 01:03I find that it helps to break things down, and in complex situations, write down the truth table for the various signals (including the intermediate signals). Sometimes this will lead to an "aha" moment where you see a connection you can use to simplify things.
You may also find it helpful to draw a graph that maps the flow of the signals through the circuit.
Finally, the adage that "first make it work, then make it pretty" applies. Once you have something working, you can look at the design and find simplifications and optimizations. A good example of this is building the XOR circuit. Once you have the straightforward version, if you look at it hard, you can find the clever optimization.
I suppose it is just one of those things where you have to practice until you get the knack of it. You may find it useful to revisit earlier projects with an eye to making them cleaner and easier for you to understand. There are often several ways to build the required circuit, but some ways may be more comprehensible to you. Also, I would recommend you get in the habit of commenting your designs; it is helpful to have a reminder what you were thinking when you did something.
QUESTION
I'm currently working on the last project in Nand2Tetris course.
I've been trying to figure out how the logic expression works while implementing a bit-wise calculation.
How Python can catch the right digits of 16-bit binary that correspond to an integer y
when the twoToThe[i] == 0
(5 is 101 in binary, thus twoToThe[0] == 0
and twoToThe[2] == 0
are False
and it's the right answer)
but why does not show the exact opposite result when twoToThe[i] == 1
?
I thought it would return True
on both twoTwoThe[0] == 1
and twoTwoThe[2] == 1
Here's code below
...ANSWER
Answered 2021-Feb-04 at 09:24The y & twoToThe[0]
expressions evaluates to a new integer (as a result of a bitwise and operation between the bits of 5
and the bits of twoToThe[i]
), not to a boolean as I think you were expecting. Check it:
QUESTION
I'm implementing the nand2tetris Assembler in C++ (I'm pretty new to C++), and I'm having a lot of trouble parsing a C-instruction using regex. Mainly I really don't understand the return value of regex_search
and how to use it.
Setting aside the various permutations of a C instruction, the current example I'm having trouble with is D=D-M
. The result should have dest = "D"; comp = "D-M"
.
With the current code below, the regex appears to find the results correctly (confirmed by regex101.com), but, not really correctly, or something, or I don't know how to get to it. See the debugger screenshot. matches[n].second
(which appears to contain the correct comp
value) is not a string but an iterator.
Note that the 3rd capture group is correctly empty for this example.
...ANSWER
Answered 2021-Jan-16 at 00:05gcc warns about unknows escape sequence \-
Demo.
You have to escape \
,
QUESTION
I'm tryng to build this chip:
...ANSWER
Answered 2021-Jan-12 at 20:15Your logic for selecting what input to pass through appears to be incorrect. You should test it by creating a truth table for finalSel, notFinalSel, aAndB, cAndd and out for each of the 4 control conditions.
In general, when doing these kinds of problems, the KISS principle holds; Keep It Simple and Stupid. You don't need any fancy logical manipulation of your sel[] bits, you can just use them directly. So once you get your version fixed (and understand where you went wrong), try doing a version that just consists of 3 Mux16's and nothing else. Once you have both versions working, you'll then understand the error that caused you to go down the wrong path in your first attempt, and that will be a valuable lesson going forward.
Have fun!
QUESTION
ANSWER
Answered 2020-Dec-15 at 00:33There are 2 main parts to consider here:
call foo 2
: this instruction tells vm to call funcionfoo
that takes 2 arguments ( which should be pushed on top of the stack before this call ).
Calling any function means that you should take these steps as follow: push return address on top of stack (SP++), then push LCL, ARG, THIS,THAT ( SP+4). At this point SP should equal 310.function foo 4
: this is NOT the first instruction in functionfoo
, but still it has an effect on SP as this means that functionfoo
has 4 local variables. And these variables must be located somewhere. Where? On top of the stack. This means that before first 'real' instruction offoo
gets executed, we must push 4 values onto the stack. What values? Well - according do vm specification it should be0
's, resulting in local variables being initiated to 0. This also means that we increase SP for every local variable ( SP + 4)
This leads to conclusion that SP, after calling foo
but before executing 1st instruction of this function will have value of 314.
QUESTION
Not mentioning much about the Nand2tetris course and uploading the assembly file which interacts with the keyboard.
Basically what this program does is when a key is pressed on the keyboard the screen turns black i.e. every pixel of the screen is supposed to turn black and when the keyboard is idle the screen stays white .
Here is my code and it works well on my computer's hardware simulator but fails when I upload it for submission on coursera.
...ANSWER
Answered 2020-Nov-23 at 01:34I'm sorry, but the solution you posted does not solve the problem. I think this is why coursera is rejecting it.
When I run your solution through an assembler and then a cpu emulator I do not see the behavior required of Fill.asm
. I'm comparing your solution to a solution I know to be correct and I am seeing different behavior.
Here's a screenshot of the cpu emulator while pressing the keyboard using your solution:
Here's what I expect to see:
I suggest reviewing your solution.
Hint Something missing from your solution is code to fill the screen.
Here's why I think it's missing:
- Line 19
M=0
of your solution is where I believe the color is set to white - I change line 19 to
M=-1
, setting the white color to black - I expect to see the screen always painted black, but instead, I see only a small line of black in the top left corner of the emulator screen as seen below
Hint: You have one loop ((LOOP)
) that repeatedly listens for the keyboard. I expect to see another loop ((FILL)
, or whatever) which fills the entire section of memory dedicated to the SCREEN
with white or black.
Good luck.
QUESTION
I'm having trouble interpreting and debugging the valgrind output for a C program I just finished from an online course (nand2tetris) that is now functioning as expected. Here is a link to the source code: https://github.com/salario/nand2tetris/blob/master/assembler.c
Here is the output from valgrind showing the possibly lost memory leak message. I compiled using this command: cc -g -o assembler assembler.c
ANSWER
Answered 2020-Jul-26 at 06:59These memory leaks are from the runtime, like /usr/lib/system/libdispatch.dylib
, /usr/lib/libSystem.B.dylib
, /usr/lib/dyld
.
I ran your program on linux (valgrind --leak-check=full ./a.out Pong.asm
):
QUESTION
I am doing a parser for nand2tetris project. I want to check if the destination field is either M|D|MD|A|AM|AD|AMD
and their different ways of combinations like MA
not only AM
.
ANSWER
Answered 2020-Mar-07 at 08:47This should do it:
QUESTION
I am trying to implement a MUX (Multiplexor) gate in the nand2tetris course. I first tried myself, and I got an error. But no matter what I changed I always got the error. So I tried checking some code online, and this is what most people use:
...ANSWER
Answered 2020-Jan-13 at 22:56From what can be seen your input pins are:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nand2tetris
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page