OpenASIP  2.0
MemoryControl.hh
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 MemoryControl.hh
26  *
27  * Declaration of MemoryControl class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_MEMORY_CONTROL_HH
35 #define TTA_MEMORY_CONTROL_HH
36 
37 #include <wx/wx.h>
38 #include <wx/grid.h>
39 #include <vector>
40 
41 #include "BaseType.hh"
42 #include "Exception.hh"
43 
44 class MemoryGridTable;
45 class Memory;
46 
47 /**
48  * Widget for showing the contents of the memory.
49  *
50  * The contents of the memory is shown in bytes, half words, words, or
51  * double words, and either in binary, hexa, float, decimal, or double format.
52  */
53 class MemoryControl : public wxPanel {
54 public:
56  wxWindow* parent,
57  Memory* memory,
58  wxWindowID id = -1,
59  const wxPoint& pos = wxDefaultPosition,
60  const wxSize& size = wxDefaultSize,
61  const wxString& name = _T("MemoryControl"));
62 
63  virtual ~MemoryControl();
64  void updateView();
65  void setMemory(Memory* memory);
66 
67  void clearHighlights();
68  void highlight(Word address, unsigned count, const wxColour& colour);
69 
70 private:
71  /// Copying not allowed.
73  /// Assignment not allowed.
75 
76  /// Size label for byte size.
77  static const std::string SIZE_MAU;
78  /// Size label for half word size.
79  static const std::string SIZE_TWO_MAUS;
80  /// Size label for word size.
81  static const std::string SIZE_FOUR_MAUS;
82  /// Size label for word size.
83  static const std::string SIZE_EIGHT_MAUS;
84 
85  /// Data label for binary format.
86  static const std::string DATA_BIN;
87  /// Data label for hexa format.
88  static const std::string DATA_HEX;
89  /// Data label for signed int format.
90  static const std::string DATA_SIGNED_INT;
91  /// Data label for unsigned int format.
92  static const std::string DATA_UNSIGNED_INT;
93  /// Data label for float format.
94  static const std::string DATA_FLOAT;
95  /// Data label for double format.
96  static const std::string DATA_DOUBLE;
97 
98  /// Table width label for 8 column mode
99  static const wxString WIDTH_8;
100  /// Table width label for 16 column mode
101  static const wxString WIDTH_16;
102  /// Table width label for 32 column mode
103  static const wxString WIDTH_32;
104 
105  void createContents();
106  void onGoTo(wxCommandEvent& event);
107  void onSizeModeChanged(wxCommandEvent&);
108  void onDataModeChanged(wxCommandEvent&);
109  void onWidthChanged(wxCommandEvent&);
110  void onSize(wxSizeEvent&);
111  void onWriteMemory(wxGridEvent& event);
112  void onChar(wxKeyEvent& event);
113  void clearMemory();
114  void copySelection();
115 
116  /// Used for access to memory contents.
118  /// Size of the minimum addressable unit.
119  int MAUSize_;
120  /// Start point of memory.
121  Word start_;
122  /// End point of memory.
123  Word end_;
124  /// Grid in which the contents of the memory is written.
125  wxGrid* grid_;
126  /// Mode of the data in the cells.
127  wxChoice* dataMode_;
128  /// Mode of the data size.
129  wxChoice* sizeMode_;
130  /// Grid width choicer.
131  wxChoice* widthMode_;
132  /// Go to address.
133  wxString goToAddress_;
134  /// Grid contents.
136  /// Top level sizer of the window.
137  wxBoxSizer* sizer_;
138  /// Number of maus displayed in a cell.
139  unsigned mausPerCell_;
140 
141  std::vector<unsigned> highlights_;
142  /**
143  * Widget ids.
144  */
145  enum {
153  };
154 
155  DECLARE_EVENT_TABLE()
156 };
157 
158 #endif
MemoryControl::onChar
void onChar(wxKeyEvent &event)
Definition: MemoryControl.cc:421
MemoryControl::table_
MemoryGridTable * table_
Grid contents.
Definition: MemoryControl.hh:135
MemoryControl::DATA_FLOAT
static const std::string DATA_FLOAT
Data label for float format.
Definition: MemoryControl.hh:94
BaseType.hh
MemoryControl::highlight
void highlight(Word address, unsigned count, const wxColour &colour)
Definition: MemoryControl.cc:564
MemoryControl::ID_BUTTON_GO_TO
@ ID_BUTTON_GO_TO
Definition: MemoryControl.hh:151
Exception.hh
MemoryControl::mausPerCell_
unsigned mausPerCell_
Number of maus displayed in a cell.
Definition: MemoryControl.hh:139
MemoryControl::dataMode_
wxChoice * dataMode_
Mode of the data in the cells.
Definition: MemoryControl.hh:127
MemoryControl::DATA_HEX
static const std::string DATA_HEX
Data label for hexa format.
Definition: MemoryControl.hh:88
MemoryControl::sizeMode_
wxChoice * sizeMode_
Mode of the data size.
Definition: MemoryControl.hh:129
MemoryControl::grid_
wxGrid * grid_
Grid in which the contents of the memory is written.
Definition: MemoryControl.hh:125
MemoryControl::onSizeModeChanged
void onSizeModeChanged(wxCommandEvent &)
Definition: MemoryControl.cc:317
MemoryControl::MemoryControl
MemoryControl(wxWindow *parent, Memory *memory, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const wxString &name=_T("MemoryControl"))
Definition: MemoryControl.cc:92
MemoryControl::DATA_BIN
static const std::string DATA_BIN
Data label for binary format.
Definition: MemoryControl.hh:86
MemoryControl::clearHighlights
void clearHighlights()
Definition: MemoryControl.cc:553
MemoryControl::onGoTo
void onGoTo(wxCommandEvent &event)
Definition: MemoryControl.cc:248
MemoryControl::end_
Word end_
End point of memory.
Definition: MemoryControl.hh:123
MemoryGridTable
Definition: MemoryGridTable.hh:47
MemoryControl::clearMemory
void clearMemory()
Definition: MemoryControl.cc:445
MemoryControl::DATA_SIGNED_INT
static const std::string DATA_SIGNED_INT
Data label for signed int format.
Definition: MemoryControl.hh:90
MemoryControl::SIZE_EIGHT_MAUS
static const std::string SIZE_EIGHT_MAUS
Size label for word size.
Definition: MemoryControl.hh:83
MemoryControl::updateView
void updateView()
Definition: MemoryControl.cc:290
MemoryControl
Definition: MemoryControl.hh:53
MemoryControl::widthMode_
wxChoice * widthMode_
Grid width choicer.
Definition: MemoryControl.hh:131
MemoryControl::ID_ADDRESS_GO_TO
@ ID_ADDRESS_GO_TO
Definition: MemoryControl.hh:150
MemoryControl::ID_GRID
@ ID_GRID
Definition: MemoryControl.hh:146
MemoryControl::copySelection
void copySelection()
Definition: MemoryControl.cc:515
MemoryControl::MAUSize_
int MAUSize_
Size of the minimum addressable unit.
Definition: MemoryControl.hh:119
MemoryControl::ID_CHOICE_MODE
@ ID_CHOICE_MODE
Definition: MemoryControl.hh:147
MemoryControl::onWriteMemory
void onWriteMemory(wxGridEvent &event)
Definition: MemoryControl.cc:379
MemoryControl::operator=
MemoryControl & operator=(const MemoryControl &)
Assignment not allowed.
MemoryControl::SIZE_TWO_MAUS
static const std::string SIZE_TWO_MAUS
Size label for half word size.
Definition: MemoryControl.hh:79
MemoryControl::setMemory
void setMemory(Memory *memory)
Definition: MemoryControl.cc:477
MemoryControl::ID_CHOICE_DATA
@ ID_CHOICE_DATA
Definition: MemoryControl.hh:148
MemoryControl::onDataModeChanged
void onDataModeChanged(wxCommandEvent &)
Definition: MemoryControl.cc:344
MemoryControl::DATA_DOUBLE
static const std::string DATA_DOUBLE
Data label for double format.
Definition: MemoryControl.hh:96
MemoryControl::onWidthChanged
void onWidthChanged(wxCommandEvent &)
Definition: MemoryControl.cc:496
MemoryControl::WIDTH_16
static const wxString WIDTH_16
Table width label for 16 column mode.
Definition: MemoryControl.hh:101
MemoryControl::sizer_
wxBoxSizer * sizer_
Top level sizer of the window.
Definition: MemoryControl.hh:137
MemoryControl::ID_SPIN_SIZE
@ ID_SPIN_SIZE
Definition: MemoryControl.hh:152
MemoryControl::~MemoryControl
virtual ~MemoryControl()
Definition: MemoryControl.cc:182
MemoryControl::highlights_
std::vector< unsigned > highlights_
Definition: MemoryControl.hh:141
MemoryControl::WIDTH_8
static const wxString WIDTH_8
Table width label for 8 column mode.
Definition: MemoryControl.hh:99
MemoryControl::WIDTH_32
static const wxString WIDTH_32
Table width label for 32 column mode.
Definition: MemoryControl.hh:103
MemoryControl::memory_
Memory * memory_
Used for access to memory contents.
Definition: MemoryControl.hh:117
MemoryControl::SIZE_FOUR_MAUS
static const std::string SIZE_FOUR_MAUS
Size label for word size.
Definition: MemoryControl.hh:81
MemoryControl::start_
Word start_
Start point of memory.
Definition: MemoryControl.hh:121
MemoryControl::DATA_UNSIGNED_INT
static const std::string DATA_UNSIGNED_INT
Data label for unsigned int format.
Definition: MemoryControl.hh:92
MemoryControl::onSize
void onSize(wxSizeEvent &)
Definition: MemoryControl.cc:368
MemoryControl::ID_CHOICE_WIDTH
@ ID_CHOICE_WIDTH
Definition: MemoryControl.hh:149
MemoryControl::SIZE_MAU
static const std::string SIZE_MAU
Size label for byte size.
Definition: MemoryControl.hh:77
Memory
Definition: Memory.hh:74
MemoryControl::goToAddress_
wxString goToAddress_
Go to address.
Definition: MemoryControl.hh:133
MemoryControl::createContents
void createContents()
Definition: MemoryControl.cc:190