OpenASIP 2.2
Loading...
Searching...
No Matches
ProximRegisterWindow.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2010 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 ProximRegisterWindow.cc
26 *
27 * Definition of ProximRegisterWindow class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @author Pekka Jääskeläinen 2010
31 * @note rating: red
32 */
33
34
35#include <string>
36
38#include "WxConversion.hh"
40#include "ProximMainFrame.hh"
41
42#include "Machine.hh"
43#include "RegisterFile.hh"
44#include "RegisterFileState.hh"
45#include "MachineState.hh"
46#include "RegisterState.hh"
47#include "StateData.hh"
48#include "SimValue.hh"
51
56
57#include "Conversion.hh"
58
59#include <wx/listctrl.h>
60
61using std::string;
62using namespace TTAMachine;
63
64const std::string ProximRegisterWindow::RF_PREFIX = "RF: ";
65const std::string ProximRegisterWindow::IMM_PREFIX = "IMM: ";
66
67/**
68 * Constructor.
69 *
70 * @param parent Parent window of the window.
71 * @param id Window identifier.
72 */
74 ProximMainFrame* parent, int id):
75 ProximUnitWindow(parent, id) {
76
77 valueList_->InsertColumn(0, _T("Register"), wxLIST_FORMAT_LEFT, 100);
78 valueList_->InsertColumn(1, _T("Value"), wxLIST_FORMAT_RIGHT, 120);
79
80 modeChoice_->Disable();
81
85
87 }
88}
89
90/**
91 * Destructor.
92 */
95
96
97/**
98 * Sets the available register file selections in the register file choice.
99 */
100void
102
103 unitChoice_->Clear();
104
105 // parallel simulation
106 const Machine::RegisterFileNavigator& rfNavigator =
108
109 for (int i = 0; i < rfNavigator.count(); i++) {
110 string rfName = RF_PREFIX + rfNavigator.item(i)->name();
111 unitChoice_->Append(WxConversion::toWxString(rfName));
112 }
113
114 const Machine::ImmediateUnitNavigator& immNavigator =
116 for (int i = 0; i < immNavigator.count(); i++) {
117 string rfName = IMM_PREFIX + immNavigator.item(i)->name();
118 unitChoice_->Append(WxConversion::toWxString(rfName));
119 }
120
121 unitChoice_->SetSelection(0);
122 update();
123}
124
125
126/**
127 * Event handler for the register file choicer.
128 *
129 * When the choice selection changes, corresponding register file registers
130 * are loaded in the register list.
131 */
132void
134
135 int rfIndex = unitChoice_->GetSelection();
136
137 modeChoice_->Disable();
138 modeChoice_->Enable();
139
140 // Machine is not a universal machine.
141 const Machine::RegisterFileNavigator& rfNavigator =
143
144 if (rfIndex < rfNavigator.count()) {
145 loadRegisterFile(*rfNavigator.item(rfIndex));
146 } else {
147 const Machine::ImmediateUnitNavigator& immNavigator =
149
150 rfIndex = rfIndex - rfNavigator.count();
151 loadImmediateUnit(*immNavigator.item(rfIndex));
152 }
153}
154
155/**
156 * Loads register file registers to the register list.
157 *
158 * @param rf Register file to display.
159 */
160void
162
163 valueList_->DeleteAllItems();
164
165 RegisterFileState& rfState =
167
168 // Append all registers to the register list.
169 int row = 0;
170 for (unsigned i = 0; i < rfState.registerCount(); i++) {
171 wxString value;
172 const RegisterState& state = rfState.registerState(i);
173
174 wxString mode = modeChoice_->GetStringSelection();
175
176 if (mode == MODE_UNSIGNED) {
178 } else if (mode == MODE_INT) {
179 int intValue = state.value().intValue();
180 value = WxConversion::toWxString(intValue);
181 } else if (mode == MODE_HEX) {
184 } else if (mode == MODE_BIN) {
185 int intValue = state.value().intValue();
187 Conversion::toBinString(intValue));
188 }
189
190 DisassemblyRegister r(rf.name(), i);
191 valueList_->InsertItem(
193
194 valueList_->SetItem(row, 1, value);
195 row++;
196 }
197}
198
199/**
200 * Loads register file registers to the register list.
201 *
202 * @param imm Immediate Unit to display.
203 */
204void
206
207 valueList_->DeleteAllItems();
208
209 LongImmediateUnitState& immState =
211
212 // Append all registers to the register list.
213 int row = 0;
214 for (int i = 0; i < immState.immediateRegisterCount(); i++) {
215 wxString value;
216
217 const LongImmediateRegisterState& state =
218 immState.immediateRegister(i);
219
220 wxString mode = modeChoice_->GetStringSelection();
221
222 if (mode == MODE_UNSIGNED) {
224 } else if (mode == MODE_INT) {
225 int intValue = state.value().intValue();
226 value = WxConversion::toWxString(intValue);
227 } else if (mode == MODE_HEX) {
230 } else if (mode == MODE_BIN) {
231 int intValue = static_cast<int>(state.value().unsignedValue());
233 Conversion::toBinString(intValue));
234 }
235
236 DisassemblyRegister r(imm.name(), i);
237 valueList_->InsertItem(
239
240 valueList_->SetItem(row, 1, value);
241 row++;
242 }
243}
244
245
246/**
247 * Sets the registerfile displayed in the window.
248 *
249 * @param name Name of the register file.
250 */
251void
253
254 unitChoice_->SetStringSelection(
256 update();
257}
258
259/**
260 * Sets the immediate unit dipslayed in the window.
261 *
262 * @param name Name of the immediate unit.
263 */
264void
266
267 unitChoice_->SetStringSelection(
269 update();
270}
static std::string toBinString(int source)
Definition Conversion.cc:81
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
std::string toString() const
virtual const SimValue & value() const
virtual LongImmediateRegisterState & immediateRegister(int i)
virtual int immediateRegisterCount() const
LongImmediateUnitState & longImmediateUnitState(const std::string &name)
RegisterFileState & registerFileState(const std::string &name)
void showImmediateUnit(const std::string &name)
void loadRegisterFile(const TTAMachine::RegisterFile &rf)
void showRegisterFile(const std::string &name)
void loadImmediateUnit(const TTAMachine::ImmediateUnit &iu)
static const std::string IMM_PREFIX
Prefix for immediate units in the unit choicer.
ProximRegisterWindow(ProximMainFrame *parent, int id)
static const std::string RF_PREFIX
Prefix for register files in the unit choicer.
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 RegisterState & registerState(int index)
virtual std::size_t registerCount() const
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
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
static wxString toWxString(const std::string &source)
mode
Definition tceopgen.cc:45