OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
OperationDialog Class Reference

#include <OperationDialog.hh>

Inheritance diagram for OperationDialog:
Inheritance graph
Collaboration diagram for OperationDialog:
Collaboration graph

Public Member Functions

 OperationDialog (wxWindow *parent, TTAMachine::HWOperation *operation)
 
 ~OperationDialog ()
 

Private Types

enum  {
  ID_NAME = 10000, ID_LABEL_NAME, ID_BIND_LIST, ID_LABEL_PORT,
  ID_PORT, ID_LABEL_NUMBER, ID_ADD_OPERAND, ID_DELETE_OPERAND,
  ID_HELP, ID_LINE, ID_LABEL_OPERAND, ID_NUMBER,
  ID_RESOURCE_GRID, ID_OPERAND_GRID, ID_LABEL_RESOURCE_NAME, ID_RESOURCE_NAME,
  ID_ADD_RESOURCE, ID_DELETE_RESOURCE, ID_DELETE_RESOURCE_CYCLE, ID_MENU_FOO,
  ID_MENU_BAR, ID_LABEL_LATENCY, ID_LATENCY
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
bool TransferDataToWindow ()
 
void initialize ()
 
void setTexts ()
 
void updateOperandList ()
 
void updateResourceGrid ()
 
void updateUsageGrid ()
 
void updateLatency ()
 
void setOperandType (int operand, bool read)
 
void warnOnResourcesWithoutUsages ()
 
void onAddOperand (wxCommandEvent &event)
 
void onDeleteOperand (wxCommandEvent &event)
 
void onBindOperand (wxCommandEvent &event)
 
void onAddResource (wxCommandEvent &event)
 
void onDeleteResource (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
void onName (wxCommandEvent &event)
 
void onOperandSelection (wxListEvent &event)
 
void onResourceSelection (wxGridRangeSelectEvent &event)
 
void onResourceLClick (wxGridEvent &event)
 
void onOperandLClick (wxGridEvent &event)
 
void onGridLClick (wxGridEvent &event)
 
void onGridRClick (wxGridEvent &event)
 
std::string selectedResource ()
 
int operandRow (int operand)
 

Private Attributes

TTAMachine::HWOperationoperation_
 Operation to edit. More...
 
wxString name_
 Name of the operation. More...
 
wxString resourceName_
 Name of resource to be added. More...
 
wxListCtrl * bindList_
 Bind list widget. More...
 
wxSpinCtrl * numberControl_
 Spin button control for the bind operand. More...
 
wxGrid * resourceGrid_
 Resource list widget. More...
 
wxGrid * usageGrid_
 Operand usage grid widget. More...
 
wxChoice * portChoice_
 Choice widget for the port to bind. More...
 
wxStaticBoxSizer * resourceSizer_
 Static boxsizer for the resource grid widgets. More...
 
wxStaticBoxSizer * operandSizer_
 Static boxsizer for the operand list widgets. More...
 
wxStaticBoxSizer * usageSizer_
 Static boxsizer for the operand usage grid widgets. More...
 
std::list< std::string > newResources_
 List of unused resources. More...
 
std::set< int > operands_
 List of unused operands. More...
 
wxStaticText * latencyText_
 Static text control displaying the operation latency. More...
 

Static Private Attributes

static const int GRID_COLUMN_WIDTH = 25
 Width of the resource and operand usage grid columns. More...
 
static const wxString USE_MARK = _T("X")
 Grid marker for resource use. More...
 
static const wxString READ_MARK = _T("R")
 Grid marker for a read. More...
 
static const wxString WRITE_MARK = _T("W")
 Grid marker for a write. More...
 

Detailed Description

Dialog for editing HWOperation properties.

Definition at line 49 of file OperationDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_NAME 
ID_LABEL_NAME 
ID_BIND_LIST 
ID_LABEL_PORT 
ID_PORT 
ID_LABEL_NUMBER 
ID_ADD_OPERAND 
ID_DELETE_OPERAND 
ID_HELP 
ID_LINE 
ID_LABEL_OPERAND 
ID_NUMBER 
ID_RESOURCE_GRID 
ID_OPERAND_GRID 
ID_LABEL_RESOURCE_NAME 
ID_RESOURCE_NAME 
ID_ADD_RESOURCE 
ID_DELETE_RESOURCE 
ID_DELETE_RESOURCE_CYCLE 
ID_MENU_FOO 
ID_MENU_BAR 
ID_LABEL_LATENCY 
ID_LATENCY 

Definition at line 128 of file OperationDialog.hh.

128  {
129  ID_NAME = 10000,
131  ID_BIND_LIST,
133  ID_PORT,
137  ID_HELP,
138  ID_LINE,
140  ID_NUMBER,
148  ID_MENU_FOO,
149  ID_MENU_BAR,
151  ID_LATENCY
152  };

Constructor & Destructor Documentation

◆ OperationDialog()

OperationDialog::OperationDialog ( wxWindow *  parent,
TTAMachine::HWOperation operation 
)

The Constructor.

Parameters
parentParent window of the dialog.
operationOperation to modify.

Definition at line 100 of file OperationDialog.cc.

102  :
103  wxDialog(
104  parent, -1, _T(""), wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER),
105  operation_(operation),
106  name_(_T("")),
107  resourceName_(_T("")),
108  latencyText_(NULL) {
109 
110  createContents(this, true, true);
111  initialize();
112  setTexts();
113 }

◆ ~OperationDialog()

OperationDialog::~OperationDialog ( )

The Destructor.

Definition at line 120 of file OperationDialog.cc.

120  {
121 }

Member Function Documentation

◆ createContents()

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

Creates the dialog contents.

This function was generated by wxDesigner.

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

Definition at line 1093 of file OperationDialog.cc.

1094  {
1095 
1096  wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
1097  item0->AddGrowableCol( 0 );
1098  item0->AddGrowableRow( 0 );
1099 
1100  wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
1101  item1->AddGrowableCol( 1 );
1102  item1->AddGrowableRow( 0 );
1103 
1104  wxFlexGridSizer *item2 = new wxFlexGridSizer( 1, 0, 0 );
1105  item2->AddGrowableRow( 1 );
1106 
1107  wxBoxSizer *item3 = new wxBoxSizer( wxHORIZONTAL );
1108 
1109  wxStaticText *item4 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1110  item3->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
1111 
1112  wxTextCtrl *item5 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(160,-1), 0 );
1113  item3->Add( item5, 0, wxALIGN_CENTER, 5 );
1114 
1115  item2->Add( item3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1116 
1117  wxStaticBox *item7 = new wxStaticBox( parent, -1, wxT("Operands:") );
1118  wxStaticBoxSizer *item6 = new wxStaticBoxSizer( item7, wxHORIZONTAL );
1119  operandSizer_ = item6;
1120 
1121  wxFlexGridSizer *item8 = new wxFlexGridSizer( 1, 0, 0 );
1122  item8->AddGrowableRow( 0 );
1123 
1124  wxListCtrl *item9 = new wxListCtrl( parent, ID_BIND_LIST, wxDefaultPosition, wxSize(200,300), wxLC_REPORT|wxSUNKEN_BORDER );
1125  item8->Add( item9, 0, wxGROW|wxALL, 5 );
1126 
1127  wxBoxSizer *item10 = new wxBoxSizer( wxVERTICAL );
1128 
1129  wxBoxSizer *item11 = new wxBoxSizer( wxHORIZONTAL );
1130 
1131  wxStaticText *item12 = new wxStaticText( parent, ID_LABEL_PORT, wxT("Port:"), wxDefaultPosition, wxDefaultSize, 0 );
1132  item11->Add( item12, 0, wxALL, 5 );
1133 
1134  wxString *strs13 = (wxString*) NULL;
1135  wxChoice *item13 = new wxChoice( parent, ID_PORT, wxDefaultPosition, wxSize(100,-1), 0, strs13, 0 );
1136  item11->Add( item13, 0, wxGROW|wxALL, 5 );
1137 
1138  wxButton *item14 = new wxButton( parent, ID_DELETE_OPERAND, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1139  item11->Add( item14, 0, wxALL, 5 );
1140 
1141  item10->Add( item11, 0, wxGROW, 5 );
1142 
1143  wxStaticLine *item15 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
1144  item10->Add( item15, 0, wxGROW|wxALL, 5 );
1145 
1146  wxBoxSizer *item16 = new wxBoxSizer( wxHORIZONTAL );
1147 
1148  wxStaticText *item17 = new wxStaticText( parent, ID_LABEL_OPERAND, wxT("New operand:"), wxDefaultPosition, wxDefaultSize, 0 );
1149  item16->Add( item17, 0, wxALL, 5 );
1150 
1151  wxSpinCtrl *item18 = new wxSpinCtrl( parent, ID_NUMBER, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
1152  item16->Add( item18, 0, wxGROW|wxALL, 5 );
1153 
1154  wxButton *item19 = new wxButton( parent, ID_ADD_OPERAND, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
1155  item16->Add( item19, 0, wxALL, 5 );
1156 
1157  item10->Add( item16, 0, wxALIGN_CENTER, 5 );
1158 
1159  item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
1160 
1161  item6->Add( item8, 0, wxGROW, 5 );
1162 
1163  item2->Add( item6, 0, wxGROW, 5 );
1164 
1165  item1->Add( item2, 0, wxGROW|wxALL, 5 );
1166 
1167  wxFlexGridSizer *item20 = new wxFlexGridSizer( 1, 0, 0 );
1168  item20->AddGrowableCol( 0 );
1169  item20->AddGrowableRow( 0 );
1170  item20->AddGrowableRow( 1 );
1171 
1172  wxStaticBox *item22 = new wxStaticBox( parent, -1, wxT("Pipeline Resources:") );
1173  wxStaticBoxSizer *item21 = new wxStaticBoxSizer( item22, wxHORIZONTAL );
1174  resourceSizer_ = item21;
1175 
1176  wxFlexGridSizer *item23 = new wxFlexGridSizer( 1, 0, 0 );
1177  item23->AddGrowableCol( 0 );
1178  item23->AddGrowableRow( 0 );
1179 
1180  wxGrid *item24 = new wxGrid( parent, ID_RESOURCE_GRID, wxDefaultPosition, wxSize(400,200), wxWANTS_CHARS );
1181  item24->CreateGrid( 0, 0, wxGrid::wxGridSelectRows );
1182  item23->Add( item24, 0, wxGROW|wxALL, 5 );
1183 
1184  wxBoxSizer *item25 = new wxBoxSizer( wxHORIZONTAL );
1185 
1186  wxStaticText *item26 = new wxStaticText( parent, ID_LABEL_RESOURCE_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1187  item25->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
1188 
1189  wxTextCtrl *item27 = new wxTextCtrl( parent, ID_RESOURCE_NAME, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1190  item25->Add( item27, 1, wxALIGN_CENTER|wxALL, 5 );
1191 
1192  wxButton *item28 = new wxButton( parent, ID_ADD_RESOURCE, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
1193  item28->Enable( false );
1194  item25->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
1195 
1196  wxButton *item29 = new wxButton( parent, ID_DELETE_RESOURCE, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1197  item29->Enable( false );
1198  item25->Add( item29, 0, wxALIGN_CENTER|wxALL, 5 );
1199 
1200  //item25->Add( 30, 20, 0, wxALIGN_CENTER|wxALL, 5 );
1201 
1202  item23->Add( item25, 0, wxGROW|wxALL, 5 );
1203 
1204  item21->Add( item23, 1, wxGROW, 5 );
1205 
1206  item20->Add( item21, 0, wxGROW|wxBOTTOM, 5 );
1207 
1208  wxStaticBox *item33 = new wxStaticBox( parent, -1, wxT("Operand usage:") );
1209  wxStaticBoxSizer *item32 = new wxStaticBoxSizer( item33, wxHORIZONTAL );
1210  usageSizer_ = item32;
1211 
1212  wxGrid *item34 = new wxGrid( parent, ID_OPERAND_GRID, wxDefaultPosition, wxSize(400,200), wxWANTS_CHARS );
1213  item34->CreateGrid( 0, 0, wxGrid::wxGridSelectCells );
1214  item32->Add( item34, 1, wxGROW|wxALL, 5 );
1215 
1216  item20->Add( item32, 0, wxGROW, 5 );
1217 
1218  wxBoxSizer *item35 = new wxBoxSizer( wxHORIZONTAL );
1219 
1220  wxStaticText *item36 = new wxStaticText( parent, ID_LABEL_LATENCY, wxT("Operation latency:"), wxDefaultPosition, wxDefaultSize, 0 );
1221  item35->Add( item36, 0, wxALIGN_CENTER|wxALL, 5 );
1222 
1223  wxStaticText *item37 = new wxStaticText( parent, ID_LATENCY, wxT(" "), wxDefaultPosition, wxDefaultSize, 0 );
1224  item35->Add( item37, 0, wxALIGN_CENTER|wxALL, 5 );
1225 
1226  item20->Add( item35, 0, wxGROW|wxALL, 5 );
1227 
1228  item1->Add( item20, 0, wxGROW, 5 );
1229 
1230  item0->Add( item1, 0, wxGROW|wxALL, 5 );
1231 
1232  wxBoxSizer *item38 = new wxBoxSizer( wxVERTICAL );
1233 
1234  wxStaticLine *item39 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
1235  item38->Add( item39, 0, wxGROW|wxALL, 5 );
1236 
1237  wxGridSizer *item40 = new wxGridSizer( 2, 0, 0 );
1238 
1239  wxButton *item41 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
1240  item40->Add( item41, 0, wxALL, 5 );
1241 
1242  wxBoxSizer *item42 = new wxBoxSizer( wxHORIZONTAL );
1243 
1244  wxButton *item43 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
1245  item42->Add( item43, 0, wxALIGN_CENTER|wxALL, 5 );
1246 
1247  wxButton *item44 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
1248  item42->Add( item44, 0, wxALIGN_CENTER|wxALL, 5 );
1249 
1250  item40->Add( item42, 0, 0, 5 );
1251 
1252  item38->Add( item40, 0, wxGROW, 5 );
1253 
1254  item0->Add( item38, 0, wxGROW, 5 );
1255 
1256  if (set_sizer) {
1257  parent->SetSizer( item0 );
1258  if (call_fit) {
1259  item0->SetSizeHints( parent );
1260  }
1261  }
1262 
1263  return item0;
1264 }

◆ initialize()

void OperationDialog::initialize ( )
private

Initializes the dialog widgets and some class variables.

Definition at line 128 of file OperationDialog.cc.

128  {
129 
130  // Name field validators.
131  FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
132  FindWindow(ID_RESOURCE_NAME)->SetValidator(
133  wxTextValidator(wxFILTER_ASCII, &resourceName_));
134 
135  // Set widget pointers.
136  bindList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_BIND_LIST));
137  resourceGrid_ = dynamic_cast<wxGrid*>(FindWindow(ID_RESOURCE_GRID));
138  usageGrid_ = dynamic_cast<wxGrid*>(FindWindow(ID_OPERAND_GRID));
139  portChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_PORT));
140  numberControl_ = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_NUMBER));
141 
142  // Operand list.
143  FindWindow(ID_DELETE_OPERAND)->Disable();
144  FindWindow(ID_DELETE_RESOURCE)->Disable();
145 
146  // Resource grid.
147  resourceGrid_->EnableEditing(false);
148  resourceGrid_->SetDefaultCellAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
149  resourceGrid_->SetDefaultCellBackgroundColour(
150  wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
151  resourceGrid_->SetSelectionBackground(ProDeConstants::WHITE_COLOR);
152  resourceGrid_->SetSelectionForeground(ProDeConstants::BLACK_COLOR);
153  resourceGrid_->DisableDragColSize();
154  resourceGrid_->DisableDragRowSize();
155 
156  // Operand usage grid.
157  usageGrid_->EnableEditing(false);
158  usageGrid_->DisableDragColSize();
159  usageGrid_->DisableDragRowSize();
160  usageGrid_->SetDefaultCellBackgroundColour(ProDeConstants::WHITE_COLOR);
161 
162  latencyText_ = dynamic_cast<wxStaticText*>(FindWindow(ID_LATENCY));
163 }

References ProDeConstants::BLACK_COLOR, and ProDeConstants::WHITE_COLOR.

◆ onAddOperand()

void OperationDialog::onAddOperand ( wxCommandEvent &  event)
private

Handles the Add bind button event.

Adds a bind to the operation according to the number and port selection widgets.

Definition at line 754 of file OperationDialog.cc.

754  {
755 
756  int number = numberControl_->GetValue();
757 
758  std::pair<std::set<int>::iterator, bool> result =
759  operands_.insert(number);
760 
761  // Check that the number is not reserved for an operand.
762  if (!result.second) {
764  format fmt = prodeTexts->text(
766  fmt % number;
767  InformationDialog dialog(this, WxConversion::toWxString(fmt.str()));
768  dialog.ShowModal();
769  return;
770  }
771 
773  numberControl_->SetValue(number + 1);
774 
775 /*
776  } else {
777  }
778 */
779 }

References ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_OPERAND_NUM_RESERVED, Texts::TextGenerator::text(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onAddResource()

void OperationDialog::onAddResource ( wxCommandEvent &  event)
private

Handles the Add resource button event.

Opens pipeline resource dialog for adding a new resource to the operation.

Definition at line 948 of file OperationDialog.cc.

948  {
949 
950  string newName = WxConversion::toString(resourceName_);
951 
952  // Check the name validity.
953  if (!MachineTester::isValidComponentName(newName)) {
955  format message =
957  InformationDialog warning(
958  this, WxConversion::toWxString(message.str()));
959  warning.ShowModal();
960  return;
961  }
962 
963  // Check that the resource name is not reserved.
964  if (operation_->parentUnit()->hasPipelineElement(newName) ||
966 
968  format message =
970  format component =
972  format functionUnit =
974  message % newName % component.str() % functionUnit.str();
975  component = prodeTexts->text(ProDeTextGenerator::COMP_RESOURCE);
976  message % component.str();
977  WarningDialog warning(this, WxConversion::toWxString(message.str()));
978  warning.ShowModal();
979  return;
980  }
981  newResources_.push_back(newName);
983  dynamic_cast<wxTextCtrl*>(FindWindow(ID_RESOURCE_NAME))->Clear();
984 }

References ProDeTextGenerator::COMP_A_RESOURCE, ProDeTextGenerator::COMP_FUNCTION_UNIT, ProDeTextGenerator::COMP_RESOURCE, ContainerTools::containsValue(), ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, Texts::TextGenerator::text(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onBindOperand()

void OperationDialog::onBindOperand ( wxCommandEvent &  event)
private

Event handler for the operand port binding choicer.

Definition at line 842 of file OperationDialog.cc.

842  {
843 
844  string selected = WidgetTools::lcStringSelection(bindList_, 0);
845  int number = Conversion::toInt(selected);
846 
847  if (portChoice_->GetSelection() > 0) {
848  string portName=
849  WxConversion::toString(portChoice_->GetStringSelection());
850 
851  FUPort* port = operation_->parentUnit()->operationPort(portName);
852  operation_->bindPort(number, *port);
853  } else {
854  FUPort* port = operation_->port(number);
855  if (port != NULL) {
856  operation_->unbindPort(*port);
857  }
858  }
860 }

References WidgetTools::lcStringSelection(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::BaseFUPort::parentUnit(), Conversion::toInt(), and WxConversion::toString().

Here is the call graph for this function:

◆ onDeleteOperand()

void OperationDialog::onDeleteOperand ( wxCommandEvent &  event)
private

Removes the selected bind from the operation.

Definition at line 786 of file OperationDialog.cc.

786  {
787 
788  ExecutionPipeline* pipeline = operation_->pipeline();
789 
790  string selected = WidgetTools::lcStringSelection(bindList_, 0);
791  if (selected == "") {
792  return;
793  }
794 
795  int operand = Conversion::toInt(selected);
796 
797  // If the selected operand is read or written, a dialog is displayed
798  // that allows user to choose if the operand reads and writes are
799  // also cleared.
800  if (ContainerTools::containsValue(pipeline->readOperands(), operand) ||
801  ContainerTools::containsValue(pipeline->writtenOperands(), operand)) {
802 
804 
805  format msgFmt = prodeTexts->text(
807  msgFmt % operand;
808  ConfirmDialog dialog(this, WxConversion::toWxString(msgFmt.str()));
809 
810  int choice = dialog.ShowModal();
811  if (choice == wxID_YES) {
812  try {
813  for (int c = pipeline->latency() - 1; c >= 0; c--) {
814  pipeline->removeOperandUse(operand, c);
815  }
816  } catch (StartTooLate& e) {
817  format fmt = prodeTexts->text(
819  InformationDialog dialog(
820  this, WxConversion::toWxString(fmt.str()));
821  dialog.ShowModal();
822  return;
823  }
824  } else if (choice != wxID_NO) {
825  return;
826  }
827  }
828 
830 
831  FUPort* port = operation_->port(operand);
832  if (port != NULL) {
833  operation_->unbindPort(*port);
834  }
836 }

References ContainerTools::containsValue(), ProDeTextGenerator::instance(), TTAMachine::ExecutionPipeline::latency(), WidgetTools::lcStringSelection(), ProDeTextGenerator::MSG_CONFIRM_OPERAND_DELETION, ProDeTextGenerator::MSG_ERROR_PIPELINE_START, TTAMachine::ExecutionPipeline::readOperands(), TTAMachine::ExecutionPipeline::removeOperandUse(), ContainerTools::removeValueIfExists(), Texts::TextGenerator::text(), Conversion::toInt(), WxConversion::toWxString(), and TTAMachine::ExecutionPipeline::writtenOperands().

Here is the call graph for this function:

◆ onDeleteResource()

void OperationDialog::onDeleteResource ( wxCommandEvent &  event)
private

Handles the delete resource button event.

Deletes the selected resource usage from the operation.

Definition at line 993 of file OperationDialog.cc.

993  {
994 
995  string selected = selectedResource();
996 
997  // Search resource from the unused resources.
998  if (selected == "" ||
1000 
1002  return;
1003  }
1004 
1005  // Remove resource from the operation pipeline.
1006  try {
1007  operation_->pipeline()->removeResourceUse(selected);
1008  } catch (StartTooLate& e) {
1010  format fmt = prodeTexts->text(
1012  InformationDialog dialog(
1013  this, WxConversion::toWxString(fmt.str()));
1014  dialog.ShowModal();
1015  return;
1016  }
1018 }

References ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_PIPELINE_START, ContainerTools::removeValueIfExists(), Texts::TextGenerator::text(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onGridLClick()

void OperationDialog::onGridLClick ( wxGridEvent &  event)
private

Handles the left mouse button event in both grids.

The event is passed to the grid specific handler.

Parameters
eventThe mouse event to handle.

Definition at line 536 of file OperationDialog.cc.

536  {
537  if (event.GetId() == ID_RESOURCE_GRID) {
538  onResourceLClick(event);
539  } else if (event.GetId() == ID_OPERAND_GRID) {
540  onOperandLClick(event);
541  }
542 }

◆ onGridRClick()

void OperationDialog::onGridRClick ( wxGridEvent &  event)
private

Handles the right mouse button event in both grids.

Parameters
eventThe mouse event to handle.

Definition at line 550 of file OperationDialog.cc.

550  {
551  if (event.GetId() == ID_RESOURCE_GRID) {
552  resourceGrid_->ClearSelection();
553  }
554 }

◆ onName()

void OperationDialog::onName ( wxCommandEvent &  event)
private

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

Definition at line 723 of file OperationDialog.cc.

723  {
724 
725  if (!TransferDataFromWindow()) {
726  assert(false);
727  }
728 
729  // OK-button.
730  wxString trimmedName = name_.Trim(false).Trim(true);
731  if (trimmedName == _T("")) {
732  FindWindow(wxID_OK)->Disable();
733  } else {
734  FindWindow(wxID_OK)->Enable();
735  }
736 
737  // Add resource button.
738  wxString trimmedResourceName = resourceName_.Trim(false).Trim(true);
739  if (trimmedResourceName == _T("")) {
740  FindWindow(ID_ADD_RESOURCE)->Disable();
741  } else {
742  FindWindow(ID_ADD_RESOURCE)->Enable();
743  }
744 }

References assert.

◆ onOK()

void OperationDialog::onOK ( wxCommandEvent &  event)
private

Handles the OK-button event.

Updates the operation and closes the dialog.

Definition at line 1027 of file OperationDialog.cc.

1027  {
1028 
1029  TransferDataFromWindow();
1030  string newName =
1031  WxConversion::toString(name_.Trim(true).Trim(false));
1032 
1033  // Check the name validity.
1034  if (!MachineTester::isValidComponentName(newName)) {
1036  format message =
1038  InformationDialog warning(
1039  this, WxConversion::toWxString(message.str()));
1040  warning.ShowModal();
1041  return;
1042  }
1043 
1044  try {
1045  operation_->setName(newName);
1046  } catch (ComponentAlreadyExists& e) {
1047 
1048  // Display an error message indicating that the name is reserved for
1049  // another operation.
1051  format message =
1053  format component =
1055 
1056  format bus = prodeTexts->text(ProDeTextGenerator::COMP_MACHINE);
1057  message % newName % component.str() % bus.str();
1058  component = prodeTexts->text(ProDeTextGenerator::COMP_OPERATION);
1059  message % component.str();
1060 
1061  InformationDialog dialog(
1062  this, WxConversion::toWxString(message.str()));
1063 
1064  dialog.ShowModal();
1065  return;
1066  }
1067 
1069 
1070  EndModal(wxID_OK);
1071 }

References ProDeTextGenerator::COMP_AN_OPERATION, ProDeTextGenerator::COMP_MACHINE, ProDeTextGenerator::COMP_OPERATION, ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, Texts::TextGenerator::text(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onOperandLClick()

void OperationDialog::onOperandLClick ( wxGridEvent &  event)
private

Handles left mouse button clicks in the operand usage grid.

Parameters
eventThe mouse event to handle.

Definition at line 622 of file OperationDialog.cc.

622  {
623 
624  int cycle = event.GetCol();
625 
626  std::set<int>::const_iterator iter = operands_.begin();
627  for (int i = 0; i < event.GetRow(); i++) {
628  assert(iter != operands_.end());
629  iter++;
630  }
631  int operand = *iter;
632  ExecutionPipeline* pipeline = operation_->pipeline();
633 
634 
635  bool read = false;
636  bool written = false;
637 
638  // Check if the operand is already being read.
639  ExecutionPipeline::OperandSet readOperands =
640  pipeline->readOperands(cycle);
641  if (ContainerTools::containsValue(readOperands, operand)) {
642  read = true;
643  }
644  // Check if the operand is already being written.
645  ExecutionPipeline::OperandSet writtenOperands =
646  pipeline->writtenOperands(cycle);
647  if (ContainerTools::containsValue(writtenOperands, operand)) {
648  written = true;
649  }
650 
651  bool toggled = false;
652  if (written == false && read == false) {
653  try {
654  // not used -> read.
655  pipeline->addPortRead(operand, cycle, 1);
656  toggled = true;
657  } catch (StartTooLate& e) {
659  format fmt = prodeTexts->text(
661  InformationDialog dialog(
662  this, WxConversion::toWxString(fmt.str()));
663  dialog.ShowModal();
664  return;
665  } catch (Exception& e) {
666  // do nothing
667  }
668  }
669  if (toggled == false && read == false && written == false) {
670  try {
671  // not used -> written
672  pipeline->addPortWrite(operand, cycle, 1);
673  toggled = true;
674  } catch (Exception& e) {
675  // do nothing
676  }
677  }
678  if (toggled == false && read == true && written == false) {
679  try {
680  // read -> written
681  pipeline->removeOperandUse(operand, cycle);
682  pipeline->addPortWrite(operand, cycle, 1);
683  toggled = true;
684  } catch (StartTooLate& e) {
686  format fmt = prodeTexts->text(
688  InformationDialog dialog(
689  this, WxConversion::toWxString(fmt.str()));
690  dialog.ShowModal();
691  return;
692  } catch (Exception& e) {
693  // do nothing
694  }
695  }
696  if (toggled == false && (read == true || written == true)) {
697  try {
698  // written/read -> not used
699  pipeline->removeOperandUse(operand, cycle);
700  toggled = true;
701  } catch (StartTooLate& e) {
703  format fmt = prodeTexts->text(
705  InformationDialog dialog(
706  this, WxConversion::toWxString(fmt.str()));
707  dialog.ShowModal();
708  return;
709  } catch (Exception& e) {
710  // do nothing
711  }
712  }
714  updateUsageGrid();
715  usageGrid_->MakeCellVisible(event.GetRow(), event.GetCol());
716 }

References TTAMachine::ExecutionPipeline::addPortRead(), TTAMachine::ExecutionPipeline::addPortWrite(), assert, ContainerTools::containsValue(), ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_PIPELINE_START, TTAMachine::ExecutionPipeline::readOperands(), TTAMachine::ExecutionPipeline::removeOperandUse(), Texts::TextGenerator::text(), WxConversion::toWxString(), and TTAMachine::ExecutionPipeline::writtenOperands().

Here is the call graph for this function:

◆ onOperandSelection()

void OperationDialog::onOperandSelection ( wxListEvent &  event)
private

Handles the bind list item selection events.

Enables and disables the delete bind button according to the selection.

Definition at line 869 of file OperationDialog.cc.

869  {
870 
871  portChoice_->Clear();
872  portChoice_->Append(_T("none"));
873 
874  string selected = WidgetTools::lcStringSelection(bindList_, 0);
875 
876  if (selected == "") {
877  FindWindow(ID_DELETE_OPERAND)->Disable();
878  FindWindow(ID_PORT)->Disable();
879  return;
880  } else {
881  int selection = 0;
882  int operand = Conversion::toInt(selected);
883  FindWindow(ID_DELETE_OPERAND)->Enable();
884  FindWindow(ID_PORT)->Enable();
885 
886  // Search bound operands.
887  for (int i = 0; i < operation_->parentUnit()->operationPortCount();
888  i++) {
889 
890  FUPort* port = operation_->parentUnit()->operationPort(i);
891 
892  if (!operation_->isBound(*port)) {
893  portChoice_->Append(WxConversion::toWxString(port->name()));
894  } else if (operation_->io(*port) == operand) {
895  selection = portChoice_->Append(
896  WxConversion::toWxString(port->name()));
897  }
898  }
899  portChoice_->SetSelection(selection);
900  }
901 }

References WidgetTools::lcStringSelection(), TTAMachine::Port::name(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::BaseFUPort::parentUnit(), Conversion::toInt(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onResourceLClick()

void OperationDialog::onResourceLClick ( wxGridEvent &  event)
private

Handles left mouse button cliks in the resource grid.

Parameters
eventThe mouse event to handle.

Definition at line 563 of file OperationDialog.cc.

563  {
564 
565  if (event.GetCol() < 0 || event.GetRow() < 0) {
566  return;
567  }
568 
569  ExecutionPipeline* pipeline = operation_->pipeline();
570  int cycle = event.GetCol();
571  string resource = selectedResource();
572 
573  // First click just selects the row.
575  resourceGrid_->GetRowLabelValue(event.GetRow()))) {
576 
577  resourceGrid_->SelectRow(event.GetRow());
578  return;
579  }
580 
581  if (operation_->pipeline()->isResourceUsed(resource, cycle)) {
582  //Try to remove resource use.
583  try {
584  pipeline->removeResourceUse(resource, cycle);
585  } catch (StartTooLate& e) {
587  format fmt = prodeTexts->text(
589  InformationDialog dialog(
590  this, WxConversion::toWxString(fmt.str()));
591  dialog.ShowModal();
592  return;
593  }
594  if (!operation_->parentUnit()->hasPipelineElement(resource)) {
595  newResources_.push_back(resource);
596  }
597  } else {
598  // Try to add resource use.
599  try {
600  pipeline->addResourceUse(resource, cycle, 1);
601  } catch (StartTooLate& e) {
603  format fmt = prodeTexts->text(
605  InformationDialog dialog(
606  this, WxConversion::toWxString(fmt.str()));
607  dialog.ShowModal();
608  return;
609  }
611  }
613  resourceGrid_->SelectRow(event.GetRow());
614 }

References TTAMachine::ExecutionPipeline::addResourceUse(), ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_PIPELINE_START, TTAMachine::ExecutionPipeline::removeResourceUse(), ContainerTools::removeValueIfExists(), Texts::TextGenerator::text(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onResourceSelection()

void OperationDialog::onResourceSelection ( wxGridRangeSelectEvent &  event)
private

Handles the resource list item selection events.

Enables and disables the edit and delete resource buttons according to the selection.

Definition at line 911 of file OperationDialog.cc.

911  {
912  if (resourceGrid_->IsSelection()) {
913  FindWindow(ID_DELETE_RESOURCE)->Enable();
914  } else {
915  FindWindow(ID_DELETE_RESOURCE)->Disable();
916  }
917  updateUsageGrid();
918 }

◆ operandRow()

int OperationDialog::operandRow ( int  operand)
private

Returns row nubmer of the operand in the resource usage grid.

Returns -1 if the operand is not found.

Parameters
Operandto search.
Returns
Operand grid row number of the operand.

Definition at line 516 of file OperationDialog.cc.

516  {
517  int row = 0;
518  std::set<int>::const_iterator iter = operands_.begin();
519  for (; iter != operands_.end(); iter++) {
520  if (*iter == operand) {
521  return row;
522  }
523  row++;
524  }
525  return -1;
526 }

◆ selectedResource()

string OperationDialog::selectedResource ( )
private

Returns name of the resource selected in the resource grid.

If a resource is not selected, an empty string is returned.

Definition at line 927 of file OperationDialog.cc.

927  {
928  if (!resourceGrid_->IsSelection()) {
929  return "";
930  }
931  // Sometimes GetSelectedRows() returns an empty array even if
932  // IsSelection() returns true.
933  if (resourceGrid_->GetSelectedRows().Count() != 1) {
934  resourceGrid_->ClearSelection();
935  return "";
936  }
937  int row = resourceGrid_->GetSelectedRows().Item(0);
938  return WxConversion::toString(resourceGrid_->GetRowLabelValue(row));
939 }

References WxConversion::toString().

Here is the call graph for this function:

◆ setOperandType()

void OperationDialog::setOperandType ( int  operand,
bool  read 
)
private

Sets operand row label read/write flag.

Parameters
operandOperand to set the label to.
readTrue if operand is read, false if written.

Definition at line 463 of file OperationDialog.cc.

463  {
464  wxString label = WxConversion::toWxString(operand);
465  label.Append(_T(" ("));
466  if (read) {
467  label.Append(READ_MARK);
468  } else {
469  label.Append(WRITE_MARK);
470  }
471  label.Append(_T(")"));
472  int row = operandRow(operand);
473  assert(row >= 0);
474  usageGrid_->SetRowLabelValue(row , label);
475 }

References assert, and WxConversion::toWxString().

Here is the call graph for this function:

◆ setTexts()

void OperationDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 170 of file OperationDialog.cc.

170  {
173 
174  // Dialog title
175  format fmt = prodeTexts->text(
177  SetTitle(WxConversion::toWxString(fmt.str()));
178 
179  // buttons
180  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
182 
183  WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
185 
188 
191 
194 
197 
200 
201 
202  // widget labels
205 
208 
211 
214 
215  // box sizer label
218 
221 
224 
225  // Create bind list columns.
226  wxListCtrl* bindList =
227  dynamic_cast<wxListCtrl*>(FindWindow(ID_BIND_LIST));
228  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_OPERAND);
229  bindList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
230  wxLIST_FORMAT_LEFT, 80);
231  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_PORT);
232  bindList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
233  wxLIST_FORMAT_LEFT, 100);
234 }

References GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), WidgetTools::setWidgetLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_ADD, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_OPERAND, ProDeTextGenerator::TXT_COLUMN_PORT, ProDeTextGenerator::TXT_LABEL_NAME, ProDeTextGenerator::TXT_LABEL_OPERAND, ProDeTextGenerator::TXT_LABEL_PORT, ProDeTextGenerator::TXT_OPERATION_DIALOG_TITLE, ProDeTextGenerator::TXT_OPERATION_OPERANDS_BOX, ProDeTextGenerator::TXT_OPERATION_RESOURCES_BOX, and ProDeTextGenerator::TXT_OPERATION_USAGE_BOX.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool OperationDialog::TransferDataToWindow ( )
private

Transfers data from the operation object to the dialog widgets.

Returns
true, if the transfer was succesful, false otherwise

Definition at line 243 of file OperationDialog.cc.

243  {
247  updateUsageGrid();
248  return wxDialog::TransferDataToWindow();
249 }

References WxConversion::toWxString().

Here is the call graph for this function:

◆ updateLatency()

void OperationDialog::updateLatency ( )
private

Updates the latency information static text widget.

Definition at line 1077 of file OperationDialog.cc.

1077  {
1078  wxString latency = WxConversion::toWxString(operation_->latency());
1079  latencyText_->SetLabel(latency);
1080 }

References WxConversion::toWxString().

Here is the call graph for this function:

◆ updateOperandList()

void OperationDialog::updateOperandList ( )
private

Updates the operand bind list.

Definition at line 256 of file OperationDialog.cc.

256  {
257 
258  ExecutionPipeline* pipeline = operation_->pipeline();
259  for (int cycle = 0; cycle <= pipeline->latency(); cycle++) {
260  // Read operands.
262  pipeline->readOperands(cycle);
263  ExecutionPipeline::OperandSet::const_iterator iter =
264  operands.begin();
265  for (; iter != operands.end(); iter++) {
266  operands_.insert(*iter);
267  }
268  // Written operands.
269  operands = pipeline->writtenOperands(cycle);
270  iter = operands.begin();
271  for (; iter != operands.end(); iter++) {
272  operands_.insert(*iter);
273  }
274  }
275 
276  // Search bound operands.
277  for (int i = 0; i < operation_->parentUnit()->operationPortCount(); i++) {
278  FUPort* port = operation_->parentUnit()->operationPort(i);
279  if (operation_->isBound(*port)) {
280  int operand = operation_->io(*port);
281  operands_.insert(operand);
282  }
283  }
284 
285  // Add operand-port pairs to the operation list.
286  std::set<int>::const_iterator iter = operands_.begin();
287  bindList_->DeleteAllItems();
288  for (; iter != operands_.end(); iter++) {
289  wxString portName = _T("");
290  if (operation_->port(*iter) != NULL) {
291  portName =
293  }
294  bindList_->InsertItem(0, WxConversion::toWxString(*iter));
295  bindList_->SetItem(0, 1, portName);
296  }
297  if (portChoice_->GetCount() > 1) {
298  portChoice_->SetSelection(1);
299  } else {
300  portChoice_->SetSelection(0);
301  }
302  wxListEvent dummy;
304  updateUsageGrid();
305 }

References dummy, TTAMachine::ExecutionPipeline::latency(), TTAMachine::FunctionUnit::operationPort(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::ExecutionPipeline::readOperands(), WxConversion::toWxString(), and TTAMachine::ExecutionPipeline::writtenOperands().

Here is the call graph for this function:

◆ updateResourceGrid()

void OperationDialog::updateResourceGrid ( )
private

Updates the list of pipeline resources.

Definition at line 312 of file OperationDialog.cc.

312  {
313 
314  int selected = -1;
315 
316  if (resourceGrid_->IsSelection()) {
317  selected = resourceGrid_->GetSelectedRows().Item(0);
318  }
319 
320  if (resourceGrid_->GetNumberCols() > 0) {
321  resourceGrid_->DeleteCols(0, resourceGrid_->GetNumberCols());
322  }
323  if (resourceGrid_->GetNumberRows() > 0) {
324  resourceGrid_->DeleteRows(0, resourceGrid_->GetNumberRows());
325  }
326 
327  ExecutionPipeline* pipeline = operation_->pipeline();
328  FunctionUnit* parent = operation_->parentUnit();
329 
330  resourceGrid_->AppendCols(pipeline->latency() + 50);
331  resourceGrid_->AppendRows(parent->pipelineElementCount());
332 
333  resourceGrid_->EnableEditing(false);
334 
335  // Set column labels (cycle numbers).
336  for (int i = 0; i < pipeline->latency() + 50; i++) {
337  resourceGrid_->SetColLabelValue(i, WxConversion::toWxString(i));
338  resourceGrid_->SetColSize(i, GRID_COLUMN_WIDTH);
339  }
340 
341  // Set row labels (resource names).
342  std::list<string> resources;
343  for (int i = 0; i < parent->pipelineElementCount(); i++) {
344  string label = parent->pipelineElement(i)->name();
345  resources.push_back(label);
346  }
347  resources.sort();
348  int row = 0;
349  std::list<string>::const_iterator iter = resources.begin();
350  for (; iter != resources.end(); iter++) {
351  resourceGrid_->SetRowLabelValue(row, WxConversion::toWxString(*iter));
352  row++;
353  }
354 
355  // add resource uses to the grid
356  for (int cycle = 0; cycle < (pipeline->latency() + 1); cycle++) {
357  row = 0;
358  for (iter = resources.begin(); iter != resources.end(); iter++) {
359  if (pipeline->isResourceUsed((*iter), cycle)) {
360  resourceGrid_->SetCellValue(row, cycle, USE_MARK);
361  }
362  row++;
363  }
364  }
365 
366  // Add resources that are not used
367  newResources_.sort();
368  iter = newResources_.begin();
369  for (; iter != newResources_.end(); iter++) {
370  resourceGrid_->AppendRows();
371  resourceGrid_->SetRowLabelValue(row, WxConversion::toWxString(*iter));
372  row++;
373  }
374 
375  if (selected >= 0) {
376  resourceGrid_->SelectRow(selected);
377  }
378 
379  resourceGrid_->FitInside();
380  updateLatency();
381 }

References TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::PipelineElement::name(), TTAMachine::FunctionUnit::pipelineElement(), TTAMachine::FunctionUnit::pipelineElementCount(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ updateUsageGrid()

void OperationDialog::updateUsageGrid ( )
private

Updates the operand usage grid.

If a resource is selected in the resource grid, the grid is enabled for editing and it displays the operand usage only for the selected resource. If a resource isn't selected, the grid will be disabled, and it displays summary of the operand use for all resources.

Definition at line 393 of file OperationDialog.cc.

393  {
394 
395  ExecutionPipeline* pipeline = operation_->pipeline();
396 
397  // Clear grid.
398  if (usageGrid_->GetNumberCols() > 0) {
399  usageGrid_->DeleteCols(0, usageGrid_->GetNumberCols());
400  }
401  if (usageGrid_->GetNumberRows() > 0) {
402  usageGrid_->DeleteRows(0, usageGrid_->GetNumberRows());
403  }
404 
405  usageGrid_->AppendCols(pipeline->latency() + 50);
406  usageGrid_->AppendRows(operands_.size());
407 
408  // Reset row labels to numbers (clear R/W flags).
409  int i = 0;
410  std::set<int>::const_iterator iter = operands_.begin();
411  for (; iter != operands_.end(); iter++) {
412  usageGrid_->SetRowLabelValue(i, WxConversion::toWxString(*iter));
413  i++;
414  }
415 
416  // Update operand uses to the grid
417  for (int cycle = 0; cycle < pipeline->latency() + 50; cycle++) {
418 
419  usageGrid_->SetColSize(cycle, GRID_COLUMN_WIDTH);
420  usageGrid_->SetColLabelValue(
421  cycle, WxConversion::toWxString(cycle));
422 
423  wxColour na = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
424 
425  // Reads
427  pipeline->readOperands(cycle);
428  ExecutionPipeline::OperandSet::const_iterator iter =
429  operands.begin();
430 
431  for (; iter != operands.end(); iter++) {
432  int row = operandRow(*iter);
433  assert(row >= 0);
434  setOperandType(*iter, true);
435  // operand read
436  usageGrid_->SetCellValue(row, cycle, READ_MARK);
437  }
438 
439  // Writes
440  operands = pipeline->writtenOperands(cycle);
441  iter = operands.begin();
442  for (; iter != operands.end(); iter++) {
443  int row = operandRow(*iter);
444  assert(row >= 0);
445  setOperandType(*iter, false);
446  // operand written
447  usageGrid_->SetCellValue(row, cycle, WRITE_MARK);
448  }
449  }
450 
451  usageGrid_->FitInside();
452  updateLatency();
453 }

References assert, TTAMachine::ExecutionPipeline::latency(), TTAMachine::ExecutionPipeline::readOperands(), WxConversion::toWxString(), and TTAMachine::ExecutionPipeline::writtenOperands().

Here is the call graph for this function:

◆ warnOnResourcesWithoutUsages()

void OperationDialog::warnOnResourcesWithoutUsages ( )
private

Warns if pipeline resources without usages exist

Definition at line 482 of file OperationDialog.cc.

482  {
483  ExecutionPipeline* pipeline = operation_->pipeline();
485  for (std::list<string>::const_iterator iter = newResources_.begin();
486  iter != newResources_.end(); iter++) {
487 
488  bool warn = true;
489  for (int cycle = 0; cycle < pipeline->latency(); cycle++) {
490  if (pipeline->isResourceUsed(*iter, cycle)) {
491  warn = false;
492  break;
493  }
494  }
495 
496  if (warn) {
497  format fmt = prodeTexts->text(
499  WarningDialog warning(this, WxConversion::toWxString(fmt.str()
500  + *iter));
501  warning.ShowModal();
502  }
503  }
504 }

References ProDeTextGenerator::instance(), TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::ExecutionPipeline::latency(), ProDeTextGenerator::MSG_WARN_RES_WITHOUT_USAGES, Texts::TextGenerator::text(), and WxConversion::toWxString().

Here is the call graph for this function:

Member Data Documentation

◆ bindList_

wxListCtrl* OperationDialog::bindList_
private

Bind list widget.

Definition at line 93 of file OperationDialog.hh.

◆ GRID_COLUMN_WIDTH

const int OperationDialog::GRID_COLUMN_WIDTH = 25
staticprivate

Width of the resource and operand usage grid columns.

Definition at line 119 of file OperationDialog.hh.

◆ latencyText_

wxStaticText* OperationDialog::latencyText_
private

Static text control displaying the operation latency.

Definition at line 116 of file OperationDialog.hh.

◆ name_

wxString OperationDialog::name_
private

Name of the operation.

Definition at line 89 of file OperationDialog.hh.

◆ newResources_

std::list<std::string> OperationDialog::newResources_
private

List of unused resources.

Definition at line 110 of file OperationDialog.hh.

◆ numberControl_

wxSpinCtrl* OperationDialog::numberControl_
private

Spin button control for the bind operand.

Definition at line 95 of file OperationDialog.hh.

◆ operands_

std::set<int> OperationDialog::operands_
private

List of unused operands.

Definition at line 113 of file OperationDialog.hh.

◆ operandSizer_

wxStaticBoxSizer* OperationDialog::operandSizer_
private

Static boxsizer for the operand list widgets.

Definition at line 105 of file OperationDialog.hh.

◆ operation_

TTAMachine::HWOperation* OperationDialog::operation_
private

Operation to edit.

Definition at line 87 of file OperationDialog.hh.

◆ portChoice_

wxChoice* OperationDialog::portChoice_
private

Choice widget for the port to bind.

Definition at line 101 of file OperationDialog.hh.

◆ READ_MARK

const wxString OperationDialog::READ_MARK = _T("R")
staticprivate

Grid marker for a read.

Definition at line 123 of file OperationDialog.hh.

◆ resourceGrid_

wxGrid* OperationDialog::resourceGrid_
private

Resource list widget.

Definition at line 97 of file OperationDialog.hh.

◆ resourceName_

wxString OperationDialog::resourceName_
private

Name of resource to be added.

Definition at line 91 of file OperationDialog.hh.

◆ resourceSizer_

wxStaticBoxSizer* OperationDialog::resourceSizer_
private

Static boxsizer for the resource grid widgets.

Definition at line 103 of file OperationDialog.hh.

◆ usageGrid_

wxGrid* OperationDialog::usageGrid_
private

Operand usage grid widget.

Definition at line 99 of file OperationDialog.hh.

◆ usageSizer_

wxStaticBoxSizer* OperationDialog::usageSizer_
private

Static boxsizer for the operand usage grid widgets.

Definition at line 107 of file OperationDialog.hh.

◆ USE_MARK

const wxString OperationDialog::USE_MARK = _T("X")
staticprivate

Grid marker for resource use.

Definition at line 121 of file OperationDialog.hh.

◆ WRITE_MARK

const wxString OperationDialog::WRITE_MARK = _T("W")
staticprivate

Grid marker for a write.

Definition at line 125 of file OperationDialog.hh.


The documentation for this class was generated from the following files:
OperationDialog::ID_PORT
@ ID_PORT
Definition: OperationDialog.hh:133
WarningDialog
Definition: WarningDialog.hh:42
OperationDialog::ID_DELETE_RESOURCE
@ ID_DELETE_RESOURCE
Definition: OperationDialog.hh:146
OperationDialog::newResources_
std::list< std::string > newResources_
List of unused resources.
Definition: OperationDialog.hh:110
OperationDialog::latencyText_
wxStaticText * latencyText_
Static text control displaying the operation latency.
Definition: OperationDialog.hh:116
OperationDialog::ID_LINE
@ ID_LINE
Definition: OperationDialog.hh:138
OperationDialog::ID_LATENCY
@ ID_LATENCY
Definition: OperationDialog.hh:151
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OperationDialog::updateResourceGrid
void updateResourceGrid()
Definition: OperationDialog.cc:312
TTAMachine::HWOperation::bindPort
virtual void bindPort(int operand, const FUPort &port)
Definition: HWOperation.cc:269
ProDeTextGenerator::MSG_WARN_RES_WITHOUT_USAGES
@ MSG_WARN_RES_WITHOUT_USAGES
Warning: Resources without usages.
Definition: ProDeTextGenerator.hh:248
OperationDialog::operands_
std::set< int > operands_
List of unused operands.
Definition: OperationDialog.hh:113
ProDeTextGenerator::MSG_ERROR_OPERAND_NUM_RESERVED
@ MSG_ERROR_OPERAND_NUM_RESERVED
Error: Operand number reserved.
Definition: ProDeTextGenerator.hh:236
OperationDialog::ID_ADD_OPERAND
@ ID_ADD_OPERAND
Definition: OperationDialog.hh:135
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
OperationDialog::ID_LABEL_LATENCY
@ ID_LABEL_LATENCY
Definition: OperationDialog.hh:150
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
ProDeTextGenerator::MSG_ERROR_PIPELINE_START
@ MSG_ERROR_PIPELINE_START
Error: Pipeline usage start late.
Definition: ProDeTextGenerator.hh:239
OperationDialog::onOperandLClick
void onOperandLClick(wxGridEvent &event)
Definition: OperationDialog.cc:622
GUITextGenerator
Definition: GUITextGenerator.hh:46
GUITextGenerator::TXT_BUTTON_HELP
@ TXT_BUTTON_HELP
Label for help button.
Definition: GUITextGenerator.hh:60
TTAMachine::ExecutionPipeline::removeResourceUse
void removeResourceUse(const std::string &name)
Definition: ExecutionPipeline.cc:189
OperationDialog::ID_NAME
@ ID_NAME
Definition: OperationDialog.hh:129
FindWindow
Definition: FindWindow.hh:49
OperationDialog::updateUsageGrid
void updateUsageGrid()
Definition: OperationDialog.cc:393
OperationDialog::operation_
TTAMachine::HWOperation * operation_
Operation to edit.
Definition: OperationDialog.hh:87
TTAMachine::ExecutionPipeline::writtenOperands
OperandSet writtenOperands(int cycle) const
Definition: ExecutionPipeline.cc:429
TTAMachine::PipelineElement::name
const std::string & name() const
ProDeConstants::WHITE_COLOR
static const wxColour WHITE_COLOR
Definition: ProDeConstants.hh:50
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
TTAMachine::ExecutionPipeline::readOperands
OperandSet readOperands(int cycle) const
Definition: ExecutionPipeline.cc:408
ProDeTextGenerator::COMP_OPERATION
@ COMP_OPERATION
Name for operation (w/o article).
Definition: ProDeTextGenerator.hh:258
OperationDialog::initialize
void initialize()
Definition: OperationDialog.cc:128
OperationDialog::USE_MARK
static const wxString USE_MARK
Grid marker for resource use.
Definition: OperationDialog.hh:121
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
Definition: ProDeTextGenerator.hh:223
OperationDialog::usageSizer_
wxStaticBoxSizer * usageSizer_
Static boxsizer for the operand usage grid widgets.
Definition: OperationDialog.hh:107
OperationDialog::resourceSizer_
wxStaticBoxSizer * resourceSizer_
Static boxsizer for the resource grid widgets.
Definition: OperationDialog.hh:103
OperationDialog::ID_RESOURCE_NAME
@ ID_RESOURCE_NAME
Definition: OperationDialog.hh:144
ProDeTextGenerator::MSG_ERROR_SAME_NAME
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
Definition: ProDeTextGenerator.hh:229
OperationDialog::ID_BIND_LIST
@ ID_BIND_LIST
Definition: OperationDialog.hh:131
ProDeTextGenerator::COMP_FUNCTION_UNIT
@ COMP_FUNCTION_UNIT
Name for FU (w/o article).
Definition: ProDeTextGenerator.hh:263
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::HWOperation::port
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:320
ProDeTextGenerator::COMP_A_RESOURCE
@ COMP_A_RESOURCE
Name for resource (w/ article).
Definition: ProDeTextGenerator.hh:262
ProDeTextGenerator::COMP_RESOURCE
@ COMP_RESOURCE
Name for resource (w/o article).
Definition: ProDeTextGenerator.hh:261
TTAMachine::FUPort
Definition: FUPort.hh:46
OperationDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: OperationDialog.cc:1093
OperationDialog::operandSizer_
wxStaticBoxSizer * operandSizer_
Static boxsizer for the operand list widgets.
Definition: OperationDialog.hh:105
OperationDialog::WRITE_MARK
static const wxString WRITE_MARK
Grid marker for a write.
Definition: OperationDialog.hh:125
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
TTAMachine::ExecutionPipeline::addResourceUse
void addResourceUse(const std::string &name, int start, int duration)
Definition: ExecutionPipeline.cc:112
OperationDialog::selectedResource
std::string selectedResource()
Definition: OperationDialog.cc:927
TTAMachine::HWOperation::io
int io(const FUPort &port) const
Definition: HWOperation.cc:364
OperationDialog::ID_DELETE_OPERAND
@ ID_DELETE_OPERAND
Definition: OperationDialog.hh:136
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
TTAMachine::FunctionUnit::pipelineElement
virtual PipelineElement * pipelineElement(int index) const
Definition: FunctionUnit.cc:523
ProDeTextGenerator::TXT_LABEL_PORT
@ TXT_LABEL_PORT
Label for port widget.
Definition: ProDeTextGenerator.hh:75
ProDeTextGenerator::TXT_OPERATION_OPERANDS_BOX
@ TXT_OPERATION_OPERANDS_BOX
Operands box title.
Definition: ProDeTextGenerator.hh:186
OperationDialog::resourceName_
wxString resourceName_
Name of resource to be added.
Definition: OperationDialog.hh:91
ContainerTools::removeValueIfExists
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
OperationDialog::setOperandType
void setOperandType(int operand, bool read)
Definition: OperationDialog.cc:463
ProDeTextGenerator::TXT_COLUMN_PORT
@ TXT_COLUMN_PORT
Label for port column in a list.
Definition: ProDeTextGenerator.hh:114
TTAMachine::HWOperation::unbindPort
virtual void unbindPort(const FUPort &port)
Definition: HWOperation.cc:296
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
OperationDialog::ID_MENU_FOO
@ ID_MENU_FOO
Definition: OperationDialog.hh:148
WidgetTools::lcStringSelection
static std::string lcStringSelection(wxListCtrl *list, int column)
Definition: WidgetTools.cc:108
TTAMachine::HWOperation::isBound
bool isBound(const FUPort &port) const
Definition: HWOperation.cc:338
TTAMachine::ExecutionPipeline::addPortRead
void addPortRead(int operand, int start, int duration)
Definition: ExecutionPipeline.cc:141
OperationDialog::name_
wxString name_
Name of the operation.
Definition: OperationDialog.hh:89
OperationDialog::resourceGrid_
wxGrid * resourceGrid_
Resource list widget.
Definition: OperationDialog.hh:97
GUITextGenerator::TXT_BUTTON_ADD
@ TXT_BUTTON_ADD
Label for an add button.
Definition: GUITextGenerator.hh:53
OperationDialog::bindList_
wxListCtrl * bindList_
Bind list widget.
Definition: OperationDialog.hh:93
ProDeTextGenerator::TXT_LABEL_NAME
@ TXT_LABEL_NAME
Label for component name widget.
Definition: ProDeTextGenerator.hh:56
OperationDialog::ID_RESOURCE_GRID
@ ID_RESOURCE_GRID
Definition: OperationDialog.hh:141
Exception
Definition: Exception.hh:54
ProDeTextGenerator::TXT_OPERATION_USAGE_BOX
@ TXT_OPERATION_USAGE_BOX
Pipeline usage box title.
Definition: ProDeTextGenerator.hh:184
OperationDialog::ID_LABEL_PORT
@ ID_LABEL_PORT
Definition: OperationDialog.hh:132
MachineTester::isValidComponentName
static bool isValidComponentName(const std::string &name)
Definition: MachineTester.cc:312
OperationDialog::ID_MENU_BAR
@ ID_MENU_BAR
Definition: OperationDialog.hh:149
TTAMachine::ExecutionPipeline::OperandSet
std::set< int > OperandSet
Set for operand indexes.
Definition: ExecutionPipeline.hh:58
OperationDialog::numberControl_
wxSpinCtrl * numberControl_
Spin button control for the bind operand.
Definition: OperationDialog.hh:95
ConfirmDialog
Definition: ConfirmDialog.hh:41
OperationDialog::ID_NUMBER
@ ID_NUMBER
Definition: OperationDialog.hh:140
OperationDialog::ID_OPERAND_GRID
@ ID_OPERAND_GRID
Definition: OperationDialog.hh:142
GUITextGenerator::TXT_BUTTON_DELETE
@ TXT_BUTTON_DELETE
Label for delete button.
Definition: GUITextGenerator.hh:56
TTAMachine::FunctionUnit::pipelineElementCount
virtual int pipelineElementCount() const
Definition: FunctionUnit.cc:507
OperationDialog::ID_ADD_RESOURCE
@ ID_ADD_RESOURCE
Definition: OperationDialog.hh:145
StartTooLate
Definition: Exception.hh:710
ProDeTextGenerator::COMP_AN_OPERATION
@ COMP_AN_OPERATION
Name for operation (w/ article).
Definition: ProDeTextGenerator.hh:257
OperationDialog::portChoice_
wxChoice * portChoice_
Choice widget for the port to bind.
Definition: OperationDialog.hh:101
OperationDialog::updateLatency
void updateLatency()
Definition: OperationDialog.cc:1077
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
ProDeTextGenerator::TXT_COLUMN_OPERAND
@ TXT_COLUMN_OPERAND
Label for operand column.
Definition: ProDeTextGenerator.hh:118
OperationDialog::ID_LABEL_NAME
@ ID_LABEL_NAME
Definition: OperationDialog.hh:130
OperationDialog::onOperandSelection
void onOperandSelection(wxListEvent &event)
Definition: OperationDialog.cc:869
ProDeTextGenerator::TXT_OPERATION_RESOURCES_BOX
@ TXT_OPERATION_RESOURCES_BOX
Pipeline resources box title.
Definition: ProDeTextGenerator.hh:185
ProDeTextGenerator::TXT_LABEL_OPERAND
@ TXT_LABEL_OPERAND
Label for operand widget.
Definition: ProDeTextGenerator.hh:76
OperationDialog::READ_MARK
static const wxString READ_MARK
Grid marker for a read.
Definition: OperationDialog.hh:123
ProDeTextGenerator::MSG_CONFIRM_OPERAND_DELETION
@ MSG_CONFIRM_OPERAND_DELETION
Confirm: operand deletion.
Definition: ProDeTextGenerator.hh:250
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
ProDeTextGenerator::TXT_OPERATION_DIALOG_TITLE
@ TXT_OPERATION_DIALOG_TITLE
Operation dialog title.
Definition: ProDeTextGenerator.hh:183
TTAMachine::HWOperation::parentUnit
FunctionUnit * parentUnit() const
Definition: HWOperation.cc:190
TTAMachine::ExecutionPipeline::removeOperandUse
void removeOperandUse(int operand, int cycle)
Definition: ExecutionPipeline.cc:272
ComponentAlreadyExists
Definition: Exception.hh:510
OperationDialog::ID_HELP
@ ID_HELP
Definition: OperationDialog.hh:137
OperationDialog::warnOnResourcesWithoutUsages
void warnOnResourcesWithoutUsages()
Definition: OperationDialog.cc:482
TTAMachine::HWOperation::pipeline
ExecutionPipeline * pipeline() const
Definition: HWOperation.cc:201
TTAMachine::ExecutionPipeline
Definition: ExecutionPipeline.hh:55
OperationDialog::ID_LABEL_OPERAND
@ ID_LABEL_OPERAND
Definition: OperationDialog.hh:139
OperationDialog::GRID_COLUMN_WIDTH
static const int GRID_COLUMN_WIDTH
Width of the resource and operand usage grid columns.
Definition: OperationDialog.hh:119
OperationDialog::setTexts
void setTexts()
Definition: OperationDialog.cc:170
ProDeTextGenerator::COMP_MACHINE
@ COMP_MACHINE
Text for machine description.
Definition: ProDeTextGenerator.hh:252
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
TTAMachine::ExecutionPipeline::addPortWrite
void addPortWrite(int operand, int start, int duration)
Definition: ExecutionPipeline.cc:167
OperationDialog::ID_LABEL_RESOURCE_NAME
@ ID_LABEL_RESOURCE_NAME
Definition: OperationDialog.hh:143
WidgetTools::setWidgetLabel
static void setWidgetLabel(wxWindow *widget, std::string text)
Definition: WidgetTools.cc:52
TTAMachine::HWOperation::latency
int latency() const
Definition: HWOperation.cc:216
Conversion::toInt
static int toInt(const T &source)
InformationDialog
Definition: InformationDialog.hh:42
OperationDialog::operandRow
int operandRow(int operand)
Definition: OperationDialog.cc:516
TTAMachine::FunctionUnit::operationPort
virtual FUPort * operationPort(const std::string &name) const
Definition: FunctionUnit.cc:224
OperationDialog::ID_DELETE_RESOURCE_CYCLE
@ ID_DELETE_RESOURCE_CYCLE
Definition: OperationDialog.hh:147
TTAMachine::ExecutionPipeline::latency
int latency() const
Definition: ExecutionPipeline.cc:482
TTAMachine::FunctionUnit::hasPipelineElement
virtual bool hasPipelineElement(const std::string &name) const
Definition: FunctionUnit.cc:540
WxConversion::toString
static std::string toString(const wxString &source)
OperationDialog::usageGrid_
wxGrid * usageGrid_
Operand usage grid widget.
Definition: OperationDialog.hh:99
OperationDialog::updateOperandList
void updateOperandList()
Definition: OperationDialog.cc:256
OperationDialog::onResourceLClick
void onResourceLClick(wxGridEvent &event)
Definition: OperationDialog.cc:563
TTAMachine::HWOperation::setName
virtual void setName(const std::string &name)
Definition: HWOperation.cc:155
ProDeConstants::BLACK_COLOR
static const wxColour BLACK_COLOR
Definition: ProDeConstants.hh:49
TTAMachine::ExecutionPipeline::isResourceUsed
bool isResourceUsed(const std::string &name, int cycle) const
Definition: ExecutionPipeline.cc:300
OperationDialog::ID_LABEL_NUMBER
@ ID_LABEL_NUMBER
Definition: OperationDialog.hh:134
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59