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

#include <RFDialog.hh>

Inheritance diagram for RFDialog:
Inheritance graph
Collaboration diagram for RFDialog:
Collaboration graph

Public Member Functions

 RFDialog (wxWindow *parent, TTAMachine::RegisterFile *registerFile)
 
virtual ~RFDialog ()
 

Private Types

enum  {
  ID_NAME = 10000 , ID_TYPE , ID_SIZE , ID_WIDTH ,
  ID_MAX_READS , ID_MAX_WRITES , ID_GUARD_LATENCY , ID_PORT_LIST ,
  ID_ADD_PORT , ID_EDIT_PORT , ID_DELETE_PORT , ID_HELP ,
  ID_LABEL_NAME , ID_LABEL_SIZE , ID_LABEL_WIDTH , ID_LABEL_TYPE ,
  ID_LABEL_MAX_READS , ID_LABEL_MAX_WRITES , ID_LABEL_GUARD_LATENCY , ID_ZERO_REGISTER
}
 enumerated IDs for the dialog controls More...
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
virtual bool TransferDataToWindow ()
 
TTAMachine::PortselectedPort () const
 
void onOK (wxCommandEvent &event)
 
void onHelp (wxCommandEvent &event)
 
void onName (wxCommandEvent &event)
 
void onPortSelection (wxListEvent &event)
 
void onPortRightClick (wxListEvent &event)
 
void onAddPort (wxCommandEvent &event)
 
void onActivatePort (wxListEvent &event)
 
void onEditPort (wxCommandEvent &event)
 
void onDeletePort (wxCommandEvent &event)
 
void updateWidgets ()
 
void updatePortList ()
 
void setTexts ()
 

Private Attributes

wxStaticBoxSizer * portsSizer_
 Sizer containing the port list and associated buttons.
 
TTAMachine::RegisterFileregisterFile_
 Register file to modify.
 
wxString name_
 Name of the register file.
 
int size_
 Number of registers.
 
int width_
 Width.
 
int maxReads_
 Max reads.
 
int maxWrites_
 Maximum writes.
 
int guardLatency_
 Guard latency.
 
bool zeroRegister_
 Zero register.
 
wxListCtrl * portListCtrl_
 Port list control.
 
wxChoice * typeChoice_
 Opcode choice control.
 

Detailed Description

Dialog for editing register file parameters.

Definition at line 47 of file RFDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

enumerated IDs for the dialog controls

Enumerator
ID_NAME 
ID_TYPE 
ID_SIZE 
ID_WIDTH 
ID_MAX_READS 
ID_MAX_WRITES 
ID_GUARD_LATENCY 
ID_PORT_LIST 
ID_ADD_PORT 
ID_EDIT_PORT 
ID_DELETE_PORT 
ID_HELP 
ID_LABEL_NAME 
ID_LABEL_SIZE 
ID_LABEL_WIDTH 
ID_LABEL_TYPE 
ID_LABEL_MAX_READS 
ID_LABEL_MAX_WRITES 
ID_LABEL_GUARD_LATENCY 
ID_ZERO_REGISTER 

Definition at line 95 of file RFDialog.hh.

95 {
96 ID_NAME = 10000,
97 ID_TYPE,
98 ID_SIZE,
107 ID_HELP,
116 };
@ ID_LABEL_MAX_WRITES
Definition RFDialog.hh:113
@ ID_LABEL_MAX_READS
Definition RFDialog.hh:112
@ ID_ADD_PORT
Definition RFDialog.hh:104
@ ID_LABEL_SIZE
Definition RFDialog.hh:109
@ ID_DELETE_PORT
Definition RFDialog.hh:106
@ ID_EDIT_PORT
Definition RFDialog.hh:105
@ ID_LABEL_NAME
Definition RFDialog.hh:108
@ ID_MAX_READS
Definition RFDialog.hh:100
@ ID_GUARD_LATENCY
Definition RFDialog.hh:102
@ ID_LABEL_WIDTH
Definition RFDialog.hh:110
@ ID_LABEL_GUARD_LATENCY
Definition RFDialog.hh:114
@ ID_MAX_WRITES
Definition RFDialog.hh:101
@ ID_ZERO_REGISTER
Definition RFDialog.hh:115
@ ID_LABEL_TYPE
Definition RFDialog.hh:111
@ ID_PORT_LIST
Definition RFDialog.hh:103

