OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ProximMemoryWindow Class Reference

#include <ProximMemoryWindow.hh>

Inheritance diagram for ProximMemoryWindow:
Inheritance graph
Collaboration diagram for ProximMemoryWindow:
Collaboration graph

Public Member Functions

 ProximMemoryWindow (ProximMainFrame *parent, int id)
 
virtual ~ProximMemoryWindow ()
 
virtual void reset ()
 

Private Types

enum  {
  ID_AS_CHOICE = 10000, ID_TEXT_AS, ID_TEXT_AS_INFO, ID_TEXT_START_ADDRESS,
  ID_START_ADDRESS, ID_TEXT_DISPLAY, ID_DISPLAY_SIZE_CHOICE, ID_LINE
}
 

Private Member Functions

void onProgramLoaded (const SimulatorEvent &event)
 
void onSimulationStop (const SimulatorEvent &event)
 
void loadProgramMemory ()
 
void loadMemory (const TTAMachine::AddressSpace &as)
 
void initialize ()
 
void onASChoice (wxCommandEvent &event)
 
void onDisplayRangeChoice (wxCommandEvent &event)
 
void createContents ()
 

Private Attributes

MemorySystemmemorySystem_
 Memory system to display in teh window. More...
 
MemoryControlmemoryControl_
 MemoryControl widget which displays the memory contents. More...
 
SimulatorFrontendsimulator_
 Simulator instance which contains the memory system to display. More...
 
wxBoxSizer * sizer_
 Toplevel sizer for the window widgets. More...
 
wxChoice * asChoice_
 Address space choicer widget. More...
 
wxStaticBoxSizer * addressRangeSizer_
 Sizer for address range widgets. More...
 
wxStaticText * asInfoText_
 Static text control displaying address space information. 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 ()
 

Detailed Description

Proxim subwindow which displays memory contents.

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

Definition at line 54 of file ProximMemoryWindow.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_AS_CHOICE 
ID_TEXT_AS 
ID_TEXT_AS_INFO 
ID_TEXT_START_ADDRESS 
ID_START_ADDRESS 
ID_TEXT_DISPLAY 
ID_DISPLAY_SIZE_CHOICE 
ID_LINE 

Definition at line 85 of file ProximMemoryWindow.hh.

85  {
86  ID_AS_CHOICE = 10000,
87  ID_TEXT_AS,
93  ID_LINE
94  };

Constructor & Destructor Documentation

◆ ProximMemoryWindow()

ProximMemoryWindow::ProximMemoryWindow ( ProximMainFrame parent,
int  id 
)

Constructor.

Parameters
parentParent window of the window.
idWindow identifier.

Definition at line 65 of file ProximMemoryWindow.cc.

66  :
67  ProximSimulatorWindow(parent, id, wxDefaultPosition, wxSize(800,600)),
68  memorySystem_(NULL),
69  memoryControl_(NULL), asInfoText_(NULL) {
70 
72  simulator_ = wxGetApp().simulation()->frontend();
73 
77 
79  }
80 }

◆ ~ProximMemoryWindow()

ProximMemoryWindow::~ProximMemoryWindow ( )
virtual

Destructor.

Definition at line 86 of file ProximMemoryWindow.cc.

86  {
87 }

Member Function Documentation

◆ createContents()

void ProximMemoryWindow::createContents ( )
private

Creates the window contents.

Definition at line 221 of file ProximMemoryWindow.cc.

221  {
222 
223  sizer_= new wxBoxSizer(wxVERTICAL);
224  wxBoxSizer *item1 = new wxBoxSizer(wxHORIZONTAL);
225  wxStaticText *item2 = new wxStaticText(
226  this, ID_TEXT_AS, wxT("Address space:"),
227  wxDefaultPosition, wxDefaultSize, 0);
228 
229  item1->Add(item2, 0, wxALIGN_CENTER|wxALL, 5);
230 
231  wxString *strs3 = (wxString*) NULL;
232  asChoice_ = new wxChoice(
233  this, ID_AS_CHOICE, wxDefaultPosition, wxSize(150,-1), 0, strs3, 0);
234 
235  item1->Add(asChoice_, 0, wxALIGN_CENTER|wxALL, 5);
236  sizer_->Add(item1, 0, wxALIGN_CENTER|wxALL, 5);
237 
238  wxStaticLine *item4 = new wxStaticLine(
239  this, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL);
240 
241  sizer_->Add(item4, 0, wxGROW|wxALL, 5);
242 
243  asInfoText_ = new wxStaticText(this, ID_TEXT_AS_INFO, wxT(""));
244  sizer_->Add(asInfoText_, 0, wxGROW|wxALL, 5);
245 
246  this->SetSizer(sizer_);
247  sizer_->SetSizeHints(this);
248 
249 }

