Re: Nand2Tetris CPU Emulator Clock Frequency

Posted by Gerrit0 on
URL: http://nand2tetris-questions-and-answers-forum.52.s1.nabble.com/Nand2Tetris-CPU-Emulator-Clock-Frequency-tp4034881p4035186.html

An alternative method of answering this question is - what does the OS think its clock speed is? There is a Sys.wait(ms) function that can be used to get a rough estimate, with a VM implementation available in the provided download.

Of course the estimate may vary greatly depending on the quality of your translator's optimizations...

The implementation is roughly:

def sys_wait(ms):
    if ms < 0:
        sys_error(1)
    while ms > 0:
        c = 50
        while c > 0:
            c -= 1
        ms -= 1

With my translator, optimizations on, this indicates that Sys.vm expects 1.63MHz. I don't have a good way to turn optimizations off yet, but I am almost certain that my first implementation of the translator would have indicated that Sys.vm expects 3+MHz.