cva6 icon indicating copy to clipboard operation
cva6 copied to clipboard

[BUG] B extension: incorrect decoding for some instructions in RV32

Open ASintzoff opened this issue 1 year ago • 2 comments

Is there an existing CVA6 bug for this?

  • [X] I have searched the existing bug issues

Bug Description

According to RISC-V ISA specification, for RV32, the bit 25 of instructions BCLRI, BINVI, BSETI, BEXTI and RORI must be equal to zero. So when this bit is set, an illegal instruction exception has to be raised.

With the current implementation, when bit 25 is set, there is no exception for RV32.

end else if (instr.instr[31:26] == 6'b010010) instruction_o.op = ariane_pkg::BCLRI;
                else if (instr.instr[31:26] == 6'b011010) instruction_o.op = ariane_pkg::BINVI;
                else if (instr.instr[31:26] == 6'b001010) instruction_o.op = ariane_pkg::BSETI;
                else illegal_instr_bm = 1'b1;
  else if (instr.instr[31:26] == 6'b010_010) instruction_o.op = ariane_pkg::BEXTI;
                else if (instr.instr[31:26] == 6'b011_000) instruction_o.op = ariane_pkg::RORI;
                else illegal_instr_bm = 1'b1;           

ASintzoff avatar Jun 20 '24 15:06 ASintzoff

I agree with the Github issue, but which specification tells us that an exception is raised when bit25 is equal to zero ?

JeanRochCoulon avatar Jun 20 '24 15:06 JeanRochCoulon

I agree with the Github issue, but which specification tells us that an exception is raised when bit25 is equal to zero ?

if the 25th bit isn't equal to zero these instruction are treated as RV64 instruction base on the RISCV bitmanip spec

AyoubJalali avatar Jun 21 '24 13:06 AyoubJalali

This needs to be checked on the Spike side as well.

zchamski avatar Jan 17 '25 08:01 zchamski

Spike has the same issue as i remember

AyoubJalali avatar Jan 17 '25 08:01 AyoubJalali

if the 25th bit isn't equal to zero these instruction are treated as RV64 instruction base on the RISCV bitmanip spec

Hi @AyoubJalali, I believe you, but for future reference, can you point of the version and section of the ISA that states this?

MikeOpenHWGroup avatar Jan 17 '25 15:01 MikeOpenHWGroup

Sorry @MikeOpenHWGroup, I should be accurate on the version of the spec I'm referring to.

I the sepc version is :

The RISC-V Instruction Set Manual Volume I Unprivileged Architecture Version 20240411 Chapter 28. "B" Extension for Bit Manipulation, Version 1.0.0

AyoubJalali avatar Jan 20 '25 11:01 AyoubJalali

The Spike side is fixed in https://github.com/openhwgroup/core-v-verif/pull/2578.

zchamski avatar Jan 23 '25 09:01 zchamski

RTL and Spike have been fixed. Close the item.

JeanRochCoulon avatar Jan 23 '25 09:01 JeanRochCoulon