OpenASIP  2.0
GCUDialog.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 GCUDialog.cc
26  *
27  * Definition of GCUDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include <wx/spinctrl.h>
35 #include <wx/listctrl.h>
36 #include <wx/statline.h>
37 #include <wx/valgen.h>
38 #include <boost/format.hpp>
39 
40 #include "Application.hh"
41 #include "GCUDialog.hh"
42 #include "ModelConstants.hh"
43 #include "ProDeConstants.hh"
44 #include "WxConversion.hh"
45 #include "Conversion.hh"
46 #include "Machine.hh"
47 #include "MachineTester.hh"
48 #include "ControlUnit.hh"
49 #include "FUPort.hh"
50 #include "SpecialRegisterPort.hh"
51 #include "AddressSpace.hh"
52 #include "Socket.hh"
53 #include "InformationDialog.hh"
54 #include "GUITextGenerator.hh"
55 #include "ProDeTextGenerator.hh"
56 #include "WxConversion.hh"
57 #include "WidgetTools.hh"
58 #include "UserManualCmd.hh"
59 #include "OperationDialog.hh"
60 #include "HWOperation.hh"
61 #include "WarningDialog.hh"
62 #include "FUPortDialog.hh"
63 #include "SRPortDialog.hh"
64 #include "ObjectState.hh"
65 
66 using std::string;
67 using boost::format;
68 using namespace TTAMachine;
69 
70 // Too long lines to keep Doxygen quiet.
71 BEGIN_EVENT_TABLE(GCUDialog, wxDialog)
72  EVT_TEXT(ID_NAME, GCUDialog::onName)
73  EVT_BUTTON(wxID_OK, GCUDialog::onOK)
74 
75  EVT_BUTTON(ID_ADD_OPERATION, GCUDialog::onAddOperation)
76  EVT_BUTTON(ID_EDIT_OPERATION, GCUDialog::onEditOperation)
77  EVT_BUTTON(ID_DELETE_OPERATION, GCUDialog::onDeleteOperation)
81  EVT_LIST_ITEM_RIGHT_CLICK(ID_OPERATION_LIST, GCUDialog::onOperationRightClick)
82  EVT_MENU(ID_EDIT_OPERATION, GCUDialog::onEditOperation)
83  EVT_MENU(ID_DELETE_OPERATION, GCUDialog::onDeleteOperation)
84 
85  EVT_BUTTON(ID_ADD_FU_PORT, GCUDialog::onAddFUPort)
86  EVT_BUTTON(ID_ADD_SR_PORT, GCUDialog::onAddSRPort)
87  EVT_BUTTON(ID_EDIT_PORT, GCUDialog::onEditPort)
88  EVT_BUTTON(ID_DELETE_PORT, GCUDialog::onDeletePort)
92  EVT_LIST_ITEM_RIGHT_CLICK(ID_PORT_LIST, GCUDialog::onPortRightClick)
93  EVT_MENU(ID_EDIT_PORT, GCUDialog::onEditPort)
94  EVT_MENU(ID_DELETE_PORT, GCUDialog::onDeletePort)
95 
96  EVT_CHOICE(ID_RA_CHOICE, GCUDialog::onRAPortChoice)
98 
99 
100 /**
101  * The Constructor.
102  *
103  * @param parent Parent window of the dialog.
104  * @param gcu The Global Control Unit to be modified with the dialog.
105  */
107  wxWindow* parent,
108  ControlUnit* gcu):
109  wxDialog(parent, -1, _T(""), wxDefaultPosition),
110  gcu_(gcu),
111  name_(_T("")),
112  delaySlots_(0) {
113 
114  // Create dialog contents and set pointers to the dialog controls.
115  createContents(this, true, true);
116  addressSpaceChoice_ =
117  dynamic_cast<wxChoice*>(FindWindow(ID_ADDRESS_SPACE));
118  raPortChoice_ =
119  dynamic_cast<wxChoice*>(FindWindow(ID_RA_CHOICE));
120  operationList_ =
121  dynamic_cast<wxListCtrl*>(FindWindow(ID_OPERATION_LIST));
122  portList_ =
123  dynamic_cast<wxListCtrl*>(FindWindow(ID_PORT_LIST));
124 
125  // Disable conditional controls initially.
126  FindWindow(wxID_OK)->Disable();
127  FindWindow(ID_EDIT_OPERATION)->Disable();
128  FindWindow(ID_DELETE_OPERATION)->Disable();
129  FindWindow(ID_EDIT_PORT)->Disable();
130  FindWindow(ID_DELETE_PORT)->Disable();
131 
132  // set widget labels
133  setLabels();
134 
135  // Set validators for dialog controls.
136  FindWindow(ID_NAME)->SetValidator(
137  wxTextValidator(wxFILTER_ASCII, &name_));
138  FindWindow(ID_DELAY_SLOTS)->SetValidator(
139  wxGenericValidator(&delaySlots_));
140  //FindWindow(ID_GUARD_LATENCY)->SetValidator(
141  //wxGenericValidator(&guardLatency_));
142 
143  TransferDataToWindow();
144 }
145 
146 
147 /**
148  * The Destructor.
149  */
151 }
152 
153 
154 /**
155  * Sets the widget labels to texts provided by the GUITextGenerator.
156  */
157 void
159 
162 
163  // Dialog title
164  format fmt = prodeTexts->text(ProDeTextGenerator::TXT_GCU_DIALOG_TITLE);
165  string title = fmt.str();
166  SetTitle(WxConversion::toWxString(title));
167 
168  // buttons
169  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
171 
172  WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
174 
175  WidgetTools::setLabel(generator, FindWindow(ID_ADD_OPERATION),
177 
178  WidgetTools::setLabel(generator, FindWindow(ID_EDIT_OPERATION),
180 
181  WidgetTools::setLabel(generator, FindWindow(ID_DELETE_OPERATION),
183 
184  WidgetTools::setLabel(generator, FindWindow(ID_EDIT_PORT),
186 
187  WidgetTools::setLabel(generator, FindWindow(ID_DELETE_PORT),
189 
190  WidgetTools::setLabel(generator, FindWindow(ID_HELP),
192 
193  WidgetTools::setLabel(prodeTexts, FindWindow(ID_ADD_FU_PORT),
195 
196  WidgetTools::setLabel(prodeTexts, FindWindow(ID_ADD_SR_PORT),
198 
199  // widget labels
200  WidgetTools::setLabel(prodeTexts, FindWindow(ID_TEXT_NAME),
202 
203  WidgetTools::setLabel(prodeTexts, FindWindow(ID_TEXT_AS),
205 
206  WidgetTools::setLabel(prodeTexts, FindWindow(ID_TEXT_DS),
208 
209  //WidgetTools::setLabel(
210  //prodeTexts, FindWindow(ID_LABEL_GLOBAL_GUARD_LATENCY),
211  //ProDeTextGenerator::TXT_LABEL_GLOBAL_GUARD_LATENCY);
212 
213  // box sizer labels
214  fmt = prodeTexts->text(ProDeTextGenerator::TXT_GCU_PORTS_BOX);
215  WidgetTools::setWidgetLabel(portListSizer_, fmt.str());
216 
217 
218  // Create operation list columns.
219  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
220  wxListCtrl* operationList =
221  dynamic_cast<wxListCtrl*>(FindWindow(ID_OPERATION_LIST));
222  operationList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
223  wxLIST_FORMAT_LEFT, 260);
224 
225  // Create port list columns.
227  portList_->InsertColumn(0, WxConversion::toWxString(fmt.str()),
228  wxLIST_FORMAT_CENTER, 30);
229  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_SRP);
230  portList_->InsertColumn(1, WxConversion::toWxString(fmt.str()),
231  wxLIST_FORMAT_CENTER, 40);
232  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
233  portList_->InsertColumn(2, WxConversion::toWxString(fmt.str()),
234  wxLIST_FORMAT_LEFT, 110);
235  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_WIDTH);
236  portList_->InsertColumn(3, WxConversion::toWxString(fmt.str()),
237  wxLIST_FORMAT_LEFT, 110);
238 }
239 
240 
241 /**
242  * Transfers data from the GCU object to the dialog widgets.
243  *
244  * @return false, if an error occured in the transfer.
245  */
246 bool
248  name_ = WxConversion::toWxString(gcu_->name());
249  delaySlots_ = gcu_->delaySlots();
250  guardLatency_ = gcu_->globalGuardLatency();
251  updateAddressSpaceChoice();
252  updateRAPortChoice();
253  updatePortList();
254  updateOperationList();
255 
256  // wxWidgets GTK1 version seems to bug with spincontrol validators.
257  // The widget value has to be set manually.
258  dynamic_cast<wxSpinCtrl*>(
259  FindWindow(ID_DELAY_SLOTS))->SetValue(delaySlots_);
260 
261  return wxWindow::TransferDataToWindow();
262 }
263 
264 
265 /**
266  * Updates 'Address Space' choice control.
267  *
268  * Clears all items from the choicer and adds all address spaces plus
269  * an item 'NONE' indicating empty selection.
270  */
271 void
273 
274  addressSpaceChoice_->Clear();
275  addressSpaceChoice_->Append(ProDeConstants::NONE);
276 
277  // Put each address space of the Machine to the control.
279  gcu_->machine()->addressSpaceNavigator();
280 
281  for (int i = 0;i < navigator.count(); i++) {
282  AddressSpace* as = navigator.item(i);
283  wxString name = WxConversion::toWxString(as->name());
284  addressSpaceChoice_->Append(name);
285  }
286 
287  if (gcu_->addressSpace() != NULL) {
288 
289  wxString asName =
290  WxConversion::toWxString(gcu_->addressSpace()->name());
291 
292  addressSpaceChoice_->SetStringSelection(asName);
293 
294  } else {
295  addressSpaceChoice_->SetStringSelection(ProDeConstants::NONE);
296  }
297 }
298 
299 
300 /**
301  * Updates the Return address port choicer when the return address port
302  * choicer selection is changed.
303  */
304 void
306 
307  wxString selection = raPortChoice_->GetStringSelection();
308 
309  raPortChoice_->Clear();
310  raPortChoice_->Append(ProDeConstants::NONE);
311  raPortChoice_->SetSelection(0);
312 
313  for (int i = 0; i < gcu_->specialRegisterPortCount(); i++) {
314  SpecialRegisterPort* port = gcu_->specialRegisterPort(i);
315  string portName = port->name();
316  raPortChoice_->Append(WxConversion::toWxString(portName));
317 
318  if (gcu_->hasReturnAddressPort() &&
319  port == gcu_->returnAddressPort()) {
320 
321  raPortChoice_->SetStringSelection(
322  WxConversion::toWxString(portName));
323  }
324  }
325 }
326 
327 
328 /**
329  * Updates 'Ports' list control.
330  *
331  * Clears all items from the choicer and adds all ports.
332  */
333 void
335 
336  portList_->DeleteAllItems();
337 
338  // Current list index is stored in a separate variable because of
339  // possible omitting of the return address port.
340  int index = 0;
341  for (int i = 0; i < gcu_->portCount(); i++) {
342 
343  BaseFUPort* port = gcu_->port(i);
344 
345  bool triggers = port->isTriggering();
346  string width = Conversion::toString(port->width());
347  string name = port->name();
348 
349  // set asterisk symbol in the "T" column if port triggers
350  if (!triggers) {
351  portList_->InsertItem(index, _T(""), 0);
352  } else {
353  portList_->InsertItem(index, _T("*"), 0);
354  }
355 
356  // set asterisk symbol in the "SRP" column if the port is
357  // a special register port
358  if (gcu_->hasSpecialRegisterPort(port->name())) {
359  portList_->SetItem(index, 1, _T("*"));
360  } else {
361  portList_->SetItem(index, 1, _T(""));
362  }
363 
364  portList_->SetItem(index, 2, WxConversion::toWxString(name));
365  portList_->SetItem(index, 3, WxConversion::toWxString(width));
366 
367  index++;
368  }
369  wxListEvent dummy;
370  onPortSelection(dummy);
371 }
372 
373 
374 /**
375  * Validates input in the controls, and updates the ControlUnit.
376  */
377 void
378 GCUDialog::onOK(wxCommandEvent&) {
379 
380  if (!Validate()) {
381  return;
382  }
383 
384  if (!TransferDataFromWindow()) {
385  return;
386  }
387 
388  string trimmedName =
389  WxConversion::toString(name_.Trim(false).Trim(true));
390 
391  // Check the name validity.
392  if (!MachineTester::isValidComponentName(trimmedName)) {
394  format message =
396  InformationDialog warning(
397  this, WxConversion::toWxString(message.str()));
398  warning.ShowModal();
399  return;
400  }
401 
402  // Check that the name is not reserved for another FU.
403  if (trimmedName != gcu_->name()) {
405  gcu_->machine()->functionUnitNavigator();
406  for (int i = 0; i < navigator.count(); i++) {
407  FunctionUnit* fu = navigator.item(i);
408  if (trimmedName == fu->name()) {
409  ProDeTextGenerator* prodeTexts =
411  format message =
413  format a_fu =
415  format machine =
417  format gcu = prodeTexts->text(ProDeTextGenerator::COMP_GCU);
418  message % trimmedName % a_fu.str() % machine.str() % gcu.str();
419  WarningDialog warning(
420  this, WxConversion::toWxString(message.str()));
421  warning.ShowModal();
422  return;
423  }
424  }
425  }
426 
427  try {
428  gcu_->setName(trimmedName);
429  gcu_->setDelaySlots(delaySlots_);
430  gcu_->setGlobalGuardLatency(guardLatency_);
431  } catch (Exception& e) {
432  InformationDialog dialog(
434  dialog.ShowModal();
435  return;
436  }
437 
438  // set GCU address space
439  string asName =
440  WxConversion::toString(addressSpaceChoice_->GetStringSelection());
441 
443 
444  Machine::AddressSpaceNavigator asNavigator =
445  gcu_->machine()->addressSpaceNavigator();
446 
447  assert(asNavigator.hasItem(asName));
448  AddressSpace* addressSpace = asNavigator.item(asName);
449  gcu_->setAddressSpace(addressSpace);
450 
451  } else {
452  // no address space set
453  gcu_->setAddressSpace(NULL);
454  }
455 
456  EndModal(wxID_OK);
457 }
458 
459 
460 /**
461  * Checks whether the name field is empty, and disables OK button of the
462  * dialog if it is.
463  */
464 void
465 GCUDialog::onName(wxCommandEvent&) {
466  if (!TransferDataFromWindow()) {
467  assert(false);
468  }
469  wxString trimmedName = name_.Trim(false).Trim(true);
470  if (trimmedName == _T("")) {
471  FindWindow(wxID_OK)->Disable();
472  } else {
473  FindWindow(wxID_OK)->Enable();
474  }
475 }
476 
477 
478 
479 /**
480  * Creates and shows an empty Operation Dialog for adding operations.
481  */
482 void
483 GCUDialog::onAddOperation(wxCommandEvent&) {
484  ObjectState* gcu = gcu_->saveState();
485 
486  // Generate name for the new operation.
487  int i = 1;
490  while (gcu_->hasOperation(newName)) {
493  i++;
494  }
495 
496  HWOperation* operation = new HWOperation(newName, *gcu_);
497  OperationDialog dialog(this, operation);
498  if (dialog.ShowModal() == wxID_OK) {
499  delete gcu;
500  } else {
501  gcu_->loadState(gcu);
502  }
503  updateOperationList();
504 }
505 
506 
507 /**
508  * Deletes selected operation from the operation list.
509  */
510 void
512  string name = WidgetTools::lcStringSelection(operationList_, 0);
513  if (name == "") {
514  return;
515  }
516  delete gcu_->operation(name);
517  updateOperationList();
518 }
519 
520 
521 /**
522  * Handles the 'Edit Operation' button event.
523  *
524  * Opens a OperationDialog with the selected operation's attributes set.
525  */
526 void
527 GCUDialog::onEditOperation(wxCommandEvent&) {
528 
529  HWOperation* selected = selectedOperation();
530  if (selected == NULL) {
531  // No operation selected.
532  return;
533  }
534 
535  ObjectState* gcu = gcu_->saveState();
536  OperationDialog dialog(this, selected);
537  if (dialog.ShowModal() == wxID_OK) {
538  delete gcu;
539  } else {
540  gcu_->loadState(gcu);
541  }
542  updateOperationList();
543 }
544 
545 
546 /**
547  * Returns pointer to the operation, which is selected on the operation list.
548  *
549  * @return Pointer to the selected operation.
550  */
553  string name = WidgetTools::lcStringSelection(operationList_, 0);
554  if (name == "") {
555  return NULL;
556  }
557  return gcu_->operation(name);
558 }
559 
560 
561 /**
562  * Disables and enables Edit and Delete buttons under the operation list.
563  *
564  * If a operation is selected, buttons are enabled. If no operation is
565  * selected the buttons will be disabled.
566  *
567  * @param event ListEvent, which may have changed the selection.
568  */
569 void
571  if (operationList_->GetSelectedItemCount() != 1) {
572  FindWindow(ID_DELETE_OPERATION)->Disable();
573  FindWindow(ID_EDIT_OPERATION)->Disable();
574  return;
575  }
576  FindWindow(ID_DELETE_OPERATION)->Enable();
577  FindWindow(ID_EDIT_OPERATION)->Enable();
578 }
579 
580 
581 /**
582  * Updates the operation list.
583  */
584 void
586  operationList_->DeleteAllItems();
587  for (int i=0; i < gcu_->operationCount(); i++) {
588  wxString name = WxConversion::toWxString(gcu_->operation(i)->name());
589  operationList_->InsertItem(0, name);
590  }
591  wxListEvent dummy;
592  onOperationSelection(dummy);
593 }
594 
595 
596 /**
597  * Opens a pop-up menu when right mouse button was pressed on the
598  * operation list.
599  *
600  * @param event Information about right mouse click event.
601  */
602 void
603 GCUDialog::onOperationRightClick(wxListEvent& event) {
604 
605  operationList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
606  wxLIST_STATE_SELECTED);
607 
608  wxMenu* contextMenu = new wxMenu();
609 
611  format button = prodeTexts->text(
613  contextMenu->Append(
614  ID_EDIT_OPERATION, WxConversion::toWxString(button.str()));
615  button = prodeTexts->text(
617  contextMenu->Append(
618  ID_DELETE_OPERATION, WxConversion::toWxString(button.str()));
619  operationList_->PopupMenu(contextMenu, event.GetPoint());
620 }
621 
622 
623 /**
624  * Handles left mouse button double clicks on the operation list.
625  */
626 void
628  wxCommandEvent dummy;
629  onEditOperation(dummy);
630 }
631 
632 
633 
634 /**
635  * Creates and shows an empty Function Unit Port Dialog for adding ports.
636  */
637 void
638 GCUDialog::onAddFUPort(wxCommandEvent&) {
639 
640  // Generate name for the new port.
641  int i = 1;
644  while (gcu_->hasPort(newName)) {
647  i++;
648  }
649 
650  FUPort* port = new FUPort(
651  newName, ModelConstants::DEFAULT_WIDTH, *gcu_, false, false);
652  FUPortDialog portDialog(this, port);
653  if (portDialog.ShowModal() == wxID_CANCEL) {
654  // adding port was cancelled
655  delete port;
656  }
657  updatePortList();
658 }
659 
660 
661 /**
662  * Creates and shows an empty Special Register Port Dialog for adding ports.
663  */
664 void
665 GCUDialog::onAddSRPort(wxCommandEvent&) {
666 
667  // Generate name for the new port.
668  int i = 1;
671  while (gcu_->hasPort(newName)) {
674  i++;
675  }
676 
678  newName, ModelConstants::DEFAULT_WIDTH, *gcu_);
679 
680  SRPortDialog portDialog(this, port);
681  if (portDialog.ShowModal() == wxID_CANCEL) {
682  // adding port was cancelled
683  delete port;
684  }
685  updatePortList();
686  updateRAPortChoice();
687 }
688 
689 
690 /**
691  * Deletes selected port from the port list.
692  */
693 void
694 GCUDialog::onDeletePort(wxCommandEvent&) {
695  Port* selected = selectedPort();
696  if (selected == NULL) {
697  return;
698  }
699  delete selected;
700  updatePortList();
701  updateRAPortChoice();
702 }
703 
704 
705 /**
706  * Returns a pointer to the port selected in the port list.
707  *
708  * @return Pointer to the port selected in the port list.
709  */
710 BaseFUPort*
712  string name = WidgetTools::lcStringSelection(portList_, 2);
713  if (name == "") {
714  return NULL;
715  }
716  BaseFUPort* port = gcu_->port(name);
717  return port;
718 }
719 
720 
721 /**
722  * Handles the 'Edit Port' button event.
723  *
724  * Opens a FUPortDialog with the selected port set.
725  */
726 void
727 GCUDialog::onEditPort(wxCommandEvent&) {
728  BaseFUPort* selected = selectedPort();
729  if (selected == NULL) {
730  return;
731  }
732 
733  if (gcu_->hasSpecialRegisterPort(selected->name())) {
734  SpecialRegisterPort* port =
735  gcu_->specialRegisterPort(selected->name());
736  SRPortDialog portDialog(this, port);
737  portDialog.ShowModal();
738  } else if (gcu_->hasOperationPort(selected->name())) {
739  FUPort* port = gcu_->operationPort(selected->name());
740  FUPortDialog portDialog(this, port);
741  portDialog.ShowModal();
742  }
743  updatePortList();
744  updateRAPortChoice();
745 }
746 
747 
748 /**
749  * Disables and enables Edit and Delete buttons under the port list.
750  *
751  * If a port is selected, buttons are enabled. If no port is selected the
752  * buttons will be disabled.
753  *
754  * @param event ListEvent, which may have changed the selection.
755  */
756 void
758  if (portList_->GetSelectedItemCount() != 1) {
759  FindWindow(ID_DELETE_PORT)->Disable();
760  FindWindow(ID_EDIT_PORT)->Disable();
761  return;
762  }
763  FindWindow(ID_DELETE_PORT)->Enable();
764  FindWindow(ID_EDIT_PORT)->Enable();
765 }
766 
767 
768 /**
769  * Opens a pop-up menu when right mouse button was pressed on the port list.
770  *
771  * @param event Information about right mouse click event.
772  */
773 void
774 GCUDialog::onPortRightClick(wxListEvent& event) {
775 
776  portList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
777  wxLIST_STATE_SELECTED);
778 
779  wxMenu* contextMenu = new wxMenu();
780 
782  format button = prodeTexts->text(
784  contextMenu->Append(
785  ID_EDIT_PORT, WxConversion::toWxString(button.str()));
786  button = prodeTexts->text(
788  contextMenu->Append(
789  ID_DELETE_PORT, WxConversion::toWxString(button.str()));
790  portList_->PopupMenu(contextMenu, event.GetPoint());
791 }
792 
793 
794 /**
795  * Handles left mouse button double clicks on the port list.
796  */
797 void
799  wxCommandEvent dummy;
800  onEditPort(dummy);
801 }
802 
803 
804 /**
805  * Sets the return address port when return address port choicer selection
806  * changes.
807  */
808 void
809 GCUDialog::onRAPortChoice(wxCommandEvent&) {
810 
811  if (raPortChoice_->GetStringSelection() == ProDeConstants::NONE) {
812  gcu_->unsetReturnAddressPort();
813  return;
814  }
815 
816  string selection =
817  WxConversion::toString(raPortChoice_->GetStringSelection());
818 
819  SpecialRegisterPort* port = gcu_->specialRegisterPort(selection);
820 
821  assert(port != NULL);
822 
823  gcu_->setReturnAddressPort(*port);
824  updateRAPortChoice();
825 }
826 
827 
828 /**
829  * Creates the dialog window contents.
830  *
831  * This method was generated with wxDesigner, thus the ugly code and
832  * too long lines.
833  *
834  * @return Main sizer of the created contents.
835  * @param parent The dialog window.
836  * @param call_fit If true, fits the contents inside the dialog.
837  * @param set_sizer If true, sets the main sizer as dialog contents.
838  */
839 wxSizer*
840 GCUDialog::createContents(wxWindow *parent, bool call_fit, bool set_sizer) {
841 
842  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
843 
844  wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
845 
846  wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL );
847 
848  wxFlexGridSizer *item3 = new wxFlexGridSizer( 2, 0, 0 );
849 
850  wxStaticText *item4 = new wxStaticText( parent, ID_TEXT_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
851  item3->Add( item4, 0, wxALL, 5 );
852 
853  wxTextCtrl *item5 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(140,-1), 0 );
854  item3->Add( item5, 0, wxGROW|wxALL, 5 );
855 
856  wxStaticText *item6 = new wxStaticText( parent, ID_TEXT_DS, wxT("Delay slots:"), wxDefaultPosition, wxDefaultSize, 0 );
857  item3->Add( item6, 0, wxALL, 5 );
858 
859  wxSpinCtrl *item7 = new wxSpinCtrl( parent, ID_DELAY_SLOTS, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 10000, 1 );
860  item3->Add( item7, 0, wxGROW|wxALL, 5 );
861 
862  // global guard latency currently fixed at 1.
863  //wxStaticText *item8 = new wxStaticText( parent, ID_LABEL_GLOBAL_GUARD_LATENCY, wxT("Guard Latency:"), wxDefaultPosition, wxDefaultSize, 0 );
864  //item3->Add( item8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
865 
866  //wxSpinCtrl *item9 = new wxSpinCtrl( parent, ID_GUARD_LATENCY, wxT("0"), wxDefaultPosition, wxSize(100,-1), 0, 0, 1000, 0 );
867  //item3->Add( item9, 0, wxGROW|wxALL, 5 );
868 
869  wxStaticText *item10 = new wxStaticText( parent, ID_TEXT_AS, wxT("Address Space:"), wxDefaultPosition, wxDefaultSize, 0 );
870  item3->Add( item10, 0, wxALL, 5 );
871 
872  wxString *strs11 = (wxString*) NULL;
873  wxChoice *item11 = new wxChoice( parent, ID_ADDRESS_SPACE, wxDefaultPosition, wxSize(100,-1), 0, strs11, 0 );
874  item3->Add( item11, 0, wxGROW|wxALL, 5 );
875 
876  item2->Add( item3, 0, wxALL, 5 );
877 
878  wxStaticBox *item13 = new wxStaticBox( parent, -1, wxT("Operations:") );
879  wxStaticBoxSizer *item12 = new wxStaticBoxSizer( item13, wxVERTICAL );
880  operationsSizer_ = item12;
881 
882  wxListCtrl *item14 = new wxListCtrl( parent, ID_OPERATION_LIST, wxDefaultPosition, wxSize(300,200), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
883  item12->Add( item14, 0, wxGROW|wxALL, 5 );
884 
885  wxBoxSizer *item15 = new wxBoxSizer( wxHORIZONTAL );
886 
887  wxButton *item16 = new wxButton( parent, ID_ADD_OPERATION, wxT("&Add..."), wxDefaultPosition, wxDefaultSize, 0 );
888  item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
889 
890  wxButton *item17 = new wxButton( parent, ID_EDIT_OPERATION, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
891  item15->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
892 
893  wxButton *item18 = new wxButton( parent, ID_DELETE_OPERATION, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
894  item15->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
895 
896  item12->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
897 
898  item2->Add( item12, 0, wxGROW|wxALL, 5 );
899 
900  item1->Add( item2, 0, wxGROW|wxALL, 5 );
901 
902  wxStaticBox *item20 = new wxStaticBox( parent, -1, wxT("Ports:") );
903  wxStaticBoxSizer *item19 = new wxStaticBoxSizer( item20, wxVERTICAL );
904  portListSizer_ = item19;
905 
906  wxBoxSizer *item21 = new wxBoxSizer( wxVERTICAL );
907 
908  wxListCtrl *item22 = new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(300,180), wxLC_REPORT|wxSUNKEN_BORDER );
909  item21->Add( item22, 0, wxGROW|wxALL, 5 );
910 
911  wxBoxSizer *item23 = new wxBoxSizer( wxHORIZONTAL );
912 
913  wxButton *item24 = new wxButton( parent, ID_EDIT_PORT, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
914  item23->Add( item24, 0, wxALIGN_CENTER|wxALL, 5 );
915 
916  wxButton *item25 = new wxButton( parent, ID_DELETE_PORT, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
917  item23->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
918 
919  item21->Add( item23, 0, 0, 5 );
920 
921  wxBoxSizer *item26 = new wxBoxSizer( wxHORIZONTAL );
922 
923  wxButton *item27 = new wxButton( parent, ID_ADD_FU_PORT, wxT("Add operation port..."), wxDefaultPosition, wxDefaultSize, 0 );
924  item26->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
925 
926  wxButton *item28 = new wxButton( parent, ID_ADD_SR_PORT, wxT("Add special register port..."), wxDefaultPosition, wxDefaultSize, 0 );
927  item26->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
928 
929  item21->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
930 
931  wxStaticLine *item29 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
932  item21->Add( item29, 0, wxGROW|wxALL, 5 );
933 
934  wxFlexGridSizer *item30 = new wxFlexGridSizer( 2, 0, 0 );
935 
936  wxStaticText *item31 = new wxStaticText( parent, ID_LABEL_RA_CHOICE, wxT("Return address port:"), wxDefaultPosition, wxDefaultSize, 0 );
937  item30->Add( item31, 0, wxALIGN_CENTER|wxALL, 5 );
938 
939  wxString strs32[] =
940  {
941  wxT("NONE")
942  };
943  wxChoice *item32 = new wxChoice( parent, ID_RA_CHOICE, wxDefaultPosition, wxSize(120,-1), 1, strs32, 0 );
944  item30->Add( item32, 0, wxALIGN_CENTER|wxALL, 5 );
945 
946  item21->Add( item30, 0, wxGROW|wxALL, 5 );
947 
948  wxStaticLine *item35 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
949  item21->Add( item35, 0, wxGROW|wxALL, 5 );
950 
951  item19->Add( item21, 0, wxGROW|wxALL, 5 );
952 
953  item1->Add( item19, 0, wxGROW|wxALL, 5 );
954 
955  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
956 
957  wxStaticLine *item36 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
958  item0->Add( item36, 0, wxGROW|wxALL, 5 );
959 
960  wxGridSizer *item37 = new wxGridSizer( 2, 0, 0 );
961 
962  wxButton *item38 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
963  item37->Add( item38, 0, wxALL, 5 );
964 
965  wxBoxSizer *item39 = new wxBoxSizer( wxHORIZONTAL );
966 
967  wxButton *item40 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
968  item39->Add( item40, 0, wxALIGN_CENTER|wxALL, 5 );
969 
970  wxButton *item41 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
971  item39->Add( item41, 0, wxALIGN_CENTER|wxALL, 5 );
972 
973  item37->Add( item39, 0, wxALL, 5 );
974 
975  item0->Add( item37, 0, wxGROW|wxLEFT|wxRIGHT, 5 );
976 
977  if (set_sizer)
978  {
979  parent->SetSizer( item0 );
980  if (call_fit)
981  item0->SetSizeHints( parent );
982  }
983 
984  return item0;
985 }
ProDeTextGenerator::TXT_GCU_DIALOG_TITLE
@ TXT_GCU_DIALOG_TITLE
GCU Dialog title.
Definition: ProDeTextGenerator.hh:143
WarningDialog
Definition: WarningDialog.hh:42
WxConversion::toWxString
static wxString toWxString(const std::string &source)
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ProDeTextGenerator::TXT_BUTTON_ADD_SR_PORT
@ TXT_BUTTON_ADD_SR_PORT
Label for GCUdlg add FU port btn.
Definition: ProDeTextGenerator.hh:97
EVT_LIST_ITEM_ACTIVATED
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation FUImplementationDialog::onExternalPortActivation FUImplementationDialog::onParameterSelection EVT_LIST_ITEM_ACTIVATED(ID_PARAMETER_LIST, FUImplementationDialog::onParameterActivation) EVT_LIST_ITEM_DESELECTED(ID_PARAMETER_LIST
ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE
@ TXT_LABEL_BUTTON_DELETE
Label for &Delete button.
Definition: ProDeTextGenerator.hh:95
FUPortDialog.hh
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
TTAMachine::HWOperation
Definition: HWOperation.hh:52
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
TTAMachine::BaseFUPort
Definition: BaseFUPort.hh:44
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
AddressSpace.hh
GUITextGenerator
Definition: GUITextGenerator.hh:46
ObjectState
Definition: ObjectState.hh:59
GUITextGenerator::TXT_BUTTON_HELP
@ TXT_BUTTON_HELP
Label for help button.
Definition: GUITextGenerator.hh:60
WidgetTools.hh
FindWindow
Definition: FindWindow.hh:49
ProDeTextGenerator::COMP_A_FUNCTION_UNIT
@ COMP_A_FUNCTION_UNIT
Name for FU (w/ article).
Definition: ProDeTextGenerator.hh:264
ProDeTextGenerator::TXT_COLUMN_WIDTH
@ TXT_COLUMN_WIDTH
Label for width column in a list.
Definition: ProDeTextGenerator.hh:109
ProDeConstants::COMP_NEW_NAME_PREFIX_PORT
static const std::string COMP_NEW_NAME_PREFIX_PORT
Prefix for new port names.
Definition: ProDeConstants.hh:373
GCUDialog::onEditPort
void onEditPort(wxCommandEvent &event)
Definition: GCUDialog.cc:727
TTAMachine::Machine::Navigator::count
int count() const
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
Socket.hh
ProDeTextGenerator.hh
Conversion::toString
static std::string toString(const T &source)
ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT
@ TXT_LABEL_BUTTON_EDIT
Label for &Edit... button.
Definition: ProDeTextGenerator.hh:96
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
Definition: ProDeTextGenerator.hh:223
ProDeTextGenerator::MSG_ERROR_SAME_NAME
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
Definition: ProDeTextGenerator.hh:229
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
ProDeTextGenerator::TXT_GCU_PORTS_BOX
@ TXT_GCU_PORTS_BOX
Port list box title.
Definition: ProDeTextGenerator.hh:145
GCUDialog::setLabels
void setLabels()
Definition: GCUDialog.cc:158
ProDeConstants::COMP_NEW_NAME_PREFIX_OPERATION
static const std::string COMP_NEW_NAME_PREFIX_OPERATION
Prefix for new operation names.
Definition: ProDeConstants.hh:377
TTAMachine::FUPort
Definition: FUPort.hh:46
ProDeTextGenerator::TXT_COLUMN_SRP
@ TXT_COLUMN_SRP
Label for sp.reg. port column.
Definition: ProDeTextGenerator.hh:128
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
ModelConstants::DEFAULT_WIDTH
static const int DEFAULT_WIDTH
Default bit width.
Definition: ModelConstants.hh:46
HWOperation.hh
TTAMachine::SpecialRegisterPort
Definition: SpecialRegisterPort.hh:48
GCUDialog
Definition: GCUDialog.hh:48
OperationDialog.hh
WarningDialog.hh
GCUDialog::updatePortList
void updatePortList()
Definition: GCUDialog.cc:334
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
Conversion.hh
ProDeTextGenerator::COMP_GCU
@ COMP_GCU
Name for control unit.
Definition: ProDeTextGenerator.hh:265
GCUDialog::onDeletePort
void onDeletePort(wxCommandEvent &event)
Definition: GCUDialog.cc:694
TTAMachine::Port
Definition: Port.hh:54
ProDeTextGenerator::TXT_BUTTON_ADD_FU_PORT
@ TXT_BUTTON_ADD_FU_PORT
Label for GCUdlg add SR port btn.
Definition: ProDeTextGenerator.hh:98
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
InformationDialog.hh
Application.hh
GCUDialog::onAddSRPort
void onAddSRPort(wxCommandEvent &event)
Definition: GCUDialog.cc:665
ProDeTextGenerator::TXT_COLUMN_TRIGGERS
@ TXT_COLUMN_TRIGGERS
Label for T column in a list.
Definition: ProDeTextGenerator.hh:119
WidgetTools::lcStringSelection
static std::string lcStringSelection(wxListCtrl *list, int column)
Definition: WidgetTools.cc:108
ObjectState.hh
SRPortDialog
Definition: SRPortDialog.hh:44
GCUDialog::onOK
void onOK(wxCommandEvent &event)
Definition: GCUDialog.cc:378
ProDeTextGenerator::TXT_LABEL_NAME
@ TXT_LABEL_NAME
Label for component name widget.
Definition: ProDeTextGenerator.hh:56
GCUDialog::onActivateOperation
void onActivateOperation(wxListEvent &event)
Definition: GCUDialog.cc:627
GCUDialog.hh
ModelConstants.hh
Machine.hh
Exception
Definition: Exception.hh:54
MachineTester::isValidComponentName
static bool isValidComponentName(const std::string &name)
Definition: MachineTester.cc:312
EVT_LIST_ITEM_SELECTED
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation EVT_LIST_ITEM_SELECTED(ID_EXTERNAL_PORT_LIST, FUImplementationDialog::onExternalPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_EXTERNAL_PORT_LIST
TTAMachine::BaseFUPort::isTriggering
virtual bool isTriggering() const =0
GCUDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: GCUDialog.cc:840
GCUDialog::~GCUDialog
virtual ~GCUDialog()
Definition: GCUDialog.cc:150
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
GCUDialog::onAddOperation
void onAddOperation(wxCommandEvent &event)
Definition: GCUDialog.cc:483
GUITextGenerator::TXT_BUTTON_DELETE
@ TXT_BUTTON_DELETE
Label for delete button.
Definition: GUITextGenerator.hh:56
GCUDialog::onEditOperation
void onEditOperation(wxCommandEvent &event)
Definition: GCUDialog.cc:527
ProDeConstants.hh
GUITextGenerator.hh
GCUDialog::onActivatePort
void onActivatePort(wxListEvent &event)
Definition: GCUDialog.cc:798
MachineTester.hh
GCUDialog::onName
void onName(wxCommandEvent &event)
Definition: GCUDialog.cc:465
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
GCUDialog::selectedPort
TTAMachine::BaseFUPort * selectedPort()
Definition: GCUDialog.cc:711
EVT_LIST_ITEM_DESELECTED
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection EVT_LIST_ITEM_DESELECTED(ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_ARCH_PORT_LIST
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
SRPortDialog.hh
GUITextGenerator::TXT_BUTTON_ADD_DIALOG
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
Definition: GUITextGenerator.hh:54
GCUDialog::onDeleteOperation
void onDeleteOperation(wxCommandEvent &event)
Definition: GCUDialog.cc:511
GUITextGenerator::TXT_BUTTON_EDIT_DIALOG
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
Definition: GUITextGenerator.hh:58
GCUDialog::updateAddressSpaceChoice
void updateAddressSpaceChoice()
Definition: GCUDialog.cc:272
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
GCUDialog::onOperationRightClick
void onOperationRightClick(wxListEvent &event)
Definition: GCUDialog.cc:603
FUPort.hh
GCUDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: GCUDialog.cc:247
GCUDialog::onRAPortChoice
void onRAPortChoice(wxCommandEvent &event)
Definition: GCUDialog.cc:809
ControlUnit.hh
SpecialRegisterPort.hh
ProDeTextGenerator::COMP_MACHINE
@ COMP_MACHINE
Text for machine description.
Definition: ProDeTextGenerator.hh:252
WxConversion.hh
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
WidgetTools::setWidgetLabel
static void setWidgetLabel(wxWindow *widget, std::string text)
Definition: WidgetTools.cc:52
InformationDialog
Definition: InformationDialog.hh:42
GCUDialog::updateOperationList
void updateOperationList()
Definition: GCUDialog.cc:585
TTAMachine
Definition: Assembler.hh:48
GCUDialog::onPortSelection
void onPortSelection(wxListEvent &event)
Definition: GCUDialog.cc:757
GCUDialog::selectedOperation
TTAMachine::HWOperation * selectedOperation()
Definition: GCUDialog.cc:552
ProDeConstants::NONE
static const wxString NONE
Constant for "None".
Definition: ProDeConstants.hh:56
GCUDialog::onPortRightClick
void onPortRightClick(wxListEvent &event)
Definition: GCUDialog.cc:774
WxConversion::toString
static std::string toString(const wxString &source)
ProDeTextGenerator::TXT_COLUMN_NAME
@ TXT_COLUMN_NAME
Label for name column in a list.
Definition: ProDeTextGenerator.hh:105
ProDeTextGenerator::TXT_GCU_DELAY_SLOTS
@ TXT_GCU_DELAY_SLOTS
Delay slots control label.
Definition: ProDeTextGenerator.hh:146
FUPortDialog
Definition: FUPortDialog.hh:44
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
GCUDialog::updateRAPortChoice
void updateRAPortChoice()
Definition: GCUDialog.cc:305
UserManualCmd.hh
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
OperationDialog
Definition: OperationDialog.hh:49
GCUDialog::onAddFUPort
void onAddFUPort(wxCommandEvent &event)
Definition: GCUDialog.cc:638
ProDeTextGenerator::TXT_LABEL_ADDRESS_SPACE
@ TXT_LABEL_ADDRESS_SPACE
Label for address spave selector.
Definition: ProDeTextGenerator.hh:59
TTAMachine::BaseFUPort::width
virtual int width() const
Definition: BaseFUPort.cc:109
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59
GCUDialog::onOperationSelection
void onOperationSelection(wxListEvent &event)
Definition: GCUDialog.cc:570