This Machine simulator allows the user to run an arbitrary machine contains any number of adders, multipliers and registers with changeable cycle time for the adders, multipliers and the instruction unit. It has a code editor that allows you to write code for the machine, save that code and load it again. The simulator also allows you to step through a program one cycle at a time or have the machine auto run.
The program can be run by typing "java -jar MachineSimulator.jar" in your command line.
A precompiled binary is already included with the source so there is no need to compile. But if you with to compile the source code you need to download the Gradle from http://www.gradle.org/. Once installed run "gradle build" from your command line, the jar file will be at "build/libs/a2.jar".
It should be possible to import the project into Eclipse and run it from there. But why would anyone want to do that?
This panel contains all the options for the machine. The options "Adders", "Multipliers" and "Registers" determine how many of those components exist in the machine. The options "Adder Cycles", "Multiplier Cycles" and "IU Cycles" determines how many cycles each of those components take to run. The last option is the "Cycle Time" options which lets you set how long in milliseconds each cycle takes when running in Auto Mode.
The editor panel is where you enter the program to be run on the machine. You can load a program into the editor by clicking the "Load" button and selected a valid program file. Once you have entered a program you can save it to a file using the "Save" button. The "Clear" button will clear the program input area. The final operation you can perform in this area of the GUI is the "Run" operation. This will create the Machine described in the options and load the program in the editor into memory.
The graph panel's main purpose is to display a graph of operations per cycle. The "Auto Next" button will auto run the machine performing one cycle at a time. The "Pause" button will pause the machine when running in auto mode. The "Next" button will run the next cycle of the machine. Lastly, the "Stop" button will stop the running of the machine and unload the program from memory. Once stopped you are an able to continue execution of the machine from where it left off.
The machine uses a very simple programming language that only contains two operations. Instruction are in the form "inst rd rs rt" where inst is replaced with one of "add" or "mul", rd is the result register number and rs and rt are the source register numbers.
Example:
add 1 4 5 mul 5 3 7