OpenASIP 2.2
Loading...
Searching...
No Matches
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"
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 */
53
54
55/**
56 * The Destructor.
57 */
60
61
62/**
63 * Returns grid cell attributes for cell with given move.
64 *
65 * @param address Address of the cell's instruction.
66 */
67wxGridCellAttr*
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}
#define assert(condition)
UInt32 InstructionAddress
Definition BaseType.hh:175
find Finds info of the inner loops in the program
CycleCount ClockCycleCount
Alias for ClockCycleCount.
DisasmExecPercentageAttrProvider(const TracedSimulatorFrontend &simulator)
virtual wxGridCellAttr * moveCellAttr(InstructionAddress address, int move)
ClockCycleCount moveExecutionCount(std::size_t moveIndex) const
ClockCycleCount cycleCount() const
const TTAProgram::Program & program() const
const ExecutableInstruction & executableInstructionAt(InstructionAddress address) const
ComponentType * item(int index) const
Move & move(int i) const
const TTAMachine::Bus & bus() const
Definition Move.cc:373