Compare commits

..

1 Commits

Author SHA1 Message Date
98f2b5e554 feat: add custom b-type instruction (jump) 2026-05-13 16:46:25 +02:00

View File

@@ -98,6 +98,18 @@ inline void tinyriscv_custom_I_type(const u8 funct3, const u8 funct7, u32* x,
}
}
////////////////////////////////////////////////////////////////////////////////
__attribute__((always_inline))
inline void tinyriscv_custom_B_type(const u8 funct3, const u32* x, u32* pc,
const u8 rs1, const u8 rs2, const i16 imm){
switch(funct3){
case /*CUSTOM bitcomp*/ 0: if((x[rs1] ^ 0x7C) != x[rs2]) *pc += (i32)imm - 4; break;
}
}
////////////////////////////////////////////////////////////////////////////////
__attribute__((always_inline))
@@ -213,6 +225,9 @@ void tinyriscv_step(tinyriscv_core* core){
case /*Custom-I-type*/ 0x0B:
tinyriscv_custom_I_type(funct3, funct7, core->x, rd, rs1, imm_i, rs2);
break;
case /*Custom-I-type*/ 0x2B:
tinyriscv_custom_B_type(funct3, core->x, &core->pc, rs1, rs2, imm_b);
break;
case /*R-type*/ 0x33:
tinyriscv_R_type(funct3, funct7, core->x, rd, rs1, rs2);
break;