Added CSRRC/CSRRCI

master
vhaudiquet 11 months ago
parent c404defb42
commit 6c5e3fcc32
  1. 8
      src/cpu/rv32cpu.c

@ -556,7 +556,9 @@ static void cpu_execute(rv32_cpu_t* cpu, instruction_t* instruction)
cpu->csr[instruction->immediate] |= cpu->regs.x[instruction->rs1];
break;
case FUNC3_CSRRC:
fprintf(stderr, "CSRRC\n");
// CSR atomic Read and Clear bits
cpu->regs.x[instruction->rd] = cpu->csr[instruction->immediate];
cpu->csr[instruction->immediate] &= (~cpu->regs.x[instruction->rs1]);
break;
case FUNC3_CSRRWI:
// CSR atomic Read/Write Immediate (immediate in rs1)
@ -568,7 +570,9 @@ static void cpu_execute(rv32_cpu_t* cpu, instruction_t* instruction)
fprintf(stderr, "CSRRSI\n");
break;
case FUNC3_CSRRCI:
fprintf(stderr, "CSRRCI\n");
// CSR atomic Read and Clear bits Immediate (immediate in rs1)
cpu->regs.x[instruction->rd] = cpu->csr[instruction->immediate];
cpu->csr[instruction->immediate] &= (~((uint32_t) instruction->rs1));
break;
default:
fprintf(stderr, "FATAL: Unknown func3 0x%x for SYSTEM instruction while executing\n", instruction->func3);

Loading…
Cancel
Save