OpenASIP  2.0
SimulateDialog.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 SimulateDialog.cc
26  *
27  * Definition of SimulateDialog class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/valgen.h>
34 #include <boost/format.hpp>
35 
36 #include "SimulateDialog.hh"
37 #include "SequenceTools.hh"
38 #include "OSEdTextGenerator.hh"
39 #include "GUITextGenerator.hh"
40 #include "WidgetTools.hh"
41 #include "WxConversion.hh"
42 #include "OSEdConstants.hh"
43 #include "Conversion.hh"
44 #include "OperationSimulator.hh"
45 #include "ErrorDialog.hh"
46 #include "DialogPosition.hh"
47 #include "SimulationInfoDialog.hh"
48 #include "Operation.hh"
49 #include "DataObject.hh"
50 #include "OperationContext.hh"
51 #include "NumberControl.hh"
52 #include "SimValue.hh"
53 #include "ContainerTools.hh"
54 #include "OSEdMainFrame.hh"
55 #include "Memory.hh"
56 #include "OperationContainer.hh"
57 #include "OSEd.hh"
58 #include "OSEdInformer.hh"
59 #include "TCEString.hh"
61 
62 using boost::format;
63 using std::string;
64 using std::vector;
65 
66 const string SimulateDialog::FORMAT_SIGNED_INT = "signed int";
67 const string SimulateDialog::FORMAT_UNSIGNED_INT = "unsigned int";
68 const string SimulateDialog::FORMAT_DOUBLE = "double";
69 const string SimulateDialog::FORMAT_FLOAT = "float";
70 const string SimulateDialog::FORMAT_BINARY = "binary";
71 const string SimulateDialog::FORMAT_HEXA_DECIMAL = "hexadecimal";
72 
73 BEGIN_EVENT_TABLE(SimulateDialog, wxDialog)
76 
77  EVT_BUTTON(ID_BUTTON_UPDATE, SimulateDialog::onUpdateValue)
78  EVT_BUTTON(ID_BUTTON_TRIGGER, SimulateDialog::onTrigger)
79  EVT_BUTTON(ID_BUTTON_ADVANCE_LOCK, SimulateDialog::onAdvanceClock)
80  EVT_BUTTON(ID_BUTTON_RESET, SimulateDialog::onReset)
81  EVT_BUTTON(ID_BUTTON_SHOW_HIDE_REGISTERS, SimulateDialog::showOrHideRegisters)
83 
84  EVT_CHOICE(ID_FORMAT, SimulateDialog::onFormatChanged)
85 
86  EVT_CLOSE(SimulateDialog::onClose)
88 
89 
90 const wxString SimulateDialog::DIALOG_NAME = _T("SimulateDialog");
91 
92 /**
93  * Constructor.
94  *
95  * @param parent Parent window.
96  * @param operation Operation to be simulated.
97  */
99  wxWindow* parent,
100  Operation* operation,
101  const std::string& pathName,
102  const std::string& modName) :
103  wxDialog(parent, -1, _T(""),
104  DialogPosition::getPosition(DialogPosition::DIALOG_SIMULATE),
105  wxDefaultSize, wxRESIZE_BORDER, DIALOG_NAME),
106  operation_(operation), pathName_(pathName), modName_(modName), clock_(0) {
107 
108  createContents(this, true, true);
109 
110  for (int i = 0; i < operation_->numberOfInputs(); i++) {
111  inputs_.push_back(new DataObject());
112  inputs_[i]->setString("0");
113  }
114 
115  for (int i = 0; i < operation_->numberOfOutputs(); i++) {
116  outputs_.push_back(new DataObject());
117  outputs_[i]->setString("0");
118  }
119 
120  inputList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_INPUT_LIST));
121  outputList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_OUTPUT_LIST));
122  updateValue_ = dynamic_cast<NumberControl*>(FindWindow(ID_VALUE));
123  format_ = dynamic_cast<wxChoice*>(FindWindow(ID_FORMAT));
124  //triggerBM_ = dynamic_cast<wxStaticBitmap*>(FindWindow(ID_BITMAP_READY));
125 
126  //lateResultBM_ =
127  // dynamic_cast<wxStaticBitmap*>(FindWindow(ID_BITMAP_UPDATE));
128 
129  FindWindow(wxID_OK)->SetFocus();
130 
131  format_->Append(WxConversion::toWxString(FORMAT_SIGNED_INT));
132  format_->Append(WxConversion::toWxString(FORMAT_UNSIGNED_INT));
133  format_->Append(WxConversion::toWxString(FORMAT_DOUBLE));
134  format_->Append(WxConversion::toWxString(FORMAT_FLOAT));
135  format_->Append(WxConversion::toWxString(FORMAT_BINARY));
136  format_->Append(WxConversion::toWxString(FORMAT_HEXA_DECIMAL));
137 
138  format_->SetSelection(0);
139 
140  setTexts();
141 
142  infoDialog_ = new SimulationInfoDialog(
144  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
145  informer->registerListener(OSEdInformer::EVENT_REGISTER, infoDialog_);
146  informer->registerListener(OSEdInformer::EVENT_RESET, infoDialog_);
147 
148  /* Ensure we won't refresh the behavior from the plugin file again
149  during the simulation. This leads to crashes due to using a state
150  instance created by a behavior definition created by a previously
151  loaded behavior instance. This effectively "freezes" the behavior
152  to the one loaded in the next behavior function call. */
153  behaviorProxy_ =
154  dynamic_cast<OperationBehaviorProxy*>(&operation->behavior());
155  assert(behaviorProxy_ != NULL);
156  behaviorProxy_->setAlwaysReloadBehavior(false);
157 }
158 
159 /**
160  * Destructor.
161  */
163 
166 
167  int x, y;
168  GetPosition(&x, &y);
169  wxPoint point(x, y);
171 
172  /* Ensure we won't use the old state object the next time because
173  the behavior will be reloaded from the dynlib. It would crash. */
174  OperationBehavior& behavior = operation_->behavior();
176 
177  /* "Unfreeze" the OperationBehavior. Now it will be reloaded always
178  when accessing the methods to enable the dynamic menu items in
179  the operation list. */
182 
183 }
184 
185 /**
186  * Transfers data to window.
187  */
188 bool
190  updateLists();
191  return wxWindow::TransferDataToWindow();
192 }
193 
194 /**
195  * Set texts to widgets.
196  */
197 void
199 
202 
203  // title
204  format fmt = osedText.text(OSEdTextGenerator::TXT_SIMULATE_DIALOG_TITLE);
205  fmt % operation_->name();
206  SetTitle(WxConversion::toWxString(fmt.str()));
207 
208  // static texts
209  //WidgetTools::setLabel(&osedText, FindWindow(ID_TEXT_READY),
210  // OSEdTextGenerator::TXT_LABEL_READY);
211 
212  //WidgetTools::setLabel(&osedText, FindWindow(ID_TEXT_UPDATE),
213  // OSEdTextGenerator::TXT_LABEL_UPDATE);
214 
217 
220 
221  // buttons
222  WidgetTools::setLabel(&guiText, FindWindow(wxID_OK),
224 
227 
230 
233 
236 
239 
240  // column titles
242  inputList_->InsertColumn(
243  0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
245 
246  outputList_->InsertColumn(
247  0, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
249 
251  inputList_->InsertColumn(
252  1, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
254 
255  outputList_->InsertColumn(
256  1, WxConversion::toWxString(fmt.str()), wxLIST_FORMAT_LEFT,
258 
259  // box sizers
262 
265 }
266 
267 /**
268  * Updates input and output value lists.
269  */
270 void
272 
273  inputList_->DeleteAllItems();
274  outputList_->DeleteAllItems();
275  for (unsigned int i = 0; i < inputs_.size(); i++) {
276  wxString id = WxConversion::toWxString(i + 1);
277  inputList_->InsertItem(i, id);
278  inputList_->SetItem(
279  i, 1, WxConversion::toWxString(inputs_[i]->stringValue()));
280  }
281 
282  int k = inputs_.size() + 1;
283  for (unsigned int i = 0; i < outputs_.size(); i++) {
284  wxString id = WxConversion::toWxString(k);
285  outputList_->InsertItem(i, id);
286  outputList_->SetItem(
287  i, 1, WxConversion::toWxString(outputs_[i]->stringValue()));
288  k++;
289  }
290 
291  wxListEvent dummy;
293 }
294 
295 /**
296  * Handles the event when a value is selected or deselected on input list.
297  */
298 void
300  if (inputList_->GetSelectedItemCount() != 1) {
301  FindWindow(ID_BUTTON_UPDATE)->Disable();
302  } else {
303  FindWindow(ID_BUTTON_UPDATE)->Enable();
304  }
305 }
306 
307 /**
308  * Handles the event when input value is updated.
309  */
310 void
312  TransferDataFromWindow();
313  string inputString = WidgetTools::lcStringSelection(inputList_, 0);
314  if (inputString != "") {
315  int input = Conversion::toInt(inputString);
316  SimValue* temp = new SimValue(32);
318  double value = updateValue_->doubleValue();
319  *temp = value;
320  } else {
321  int value = updateValue_->intValue();
322  *temp = value;
323  }
324  inputs_[input - 1]->setString(formattedValue(temp));
325  delete temp;
326  updateLists();
327  }
328 }
329 
330 /**
331  * Handles the event when Reset button is pushed.
332  *
333  * Reset sets all values to their defaults.
334  */
335 void
336 SimulateDialog::onReset(wxCommandEvent&) {
337 
338  OperationBehavior& behavior = operation_->behavior();
340 
341  for (size_t i = 0; i < inputs_.size(); i++) {
342  inputs_[i]->setString("0");
343  }
344 
345  for (size_t i = 0; i < outputs_.size(); i++) {
346  outputs_[i]->setString("0");
347  }
348 
349  //triggerBM_->SetBitmap(createBitmap(2));
350  //lateResultBM_->SetBitmap(createBitmap(2));
351  clock_ = 0;
353  SetLabel(WxConversion::toWxString(clock_));
354  updateLists();
355  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
357 }
358 
359 /**
360  * Handles the event when Trigger button is pushed.
361  */
362 void
363 SimulateDialog::onTrigger(wxCommandEvent&) {
364 
366  vector<SimValue*> outputs;
367  vector<DataObject> inputs;
368  for (size_t i = 0; i < inputs_.size(); i++) {
369  inputs.push_back(*inputs_[i]);
370  }
371 
372  string result = "";
373 
374  createState();
376  if (simulator.simulateTrigger(
377  *operation_, inputs, outputs, context, result)) {
378 
379  //triggerBM_->SetBitmap(createBitmap(1));
380  setOutputValues(outputs);
381  updateLists();
382  } else {
383  //triggerBM_->SetBitmap(createBitmap(0));
384  if (result != "") {
385  ErrorDialog dialog(this, WxConversion::toWxString(result));
386  dialog.ShowModal();
387  }
388  }
390  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
393 }
394 
395 /**
396  * Handles the event when advance clock button is pushed.
397  */
398 void
400  createState();
403  clock_++;
405  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
407 }
408 
409 /**
410  * Handles the event when intput and output format is changed.
411  */
412 void
414 
415  vector<SimValue*> outputs;
416 
418  string result = "";
419 
420  for (size_t i = 0; i < inputs_.size(); i++) {
421  SimValue* sim = new SimValue(32);
422  string value = inputs_[i]->stringValue();
423  simulator.initializeSimValue(value, sim, result);
424  outputs.push_back(sim);
425  }
426 
427  for (size_t i = 0; i < outputs_.size(); i++) {
428  SimValue* sim = new SimValue(32);
429  string value = outputs_[i]->stringValue();
430  simulator.initializeSimValue(value, sim, result);
431  outputs.push_back(sim);
432  }
433 
434  setInputValues(outputs);
435  setOutputValues(outputs);
436  updateLists();
438  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
440 }
441 
442 /**
443  * Handles the event when registers are shown or hidden.
444  */
445 void
447  wxButton* button =
448  dynamic_cast<wxButton*>(FindWindow(ID_BUTTON_SHOW_HIDE_REGISTERS));
451  if (button->GetLabel() == WxConversion::toWxString(fmt.str())) {
452  int x, y;
453  GetPosition(&x, &y);
454  int width, height;
455  GetSize(&width, &height);
456  y += height + 25;
457  infoDialog_->Move(x, y);
458  infoDialog_->Show(true);
460  button->SetLabel(WxConversion::toWxString(fmt.str()));
461  } else {
462  infoDialog_->Show(false);
463  button->SetLabel(WxConversion::toWxString(fmt.str()));
464  }
465 }
466 
467 /**
468  * Handles the event when OK button is pushed.
469  */
470 void
471 SimulateDialog::onOK(wxCommandEvent&) {
472  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
475  infoDialog_->Destroy();
476  Destroy();
477 }
478 
479 /**
480  * Handles the event when window is closed.
481  *
482  * @param event Event to be handled.
483  */
484 void
485 SimulateDialog::onClose(wxCloseEvent& event){
486  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
489  infoDialog_->Destroy();
490  event.Skip();
491 }
492 
493 /**
494  * Sets the input values after the format has changed.
495  *
496  * @param inputs Input values of operation.
497  */
498 void
499 SimulateDialog::setInputValues(std::vector<SimValue*> inputs) {
500 
501  string inputFormat = WxConversion::toString(format_->GetStringSelection());
502 
503  for (size_t i = 0; i < inputs_.size(); i++) {
504  SimValue* current = inputs[i];
505  inputs_[i]->setString(formattedValue(current));
506  }
507 }
508 
509 /**
510  * Sets the output values of the operation after executing a command.
511  *
512  * @param outputs Output values of operation.
513  */
514 void
515 SimulateDialog::setOutputValues(std::vector<SimValue*> outputs) {
516 
517  int k = 0;
518  size_t upperBound = inputs_.size() + outputs_.size();
519  for (size_t i = inputs_.size(); i < upperBound; i++) {
520  SimValue* current = outputs[i];
521  outputs_[k]->setString(formattedValue(current));
522  k++;
523  }
524 }
525 
526 /**
527  * Formats the value of the SimValue.
528  *
529  * @param value Value to be formatted.
530  */
531 string
533 
534  string format = WxConversion::toString(format_->GetStringSelection());
535  if (format == FORMAT_SIGNED_INT) {
536  SIntWord intSigned = value->sIntWordValue();
537  return Conversion::toString(static_cast<int>(intSigned));
538  } else if (format == FORMAT_UNSIGNED_INT) {
539  UIntWord intUnsigned = value->uIntWordValue();
540  return Conversion::toString(intUnsigned);
541  } else if (format == FORMAT_DOUBLE) {
542  DoubleWord doubleWord = value->doubleWordValue();
543  return Conversion::toString(doubleWord);
544  } else if (format == FORMAT_FLOAT) {
545  FloatWord floatWord = value->floatWordValue();
546  string floatString = Conversion::toString(floatWord);
547  if (floatString.find(".") == string::npos) {
548  floatString += ".0";
549  }
550  floatString += "f";
551  return floatString;
552  } else if (format == FORMAT_BINARY) {
553  UIntWord binary = value->uIntWordValue();
554  return Conversion::toBinString(static_cast<int>(binary));
555  } else if (format == FORMAT_HEXA_DECIMAL) {
556  UIntWord hex = value->uIntWordValue();
557  return Conversion::toHexString(hex);
558  }
559  return "";
560 }
561 
562 /**
563  * Creates the state for the operation.
564  */
565 void
569 }
570 
571 /**
572  * Creates the contents of the dialog.
573  *
574  * NOTE! This function was generated by wxDesigner.
575  *
576  * @param parent Parent window.
577  * @param call_fit If true fits the contenst inside the dialog.
578  * @param set_sizer If true sets the main sizer as dialog contents.
579  * @return The created sizer.
580  */
581 wxSizer*
583  wxWindow *parent,
584  bool call_fit,
585  bool set_sizer ) {
586 
587  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
588 
589  wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
590 
591  wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("Input values") );
592  wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
593  inputSizer_ = item2;
594 
595  wxListCtrl *item4 = new wxListCtrl( parent, ID_INPUT_LIST, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER );
596  item2->Add( item4, 1, wxGROW|wxALL, 5 );
597 
598  wxBoxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
599 
600  NumberControl *item6 = new NumberControl(
601  parent, ID_VALUE, wxDefaultPosition, wxSize(200, -1),
605 
606  item5->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
607 
608  wxButton *item7 = new wxButton( parent, ID_BUTTON_UPDATE, wxT("Update"), wxDefaultPosition, wxDefaultSize, 0 );
609  item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
610 
611  item2->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
612 
613  item1->Add( item2, 1, wxGROW|wxALL, 5 );
614 
615  wxStaticBox *item9 = new wxStaticBox( parent, -1, wxT("Output values") );
616  wxStaticBoxSizer *item8 = new wxStaticBoxSizer( item9, wxVERTICAL );
617  outputSizer_ = item8;
618 
619  wxListCtrl *item10 = new wxListCtrl( parent, ID_OUTPUT_LIST, wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
620  item8->Add( item10, 1, wxGROW|wxALL, 5 );
621 
622  item1->Add( item8, 1, wxGROW|wxALL, 5 );
623 
624  wxGridSizer *item11 = new wxGridSizer( 2, 0, 0 );
625 
626  //wxStaticText *item12 = new wxStaticText( parent, ID_TEXT_READY, wxT("Ready"), wxDefaultPosition, wxDefaultSize, 0 );
627  //item11->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
628 
629  //wxStaticBitmap *item13 = new wxStaticBitmap( parent, ID_BITMAP_READY, createBitmap( 2 ), wxDefaultPosition, wxDefaultSize );
630  //item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
631 
632  //wxStaticText *item14 = new wxStaticText( parent, ID_TEXT_UPDATE, wxT("Update"), wxDefaultPosition, wxDefaultSize, 0 );
633  //item11->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
634 
635  //wxStaticBitmap *item15 = new wxStaticBitmap( parent, ID_BITMAP_UPDATE, createBitmap( 2 ), wxDefaultPosition, wxDefaultSize );
636  //item11->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
637 
638  wxStaticText *item16 = new wxStaticText( parent, ID_TEXT_CLOCK, wxT("Clock count:"), wxDefaultPosition, wxDefaultSize, 0 );
639  item11->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
640 
641  wxStaticText *item17 = new wxStaticText( parent, ID_TEXT_CLOCK_VALUE, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 );
642  item11->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
643 
644  item1->Add( item11, 0, wxGROW|wxALL, 5 );
645 
646  item0->Add( item1, 1, wxGROW|wxALL, 5 );
647 
648  wxBoxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );
649 
650  wxStaticText *item19 = new wxStaticText( parent, ID_FORMAT_TEXT, wxT("Format:"), wxDefaultPosition, wxDefaultSize, 0 );
651  item18->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
652 
653  wxString *strs20 = (wxString*) NULL;
654  wxChoice *item20 = new wxChoice( parent, ID_FORMAT, wxDefaultPosition, wxSize(130,-1), 0, strs20, 0 );
655  item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
656 
657  item0->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
658 
659  wxBoxSizer *item21 = new wxBoxSizer( wxHORIZONTAL );
660 
661  wxButton *item22 = new wxButton( parent, ID_BUTTON_RESET, wxT("Reset"), wxDefaultPosition, wxDefaultSize, 0 );
662  item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
663 
664  wxButton *item23 = new wxButton( parent, ID_BUTTON_TRIGGER, wxT("Trigger"), wxDefaultPosition, wxDefaultSize, 0 );
665  item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
666 
667  wxButton *item25 = new wxButton( parent, ID_BUTTON_ADVANCE_LOCK, wxT("Advance Clock"), wxDefaultPosition, wxDefaultSize, 0 );
668  item21->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
669 
670  wxButton *item26 = new wxButton( parent, ID_BUTTON_SHOW_HIDE_REGISTERS, wxT("Show registers"), wxDefaultPosition, wxDefaultSize, 0 );
671  item21->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
672 
673  wxButton *item27 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
674  item21->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
675 
676  item0->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
677 
678  if (set_sizer)
679  {
680  parent->SetSizer( item0 );
681  if (call_fit)
682  item0->SetSizeHints( parent );
683  }
684 
685  return item0;
686 
687 }
688 
689 /**
690  *
691  */
692 wxBitmap
693 SimulateDialog::createBitmap(unsigned int index) {
694 
695  if (index == 0)
696  {
697  /* XPM */
698  static const char *xpm_data[] = {
699  /* columns rows colors chars-per-pixel */
700  "16 15 2 1",
701  " c None",
702  "a c #FF0000",
703  /* pixels */
704  " ",
705  " aaaaaaaaaaaaaa ",
706  " aaaaaaaaaaaaaa ",
707  " aaaaaaaaaaaaaa ",
708  " aaaaaaaaaaaaaa ",
709  " aaaaaaaaaaaaaa ",
710  " aaaaaaaaaaaaaa ",
711  " aaaaaaaaaaaaaa ",
712  " aaaaaaaaaaaaaa ",
713  " aaaaaaaaaaaaaa ",
714  " aaaaaaaaaaaaaa ",
715  " aaaaaaaaaaaaaa ",
716  " aaaaaaaaaaaaaa ",
717  " aaaaaaaaaaaaaa ",
718  " "
719  };
720  wxBitmap bitmap( xpm_data );
721  return bitmap;
722  }
723  if (index == 1)
724  {
725  /* XPM */
726  static const char *xpm_data[] = {
727  /* columns rows colors chars-per-pixel */
728  "16 15 2 1",
729  " c None",
730  "b c #00FF00",
731  /* pixels */
732  " ",
733  " bbbbbbbbbbbbbb ",
734  " bbbbbbbbbbbbbb ",
735  " bbbbbbbbbbbbbb ",
736  " bbbbbbbbbbbbbb ",
737  " bbbbbbbbbbbbbb ",
738  " bbbbbbbbbbbbbb ",
739  " bbbbbbbbbbbbbb ",
740  " bbbbbbbbbbbbbb ",
741  " bbbbbbbbbbbbbb ",
742  " bbbbbbbbbbbbbb ",
743  " bbbbbbbbbbbbbb ",
744  " bbbbbbbbbbbbbb ",
745  " bbbbbbbbbbbbbb ",
746  " "
747  };
748  wxBitmap bitmap( xpm_data );
749  return bitmap;
750  }
751  if (index == 2)
752  {
753  /* XPM */
754  static const char *xpm_data[] = {
755  /* columns rows colors chars-per-pixel */
756  "16 15 2 1",
757  " c None",
758  "a c Black",
759  /* pixels */
760  " ",
761  " aaaaaaaaaaaaaa ",
762  " aaaaaaaaaaaaaa ",
763  " aaaaaaaaaaaaaa ",
764  " aaaaaaaaaaaaaa ",
765  " aaaaaaaaaaaaaa ",
766  " aaaaaaaaaaaaaa ",
767  " aaaaaaaaaaaaaa ",
768  " aaaaaaaaaaaaaa ",
769  " aaaaaaaaaaaaaa ",
770  " aaaaaaaaaaaaaa ",
771  " aaaaaaaaaaaaaa ",
772  " aaaaaaaaaaaaaa ",
773  " aaaaaaaaaaaaaa ",
774  " "
775  };
776  wxBitmap bitmap( xpm_data );
777  return bitmap;
778  }
779  return wxNullBitmap;
780 }
SimulateDialog::~SimulateDialog
virtual ~SimulateDialog()
Definition: SimulateDialog.cc:162
SimulateDialog::ID_BUTTON_ADVANCE_LOCK
@ ID_BUTTON_ADVANCE_LOCK
Definition: SimulateDialog.hh:123
SimulateDialog::ID_VALUE
@ ID_VALUE
Definition: SimulateDialog.hh:111
SimulateDialog::ID_OUTPUT_LIST
@ ID_OUTPUT_LIST
Definition: SimulateDialog.hh:113
SimulateDialog::onUpdateValue
void onUpdateValue(wxCommandEvent &event)
Definition: SimulateDialog.cc:311
OperationBehaviorProxy.hh
OSEdTextGenerator::TXT_BUTTON_SHOW_REGISTERS
@ TXT_BUTTON_SHOW_REGISTERS
Show registers button label.
Definition: OSEdTextGenerator.hh:82
OperationSimulator::initializeSimValue
bool initializeSimValue(std::string value, SimValue *sim, std::string &result)
Definition: OperationSimulator.cc:122
UIntWord
Word UIntWord
Definition: BaseType.hh:144
SimulateDialog::ID_FORMAT_TEXT
@ ID_FORMAT_TEXT
Definition: SimulateDialog.hh:125
SimulateDialog::infoDialog_
SimulationInfoDialog * infoDialog_
Dialog for showing additional information.
Definition: SimulateDialog.hh:158
OSEdConstants::DEFAULT_COLUMN_WIDTH
static const int DEFAULT_COLUMN_WIDTH
Default column width.
Definition: OSEdConstants.hh:113
SimulateDialog::ID_TEXT_CLOCK
@ ID_TEXT_CLOCK
Definition: SimulateDialog.hh:118
OSEdInformer::handleEvent
void handleEvent(EventId event)
Definition: OSEdInformer.cc:58
SimulateDialog::clock_
unsigned int clock_
Variable where the value of clock is kept.
Definition: SimulateDialog.hh:156
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdTextGenerator::TXT_LABEL_CLOCK
@ TXT_LABEL_CLOCK
Clock label.
Definition: OSEdTextGenerator.hh:60
SimulateDialog::ID_BUTTON_UPDATE
@ ID_BUTTON_UPDATE
Definition: SimulateDialog.hh:112
OperationSimulator
Definition: OperationSimulator.hh:48
SimulateDialog::updateValue_
NumberControl * updateValue_
Text control for updating input values.
Definition: SimulateDialog.hh:138
SimValue::doubleWordValue
DoubleWord doubleWordValue() const
Definition: SimValue.cc:1052
SimulateDialog::outputSizer_
wxStaticBoxSizer * outputSizer_
Output operand sizer.
Definition: SimulateDialog.hh:132
SimulateDialog::outputList_
wxListCtrl * outputList_
Output list.
Definition: SimulateDialog.hh:136
OperationContainer::operationContext
static OperationContext & operationContext()
Definition: OperationContainer.cc:124
OSEdTextGenerator::TXT_SIMULATE_DIALOG_TITLE
@ TXT_SIMULATE_DIALOG_TITLE
Simulate dialog title.
Definition: OSEdTextGenerator.hh:113
SimulateDialog::inputSizer_
wxStaticBoxSizer * inputSizer_
Input operand sizer.
Definition: SimulateDialog.hh:130
OSEdTextGenerator::TXT_BUTTON_TRIGGER
@ TXT_BUTTON_TRIGGER
Trigger button label.
Definition: OSEdTextGenerator.hh:72
DataObject
Definition: DataObject.hh:50
OperationBehaviorProxy::setAlwaysReloadBehavior
virtual void setAlwaysReloadBehavior(bool f)
Definition: OperationBehaviorProxy.hh:76
SimulateDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: SimulateDialog.cc:582
SimulationInfoDialog.hh
SimulateDialog
Definition: SimulateDialog.hh:53
Memory.hh
SimulateDialog.hh
OperationContext
Definition: OperationContext.hh:56
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
SequenceTools.hh
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
OSEdTextGenerator::TXT_LABEL_FORMAT
@ TXT_LABEL_FORMAT
Format label.
Definition: OSEdTextGenerator.hh:59
SimulateDialog::operation_
Operation * operation_
Bitmap for Trigger result.
Definition: SimulateDialog.hh:146
GUITextGenerator
Definition: GUITextGenerator.hh:46
SimulateDialog::FORMAT_FLOAT
static const std::string FORMAT_FLOAT
Float format.
Definition: SimulateDialog.hh:100
OSEdInformer::EVENT_REGISTER
@ EVENT_REGISTER
Event when register value might change.
Definition: OSEdInformer.hh:53
WidgetTools.hh
OSEd.hh
FindWindow
Definition: FindWindow.hh:49
SimulateDialog::ID_BUTTON_SHOW_HIDE_REGISTERS
@ ID_BUTTON_SHOW_HIDE_REGISTERS
Definition: SimulateDialog.hh:124
SimulateDialog::ID_TEXT_CLOCK_VALUE
@ ID_TEXT_CLOCK_VALUE
Definition: SimulateDialog.hh:119
OSEdTextGenerator::TXT_COLUMN_VALUE
@ TXT_COLUMN_VALUE
Value column header.
Definition: OSEdTextGenerator.hh:99
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
SimValue::uIntWordValue
UIntWord uIntWordValue() const
Definition: SimValue.cc:972
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
NumberControl::mode
long mode() const
Definition: NumberControl.cc:764
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
SimulateDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: SimulateDialog.cc:189
Conversion::toString
static std::string toString(const T &source)
SimulateDialog::onTrigger
void onTrigger(wxCommandEvent &event)
Definition: SimulateDialog.cc:363
OSEdConstants.hh
OperationBehavior::createState
virtual void createState(OperationContext &context) const
Definition: OperationBehavior.cc:127
SimValue
Definition: SimValue.hh:96
SimulateDialog::FORMAT_UNSIGNED_INT
static const std::string FORMAT_UNSIGNED_INT
Unsigned int format.
Definition: SimulateDialog.hh:96
TCEString.hh
SimulateDialog::onSelection
void onSelection(wxListEvent &event)
Definition: SimulateDialog.cc:299
assert
#define assert(condition)
Definition: Application.hh:86
OSEdInformer.hh
SimulateDialog::behaviorProxy_
OperationBehaviorProxy * behaviorProxy_
The behavior proxy that loads the behavior. Used to "freeze" the behavior loading for the duration of...
Definition: SimulateDialog.hh:161
OSEdInformer::EVENT_MEMORY
@ EVENT_MEMORY
Event when memory may be changed.
Definition: OSEdInformer.hh:55
SimulateDialog::updateLists
void updateLists()
Definition: SimulateDialog.cc:271
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
OSEdInformer::registerListener
void registerListener(EventId event, OSEdListener *listener)
Definition: OSEdInformer.cc:74
SimulateDialog::FORMAT_HEXA_DECIMAL
static const std::string FORMAT_HEXA_DECIMAL
Hexadecimal format.
Definition: SimulateDialog.hh:104
SimulateDialog::inputList_
wxListCtrl * inputList_
Input list.
Definition: SimulateDialog.hh:134
ErrorDialog
Definition: ErrorDialog.hh:42
OSEdTextGenerator::TXT_BUTTON_RESET
@ TXT_BUTTON_RESET
Reset button label.
Definition: OSEdTextGenerator.hh:80
NumberControl::intValue
int intValue() const
Definition: NumberControl.cc:417
NumberControl::doubleValue
double doubleValue() const
Definition: NumberControl.cc:450
NumberControl.hh
ErrorDialog.hh
OperationBehaviorProxy
Definition: OperationBehaviorProxy.hh:58
Conversion.hh
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
OSEdMainFrame.hh
SimulateDialog::setOutputValues
void setOutputValues(std::vector< SimValue * > outputs)
Definition: SimulateDialog.cc:515
FloatWord
float FloatWord
Definition: BaseType.hh:160
SimValue::floatWordValue
FloatWord floatWordValue() const
Definition: SimValue.cc:1075
WidgetTools::lcStringSelection
static std::string lcStringSelection(wxListCtrl *list, int column)
Definition: WidgetTools.cc:108
SimulateDialog::setInputValues
void setInputValues(std::vector< SimValue * > inputs)
Definition: SimulateDialog.cc:499
SimulateDialog::showOrHideRegisters
void showOrHideRegisters(wxCommandEvent &event)
Definition: SimulateDialog.cc:446
OSEdTextGenerator::TXT_BUTTON_UPDATE
@ TXT_BUTTON_UPDATE
Update button label.
Definition: OSEdTextGenerator.hh:84
OperationSimulator::simulateTrigger
bool simulateTrigger(Operation &op, std::vector< DataObject > inputs, std::vector< SimValue * > &outputs, OperationContext &context, std::string &result)
Definition: OperationSimulator.cc:83
SimulateDialog::ID_INPUT_LIST
@ ID_INPUT_LIST
Definition: SimulateDialog.hh:110
SIntWord
SignedWord SIntWord
Definition: BaseType.hh:149
Operation.hh
DialogPosition
Definition: DialogPosition.hh:42
SimulateDialog::ID_BUTTON_RESET
@ ID_BUTTON_RESET
Definition: SimulateDialog.hh:120
DoubleWord
double DoubleWord
Definition: BaseType.hh:166
OSEdTextGenerator::TXT_BUTTON_ADVANCE_LOCK
@ TXT_BUTTON_ADVANCE_LOCK
Advance Lock button label.
Definition: OSEdTextGenerator.hh:74
DataObject.hh
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
SimulateDialog::inputs_
std::vector< DataObject * > inputs_
List of input values.
Definition: SimulateDialog.hh:152
Operation
Definition: Operation.hh:59
NumberControl::MODE_INT
static const long MODE_INT
Style flag for signed integer mode availablity.
Definition: NumberControl.hh:96
DialogPosition::DIALOG_SIMULATE
@ DIALOG_SIMULATE
Simulation dialog.
Definition: DialogPosition.hh:49
Conversion::toHexString
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
GUITextGenerator.hh
SimulateDialog::outputs_
std::vector< DataObject * > outputs_
List of output values.
Definition: SimulateDialog.hh:154
SimulationInfoDialog
Definition: SimulationInfoDialog.hh:48
NumberControl::MODE_UNSIGNED
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
Definition: NumberControl.hh:98
OSEdInformer::EVENT_RESET
@ EVENT_RESET
Event when operation is reseted.
Definition: OSEdInformer.hh:54
SimValue::sIntWordValue
SIntWord sIntWordValue() const
Definition: SimValue.cc:944
OperationBehaviorProxy::uninitializeBehavior
void uninitializeBehavior() const
Definition: OperationBehaviorProxy.cc:244
OSEdTextGenerator::TXT_BOX_OUTPUT_VALUES
@ TXT_BOX_OUTPUT_VALUES
Output values sizer label.
Definition: OSEdTextGenerator.hh:129
NumberControl::MODE_HEXADECIMAL
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.
Definition: NumberControl.hh:100
Memory::advanceClock
virtual void advanceClock()
Definition: Memory.cc:819
OperationBehavior
Definition: OperationBehavior.hh:53
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
NumberControl::MODE_BINARY
static const long MODE_BINARY
Style flag for binary mode availability.
Definition: NumberControl.hh:94
SimulateDialog::setTexts
void setTexts()
Definition: SimulateDialog.cc:198
OperationBehavior::deleteState
virtual void deleteState(OperationContext &context) const
Definition: OperationBehavior.cc:141
SimulateDialog::onFormatChanged
void onFormatChanged(wxCommandEvent &event)
Definition: SimulateDialog.cc:413
SimValue.hh
SimulateDialog::createState
void createState()
Definition: SimulateDialog.cc:566
SimulateDialog::ID_BUTTON_TRIGGER
@ ID_BUTTON_TRIGGER
Definition: SimulateDialog.hh:121
Conversion::toBinString
static std::string toBinString(int source)
Definition: Conversion.cc:81
OSEdTextGenerator::TXT_BOX_INPUT_VALUES
@ TXT_BOX_INPUT_VALUES
Input values sizer label.
Definition: OSEdTextGenerator.hh:128
NumberControl
Definition: NumberControl.hh:59
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
SimulateDialog::onClose
void onClose(wxCloseEvent &)
Definition: SimulateDialog.cc:485
OSEdTextGenerator::TXT_COLUMN_OPERAND
@ TXT_COLUMN_OPERAND
Operand column header.
Definition: OSEdTextGenerator.hh:97
SimulateDialog::FORMAT_BINARY
static const std::string FORMAT_BINARY
Binary format.
Definition: SimulateDialog.hh:102
Operation::behavior
virtual OperationBehavior & behavior() const
Definition: Operation.cc:388
SimulateDialog::onAdvanceClock
void onAdvanceClock(wxCommandEvent &event)
Definition: SimulateDialog.cc:399
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OperationContainer::memory
static Memory & memory()
Definition: OperationContainer.cc:134
SimulateDialog::FORMAT_SIGNED_INT
static const std::string FORMAT_SIGNED_INT
Signed int format.
Definition: SimulateDialog.hh:94
WxConversion.hh
OSEdInformer::unregisterListener
void unregisterListener(EventId event, OSEdListener *listener)
Definition: OSEdInformer.cc:92
WidgetTools::setWidgetLabel
static void setWidgetLabel(wxWindow *widget, std::string text)
Definition: WidgetTools.cc:52
SimulateDialog::onOK
void onOK(wxCommandEvent &event)
Definition: SimulateDialog.cc:471
Conversion::toInt
static int toInt(const T &source)
OSEdInformer
Definition: OSEdInformer.hh:47
SimulateDialog::FORMAT_DOUBLE
static const std::string FORMAT_DOUBLE
Double format.
Definition: SimulateDialog.hh:98
WxConversion::toString
static std::string toString(const wxString &source)
NumberControl::MODE_FLOAT
static const long MODE_FLOAT
Style flag for float mode availability.
Definition: NumberControl.hh:102
SimulateDialog::ID_FORMAT
@ ID_FORMAT
Definition: SimulateDialog.hh:126
OSEdTextGenerator.hh
OperationContext::advanceClock
void advanceClock()
Definition: OperationContext.cc:108
SimulateDialog::createBitmap
wxBitmap createBitmap(unsigned int index)
Definition: SimulateDialog.cc:693
OSEdTextGenerator::TXT_BUTTON_HIDE_REGISTERS
@ TXT_BUTTON_HIDE_REGISTERS
Hide registers button label.
Definition: OSEdTextGenerator.hh:83
NumberControl::MODE_DOUBLE
static const long MODE_DOUBLE
Style flag for double mode availability.
Definition: NumberControl.hh:104
SimulateDialog::formattedValue
std::string formattedValue(SimValue *value)
Definition: SimulateDialog.cc:532
OperationContext.hh
OperationSimulator.hh
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
OperationSimulator::instance
static OperationSimulator & instance()
Definition: OperationSimulator.cc:65
SimulateDialog::onReset
void onReset(wxCommandEvent &event)
Definition: SimulateDialog.cc:336
SimulateDialog::format_
wxChoice * format_
Choice list of possible output formats.
Definition: SimulateDialog.hh:140
OperationContainer.hh
ContainerTools.hh
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59
DialogPosition.hh