OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BlockImplementationDialog Class Reference

#include <BlockImplementationDialog.hh>

Inheritance diagram for BlockImplementationDialog:
Inheritance graph
Collaboration diagram for BlockImplementationDialog:
Collaboration graph

Public Member Functions

 BlockImplementationDialog (wxWindow *parent, const TTAMachine::Component &block, IDF::UnitImplementationLocation &impl)
 
virtual ~BlockImplementationDialog ()
 

Private Types

enum  { ID_HDB_CHOICE , ID_BROWSE , ID_LIST , ID_LINE }
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void onBrowse (wxCommandEvent &event)
 
void onImplSelection (wxListEvent &event)
 
void onImplActivation (wxListEvent &e)
 
void doOK ()
 
void onOK (wxCommandEvent &event)
 
void onHDBSelection (wxCommandEvent &event)
 

Private Attributes

const TTAMachine::Componentblock_
 
IDF::UnitImplementationLocationimpl_
 
wxListCtrl * list_
 
wxChoice * hdbChoice_
 

Static Private Attributes

static std::set< std::string > hdbs_
 Static set for hdb paths.
 
static int selection_ = 0
 Static variable for the hdb choicer selection.
 
static const std::string defaultHDB_
 

Detailed Description

Definition at line 49 of file BlockImplementationDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ BlockImplementationDialog()

BlockImplementationDialog::BlockImplementationDialog ( wxWindow *  parent,
const TTAMachine::Component block,
IDF::UnitImplementationLocation impl 
)

The Constructor.

Parameters
parentParent window of the dialog.
blockBlock to select the implementation for.
implIDF UnitImplementationLocation object for the block.

Definition at line 86 of file BlockImplementationDialog.cc.

88 :
89 wxDialog(parent, -1, _T("Select implementation from a HDB file"),
90 wxDefaultPosition, wxDefaultSize,
91 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
92 block_(block), impl_(impl) {
93
94 createContents(this, true, true);
95 SetSize(wxSize(580, 300));
96
97 list_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
98 hdbChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_HDB_CHOICE));
99
100 list_->InsertColumn(0, _T("module name"), wxLIST_FORMAT_LEFT, 150);
101 list_->InsertColumn(1, _T("id"), wxLIST_FORMAT_LEFT, 50);
102 list_->InsertColumn(2, _T("param size"), wxLIST_FORMAT_LEFT, 100);
103 list_->InsertColumn(3, _T("param width"), wxLIST_FORMAT_LEFT, 100);
104
105 if (dynamic_cast<const RegisterFile*>(&block) != 0) {
106 list_->InsertColumn(4, _T("guard latency"), wxLIST_FORMAT_LEFT, 170);
107 }
108
110 registry.loadFromSearchPaths();
111 for (int i = 0; i < registry.hdbCount(); i++) {
112 hdbs_.insert(registry.hdbPath(i));
113 }
114 if (!hdbs_.empty()) {
115 std::set<std::string>::iterator iter = hdbs_.begin();
116 bool defaultHDBFound = false;
117 for (; iter != hdbs_.end(); iter++) {
118 std::string shortPath = Environment::shortHDBPath(*iter);
119 hdbChoice_->Append(WxConversion::toWxString(shortPath));
120 if (!defaultHDBFound && StringTools::endsWith(*iter, defaultHDB_)) {
121 selection_ = hdbChoice_->GetCount() - 1;
122 defaultHDBFound = true;
123 }
124 }
125 hdbChoice_->SetSelection(selection_);
126 wxCommandEvent dummy;
128 }
129 FindWindow(wxID_OK)->Disable();
130}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
const TTAMachine::Component & block_
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
static int selection_
Static variable for the hdb choicer selection.
IDF::UnitImplementationLocation & impl_
static std::set< std::string > hdbs_
Static set for hdb paths.
void onHDBSelection(wxCommandEvent &event)
static const std::string defaultHDB_
static TCEString shortHDBPath(const TCEString &hdbPath)
static HDBRegistry & instance()
void loadFromSearchPaths()
std::string hdbPath(unsigned int index)
static bool endsWith(const std::string &source, const std::string &searchString)
static wxString toWxString(const std::string &source)

