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.

  1. Load the hex binary into your instruction memory starting at instruction memory location 0.
  2. Load the program input into data memory starting at data memory location 10.
  3. Initialize all constant registers and "implicit" registers as needed to their appropriate values.
  4. Set the start PC to address 0.

These are the steps your emulator needs to perform for Execution

  1. Fetch - fetch/read the 8-bits at the current PC
  2. 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.
  3. Execute - execute the instruction reading the corresponding register and memory data structures.
  4. Mem/Reg Writeback - after you are done executing the instruction update/write the register and data memory as required for that instruction.
  5. 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.
  6. 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