Emulator Steps
These are the steps your emulator needs to perform for Initialization
Note: These won't be done in exactly this way in your final processor design -- more on that later. But your processor will already have the instruction and data memories "loaded" with the program binary and data, respectively. We'll do that here in the emulator by loading the instruction and data "memories" from files.
- Load the hex binary into your instruction memory starting at instruction memory location 0.
- Load the program input into data memory starting at data memory location 10.
- Initialize all constant registers and "implicit" registers as needed to their
appropriate values.
- Set the start PC to address 0.
These are the steps your emulator needs to perform for Execution
- Fetch - fetch/read the 8-bits at the current PC
- Decode - look at the correct bits for your ISA to determine the opcode.
Once the opcode is determined the rest of the bits are used as needed to
determine what registers, immediate, or offsets to use.
- Execute - execute the instruction reading the corresponding register and
memory data structures.
- Mem/Reg Writeback - after you are done executing the instruction update/write
the register and data memory as required for that instruction.
- Set Next PC - If instruction is NOT a branch set PC to PC+1. If the instruction
is a branch set PC to PC+1 if not-taken, otherwise set PC to target
instruction of the branch.
- Go back to step 1, until you hit the halt instruction in your binary.
After the binary is done executing, write the COMPLETE CONTENTS OF DATA MEMORY to the output file.
The following are some points to keep in mind
- Remember that the instruction and data memory are *separate* memories.
So address 0 of instruction memory is different than address 0 of data memory.
- You can only read or write (not both) 8-bits to data memory per cycle
(so also per instruction).
- See the turn in instructions for the list of flags your emulator needs to support (to indicate input and output files, etc).