OpenASIP 2.2
Loading...
Searching...
No Matches
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
55using namespace TTAMachine;
56using 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
76 }
77}
78
79
80/**
81 * Destructor.
82 */
85
86
87/**
88 * Sets the available function unit selections in the function unit choice.
89 */
90void
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 */
116void
117ProximPortWindow::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 */
125void
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) {
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) {
156 } else if (mode == MODE_INT) {
157 int intValue = state.value().intValue();
158 value = WxConversion::toWxString(intValue);
159 } else if (mode == MODE_HEX) {
162 } else if (mode == MODE_BIN) {
163 int intValue = state.value().unsignedValue();
165 Conversion::toBinString(intValue));
166 }
167
168 valueList_->InsertItem(i, WxConversion::toWxString(portName));
169 valueList_->SetItem(i, 1, value);
170 }
171}
static std::string toBinString(int source)
Definition Conversion.cc:81
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
PortState & portState(const std::string &portName, const std::string &fuName)
ProximPortWindow(ProximMainFrame *parent, int id)
void showFunctionUnit(const std::string &name)
virtual ~ProximPortWindow()
virtual void reinitialize()
virtual void update()
static const wxString MODE_HEX
String for the mode choicer hexadecimal mode.
static const wxString MODE_INT
String for the mode choicer integer mode.
static const wxString MODE_BIN
String for the mode choicer binary mode.
wxListCtrl * valueList_
List widget for the values.
static const wxString MODE_UNSIGNED
String for the mode choicer unsigned integer mode.
wxChoice * modeChoice_
Value display mode choicer widget.
wxChoice * unitChoice_
Unit choicer widget.
SimulatorFrontend * simulator_
Simulator instance .
virtual const SimValue & value() const
int intValue() const
Definition SimValue.cc:895
unsigned int unsignedValue() const
Definition SimValue.cc:919
bool hasSimulationEnded() const
const TTAMachine::Machine & machine() const
bool isSimulationInitialized() const
MachineState & machineState(int core=-1)
bool isSimulationStopped() const
virtual TCEString name() const
virtual BaseFUPort * port(const std::string &name) const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135
static wxString toWxString(const std::string &source)
mode
Definition tceopgen.cc:45