Constructor & Destructor Documentation

◆ RFDialog()

RFDialog::RFDialog ( wxWindow *  parent,
TTAMachine::RegisterFile registerFile 
)

The Constructor.

Parameters
parentParent window of the dialog.
registerFileRegister file to add/edit.

Definition at line 82 of file RFDialog.cc.

84 :
85 wxDialog(parent, -1, _T(""), wxDefaultPosition),
86 registerFile_(registerFile),
87 name_(_T("")),
88 size_(1),
90 maxReads_(0),
91 maxWrites_(0),
92 zeroRegister_(false),
93 portListCtrl_(NULL),
94 typeChoice_(NULL) {
95
96 //registerFile_->updateMaxReadsAndWrites();
97 createContents(this, true, true);
98
99 FindWindow(wxID_OK)->Disable();
100 FindWindow(ID_EDIT_PORT)->Disable();
101 FindWindow(ID_DELETE_PORT)->Disable();
102
103 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
104
105 portListCtrl_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_PORT_LIST));
106 typeChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_TYPE));
107
108 // Set widget validators.
109 FindWindow(ID_WIDTH)->SetValidator(wxGenericValidator(&width_));
110 FindWindow(ID_SIZE)->SetValidator(wxGenericValidator(&size_));
111 FindWindow(ID_GUARD_LATENCY)->SetValidator(
112 wxGenericValidator(&guardLatency_));
113
114 FindWindow(ID_ZERO_REGISTER)->SetValidator(
115 wxGenericValidator(&zeroRegister_));
116
117 // set widget texts
118 setTexts();
119
121}
static const int DEFAULT_WIDTH
Default bit width.
int size_
Number of registers.
Definition RFDialog.hh:77
virtual bool TransferDataToWindow()
Definition RFDialog.cc:210
int maxWrites_
Maximum writes.
Definition RFDialog.hh:83
wxListCtrl * portListCtrl_
Port list control.
Definition RFDialog.hh:90
void setTexts()
Definition RFDialog.cc:135
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition RFDialog.cc:536
wxString name_
Name of the register file.
Definition RFDialog.hh:75
wxChoice * typeChoice_
Opcode choice control.
Definition RFDialog.hh:92
int width_
Width.
Definition RFDialog.hh:79
int maxReads_
Max reads.
Definition RFDialog.hh:81
TTAMachine::RegisterFile * registerFile_
Register file to modify.
Definition RFDialog.hh:73
int guardLatency_
Guard latency.
Definition RFDialog.hh:85
bool zeroRegister_
Zero register.
Definition RFDialog.hh:87

◆ ~RFDialog()

RFDialog::~RFDialog ( )
virtual

The Destructor.

Definition at line 127 of file RFDialog.cc.

127 {
128}

Member Function Documentation

◆ createContents()

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

Creates the dialog window contents.

This method was generated with wxDesigner.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 536 of file RFDialog.cc.