References dummy, StringTools::endsWith(), HDB::HDBRegistry::hdbCount(), HDB::HDBRegistry::hdbPath(), HDB::HDBRegistry::instance(), HDB::HDBRegistry::loadFromSearchPaths(), Environment::shortHDBPath(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ ~BlockImplementationDialog()

BlockImplementationDialog::~BlockImplementationDialog ( )
virtual

The Destructor.

Definition at line 135 of file BlockImplementationDialog.cc.

135 {
136}

Member Function Documentation

◆ createContents()

wxSizer * BlockImplementationDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog widgets.

Definition at line 369 of file BlockImplementationDialog.cc.

372 {
373 wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
374 item0->AddGrowableCol( 0 );
375 item0->AddGrowableRow( 1 );
376
377 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
378
379 wxString *strs2 = (wxString*) NULL;
380 wxChoice *item2 = new wxChoice( parent, ID_HDB_CHOICE, wxDefaultPosition, wxSize(250,-1), 0, strs2, 0 );
381 item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
382
383 wxButton *item3 = new wxButton( parent, ID_BROWSE, wxT("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
384 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
385
386 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
387
388 wxListCtrl *item4 = new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(300,120), wxLC_REPORT|wxSUNKEN_BORDER );
389 item0->Add( item4, 0, wxGROW|wxALL, 5 );
390
391 wxStaticLine *item5 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
392 item0->Add( item5, 0, wxGROW|wxALL, 5 );
393
394 wxBoxSizer *item6 = new wxBoxSizer( wxHORIZONTAL );
395
396 wxButton *item7 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
397 item6->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
398
399 wxButton *item8 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
400 item6->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
401
402 item0->Add( item6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
403
404 if (set_sizer)
405 {
406 parent->SetSizer( item0 );
407 if (call_fit)
408 item0->SetSizeHints( parent );
409 }
410
411 return item0;
412}

References ID_BROWSE, ID_HDB_CHOICE, ID_LINE, and ID_LIST.

◆ doOK()

void BlockImplementationDialog::doOK ( )
private

Do the things that are done to close the dialog on ok

Definition at line 335 of file BlockImplementationDialog.cc.

335 {
336 std::string HDBpath = WxConversion::toString(
337 hdbChoice_->GetStringSelection());
338 HDBpath = Environment::longHDBPath(HDBpath);
339 impl_.setHDBFile(HDBpath);
341 impl_.setID(id);
342 EndModal(wxID_OK);
343}
static int toInt(const T &source)
static TCEString longHDBPath(const TCEString &hdbPath)
virtual void setHDBFile(std::string file)
static std::string lcStringSelection(wxListCtrl *list, int column)
static std::string toString(const wxString &source)

References hdbChoice_, impl_, WidgetTools::lcStringSelection(), list_, Environment::longHDBPath(), IDF::UnitImplementationLocation::setHDBFile(), IDF::UnitImplementationLocation::setID(), Conversion::toInt(), and WxConversion::toString().

Referenced by onImplActivation(), and onOK().

Here is the call graph for this function:

◆ onBrowse()

void BlockImplementationDialog::onBrowse ( wxCommandEvent &  event)
private

Event handler for the 'Browse...' button.

Opens a file dialog.

Definition at line 144 of file BlockImplementationDialog.cc.

144 {
145 wxFileDialog dialog(
146 this, _T("Choose a HDB file containing the implementation"),
147 _T(""), _T(""), _T("HDBs|*.hdb|All files|*.*"),
148 (wxOPEN | wxFILE_MUST_EXIST));
149
150 if (dialog.ShowModal() == wxID_OK) {
151 std::string hdb = std::string(dialog.GetPath().mb_str());
152 hdb = Environment::shortHDBPath(hdb);
153 auto wxHDB = WxConversion::toWxString(hdb);
154 int item = hdbChoice_->FindString(wxHDB);
155 if (item == wxNOT_FOUND) {
156 item = hdbChoice_->Append(wxHDB);
157 }
158 hdbChoice_->Select(item);
159 wxListEvent dummy;
161 }
162}

References dummy, hdbChoice_, onHDBSelection(), Environment::shortHDBPath(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onHDBSelection()

void BlockImplementationDialog::onHDBSelection ( wxCommandEvent &  event)
private

Event handler for the HDB choicer widget.

Definition at line 177 of file BlockImplementationDialog.cc.

177 {
178
179 std::string path = WxConversion::toString(
180 hdbChoice_->GetStringSelection());
181 path = Environment::longHDBPath(path);
182
183 list_->DeleteAllItems();
184
185 try {
186 HDBManager& hdb = HDBRegistry::instance().hdb(path);
187
188 const FunctionUnit* fu = dynamic_cast<const FunctionUnit*>(&block_);
189 if (fu != NULL) {
190 int i = 0;
191 std::set<RowID> fuEntryIDs = hdb.fuEntriesByArchitecture(*fu);
192 if (fuEntryIDs.empty()) {
193 wxString message = _T("No implementations for '");
194 message.Append(WxConversion::toWxString(fu->name()));
195 message.Append(_T("' found in '"));
196 message.Append(hdbChoice_->GetStringSelection());
197 message.Append(_T("'."));
198 InformationDialog dialog(this, message);
199 dialog.ShowModal();
200 }
201 std::set<RowID>::iterator iter = fuEntryIDs.begin();
202 for (; iter != fuEntryIDs.end(); iter++) {
203
204 if (hdb.fuByEntryID(*iter)->hasImplementation()) {
205 const FUImplementation& impl =
206 hdb.fuByEntryID(*iter)->implementation();
207 const FUArchitecture& arch =
208 hdb.fuByEntryID(*iter)->architecture();
209 list_->InsertItem(
211 // we want to select the FU *entry ID* which points to the
212 // implementation
213 list_->SetItem(i, 1, WxConversion::toWxString(*iter));
214 if (arch.hasParameterizedWidth("p1")) {
215 list_->SetItem(i, 3, WxConversion::toWxString("*"));
216 }
217 }
218 }
219 }
220
221 // Register files.
222 const BaseRegisterFile* rf =
223 dynamic_cast<const BaseRegisterFile*>(&block_);
224
225 if (rf != NULL) {
226 int width = rf->width();
227 int size = rf->size();
228 int i = 0;
229 int readPorts = 0;
230 int writePorts = 0;
231 int bidirPorts = 0;
232 for (int p = 0; p < rf->portCount(); p++) {
233 const RFPort* port = rf->port(p);
234 if (port->inputSocket() != NULL &&
235 port->outputSocket() != NULL) {
236
237 bidirPorts++;
238 } else if (port->inputSocket() != NULL) {
239 writePorts++;
240 } else if (port->outputSocket() != NULL) {
241 readPorts++;
242 }
243 }
244
245 int maxReads = 0;
246 int maxWrites = 0;
247 int guardLatency = 0;
248 int latency = 1;
249 bool zeroRegister = false;
250 const RegisterFile* r = dynamic_cast<const RegisterFile*>(rf);
251 if (r != NULL) {
252 maxReads = r->maxReads();
253 maxWrites = r->maxWrites();
254 guardLatency = r->guardLatency();
255 zeroRegister = r->zeroRegister();
256 }
257 const ImmediateUnit* iu = dynamic_cast<const ImmediateUnit*>(rf);
258 if (iu != NULL) {
259 // TODO: XXX
260 latency = iu->latency();
261 // Immediate units have always one write port (not seen in adf)
262 writePorts = 1;
263 }
264 std::set<RowID> rfEntryIDs =
266 readPorts, writePorts, bidirPorts,
267 maxReads,
268 maxWrites,
269 latency,
270 r->isUsedAsGuard(),
271 guardLatency,
272 width,
273 size,
274 zeroRegister);
275
276 if (rfEntryIDs.empty()) {
277 wxString message = _T("No implementations for '");
278 message.Append(WxConversion::toWxString(rf->name()));
279 message.Append(_T("' found in '"));
280 message.Append(hdbChoice_->GetStringSelection());
281 message.Append(_T("'."));
282 InformationDialog dialog(this, message);
283 dialog.ShowModal();
284 }
285 std::set<RowID>::iterator iter = rfEntryIDs.begin();
286 for (; iter != rfEntryIDs.end(); iter++) {
287 if (hdb.rfByEntryID(*iter)->hasImplementation()) {
288
289 const RFImplementation& impl =
290 hdb.rfByEntryID(*iter)->implementation();
291
292 const RFArchitecture& arch =
293 hdb.rfByEntryID(*iter)->architecture();
294
295 list_->InsertItem(
297
298 // we want to select the RF *entry ID* which points to the
299 // implementation
300 list_->SetItem(i, 1, WxConversion::toWxString(*iter));
301
302 if (arch.hasParameterizedSize()) {
303 list_->SetItem(i, 2, WxConversion::toWxString("*"));
304 }
305 if (arch.hasParameterizedWidth()) {
306 list_->SetItem(i, 3, WxConversion::toWxString("*"));
307 }
308
309 list_->SetItem(i, 4, r->isUsedAsGuard() ?
310 WxConversion::toWxString(guardLatency) :
311 WxConversion::toWxString("not used as guard"));
312 }
313 }
314
315 }
316 } catch (Exception& e) {
317 wxString message = _T("Error opening '");
318 message.Append(WxConversion::toWxString(path));
319 message.Append(_T("':\n\n"));
320 message.Append(WxConversion::toWxString(e.errorMessage()));
321 ErrorDialog dialog(this, message);
322 dialog.ShowModal();
323 hdbChoice_->Delete(hdbChoice_->GetSelection());
324 return;
325 }
326
327 hdbs_.insert(path);
328 selection_ = hdbChoice_->GetSelection();
329}
std::string errorMessage() const
Definition Exception.cc:123
bool hasParameterizedWidth(const std::string &port) const
FUImplementation & implementation() const
Definition FUEntry.cc:86
virtual bool hasImplementation() const
Definition FUEntry.cc:74
FUArchitecture & architecture() const
Definition FUEntry.cc:129
std::set< RowID > fuEntriesByArchitecture(const TTAMachine::FunctionUnit &fu) const
FUEntry * fuByEntryID(RowID id) const
std::set< RowID > rfEntriesByArchitecture(int readPorts, int writePorts, int bidirPorts, int maxReads, int maxWrites, int latency, bool guardSupport, int guardLatency=0, int width=0, int size=0, bool zeroRegister=false) const
RFEntry * rfByEntryID(RowID id) const
CachedHDBManager & hdb(const std::string fileName)
bool hasParameterizedWidth() const
bool hasParameterizedSize() const
virtual bool hasImplementation() const
Definition RFEntry.cc:74
RFArchitecture & architecture() const
Definition RFEntry.cc:145
RFImplementation & implementation() const
Definition RFEntry.cc:102
virtual int size() const
virtual int width() const
virtual RFPort * port(const std::string &name) const
virtual TCEString name() const
virtual int latency() const
virtual Socket * outputSocket() const
Definition Port.cc:281
virtual Socket * inputSocket() const
Definition Port.cc:261
virtual int maxReads() const
virtual bool zeroRegister() const
virtual int guardLatency() const
virtual bool isUsedAsGuard() const
virtual int maxWrites() const
virtual int portCount() const
Definition Unit.cc:135

References HDB::FUEntry::architecture(), HDB::RFEntry::architecture(), block_, Exception::errorMessage(), HDB::HDBManager::fuByEntryID(), HDB::HDBManager::fuEntriesByArchitecture(), TTAMachine::RegisterFile::guardLatency(), HDB::FUEntry::hasImplementation(), HDB::RFEntry::hasImplementation(), HDB::RFArchitecture::hasParameterizedSize(), HDB::RFArchitecture::hasParameterizedWidth(), HDB::FUArchitecture::hasParameterizedWidth(), HDB::HDBRegistry::hdb(), hdbChoice_, hdbs_, HDB::FUEntry::implementation(), HDB::RFEntry::implementation(), TTAMachine::Port::inputSocket(), HDB::HDBRegistry::instance(), TTAMachine::RegisterFile::isUsedAsGuard(), TTAMachine::ImmediateUnit::latency(), list_, Environment::longHDBPath(), TTAMachine::RegisterFile::maxReads(), TTAMachine::RegisterFile::maxWrites(), HDB::HWBlockImplementation::moduleName(), TTAMachine::Component::name(), TTAMachine::Port::outputSocket(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), HDB::HDBManager::rfByEntryID(), HDB::HDBManager::rfEntriesByArchitecture(), selection_, TTAMachine::BaseRegisterFile::size(), WxConversion::toString(), WxConversion::toWxString(), TTAMachine::BaseRegisterFile::width(), and TTAMachine::RegisterFile::zeroRegister().

Referenced by onBrowse().

Here is the call graph for this function:

◆ onImplActivation()

void BlockImplementationDialog::onImplActivation ( wxListEvent &  e)
private

Event handler for list activation OK button.

Updates the UnitImplementationLocation object.

Definition at line 361 of file BlockImplementationDialog.cc.

References doOK().

Here is the call graph for this function:

◆ onImplSelection()

void BlockImplementationDialog::onImplSelection ( wxListEvent &  event)
private

Definition at line 165 of file BlockImplementationDialog.cc.

165 {
166 if (list_->GetSelectedItemCount() == 1) {
167 FindWindow(wxID_OK)->Enable();
168 } else {
169 FindWindow(wxID_OK)->Disable();
170 }
171}

References list_.

◆ onOK()

void BlockImplementationDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the OK button.

Updates the UnitImplementationLocation object.

Definition at line 351 of file BlockImplementationDialog.cc.

351 {
352 doOK();
353}

References doOK().

Here is the call graph for this function:

Member Data Documentation

◆ block_

const TTAMachine::Component& BlockImplementationDialog::block_
private

Definition at line 67 of file BlockImplementationDialog.hh.

Referenced by onHDBSelection().

◆ defaultHDB_

const std::string BlockImplementationDialog::defaultHDB_
staticprivate

Definition at line 78 of file BlockImplementationDialog.hh.

◆ hdbChoice_

wxChoice* BlockImplementationDialog::hdbChoice_
private

Definition at line 70 of file BlockImplementationDialog.hh.

Referenced by doOK(), onBrowse(), and onHDBSelection().

◆ hdbs_

std::set< std::string > BlockImplementationDialog::hdbs_
staticprivate

Static set for hdb paths.

Definition at line 73 of file BlockImplementationDialog.hh.

Referenced by onHDBSelection().

◆ impl_

IDF::UnitImplementationLocation& BlockImplementationDialog::impl_
private

Definition at line 68 of file BlockImplementationDialog.hh.

Referenced by doOK().

◆ list_

wxListCtrl* BlockImplementationDialog::list_
private

Definition at line 69 of file BlockImplementationDialog.hh.

Referenced by doOK(), onHDBSelection(), and onImplSelection().

◆ selection_

int BlockImplementationDialog::selection_ = 0
staticprivate

Static variable for the hdb choicer selection.

Definition at line 75 of file BlockImplementationDialog.hh.

Referenced by onHDBSelection().


The documentation for this class was generated from the following files: