OpenASIP  2.0
ProximRFDetailsCmd.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 ProximRFDetailsCmd.cc
26  *
27  * Implementation of ProximRFDetailsCmd 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 "ProximRFDetailsCmd.hh"
36 #include "ProximToolbox.hh"
37 #include "RegisterFile.hh"
39 #include "Conversion.hh"
40 #include "ProximConstants.hh"
41 #include "MachineState.hh"
42 #include "PortState.hh"
43 #include "RegisterFileState.hh"
44 #include "UtilizationStats.hh"
45 
46 using std::string;
47 using namespace TTAMachine;
48 
49 /**
50  * The Constructor.
51  *
52  * @param rf Register file to display.
53  */
55  ComponentCommand(), rf_(rf) {
56 }
57 
58 
59 /**
60  * The Destructor.
61  */
63 }
64 
65 /**
66  * Executes the command.
67  */
68 bool
70 
71  string rfName = rf_.name();
72 
75 
76  const UtilizationStats& stats =
78 
79  // Append component type and name to the details widget.
81  machineWin->appendDetails(rfName + "\n\n");
82 
83  // Append registers to the details widget.
84  machineWin->appendDetails(
86  RegisterFileState& rfState = machineState.registerFileState(rfName);
87  for (unsigned i = 0; i < rfState.registerCount(); i++) {
88  machineWin->appendDetails(" " + Conversion::toString(i) + ":\t");
89  int registerValue = rfState.registerState(i).value().unsignedValue();
90  machineWin->appendDetails(Conversion::toString(registerValue) + "\n");
91  }
92 
93  // Append register access statistics to the utilization widget.
94  machineWin->appendUtilizationData("Register access statistics:\n\n");
95 
96  int usedRegCount = 0;
97  for (unsigned i = 0; i < rfState.registerCount(); i++) {
98  ClockCycleCount readCount = stats.registerReads(rfName, i);
99  ClockCycleCount writeCount = stats.registerWrites(rfName, i);
100  if (readCount > 0 || writeCount > 0) {
101  usedRegCount++;
102  }
103  machineWin->appendUtilizationData(
104  Conversion::toString(i) + + ": " +
105  Conversion::toString(readCount) + " reads, " +
106  Conversion::toString(writeCount) + " writes.\n");
107  }
108 
109  machineWin->appendUtilizationData(
110  "\nTotal of " + Conversion::toString(usedRegCount) +
111  " registers used.");
112 
113  return true;
114 }
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
RegisterFileState.hh
ProximMachineStateWindow.hh
ProximRFDetailsCmd::~ProximRFDetailsCmd
virtual ~ProximRFDetailsCmd()
Definition: ProximRFDetailsCmd.cc:62
ProximMachineStateWindow::appendDetails
void appendDetails(std::string text)
Definition: ProximMachineStateWindow.cc:479
ProximMachineStateWindow
Definition: ProximMachineStateWindow.hh:56
Conversion::toString
static std::string toString(const T &source)
ProximToolbox.hh
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
MachineState
Definition: MachineState.hh:61
ProximConstants::MACH_WIN_RF_LABEL
static const std::string MACH_WIN_RF_LABEL
Label precing register file names in the machine state window.
Definition: ProximConstants.hh:214
Conversion.hh
SimulatorFrontend::utilizationStatistics
const UtilizationStats & utilizationStatistics(int core=-1)
Definition: SimulatorFrontend.cc:2155
ProximRFDetailsCmd.hh
ProximConstants::MACH_WIN_REGISTERS_TITLE
static const std::string MACH_WIN_REGISTERS_TITLE
Title for the machine state window register file register list.
Definition: ProximConstants.hh:237
ComponentCommand
Definition: ComponentCommand.hh:46
ProximMachineStateWindow::appendUtilizationData
void appendUtilizationData(std::string text)
Definition: ProximMachineStateWindow.cc:467
SimValue::unsignedValue
unsigned int unsignedValue() const
Definition: SimValue.cc:919
ProximRFDetailsCmd::rf_
const TTAMachine::RegisterFile & rf_
Register file to display.
Definition: ProximRFDetailsCmd.hh:53
ProximToolbox::machineStateWindow
static ProximMachineStateWindow * machineStateWindow()
Definition: ProximToolbox.cc:123
UtilizationStats.hh
TracedSimulatorFrontend.hh
RegisterFileState::registerCount
virtual std::size_t registerCount() const
Definition: RegisterFileState.cc:95
ProximConstants.hh
RegisterFileState::registerState
virtual RegisterState & registerState(int index)
Definition: RegisterFileState.cc:81
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
RegisterFile.hh
UtilizationStats::registerWrites
ClockCycleCount registerWrites(const std::string &rfName, int registerIndex) const
Definition: UtilizationStats.cc:314
ProximRFDetailsCmd::ProximRFDetailsCmd
ProximRFDetailsCmd(const TTAMachine::RegisterFile &rf)
Definition: ProximRFDetailsCmd.cc:54
MachineState.hh
RegisterFileState
Definition: RegisterFileState.hh:49
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
ProximRFDetailsCmd::Do
virtual bool Do()
Definition: ProximRFDetailsCmd.cc:69
UtilizationStats::registerReads
ClockCycleCount registerReads(const std::string &rfName, int registerIndex) const
Definition: UtilizationStats.cc:270
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TTAMachine
Definition: Assembler.hh:48
PortState.hh
UtilizationStats
Definition: UtilizationStats.hh:50
MachineState::registerFileState
RegisterFileState & registerFileState(const std::string &name)
Definition: MachineState.cc:213