OpenASIP  2.0
ProximPortWindow.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 ProximPortWindow.cc
26  *
27  * Definition of ProximPortWindow class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 
34 #include <string>
35 
36 #include "ProximPortWindow.hh"
37 #include "Proxim.hh"
38 #include "WxConversion.hh"
41 
42 #include "FunctionUnit.hh"
43 #include "ControlUnit.hh"
44 #include "Machine.hh"
45 #include "FUPort.hh"
46 #include "MachineState.hh"
47 #include "PortState.hh"
48 #include "FUState.hh"
49 #include "StateData.hh"
50 #include "SimValue.hh"
51 #include "Conversion.hh"
52 
53 #include <wx/listctrl.h>
54 
55 using namespace TTAMachine;
56 using std::string;
57 
58 /**
59  * Constructor.
60  *
61  * @param parent Parent window of the window.
62  * @param id Window identifier.
63  */
65  ProximMainFrame* parent, int id):
66  ProximUnitWindow(parent, id) {
67 
68  valueList_->InsertColumn(0, _T("Port"), wxLIST_FORMAT_LEFT, 100);
69  valueList_->InsertColumn(1, _T("Value"), wxLIST_FORMAT_RIGHT, 120);
70 
74 
75  reinitialize();
76  }
77 }
78 
79 
80 /**
81  * Destructor.
82  */
84 }
85 
86 
87 /**
88  * Sets the available function unit selections in the function unit choice.
89  */
90 void
92 
93  unitChoice_->Clear();
94 
95  string gcuName = simulator_->machine().controlUnit()->name();
96  unitChoice_->Append(WxConversion::toWxString(gcuName));
97 
100 
101  for (int i = 0; i < navigator.count(); i++) {
102  string fuName = navigator.item(i)->name();
103  unitChoice_->Append(WxConversion::toWxString(fuName));
104  }
105 
106  unitChoice_->SetSelection(0);
107 
108  update();
109 }
110 
111 /**
112  * Changes unit selection to function unit with given name.
113  *
114  * @param name Name of the function unit to select.
115  */
116 void
117 ProximPortWindow::showFunctionUnit(const std::string& name) {
118  unitChoice_->SetStringSelection(WxConversion::toWxString(name));
119  update();
120 }
121 
122 /**
123  * Updates the value list with port values of the selected function unit.
124  */
125 void
127 
128  valueList_->DeleteAllItems();
129 
130  MachineState& machState = simulator_->machineState();
133 
134  int fuIndex = unitChoice_->GetSelection();
135  FunctionUnit* fu = NULL;
136 
137  // FU Choice item with index 0 is the control unit.
138  if (fuIndex == 0) {
139  fu = simulator_->machine().controlUnit();
140  } else {
141  fu = navigator.item(fuIndex - 1);
142  }
143 
144  // Append all ports of the function unit to the port list.
145  for (int i = 0; i < fu->portCount(); i++) {
146 
147  string portName = fu->port(i)->name();
148  const PortState& state = machState.portState(portName, fu->name());
149 
150  wxString value;
151 
152  wxString mode = modeChoice_->GetStringSelection();
153 
154  if (mode == MODE_UNSIGNED) {
155  value = WxConversion::toWxString(state.value().unsignedValue());
156  } else if (mode == MODE_INT) {
157  int intValue = state.value().intValue();
158  value = WxConversion::toWxString(intValue);
159  } else if (mode == MODE_HEX) {
160  value = WxConversion::toWxString(
162  } else if (mode == MODE_BIN) {
163  int intValue = state.value().unsignedValue();
164  value = WxConversion::toWxString(
165  Conversion::toBinString(intValue));
166  }
167 
168  valueList_->InsertItem(i, WxConversion::toWxString(portName));
169  valueList_->SetItem(i, 1, value);
170  }
171 }
ProximMainFrame
Definition: ProximMainFrame.hh:58
SimValue::intValue
int intValue() const
Definition: SimValue.cc:895
ProximPortWindow.hh
WxConversion::toWxString
static wxString toWxString(const std::string &source)
mode
mode
Definition: tceopgen.cc:45
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
MachineState::portState
PortState & portState(const std::string &portName, const std::string &fuName)
Definition: MachineState.cc:175
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
ProximUnitWindow::modeChoice_
wxChoice * modeChoice_
Value display mode choicer widget.
Definition: ProximUnitWindow.hh:62
ProximPortWindow::~ProximPortWindow
virtual ~ProximPortWindow()
Definition: ProximPortWindow.cc:83
SimulatorFrontend::isSimulationStopped
bool isSimulationStopped() const
Definition: SimulatorFrontend.cc:1271
FUState.hh
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
ProximSimulationThread.hh
Proxim.hh
TTAMachine::Machine::Navigator::count
int count() const
ProximPortWindow::reinitialize
virtual void reinitialize()
Definition: ProximPortWindow.cc:91
ProximUnitWindow::MODE_UNSIGNED
static const wxString MODE_UNSIGNED
String for the mode choicer unsigned integer mode.
Definition: ProximUnitWindow.hh:69
ProximUnitWindow::unitChoice_
wxChoice * unitChoice_
Unit choicer widget.
Definition: ProximUnitWindow.hh:60
ProximPortWindow::update
virtual void update()
Definition: ProximPortWindow.cc:126
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
MachineState
Definition: MachineState.hh:61
ProximPortWindow::ProximPortWindow
ProximPortWindow(ProximMainFrame *parent, int id)
Definition: ProximPortWindow.cc:64
ProximUnitWindow::valueList_
wxListCtrl * valueList_
List widget for the values.
Definition: ProximUnitWindow.hh:64
Conversion.hh
StateData.hh
ProximUnitWindow::MODE_INT
static const wxString MODE_INT
String for the mode choicer integer mode.
Definition: ProximUnitWindow.hh:67
ProximUnitWindow
Definition: ProximUnitWindow.hh:51
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
ProximUnitWindow::simulator_
SimulatorFrontend * simulator_
Simulator instance .
Definition: ProximUnitWindow.hh:58
Machine.hh
PortState
Definition: PortState.hh:51
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
Conversion::toHexString
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
SimValue::unsignedValue
unsigned int unsignedValue() const
Definition: SimValue.cc:919
TracedSimulatorFrontend.hh
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
SimValue.hh
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
FUPort.hh
ControlUnit.hh
Conversion::toBinString
static std::string toBinString(int source)
Definition: Conversion.cc:81
MachineState.hh
ProximPortWindow::showFunctionUnit
void showFunctionUnit(const std::string &name)
Definition: ProximPortWindow.cc:117
ProximUnitWindow::MODE_HEX
static const wxString MODE_HEX
String for the mode choicer hexadecimal mode.
Definition: ProximUnitWindow.hh:71
WxConversion.hh
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
SimulatorFrontend::hasSimulationEnded
bool hasSimulationEnded() const
Definition: SimulatorFrontend.cc:1283
TTAMachine
Definition: Assembler.hh:48
ProximUnitWindow::MODE_BIN
static const wxString MODE_BIN
String for the mode choicer binary mode.
Definition: ProximUnitWindow.hh:73
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
SimulatorFrontend::isSimulationInitialized
bool isSimulationInitialized() const
Definition: SimulatorFrontend.cc:1228
PortState.hh
FunctionUnit.hh