I need help to solve a project from CDA 3103 CDA3103 – Computer Logic and Organization Project Description 1. Introduction In this project, you are


The instruction is an R-type instruction

3.     Return 1 if a halt condition occurs; otherwise, return 0.

·                           read_register(…)

1.     Read the registers addressed by r1 and r2 from Reg, and write the read values to data1 and data2 respectively.

·                           sign_extend(…)

1.     Assign the sign-extended value of offset to extended_value.

·                           ALU_operations(…)

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.

·                           rw_memory(…)

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.

·                           write_register(…)

1.     Write the data (ALUresult or memdata) to a register (Reg) addressed by r2 or r3.

·                           PC_update(…)

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.