References asChoice_, asInfoText_, ID_AS_CHOICE, ID_LINE, ID_TEXT_AS, ID_TEXT_AS_INFO, and sizer_.

◆ initialize()

void ProximMemoryWindow::initialize ( )
private

◆ loadMemory()

void ProximMemoryWindow::loadMemory ( const TTAMachine::AddressSpace as)
private

Loads memory from the given address space to the memory window.

Parameters
asAddress space of the memory to load.

Definition at line 96 of file ProximMemoryWindow.cc.

96  {
97 
98  MemorySystem& memorySystem = simulator_->memorySystem();
99 
100  MemorySystem::MemoryPtr mem = memorySystem.memory(as);
101 
102  if (memoryControl_ == NULL) {
104  new MemoryControl(this, mem.get());
105  sizer_->Add(memoryControl_, 1, wxGROW);
106  sizer_->Layout();
107  Fit();
108  } else {
109  memoryControl_->setMemory(mem.get());
110  }
111 
112  wxString asInfo = WxConversion::toWxString(as.name());
113  asInfo.Prepend(_T(" "));
114  asInfo.Append(_T(": "));
115  asInfo.Append(
117 
118  asInfo.Append(_T(" - "));
119 
120  asInfo.Append(
122 
123  asInfo.Append(_T(" MAU: "));
124  asInfo.Append(WxConversion::toWxString(as.width()));
125  asInfoText_->SetLabel(asInfo);
126 }

References asInfoText_, TTAMachine::AddressSpace::end(), MemorySystem::memory(), memoryControl_, SimulatorFrontend::memorySystem(), TTAMachine::Component::name(), MemoryControl::setMemory(), simulator_, sizer_, TTAMachine::AddressSpace::start(), Conversion::toHexString(), WxConversion::toWxString(), and TTAMachine::AddressSpace::width().

Referenced by onASChoice().

Here is the call graph for this function:

◆ loadProgramMemory()

void ProximMemoryWindow::loadProgramMemory ( )
private

Initializes simulated memory system in the window.

Definition at line 155 of file ProximMemoryWindow.cc.

155  {
156  asChoice_->Clear();
157  MemorySystem& memorySystem = simulator_->memorySystem();
158 
159  for (unsigned int i = 0; i < memorySystem.memoryCount(); i++) {
160  string asName = memorySystem.addressSpace(i).name();
161  asChoice_->Append(WxConversion::toWxString(asName));
162  }
163  asChoice_->SetSelection(0);
164  wxCommandEvent dummy;
165  onASChoice(dummy);
166 }

References MemorySystem::addressSpace(), asChoice_, dummy, MemorySystem::memoryCount(), SimulatorFrontend::memorySystem(), TTAMachine::Component::name(), onASChoice(), simulator_, and WxConversion::toWxString().

Referenced by onProgramLoaded().

Here is the call graph for this function:

◆ onASChoice()

void ProximMemoryWindow::onASChoice ( wxCommandEvent &  event)
private

Event handler for the address space choicer.

Loads the selected address space in the memory control.

Definition at line 175 of file ProximMemoryWindow.cc.

175  {
176  MemorySystem& memorySystem = simulator_->memorySystem();
177  const AddressSpace& as =
178  memorySystem.addressSpace(asChoice_->GetSelection());
179  loadMemory(as);
180 }

References MemorySystem::addressSpace(), asChoice_, loadMemory(), SimulatorFrontend::memorySystem(), and simulator_.

Referenced by loadProgramMemory().

Here is the call graph for this function:

◆ onDisplayRangeChoice()

void ProximMemoryWindow::onDisplayRangeChoice ( wxCommandEvent &  event)
private

◆ onProgramLoaded()

void ProximMemoryWindow::onProgramLoaded ( const SimulatorEvent event)
private

Event handler which is called when a new program is loaded in the simulator.

Definition at line 133 of file ProximMemoryWindow.cc.

133  {
135 }

References loadProgramMemory().

Here is the call graph for this function:

◆ onSimulationStop()

void ProximMemoryWindow::onSimulationStop ( const SimulatorEvent event)
private

Event handler for simulation stop.

Refreshes the memory display.

Definition at line 189 of file ProximMemoryWindow.cc.

189  {
190 
192 
193  MemorySystem& memorySystem = simulator_->memorySystem();
194  MemoryProxy* mem = dynamic_cast<MemoryProxy*>(
195  memorySystem.memory(asChoice_->GetSelection()).get());
196 
197  if (mem != NULL) {
198 
199  unsigned reads = mem->readAccessCount();
200  for (unsigned i = 0; i < reads; i++) {
201  MemoryProxy::MemoryAccess access = mem->readAccess(i);
203  access.first, access.second, *wxGREEN);
204  }
205 
206  unsigned writes = mem->writeAccessCount();
207  for (unsigned i = 0; i < writes; i++) {
208  MemoryProxy::MemoryAccess access = mem->writeAccess(i);
210  access.first, access.second, *wxRED);
211  }
212  }
214 }

