OpenASIP  2.0
ProximFUDetailsCmd.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 ProximFUDetailsCmd.cc
26  *
27  * Implementation of ProximFUDetailsCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include "ProximFUDetailsCmd.hh"
36 #include "ProximToolbox.hh"
37 #include "FunctionUnit.hh"
38 #include "UtilizationStats.hh"
40 #include "HWOperation.hh"
41 #include "Conversion.hh"
42 #include "StringTools.hh"
43 #include "ProximConstants.hh"
44 #include "MachineState.hh"
45 #include "PortState.hh"
46 
47 using std::string;
48 using namespace TTAMachine;
49 
50 /**
51  * The Constructor.
52  *
53  * @param fu Function unit to display.
54  */
56  ComponentCommand(), fu_(fu) {
57 }
58 
59 
60 /**
61  * The Destructor.
62  */
64 }
65 
66 /**
67  * Executes the command.
68  */
69 bool
71 
72  string fuName = fu_.name();
73 
75 
76  const UtilizationStats& stats =
78 
80 
81  // Append component type and name to the details widget.
83  machineWin->appendDetails(fuName + "\n\n");
84 
85  // Append ports to the details widget.
87  for (int i = 0; i < fu_.portCount(); i++) {
88  string portName = fu_.port(i)->name();
89  const PortState& portState = machineState.portState(portName, fuName);
90  machineWin->appendDetails(" " + portName + ":\t");
91  machineWin->appendDetails(
92  Conversion::toString(portState.value().uIntWordValue()) + "\n");
93  }
94 
95  // Append trigger count to the utlization widget.
96  machineWin->appendUtilizationData(
98  double triggerCount = stats.triggerCount(fuName);
99  machineWin->appendUtilizationData(Conversion::toString(triggerCount));
100  machineWin->appendUtilizationData("\n\n");
101 
102  // Append operation usage to the utilization widget.
103  machineWin->appendUtilizationData(
105  machineWin->appendUtilizationData("\n");
106 
107  for (int i = 0; i < fu_.operationCount(); i++) {
108  string opName = StringTools::stringToUpper(fu_.operation(i)->name());
109  ClockCycleCount execCount = stats.operationExecutions(fuName, opName);
110  double percent = 0;
111  if (triggerCount > 0) {
112  percent = 100 * (execCount / triggerCount);
113  }
114  machineWin->appendUtilizationData(
115  " " + opName + ": " +
116  Conversion::toString(execCount) + " (" +
117  Conversion::toString(percent) + "%)\n");
118  }
119 
120  return true;
121 }
ProximFUDetailsCmd.hh
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
UtilizationStats::triggerCount
ClockCycleCount triggerCount(const std::string &fuName) const
Definition: UtilizationStats.cc:220
ProximFUDetailsCmd::fu_
const TTAMachine::FunctionUnit & fu_
Function unit to display.
Definition: ProximFUDetailsCmd.hh:53
MachineState::portState
PortState & portState(const std::string &portName, const std::string &fuName)
Definition: MachineState.cc:175
ProximFUDetailsCmd::Do
virtual bool Do()
Definition: ProximFUDetailsCmd.cc:70
ProximMachineStateWindow.hh
ProximMachineStateWindow::appendDetails
void appendDetails(std::string text)
Definition: ProximMachineStateWindow.cc:479
ProximMachineStateWindow
Definition: ProximMachineStateWindow.hh:56
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
SimValue::uIntWordValue
UIntWord uIntWordValue() const
Definition: SimValue.cc:972
Conversion::toString
static std::string toString(const T &source)
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
StringTools.hh
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
ProximConstants::MACH_WIN_EXECUTION_COUNT_LABEL
static const std::string MACH_WIN_EXECUTION_COUNT_LABEL
Execution count title for the machine state window.
Definition: ProximConstants.hh:229
ProximToolbox.hh
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
MachineState
Definition: MachineState.hh:61
HWOperation.hh
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
Conversion.hh
SimulatorFrontend::utilizationStatistics
const UtilizationStats & utilizationStatistics(int core=-1)
Definition: SimulatorFrontend.cc:2155
UtilizationStats::operationExecutions
ClockCycleCount operationExecutions(const std::string &operationName) const
Definition: UtilizationStats.cc:234
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
ProximConstants::MACH_WIN_TRIGGER_COUNT_LABEL
static const std::string MACH_WIN_TRIGGER_COUNT_LABEL
Trigger count label for the machine state window.
Definition: ProximConstants.hh:232
PortState
Definition: PortState.hh:51
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
ComponentCommand
Definition: ComponentCommand.hh:46
ProximMachineStateWindow::appendUtilizationData
void appendUtilizationData(std::string text)
Definition: ProximMachineStateWindow.cc:467
ProximToolbox::machineStateWindow
static ProximMachineStateWindow * machineStateWindow()
Definition: ProximToolbox.cc:123
UtilizationStats.hh
TracedSimulatorFrontend.hh
ProximConstants.hh
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
ProximFUDetailsCmd::ProximFUDetailsCmd
ProximFUDetailsCmd(const TTAMachine::FunctionUnit &fu)
Definition: ProximFUDetailsCmd.cc:55
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
MachineState.hh
ProximConstants::MACH_WIN_PORTS_TITLE
static const std::string MACH_WIN_PORTS_TITLE
Title for the machine state window ports list.
Definition: ProximConstants.hh:235
ProximConstants::MACH_WIN_FU_LABEL
static const std::string MACH_WIN_FU_LABEL
Label precing function unit names in the machine state window.
Definition: ProximConstants.hh:206
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine
Definition: Assembler.hh:48
ProximFUDetailsCmd::~ProximFUDetailsCmd
virtual ~ProximFUDetailsCmd()
Definition: ProximFUDetailsCmd.cc:63
PortState.hh
UtilizationStats
Definition: UtilizationStats.hh:50
FunctionUnit.hh