OpenASIP  2.0
Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
ProximRegisterWindow Class Reference

#include <ProximRegisterWindow.hh>

Inheritance diagram for ProximRegisterWindow:
Inheritance graph
Collaboration diagram for ProximRegisterWindow:
Collaboration graph

Public Member Functions

 ProximRegisterWindow (ProximMainFrame *parent, int id)
 
virtual ~ProximRegisterWindow ()
 
void showRegisterFile (const std::string &name)
 
void showImmediateUnit (const std::string &name)
 
- Public Member Functions inherited from ProximUnitWindow
 ProximUnitWindow (ProximMainFrame *parent, int id)
 
virtual ~ProximUnitWindow ()
 
- Public Member Functions inherited from ProximSimulatorWindow
virtual void reset ()
 

Private Member Functions

void loadRegisterFile (const TTAMachine::RegisterFile &rf)
 
void loadImmediateUnit (const TTAMachine::ImmediateUnit &iu)
 
virtual void reinitialize ()
 
virtual void update ()
 

Static Private Attributes

static const std::string RF_PREFIX = "RF: "
 Prefix for register files in the unit choicer. More...
 
static const std::string IMM_PREFIX = "IMM: "
 Prefix for immediate units in the unit choicer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ProximSimulatorWindow
 ProximSimulatorWindow (ProximMainFrame *mainFrame, wxWindowID id=-1, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
 
virtual ~ProximSimulatorWindow ()
 
- Protected Attributes inherited from ProximUnitWindow
SimulatorFrontendsimulator_
 Simulator instance . More...
 
wxChoice * unitChoice_
 Unit choicer widget. More...
 
wxChoice * modeChoice_
 Value display mode choicer widget. More...
 
wxListCtrl * valueList_
 List widget for the values. More...
 
- Static Protected Attributes inherited from ProximUnitWindow
static const wxString MODE_INT = _T("Int")
 String for the mode choicer integer mode. More...
 
static const wxString MODE_UNSIGNED = _T("Unsigned")
 String for the mode choicer unsigned integer mode. More...
 
static const wxString MODE_HEX = _T("Hex")
 String for the mode choicer hexadecimal mode. More...
 
static const wxString MODE_BIN = _T("Binary")
 String for the mode choicer binary mode. More...
 

Detailed Description

Proxim subwindow which displays register values.

This window listens to SimulatorEvents and updates the window contents automatically.

Definition at line 54 of file ProximRegisterWindow.hh.

Constructor & Destructor Documentation

◆ ProximRegisterWindow()

ProximRegisterWindow::ProximRegisterWindow ( ProximMainFrame parent,
int  id 
)

Constructor.

Parameters
parentParent window of the window.
idWindow identifier.

Definition at line 73 of file ProximRegisterWindow.cc.

74  :
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 
86  reinitialize();
87  }
88 }

References SimulatorFrontend::hasSimulationEnded(), SimulatorFrontend::isSimulationInitialized(), SimulatorFrontend::isSimulationStopped(), ProximUnitWindow::modeChoice_, reinitialize(), ProximUnitWindow::simulator_, and ProximUnitWindow::valueList_.

Here is the call graph for this function:

◆ ~ProximRegisterWindow()

ProximRegisterWindow::~ProximRegisterWindow ( )
virtual

Destructor.

Definition at line 93 of file ProximRegisterWindow.cc.

93  {
94 }

Member Function Documentation

◆ loadImmediateUnit()

void ProximRegisterWindow::loadImmediateUnit ( const TTAMachine::ImmediateUnit iu)
private

Loads register file registers to the register list.

Parameters
immImmediate Unit to display.

Definition at line 205 of file ProximRegisterWindow.cc.

205  {
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) {
223  value = WxConversion::toWxString(state.value().unsignedValue());
224  } else if (mode == MODE_INT) {
225  int intValue = state.value().intValue();
226  value = WxConversion::toWxString(intValue);
227  } else if (mode == MODE_HEX) {
228  value = WxConversion::toWxString(
230  } else if (mode == MODE_BIN) {
231  int intValue = static_cast<int>(state.value().unsignedValue());
232  value = WxConversion::toWxString(
233  Conversion::toBinString(intValue));
234  }
235 
236  DisassemblyRegister r(imm.name(), i);
237  valueList_->InsertItem(
238  row, WxConversion::toWxString(r.toString()));
239 
240  valueList_->SetItem(row, 1, value);
241  row++;
242  }
243 }

