OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
MemoryControlmemoryControl_
 MemoryControl widget which displays the memory contents.
 
SimulatorFrontendsimulator_
 Simulator instance which contains the memory system to display.
 
wxBoxSizer * sizer_
 Toplevel sizer for the window widgets.
 
wxChoice * asChoice_
 Address space choicer widget.
 
wxStaticBoxSizer * addressRangeSizer_
 Sizer for address range widgets.
 
wxStaticText * asInfoText_
 Static text control displaying address space information.
 

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.

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}
MemoryControl * memoryControl_
MemoryControl widget which displays the memory contents.
wxStaticText * asInfoText_
Static text control displaying address space information.
MemorySystem * memorySystem_
Memory system to display in teh window.
SimulatorFrontend * simulator_
Simulator instance which contains the memory system to display.
bool hasSimulationEnded() const
bool isSimulationInitialized() const
bool isSimulationStopped() const

◆ ~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}
wxBoxSizer * sizer_
Toplevel sizer for the window widgets.
wxChoice * asChoice_
Address space choicer widget.

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}
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
void setMemory(Memory *memory)
MemoryPtr memory(const TTAMachine::AddressSpace &as)
boost::shared_ptr< Memory > MemoryPtr
MemorySystem & memorySystem(int coreId=-1)
virtual ULongWord end() const
virtual int width() const
virtual ULongWord start() const
virtual TCEString name() const
static wxString toWxString(const std::string &source)

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;
166}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
unsigned int memoryCount() const
const TTAMachine::AddressSpace & addressSpace(unsigned int i)
void onASChoice(wxCommandEvent &event)

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}
void loadMemory(const TTAMachine::AddressSpace &as)

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}
void highlight(Word address, unsigned count, const wxColour &colour)
std::pair< Word, int > MemoryAccess
MemoryAccess writeAccess(unsigned int idx) const
unsigned int readAccessCount() const
unsigned int writeAccessCount() const
MemoryAccess readAccess(unsigned int idx) const

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: