[Spike] Fix of the custom instruction CUS_ADD:

* Spike was deconding CUS_ADD even if func7 was not equal to 0.
  A test was added so now it will raise an illegal instruction.

Signed-off-by: Jules Fauchon <jules.fauchon@thalesgroup.com>
This commit is contained in:
Jules Fauchon 2023-07-17 16:43:32 +02:00
parent 778a20bf18
commit 11a8df9aa3

View file

@ -135,16 +135,28 @@ class cvxif_t : public cvxif_extn_t
break;
case FUNC3_1:
//Actually only CUS_ADD using func3 equal to one, we don't need to add another switch case
return (reg_t) ((reg_t) RS1 + (reg_t) RS2);
switch(r_insn.funct7) {
case 0:
return (reg_t) ((reg_t) RS1 + (reg_t) RS2);
break;
default:
illegal_instruction();
}
case FUNC3_2:
//Actually only CUS_EXC using func3 equal to one, we don't need to add another switch case
if (r_insn.rs2 != 0 || r_insn.rd != 0){
illegal_instruction();
} else {
raise_exception(insn, (reg_t) (r_insn.rs1));
}
break;
switch (r_insn.funct7) {
case (0x60):
if (r_insn.rs2 != 0 || r_insn.rd != 0){
illegal_instruction();
} else {
raise_exception(insn, (reg_t) (r_insn.rs1));
}
break;
default:
illegal_instruction();
}
default:
illegal_instruction();
}