OpenASIP  2.0
ProximIUDetailsCmd.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 ProximIUDetailsCmd.cc
26  *
27  * Implementation of ProximIUDetailsCmd 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 "ProximIUDetailsCmd.hh"
36 #include "ProximToolbox.hh"
37 #include "ImmediateUnit.hh"
39 #include "Conversion.hh"
40 #include "ProximConstants.hh"
41 #include "MachineState.hh"
43 #include "UtilizationStats.hh"
44 
45 using std::string;
46 using namespace TTAMachine;
47 
48 /**
49  * The Constructor.
50  *
51  * @param iu Immediate unit to display.
52  */
54  ComponentCommand(), iu_(iu) {
55 }
56 
57 
58 /**
59  * The Destructor.
60  */
62 }
63 
64 /**
65  * Executes the command.
66  */
67 bool
69 
70  string iuName = iu_.name();
71 
74 
75  const UtilizationStats& stats =
77 
78  // Append component type and name to the details widget.
80  machineWin->appendDetails(iuName + "\n\n");
81 
82  // Append registers to the details widget.
83  machineWin->appendDetails(
85  LongImmediateUnitState& iuState =
86  machineState.longImmediateUnitState(iuName);
87 
88  for (int i = 0; i < iuState.immediateRegisterCount(); i++) {
89  machineWin->appendDetails(" " + Conversion::toString(i) + ":\t");
90  int immValue = iuState.registerValue(i).sIntWordValue();
91  machineWin->appendDetails(Conversion::toString(immValue) + "\n");
92  }
93 
94  // Append register access statistics to the utilization widget.
95  machineWin->appendUtilizationData("Register access statistics:\n\n");
96 
97  int usedRegCount = 0;
98  for (int i = 0; i < iuState.immediateRegisterCount(); i++) {
99  ClockCycleCount reads = stats.registerReads(iuName, i);
100  ClockCycleCount writes = stats.registerWrites(iuName, i);
101  if (reads > 0 || writes > 0) {
102  usedRegCount++;
103  }
104  machineWin->appendUtilizationData(
105  Conversion::toString(i) + + ": " +
106  Conversion::toString(reads) + " reads, " +
107  Conversion::toString(writes) + " writes.\n");
108  }
109 
110  machineWin->appendUtilizationData(
111  "\nTotal of " + Conversion::toString(usedRegCount) +
112  " registers used.");
113 
114  return true;
115 }
ProximIUDetailsCmd::Do
virtual bool Do()
Definition: ProximIUDetailsCmd.cc:68
MachineState::longImmediateUnitState
LongImmediateUnitState & longImmediateUnitState(const std::string &name)
Definition: MachineState.cc:196
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
ProximIUDetailsCmd.hh
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ProximMachineStateWindow.hh
ProximIUDetailsCmd::ProximIUDetailsCmd
ProximIUDetailsCmd(const TTAMachine::ImmediateUnit &iu)
Definition: ProximIUDetailsCmd.cc:53
LongImmediateUnitState::immediateRegisterCount
virtual int immediateRegisterCount() const
Definition: LongImmediateUnitState.cc:174
ProximMachineStateWindow::appendDetails
void appendDetails(std::string text)
Definition: ProximMachineStateWindow.cc:479
ProximIUDetailsCmd::~ProximIUDetailsCmd
virtual ~ProximIUDetailsCmd()
Definition: ProximIUDetailsCmd.cc:61
ProximMachineStateWindow
Definition: ProximMachineStateWindow.hh:56
ImmediateUnit.hh
Conversion::toString
static std::string toString(const T &source)
LongImmediateUnitState.hh
ProximToolbox.hh
MachineState
Definition: MachineState.hh:61
Conversion.hh
SimulatorFrontend::utilizationStatistics
const UtilizationStats & utilizationStatistics(int core=-1)
Definition: SimulatorFrontend.cc:2155
ProximConstants::MACH_WIN_IMMEDIATES_TITLE
static const std::string MACH_WIN_IMMEDIATES_TITLE
Title for the machine state window immediate unit immediates list.
Definition: ProximConstants.hh:239
ProximIUDetailsCmd::iu_
const TTAMachine::ImmediateUnit & iu_
Immediate unit to display.
Definition: ProximIUDetailsCmd.hh:53
ComponentCommand
Definition: ComponentCommand.hh:46
ProximMachineStateWindow::appendUtilizationData
void appendUtilizationData(std::string text)
Definition: ProximMachineStateWindow.cc:467
SimValue::sIntWordValue
SIntWord sIntWordValue() const
Definition: SimValue.cc:944
ProximToolbox::machineStateWindow
static ProximMachineStateWindow * machineStateWindow()
Definition: ProximToolbox.cc:123
UtilizationStats.hh
TracedSimulatorFrontend.hh
ProximConstants::MACH_WIN_IU_LABEL
static const std::string MACH_WIN_IU_LABEL
Label precing immediate unit names in the machine state window.
Definition: ProximConstants.hh:218
ProximConstants.hh
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
UtilizationStats::registerWrites
ClockCycleCount registerWrites(const std::string &rfName, int registerIndex) const
Definition: UtilizationStats.cc:314
MachineState.hh
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
UtilizationStats::registerReads
ClockCycleCount registerReads(const std::string &rfName, int registerIndex) const
Definition: UtilizationStats.cc:270
LongImmediateUnitState::registerValue
virtual SimValue & registerValue(int index)
Definition: LongImmediateUnitState.cc:98
TTAMachine
Definition: Assembler.hh:48
UtilizationStats
Definition: UtilizationStats.hh:50
LongImmediateUnitState
Definition: LongImmediateUnitState.hh:55
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50