References LongImmediateUnitState::immediateRegister(), LongImmediateUnitState::immediateRegisterCount(), SimValue::intValue(), MachineState::longImmediateUnitState(), SimulatorFrontend::machineState(), ProximUnitWindow::MODE_BIN, ProximUnitWindow::MODE_HEX, ProximUnitWindow::MODE_INT, ProximUnitWindow::MODE_UNSIGNED, ProximUnitWindow::modeChoice_, TTAMachine::Component::name(), ProximUnitWindow::simulator_, Conversion::toBinString(), Conversion::toHexString(), DisassemblyRegister::toString(), WxConversion::toWxString(), SimValue::unsignedValue(), LongImmediateRegisterState::value(), and ProximUnitWindow::valueList_.

Referenced by update().

Here is the call graph for this function:

◆ loadRegisterFile()

void ProximRegisterWindow::loadRegisterFile ( const TTAMachine::RegisterFile rf)
private

Loads register file registers to the register list.

Parameters
rfRegister file to display.

Definition at line 161 of file ProximRegisterWindow.cc.

161  {
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) {
177  value = WxConversion::toWxString(state.value().unsignedValue());
178  } else if (mode == MODE_INT) {
179  int intValue = state.value().intValue();
180  value = WxConversion::toWxString(intValue);
181  } else if (mode == MODE_HEX) {
182  value = WxConversion::toWxString(
184  } else if (mode == MODE_BIN) {
185  int intValue = state.value().intValue();
186  value = WxConversion::toWxString(
187  Conversion::toBinString(intValue));
188  }
189 
190  DisassemblyRegister r(rf.name(), i);
191  valueList_->InsertItem(
192  row, WxConversion::toWxString(r.toString()));
193 
194  valueList_->SetItem(row, 1, value);
195  row++;
196  }
197 }

References SimValue::intValue(), SimulatorFrontend::machineState(), ProximUnitWindow::MODE_BIN, ProximUnitWindow::MODE_HEX, ProximUnitWindow::MODE_INT, ProximUnitWindow::MODE_UNSIGNED, ProximUnitWindow::modeChoice_, TTAMachine::Component::name(), RegisterFileState::registerCount(), MachineState::registerFileState(), RegisterFileState::registerState(), ProximUnitWindow::simulator_, Conversion::toBinString(), Conversion::toHexString(), DisassemblyRegister::toString(), WxConversion::toWxString(), SimValue::unsignedValue(), RegisterState::value(), and ProximUnitWindow::valueList_.

Referenced by update().

Here is the call graph for this function:

◆ reinitialize()

void ProximRegisterWindow::reinitialize ( )
privatevirtual

Sets the available register file selections in the register file choice.

Reimplemented from ProximUnitWindow.

Definition at line 101 of file ProximRegisterWindow.cc.

101  {
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 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), IMM_PREFIX, TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), SimulatorFrontend::machine(), TTAMachine::Machine::registerFileNavigator(), RF_PREFIX, ProximUnitWindow::simulator_, WxConversion::toWxString(), ProximUnitWindow::unitChoice_, and update().

Referenced by ProximRegisterWindow().

Here is the call graph for this function:

◆ showImmediateUnit()

void ProximRegisterWindow::showImmediateUnit ( const std::string &  name)

Sets the immediate unit dipslayed in the window.

Parameters
nameName of the immediate unit.

Definition at line 265 of file ProximRegisterWindow.cc.

