本文整理匯總了Golang中app/simulator/processor/models/operation.Operation.SetBranchResult方法的典型用法代碼示例。如果您正苦於以下問題:Golang Operation.SetBranchResult方法的具體用法?Golang Operation.SetBranchResult怎麽用?Golang Operation.SetBranchResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app/simulator/processor/models/operation.Operation
的用法示例。
在下文中一共展示了Operation.SetBranchResult方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Process
func (this *Branch) Process(operation *operation.Operation) (*operation.Operation, error) {
instruction := operation.Instruction()
info := instruction.Info
operands := instruction.Data
switch info.Type {
case data.TypeI:
registerD := operands.(*data.DataI).RegisterD.ToUint32()
op1 := this.Bus().LoadRegister(operation, registerD)
registerS := operands.(*data.DataI).RegisterS.ToUint32()
op2 := this.Bus().LoadRegister(operation, registerS)
logger.Collect(" => [BR][%03d]: [R%d(%#02X) = %#08X ? R%d(%#02X) = %#08X]",
operation.Id(), registerD, registerD*consts.BYTES_PER_WORD, op1, registerS, registerS*consts.BYTES_PER_WORD, op2)
taken, err := processOperation(op1, op2, info.Opcode)
if err != nil {
return operation, nil
}
operation.SetBranchResult(taken)
if taken {
offsetAddress := ComputeOffsetTypeI(operands)
this.Bus().IncrementProgramCounter(operation, offsetAddress)
logger.Collect(" => [BR][%03d]: [PC(offset) = 0x%06X", operation.Id(), offsetAddress)
} else {
// Notify ROB
this.Bus().IncrementProgramCounter(operation, 0)
}
case data.TypeJ:
address := ComputeAddressTypeJ(operands)
this.Bus().SetProgramCounter(operation, uint32(address-consts.BYTES_PER_WORD))
logger.Collect(" => [BR][%03d]: [Address = %06X]", operation.Id(), address)
default:
return operation, errors.New(fmt.Sprintf("Invalid data type to process by Branch unit. Type: %d", info.Type))
}
return operation, nil
}