You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.2 KiB
57 lines
1.2 KiB
package generic;
|
|
|
|
import processor.Clock;
|
|
import processor.Processor;
|
|
|
|
public class Simulator {
|
|
|
|
static Processor processor;
|
|
static boolean simulationComplete;
|
|
|
|
public static void setupSimulation(String assemblyProgramFile, Processor p)
|
|
{
|
|
Simulator.processor = p;
|
|
loadProgram(assemblyProgramFile);
|
|
|
|
simulationComplete = false;
|
|
}
|
|
|
|
static void loadProgram(String assemblyProgramFile)
|
|
{
|
|
/*
|
|
* TODO
|
|
* 1. load the program into memory according to the program layout described
|
|
* in the ISA specification
|
|
* 2. set PC to the address of the first instruction in the main
|
|
* 3. set the following registers:
|
|
* x0 = 0
|
|
* x1 = 65535
|
|
* x2 = 65535
|
|
*/
|
|
}
|
|
|
|
public static void simulate()
|
|
{
|
|
while(simulationComplete == false)
|
|
{
|
|
processor.getIFUnit().performIF();
|
|
Clock.incrementClock();
|
|
processor.getOFUnit().performOF();
|
|
Clock.incrementClock();
|
|
processor.getEXUnit().performEX();
|
|
Clock.incrementClock();
|
|
processor.getMAUnit().performMA();
|
|
Clock.incrementClock();
|
|
processor.getRWUnit().performRW();
|
|
Clock.incrementClock();
|
|
}
|
|
|
|
// TODO
|
|
// set statistics
|
|
}
|
|
|
|
public static void setSimulationComplete(boolean value)
|
|
{
|
|
simulationComplete = value;
|
|
}
|
|
}
|
|
|