BrunoLevy / learn-fpga

Learning FPGA, yosys, nextpnr, and RISC-V
BSD 3-Clause "New" or "Revised" License
2.53k stars 242 forks source link

comment/code mismatch FROM_BLINKER_TO_RISCV step 4 (?) #85

Closed wohlbier closed 1 year ago

wohlbier commented 1 year ago

Hi, I am trying to reconcile the following lines of code and comments:

      // sw x2,0(x1)
      //             imm   rs2   rs1   w   imm  STORE
      MEM[6] = 32'b000000_00001_00010_010_00000_0100011;

as compared to

   wire isStore   =  (instr[6:0] == 7'b0100011); // mem[rs1+Simm] <- rs2

My understanding of the store instruction assembly is "store the contents of register x2 to the address is register x1 adding zero offset." If I compare that to the comment // mem[rs1+Simm] <- rs2 it would seem that the values in rs1 and rs2 in the instruction are flipped. Then it seems to me that the MEM line should read

      //             imm   rs2   rs1   w   imm  STORE
      MEM[6] = 32'b000000_00010_00001_010_00000_0100011;

Do I have it right? Thanks!

BrunoLevy commented 1 year ago

You are right, thank you for noticing (fixed)