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

#include <AddRFFromHDBDialog.hh>

Inheritance diagram for AddRFFromHDBDialog:
Inheritance graph
Collaboration diagram for AddRFFromHDBDialog:
Collaboration graph

Public Member Functions

 AddRFFromHDBDialog (wxWindow *parent, Model *model)
 
virtual ~AddRFFromHDBDialog ()
 

Private Types

enum  { ID_LIST = 10000 , ID_ADD , ID_CLOSE , ID_LINE }
 

Private Member Functions

virtual bool TransferDataToWindow ()
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void onListSelectionChange (wxListEvent &event)
 
void onAdd (wxCommandEvent &event)
 
void onClose (wxCommandEvent &event)
 
bool loadHDB (const HDB::HDBManager &manager)
 
void onColumnClick (wxListEvent &event)
 
void setColumnImage (int col, int image)
 

Private Attributes

Modelmodel_
 Model of the current adf file.
 
wxListCtrl * list_
 Immediate slot list widget.
 
std::map< int, HDB::RFArchitecture * > rfArchitectures_
 Map of rf architectures displayed in the dialog list.
 
int sortColumn_
 
bool sortASC_
 

Static Private Attributes

static const int DEFAULT_SIZE = 1
 Default size for the rf, if the size is parameterized in the HDB.
 
static const int DEFAULT_WIDTH = 32
 Default bit width for the rf, if the size is parameterized in the HDB.
 
static const wxString HDB_FILE_FILTER = _T("*.hdb")
 File filter for the HDB files.
 

Detailed Description

Dialog for adding register file architectures directly from HDB to the current machine.

Definition at line 64 of file AddRFFromHDBDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_LIST 
ID_ADD 
ID_CLOSE 
ID_LINE 

Definition at line 89 of file AddRFFromHDBDialog.hh.

Constructor & Destructor Documentation

◆ AddRFFromHDBDialog()

AddRFFromHDBDialog::AddRFFromHDBDialog ( wxWindow *  parent,
Model model 
)

The Constructor.

Parameters
parentParent window of the dialog.
machineParent Machine of the immediate slots.

Definition at line 142 of file AddRFFromHDBDialog.cc.

