add custom instruction
This commit is contained in:
@@ -89,6 +89,17 @@ inline void tinyriscv_I_type(const u8 funct3, const u8 funct7, u32* x,
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
__attribute__((always_inline))
|
||||||
|
inline void tinyriscv_custom_I_type(const u8 funct3, const u8 funct7, u32* x,
|
||||||
|
const u8 rd, const u8 rs1, const i16 imm, const u8 shamt){
|
||||||
|
|
||||||
|
switch (funct3) {
|
||||||
|
case /*CUSTOM XOR*/ 0: x[rd] = ((x[rs1] << (i32)imm) ^ 0xFF) >> (i32)imm; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline))
|
||||||
inline void tinyriscv_R_type(const u8 funct3, const u8 funct7, u32* x,
|
inline void tinyriscv_R_type(const u8 funct3, const u8 funct7, u32* x,
|
||||||
const u8 rd, const u8 rs1, const u8 rs2){
|
const u8 rd, const u8 rs1, const u8 rs2){
|
||||||
@@ -199,6 +210,9 @@ void tinyriscv_step(tinyriscv_core* core){
|
|||||||
case /*I-type*/ 0x13:
|
case /*I-type*/ 0x13:
|
||||||
tinyriscv_I_type(funct3, funct7, core->x, rd, rs1, imm_i, rs2);
|
tinyriscv_I_type(funct3, funct7, core->x, rd, rs1, imm_i, rs2);
|
||||||
break;
|
break;
|
||||||
|
case /*Custom-I-type*/ 0x0B:
|
||||||
|
tinyriscv_custom_I_type(funct3, funct7, core->x, rd, rs1, imm_i, rs2);
|
||||||
|
break;
|
||||||
case /*R-type*/ 0x33:
|
case /*R-type*/ 0x33:
|
||||||
tinyriscv_R_type(funct3, funct7, core->x, rd, rs1, rs2);
|
tinyriscv_R_type(funct3, funct7, core->x, rd, rs1, rs2);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user