OpenASIP 2.2
Loading...
Searching...
No Matches
ProximMemoryWindow.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 ProximMemoryWindow.cc
26 *
27 * Definition of ProximMemoryWindow 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#include <wx/statline.h>
36#include <wx/spinctrl.h>
37
38#include "ProximMemoryWindow.hh"
39#include "MemoryControl.hh"
40#include "WxConversion.hh"
41#include "MemorySystem.hh"
42#include "Proxim.hh"
45#include "Machine.hh"
46#include "MemoryProxy.hh"
47#include "Conversion.hh"
48
52 EVT_CHOICE(ID_AS_CHOICE, ProximMemoryWindow::onASChoice)
54
55using std::string;
56using namespace TTAMachine;
57
58
59/**
60 * Constructor.
61 *
62 * @param parent Parent window of the window.
63 * @param id Window identifier.
64 */
66 ProximMainFrame* parent, int id):
67 ProximSimulatorWindow(parent, id, wxDefaultPosition, wxSize(800,600)),
68 memorySystem_(NULL),
69 memoryControl_(NULL), asInfoText_(NULL) {
70
71 createContents();
72 simulator_ = wxGetApp().simulation()->frontend();
73
74 if (simulator_->isSimulationInitialized() ||
75 simulator_->isSimulationStopped() ||
76 simulator_->hasSimulationEnded()) {
77
78 loadProgramMemory();
79 }
80}
81
82
83/**
84 * Destructor.
85 */
88
89
90/**
91 * Loads memory from the given address space to the memory window.
92 *
93 * @param as Address space of the memory to load.
94 */
95void
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}
127
128
129/**
130 * Event handler which is called when a new program is loaded in the simulator.
131 */
132void
136
137/**
138 * Resets the window when a new program or machine is being loaded in the
139 * simulator.
140 */
141void
143 asChoice_->Clear();
144 asInfoText_->SetLabel(_T(""));
145 if (memoryControl_ != NULL) {
146 memoryControl_->Destroy();
147 memoryControl_ = NULL;
148 }
149}
150
151/**
152 * Initializes simulated memory system in the window.
153 */
154void
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}
167
168
169/**
170 * Event handler for the address space choicer.
171 *
172 * Loads the selected address space in the memory control.
173 */
174void
176 MemorySystem& memorySystem = simulator_->memorySystem();
177 const AddressSpace& as =
178 memorySystem.addressSpace(asChoice_->GetSelection());
179 loadMemory(as);
180}
181
182
183/**
184 * Event handler for simulation stop.
185 *
186 * Refreshes the memory display.
187 */
188void
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}
215
216
217/**
218 * Creates the window contents.
219 */
220void
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}
END_EVENT_TABLE() using namespace IDF
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
#define EVT_SIMULATOR_PROGRAM_LOADED(id, fn)
#define EVT_SIMULATOR_STOP(id, fn)
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
void highlight(Word address, unsigned count, const wxColour &colour)
void setMemory(Memory *memory)
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
MemoryPtr memory(const TTAMachine::AddressSpace &as)
unsigned int memoryCount() const
boost::shared_ptr< Memory > MemoryPtr
const TTAMachine::AddressSpace & addressSpace(unsigned int i)
MemoryControl * memoryControl_
MemoryControl widget which displays the memory contents.
void onProgramLoaded(const SimulatorEvent &event)
wxBoxSizer * sizer_
Toplevel sizer for the window widgets.
wxStaticText * asInfoText_
Static text control displaying address space information.
void onASChoice(wxCommandEvent &event)
SimulatorFrontend * simulator_
Simulator instance which contains the memory system to display.
wxChoice * asChoice_
Address space choicer widget.
void loadMemory(const TTAMachine::AddressSpace &as)
void onSimulationStop(const SimulatorEvent &event)
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)