Week 22/24 Assessed Coursework

C/DEBUGGING

Deadline Friday Week 24 (14/5/21, 16:00)


In week 20, you worked on the task of implementing a C function which translates MIPS assembly code into bytecode. You task for the SCC.150 week 24 coursework is to extend the code and implement an exec_bytecode function, to complete your MIPS CPU emulator. The function should read the bytecode generated by the make_bytecode function and stored in the integer array text. Your program should unmarshal 32-bit instructions and modify appropriately the state of the registers contained in the registers integer array and the pc global variable. Your implementation should support the following instructions:

NOP - no operation, ADD - addition, ADDI – addition immediate ,

ANDI - bitwise immediate and, SRL - shift right logical, SLL - shift left logical,

BEQ - branch on equal, BNE - branch on not equal

Your implementation should manipulate the pc register value and emulate addresses in the text memory area (0x00400000 – 0x1001000, start from address 0x00400000) and should provide a way to terminate the execution of a program (e.g. nop instruction).


Important notes:

• Marks will be awarded only for the exec_bytecode function implementation and any new functions that you will define/implement to improve code readability.

• You should use the update template, which can be found at https://modules.lancaster.ac.uk/draftfile.php/465779/user/draft/55386476/emulator_w24. zip to implement your solution, which contains a correct implementation of the make_bytecode code.

Figure 1 Output of the MIPS emulator when running the Ethiopean multiplication algorithm with input the number 5 and 5. 


Marking Scheme

  Aspect
  Weighting
  Functionality
  60%
  Code elegance, clarity, organization
  30%
  Self-marking
  10%


Functionality

A+
  Registers are handled correctly in all cases, there is a method to terminate the
  program, the emulator executes correctly complex MIPS programs.
A
  The program can parse and execute branch instructions.
B
  I-type instructions are correctly parse and executed (addi, andi).
C
  R-type instructions are correctly parsed and executed (add, srl, sll).
D
  Program is read from the int array, a loop is implemented to execute the program
  (program counter is used), code is executed based on instruction opcode and func
  fields.

(*) This is an example of a marking scenario and marks are awarded proportionally for each functionality. If you code only implements the addi and andi insutrctions and a simple loop, then you will get a C.


Comments/clarity/organization

A
  Clear structure (and helpful comments) about variable use. Well commented
  throughout. Spaced and organised for clarity. Appropriate use of function to organize
  code.
B
  Good use of comments. Reasonable organisation, can follow program reasonably well.
  Variable use is sensible.
C
  Sparse or sometimes unhelpful comments. Some consistency in use of variables.
D
  No comments. Difficult to read code.


Self-marking

A
  Clear and concise, functionality is accurate, comments reflect marking criteria
B
  List of mostly accurate grades, comments are there but not entirely clear or
  unnecessarily long, or functionality grade is slightly off
C
  Just a list of grades, mostly accurate (or close) but no explanation
D
  Just a list of grades, inaccurate