Documentation ¶
Overview ¶
Package decoder provides RISC-V instruction decoding methods.
Index ¶
- type Bit12
- type Funct2
- type Funct3
- type Funct5Head
- type Funct5Tail
- type Funct6Tail
- type Funct7
- type IDBuilder
- func (i IDBuilder) ID() uint32
- func (i IDBuilder) Mask() uint32
- func (i IDBuilder) WithCBit12(bit12 Bit12) IDBuilder
- func (i IDBuilder) WithCFunct2(funct2 Funct2) IDBuilder
- func (i IDBuilder) WithCFunct3(funct3 Funct3) IDBuilder
- func (i IDBuilder) WithCFunct6Tail(funct6tail Funct6Tail) IDBuilder
- func (i IDBuilder) WithCustom(match uint32, mask uint32) IDBuilder
- func (i IDBuilder) WithFunct7(funct7 Funct7) IDBuilder
- func (i IDBuilder) WithMajOp(majOp MajorOpcode) IDBuilder
- func (i IDBuilder) WithMinOp(minOp MinorOpcode) IDBuilder
- func (i IDBuilder) WithStdFunct3(funct3 Funct3) IDBuilder
- func (i IDBuilder) WithStdFunct5Head(funct5Head Funct5Head) IDBuilder
- func (i IDBuilder) WithStdFunct5Tail(funct5Tail Funct5Tail) IDBuilder
- type Immediate
- type MajorOpcode
- type MinorOpcode
- type RawInstruction
- func (r RawInstruction) CADDI16Imm() Immediate
- func (r RawInstruction) CADDI4Imm() Immediate
- func (r RawInstruction) CAFunct2() Funct2
- func (r RawInstruction) CBFunct2() Funct2
- func (r RawInstruction) CBImm() Immediate
- func (r RawInstruction) CDImm() Immediate
- func (r RawInstruction) CFunct3() Funct3
- func (r RawInstruction) CIImm() Immediate
- func (r RawInstruction) CJImm() Immediate
- func (r RawInstruction) CLDSPImm() Immediate
- func (r RawInstruction) CLQSPImm() Immediate
- func (r RawInstruction) CLUIImm() Immediate
- func (r RawInstruction) CLWSPImm() Immediate
- func (r RawInstruction) CQImm() Immediate
- func (r RawInstruction) CRdRs1() RegisterIndex
- func (r RawInstruction) CRdRs1Short() RegisterIndex
- func (r RawInstruction) CRdShort() RegisterIndex
- func (r RawInstruction) CRs1() RegisterIndex
- func (r RawInstruction) CRs2() RegisterIndex
- func (r RawInstruction) CRs2Short() RegisterIndex
- func (r RawInstruction) CSDSPImm() Immediate
- func (r RawInstruction) CSQSPImm() Immediate
- func (r RawInstruction) CSWSPImm() Immediate
- func (r RawInstruction) CWImm() Immediate
- func (r RawInstruction) GetFunct3() Funct3
- func (r RawInstruction) GetFunct7() Funct7
- func (r RawInstruction) GetImmediate() Immediate
- func (r RawInstruction) GetMinorOpcode() MinorOpcode
- func (r RawInstruction) GetRd() RegisterIndex
- func (r RawInstruction) GetRs1() RegisterIndex
- func (r RawInstruction) GetRs2() RegisterIndex
- func (r RawInstruction) GetRs3() RegisterIndex
- type RegisterIndex
- type TranslationRegistrationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Funct3 ¶
type Funct3 uint32
Funct3 determines the operation for an instruction
const ( // Caddi compact add immediate Caddi Funct3 = iota // Cjal compact jump and link Cjal // Cli compact load immediate. Cli // Clui compact load upper immediate Clui // Extend6 designates a funct field that extends to Funct6 Extend6 // Cj compact jump Cj // Cbeqz compact branch equal to zero Cbeqz // Cbnez compact branch not equal to zero Cbnez )
const ( // Cslli compact shift left logical Cslli Funct3 = iota // Cfldsp compact float load double stack pointer Cfldsp // Clwsp compact load double stack pointer Clwsp // Cflwsp compact float load word stack pointer Cflwsp // CMvAdd contains the move and add instructions CMvAdd // Cfsdsp compact float store double stack pointer Cfsdsp // Cswsp compact store word stack pointer Cswsp // Cfswsp compact float store word stack pointer Cfswsp )
const ( // Mul is a multiply instruction and sets the lower bits of the product. Mul Funct3 = iota // Mulh is a multiply instruction and sets the upper bits of the product. Mulh // Mulhsu is a multiply instruction, returns upper bits, rs1 signed, rs2 // unsigned. Mulhsu // Mulhu is a multiply instruction, returns upper bits, both multiplicands // are unsigned. Mulhu // Div is a divide instruction. Div // Divu is an unsigned division instruction. Divu // Rem returns the remainder of division. Rem // Remu returns the remainder of unsigned division. Remu )
const ( // Other includes all not CSR instructions Other Funct3 = iota // Csrrw is the funct value for csrrw Csrrw // Csrrs is the funct value for csrrs Csrrs // Csrrc is the funct value for csrrc Csrrc // Csrrwi is the funct value for csrrwi Csrrwi // Csrrsi is the funct value for csrrsi Csrrsi // Csrrci is the funct value for csrrci Csrrci )
const (
FLoadStore Funct3 = 0x2
)
type Funct5Head ¶
type Funct5Head uint32
Funct5Head determines the operation for an atomic instruction.
const ( CommonAtomic Funct5Head = iota Amoxor Amoor Amoand Amomin Amomax Amominu Amomaxu )
type Funct5Tail ¶
type Funct5Tail uint32
Funct5Tail determines the operation for an atomic instruction.
const ( ArithAtomic Funct5Tail = iota Amoswap Lr Sc )
type Funct6Tail ¶
type Funct6Tail uint32
Funct6Tail is a funct field extension for the Funct6 field
const ( // Csrli compact shift right logical immediate Csrli Funct6Tail = iota // Csrai compact shift right arithmetic immediate Csrai // Candi compact and immediate Candi // RegGroupTail is a group of compact arithmetic register instructions RegGroupTail )
type Funct7 ¶
type Funct7 uint32
Funct7 determines the operation for an R format instruction
const ( // MulDiv denotes an M extension instruction. MulDiv Funct7 = 1 )
type IDBuilder ¶
type IDBuilder struct {
// contains filtered or unexported fields
}
IDBuilder generates an instruction ID and Mask.
To be used at Vemulator build time. Too slow to use during RISC-V binary emulation.
func (IDBuilder) Mask ¶
Mask returns the generated instruction mask used for matching instruction words.
func (IDBuilder) WithCBit12 ¶
WithCBit12 updates the ID and mask with the specified field.
func (IDBuilder) WithCFunct2 ¶
WithCFunct2 updates the ID and mask with the specified field.
func (IDBuilder) WithCFunct3 ¶
WithCFunct3 updates the ID and mask with the specified field.
func (IDBuilder) WithCFunct6Tail ¶
func (i IDBuilder) WithCFunct6Tail(funct6tail Funct6Tail) IDBuilder
WithCFunct6Tail updates the ID and mask with the specified field.
func (IDBuilder) WithCustom ¶
WithCustom adds custom match and mask bits.
The match bits should be normalized such that the LSB is zero bit.
func (IDBuilder) WithFunct7 ¶
WithFunct7 updates the ID and mask with the specified field.
func (IDBuilder) WithMajOp ¶
func (i IDBuilder) WithMajOp(majOp MajorOpcode) IDBuilder
WithMajOp updates the ID and mask with the specified field.
func (IDBuilder) WithMinOp ¶
func (i IDBuilder) WithMinOp(minOp MinorOpcode) IDBuilder
WithMinOp updates the ID and mask with the specified field.
func (IDBuilder) WithStdFunct3 ¶
WithStdFunct3 updates the ID and mask with the specified field.
func (IDBuilder) WithStdFunct5Head ¶
func (i IDBuilder) WithStdFunct5Head(funct5Head Funct5Head) IDBuilder
WithStdFunct5Head updates the ID and mask with the specified field.
func (IDBuilder) WithStdFunct5Tail ¶
func (i IDBuilder) WithStdFunct5Tail(funct5Tail Funct5Tail) IDBuilder
WithStdFunct5Tail updates the ID and mask with the specified field.
type MajorOpcode ¶
type MajorOpcode uint32
MajorOpcode determines whether the instruction is part of the G designation
const ( // C0 designates a compact instruction in the C0 space. C0 MajorOpcode = iota // C1 designates a compact instruction in the C1 space. C1 // C2 designates a compact instruction in the c2 space. C2 // Std designates a full length instruction that is part of the standard ISA. Std )
type MinorOpcode ¶
type MinorOpcode uint32
MinorOpcode determines the format of the given instruction
const ( // IntRegReg designates an integer register-register instruction IntRegReg MinorOpcode = 0xc // IntRegImm designates an integer register-immediate instruction IntRegImm MinorOpcode = 0x4 // IntRegReg32 designates an integer register-register instruction in RV64 for a 32-bit operation. IntRegReg32 MinorOpcode = 0xe // IntRegImm32 designates an integer register-immediate instruction in RV64 for a 32-bit operation. IntRegImm32 MinorOpcode = 0x6 // Load designates a load instruction Load MinorOpcode = 0x0 // Jalr designates a JALR instruction Jalr MinorOpcode = 0x19 // Store designates a store type instruction Store MinorOpcode = 0x8 // Branch desigtnates a branch type instruction Branch MinorOpcode = 0x18 // Lui designates an LUI instruction Lui MinorOpcode = 0xd // Auipc designates an AUIPC instruction Auipc MinorOpcode = 0x5 // Jal designates a JAL instruction Jal MinorOpcode = 0x1b // FenceOp designates a fence instruction FenceOp MinorOpcode = 0x3 // Sys designates a system call instruction Sys MinorOpcode = 0x1c // Atomic designates an atomic instruction Atomic MinorOpcode = 0xb )
const ( Flw MinorOpcode = 0x1 Fsw MinorOpcode = 0x9 )
type RawInstruction ¶
type RawInstruction struct { BinWord uint32 MajOp MajorOpcode }
RawInstruction enables field extraction from an instruction word
func NewRawInstruction ¶
func NewRawInstruction(bits uint32) RawInstruction
NewRawInstruction assigns the binary word to the structure.
func (RawInstruction) CADDI16Imm ¶
func (r RawInstruction) CADDI16Imm() Immediate
CADDI16Imm returns the CADDI16SP immediate.
func (RawInstruction) CADDI4Imm ¶
func (r RawInstruction) CADDI4Imm() Immediate
CADDI4Imm returns the CADDI4SPN immediate.
func (RawInstruction) CAFunct2 ¶
func (r RawInstruction) CAFunct2() Funct2
CAFunct2 returns the compact funct2 field for the ca-type instructions.
func (RawInstruction) CBFunct2 ¶
func (r RawInstruction) CBFunct2() Funct2
CBFunct2 returns the compact funct2 field for cb-type instructions.
func (RawInstruction) CBImm ¶
func (r RawInstruction) CBImm() Immediate
CBImm returns the compact b-type immediate.
func (RawInstruction) CDImm ¶
func (r RawInstruction) CDImm() Immediate
CDImm returns CLD, CFLD, CSD, and CFSD immediate.
func (RawInstruction) CFunct3 ¶
func (r RawInstruction) CFunct3() Funct3
CFunct3 returns a compact Funct3 field
func (RawInstruction) CIImm ¶
func (r RawInstruction) CIImm() Immediate
CIImm returns the CLI, CADDI, CSLLI, CSRLI, CSRAI, CANDI, and CADDIW immediate.
func (RawInstruction) CJImm ¶
func (r RawInstruction) CJImm() Immediate
CJImm returns the compact j-type immediate.
func (RawInstruction) CLDSPImm ¶
func (r RawInstruction) CLDSPImm() Immediate
CLDSPImm returns CLDSP or CFLDSP immediate.
func (RawInstruction) CLQSPImm ¶
func (r RawInstruction) CLQSPImm() Immediate
CLQSPImm returns CLQSPImm immediate.
func (RawInstruction) CLUIImm ¶
func (r RawInstruction) CLUIImm() Immediate
CLUIImm returns the CLUI immediate.
func (RawInstruction) CLWSPImm ¶
func (r RawInstruction) CLWSPImm() Immediate
CLWSPImm returns CLWSP or CFLWSP immediate.
func (RawInstruction) CQImm ¶
func (r RawInstruction) CQImm() Immediate
CQImm returns CLQ and CSQ immediate.
func (RawInstruction) CRdRs1 ¶
func (r RawInstruction) CRdRs1() RegisterIndex
CRdRs1 returns a compact rd/rs1 field
func (RawInstruction) CRdRs1Short ¶
func (r RawInstruction) CRdRs1Short() RegisterIndex
CRdRs1Short returns the shortened Rd'Rs1' field.
func (RawInstruction) CRdShort ¶
func (r RawInstruction) CRdShort() RegisterIndex
CRdShort returns the compact Rd field.
func (RawInstruction) CRs1 ¶
func (r RawInstruction) CRs1() RegisterIndex
CRs1 returns the compact Rs1 field.
func (RawInstruction) CRs2 ¶
func (r RawInstruction) CRs2() RegisterIndex
CRs2 returns a compact rs2 field
func (RawInstruction) CRs2Short ¶
func (r RawInstruction) CRs2Short() RegisterIndex
CRs2Short returns the compact short Rs2 field.
func (RawInstruction) CSDSPImm ¶
func (r RawInstruction) CSDSPImm() Immediate
CSDSPImm returns CSDSP or CFSDSP immediate.
func (RawInstruction) CSQSPImm ¶
func (r RawInstruction) CSQSPImm() Immediate
CSQSPImm returns CSQSP immediate.
func (RawInstruction) CSWSPImm ¶
func (r RawInstruction) CSWSPImm() Immediate
CSWSPImm returns CSWSP or CFSWSP immediate.
func (RawInstruction) CWImm ¶
func (r RawInstruction) CWImm() Immediate
CWImm returns CLW, CFLW, CSW, and CFSW immediate.
func (RawInstruction) GetFunct3 ¶
func (r RawInstruction) GetFunct3() Funct3
GetFunct3 returns the funct3 field
func (RawInstruction) GetFunct7 ¶
func (r RawInstruction) GetFunct7() Funct7
GetFunct7 returns the funct7 field
func (RawInstruction) GetImmediate ¶
func (r RawInstruction) GetImmediate() Immediate
GetImmediate returns the immediate value encoded in the instruction
func (RawInstruction) GetMinorOpcode ¶
func (r RawInstruction) GetMinorOpcode() MinorOpcode
GetMinorOpcode returns the minor opcode for the given instruction
func (RawInstruction) GetRd ¶
func (r RawInstruction) GetRd() RegisterIndex
GetRd returns the rd field for the instruction word
func (RawInstruction) GetRs1 ¶
func (r RawInstruction) GetRs1() RegisterIndex
GetRs1 returns the rs1 field
func (RawInstruction) GetRs2 ¶
func (r RawInstruction) GetRs2() RegisterIndex
GetRs2 returns the rs2 field
func (RawInstruction) GetRs3 ¶
func (r RawInstruction) GetRs3() RegisterIndex
GetRs3 returns the rs2 field
type RegisterIndex ¶
type RegisterIndex uint32
RegisterIndex determines the indexes the register in the register file
type TranslationRegistrationError ¶
type TranslationRegistrationError struct {
// contains filtered or unexported fields
}
TranslationRegistrationError indicates that a problem occurred while registering instruction ID to Uop translations in the Decoder.
func NewTransRegError ¶
func NewTransRegError(insn string, id uint32, mask uint32, duplicate bool) TranslationRegistrationError
func (TranslationRegistrationError) Error ¶
func (t TranslationRegistrationError) Error() string