OpenASIP  2.0
RFArchitectureDialog.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 RFArchParamatersDialog.cc
26  *
27  * Implementation of RFArchitectureDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/statline.h>
34 #include <wx/valgen.h>
35 #include <wx/spinctrl.h>
36 #include "RFArchitectureDialog.hh"
37 #include "RFArchitecture.hh"
38 #include "WxConversion.hh"
39 
40 BEGIN_EVENT_TABLE(RFArchitectureDialog, wxDialog)
43 
44 /**
45  * The Constructor.
46  *
47  * @param parent Parent window of the dialog.
48  * @param id Window identifier for the dialog.
49  * @param arch Register file architecture to modify.
50  */
52  wxWindow* parent, wxWindowID id, HDB::RFArchitecture& arch) :
53  wxDialog(parent, id, _T("Register file architecture.")),
54  arch_(arch), size_(0), width_(0) {
55 
56  if (!arch_.hasParameterizedSize()) {
57  size_ = arch_.size();
58  }
59 
60  if (!arch_.hasParameterizedWidth()) {
61  width_ = arch_.width();
62  }
63 
64  readPorts_ = arch_.readPortCount();
65  writePorts_ = arch_.writePortCount();
66  bidirPorts_ = arch_.bidirPortCount();
67  maxReads_ = arch_.maxReads();
68  maxWrites_ = arch_.maxWrites();
69  latency_ = arch_.latency();
70  zeroRegister_ = arch.zeroRegister();
71 
72 
73  paramWidth_ = arch_.hasParameterizedWidth();
74  paramSize_ = arch_.hasParameterizedSize();
75  guardSupport_ = arch_.hasGuardSupport();
76  createContents(this, true, true);
77 
78  FindWindow(ID_SIZE)->SetValidator(wxGenericValidator(&size_));
79  FindWindow(ID_WIDTH)->SetValidator(wxGenericValidator(&width_));
80  FindWindow(ID_MAX_READS)->SetValidator(wxGenericValidator(&maxReads_));
81  FindWindow(ID_MAX_WRITES)->SetValidator(wxGenericValidator(&maxWrites_));
82  FindWindow(ID_READ_PORTS)->SetValidator(wxGenericValidator(&readPorts_));
83  FindWindow(ID_WRITE_PORTS)->SetValidator(wxGenericValidator(&writePorts_));
84  FindWindow(ID_BIDIR_PORTS)->SetValidator(wxGenericValidator(&bidirPorts_));
85  FindWindow(ID_ZERO_REGISTER)->SetValidator(
86  wxGenericValidator(&zeroRegister_));
87 
88 
89  FindWindow(ID_PARAM_SIZE)->SetValidator(wxGenericValidator(&paramSize_));
90  FindWindow(ID_PARAM_WIDTH)->SetValidator(wxGenericValidator(&paramWidth_));
91  FindWindow(ID_GUARD_SUPPORT)->SetValidator(
92  wxGenericValidator(&guardSupport_));
93 
94 }
95 
96 /**
97  * The Destructor.
98  */
100 }
101 
102 
103 /**
104  * Event handler for the dialog OK-button.
105  */
106 void
107 RFArchitectureDialog::onOK(wxCommandEvent&) {
108 
109  TransferDataFromWindow();
110 
111  if (!paramSize_) {
113  }
114  if (!paramWidth_) {
116  }
117 
126 
127  EndModal(wxID_OK);
128 }
129 
130 /**
131  * Creates the dialog contents.
132  */
133 wxSizer*
135  wxWindow *parent, bool call_fit, bool set_sizer) {
136 
137  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
138 
139  wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
140 
141  wxFlexGridSizer *item2 = new wxFlexGridSizer( 2, 0, 0 );
142 
143  wxStaticText *item3 = new wxStaticText( parent, ID_LABEL_SIZE, wxT("Size:"), wxDefaultPosition, wxDefaultSize, 0 );
144  item2->Add( item3, 0, wxALL, 5 );
145 
146  wxSpinCtrl *item4 = new wxSpinCtrl( parent, ID_SIZE, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 10000, 0 );
147  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
148 
149  wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_WIDTH, wxT("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
150  item2->Add( item5, 0, wxALL, 5 );
151 
152  wxSpinCtrl *item6 = new wxSpinCtrl( parent, ID_WIDTH, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 10000, 0 );
153  item2->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
154 
155  // Modifying latency disabled for now!
156  //wxStaticText *item7 = new wxStaticText( parent, ID_LABEL_LATENCY, wxT("Latency:"), wxDefaultPosition, wxDefaultSize, 0 );
157  //item2->Add( item7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
158 
159  //wxSpinCtrl *item8 = new wxSpinCtrl( parent, ID_LATENCY, wxT("0"), wxDefaultPosition, wxSize(100,-1), 0, 0, 100, 0 );
160  //item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
161 
162  wxStaticText *item9 = new wxStaticText( parent, ID_LABEL_MAX_READS, wxT("Max reads:"), wxDefaultPosition, wxDefaultSize, 0 );
163  item2->Add( item9, 0, wxALL, 5 );
164 
165  wxSpinCtrl *item10 = new wxSpinCtrl( parent, ID_MAX_READS, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 10000, 0 );
166  item2->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
167 
168  wxStaticText *item11 = new wxStaticText( parent, ID_LABEL_MAX_WRITES, wxT("Max writes:"), wxDefaultPosition, wxDefaultSize, 0 );
169  item2->Add( item11, 0, wxALL, 5 );
170 
171  wxSpinCtrl *item12 = new wxSpinCtrl( parent, ID_MAX_WRITES, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 100, 0 );
172  item2->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
173 
174  wxStaticText *item13 = new wxStaticText( parent, ID_LABEL_READ_PORTS, wxT("Read ports:"), wxDefaultPosition, wxDefaultSize, 0 );
175  item2->Add( item13, 0, wxALL, 5 );
176 
177  wxSpinCtrl *item14 = new wxSpinCtrl( parent, ID_READ_PORTS, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 100, 0 );
178  item2->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
179 
180  wxStaticText *item15 = new wxStaticText( parent, ID_LABEL_WRITE_PORTS, wxT("Write ports:"), wxDefaultPosition, wxDefaultSize, 0 );
181  item2->Add( item15, 0, wxALL, 5 );
182 
183  wxSpinCtrl *item16 = new wxSpinCtrl( parent, ID_WRITE_PORTS, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 100, 0 );
184  item2->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
185 
186  wxStaticText *item17 = new wxStaticText( parent, ID_LABEL_BIDIR_PORTS, wxT("Bidirectional ports:"), wxDefaultPosition, wxDefaultSize, 0 );
187  item2->Add( item17, 0, wxALL, 5 );
188 
189  wxSpinCtrl *item18 = new wxSpinCtrl( parent, ID_BIDIR_PORTS, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 100, 0 );
190  item2->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
191 
192  item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
193 
194  wxBoxSizer *item19 = new wxBoxSizer( wxVERTICAL );
195 
196  wxCheckBox *item20 = new wxCheckBox( parent, ID_PARAM_WIDTH, wxT("Parametrized width"), wxDefaultPosition, wxDefaultSize, 0 );
197  item19->Add( item20, 0, wxALL, 5 );
198 
199  wxCheckBox *item21 = new wxCheckBox( parent, ID_PARAM_SIZE, wxT("Parametrized size"), wxDefaultPosition, wxDefaultSize, 0 );
200  item19->Add( item21, 0, wxALL, 5 );
201 
202  wxCheckBox *item22 = new wxCheckBox( parent, ID_GUARD_SUPPORT, wxT("Guard support"), wxDefaultPosition, wxDefaultSize, 0 );
203  item19->Add( item22, 0, wxALL, 5 );
204 
205  item1->Add( item19, 0, wxALL, 5 );
206 
207  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
208 
209  wxStaticLine *item23 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
210  item0->Add( item23, 0, wxGROW|wxALL, 5 );
211 
212  wxBoxSizer *item24 = new wxBoxSizer( wxHORIZONTAL );
213 
214  wxButton *item25 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
215  item24->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
216 
217  wxButton *item26 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
218  item24->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
219 
220  item0->Add( item24, 0, wxALL, 5 );
221 
222  wxCheckBox *item27 = new wxCheckBox( parent, ID_ZERO_REGISTER, wxT("Zero register"), wxDefaultPosition, wxDefaultSize, 0 );
223  item19->Add( item27, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
224 
225  if (set_sizer)
226  {
227  parent->SetSizer( item0 );
228  if (call_fit)
229  item0->SetSizeHints( parent );
230  }
231 
232  return item0;
233 }
RFArchitectureDialog::ID_LABEL_SIZE
@ ID_LABEL_SIZE
Definition: RFArchitectureDialog.hh:59
RFArchitectureDialog::readPorts_
int readPorts_
Definition: RFArchitectureDialog.hh:84
HDB::RFArchitecture::setReadPortCount
void setReadPortCount(int portCount)
Definition: RFArchitecture.cc:359
RFArchitectureDialog::ID_PARAM_SIZE
@ ID_PARAM_SIZE
Definition: RFArchitectureDialog.hh:74
RFArchitectureDialog::paramWidth_
bool paramWidth_
Definition: RFArchitectureDialog.hh:91
RFArchitectureDialog::maxReads_
int maxReads_
Definition: RFArchitectureDialog.hh:87
HDB
Definition: CostDatabase.hh:49
HDB::RFArchitecture::setLatency
void setLatency(int latency)
Definition: RFArchitecture.cc:484
RFArchitectureDialog::width_
int width_
Definition: RFArchitectureDialog.hh:83
RFArchitectureDialog::ID_LABEL_MAX_READS
@ ID_LABEL_MAX_READS
Definition: RFArchitectureDialog.hh:69
RFArchitectureDialog::size_
int size_
Definition: RFArchitectureDialog.hh:82
RFArchitectureDialog::ID_SIZE
@ ID_SIZE
Definition: RFArchitectureDialog.hh:60
RFArchitectureDialog::ID_MAX_WRITES
@ ID_MAX_WRITES
Definition: RFArchitectureDialog.hh:72
HDB::RFArchitecture::setMaxWrites
void setMaxWrites(int maxWrites)
Definition: RFArchitecture.cc:459
HDB::RFArchitecture::setZeroRegister
void setZeroRegister(bool zeroRegister)
Definition: RFArchitecture.cc:530
FindWindow
Definition: FindWindow.hh:49
RFArchitectureDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: RFArchitectureDialog.cc:134
HDB::RFArchitecture::setBidirPortCount
void setBidirPortCount(int portCount)
Definition: RFArchitecture.cc:409
RFArchitectureDialog::guardSupport_
bool guardSupport_
Definition: RFArchitectureDialog.hh:90
RFArchitectureDialog::ID_GUARD_SUPPORT
@ ID_GUARD_SUPPORT
Definition: RFArchitectureDialog.hh:75
RFArchitectureDialog::ID_LABEL_BIDIR_PORTS
@ ID_LABEL_BIDIR_PORTS
Definition: RFArchitectureDialog.hh:67
RFArchitectureDialog::ID_MAX_READS
@ ID_MAX_READS
Definition: RFArchitectureDialog.hh:70
RFArchitectureDialog::~RFArchitectureDialog
virtual ~RFArchitectureDialog()
Definition: RFArchitectureDialog.cc:99
RFArchitecture.hh
HDB::RFArchitecture::setWidth
void setWidth(int width)
Definition: RFArchitecture.cc:294
RFArchitectureDialog::bidirPorts_
int bidirPorts_
Definition: RFArchitectureDialog.hh:86
RFArchitectureDialog.hh
RFArchitectureDialog::ID_LINE
@ ID_LINE
Definition: RFArchitectureDialog.hh:76
RFArchitectureDialog::ID_LABEL_READ_PORTS
@ ID_LABEL_READ_PORTS
Definition: RFArchitectureDialog.hh:63
RFArchitectureDialog::ID_LABEL_WRITE_PORTS
@ ID_LABEL_WRITE_PORTS
Definition: RFArchitectureDialog.hh:65
RFArchitectureDialog::paramSize_
bool paramSize_
Definition: RFArchitectureDialog.hh:92
RFArchitectureDialog::arch_
HDB::RFArchitecture & arch_
Definition: RFArchitectureDialog.hh:80
RFArchitectureDialog::ID_WIDTH
@ ID_WIDTH
Definition: RFArchitectureDialog.hh:62
RFArchitectureDialog::ID_ZERO_REGISTER
@ ID_ZERO_REGISTER
Definition: RFArchitectureDialog.hh:77
RFArchitectureDialog::ID_LABEL_WIDTH
@ ID_LABEL_WIDTH
Definition: RFArchitectureDialog.hh:61
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
RFArchitectureDialog::ID_BIDIR_PORTS
@ ID_BIDIR_PORTS
Definition: RFArchitectureDialog.hh:68
RFArchitectureDialog::maxWrites_
int maxWrites_
Definition: RFArchitectureDialog.hh:88
RFArchitectureDialog::ID_LABEL_MAX_WRITES
@ ID_LABEL_MAX_WRITES
Definition: RFArchitectureDialog.hh:71
RFArchitectureDialog
Definition: RFArchitectureDialog.hh:46
RFArchitectureDialog::ID_PARAM_WIDTH
@ ID_PARAM_WIDTH
Definition: RFArchitectureDialog.hh:73
WxConversion.hh
RFArchitectureDialog::latency_
int latency_
Definition: RFArchitectureDialog.hh:89
RFArchitectureDialog::onOK
void onOK(wxCommandEvent &event)
Definition: RFArchitectureDialog.cc:107
RFArchitectureDialog::ID_READ_PORTS
@ ID_READ_PORTS
Definition: RFArchitectureDialog.hh:64
RFArchitectureDialog::writePorts_
int writePorts_
Definition: RFArchitectureDialog.hh:85
HDB::RFArchitecture::setMaxReads
void setMaxReads(int maxReads)
Definition: RFArchitecture.cc:434
RFArchitectureDialog::zeroRegister_
bool zeroRegister_
Definition: RFArchitectureDialog.hh:93
HDB::RFArchitecture::setSize
void setSize(int size)
Definition: RFArchitecture.cc:310
RFArchitectureDialog::ID_WRITE_PORTS
@ ID_WRITE_PORTS
Definition: RFArchitectureDialog.hh:66
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
HDB::RFArchitecture::setGuardSupport
void setGuardSupport(bool supported)
Definition: RFArchitecture.cc:508
HDB::RFArchitecture::setWritePortCount
void setWritePortCount(int portCount)
Definition: RFArchitecture.cc:384