The instruction is an R-type instruction
3. Return 1 if a halt condition occurs; otherwise, return 0.
1. Read the registers addressed by r1 and r2 from Reg, and write the read values to data1 and data2 respectively.
1. Assign the sign-extended value of offset to extended_value.
1. Apply ALU operations on data1, and data2 or extended_value (determined by ALUSrc).
2. The operation performed is based on ALUOp and funct.
3. Apply the function ALU(…).
4. Output the result to ALUresult.
5. Return 1 if a halt condition occurs; otherwise, return 0.
1. Base on the value of MemWrite or MemRead to determine memory write operation or memory read operation.
2. Read the content of the memory location addressed by ALUresult to memdata.
3. Write the value of data2 to the memory location addressed by ALUresult.
4. Return 1 if a halt condition occurs; otherwise, return 0.
1. Write the data (ALUresult or memdata) to a register (Reg) addressed by r2 or r3.
1. Update the program counter (PC).
The file spimcore.h is the header file which contains the definition of a structure storing the control signals and the prototypes of the above 10 functions. The functions may contain some parameters. Read spimcore.h for more information.
Hint: Some instructions may try to write to the register $zero and we assume that they are valid.
However, your simulator should always keep the value of $zero equal to 0.
NOTE: You should not do any “print” operation in project.c. Otherwise, the operation will disturb the marking process and you will be penalized.