Processor

Add

ld: R[rd]=M[R[rs1]+imm]

The immediate comes from our instruction into the second input of the MUX to go into the [ALU]. Add R[rs1] coming out of the register file into the ALU. The output of the ALU is the address going into the data memory. With this address We can determine which data in the memory we are going to read out. M[R[s1]+imm] this data we read out, will be sent back to the register file (use the second mux).

sd: M[R[rs1]+imm] = R[rs2]

Send the data from the register to the memory. R[s1] + imm value comes into the ALU from the register file to denerate the address, instead of reading from data memory, we write the data and storing data into the data memory. R[s2] is used to send the data into the data memory, to do a MemWrite: store data instruction. Similar to ld, but we have the data coming from R[s2] into Data memory to write data instead.