package instr import ( "git.elyanpoujol.fr/elyan/central-arch/pkg/register" "git.elyanpoujol.fr/elyan/central-arch/pkg/simstate" ) type Instr uint32 type InstrFormat uint32 const ( A InstrFormat = iota B C D1 D2 E ) func (instrf InstrFormat) String() string { switch instrf { case A: return "A" case B: return "B" case C: return "C" case D1: return "D1" case D2: return "D2" case E: return "E" } panic("unknown format") } type Cond uint32 const ( AL Cond = iota // Always EQ // Equal, Z==1 NEQ // Not Equal, Z==0 UGE // Unsigned Greater or Equal, C==1 CS Cond = iota - 1 // Carry Set, C==1 ULT // Unsigned Lower Than, C==0 CC Cond = iota - 2 // Carry Clear, C==0 NEG // Negative, N==1 POS // Positive, N==0 VS // oVerflow Set, V==1 VC // oVerflow Clear, V==0 UGT // Unsigned Greater Than, C==1 && Z==0 ULE // Unsigned Lower Than, C==0 && Z==1 SGE // Signed Greater or Equal, N==V SLT // Signed Lower Than, N!=V SGT // Signed Greater Than, Z==0 && N==V SLE // Signed Lower or Equal, Z==1 && N!=V ) type InstrFormatter func(*DecodedInstr) string type InstrBehavior func(*DecodedInstr, simstate.SimState) error type InstrDesc struct { VariantName string Mnemonic string OpCode uint32 Format InstrFormat Formatter InstrFormatter Behavior InstrBehavior } type StandardFormatFields struct { Condition Cond Rd register.CpuRegister Rs1 register.CpuRegister Rs2 register.CpuRegister Imm uint32 } type SubsystemFormatFields struct { Reg register.CpuRegister Sid uint32 Sre uint32 Cmd uint32 } type DecodedInstr struct { Format InstrFormat OpCode uint32 // A, B, C, D1 and D2 formats fields StandardFormatFields // E format fields SubsystemFormatFields }