144 :
145 wxDialog(
146 parent, -1, _T("HDB Register Files"), wxDefaultPosition, wxDefaultSize,
147 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
148 model_(model), sortColumn_(0), sortASC_(true) {
149
150 createContents(this, true, true);
151 SetSize(400, 300);
152
153 list_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
154
155 list_->InsertColumn(0, _T("Width"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
156 list_->InsertColumn(1, _T("Size"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
157 list_->InsertColumn(2, _T("Read ports"), wxLIST_FORMAT_LEFT, 100);
158 list_->InsertColumn(3, _T("Write ports"), wxLIST_FORMAT_LEFT, 100);
159 list_->InsertColumn(4, _T("Bidir ports"), wxLIST_FORMAT_LEFT, 100);
160 list_->InsertColumn(5, _T("Max Reads"), wxLIST_FORMAT_LEFT, 100);
161 list_->InsertColumn(6, _T("Max RW"), wxLIST_FORMAT_LEFT, 100);
162 list_->InsertColumn(7, _T("ID"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
163 list_->InsertColumn(8, _T("HDB"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
164
165 string iconPath =
167
168 wxImageList* imageList = new wxImageList(13, 17);
169 imageList->Add(wxIcon(
171 imageList->Add(wxIcon(
173 list_->SetImageList(imageList, wxIMAGE_LIST_SMALL);
174
175 // Disable conditional buttons.
176 FindWindow(ID_ADD)->Disable();
177}
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxListCtrl * list_
Immediate slot list widget.
Model * model_
Model of the current adf file.
static std::string iconDirPath()
static const std::string DIRECTORY_SEPARATOR
static const std::string ICON_SORT_DESC
Icon location for descending sort.
static const std::string ICON_SORT_ASC
Icon location for ascending sort.
static wxString toWxString(const std::string &source)

References createContents(), FileSystem::DIRECTORY_SEPARATOR, ProDeConstants::ICON_SORT_ASC, ProDeConstants::ICON_SORT_DESC, Environment::iconDirPath(), ID_ADD, ID_LIST, list_, and WxConversion::toWxString().

Here is the call graph for this function:

◆ ~AddRFFromHDBDialog()

AddRFFromHDBDialog::~AddRFFromHDBDialog ( )
virtual

The Destructor.

Definition at line 183 of file AddRFFromHDBDialog.cc.

183 {
184}

Member Function Documentation

◆ createContents()

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

Creates the dialog contents.

Parameters
parentParent dialog of the contents.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.
Returns
Top level sizer of the dialog contents.

Definition at line 387 of file AddRFFromHDBDialog.cc.

388 {
389
390 wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
391 item0->AddGrowableCol( 0 );
392 item0->AddGrowableRow( 0 );
393
394 wxListCtrl *item1 = new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER );
395 item0->Add( item1, 0, wxGROW|wxALL, 5 );
396
397 wxButton *item2 = new wxButton( parent, ID_ADD, wxT("&Add"), wxDefaultPosition, wxDefaultSize, 0 );
398 item0->Add( item2, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
399
400 wxStaticLine *item3 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
401 item0->Add( item3, 0, wxGROW|wxALL, 5 );
402
403 wxButton *item4 = new wxButton( parent, ID_CLOSE, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
404 item0->Add( item4, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
405
406 if (set_sizer) {
407 parent->SetSizer( item0 );
408 if (call_fit) {
409 item0->SetSizeHints( parent );
410 }
411 }
412
413 return item0;
414}

References ID_ADD, ID_CLOSE, ID_LINE, and ID_LIST.

Referenced by AddRFFromHDBDialog().

◆ loadHDB()

bool AddRFFromHDBDialog::loadHDB ( const HDB::HDBManager manager)
private

Loads register files from a HDB to the dialog list.

Parameters
managerHDBManager managing the HDB to load.
Returns
True, if the HDB was succesfully loaded.

Definition at line 231 of file AddRFFromHDBDialog.cc.

231 {
232
233 std::string path = manager.fileName();
234
235 const std::set<RowID> rfArchIDs = manager.rfArchitectureIDs();
236 std::set<RowID>::iterator iter = rfArchIDs.begin();
237
238 // Read properties of all register files in the HDB and append
239 // data to the register file list widget.
240 for (; iter != rfArchIDs.end(); iter++) {
241
242 RFArchitecture* arch = manager.rfArchitectureByID(*iter);
243
244 if (arch->latency() != 1) {
245 continue;
246 }
247
248 rfArchitectures_.insert(
249 std::pair<int, RFArchitecture*>(list_->GetItemCount(), arch));
250
251 ListItemData* lid = new ListItemData;
252
253 if (arch->hasParameterizedWidth()) {
254 list_->InsertItem(0, _T("param"));
255 lid->width = 0;
256 } else {
257 list_->InsertItem(0, WxConversion::toWxString(arch->width()));
258 lid->width = arch->width();
259 }
260 if (arch->hasParameterizedSize()) {
261 list_->SetItem(0, 1, _T("param"));
262 lid->size = 0;
263 } else {
264 list_->SetItem(0, 1, WxConversion::toWxString(arch->size()));
265 lid->size = arch->size();
266 }
267 list_->SetItem(0, 2, WxConversion::toWxString(arch->readPortCount()));
268 lid->readPorts = arch->readPortCount();
269 list_->SetItem(
271 lid->writePorts = arch->writePortCount();
272 list_->SetItem(0, 4, WxConversion::toWxString(arch->bidirPortCount()));
273 lid->bidirPorts = arch->bidirPortCount();
274 list_->SetItem(0, 5, WxConversion::toWxString(arch->maxReads()));
275 lid->maxReads = arch->maxReads();
276 list_->SetItem(0, 6, WxConversion::toWxString(arch->maxWrites()));
277 lid->maxWrites = arch->maxWrites();
278 list_->SetItem(0, 7, WxConversion::toWxString(*iter));
279 lid->hdbId = *iter;
280 list_->SetItem(0, 8, WxConversion::toWxString(path));
281 lid->path = WxConversion::toWxString(path);
282 lid->id = list_->GetItemCount() - 1;
283 list_->SetItemData(0, (long)lid);
284 }
285 // default sorting column is "Width"
286 list_->SortItems(RFListCompareASC, 0);
288
289 return true;
290}
int wxCALLBACK RFListCompareASC(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
void setColumnImage(int col, int image)
std::map< int, HDB::RFArchitecture * > rfArchitectures_
Map of rf architectures displayed in the dialog list.
std::set< RowID > rfArchitectureIDs() const
std::string fileName() const
virtual RFArchitecture * rfArchitectureByID(RowID id) const
bool hasParameterizedWidth() const
bool hasParameterizedSize() const

References HDB::RFArchitecture::bidirPortCount(), ListItemData::bidirPorts, HDB::HDBManager::fileName(), HDB::RFArchitecture::hasParameterizedSize(), HDB::RFArchitecture::hasParameterizedWidth(), ListItemData::hdbId, ListItemData::id, HDB::RFArchitecture::latency(), list_, HDB::RFArchitecture::maxReads(), ListItemData::maxReads, HDB::RFArchitecture::maxWrites(), ListItemData::maxWrites, ListItemData::path, HDB::RFArchitecture::readPortCount(), ListItemData::readPorts, HDB::HDBManager::rfArchitectureByID(), HDB::HDBManager::rfArchitectureIDs(), rfArchitectures_, RFListCompareASC(), setColumnImage(), HDB::RFArchitecture::size(), ListItemData::size, sortASC_, WxConversion::toWxString(), HDB::RFArchitecture::width(), ListItemData::width, HDB::RFArchitecture::writePortCount(), and ListItemData::writePorts.

Referenced by TransferDataToWindow().

Here is the call graph for this function:

◆ onAdd()

void AddRFFromHDBDialog::onAdd ( wxCommandEvent &  event)
private

Adds a new register file to the machine when "Add" button is pressed.

Definition at line 309 of file AddRFFromHDBDialog.cc.

309 {
310
311 long item = -1;
312 item = list_->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
313 if ( item == -1 ) return;
314
315 ListItemData* lid = (ListItemData*)list_->GetItemData(item);
316 int id = lid->id;
317 const RFArchitecture* arch =
319
321
322 int size = DEFAULT_SIZE;
323 int width = DEFAULT_WIDTH;
324
325 if (!arch->hasParameterizedWidth()) {
326 size = arch->width();
327 }
328
329 if (!arch->hasParameterizedSize()) {
330 size = arch->size();
331 }
332
333 // Generate name for the new register file.
334 string name =
335 "RF_" + Conversion::toString(size) + "x" + Conversion::toString(width);
336
337 string rfName = name;
338 int idx = 1;
339 while (machine->registerFileNavigator().hasItem(rfName)) {
340 rfName = name + "_" + Conversion::toString(idx);
341 idx++;
342 }
343
344 RegisterFile* rf = new RegisterFile(
345 rfName, size, width, arch->maxReads(), arch->maxWrites(),
347
348 for (int i = 0; i < arch->readPortCount(); i++) {
349 string name = "r" + Conversion::toString(i);
350 new RFPort(name, *rf);
351 }
352
353 for (int i = 0; i < arch->writePortCount(); i++) {
354 string name = "w" + Conversion::toString(i);
355 new RFPort(name, *rf);
356 }
357
358 for (int i = 0; i < arch->bidirPortCount(); i++) {
359 string name = "rw" + Conversion::toString(i);
360 new RFPort(name, *rf);
361 }
362
366
367}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static const int DEFAULT_SIZE
Default size for the rf, if the size is parameterized in the HDB.
static const int DEFAULT_WIDTH
Default bit width for the rf, if the size is parameterized in the HDB.
static std::string toString(const T &source)
bool zeroRegister() const
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
TTAMachine::Machine * getMachine()
Definition Model.cc:88
bool hasItem(const std::string &name) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual void addRegisterFile(RegisterFile &unit)
Definition Machine.cc:236
@ NORMAL
Used for general register allocation.

References TTAMachine::Machine::addRegisterFile(), HDB::RFArchitecture::bidirPortCount(), DEFAULT_SIZE, DEFAULT_WIDTH, Model::getMachine(), HDB::RFArchitecture::guardLatency(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), HDB::RFArchitecture::hasParameterizedSize(), HDB::RFArchitecture::hasParameterizedWidth(), ListItemData::id, MapTools::keyForValue(), list_, machine, HDB::RFArchitecture::maxReads(), HDB::RFArchitecture::maxWrites(), model_, TTAMachine::RegisterFile::NORMAL, Model::notifyObservers(), Model::pushToStack(), HDB::RFArchitecture::readPortCount(), TTAMachine::Machine::registerFileNavigator(), rfArchitectures_, HDB::RFArchitecture::size(), Conversion::toString(), HDB::RFArchitecture::width(), HDB::RFArchitecture::writePortCount(), and HDB::RFArchitecture::zeroRegister().

Here is the call graph for this function:

◆ onClose()

void AddRFFromHDBDialog::onClose ( wxCommandEvent &  event)
private

Closes the dialog when the close button is pressed.

Definition at line 373 of file AddRFFromHDBDialog.cc.

373 {
374 Close();
375}

◆ onColumnClick()

void AddRFFromHDBDialog::onColumnClick ( wxListEvent &  event)
private

Sorts HDB RF list according to clicked column.

Definition at line 421 of file AddRFFromHDBDialog.cc.

421 {
422
423 int clickedColumn = event.GetColumn();
424
425 if (clickedColumn == sortColumn_) {
427 } else {
428 sortASC_ = true;
429 setColumnImage(sortColumn_, -1); // removes arrow from old column
430 sortColumn_ = clickedColumn;
431 }
432
433 setColumnImage(clickedColumn, sortASC_);
434
435 if (sortASC_) {
436 list_->SortItems(RFListCompareASC, clickedColumn);
437 } else {
438 list_->SortItems(RFListCompareDESC, clickedColumn);
439 }
440}
int wxCALLBACK RFListCompareDESC(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)

References list_, RFListCompareASC(), RFListCompareDESC(), setColumnImage(), sortASC_, and sortColumn_.

Here is the call graph for this function:

◆ onListSelectionChange()

void AddRFFromHDBDialog::onListSelectionChange ( wxListEvent &  event)
private

Enables and disables the delete button according to slot list selection.

Definition at line 296 of file AddRFFromHDBDialog.cc.

296 {
297 if (list_->GetSelectedItemCount() == 1) {
298 FindWindow(ID_ADD)->Enable();
299 } else {
300 FindWindow(ID_ADD)->Disable();
301 }
302}

References ID_ADD, and list_.

◆ setColumnImage()

void AddRFFromHDBDialog::setColumnImage ( int  col,
int  image 
)
private

Sets sorting arrow image on selected column

Parameters
colColumn index to set the image
imageImage index in wxImageList

Definition at line 450 of file AddRFFromHDBDialog.cc.

450 {
451 wxListItem item;
452 item.SetMask(wxLIST_MASK_IMAGE);
453 item.SetImage(image);
454 list_->SetColumn(col, item);
455}

References list_.

Referenced by loadHDB(), and onColumnClick().

◆ TransferDataToWindow()

bool AddRFFromHDBDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the HDBs to the dialog list.

Returns
True, if the data transfer was ssuccesful.

Definition at line 193 of file AddRFFromHDBDialog.cc.

193 {
194
196 list_->DeleteAllItems();
197
199 registry.loadFromSearchPaths();
200
201 for (int i = 0; i < registry.hdbCount(); i++) {
202 loadHDB(registry.hdb(i));
203 }
204
205 wxString errorMessage;
206 for (int i = 0; i < registry.hdbErrorCount(); i++) {
207 errorMessage.Append(
209 errorMessage.Append(_T("\n"));
210 WarningDialog dialog(this, errorMessage);
211 dialog.ShowModal();
212 }
213
214 if (registry.hdbCount() < 1) {
215 wxString message = _T("No HDBs found in HDB search paths.");
216 WarningDialog dialog(this, message);
217 dialog.ShowModal();
218 }
219
220 list_->SetColumnWidth(8, wxLIST_AUTOSIZE);
221 return wxDialog::TransferDataToWindow();
222}
bool loadHDB(const HDB::HDBManager &manager)
static HDBRegistry & instance()
CachedHDBManager & hdb(const std::string fileName)
void loadFromSearchPaths()
std::string hdbErrorMessage(unsigned int index)
static void deleteAllValues(MapType &aMap)

References MapTools::deleteAllValues(), HDB::HDBRegistry::hdb(), HDB::HDBRegistry::hdbCount(), HDB::HDBRegistry::hdbErrorCount(), HDB::HDBRegistry::hdbErrorMessage(), HDB::HDBRegistry::instance(), list_, HDB::HDBRegistry::loadFromSearchPaths(), loadHDB(), rfArchitectures_, and WxConversion::toWxString().

Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_SIZE

const int AddRFFromHDBDialog::DEFAULT_SIZE = 1
staticprivate

Default size for the rf, if the size is parameterized in the HDB.

Definition at line 97 of file AddRFFromHDBDialog.hh.

Referenced by onAdd().

◆ DEFAULT_WIDTH

const int AddRFFromHDBDialog::DEFAULT_WIDTH = 32
staticprivate

Default bit width for the rf, if the size is parameterized in the HDB.

Definition at line 99 of file AddRFFromHDBDialog.hh.

Referenced by onAdd().

◆ HDB_FILE_FILTER

const wxString AddRFFromHDBDialog::HDB_FILE_FILTER = _T("*.hdb")
staticprivate

File filter for the HDB files.

Definition at line 101 of file AddRFFromHDBDialog.hh.

◆ list_

wxListCtrl* AddRFFromHDBDialog::list_
private

Immediate slot list widget.

Definition at line 82 of file AddRFFromHDBDialog.hh.

Referenced by AddRFFromHDBDialog(), loadHDB(), onAdd(), onColumnClick(), onListSelectionChange(), setColumnImage(), and TransferDataToWindow().

◆ model_

Model* AddRFFromHDBDialog::model_
private

Model of the current adf file.

Definition at line 80 of file AddRFFromHDBDialog.hh.

Referenced by onAdd().

◆ rfArchitectures_

std::map<int, HDB::RFArchitecture*> AddRFFromHDBDialog::rfArchitectures_
private

Map of rf architectures displayed in the dialog list.

Definition at line 84 of file AddRFFromHDBDialog.hh.

Referenced by loadHDB(), onAdd(), and TransferDataToWindow().

◆ sortASC_

bool AddRFFromHDBDialog::sortASC_
private

Definition at line 87 of file AddRFFromHDBDialog.hh.

Referenced by loadHDB(), and onColumnClick().

◆ sortColumn_

int AddRFFromHDBDialog::sortColumn_
private

Definition at line 86 of file AddRFFromHDBDialog.hh.

Referenced by onColumnClick().


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