References asChoice_, MemoryControl::clearHighlights(), MemoryControl::highlight(), MemorySystem::memory(), memoryControl_, SimulatorFrontend::memorySystem(), MemoryProxy::readAccess(), MemoryProxy::readAccessCount(), simulator_, MemoryControl::updateView(), MemoryProxy::writeAccess(), and MemoryProxy::writeAccessCount().

Here is the call graph for this function:

◆ reset()

void ProximMemoryWindow::reset ( )
virtual

Resets the window when a new program or machine is being loaded in the simulator.

Reimplemented from ProximSimulatorWindow.

Definition at line 142 of file ProximMemoryWindow.cc.

142  {
143  asChoice_->Clear();
144  asInfoText_->SetLabel(_T(""));
145  if (memoryControl_ != NULL) {
146  memoryControl_->Destroy();
147  memoryControl_ = NULL;
148  }
149 }

References asChoice_, asInfoText_, and memoryControl_.

Member Data Documentation

◆ addressRangeSizer_

wxStaticBoxSizer* ProximMemoryWindow::addressRangeSizer_
private

Sizer for address range widgets.

Definition at line 80 of file ProximMemoryWindow.hh.

◆ asChoice_

wxChoice* ProximMemoryWindow::asChoice_
private

Address space choicer widget.

Definition at line 78 of file ProximMemoryWindow.hh.

Referenced by createContents(), loadProgramMemory(), onASChoice(), onSimulationStop(), and reset().

◆ asInfoText_

wxStaticText* ProximMemoryWindow::asInfoText_
private

Static text control displaying address space information.

Definition at line 82 of file ProximMemoryWindow.hh.

Referenced by createContents(), loadMemory(), and reset().

◆ memoryControl_

MemoryControl* ProximMemoryWindow::memoryControl_
private

MemoryControl widget which displays the memory contents.

Definition at line 72 of file ProximMemoryWindow.hh.

Referenced by loadMemory(), onSimulationStop(), and reset().

◆ memorySystem_

MemorySystem* ProximMemoryWindow::memorySystem_
private

Memory system to display in teh window.

Definition at line 70 of file ProximMemoryWindow.hh.

◆ simulator_

SimulatorFrontend* ProximMemoryWindow::simulator_
private

Simulator instance which contains the memory system to display.

Definition at line 74 of file ProximMemoryWindow.hh.

Referenced by loadMemory(), loadProgramMemory(), onASChoice(), and onSimulationStop().

◆ sizer_

wxBoxSizer* ProximMemoryWindow::sizer_
private

Toplevel sizer for the window widgets.

Definition at line 76 of file ProximMemoryWindow.hh.

Referenced by createContents(), and loadMemory().


