mossprescott / pynand

Nand2Tetris in Python.
Other
12 stars 4 forks source link

Project 3 components, up to RAM64 #10

Closed mossprescott closed 4 years ago

mossprescott commented 4 years ago

With all that, DFF can be implemented from nands, and the components of project #3 can be implemented on top of that.

A simple test for each RAM is here; I didn't try to translate the original test suite, which is getting tedious. Nevertheless, the tests could be stronger.

Currently the compiler is taking ~25 seconds to translate RAM64 into the bit vector representation. After that, individual operations are reasonably fast (~50ms per clock), even though each step is now copying a vector of about 17k bits. This clearly isn't going to scale to larger memories, so a new approach will be needed to get further.

cc @dfithian

dfithian commented 4 years ago

When you say "compiler" do you mean Python interpreter or combination of Python interpreter + underlying Python code you wrote here?

mossprescott commented 4 years ago

The "compiler" is the code in compiler.py that translates a graph of components into the new NandVector representation which is efficient to evaluate.

That code is very clearly the bottleneck at this point. I have a couple of ideas for making it better, and hopefully one of them pans out because at this point a 64-word memory is slightly beyond the limit of usability.