536 {
537
538 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
539
540 wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
541
542 wxStaticText *item2 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
543 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
544
545 wxTextCtrl *item3 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
546 item1->Add( item3, 0, wxGROW|wxALL, 5 );
547
548 wxStaticText *item4 = new wxStaticText( parent, ID_LABEL_TYPE, wxT("Type:"), wxDefaultPosition, wxDefaultSize, 0 );
549 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
550
551 wxString *strs5 = (wxString*) NULL;
552 wxChoice *item5 = new wxChoice( parent, ID_TYPE, wxDefaultPosition, wxSize(100,-1), 0, strs5, 0 );
553 item1->Add( item5, 0, wxGROW|wxALL, 5 );
554
555 wxStaticText *item6 = new wxStaticText( parent, ID_LABEL_SIZE, wxT("Size:"), wxDefaultPosition, wxDefaultSize, 0 );
556 item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
557
558 wxSpinCtrl *item7 = new wxSpinCtrl( parent, ID_SIZE, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
559 item1->Add( item7, 0, wxGROW|wxALL, 5 );
560
561 wxStaticText *item8 = new wxStaticText( parent, ID_LABEL_WIDTH, wxT("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
562 item1->Add( item8, 0, wxALIGN_RIGHT|wxALL, 5 );
563
564 wxSpinCtrl *item9 = new wxSpinCtrl( parent, ID_WIDTH, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
565 item1->Add( item9, 0, wxGROW|wxALL, 5 );
566
567 wxStaticText *item10 = new wxStaticText( parent, ID_LABEL_MAX_READS, wxT("Max-Reads:"), wxDefaultPosition, wxDefaultSize, 0 );
568 item1->Add( item10, 0, wxALIGN_RIGHT|wxALL, 5 );
569
570 wxStaticText *item11 = new wxStaticText( parent, ID_MAX_READS, wxT("0"), wxDefaultPosition, wxSize(100,-1), 0);
571 item1->Add( item11, 0, wxGROW|wxALL, 5 );
572
573 wxStaticText *item12 = new wxStaticText( parent, ID_LABEL_MAX_WRITES, wxT("Max-Writes:"), wxDefaultPosition, wxDefaultSize, 0 );
574 item1->Add( item12, 0, wxALIGN_RIGHT|wxALL, 5 );
575
576 wxStaticText *item13 = new wxStaticText( parent, ID_MAX_WRITES, wxT("0"), wxDefaultPosition, wxSize(100,-1), 0);
577 item1->Add( item13, 0, wxGROW|wxALL, 5 );
578
579 wxStaticText *item14 = new wxStaticText( parent, ID_LABEL_GUARD_LATENCY, wxT("Guard Latency:"), wxDefaultPosition, wxDefaultSize, 0 );
580 item1->Add( item14, 0, wxALIGN_RIGHT|wxALL, 5 );
581
582 wxSpinCtrl *item15 = new wxSpinCtrl( parent, ID_GUARD_LATENCY, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 1, 0 );
583 item1->Add( item15, 0, wxGROW|wxALL, 5 );
584
585 item0->Add( item1, 0, wxGROW|wxALL, 5 );
586
587 wxStaticBox *item17 = new wxStaticBox( parent, -1, wxT("Ports:") );
588 wxStaticBoxSizer *item16 = new wxStaticBoxSizer( item17, wxVERTICAL );
589 portsSizer_ = item16;
590
591 wxListCtrl *item18 = new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER );
592 item16->Add( item18, 0, wxGROW|wxALL, 5 );
593
594 wxBoxSizer *item19 = new wxBoxSizer( wxHORIZONTAL );
595
596 wxButton *item20 = new wxButton( parent, ID_ADD_PORT, wxT("&Add.."), wxDefaultPosition, wxDefaultSize, 0 );
597 item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
598
599 wxButton *item21 = new wxButton( parent, ID_EDIT_PORT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
600 item19->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
601
602 wxButton *item22 = new wxButton( parent, ID_DELETE_PORT, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
603 item19->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
604
605 item16->Add( item19, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 );
606
607 item0->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
608
609 wxBoxSizer *item23 = new wxBoxSizer( wxHORIZONTAL );
610
611 wxButton *item24 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
612 item23->Add( item24, 0, wxALIGN_CENTER|wxALL, 5 );
613
614 wxButton *item25 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
615 item23->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
616
617 wxButton *item26 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
618 item23->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
619
620 item0->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
621
622 wxCheckBox *item27 = new wxCheckBox( parent, ID_ZERO_REGISTER, wxT("Zero register"), wxDefaultPosition, wxDefaultSize, 0);
623 item1->Add( item27, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
624
625 if (set_sizer)
626 {
627 parent->SetSizer( item0 );
628 if (call_fit)
629 item0->SetSizeHints( parent );
630 }
631
632 return item0;
633}
wxStaticBoxSizer * portsSizer_
Sizer containing the port list and associated buttons.
Definition RFDialog.hh:70

References ID_ADD_PORT, ID_DELETE_PORT, ID_EDIT_PORT, ID_GUARD_LATENCY, ID_HELP, ID_LABEL_GUARD_LATENCY, ID_LABEL_MAX_READS, ID_LABEL_MAX_WRITES, ID_LABEL_NAME, ID_LABEL_SIZE, ID_LABEL_TYPE, ID_LABEL_WIDTH, ID_MAX_READS, ID_MAX_WRITES, ID_NAME, ID_PORT_LIST, ID_SIZE, ID_TYPE, ID_WIDTH, ID_ZERO_REGISTER, and portsSizer_.

◆ onActivatePort()

void RFDialog::onActivatePort ( wxListEvent &  event)
private

Handles left mouse button double clicks on the port list.

Definition at line 455 of file RFDialog.cc.

455 {
456 wxCommandEvent dummy;
458}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onEditPort(wxCommandEvent &event)
Definition RFDialog.cc:467

References dummy, and onEditPort().

Here is the call graph for this function:

◆ onAddPort()

void RFDialog::onAddPort ( wxCommandEvent &  event)
private

Creates and shows an empty RFPortDialog for adding ports.

Definition at line 412 of file RFDialog.cc.

412 {
413
414 // Generate name for the new port.
415 int i = 1;
418 while (registerFile_->hasPort(newName)) {
421 i++;
422 }
423
424 RFPort* port = new RFPort(newName, *registerFile_);
425 RFPortDialog portDialog(this, port);
426 if (portDialog.ShowModal() == wxID_OK) {
428 } else {
429 delete port;
430 }
431
433
434}
static std::string toString(const T &source)
static const std::string COMP_NEW_NAME_PREFIX_PORT
Prefix for new port names.
void updatePortList()
Definition RFDialog.cc:269
void updateWidgets()
Definition RFDialog.cc:223
virtual bool hasPort(const std::string &name) const
Definition Unit.cc:96

References ProDeConstants::COMP_NEW_NAME_PREFIX_PORT, TTAMachine::Unit::hasPort(), registerFile_, Conversion::toString(), updatePortList(), and updateWidgets().

Here is the call graph for this function:

◆ onDeletePort()

void RFDialog::onDeletePort ( wxCommandEvent &  event)
private

Deletes selected port from the port list.

Definition at line 441 of file RFDialog.cc.

441 {
442 Port* selected = selectedPort();
443 assert(selected != NULL);
444 delete selected;
446
448}
#define assert(condition)
TTAMachine::Port * selectedPort() const
Definition RFDialog.cc:392

References assert, selectedPort(), updatePortList(), and updateWidgets().

Here is the call graph for this function:

◆ onEditPort()

void RFDialog::onEditPort ( wxCommandEvent &  event)
private

Handles the 'Edit Port' button event.

Opens a RFPortDialog with the selected port's attributes set.

Definition at line 467 of file RFDialog.cc.

467 {
468
469 Port* port = selectedPort();
470 if (port == NULL) {
471 // No port selected.
472 return;
473 }
474
475 RFPortDialog portDialog(this, port);
476 if (portDialog.ShowModal() == wxID_OK) {
478 }
479}

References selectedPort(), and updatePortList().

Referenced by onActivatePort().

Here is the call graph for this function:

◆ onHelp()

void RFDialog::onHelp ( wxCommandEvent &  event)
private

◆ onName()

void RFDialog::onName ( wxCommandEvent &  event)
private

Checks whether name field is empty and disables OK button of the dialog if it is.

Definition at line 373 of file RFDialog.cc.

373 {
374 if (!TransferDataFromWindow()) {
375 assert(false);
376 }
377 wxString trimmedName = name_.Trim(false).Trim(true);
378 if (trimmedName == _T("")) {
379 FindWindow(wxID_OK)->Disable();
380 } else {
381 FindWindow(wxID_OK)->Enable();
382 }
383}

References assert, and name_.

◆ onOK()

void RFDialog::onOK ( wxCommandEvent &  event)
private

Validates input in the controls, and updates the RegisterFile.

Definition at line 285 of file RFDialog.cc.

285 {
286 if (!Validate()) {
287 return;
288 }
289
290 if (!TransferDataFromWindow()) {
291 return;
292 }
293
294 string trimmedName =
295 WxConversion::toString(name_.Trim(false).Trim(true));
296
297 // Check the name validity.
298 if (!MachineTester::isValidComponentName(trimmedName)) {
300 format message =
302 InformationDialog warning(
303 this, WxConversion::toWxString(message.str()));
304 warning.ShowModal();
305 return;
306 }
307
308 if (registerFile_->name() != trimmedName) {
309
312
313 for (int i = 0; i < navigator.count(); i++) {
314 RegisterFile* rf = navigator.item(i);
315 if (trimmedName == rf->name()) {
316 ProDeTextGenerator* prodeTexts =
318 format message =
320 format a_rf =
322 format machine =
324 format rf =
326 message % trimmedName % a_rf.str() % machine.str() % rf.str();
327 WarningDialog warning(
328 this, WxConversion::toWxString(message.str()));
329 warning.ShowModal();
330 return;
331 }
332 }
333 }
334
335 try {
336 registerFile_->setName(trimmedName);
341 } catch (Exception& e) {
342 InformationDialog dialog(
344 dialog.ShowModal();
345 return;
346 }
347
348 // set register file type
349 switch (typeChoice_->GetSelection()) {
350 case 0:
352 break;
353 case 1:
355 break;
356 case 2:
358 break;
359 default:
360 assert(false);
361 }
362
363 //registerFile_->updateMaxReadsAndWrites();
364 EndModal(wxID_OK);
365}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
std::string errorMessage() const
Definition Exception.cc:123
static bool isValidComponentName(const std::string &name)
static ProDeTextGenerator * instance()
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
@ COMP_REGISTER_FILE
Register file (w/o article).
@ COMP_MACHINE
Text for machine description.
@ COMP_A_REGISTER_FILE
Register file (w/ article).
virtual void setWidth(int width)
virtual Machine * machine() const
virtual TCEString name() const
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual void setType(RegisterFile::Type type)
virtual void setZeroRegister(const bool &value)
virtual void setName(const std::string &name)
@ VOLATILE
Used for user-controlled I/O communication.
@ NORMAL
Used for general register allocation.
@ RESERVED
Used for custom, user controlled register allocation.
virtual void setGuardLatency(int latency)
virtual void setNumberOfRegisters(int registers)
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

References assert, ProDeTextGenerator::COMP_A_REGISTER_FILE, ProDeTextGenerator::COMP_MACHINE, ProDeTextGenerator::COMP_REGISTER_FILE, TTAMachine::Machine::Navigator< ComponentType >::count(), Exception::errorMessage(), guardLatency_, ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), machine, ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, TTAMachine::Component::name(), name_, TTAMachine::RegisterFile::NORMAL, registerFile_, TTAMachine::Machine::registerFileNavigator(), TTAMachine::RegisterFile::RESERVED, TTAMachine::RegisterFile::setGuardLatency(), TTAMachine::RegisterFile::setName(), TTAMachine::RegisterFile::setNumberOfRegisters(), TTAMachine::RegisterFile::setType(), TTAMachine::BaseRegisterFile::setWidth(), TTAMachine::RegisterFile::setZeroRegister(), size_, Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), typeChoice_, TTAMachine::RegisterFile::VOLATILE, width_, and zeroRegister_.

Here is the call graph for this function:

◆ onPortRightClick()

void RFDialog::onPortRightClick ( wxListEvent &  event)
private

Opens a pop-up menu when right mouse button was pressed.

Parameters
eventInformation about right mouse click event.

Definition at line 505 of file RFDialog.cc.

505 {
506
507 portListCtrl_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
508 wxLIST_STATE_SELECTED);
509
510 wxMenu* contextMenu = new wxMenu();
511
513 format button = prodeTexts->text(
515 contextMenu->Append(
517 button = prodeTexts->text(
519 contextMenu->Append(
521 portListCtrl_->PopupMenu(contextMenu, event.GetPoint());
522}
@ TXT_LABEL_BUTTON_EDIT
Label for &Edit... button.
@ TXT_LABEL_BUTTON_DELETE
Label for &Delete button.

References ID_DELETE_PORT, ID_EDIT_PORT, ProDeTextGenerator::instance(), portListCtrl_, Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE, and ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT.

Here is the call graph for this function:

◆ onPortSelection()

void RFDialog::onPortSelection ( wxListEvent &  event)
private

Disables and enables Edit and Delete buttons under the port list.

If a port is selected, buttons are enabled. If no port is selected the buttons will be disabled.

Definition at line 488 of file RFDialog.cc.

488 {
489 if (portListCtrl_->GetSelectedItemCount() != 1) {
490 FindWindow(ID_DELETE_PORT)->Disable();
491 FindWindow(ID_EDIT_PORT)->Disable();
492 return;
493 }
494 FindWindow(ID_DELETE_PORT)->Enable();
495 FindWindow(ID_EDIT_PORT)->Enable();
496}

References ID_DELETE_PORT, ID_EDIT_PORT, and portListCtrl_.

◆ selectedPort()

Port * RFDialog::selectedPort ( ) const
private

Returns pointer to the port which is selected on the port list.

Returns
Pointer to the port which is selected on the port list.

Definition at line 392 of file RFDialog.cc.

392 {
393 long item = -1;
394 item = portListCtrl_->GetNextItem(
395 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
396
397 if (item == -1) {
398 return NULL;
399 }
400
401 string portName =
402 WxConversion::toString(portListCtrl_->GetItemText(item));
403
404 return registerFile_->port(portName);
405}
virtual RFPort * port(const std::string &name) const

References TTAMachine::BaseRegisterFile::port(), portListCtrl_, registerFile_, and WxConversion::toString().

Referenced by onDeletePort(), and onEditPort().

Here is the call graph for this function:

◆ setTexts()

void RFDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 135 of file RFDialog.cc.

135 {
138
139 // Dialog title
140 format fmt = prodeTexts->text(ProDeTextGenerator::TXT_RF_DIALOG_TITLE);
141 SetTitle(WxConversion::toWxString(fmt.str()));
142
143 // buttons
144 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
146
147 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
149
152
155
158
161
162 // widget labels
165
168
171
174
177
180
183
184 // choicer texts
186 typeChoice_->Append(WxConversion::toWxString(fmt.str()));
188 typeChoice_->Append(WxConversion::toWxString(fmt.str()));
190 typeChoice_->Append(WxConversion::toWxString(fmt.str()));
191
192 // box sizer label
195
196 // Create port list column.
197 wxListCtrl* portList =
198 dynamic_cast<wxListCtrl*>(FindWindow(ID_PORT_LIST));
199 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
200 portList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
201 wxLIST_FORMAT_LEFT, 200);
202}
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_LABEL_NAME
Label for component name widget.
@ TXT_LABEL_MAX_READS
Label for Max-Reads widget.
@ TXT_LABEL_WIDTH
Label for bit width widget.
@ TXT_LABEL_MAX_WRITES
Label for Max-Writes widget.
@ TXT_LABEL_TYPE
Label for type widget.
@ TXT_RF_PORTS_BOX
Ports box title.
@ TXT_RF_TYPE_NORMAL
Register file type: normal.
@ TXT_LABEL_GUARD_LATENCY
Label for guard latency.
@ TXT_RF_TYPE_VOLATILE
Register file type: volatile.
@ TXT_LABEL_SIZE
Label for size widget.
@ TXT_RF_DIALOG_TITLE
Register file Dialog title.
@ TXT_COLUMN_NAME
Label for name column in a list.
@ TXT_RF_TYPE_RESERVED
Register file type: reserved.
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_ADD_PORT, ID_DELETE_PORT, ID_EDIT_PORT, ID_HELP, ID_LABEL_GUARD_LATENCY, ID_LABEL_MAX_READS, ID_LABEL_MAX_WRITES, ID_LABEL_NAME, ID_LABEL_SIZE, ID_LABEL_TYPE, ID_LABEL_WIDTH, ID_PORT_LIST, GUITextGenerator::instance(), ProDeTextGenerator::instance(), portsSizer_, WidgetTools::setLabel(), WidgetTools::setWidgetLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_ADD_DIALOG, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_EDIT_DIALOG, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_NAME, ProDeTextGenerator::TXT_LABEL_GUARD_LATENCY, ProDeTextGenerator::TXT_LABEL_MAX_READS, ProDeTextGenerator::TXT_LABEL_MAX_WRITES, ProDeTextGenerator::TXT_LABEL_NAME, ProDeTextGenerator::TXT_LABEL_SIZE, ProDeTextGenerator::TXT_LABEL_TYPE, ProDeTextGenerator::TXT_LABEL_WIDTH, ProDeTextGenerator::TXT_RF_DIALOG_TITLE, ProDeTextGenerator::TXT_RF_PORTS_BOX, ProDeTextGenerator::TXT_RF_TYPE_NORMAL, ProDeTextGenerator::TXT_RF_TYPE_RESERVED, ProDeTextGenerator::TXT_RF_TYPE_VOLATILE, and typeChoice_.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool RFDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the RegisterFile object to the dialog widgets.

Returns
false, if an error occured in the transfer.

Definition at line 210 of file RFDialog.cc.

210 {
211
213
214 return wxWindow::TransferDataToWindow();
215}

References updateWidgets().

Here is the call graph for this function:

◆ updatePortList()

void RFDialog::updatePortList ( )
private

Updates the port list widget.

Definition at line 269 of file RFDialog.cc.

269 {
270 portListCtrl_->DeleteAllItems();
271 for (int i=0; i < registerFile_->portCount(); i++) {
272
273 wxString name =
275
276 portListCtrl_->InsertItem(i, name);
277 }
278}
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135

References TTAMachine::Port::name(), TTAMachine::BaseRegisterFile::port(), TTAMachine::Unit::portCount(), portListCtrl_, registerFile_, and WxConversion::toWxString().

Referenced by onAddPort(), onDeletePort(), onEditPort(), and updateWidgets().

Here is the call graph for this function:

◆ updateWidgets()

void RFDialog::updateWidgets ( )
private

Reads data form the RegisterFile and updates GUI.

Definition at line 223 of file RFDialog.cc.

223 {
224
225 //registerFile_->updateMaxReadsAndWrites();
226
234
235 switch (registerFile_->type()) {
237 typeChoice_->SetSelection(0);
238 break;
240 typeChoice_->SetSelection(1);
241 break;
243 typeChoice_->SetSelection(2);
244 break;
245 default:
246 assert(false);
247 }
248
250
251 // wxWidgets GTK1 version seems to bug with spincontrol validators.
252 // The widget value has to be set manually.
253 dynamic_cast<wxSpinCtrl*>(FindWindow(ID_SIZE))->SetValue(size_);
254 dynamic_cast<wxSpinCtrl*>(FindWindow(ID_WIDTH))->SetValue(width_);
255 dynamic_cast<wxStaticText*>(FindWindow(ID_MAX_READS))->SetLabel(
257 dynamic_cast<wxStaticText*>(FindWindow(ID_MAX_WRITES))->SetLabel(
259 dynamic_cast<wxSpinCtrl*>(
261 dynamic_cast<wxCheckBox*>(
263}
virtual int numberOfRegisters() const
virtual int width() const
virtual int maxReads() const
virtual bool zeroRegister() const
virtual int guardLatency() const
virtual RegisterFile::Type type() const
virtual int maxWrites() const

References assert, TTAMachine::RegisterFile::guardLatency(), guardLatency_, ID_GUARD_LATENCY, ID_MAX_READS, ID_MAX_WRITES, ID_SIZE, ID_WIDTH, ID_ZERO_REGISTER, TTAMachine::RegisterFile::maxReads(), maxReads_, TTAMachine::RegisterFile::maxWrites(), maxWrites_, TTAMachine::Component::name(), name_, TTAMachine::RegisterFile::NORMAL, TTAMachine::BaseRegisterFile::numberOfRegisters(), registerFile_, TTAMachine::RegisterFile::RESERVED, size_, WxConversion::toWxString(), TTAMachine::RegisterFile::type(), typeChoice_, updatePortList(), TTAMachine::RegisterFile::VOLATILE, TTAMachine::BaseRegisterFile::width(), width_, TTAMachine::RegisterFile::zeroRegister(), and zeroRegister_.

Referenced by onAddPort(), onDeletePort(), and TransferDataToWindow().

Here is the call graph for this function:

Member Data Documentation

◆ guardLatency_

int RFDialog::guardLatency_
private

Guard latency.

Definition at line 85 of file RFDialog.hh.

Referenced by onOK(), and updateWidgets().

◆ maxReads_

int RFDialog::maxReads_
private

Max reads.

Definition at line 81 of file RFDialog.hh.

Referenced by updateWidgets().

◆ maxWrites_

int RFDialog::maxWrites_
private

Maximum writes.

Definition at line 83 of file RFDialog.hh.

Referenced by updateWidgets().

◆ name_

wxString RFDialog::name_
private

Name of the register file.

Definition at line 75 of file RFDialog.hh.

Referenced by onName(), onOK(), and updateWidgets().

◆ portListCtrl_

wxListCtrl* RFDialog::portListCtrl_
private

Port list control.

Definition at line 90 of file RFDialog.hh.

Referenced by onPortRightClick(), onPortSelection(), selectedPort(), and updatePortList().

◆ portsSizer_

wxStaticBoxSizer* RFDialog::portsSizer_
private

Sizer containing the port list and associated buttons.

Definition at line 70 of file RFDialog.hh.

Referenced by createContents(), and setTexts().

◆ registerFile_

TTAMachine::RegisterFile* RFDialog::registerFile_
private

Register file to modify.

Definition at line 73 of file RFDialog.hh.

Referenced by onAddPort(), onOK(), selectedPort(), updatePortList(), and updateWidgets().

◆ size_

int RFDialog::size_
private

Number of registers.

Definition at line 77 of file RFDialog.hh.

Referenced by onOK(), and updateWidgets().

◆ typeChoice_

wxChoice* RFDialog::typeChoice_
private

Opcode choice control.

Definition at line 92 of file RFDialog.hh.

Referenced by onOK(), setTexts(), and updateWidgets().

◆ width_

int RFDialog::width_
private

Width.

Definition at line 79 of file RFDialog.hh.

Referenced by onOK(), and updateWidgets().

◆ zeroRegister_

bool RFDialog::zeroRegister_
private

Zero register.

Definition at line 87 of file RFDialog.hh.

Referenced by onOK(), and updateWidgets().


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