265  {
266 
267  unitChoice_->SetStringSelection(
269  update();
270 }

References IMM_PREFIX, WxConversion::toWxString(), ProximUnitWindow::unitChoice_, and update().

Here is the call graph for this function:

◆ showRegisterFile()

void ProximRegisterWindow::showRegisterFile ( const std::string &  name)

Sets the registerfile displayed in the window.

Parameters
nameName of the register file.

Definition at line 252 of file ProximRegisterWindow.cc.

252  {
253 
254  unitChoice_->SetStringSelection(
256  update();
257 }

References RF_PREFIX, WxConversion::toWxString(), ProximUnitWindow::unitChoice_, and update().

Referenced by ProximShowRegistersCmd::Do().

Here is the call graph for this function:

◆ update()

void ProximRegisterWindow::update ( )
privatevirtual

Event handler for the register file choicer.

When the choice selection changes, corresponding register file registers are loaded in the register list.

Reimplemented from ProximUnitWindow.

Definition at line 133 of file ProximRegisterWindow.cc.

133  {
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 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::immediateUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), loadImmediateUnit(), loadRegisterFile(), SimulatorFrontend::machine(), ProximUnitWindow::modeChoice_, TTAMachine::Machine::registerFileNavigator(), ProximUnitWindow::simulator_, and ProximUnitWindow::unitChoice_.

Referenced by reinitialize(), showImmediateUnit(), and showRegisterFile().

Here is the call graph for this function:

Member Data Documentation

◆ IMM_PREFIX

const std::string ProximRegisterWindow::IMM_PREFIX = "IMM: "
staticprivate

Prefix for immediate units in the unit choicer.

Definition at line 70 of file ProximRegisterWindow.hh.

Referenced by reinitialize(), and showImmediateUnit().

◆ RF_PREFIX

const std::string ProximRegisterWindow::RF_PREFIX = "RF: "
staticprivate

Prefix for register files in the unit choicer.

Definition at line 68 of file ProximRegisterWindow.hh.

Referenced by reinitialize(), and showRegisterFile().


The documentation for this class was generated from the following files:
ProximUnitWindow::ProximUnitWindow
ProximUnitWindow(ProximMainFrame *parent, int id)
Definition: ProximUnitWindow.cc:67
SimValue::intValue
int intValue() const
Definition: SimValue.cc:895
LongImmediateUnitState::immediateRegister
virtual LongImmediateRegisterState & immediateRegister(int i)
Definition: LongImmediateUnitState.cc:160
MachineState::longImmediateUnitState
LongImmediateUnitState & longImmediateUnitState(const std::string &name)
Definition: MachineState.cc:196
ProximRegisterWindow::loadImmediateUnit
void loadImmediateUnit(const TTAMachine::ImmediateUnit &iu)
Definition: ProximRegisterWindow.cc:205
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
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
ProximUnitWindow::modeChoice_
wxChoice * modeChoice_
Value display mode choicer widget.
Definition: ProximUnitWindow.hh:62
LongImmediateUnitState::immediateRegisterCount
virtual int immediateRegisterCount() const
Definition: LongImmediateUnitState.cc:174
SimulatorFrontend::isSimulationStopped
bool isSimulationStopped() const
Definition: SimulatorFrontend.cc:1271
TTAMachine::Machine::Navigator::count
int count() const
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
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
LongImmediateRegisterState
Definition: LongImmediateRegisterState.hh:47
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
ProximUnitWindow::valueList_
wxListCtrl * valueList_
List widget for the values.
Definition: ProximUnitWindow.hh:64
ProximUnitWindow::MODE_INT
static const wxString MODE_INT
String for the mode choicer integer mode.
Definition: ProximUnitWindow.hh:67
ProximRegisterWindow::reinitialize
virtual void reinitialize()
Definition: ProximRegisterWindow.cc:101
ProximRegisterWindow::RF_PREFIX
static const std::string RF_PREFIX
Prefix for register files in the unit choicer.
Definition: ProximRegisterWindow.hh:68
ProximRegisterWindow::update
virtual void update()
Definition: ProximRegisterWindow.cc:133
ProximUnitWindow::simulator_
SimulatorFrontend * simulator_
Simulator instance .
Definition: ProximUnitWindow.hh:58
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
ProximRegisterWindow::loadRegisterFile
void loadRegisterFile(const TTAMachine::RegisterFile &rf)
Definition: ProximRegisterWindow.cc:161
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
RegisterFileState::registerCount
virtual std::size_t registerCount() const
Definition: RegisterFileState.cc:95
RegisterFileState::registerState
virtual RegisterState & registerState(int index)
Definition: RegisterFileState.cc:81
SimulatorFrontend::machineState
MachineState & machineState(int core=-1)
Definition: SimulatorFrontend.cc:2138
Conversion::toBinString
static std::string toBinString(int source)
Definition: Conversion.cc:81
RegisterFileState
Definition: RegisterFileState.hh:49
RegisterState
Definition: RegisterState.hh:50
DisassemblyRegister
Definition: DisassemblyRegister.hh:51
ProximUnitWindow::MODE_HEX
static const wxString MODE_HEX
String for the mode choicer hexadecimal mode.
Definition: ProximUnitWindow.hh:71
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
ProximRegisterWindow::IMM_PREFIX
static const std::string IMM_PREFIX
Prefix for immediate units in the unit choicer.
Definition: ProximRegisterWindow.hh:70
SimulatorFrontend::hasSimulationEnded
bool hasSimulationEnded() const
Definition: SimulatorFrontend.cc:1283
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
LongImmediateUnitState
Definition: LongImmediateUnitState.hh:55
LongImmediateRegisterState::value
virtual const SimValue & value() const
Definition: LongImmediateRegisterState.cc:99
MachineState::registerFileState
RegisterFileState & registerFileState(const std::string &name)
Definition: MachineState.cc:213