Closed mossprescott closed 4 years ago
When you say "compiler" do you mean Python interpreter or combination of Python interpreter + underlying Python code you wrote here?
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.
clock
as a special signal, available to all components, with operationstick()
andtock()
to update it and propagate statelazy()
creating forward references when building components, so that circular references can be createdsorted_nodes
to not be O(n^2) so it all actually worksinternal()
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