OpenASIP  2.0
DisasmExecPercentageAttrProvider.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DisasmExecPercentageAttrProvider.cc
26  *
27  * Implementation of DisasmExecPercentageAttrProvider class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/grid.h>
34 #include <math.h>
37 #include "Program.hh"
38 #include "Instruction.hh"
39 #include "ExecutableInstruction.hh"
40 #include "Move.hh"
41 #include "Machine.hh"
42 
43 /**
44  * The Constructor.
45  *
46  * @param simulator Simulator frontend for accessing instructions and execution
47  * counts.
48  */
50  const TracedSimulatorFrontend& simulator):
51  ProximDisasmAttrProvider(), simulator_(simulator) {
52 }
53 
54 
55 /**
56  * The Destructor.
57  */
59 }
60 
61 
62 /**
63  * Returns grid cell attributes for cell with given move.
64  *
65  * @param address Address of the cell's instruction.
66  */
67 wxGridCellAttr*
69  InstructionAddress address, int move) {
70 
72 
73  wxGridCellAttr* attr = new wxGridCellAttr();
74 
75  const ExecutableInstruction& ins =
77 
79 
81  program.targetProcessor().busNavigator();
82 
83  assert(move >= 0);
84 
85  if (move >= nav.count()) {
86  // No highlight for immediate slots.
87  return attr;
88  }
89 
90  const TTAMachine::Bus* moveBus = nav.item(move);
91  const TTAProgram::Instruction& instruction =
92  program.instructionAt(address);
93 
94  // Search for the correct move index in the instruction.
95  // TTAProgram::Instruction doesn't contain nops and the move indexing
96  // differs from the busNavigator and disassembly grid indexing.
97  int index = 0;
98  for (; index < instruction.moveCount(); index++) {
99  if (moveBus == &instruction.move(index).bus()) {
100  break;
101  }
102  }
103 
104  ClockCycleCount executions = 0;
105  if (index < instruction.moveCount()) {
106  executions = ins.moveExecutionCount(index);
107  }
108 
109  if (executions > 0) {
111  int colour = static_cast<int>(
112  5 * 255 * sin((executions / cycles) * 0.5 * 3.1415926));
113  if (colour > 255) colour = 255;
114  attr->SetBackgroundColour(
115  wxColour(255, 255 - colour, 255 - colour));
116  } else {
117  // Gray background colour for moves that are not executed at all.
118  attr->SetBackgroundColour(wxColour(220, 220, 220));
119  }
120  return attr;
121 }
DisasmExecPercentageAttrProvider::simulator_
const TracedSimulatorFrontend & simulator_
Definition: DisasmExecPercentageAttrProvider.hh:52
TracedSimulatorFrontend
Definition: TracedSimulatorFrontend.hh:49
TTAProgram::Program
Definition: Program.hh:63
ExecutableInstruction
Definition: ExecutableInstruction.hh:49
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
TTAProgram::Instruction::move
Move & move(int i) const
Definition: Instruction.cc:193
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAMachine::Bus
Definition: Bus.hh:53
DisasmExecPercentageAttrProvider::~DisasmExecPercentageAttrProvider
virtual ~DisasmExecPercentageAttrProvider()
Definition: DisasmExecPercentageAttrProvider.cc:58
TTAProgram::Move::bus
const TTAMachine::Bus & bus() const
Definition: Move.cc:373
TTAMachine::Machine::Navigator::count
int count() const
assert
#define assert(condition)
Definition: Application.hh:86
ProximDisasmAttrProvider
Definition: ProximDisasmAttrProvider.hh:44
Instruction.hh
SimulatorFrontend::executableInstructionAt
const ExecutableInstruction & executableInstructionAt(InstructionAddress address) const
Definition: SimulatorFrontend.cc:2208
DisasmExecPercentageAttrProvider.hh
DisasmExecPercentageAttrProvider::DisasmExecPercentageAttrProvider
DisasmExecPercentageAttrProvider(const TracedSimulatorFrontend &simulator)
Definition: DisasmExecPercentageAttrProvider.cc:49
Machine.hh
SimulatorFrontend::isProgramLoaded
bool isProgramLoaded() const
Definition: SimulatorFrontend.cc:1240
TracedSimulatorFrontend.hh
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
Program.hh
ExecutableInstruction.hh
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
Move.hh
DisasmExecPercentageAttrProvider::moveCellAttr
virtual wxGridCellAttr * moveCellAttr(InstructionAddress address, int move)
Definition: DisasmExecPercentageAttrProvider.cc:68
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAProgram::Instruction::moveCount
int moveCount() const
Definition: Instruction.cc:176
ExecutableInstruction::moveExecutionCount
ClockCycleCount moveExecutionCount(std::size_t moveIndex) const
Definition: ExecutableInstruction.cc:110