OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [lib/] [include/] [neorv32_intrinsics.h] - Diff between revs 54 and 55

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 54 Rev 55
Line 118... Line 118...
#define REG_ADDR_t3  28 /**< register 28 - according to calling convention */
#define REG_ADDR_t3  28 /**< register 28 - according to calling convention */
#define REG_ADDR_t4  29 /**< register 29 - according to calling convention */
#define REG_ADDR_t4  29 /**< register 29 - according to calling convention */
#define REG_ADDR_t5  30 /**< register 30 - according to calling convention */
#define REG_ADDR_t5  30 /**< register 30 - according to calling convention */
#define REG_ADDR_t6  31 /**< register 31 - according to calling convention */
#define REG_ADDR_t6  31 /**< register 31 - according to calling convention */
 
 
//** Construct instruction word (32-bit) for R-type instruction */
//** Construct instruction word (32-bit) for R2-type instruction */
#define CMD_WORD_R_TYPE(funct7, rs2, rs1, funct3, rd, opcode) \
#define CMD_WORD_R2_TYPE(funct7, rs2, rs1, funct3, rd, opcode) \
  ( (opcode & 0x7f) <<  0 ) + \
  ( (opcode & 0x7f) <<  0 ) + \
  ( (rd     & 0x1f) <<  7 ) + \
  ( (rd     & 0x1f) <<  7 ) + \
 
  ( (funct3 & 0x1f) << 12 ) + \
  ( (rs1    & 0x1f) << 15 ) + \
  ( (rs1    & 0x1f) << 15 ) + \
  ( (rs2    & 0x1f) << 20 ) + \
  ( (rs2    & 0x1f) << 20 ) + \
  ( (funct7 & 0x7f) << 25 ) + \
  ( (funct7 & 0x7f) << 25 )
  ( (funct3 & 0x1f) << 12 )
 
 
//** Construct instruction word (32-bit) for R3-type instruction */
 
#define CMD_WORD_R3_TYPE(rs3, rs2, rs1, funct3, rd, opcode) \
 
  ( (opcode & 0x7f) <<  0 ) + \
 
  ( (rd     & 0x1f) <<  7 ) + \
 
  ( (funct3 & 0x1f) << 12 ) + \
 
  ( (rs1    & 0x1f) << 15 ) + \
 
  ( (rs2    & 0x1f) << 20 ) + \
 
  ( (rs3    & 0x1f) << 27 )
 
 
//** Construct instruction word (32-bit) for I-type instruction */
//** Construct instruction word (32-bit) for I-type instruction */
#define CMD_WORD_I_TYPE(imm12, rs1_f5, funct3, rd, opcode) \
#define CMD_WORD_I_TYPE(imm12, rs1_f5, funct3, rd, opcode) \
  ( (opcode & 0x7f)  <<  0 ) + \
  ( (opcode & 0x7f)  <<  0 ) + \
  ( (rd     & 0x1f)  <<  7 ) + \
  ( (rd     & 0x1f)  <<  7 ) + \
 
  ( (funct3 & 0x1f)  << 12 ) + \
  ( (rs1_f5 & 0x1f)  << 15 ) + \
  ( (rs1_f5 & 0x1f)  << 15 ) + \
  ( (imm12  & 0xfff) << 20 ) + \
  ( (imm12  & 0xfff) << 20 )
  ( (funct3 & 0x1f)  << 12 )
 
 
//** Construct custom R3-type instruction (4 registers, funct3, opcode) */
 
#define CUSTOM_INSTR_R3_TYPE(rs3, rs2, rs1, funct3, rd, opcode) \
 
  asm volatile (".word "STR(CMD_WORD_R3_TYPE(GET_REG_ADDR(rs3), GET_REG_ADDR(rs2), GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
 
 
//** Construct custom instruction for R-type instruction */
//** Construct custom R2-type instruction (3 registers, funct3, funct7, opcode) */
#define CUSTOM_INSTR_R_TYPE(funct7, rs2, rs1, funct3, rd, opcode) \
#define CUSTOM_INSTR_R2_TYPE(funct7, rs2, rs1, funct3, rd, opcode) \
  asm volatile (".word "STR(CMD_WORD_R_TYPE(funct7, GET_REG_ADDR(rs2), GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
  asm volatile (".word "STR(CMD_WORD_R2_TYPE(funct7, GET_REG_ADDR(rs2), GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
 
 
//** Construct custom instruction for R1-type instruction (register + 5-bit immediate/function_select) */
//** Construct custom R1-type instruction (2 registers, funct3, funct7, funct5, opcode) */
#define CUSTOM_INSTR_R1_TYPE(funct7, funct5, rs1, funct3, rd, opcode) \
#define CUSTOM_INSTR_R1_TYPE(funct7, funct5, rs1, funct3, rd, opcode) \
  asm volatile (".word "STR(CMD_WORD_R_TYPE(funct7, funct5, GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
  asm volatile (".word "STR(CMD_WORD_R2_TYPE(funct7, funct5, GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
 
 
//** Construct custom instruction for I-type instruction */
//** Construct custom I-type instruction (2 registers, funct3, imm12, opcode) */
#define CUSTOM_INSTR_I_TYPE(imm12, rs1, funct3, rd, opcode) \
#define CUSTOM_INSTR_I_TYPE(imm12, rs1, funct3, rd, opcode) \
  asm volatile (".word "STR(CMD_WORD_I_TYPE(imm12, GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
  asm volatile (".word "STR(CMD_WORD_I_TYPE(imm12, GET_REG_ADDR(rs1), funct3, GET_REG_ADDR(rd), opcode))"\n");
/**@}*/
/**@}*/
 
 
#endif // neorv32_intrinsics_h
#endif // neorv32_intrinsics_h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.