It just runs as fast as it can. How fast depends entirely on your computer and what else you are running.
You can figure it out by printing out the 'time' variable to the output file at the end of a simulation and then either manually timing how long the program runs or writing a batch file that captures the time before starting the emulator and again after the emulator exits. There's some start-up and wrap-up code that pollutes the data, but if the program itself runs for a long time that will get lost in the noise.
Did you sucessfully finish your breadboard Hack-Computer? This thread is a little older, but just for the case that you're still working on it...
I have actually no idea which components you are using for your computer, but I believe that the final clock cycle you should choose will belong to the logic IC's. Maybe you should study the datasheets from the chip manufactures?
The max clock frequency will be set by the propagation delay of the longest path from any register output to any register input, taking into account the setup and hold times of the registers themselves. So the timing information in the datasheets is critical, but no where near sufficient. The logic design will have to be analyzed to first identify the critical path and then determine the worst case signal delay along that path.
Yes I understand that. I am not concerned with the maximum frequency of the circuit as I am sure that it will be higher than the clock speed of the CPU Emulator. I am just curios as to what speed the CPU Emulator runs at so when, for example, I run the Pong.asm example it doesnt run at like 10x speed or something. I am still building the circuit right now, lots of crucial bits have been completed but it is not finished.
Just for clarity because my question was not clear. I am not talking about the frequency of the circuit that I am creating, I know that is dependent on the chips that I am using etc. I was referring to the clock speed of the CPU emulator itself. I just want to know what clock to run the computer at so that the programes dont run too fast or slow. For example, if I ran the breadboard computer at 3MHz (I am just picking a number, this is on the upper range of what the chips I am using are capable of), I am sure that the Pong.asm game would be unplayably fast. Hope that explains it better.
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:
if ms < 0:
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.