The documentation for this class was generated from the following files:
ProximMemoryWindow::loadMemory
void loadMemory(const TTAMachine::AddressSpace &as)
Definition: ProximMemoryWindow.cc:96
WxConversion::toWxString
static wxString toWxString(const std::string &source)
ProximMemoryWindow::memorySystem_
MemorySystem * memorySystem_
Memory system to display in teh window.
Definition: ProximMemoryWindow.hh:70
MemoryControl::highlight
void highlight(Word address, unsigned count, const wxColour &colour)
Definition: MemoryControl.cc:564
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ProximMemoryWindow::ID_TEXT_AS
@ ID_TEXT_AS
Definition: ProximMemoryWindow.hh:87
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
ProximMemoryWindow::ID_TEXT_AS_INFO
@ ID_TEXT_AS_INFO
Definition: ProximMemoryWindow.hh:88
SimulatorFrontend::isSimulationStopped
bool isSimulationStopped() const
Definition: SimulatorFrontend.cc:1271
ProximMemoryWindow::asChoice_
wxChoice * asChoice_
Address space choicer widget.
Definition: ProximMemoryWindow.hh:78
MemoryProxy::readAccess
MemoryAccess readAccess(unsigned int idx) const
Definition: MemoryProxy.cc:133
ProximMemoryWindow::onASChoice
void onASChoice(wxCommandEvent &event)
Definition: ProximMemoryWindow.cc:175
ProximMemoryWindow::loadProgramMemory
void loadProgramMemory()
Definition: ProximMemoryWindow.cc:155
MemoryControl::clearHighlights
void clearHighlights()
Definition: MemoryControl.cc:553
MemoryProxy::MemoryAccess
std::pair< Word, int > MemoryAccess
Definition: MemoryProxy.hh:56
ProximMemoryWindow::ID_TEXT_DISPLAY
@ ID_TEXT_DISPLAY
Definition: ProximMemoryWindow.hh:91
MemoryProxy::writeAccessCount
unsigned int writeAccessCount() const
Definition: MemoryProxy.cc:145
MemorySystem::MemoryPtr
boost::shared_ptr< Memory > MemoryPtr
Definition: MemorySystem.hh:57
MemorySystem::memoryCount
unsigned int memoryCount() const
Definition: MemorySystem.cc:226
MemoryControl::updateView
void updateView()
Definition: MemoryControl.cc:290
ProximMemoryWindow::asInfoText_
wxStaticText * asInfoText_
Static text control displaying address space information.
Definition: ProximMemoryWindow.hh:82
ProximMemoryWindow::memoryControl_
MemoryControl * memoryControl_
MemoryControl widget which displays the memory contents.
Definition: ProximMemoryWindow.hh:72
ProximMemoryWindow::ID_DISPLAY_SIZE_CHOICE
@ ID_DISPLAY_SIZE_CHOICE
Definition: ProximMemoryWindow.hh:92
MemoryControl
Definition: MemoryControl.hh:53
MemoryProxy
Definition: MemoryProxy.hh:53
ProximMemoryWindow::ID_TEXT_START_ADDRESS
@ ID_TEXT_START_ADDRESS
Definition: ProximMemoryWindow.hh:89
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
ProximMemoryWindow::ID_LINE
@ ID_LINE
Definition: ProximMemoryWindow.hh:93
MemorySystem
Definition: MemorySystem.hh:55
MemoryControl::setMemory
void setMemory(Memory *memory)
Definition: MemoryControl.cc:477
Conversion::toHexString
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
TTAMachine::AddressSpace::width
virtual int width() const
Definition: AddressSpace.cc:155
ProximMemoryWindow::simulator_
SimulatorFrontend * simulator_
Simulator instance which contains the memory system to display.
Definition: ProximMemoryWindow.hh:74
ProximMemoryWindow::createContents
void createContents()
Definition: ProximMemoryWindow.cc:221
ProximMemoryWindow::ID_AS_CHOICE
@ ID_AS_CHOICE
Definition: ProximMemoryWindow.hh:86
SimulatorFrontend::memorySystem
MemorySystem & memorySystem(int coreId=-1)
Definition: SimulatorFrontend.cc:2121
MemoryProxy::writeAccess
MemoryAccess writeAccess(unsigned int idx) const
Definition: MemoryProxy.cc:157
MemorySystem::memory
MemoryPtr memory(const TTAMachine::AddressSpace &as)
Definition: MemorySystem.cc:170
ProximMemoryWindow::sizer_
wxBoxSizer * sizer_
Toplevel sizer for the window widgets.
Definition: ProximMemoryWindow.hh:76
SimulatorFrontend::hasSimulationEnded
bool hasSimulationEnded() const
Definition: SimulatorFrontend.cc:1283
MemorySystem::addressSpace
const TTAMachine::AddressSpace & addressSpace(unsigned int i)
Definition: MemorySystem.cc:261
TTAMachine::AddressSpace::start
virtual ULongWord start() const
Definition: AddressSpace.cc:166
TTAMachine::AddressSpace::end
virtual ULongWord end() const
Definition: AddressSpace.cc:177
SimulatorFrontend::isSimulationInitialized
bool isSimulationInitialized() const
Definition: SimulatorFrontend.cc:1228
MemoryProxy::readAccessCount
unsigned int readAccessCount() const
Definition: MemoryProxy.cc:122
ProximSimulatorWindow::ProximSimulatorWindow
ProximSimulatorWindow(ProximMainFrame *mainFrame, wxWindowID id=-1, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Definition: ProximSimulatorWindow.cc:49
ProximMemoryWindow::ID_START_ADDRESS
@ ID_START_ADDRESS
Definition: ProximMemoryWindow.hh:90