func (this *Processor) RunRecovery(recoveryChannel channel.Channel, flushFunc func()) {
	for value := range recoveryChannel.Channel() {
		op := operation.Cast(value)
		logger.Collect(" => Recovering at OpId: %d and Address: %#04X", op.Id(), op.Address())

		logger.SetVerboseQuiet(true)
		// Flush pipeline
		flushFunc()
		// Clean logs
		this.RemoveForwardLogs(op.Id() - 1)
		// Clear speculative jumps
		this.ClearSpeculativeJumps()
		// Start pipeline from the recovery address
		flushFunc = this.StartPipelineUnits(this.Config(), recoveryChannel, op.Id(), op.Address())
		// Release value from channel
		recoveryChannel.Release()
	}
}
func (this *Processor) Start() {

	logger.CleanBuffer()
	logger.Print("\n Simulation:")
	logger.Print("\n => Starting program...")

	// Launch pipeline units and execute instruction 0x0000
	recoveryChannel := channel.New(1)
	flushFunc := this.StartPipelineUnits(this.Config(), recoveryChannel, 0, 0x0000)

	// Launch clock
	go this.RunClock()

	// Launch recovery
	go this.RunRecovery(recoveryChannel, flushFunc)

	logger.Print(" => Program is running...")
	logger.SetVerboseQuiet(true)
}
func (this *Processor) Stats() string {
	logger.SetVerboseQuiet(false)
	stats := "\n Program Stats:\n\n"
	stats += fmt.Sprintf(" => Instructions found: %d\n", len(this.InstructionsMap()))
	stats += fmt.Sprintf(" => Instructions executed: %d\n", this.InstructionsCompletedCounter())
	stats += fmt.Sprintf(" => Cycles performed: %d\n", this.Cycles())
	stats += fmt.Sprintf(" => Cycles per instruction: %3.2f cycles\n", float32(this.Cycles())/float32(this.InstructionsCompletedCounter()))
	stats += fmt.Sprintf(" => Simulation duration: %d ms\n", this.DurationMs())
	stats += fmt.Sprintf("\n")
	totalBranches := this.processor.conditionalBranches + this.processor.unconditionalBranches
	stats += fmt.Sprintf(" => Total Branches: %d\n", totalBranches)
	stats += fmt.Sprintf(" => Conditional Branches: %d\n", this.processor.conditionalBranches)
	stats += fmt.Sprintf(" => Unconditional Branches: %d\n", this.processor.unconditionalBranches)
	if this.Config().BranchPredictorType() != config.StallPredictor {
		stats += fmt.Sprintf(" => Taken Unconditional Branches: %d\n", this.processor.conditionalBranches-this.processor.noTakenBranches)
		stats += fmt.Sprintf(" => No Taken Unconditional Branches: %d\n", this.processor.noTakenBranches)
		stats += fmt.Sprintf(" => Mispredicted Branches: %d\n", this.processor.mispredictedBranches)
		stats += fmt.Sprintf(" => Misprediction Percentage (Conditional): %3.2f\n", 100*float32(this.processor.mispredictedBranches)/float32(this.processor.conditionalBranches))
	}
	return stats
}