OpenASIP  2.0
BusDialog.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 BusDialog.cc
26  *
27  * Definition of BusDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/wx.h>
34 #include <wx/listctrl.h>
35 #include <wx/radiobox.h>
36 #include <wx/spinctrl.h>
37 #include <boost/format.hpp>
38 
39 #include "BusDialog.hh"
40 #include "Bus.hh"
41 #include "Segment.hh"
42 #include "Guard.hh"
43 #include "Conversion.hh"
44 #include "WxConversion.hh"
45 #include "WarningDialog.hh"
46 #include "ErrorDialog.hh"
47 #include "InformationDialog.hh"
48 #include "Machine.hh"
49 #include "MachineTester.hh"
50 #include "UserManualCmd.hh"
51 #include "ProDeConstants.hh"
52 #include "FUPort.hh"
53 #include "RFGuardDialog.hh"
54 #include "FUGuardDialog.hh"
55 #include "ModelConstants.hh"
56 #include "WidgetTools.hh"
57 #include "GUITextGenerator.hh"
58 #include "ProDeTextGenerator.hh"
59 
60 using boost::format;
61 using std::string;
62 using namespace TTAMachine;
63 
64 BEGIN_EVENT_TABLE(BusDialog, wxDialog)
65  EVT_TEXT(ID_SEGMENT_NAME, BusDialog::onSegmentName)
66  EVT_TEXT(ID_BUS_NAME, BusDialog::onBusName)
67  EVT_BUTTON(ID_ADD_SEGMENT, BusDialog::onAddSegment)
68  EVT_BUTTON(ID_DELETE_SEGMENT, BusDialog::onDeleteSegment)
69  EVT_BUTTON(ID_SEGMENT_UP, BusDialog::onSegmentUp)
70  EVT_BUTTON(ID_SEGMENT_DOWN, BusDialog::onSegmentDown)
71  EVT_MENU(ID_DELETE_SEGMENT, BusDialog::onDeleteSegment)
72  EVT_LIST_ITEM_RIGHT_CLICK(ID_SEGMENT_LIST, BusDialog::onSegmentRightClick)
73 
74  EVT_BUTTON(wxID_OK, BusDialog::onOK)
75 
76  EVT_SPINCTRL(ID_BUS_WIDTH, BusDialog::onWidth)
77 
78  EVT_BUTTON(ID_ADD_RF_GUARD, BusDialog::onAddRFGuard)
79  EVT_BUTTON(ID_DELETE_RF_GUARD, BusDialog::onDeleteRFGuard)
80  EVT_BUTTON(ID_EDIT_RF_GUARD, BusDialog::onEditRFGuard)
81 
82  EVT_BUTTON(ID_ADD_FU_GUARD, BusDialog::onAddFUGuard)
83  EVT_BUTTON(ID_DELETE_FU_GUARD, BusDialog::onDeleteFUGuard)
84  EVT_BUTTON(ID_EDIT_FU_GUARD, BusDialog::onEditFUGuard)
85 
86  EVT_CHECKBOX(ID_FALSE_GUARD, BusDialog::onUnconditionalGuard)
87  EVT_CHECKBOX(ID_TRUE_GUARD, BusDialog::onUnconditionalGuard)
88 
89  EVT_LIST_ITEM_FOCUSED(ID_SEGMENT_LIST, BusDialog::onSegmentSelection)
90  EVT_LIST_DELETE_ITEM(ID_SEGMENT_LIST, BusDialog::onSegmentSelection)
93 
94  EVT_LIST_ITEM_FOCUSED(ID_RF_GUARD_LIST, BusDialog::onRFGuardSelection)
95  EVT_LIST_DELETE_ITEM(ID_RF_GUARD_LIST, BusDialog::onRFGuardSelection)
98 
99  EVT_LIST_ITEM_FOCUSED(ID_FU_GUARD_LIST, BusDialog::onFUGuardSelection)
100  EVT_LIST_DELETE_ITEM(ID_FU_GUARD_LIST, BusDialog::onFUGuardSelection)
103 
105  EVT_LIST_ITEM_RIGHT_CLICK(ID_RF_GUARD_LIST, BusDialog::onRFGuardRightClick)
107  EVT_LIST_ITEM_RIGHT_CLICK(ID_FU_GUARD_LIST, BusDialog::onFUGuardRightClick)
108 
109  EVT_MENU(ID_DELETE_RF_GUARD, BusDialog::onDeleteRFGuard)
110  EVT_MENU(ID_EDIT_RF_GUARD, BusDialog::onEditRFGuard)
111  EVT_MENU(ID_DELETE_FU_GUARD, BusDialog::onDeleteFUGuard)
112  EVT_MENU(ID_EDIT_FU_GUARD, BusDialog::onEditFUGuard)
114 
115 
116 /**
117  * The Constructor.
118  *
119  * @param parent Parent window of the dialog.
120  * @param bus Transport bus to be modified with the dialog.
121  */
123  wxWindow* parent,
124  Bus* bus):
125  wxDialog(parent, -1, _T(""), wxDefaultPosition, wxSize(300, 300)),
126  bus_(bus),
127  name_(_T("")),
128  width_(ModelConstants::DEFAULT_WIDTH),
129  immWidth_(ModelConstants::DEFAULT_WIDTH),
130  newSegName_(_T("")),
131  alwaysTrueGuard_(NULL),
132  alwaysFalseGuard_(NULL),
133  immediateExtensionBox_(NULL),
134  rfGuardList_(NULL),
135  fuGuardList_(NULL) {
136 
137  createContents(this, true, true);
138 
139  FindWindow(wxID_OK)->Disable();
140  FindWindow(ID_ADD_SEGMENT)->Disable();
141  FindWindow(ID_DELETE_SEGMENT)->Disable();
142  FindWindow(ID_SEGMENT_UP)->Disable();
143  FindWindow(ID_SEGMENT_DOWN)->Disable();
144  FindWindow(ID_EDIT_RF_GUARD)->Disable();
145  FindWindow(ID_DELETE_RF_GUARD)->Disable();
146  FindWindow(ID_EDIT_FU_GUARD)->Disable();
147  FindWindow(ID_DELETE_FU_GUARD)->Disable();
148 
149  rfGuardList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_RF_GUARD_LIST));
150  fuGuardList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_FU_GUARD_LIST));
151  segList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_SEGMENT_LIST));
152 
153  immediateExtensionBox_ =
154  dynamic_cast<wxRadioBox*>(FindWindow(ID_SI_EXTENSION));
155  alwaysTrueGuard_ =
156  dynamic_cast<wxCheckBox*>(FindWindow(ID_TRUE_GUARD));
157  alwaysFalseGuard_ =
158  dynamic_cast<wxCheckBox*>(FindWindow(ID_FALSE_GUARD));
159 
160  FindWindow(ID_BUS_NAME)->SetValidator(
161  wxTextValidator(wxFILTER_ASCII, &name_));
162  FindWindow(ID_SEGMENT_NAME)->SetValidator(
163  wxTextValidator(wxFILTER_ASCII, &newSegName_));
164  FindWindow(ID_BUS_WIDTH)->SetValidator(wxGenericValidator(&width_));
165  FindWindow(ID_SI_WIDTH)->SetValidator(wxGenericValidator(&immWidth_));
166 
167  // set widget texts
168  setTexts();
169 
170  TransferDataToWindow();
171 
172  FindWindow(ID_BUS_NAME)->SetFocus();
173 
174  // Editing segments is unsupported feature => hide segment ui
175  segmentSizer_->Show(false);
176  GetSizer()->SetSizeHints(this);
177 }
178 
179 
180 
181 /**
182  * The Destructor.
183  */
185 }
186 
187 
188 /**
189  *
190  */
191 void
195 
196  // Dialog title
197  format fmt = prodeTexts->text(ProDeTextGenerator::TXT_BUS_DIALOG_TITLE);
198 
199  string title = fmt.str();
200  SetTitle(WxConversion::toWxString(title));
201 
202  // buttons
203  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
205 
206  WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
208 
209  WidgetTools::setLabel(generator, FindWindow(ID_HELP),
211 
212  WidgetTools::setLabel(generator, FindWindow(ID_ADD_SEGMENT),
214 
215  WidgetTools::setLabel(generator, FindWindow(ID_DELETE_SEGMENT),
217 
218  WidgetTools::setLabel(prodeTexts, FindWindow(ID_SEGMENT_UP),
220 
221  WidgetTools::setLabel(prodeTexts, FindWindow(ID_SEGMENT_DOWN),
223 
224  WidgetTools::setLabel(generator, FindWindow(ID_ADD_RF_GUARD),
226 
227  WidgetTools::setLabel(generator, FindWindow(ID_EDIT_RF_GUARD),
229 
230  WidgetTools::setLabel(generator, FindWindow(ID_DELETE_RF_GUARD),
232 
233  WidgetTools::setLabel(generator, FindWindow(ID_ADD_FU_GUARD),
235 
236  WidgetTools::setLabel(generator, FindWindow(ID_EDIT_FU_GUARD),
238 
239  WidgetTools::setLabel(generator, FindWindow(ID_DELETE_FU_GUARD),
241 
242  // widget labels
243  WidgetTools::setLabel(prodeTexts, FindWindow(ID_LABEL_BUS_NAME),
245 
246  WidgetTools::setLabel(prodeTexts, FindWindow(ID_LABEL_BUS_WIDTH),
248 
249  WidgetTools::setLabel(prodeTexts, FindWindow(ID_LABEL_SEGMENT_NAME),
251 
252  WidgetTools::setLabel(prodeTexts, FindWindow(ID_LABEL_SI_WIDTH),
254 
255  WidgetTools::setLabel(prodeTexts, FindWindow(ID_SI_EXTENSION),
257 
258  WidgetTools::setLabel(prodeTexts, FindWindow(ID_TRUE_GUARD),
260 
261  WidgetTools::setLabel(prodeTexts, FindWindow(ID_FALSE_GUARD),
263 
264  // Radio button labels
266  immediateExtensionBox_->SetString(0, WxConversion::toWxString(fmt.str()));
268  immediateExtensionBox_->SetString(1, WxConversion::toWxString(fmt.str()));
269 
270  // box sizer labels
271  fmt = prodeTexts->text(ProDeTextGenerator::TXT_BUS_BUS_BOX);
272  string label = fmt.str();
273  WidgetTools::setWidgetLabel(busSizer_, label);
274 
276  label = fmt.str();
277  WidgetTools::setWidgetLabel(segmentSizer_, label);
278 
279  fmt = prodeTexts->text(ProDeTextGenerator::TXT_BUS_SI_BOX);
280  label = fmt.str();
281  WidgetTools::setWidgetLabel(siSizer_, label);
282 
283  fmt = prodeTexts->
285  label = fmt.str();
286  WidgetTools::setWidgetLabel(registerGuardSizer_, label);
287 
289  label = fmt.str();
290  WidgetTools::setWidgetLabel(portGuardSizer_, label);
291 
292  // Create segment list columns.
293  wxListCtrl* segmentList =
294  dynamic_cast<wxListCtrl*>(FindWindow(ID_SEGMENT_LIST));
295  wxListCtrl* rfGuardList =
296  dynamic_cast<wxListCtrl*>(FindWindow(ID_RF_GUARD_LIST));
297  wxListCtrl* fuGuardList =
298  dynamic_cast<wxListCtrl*>(FindWindow(ID_FU_GUARD_LIST));
299 
301  string invLabel = fmt.str();
302 
303  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
304  string nameLabel = fmt.str();
305 
306  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_INDEX);
307  string indexLabel = fmt.str();
308 
309  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_PORT);
310  string portLabel = fmt.str();
311 
312  segmentList->InsertColumn(0, WxConversion::toWxString(nameLabel),
313  wxLIST_FORMAT_LEFT, 280);
314 
315  rfGuardList->InsertColumn(0, WxConversion::toWxString(nameLabel),
316  wxLIST_FORMAT_LEFT, 170);
317  rfGuardList->InsertColumn(1, WxConversion::toWxString(indexLabel),
318  wxLIST_FORMAT_LEFT, 70);
319  rfGuardList->InsertColumn(2, WxConversion::toWxString(invLabel),
320  wxLIST_FORMAT_LEFT, 40);
321 
322  fuGuardList->InsertColumn(0, WxConversion::toWxString(invLabel),
323  wxLIST_FORMAT_LEFT, 40);
324  fuGuardList->InsertColumn(1, WxConversion::toWxString(nameLabel),
325  wxLIST_FORMAT_LEFT, 170);
326  fuGuardList->InsertColumn(2, WxConversion::toWxString(portLabel),
327  wxLIST_FORMAT_LEFT, 70);
328 }
329 
330 
331 /**
332  * Transfers the data from the bus model to the dialog controls.
333  *
334  * @return false, if an error occured in the transfer.
335  */
336 bool
338 
339  name_ = WxConversion::toWxString(bus_->name());
340  width_ = bus_->width();
341  immWidth_ = bus_->immediateWidth();
342 
343 
344  // set extension
345  if (bus_->signExtends()) {
346  immediateExtensionBox_->SetStringSelection(
348  } else {
349  immediateExtensionBox_->SetStringSelection(
351  }
352 
353  updateGuardLists();
354  updateSegmentList();
355 
356  // wxWidgets GTK1 version seems to bug with spincontrol validators.
357  // The widget value has to be set manually.
358  dynamic_cast<wxSpinCtrl*>(FindWindow(ID_BUS_WIDTH))->SetValue(width_);
359  dynamic_cast<wxSpinCtrl*>(FindWindow(ID_SI_WIDTH))->SetValue(immWidth_);
360 
361  wxSpinEvent dummy;
362  onWidth(dummy);
363 
364  return wxWindow::TransferDataToWindow();
365 }
366 
367 /**
368  * Defines how SortItems() does comparison between two items to sort the list.
369  *
370  * Order: names in ascending order. Within same name, index numbers in
371  * ascending order. Within same name and index number, non-inverted guard
372  * comes before inverted.
373  */
374 int wxCALLBACK
375 ListCompareFunction(long item1, long item2, long WXUNUSED(sortData))
376 {
377  // items are set with SetItemData to contain pointers to the rf guards
378  RegisterGuard* rfGuard1 = (RegisterGuard*) item1;
379  RegisterGuard* rfGuard2 = (RegisterGuard*) item2;
380  assert (rfGuard1 != NULL);
381  assert (rfGuard2 != NULL);
382 
383  string name1 = rfGuard1->registerFile()->name();
384  int index1 = rfGuard1->registerIndex();
385  bool inverted1 = rfGuard1->isInverted();
386 
387  string name2 = rfGuard2->registerFile()->name();
388  int index2 = rfGuard2->registerIndex();
389  bool inverted2 = rfGuard2->isInverted();
390 
391  if (name1 < name2) {
392  return -1;
393  } else if (name1 > name2) {
394  return 1;
395  } else if (index1 < index2) {
396  return -1;
397  } else if (index1 > index2) {
398  return 1;
399  } else if (!inverted1 && inverted2) {
400  return -1;
401  } else if (inverted1 && !inverted2) {
402  return 1;
403  }
404 
405  return 0;
406 }
407 
408 /**
409  * Updates the guard lists.
410  */
411 void
413 
414  assert (rfGuardList_ != NULL);
415  assert (fuGuardList_ != NULL);
416  rfGuardList_->DeleteAllItems();
417  fuGuardList_->DeleteAllItems();
418 
419  registerGuards_.clear();
420  portGuards_.clear();
421 
422  alwaysTrueGuard_->SetValue(false);
423  alwaysFalseGuard_->SetValue(false);
424 
425  // add guards
426  for (int i = 0; i < bus_->guardCount(); i++) {
427 
428  Guard* guard = bus_->guard(i);
429 
430  UnconditionalGuard* unCondGuard =
431  dynamic_cast<UnconditionalGuard*>(guard);
432 
433  RegisterGuard* rfGuard = dynamic_cast<RegisterGuard*>(guard);
434  PortGuard* fuGuard = dynamic_cast<PortGuard*>(guard);
435 
436  if (unCondGuard != NULL) {
437  // unconditional guard
438  if (unCondGuard->isInverted()) {
439  alwaysFalseGuard_->SetValue(true);
440  } else {
441  alwaysTrueGuard_->SetValue(true);
442  }
443  } else if(rfGuard != NULL) {
444  // register guard
445  int index = registerGuards_.size();
446  registerGuards_.push_back(rfGuard);
447 
448  string name = rfGuard->registerFile()->name();
449  int rfIndex = rfGuard->registerIndex();
450  rfGuardList_->InsertItem(index, WxConversion::toWxString(name));
451  rfGuardList_->SetItem(index, 1, WxConversion::toWxString(rfIndex));
452  if (rfGuard->isInverted()) {
453  rfGuardList_->SetItem(index, 2, _T("*"));
454  } else {
455  rfGuardList_->SetItem(index, 2, _T(" "));
456  }
457 
458  // bind pointer to the guard as item data for future reference
459  rfGuardList_->SetItemData(index, (long)rfGuard);
460  } else if(fuGuard != NULL) {
461  // port guard
462  int index = portGuards_.size();
463  portGuards_.push_back(fuGuard);
464 
465  if (fuGuard->isInverted()) {
466  fuGuardList_->InsertItem(index, _T("*"));
467  } else {
468  fuGuardList_->InsertItem(index, _T(" "));
469  }
470 
471  string name = fuGuard->port()->parentUnit()->name();
472  fuGuardList_->SetItem(index, 1, WxConversion::toWxString(name));
473  name = fuGuard->port()->name();
474  fuGuardList_->SetItem(index, 2, WxConversion::toWxString(name));
475  }
476  }
477 
478  // sort guard list with given function, data parameter is not needed
479  rfGuardList_->SortItems(ListCompareFunction, static_cast<long>(0));
480 }
481 
482 /**
483  * Updates the segment list control.
484  */
485 void
487  segList_->DeleteAllItems();
488 
489  for (int i = bus_->segmentCount()-1;i > -1;i--) {
490  string segmentName = bus_->segment(i)->name();
491  segList_->InsertItem(0, WxConversion::toWxString(segmentName));
492  }
493 }
494 
495 /**
496  * Returns pointer to the selected segment.
497  *
498  * Returns NULL if no segment is selected.
499  */
500 Segment*
502 
503  // search the selected segment in the segment list widget
504  Segment* selected = NULL;
505  for (int i = 0; i < segList_->GetItemCount(); i++) {
506  // search selected list item
507  if (segList_->GetItemState(i, wxLIST_STATE_SELECTED) != 0) {
508  string name = WxConversion::toString(segList_->GetItemText(i));
509  selected = bus_->segment(name);
510  }
511  }
512  return selected;
513 }
514 
515 
516 /**
517  * Returns pointer to the selected fu port guard.
518  *
519  * @return NULL if no port guard is selected.
520  */
521 PortGuard*
523  long item = -1;
524  item = fuGuardList_->GetNextItem(
525  item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
526 
527  if (item == -1) {
528  return NULL;
529  }
530 
531  assert (item < int(portGuards_.size()));
532 
533  return portGuards_[item];
534 }
535 
536 
537 /**
538  * Returns pointer to the selected register file guard.
539  *
540  * @return NULL if no register guard is selected.
541  */
544  long item = -1;
545  item = rfGuardList_->GetNextItem(
546  item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
547 
548  if (item == -1) {
549  return NULL;
550  }
551 
552  assert (item < int(registerGuards_.size()));
553 
554  long itemData = rfGuardList_->GetItemData(item);
555  RegisterGuard* rfGuard = (RegisterGuard*)itemData;
556  assert (rfGuard != NULL);
557  return rfGuard;
558 }
559 
560 
561 
562 
563 /**
564  * Adds a new segment to the segment list.
565  */
566 void
567 BusDialog::onAddSegment(wxCommandEvent&) {
568 
569  if (!TransferDataFromWindow()) {
570  return;
571  }
572  assert(newSegName_ != _T(""));
573 
574  string trimmedName =
575  WxConversion::toString(newSegName_.Trim(false).Trim(true));
576 
577  // Check the name validity.
578  if (!MachineTester::isValidComponentName(trimmedName)) {
580  format message =
582  InformationDialog warning(
583  this, WxConversion::toWxString(message.str()));
584  warning.ShowModal();
585  return;
586  }
587 
588  // Check that the new segment's name is unique among the segments of
589  // the bus.
590  if (bus_->hasSegment(trimmedName)) {
592  format message =
594  format component =
596  format bus = prodeTexts->text(ProDeTextGenerator::COMP_BUS);
597  message % trimmedName % component.str() % bus.str();
598  component = prodeTexts->text(ProDeTextGenerator::COMP_SEGMENT);
599  message % component.str();
600  WarningDialog dialog(this, WxConversion::toWxString(message.str()));
601  dialog.ShowModal();
602  return;
603  }
604  new Segment(trimmedName, *bus_);
605  updateSegmentList();
606 
607  // clear the segment name control
608  dynamic_cast<wxTextCtrl*>(
609  FindWindow(ID_SEGMENT_NAME))->SetValue(_T(""));
610 }
611 
612 
613 /**
614  * Enables and disables OK button based on input in the bus name widget.
615  */
616 void
617 BusDialog::onBusName(wxCommandEvent&) {
618  if (!TransferDataFromWindow()) {
619  assert(false);
620  }
621  wxString trimmedName = name_.Trim(false).Trim(true);
622  if (trimmedName == _T("")) {
623  FindWindow(wxID_OK)->Disable();
624  } else {
625  FindWindow(wxID_OK)->Enable();
626  }
627 }
628 
629 
630 /**
631  * Handles the unconditional guard deletion/creation when
632  * true/false guard checkbox values are toggled.
633  */
634 void
635 BusDialog::onUnconditionalGuard(wxCommandEvent& event) {
636 
637  bool inverted = false;
638  wxCheckBox* checkbox = alwaysTrueGuard_;
639 
640  if (event.GetId() == ID_FALSE_GUARD) {
641  inverted = true;
642  checkbox = alwaysFalseGuard_;
643  }
644 
645  if (!checkbox->GetValue()) {
646  for (int i = 0; i < bus_->guardCount(); i++) {
647  Guard* guard = bus_->guard(i);
648  UnconditionalGuard* unCondGuard =
649  dynamic_cast<UnconditionalGuard*>(guard);
650  if (unCondGuard != NULL &&
651  unCondGuard->isInverted() == inverted) {
652 
653  delete unCondGuard;
654  }
655  }
656  } else {
657  try {
658  new UnconditionalGuard(inverted, *bus_);
659  } catch (Exception& e) {
661  format text = prodeTexts->text(ProDeTextGenerator::MSG_ERROR);
662  wxString message = WxConversion::toWxString(text.str());
663  message.Append(WxConversion::toWxString(e.errorMessage()));
664  ErrorDialog dialog(this, message);
665  dialog.ShowModal();
666  return;
667  }
668  }
669 }
670 
671 /**
672  * Enables and disables add segment button based on input in the segment
673  * name widget.
674  */
675 void
676 BusDialog::onSegmentName(wxCommandEvent&) {
677  if (!TransferDataFromWindow()) {
678  assert(false);
679  }
680  wxString trimmedName = newSegName_.Trim(false).Trim(true);
681  if (trimmedName == _T("")) {
682  FindWindow(ID_ADD_SEGMENT)->Disable();
683  } else {
684  FindWindow(ID_ADD_SEGMENT)->Enable();
685  }
686 }
687 
688 
689 /**
690  * Disables segment deletion and move buttons if no segment is selected.
691  */
692 void
694  if (segList_->GetSelectedItemCount() != 1) {
695  FindWindow(ID_DELETE_SEGMENT)->Disable();
696  FindWindow(ID_SEGMENT_UP)->Disable();
697  FindWindow(ID_SEGMENT_DOWN)->Disable();
698  return;
699  }
700  FindWindow(ID_DELETE_SEGMENT)->Enable();
701  FindWindow(ID_SEGMENT_UP)->Enable();
702  FindWindow(ID_SEGMENT_DOWN)->Enable();
703 }
704 
705 
706 /**
707  * Opens a pop-up menu when right mouse button was pressed.
708  *
709  * @param event Information about right mouse click event.
710  */
711 void
712 BusDialog::onSegmentRightClick(wxListEvent& event) {
713 
714  segList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
715  wxLIST_STATE_SELECTED);
716 
717  wxMenu* contextMenu = new wxMenu();
718 
720  format button = prodeTexts->text(
722  contextMenu->Append(
723  ID_DELETE_SEGMENT, WxConversion::toWxString(button.str()));
724  segList_->PopupMenu(contextMenu, event.GetPoint());
725 }
726 
727 
728 /**
729  * Deletes the selected segment from the bus.
730  *
731  * The Segments before and after the deleted segments are connected to each
732  * other.
733  */
734 void
735 BusDialog::onDeleteSegment(wxCommandEvent&) {
736 
737  Segment* selected = selectedSegment();
738  assert(selected != NULL);
739 
740  delete selected;
741  updateSegmentList();
742 
743  wxListEvent dummy;
744  onSegmentSelection(dummy);
745 }
746 
747 
748 /**
749  * Moves selected segment one position up in the segment chain.
750  */
751 void
752 BusDialog::onSegmentUp(wxCommandEvent&) {
753  Segment* selected = selectedSegment();
754  assert (selected != NULL);
755 
756  if (!selected->hasSourceSegment()) {
757  // Selected segment was first in the chain, do nothing.
758  return;
759  }
760 
761  selected->moveBefore(*(selected->sourceSegment()));
762  updateSegmentList();
763 
764  // set the moved segment as selected
765  long i = segList_->FindItem(0, WxConversion::toWxString(selected->name()));
766  segList_->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
767 }
768 
769 
770 
771 /**
772  * Moves selected segment one position down in the segment chain.
773  */
774 void
775 BusDialog::onSegmentDown(wxCommandEvent&) {
776  Segment* selected = selectedSegment();
777  assert (selected != NULL);
778 
779  if (!selected->hasDestinationSegment()) {
780  // Selected segment was first in the chain, do nothing.
781  return;
782  }
783 
784  selected->moveAfter(*(selected->destinationSegment()));
785  updateSegmentList();
786 
787  // set the moved segment as selected
788  long i = segList_->FindItem(0, WxConversion::toWxString(selected->name()));
789  segList_->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
790 }
791 
792 
793 /**
794  * Validates input in the controls, and updates the Bus object.
795  */
796 void
797 BusDialog::onOK(wxCommandEvent&) {
798 
799  if (!Validate()) {
800  return;
801  }
802 
803  if (!TransferDataFromWindow()) {
804  return;
805  }
806 
807  // Check that the machine doesn't contain instruction templates with
808  // slots that are wider than the new bus width.
810  bus_->machine()->instructionTemplateNavigator();
811  for (int i = 0; i < navigator.count(); i++) {
812  int slotWidth = navigator.item(i)->supportedWidth(bus_->name());
813  if (slotWidth != 0 && slotWidth > width_) {
814  ProDeTextGenerator* generator =
816  format message = generator->text(
818  message % navigator.item(i)->name();
819  message % slotWidth;
820  InformationDialog dialog(
821  this, WxConversion::toWxString(message.str()));
822  dialog.ShowModal();
823  return;
824  }
825  }
826 
827  // Check the name validity.
828  string trimmedName =
829  WxConversion::toString(name_.Trim(false).Trim(true));
830  if (!MachineTester::isValidComponentName(trimmedName)) {
832  format message =
834  InformationDialog warning(
835  this, WxConversion::toWxString(message.str()));
836  warning.ShowModal();
837  return;
838  }
839 
840  // Check that the new name is not reserved.
841  if (trimmedName != bus_->name()) {
842  const Machine::BusNavigator busNavigator =
843  bus_->machine()->busNavigator();
844  if (busNavigator.hasItem(trimmedName)) {
846  format message =
848  message % trimmedName;
849  message % prodeTexts->text(ProDeTextGenerator::COMP_A_BUS).str();
850  message % prodeTexts->text(ProDeTextGenerator::COMP_MACHINE).str();
851  message % prodeTexts->text(ProDeTextGenerator::COMP_BUS).str();
852  WarningDialog warning(
853  this, WxConversion::toWxString(message.str()));
854  warning.ShowModal();
855  return;
856  }
857  // Immediate slots share namespace with busses, check that an immediate
858  // slot with the same name does not exist.
859  const Machine::ImmediateSlotNavigator immSlotNavigator =
860  bus_->machine()->immediateSlotNavigator();
861  if (immSlotNavigator.hasItem(trimmedName)) {
863  format message =
865  message % trimmedName;
866  message % prodeTexts->text(
868  message % prodeTexts->text(ProDeTextGenerator::COMP_MACHINE).str();
869  message % prodeTexts->text(ProDeTextGenerator::COMP_BUS).str();
870  WarningDialog warning(
871  this, WxConversion::toWxString(message.str()));
872  warning.ShowModal();
873  return;
874  }
875  }
876 
877  bus_->setWidth(width_);
878  bus_->setImmediateWidth(immWidth_);
879  bus_->setName(trimmedName);
880 
881  if (immediateExtensionBox_->GetStringSelection().IsSameAs(
883 
884  bus_->setZeroExtends();
885  } else {
886  bus_->setSignExtends();
887  }
888 
889  EndModal(wxID_OK);
890 }
891 
892 
893 /**
894  * Creates and shows a register file guard dialog for
895  * adding register file guards.
896  */
897 void
898 BusDialog::onAddRFGuard(wxCommandEvent&) {
900  bus_->machine()->registerFileNavigator();
901 
902  if (navigator.count() < 1) {
904  format message =
906  InformationDialog dialog(this, WxConversion::toWxString(message.str()));
907  dialog.ShowModal();
908  return;
909  }
910 
911  RFGuardDialog dialog(this, bus_);
912  dialog.ShowModal();
913  updateGuardLists();
914 }
915 
916 
917 
918 /**
919  * Deletes selected register file guards from the register file guards list.
920  */
921 void
922 BusDialog::onDeleteRFGuard(wxCommandEvent&) {
923  long item = -1;
924 
925  // loop selected guards and delete them
926  for (int i = 0; i < rfGuardList_->GetSelectedItemCount(); ++i) {
927  item = rfGuardList_->GetNextItem(
928  item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
929 
930  assert (item < static_cast<int>(registerGuards_.size()));
931 
932  // retrieve item data (guard pointer) that is bound with the item
933  if (item >= 0) {
934  long itemData = rfGuardList_->GetItemData(item);
935  RegisterGuard* rfGuard = (RegisterGuard*)itemData;
936  if (rfGuard != NULL) {
937  delete rfGuard;
938  rfGuard = NULL;
939  }
940  }
941  }
942 
943  updateGuardLists();
944  wxListEvent dummy;
945  onRFGuardSelection(dummy);
946 
947  return;
948 }
949 
950 
951 
952 /**
953  * Handles the 'Edit RFGuard' button event.
954  *
955  * Opens a RFGuardDialog with the selected guard's attributes set.
956  */
957 void
958 BusDialog::onEditRFGuard(wxCommandEvent&) {
959  RegisterGuard* guard = selectedRFGuard();
960  if (guard == NULL) {
961  // No guard selected.
962  return;
963  }
964  RFGuardDialog dialog(this, bus_, guard);
965  dialog.ShowModal();
966  updateGuardLists();
967 }
968 
969 
970 /**
971  * Disables and enables Edit and Delete buttons under the register
972  * file guard list.
973  *
974  * If a guard is selected, buttons are enabled. If no guard is
975  * selected the buttons will be disabled.
976  */
977 void
979  if (rfGuardList_->GetSelectedItemCount() != 1) {
980  FindWindow(ID_EDIT_RF_GUARD)->Disable();
981  } else {
982  FindWindow(ID_EDIT_RF_GUARD)->Enable();
983  }
984 
985  if (rfGuardList_->GetSelectedItemCount() < 1) {
986  FindWindow(ID_DELETE_RF_GUARD)->Disable();
987  } else {
988  FindWindow(ID_DELETE_RF_GUARD)->Enable();
989  }
990 }
991 
992 
993 /**
994  * Creates and shows an empty function unit port guard dialog for
995  * adding function unit port guards.
996  */
997 void
998 BusDialog::onAddFUGuard(wxCommandEvent&) {
1000  bus_->machine()->functionUnitNavigator();
1001 
1002  bool portExists = false;
1003  for (int i = 0; i < navigator.count(); i++) {
1004  if (navigator.item(i)->portCount() > 0) {
1005  portExists = true;
1006  break;
1007  }
1008  }
1009 
1010  if (!portExists) {
1012  format message =
1014  InformationDialog dialog(
1015  this, WxConversion::toWxString(message.str()));
1016  dialog.ShowModal();
1017  return;
1018  }
1019 
1020  FUGuardDialog dialog(this, bus_);
1021  dialog.ShowModal();
1022  updateGuardLists();
1023 }
1024 
1025 
1026 
1027 /**
1028  * Deletes selected function unit port guards from the function unit
1029  * port guards list.
1030  */
1031 void
1032 BusDialog::onDeleteFUGuard(wxCommandEvent&) {
1033  delete selectedFUGuard();
1034  updateGuardLists();
1035  wxListEvent dummy;
1036  onFUGuardSelection(dummy);
1037 }
1038 
1039 
1040 
1041 /**
1042  * Handles the 'Edit FUGuard' button event.
1043  *
1044  * Opens a FUGuardDialog with the selected guard's attributes set.
1045  */
1046 void
1047 BusDialog::onEditFUGuard(wxCommandEvent&) {
1048  PortGuard* guard = selectedFUGuard();
1049  if (guard == NULL) {
1050  // No guard selected.
1051  return;
1052  }
1053  FUGuardDialog dialog(this, bus_, guard);
1054  dialog.ShowModal();
1055  updateGuardLists();
1056 }
1057 
1058 
1059 /**
1060  * Sets the immediate width range when the bus width is modified.
1061  */
1062 void
1063 BusDialog::onWidth(wxSpinEvent&) {
1064  wxSpinCtrl* width = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_BUS_WIDTH));
1065  wxSpinCtrl* siWidth = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_SI_WIDTH));
1066  if (siWidth->GetValue() > width->GetValue()) {
1067  siWidth->SetValue(width->GetValue());
1068  }
1069  siWidth->SetRange(0, width->GetValue());
1070 }
1071 
1072 
1073 /**
1074  * Disables and enables Edit and Delete buttons under the register
1075  * file guard list.
1076  *
1077  * If a guard is selected, buttons are enabled. If no guard is
1078  * selected the buttons will be disabled.
1079  */
1080 void
1082  if (fuGuardList_->GetSelectedItemCount() != 1) {
1083  FindWindow(ID_DELETE_FU_GUARD)->Disable();
1084  FindWindow(ID_EDIT_FU_GUARD)->Disable();
1085  return;
1086  }
1087  FindWindow(ID_DELETE_FU_GUARD)->Enable();
1088  FindWindow(ID_EDIT_FU_GUARD)->Enable();
1089 }
1090 
1091 
1092 /**
1093  * Opens a pop-up menu when right mouse button was pressed on the
1094  * register file guard list.
1095  *
1096  * @param event Information about right mouse click event.
1097  */
1098 void
1099 BusDialog::onRFGuardRightClick(wxListEvent& event) {
1100 
1101  rfGuardList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
1102  wxLIST_STATE_SELECTED);
1103 
1104  wxMenu* contextMenu = new wxMenu();
1105 
1107  format button = prodeTexts->text(
1109  contextMenu->Append(
1110  ID_EDIT_RF_GUARD, WxConversion::toWxString(button.str()));
1111  button = prodeTexts->text(
1113  contextMenu->Append(
1114  ID_DELETE_RF_GUARD, WxConversion::toWxString(button.str()));
1115  rfGuardList_->PopupMenu(contextMenu, event.GetPoint());
1116 }
1117 
1118 
1119 /**
1120  * Handles left mouse button double clicks on the RFGuard list.
1121  */
1122 void
1124  wxCommandEvent dummy;
1125  onEditRFGuard(dummy);
1126 }
1127 
1128 
1129 /**
1130  * Opens a pop-up menu when right mouse button was pressed on the
1131  * FU guard list.
1132  *
1133  * @param event Information about right mouse click event.
1134  */
1135 void
1136 BusDialog::onFUGuardRightClick(wxListEvent& event) {
1137 
1138  fuGuardList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
1139  wxLIST_STATE_SELECTED);
1140 
1141  wxMenu* contextMenu = new wxMenu();
1142 
1144  format button = prodeTexts->text(
1146  contextMenu->Append(
1147  ID_EDIT_FU_GUARD, WxConversion::toWxString(button.str()));
1148  button = prodeTexts->text(
1150  contextMenu->Append(
1151  ID_DELETE_FU_GUARD, WxConversion::toWxString(button.str()));
1152  fuGuardList_->PopupMenu(contextMenu, event.GetPoint());
1153 }
1154 
1155 
1156 /**
1157  * Handles left mouse button double clicks on the FUGuard list.
1158  */
1159 void
1161  wxCommandEvent dummy;
1162  onEditFUGuard(dummy);
1163 }
1164 
1165 
1166 /**
1167  * Creates the dialog window contents.
1168  *
1169  * This method was generated with wxDesigner. Don't modify manually,
1170  * all chnages will be lost if the code is regenerated.
1171  *
1172  * @return Main sizer of the created contents.
1173  * @param parent The dialog window.
1174  * @param call_fit If true, fits the contents inside the dialog.
1175  * @param set_sizer If true, sets the main sizer as dialog contents.
1176  */
1177 wxSizer*
1178 BusDialog::createContents(wxWindow *parent, bool call_fit, bool set_sizer) {
1179 
1180  wxFlexGridSizer *item0 = new wxFlexGridSizer( 2, 0, 0 );
1181 
1182  wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );
1183 
1184  wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("Bus:") );
1185  wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
1186  busSizer_ = item2;
1187 
1188  wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
1189 
1190  wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_BUS_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1191  item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
1192 
1193  wxTextCtrl *item6 = new wxTextCtrl( parent, ID_BUS_NAME, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
1194  item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
1195 
1196  item2->Add( item4, 0, wxGROW|wxALL, 5 );
1197 
1198  wxBoxSizer *item7 = new wxBoxSizer( wxHORIZONTAL );
1199 
1200  wxStaticText *item8 = new wxStaticText( parent, ID_LABEL_BUS_WIDTH, wxT("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
1201  item7->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
1202 
1203  wxSpinCtrl *item9 = new wxSpinCtrl( parent, ID_BUS_WIDTH, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 1024, 1 );
1204  item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
1205 
1206  item2->Add( item7, 0, wxGROW|wxALL, 5 );
1207 
1208  item0->Add( item2, 0, wxGROW|wxALL, 5 );
1209  //item1->Add( item2, 0, wxGROW|wxALL, 5 );
1210 
1211  wxStaticBox *item11 = new wxStaticBox( parent, -1, wxT("Short Immediate:") );
1212  wxStaticBoxSizer *item10 = new wxStaticBoxSizer( item11, wxVERTICAL );
1213  siSizer_ = item10;
1214 
1215  wxBoxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
1216 
1217  wxStaticText *item13 = new wxStaticText( parent, ID_LABEL_SI_WIDTH, wxT("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
1218  item12->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
1219 
1220  wxSpinCtrl *item14 = new wxSpinCtrl( parent, ID_SI_WIDTH, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 1000, 0 );
1221  item12->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
1222 
1223  item10->Add( item12, 0, wxGROW|wxALL, 5 );
1224 
1225  wxString strs15[] =
1226  {
1227  wxT("Zero"),
1228  wxT("Sign")
1229  };
1230  wxRadioBox *item15 = new wxRadioBox( parent, ID_SI_EXTENSION, wxT("Extension"), wxDefaultPosition, wxDefaultSize, 2, strs15, 1, wxRA_SPECIFY_ROWS );
1231  item10->Add( item15, 0, wxALL, 5 );
1232 
1233  item0->Add( item10, 0, wxGROW|wxALL, 5 );
1234  //item1->Add( item10, 0, wxGROW|wxALL, 5 );
1235 
1236  wxCheckBox *item16 = new wxCheckBox( parent, ID_TRUE_GUARD, wxT("Always true guard"), wxDefaultPosition, wxDefaultSize, 0 );
1237  item1->Add( item16, 0, wxALL, 5 );
1238 
1239  wxCheckBox *item17 = new wxCheckBox( parent, ID_FALSE_GUARD, wxT("Always false guard"), wxDefaultPosition, wxDefaultSize, 0 );
1240  item1->Add( item17, 0, wxALL, 5 );
1241 
1242  item0->Add( item1, 0, wxGROW|wxALL, 5 );
1243 
1244  wxStaticBox *item19 = new wxStaticBox( parent, -1, wxT("Segements:") );
1245  wxStaticBoxSizer *item18 = new wxStaticBoxSizer( item19, wxVERTICAL );
1246  segmentSizer_ = item18;
1247 
1248  wxListCtrl *item20 = new wxListCtrl( parent, ID_SEGMENT_LIST, wxDefaultPosition, wxSize(300,160), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
1249  item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
1250 
1251  wxBoxSizer *item21 = new wxBoxSizer( wxHORIZONTAL );
1252 
1253  wxStaticText *item22 = new wxStaticText( parent, ID_LABEL_SEGMENT_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1254  item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
1255 
1256  wxTextCtrl *item23 = new wxTextCtrl( parent, ID_SEGMENT_NAME, wxT(""), wxDefaultPosition, wxSize(100,-1), 0 );
1257  item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
1258 
1259  wxBoxSizer *item24 = new wxBoxSizer( wxHORIZONTAL );
1260 
1261  wxButton *item25 = new wxButton( parent, ID_SEGMENT_UP, wxT("Up"), wxDefaultPosition, wxSize(40,-1), 0 );
1262  item24->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
1263 
1264  wxButton *item26 = new wxButton( parent, ID_SEGMENT_DOWN, wxT("Down"), wxDefaultPosition, wxSize(50,-1), 0 );
1265  item24->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
1266 
1267  item21->Add( item24, 0, wxALL, 5 );
1268 
1269  item18->Add( item21, 0, wxGROW|wxALL, 5 );
1270 
1271  wxBoxSizer *item27 = new wxBoxSizer( wxHORIZONTAL );
1272 
1273  wxButton *item28 = new wxButton( parent, ID_ADD_SEGMENT, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
1274  item27->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
1275 
1276  item27->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
1277 
1278  wxButton *item29 = new wxButton( parent, ID_DELETE_SEGMENT, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1279  item27->Add( item29, 0, wxALIGN_CENTER|wxALL, 5 );
1280 
1281  item18->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
1282 
1283  item0->Add( item18, 0, wxALL, 5 );
1284 
1285  wxStaticBox *item31 = new wxStaticBox( parent, -1, wxT("Register File Guards:") );
1286  wxStaticBoxSizer *item30 = new wxStaticBoxSizer( item31, wxVERTICAL );
1287  registerGuardSizer_ = item30;
1288 
1289  wxListCtrl *item32 = new wxListCtrl( parent, ID_RF_GUARD_LIST, wxDefaultPosition, wxSize(300,120), wxLC_REPORT|wxSUNKEN_BORDER );
1290  item30->Add( item32, 0, wxALIGN_CENTER|wxALL, 5 );
1291 
1292  wxBoxSizer *item33 = new wxBoxSizer( wxHORIZONTAL );
1293 
1294  wxButton *item34 = new wxButton( parent, ID_ADD_RF_GUARD, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1295  item33->Add( item34, 0, wxALIGN_CENTER|wxALL, 5 );
1296 
1297  wxButton *item35 = new wxButton( parent, ID_EDIT_RF_GUARD, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1298  item35->Enable( false );
1299  item33->Add( item35, 0, wxALIGN_CENTER|wxALL, 5 );
1300 
1301  wxButton *item36 = new wxButton( parent, ID_DELETE_RF_GUARD, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1302  item36->Enable( false );
1303  item33->Add( item36, 0, wxALIGN_CENTER|wxALL, 5 );
1304 
1305  item30->Add( item33, 0, wxALIGN_CENTER|wxALL, 5 );
1306 
1307  item0->Add( item30, 0, wxGROW|wxALL, 5 );
1308 
1309  wxStaticBox *item38 = new wxStaticBox( parent, -1, wxT("Function Unit Guards") );
1310  wxStaticBoxSizer *item37 = new wxStaticBoxSizer( item38, wxVERTICAL );
1311  portGuardSizer_ = item37;
1312 
1313  wxListCtrl *item39 = new wxListCtrl( parent, ID_FU_GUARD_LIST, wxDefaultPosition, wxSize(300,120), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
1314  item37->Add( item39, 0, wxALIGN_CENTER|wxALL, 5 );
1315 
1316  wxBoxSizer *item40 = new wxBoxSizer( wxHORIZONTAL );
1317 
1318  wxButton *item41 = new wxButton( parent, ID_ADD_FU_GUARD, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1319  item40->Add( item41, 0, wxALIGN_CENTER|wxALL, 5 );
1320 
1321  wxButton *item42 = new wxButton( parent, ID_EDIT_FU_GUARD, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1322  item42->Enable( false );
1323  item40->Add( item42, 0, wxALIGN_CENTER|wxALL, 5 );
1324 
1325  wxButton *item43 = new wxButton( parent, ID_DELETE_FU_GUARD, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1326  item43->Enable( false );
1327  item40->Add( item43, 0, wxALIGN_CENTER|wxALL, 5 );
1328 
1329  item37->Add( item40, 0, wxALIGN_CENTER|wxALL, 5 );
1330 
1331  item0->Add( item37, 0, wxGROW|wxALL, 5 );
1332 
1333  wxButton *item44 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
1334  item0->Add( item44, 0, wxALL, 5 );
1335 
1336  wxBoxSizer *item45 = new wxBoxSizer( wxHORIZONTAL );
1337 
1338  wxButton *item46 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
1339  item45->Add( item46, 0, wxALIGN_CENTER|wxALL, 5 );
1340 
1341  wxButton *item47 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
1342  item45->Add( item47, 0, wxALIGN_CENTER|wxALL, 5 );
1343 
1344  item0->Add( item45, 0, wxALL, 5 );
1345 
1346  if (set_sizer)
1347  {
1348  parent->SetSizer( item0 );
1349  if (call_fit)
1350  item0->SetSizeHints( parent );
1351  }
1352 
1353  return item0;
1354 }
TTAMachine::Guard
Definition: Guard.hh:55
WarningDialog
Definition: WarningDialog.hh:42
ProDeTextGenerator::COMP_AN_IMM_SLOT
@ COMP_AN_IMM_SLOT
Name for imm. slot (w/ article).
Definition: ProDeTextGenerator.hh:283
WxConversion::toWxString
static wxString toWxString(const std::string &source)
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
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
TTAMachine::PortGuard::port
FUPort * port() const
DEFAULT_WIDTH
const int DEFAULT_WIDTH
Default window width.
Definition: GUIOptionsSerializer.cc:98
ListCompareFunction
int wxCALLBACK ListCompareFunction(long item1, long item2, long WXUNUSED(sortData))
Definition: BusDialog.cc:375
TTAMachine::RegisterGuard::registerIndex
int registerIndex() const
TTAMachine::BaseFUPort::parentUnit
FunctionUnit * parentUnit() const
Definition: BaseFUPort.cc:96
ProDeTextGenerator::COMP_A_SEGMENT
@ COMP_A_SEGMENT
Name for a segment component.
Definition: ProDeTextGenerator.hh:255
TTAMachine::Segment
Definition: Segment.hh:54
ProDeTextGenerator::TXT_COLUMN_INDEX
@ TXT_COLUMN_INDEX
Label for index column in a list.
Definition: ProDeTextGenerator.hh:113
BusDialog::onAddRFGuard
void onAddRFGuard(wxCommandEvent &)
Definition: BusDialog.cc:898
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
TTAMachine::Bus
Definition: Bus.hh:53
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
BusDialog::onOK
void onOK(wxCommandEvent &)
Definition: BusDialog.cc:797
BusDialog::updateGuardLists
void updateGuardLists()
Definition: BusDialog.cc:412
TTAMachine::Segment::destinationSegment
Segment * destinationSegment() const
ProDeTextGenerator::TXT_LABEL_TRUE_GUARD
@ TXT_LABEL_TRUE_GUARD
Label for 'always true guard'.
Definition: ProDeTextGenerator.hh:64
ProDeTextGenerator::TXT_BUS_DIALOG_TITLE
@ TXT_BUS_DIALOG_TITLE
Bus Dialog title.
Definition: ProDeTextGenerator.hh:148
ProDeTextGenerator::TXT_BUS_BUS_BOX
@ TXT_BUS_BUS_BOX
Bus Dialog bus box title.
Definition: ProDeTextGenerator.hh:149
GUITextGenerator
Definition: GUITextGenerator.hh:46
GUITextGenerator::TXT_BUTTON_HELP
@ TXT_BUTTON_HELP
Label for help button.
Definition: GUITextGenerator.hh:60
ModelConstants
Definition: ModelConstants.hh:40
WidgetTools.hh
FindWindow
Definition: FindWindow.hh:49
BusDialog::onSegmentSelection
void onSegmentSelection(wxListEvent &)
Definition: BusDialog.cc:693
TTAMachine::Machine::Navigator::count
int count() const
RFGuardDialog.hh
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
ProDeConstants::EXTENSION_SIGN
static const wxString EXTENSION_SIGN
String for the sign extension.
Definition: ProDeConstants.hh:65
BusDialog::onAddFUGuard
void onAddFUGuard(wxCommandEvent &)
Definition: BusDialog.cc:998
TTAMachine::Segment::moveAfter
void moveAfter(Segment &segment)
Definition: Segment.cc:357
ProDeTextGenerator.hh
BusDialog::onSegmentDown
void onSegmentDown(wxCommandEvent &)
Definition: BusDialog.cc:775
ProDeTextGenerator::MSG_ERROR_CANNOT_RF_GUARD
@ MSG_ERROR_CANNOT_RF_GUARD
Error: Register file guard.
Definition: ProDeTextGenerator.hh:226
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::UnconditionalGuard
Definition: Guard.hh:180
BusDialog::onEditFUGuard
void onEditFUGuard(wxCommandEvent &)
Definition: BusDialog.cc:1047
Segment.hh
ProDeTextGenerator::TXT_BUS_SI_BOX
@ TXT_BUS_SI_BOX
Short immediate box title.
Definition: ProDeTextGenerator.hh:151
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
ErrorDialog
Definition: ErrorDialog.hh:42
BusDialog::onSegmentRightClick
void onSegmentRightClick(wxListEvent &event)
Definition: BusDialog.cc:712
WarningDialog.hh
BusDialog::onDeleteRFGuard
void onDeleteRFGuard(wxCommandEvent &)
Definition: BusDialog.cc:922
ErrorDialog.hh
Conversion.hh
TTAMachine::RegisterGuard
Definition: Guard.hh:137
ProDeTextGenerator::TXT_RADIO_EXTENSION_ZERO
@ TXT_RADIO_EXTENSION_ZERO
Label for 'zero' radio button.
Definition: ProDeTextGenerator.hh:100
ProDeTextGenerator::TXT_COLUMN_PORT
@ TXT_COLUMN_PORT
Label for port column in a list.
Definition: ProDeTextGenerator.hh:114
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
FUGuardDialog.hh
ProDeTextGenerator::MSG_ERROR_BUS_IT_SLOT_WIDTH
@ MSG_ERROR_BUS_IT_SLOT_WIDTH
Error: Slot width > bus width.
Definition: ProDeTextGenerator.hh:233
ProDeTextGenerator::TXT_RADIO_EXTENSION_SIGN
@ TXT_RADIO_EXTENSION_SIGN
Label for 'sign' radio button.
Definition: ProDeTextGenerator.hh:101
GUITextGenerator::TXT_BUTTON_ADD
@ TXT_BUTTON_ADD
Label for an add button.
Definition: GUITextGenerator.hh:53
ProDeTextGenerator::TXT_LABEL_NAME
@ TXT_LABEL_NAME
Label for component name widget.
Definition: ProDeTextGenerator.hh:56
Guard.hh
ProDeTextGenerator::COMP_BUS
@ COMP_BUS
Name for bus component.
Definition: ProDeTextGenerator.hh:254
FUGuardDialog
Definition: FUGuardDialog.hh:47
BusDialog::onDeleteSegment
void onDeleteSegment(wxCommandEvent &)
Definition: BusDialog.cc:735
ModelConstants.hh
Machine.hh
Exception
Definition: Exception.hh:54
ProDeTextGenerator::COMP_SEGMENT
@ COMP_SEGMENT
Name for segment component.
Definition: ProDeTextGenerator.hh:256
BusDialog.hh
MachineTester::isValidComponentName
static bool isValidComponentName(const std::string &name)
Definition: MachineTester.cc:312
Bus.hh
ProDeConstants::EXTENSION_ZERO
static const wxString EXTENSION_ZERO
String for the zero extension.
Definition: ProDeConstants.hh:63
BusDialog::onFUGuardRightClick
void onFUGuardRightClick(wxListEvent &event)
Definition: BusDialog.cc:1136
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
BusDialog::onAddSegment
void onAddSegment(wxCommandEvent &)
Definition: BusDialog.cc:567
TTAMachine::Segment::hasSourceSegment
bool hasSourceSegment() const
Definition: Segment.cc:388
BusDialog::onWidth
void onWidth(wxSpinEvent &)
Definition: BusDialog.cc:1063
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
GUITextGenerator::TXT_BUTTON_DELETE
@ TXT_BUTTON_DELETE
Label for delete button.
Definition: GUITextGenerator.hh:56
ProDeConstants.hh
GUITextGenerator.hh
MachineTester.hh
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
ProDeTextGenerator::TXT_LABEL_EXTENSION
@ TXT_LABEL_EXTENSION
Label for 'extension' radiobox.
Definition: ProDeTextGenerator.hh:66
BusDialog::onBusName
void onBusName(wxCommandEvent &)
Definition: BusDialog.cc:617
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
BusDialog::onActivateFUGuard
void onActivateFUGuard(wxListEvent &event)
Definition: BusDialog.cc:1160
TTAMachine::Segment::sourceSegment
Segment * sourceSegment() const
TTAMachine::Segment::hasDestinationSegment
bool hasDestinationSegment() const
Definition: Segment.cc:399
BusDialog::setTexts
void setTexts()
Definition: BusDialog.cc:192
ProDeTextGenerator::MSG_ERROR
@ MSG_ERROR
Text 'Error' and new line.
Definition: ProDeTextGenerator.hh:222
BusDialog::onUnconditionalGuard
void onUnconditionalGuard(wxCommandEvent &)
Definition: BusDialog.cc:635
BusDialog::~BusDialog
virtual ~BusDialog()
Definition: BusDialog.cc:184
GUITextGenerator::TXT_BUTTON_ADD_DIALOG
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
Definition: GUITextGenerator.hh:54
ProDeTextGenerator::COMP_A_BUS
@ COMP_A_BUS
Name for a bus component.
Definition: ProDeTextGenerator.hh:253
TTAMachine::Guard::isInverted
virtual bool isInverted() const
BusDialog::onActivateRFGuard
void onActivateRFGuard(wxListEvent &event)
Definition: BusDialog.cc:1123
BusDialog::onDeleteFUGuard
void onDeleteFUGuard(wxCommandEvent &)
Definition: BusDialog.cc:1032
GUITextGenerator::TXT_BUTTON_EDIT_DIALOG
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
Definition: GUITextGenerator.hh:58
ProDeTextGenerator::TXT_BUS_SEGMENTS_BOX
@ TXT_BUS_SEGMENTS_BOX
Segments box title.
Definition: ProDeTextGenerator.hh:150
ProDeTextGenerator::TXT_BUTTON_DOWN
@ TXT_BUTTON_DOWN
Label for down button.
Definition: ProDeTextGenerator.hh:135
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
FUPort.hh
BusDialog::selectedRFGuard
TTAMachine::RegisterGuard * selectedRFGuard() const
Definition: BusDialog.cc:543
BusDialog::selectedSegment
TTAMachine::Segment * selectedSegment() const
Definition: BusDialog.cc:501
BusDialog
Definition: BusDialog.hh:54
TTAMachine::Segment::moveBefore
void moveBefore(Segment &segment)
Definition: Segment.cc:320
ProDeTextGenerator::MSG_ERROR_CANNOT_FU_GUARD
@ MSG_ERROR_CANNOT_FU_GUARD
Error: Function unit port guard.
Definition: ProDeTextGenerator.hh:227
ProDeTextGenerator::COMP_MACHINE
@ COMP_MACHINE
Text for machine description.
Definition: ProDeTextGenerator.hh:252
WxConversion.hh
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::PortGuard
Definition: Guard.hh:99
ProDeTextGenerator::TXT_COLUMN_INVERTED
@ TXT_COLUMN_INVERTED
Label for inv column in a list.
Definition: ProDeTextGenerator.hh:112
WidgetTools::setWidgetLabel
static void setWidgetLabel(wxWindow *widget, std::string text)
Definition: WidgetTools.cc:52
InformationDialog
Definition: InformationDialog.hh:42
BusDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: BusDialog.cc:337
BusDialog::onFUGuardSelection
void onFUGuardSelection(wxListEvent &)
Definition: BusDialog.cc:1081
BusDialog::selectedFUGuard
TTAMachine::PortGuard * selectedFUGuard() const
Definition: BusDialog.cc:522
ProDeTextGenerator::TXT_BUS_REGISTER_GUARD_BOX
@ TXT_BUS_REGISTER_GUARD_BOX
Register file guards box title.
Definition: ProDeTextGenerator.hh:152
TTAMachine::Segment::name
std::string name() const
TTAMachine
Definition: Assembler.hh:48
ProDeTextGenerator::TXT_LABEL_WIDTH
@ TXT_LABEL_WIDTH
Label for bit width widget.
Definition: ProDeTextGenerator.hh:57
WxConversion::toString
static std::string toString(const wxString &source)
BusDialog::onSegmentUp
void onSegmentUp(wxCommandEvent &)
Definition: BusDialog.cc:752
TTAMachine::RegisterGuard::registerFile
const RegisterFile * registerFile() const
BusDialog::onSegmentName
void onSegmentName(wxCommandEvent &)
Definition: BusDialog.cc:676
RFGuardDialog
Definition: RFGuardDialog.hh:46
BusDialog::updateSegmentList
void updateSegmentList()
Definition: BusDialog.cc:486
BusDialog::onEditRFGuard
void onEditRFGuard(wxCommandEvent &)
Definition: BusDialog.cc:958
ProDeTextGenerator::TXT_COLUMN_NAME
@ TXT_COLUMN_NAME
Label for name column in a list.
Definition: ProDeTextGenerator.hh:105
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
UserManualCmd.hh
BusDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: BusDialog.cc:1178
ProDeTextGenerator::TXT_BUS_PORT_GUARD_BOX
@ TXT_BUS_PORT_GUARD_BOX
Function unit guards box title.
Definition: ProDeTextGenerator.hh:153
BusDialog::onRFGuardRightClick
void onRFGuardRightClick(wxListEvent &event)
Definition: BusDialog.cc:1099
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
ProDeTextGenerator::TXT_LABEL_FALSE_GUARD
@ TXT_LABEL_FALSE_GUARD
Label for 'always false guard'.
Definition: ProDeTextGenerator.hh:65
BusDialog::onRFGuardSelection
void onRFGuardSelection(wxListEvent &)
Definition: BusDialog.cc:978
ProDeTextGenerator::TXT_BUTTON_UP
@ TXT_BUTTON_UP
Label for up button.
Definition: ProDeTextGenerator.hh:134
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59