OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
wxString name_
 Name of the operation.
 
wxString resourceName_
 Name of resource to be added.
 
wxListCtrl * bindList_
 Bind list widget.
 
wxSpinCtrl * numberControl_
 Spin button control for the bind operand.
 
wxGrid * resourceGrid_
 Resource list widget.
 
wxGrid * usageGrid_
 Operand usage grid widget.
 
wxChoice * portChoice_
 Choice widget for the port to bind.
 
wxStaticBoxSizer * resourceSizer_
 Static boxsizer for the resource grid widgets.
 
wxStaticBoxSizer * operandSizer_
 Static boxsizer for the operand list widgets.
 
wxStaticBoxSizer * usageSizer_
 Static boxsizer for the operand usage grid widgets.
 
std::list< std::string > newResources_
 List of unused resources.
 
std::set< int > operands_
 List of unused operands.
 
wxStaticText * latencyText_
 Static text control displaying the operation latency.
 

Static Private Attributes

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

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,
133 ID_PORT,
137 ID_HELP,
138 ID_LINE,
140 ID_NUMBER,
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}
TTAMachine::HWOperation * operation_
Operation to edit.
wxStaticText * latencyText_
Static text control displaying the operation latency.
wxString resourceName_
Name of resource to be added.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxString name_
Name of the operation.

◆ ~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 1088 of file OperationDialog.cc.

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

References ID_ADD_OPERAND, ID_ADD_RESOURCE, ID_BIND_LIST, ID_DELETE_OPERAND, ID_DELETE_RESOURCE, ID_HELP, ID_LABEL_LATENCY, ID_LABEL_NAME, ID_LABEL_OPERAND, ID_LABEL_PORT, ID_LABEL_RESOURCE_NAME, ID_LATENCY, ID_LINE, ID_NAME, ID_NUMBER, ID_OPERAND_GRID, ID_PORT, ID_RESOURCE_GRID, ID_RESOURCE_NAME, operandSizer_, resourceSizer_, and usageSizer_.

◆ 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_->DisableDragColSize();
150 resourceGrid_->DisableDragRowSize();
151
152 // Operand usage grid.
153 usageGrid_->EnableEditing(false);
154 usageGrid_->DisableDragColSize();
155 usageGrid_->DisableDragRowSize();
156
157 latencyText_ = dynamic_cast<wxStaticText*>(FindWindow(ID_LATENCY));
158}
wxChoice * portChoice_
Choice widget for the port to bind.
wxGrid * resourceGrid_
Resource list widget.
wxSpinCtrl * numberControl_
Spin button control for the bind operand.
wxGrid * usageGrid_
Operand usage grid widget.
wxListCtrl * bindList_
Bind list widget.

References bindList_, ID_BIND_LIST, ID_DELETE_OPERAND, ID_DELETE_RESOURCE, ID_LATENCY, ID_NAME, ID_NUMBER, ID_OPERAND_GRID, ID_PORT, ID_RESOURCE_GRID, ID_RESOURCE_NAME, latencyText_, name_, numberControl_, portChoice_, resourceGrid_, resourceName_, and usageGrid_.

◆ 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 749 of file OperationDialog.cc.

749 {
750
751 int number = numberControl_->GetValue();
752
753 std::pair<std::set<int>::iterator, bool> result =
754 operands_.insert(number);
755
756 // Check that the number is not reserved for an operand.
757 if (!result.second) {
759 format fmt = prodeTexts->text(
761 fmt % number;
762 InformationDialog dialog(this, WxConversion::toWxString(fmt.str()));
763 dialog.ShowModal();
764 return;
765 }
766
768 numberControl_->SetValue(number + 1);
769
770/*
771 } else {
772 }
773*/
774}
std::set< int > operands_
List of unused operands.
static ProDeTextGenerator * instance()
@ MSG_ERROR_OPERAND_NUM_RESERVED
Error: Operand number reserved.
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

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

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 943 of file OperationDialog.cc.

943 {
944
945 string newName = WxConversion::toString(resourceName_);
946
947 // Check the name validity.
950 format message =
952 InformationDialog warning(
953 this, WxConversion::toWxString(message.str()));
954 warning.ShowModal();
955 return;
956 }
957
958 // Check that the resource name is not reserved.
959 if (operation_->parentUnit()->hasPipelineElement(newName) ||
961
963 format message =
965 format component =
967 format functionUnit =
969 message % newName % component.str() % functionUnit.str();
970 component = prodeTexts->text(ProDeTextGenerator::COMP_RESOURCE);
971 message % component.str();
972 WarningDialog warning(this, WxConversion::toWxString(message.str()));
973 warning.ShowModal();
974 return;
975 }
976 newResources_.push_back(newName);
978 dynamic_cast<wxTextCtrl*>(FindWindow(ID_RESOURCE_NAME))->Clear();
979}
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
static bool isValidComponentName(const std::string &name)
std::list< std::string > newResources_
List of unused resources.
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
@ COMP_FUNCTION_UNIT
Name for FU (w/o article).
@ COMP_A_RESOURCE
Name for resource (w/ article).
@ COMP_RESOURCE
Name for resource (w/o article).
virtual bool hasPipelineElement(const std::string &name) const
FunctionUnit * parentUnit() const
static std::string toString(const wxString &source)

References ProDeTextGenerator::COMP_A_RESOURCE, ProDeTextGenerator::COMP_FUNCTION_UNIT, ProDeTextGenerator::COMP_RESOURCE, ContainerTools::containsValue(), TTAMachine::FunctionUnit::hasPipelineElement(), ID_RESOURCE_NAME, ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, newResources_, operation_, TTAMachine::HWOperation::parentUnit(), resourceName_, Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), and updateResourceGrid().

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 837 of file OperationDialog.cc.

837 {
838
839 string selected = WidgetTools::lcStringSelection(bindList_, 0);
840 int number = Conversion::toInt(selected);
841
842 if (portChoice_->GetSelection() > 0) {
843 string portName=
844 WxConversion::toString(portChoice_->GetStringSelection());
845
846 FUPort* port = operation_->parentUnit()->operationPort(portName);
847 operation_->bindPort(number, *port);
848 } else {
849 FUPort* port = operation_->port(number);
850 if (port != NULL) {
851 operation_->unbindPort(*port);
852 }
853 }
855}
static int toInt(const T &source)
virtual FUPort * operationPort(const std::string &name) const
virtual void bindPort(int operand, const FUPort &port)
virtual void unbindPort(const FUPort &port)
virtual FUPort * port(int operand) const
static std::string lcStringSelection(wxListCtrl *list, int column)

References bindList_, TTAMachine::HWOperation::bindPort(), WidgetTools::lcStringSelection(), operation_, TTAMachine::FunctionUnit::operationPort(), TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::port(), portChoice_, Conversion::toInt(), WxConversion::toString(), TTAMachine::HWOperation::unbindPort(), and updateOperandList().

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 781 of file OperationDialog.cc.

781 {
782
784
785 string selected = WidgetTools::lcStringSelection(bindList_, 0);
786 if (selected == "") {
787 return;
788 }
789
790 int operand = Conversion::toInt(selected);
791
792 // If the selected operand is read or written, a dialog is displayed
793 // that allows user to choose if the operand reads and writes are
794 // also cleared.
795 if (ContainerTools::containsValue(pipeline->readOperands(), operand) ||
796 ContainerTools::containsValue(pipeline->writtenOperands(), operand)) {
797
799
800 format msgFmt = prodeTexts->text(
802 msgFmt % operand;
803 ConfirmDialog dialog(this, WxConversion::toWxString(msgFmt.str()));
804
805 int choice = dialog.ShowModal();
806 if (choice == wxID_YES) {
807 try {
808 for (int c = pipeline->latency() - 1; c >= 0; c--) {
809 pipeline->removeOperandUse(operand, c);
810 }
811 } catch (StartTooLate& e) {
812 format fmt = prodeTexts->text(
814 InformationDialog dialog(
815 this, WxConversion::toWxString(fmt.str()));
816 dialog.ShowModal();
817 return;
818 }
819 } else if (choice != wxID_NO) {
820 return;
821 }
822 }
823
825
826 FUPort* port = operation_->port(operand);
827 if (port != NULL) {
828 operation_->unbindPort(*port);
829 }
831}
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
@ MSG_CONFIRM_OPERAND_DELETION
Confirm: operand deletion.
@ MSG_ERROR_PIPELINE_START
Error: Pipeline usage start late.
OperandSet writtenOperands(int cycle) const
void removeOperandUse(int operand, int cycle)
OperandSet readOperands(int cycle) const
ExecutionPipeline * pipeline() const

References bindList_, ContainerTools::containsValue(), ProDeTextGenerator::instance(), TTAMachine::ExecutionPipeline::latency(), WidgetTools::lcStringSelection(), ProDeTextGenerator::MSG_CONFIRM_OPERAND_DELETION, ProDeTextGenerator::MSG_ERROR_PIPELINE_START, operands_, operation_, TTAMachine::HWOperation::pipeline(), TTAMachine::HWOperation::port(), TTAMachine::ExecutionPipeline::readOperands(), TTAMachine::ExecutionPipeline::removeOperandUse(), ContainerTools::removeValueIfExists(), Texts::TextGenerator::text(), Conversion::toInt(), WxConversion::toWxString(), TTAMachine::HWOperation::unbindPort(), updateOperandList(), 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 988 of file OperationDialog.cc.

988 {
989
990 string selected = selectedResource();
991
992 // Search resource from the unused resources.
993 if (selected == "" ||
995
997 return;
998 }
999
1000 // Remove resource from the operation pipeline.
1001 try {
1003 } catch (StartTooLate& e) {
1005 format fmt = prodeTexts->text(
1007 InformationDialog dialog(
1008 this, WxConversion::toWxString(fmt.str()));
1009 dialog.ShowModal();
1010 return;
1011 }
1013}
std::string selectedResource()
void removeResourceUse(const std::string &name)

References ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_PIPELINE_START, newResources_, operation_, TTAMachine::HWOperation::pipeline(), TTAMachine::ExecutionPipeline::removeResourceUse(), ContainerTools::removeValueIfExists(), selectedResource(), Texts::TextGenerator::text(), WxConversion::toWxString(), and updateResourceGrid().

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 531 of file OperationDialog.cc.

531 {
532 if (event.GetId() == ID_RESOURCE_GRID) {
533 onResourceLClick(event);
534 } else if (event.GetId() == ID_OPERAND_GRID) {
535 onOperandLClick(event);
536 }
537}
void onOperandLClick(wxGridEvent &event)
void onResourceLClick(wxGridEvent &event)

References ID_OPERAND_GRID, ID_RESOURCE_GRID, onOperandLClick(), and onResourceLClick().

Here is the call graph for this function:

◆ 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 545 of file OperationDialog.cc.

545 {
546 if (event.GetId() == ID_RESOURCE_GRID) {
547 resourceGrid_->ClearSelection();
548 }
549}

References ID_RESOURCE_GRID, and resourceGrid_.

◆ 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 718 of file OperationDialog.cc.

718 {
719
720 if (!TransferDataFromWindow()) {
721 assert(false);
722 }
723
724 // OK-button.
725 wxString trimmedName = name_.Trim(false).Trim(true);
726 if (trimmedName == _T("")) {
727 FindWindow(wxID_OK)->Disable();
728 } else {
729 FindWindow(wxID_OK)->Enable();
730 }
731
732 // Add resource button.
733 wxString trimmedResourceName = resourceName_.Trim(false).Trim(true);
734 if (trimmedResourceName == _T("")) {
735 FindWindow(ID_ADD_RESOURCE)->Disable();
736 } else {
737 FindWindow(ID_ADD_RESOURCE)->Enable();
738 }
739}
#define assert(condition)

References assert, ID_ADD_RESOURCE, name_, and resourceName_.

◆ onOK()

void OperationDialog::onOK ( wxCommandEvent &  event)
private

Handles the OK-button event.

Updates the operation and closes the dialog.

Definition at line 1022 of file OperationDialog.cc.

1022 {
1023
1024 TransferDataFromWindow();
1025 string newName =
1026 WxConversion::toString(name_.Trim(true).Trim(false));
1027
1028 // Check the name validity.
1031 format message =
1033 InformationDialog warning(
1034 this, WxConversion::toWxString(message.str()));
1035 warning.ShowModal();
1036 return;
1037 }
1038
1039 try {
1040 operation_->setName(newName);
1041 } catch (ComponentAlreadyExists& e) {
1042
1043 // Display an error message indicating that the name is reserved for
1044 // another operation.
1046 format message =
1048 format component =
1050
1051 format bus = prodeTexts->text(ProDeTextGenerator::COMP_MACHINE);
1052 message % newName % component.str() % bus.str();
1053 component = prodeTexts->text(ProDeTextGenerator::COMP_OPERATION);
1054 message % component.str();
1055
1056 InformationDialog dialog(
1057 this, WxConversion::toWxString(message.str()));
1058
1059 dialog.ShowModal();
1060 return;
1061 }
1062
1064
1065 EndModal(wxID_OK);
1066}
void warnOnResourcesWithoutUsages()
@ COMP_MACHINE
Text for machine description.
@ COMP_OPERATION
Name for operation (w/o article).
@ COMP_AN_OPERATION
Name for operation (w/ article).
virtual void setName(const std::string &name)

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, name_, operation_, TTAMachine::HWOperation::setName(), Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), and warnOnResourcesWithoutUsages().

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 617 of file OperationDialog.cc.

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

References TTAMachine::ExecutionPipeline::addPortRead(), TTAMachine::ExecutionPipeline::addPortWrite(), assert, ContainerTools::containsValue(), ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_PIPELINE_START, operands_, operation_, TTAMachine::HWOperation::pipeline(), TTAMachine::ExecutionPipeline::readOperands(), TTAMachine::ExecutionPipeline::removeOperandUse(), Texts::TextGenerator::text(), WxConversion::toWxString(), updateResourceGrid(), updateUsageGrid(), usageGrid_, and TTAMachine::ExecutionPipeline::writtenOperands().

Referenced by onGridLClick().

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 864 of file OperationDialog.cc.

864 {
865
866 portChoice_->Clear();
867 portChoice_->Append(_T("none"));
868
869 string selected = WidgetTools::lcStringSelection(bindList_, 0);
870
871 if (selected == "") {
872 FindWindow(ID_DELETE_OPERAND)->Disable();
873 FindWindow(ID_PORT)->Disable();
874 return;
875 } else {
876 int selection = 0;
877 int operand = Conversion::toInt(selected);
878 FindWindow(ID_DELETE_OPERAND)->Enable();
879 FindWindow(ID_PORT)->Enable();
880
881 // Search bound operands.
882 for (int i = 0; i < operation_->parentUnit()->operationPortCount();
883 i++) {
884
886
887 if (!operation_->isBound(*port)) {
888 portChoice_->Append(WxConversion::toWxString(port->name()));
889 } else if (operation_->io(*port) == operand) {
890 selection = portChoice_->Append(
892 }
893 }
894 portChoice_->SetSelection(selection);
895 }
896}
int io(const FUPort &port) const
bool isBound(const FUPort &port) const
virtual std::string name() const
Definition Port.cc:141

References bindList_, ID_DELETE_OPERAND, ID_PORT, TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), WidgetTools::lcStringSelection(), TTAMachine::Port::name(), operation_, TTAMachine::FunctionUnit::operationPort(), TTAMachine::HWOperation::parentUnit(), portChoice_, Conversion::toInt(), and WxConversion::toWxString().

Referenced by updateOperandList().

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 558 of file OperationDialog.cc.

558 {
559
560 if (event.GetCol() < 0 || event.GetRow() < 0) {
561 return;
562 }
563
565 int cycle = event.GetCol();
566 string resource = selectedResource();
567
568 // First click just selects the row.
570 resourceGrid_->GetRowLabelValue(event.GetRow()))) {
571
572 resourceGrid_->SelectRow(event.GetRow());
573 return;
574 }
575
576 if (operation_->pipeline()->isResourceUsed(resource, cycle)) {
577 //Try to remove resource use.
578 try {
579 pipeline->removeResourceUse(resource, cycle);
580 } catch (StartTooLate& e) {
582 format fmt = prodeTexts->text(
584 InformationDialog dialog(
585 this, WxConversion::toWxString(fmt.str()));
586 dialog.ShowModal();
587 return;
588 }
589 if (!operation_->parentUnit()->hasPipelineElement(resource)) {
590 newResources_.push_back(resource);
591 }
592 } else {
593 // Try to add resource use.
594 try {
595 pipeline->addResourceUse(resource, cycle, 1);
596 } catch (StartTooLate& e) {
598 format fmt = prodeTexts->text(
600 InformationDialog dialog(
601 this, WxConversion::toWxString(fmt.str()));
602 dialog.ShowModal();
603 return;
604 }
606 }
608 resourceGrid_->SelectRow(event.GetRow());
609}
void addResourceUse(const std::string &name, int start, int duration)
bool isResourceUsed(const std::string &name, int cycle) const

References TTAMachine::ExecutionPipeline::addResourceUse(), TTAMachine::FunctionUnit::hasPipelineElement(), ProDeTextGenerator::instance(), TTAMachine::ExecutionPipeline::isResourceUsed(), ProDeTextGenerator::MSG_ERROR_PIPELINE_START, newResources_, operation_, TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::pipeline(), TTAMachine::ExecutionPipeline::removeResourceUse(), ContainerTools::removeValueIfExists(), resourceGrid_, selectedResource(), Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), and updateResourceGrid().

Referenced by onGridLClick().

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 906 of file OperationDialog.cc.

906 {
907 if (resourceGrid_->IsSelection()) {
909 } else {
910 FindWindow(ID_DELETE_RESOURCE)->Disable();
911 }
913}

References ID_DELETE_RESOURCE, resourceGrid_, and updateUsageGrid().

Here is the call graph for this function:

◆ 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 511 of file OperationDialog.cc.

511 {
512 int row = 0;
513 std::set<int>::const_iterator iter = operands_.begin();
514 for (; iter != operands_.end(); iter++) {
515 if (*iter == operand) {
516 return row;
517 }
518 row++;
519 }
520 return -1;
521}

References operands_.

Referenced by setOperandType(), and updateUsageGrid().

◆ 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 922 of file OperationDialog.cc.

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

References resourceGrid_, and WxConversion::toString().

Referenced by onDeleteResource(), and onResourceLClick().

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 458 of file OperationDialog.cc.

458 {
459 wxString label = WxConversion::toWxString(operand);
460 label.Append(_T(" ("));
461 if (read) {
462 label.Append(READ_MARK);
463 } else {
464 label.Append(WRITE_MARK);
465 }
466 label.Append(_T(")"));
467 int row = operandRow(operand);
468 assert(row >= 0);
469 usageGrid_->SetRowLabelValue(row , label);
470}
static const wxString READ_MARK
Grid marker for a read.
static const wxString WRITE_MARK
Grid marker for a write.
int operandRow(int operand)

References assert, operandRow(), READ_MARK, WxConversion::toWxString(), usageGrid_, and WRITE_MARK.

Referenced by updateUsageGrid().

Here is the call graph for this function:

◆ setTexts()

void OperationDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 165 of file OperationDialog.cc.

165 {
168
169 // Dialog title
170 format fmt = prodeTexts->text(
172 SetTitle(WxConversion::toWxString(fmt.str()));
173
174 // buttons
175 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
177
178 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
180
183
186
189
192
195
196
197 // widget labels
200
203
206
209
210 // box sizer label
213
216
219
220 // Create bind list columns.
221 wxListCtrl* bindList =
222 dynamic_cast<wxListCtrl*>(FindWindow(ID_BIND_LIST));
224 bindList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
225 wxLIST_FORMAT_LEFT, 80);
226 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_PORT);
227 bindList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
228 wxLIST_FORMAT_LEFT, 100);
229}
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
@ TXT_BUTTON_ADD
Label for an add button.
static GUITextGenerator * instance()
@ TXT_LABEL_NAME
Label for component name widget.
@ TXT_COLUMN_OPERAND
Label for operand column.
@ TXT_OPERATION_OPERANDS_BOX
Operands box title.
@ TXT_OPERATION_USAGE_BOX
Pipeline usage box title.
@ TXT_OPERATION_RESOURCES_BOX
Pipeline resources box title.
@ TXT_LABEL_PORT
Label for port widget.
@ TXT_COLUMN_PORT
Label for port column in a list.
@ TXT_LABEL_OPERAND
Label for operand widget.
@ TXT_OPERATION_DIALOG_TITLE
Operation dialog title.
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_ADD_OPERAND, ID_ADD_RESOURCE, ID_BIND_LIST, ID_DELETE_OPERAND, ID_DELETE_RESOURCE, ID_HELP, ID_LABEL_NAME, ID_LABEL_OPERAND, ID_LABEL_PORT, ID_LABEL_RESOURCE_NAME, GUITextGenerator::instance(), ProDeTextGenerator::instance(), operandSizer_, resourceSizer_, 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, ProDeTextGenerator::TXT_OPERATION_USAGE_BOX, and usageSizer_.

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 238 of file OperationDialog.cc.

238 {
243 return wxDialog::TransferDataToWindow();
244}
const std::string & name() const

References TTAMachine::HWOperation::name(), name_, operation_, WxConversion::toWxString(), updateOperandList(), updateResourceGrid(), and updateUsageGrid().

Here is the call graph for this function:

◆ updateLatency()

void OperationDialog::updateLatency ( )
private

Updates the latency information static text widget.

Definition at line 1072 of file OperationDialog.cc.

1072 {
1073 wxString latency = WxConversion::toWxString(operation_->latency());
1074 latencyText_->SetLabel(latency);
1075}

References TTAMachine::HWOperation::latency(), latencyText_, operation_, and WxConversion::toWxString().

Referenced by updateResourceGrid(), and updateUsageGrid().

Here is the call graph for this function:

◆ updateOperandList()

void OperationDialog::updateOperandList ( )
private

Updates the operand bind list.

Definition at line 251 of file OperationDialog.cc.

251 {
252
254 for (int cycle = 0; cycle <= pipeline->latency(); cycle++) {
255 // Read operands.
257 pipeline->readOperands(cycle);
258 ExecutionPipeline::OperandSet::const_iterator iter =
259 operands.begin();
260 for (; iter != operands.end(); iter++) {
261 operands_.insert(*iter);
262 }
263 // Written operands.
264 operands = pipeline->writtenOperands(cycle);
265 iter = operands.begin();
266 for (; iter != operands.end(); iter++) {
267 operands_.insert(*iter);
268 }
269 }
270
271 // Search bound operands.
272 for (int i = 0; i < operation_->parentUnit()->operationPortCount(); i++) {
274 if (operation_->isBound(*port)) {
275 int operand = operation_->io(*port);
276 operands_.insert(operand);
277 }
278 }
279
280 // Add operand-port pairs to the operation list.
281 std::set<int>::const_iterator iter = operands_.begin();
282 bindList_->DeleteAllItems();
283 for (; iter != operands_.end(); iter++) {
284 wxString portName = _T("");
285 if (operation_->port(*iter) != NULL) {
286 portName =
288 }
289 bindList_->InsertItem(0, WxConversion::toWxString(*iter));
290 bindList_->SetItem(0, 1, portName);
291 }
292 if (portChoice_->GetCount() > 1) {
293 portChoice_->SetSelection(1);
294 } else {
295 portChoice_->SetSelection(0);
296 }
297 wxListEvent dummy;
300}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onOperandSelection(wxListEvent &event)

References bindList_, dummy, TTAMachine::HWOperation::io(), TTAMachine::HWOperation::isBound(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::Port::name(), onOperandSelection(), operands_, operation_, TTAMachine::FunctionUnit::operationPort(), TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::pipeline(), TTAMachine::HWOperation::port(), portChoice_, TTAMachine::ExecutionPipeline::readOperands(), WxConversion::toWxString(), updateUsageGrid(), and TTAMachine::ExecutionPipeline::writtenOperands().

Referenced by onAddOperand(), onBindOperand(), onDeleteOperand(), and TransferDataToWindow().

Here is the call graph for this function:

◆ updateResourceGrid()

void OperationDialog::updateResourceGrid ( )
private

Updates the list of pipeline resources.

Definition at line 307 of file OperationDialog.cc.

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

References GRID_COLUMN_WIDTH, TTAMachine::ExecutionPipeline::isResourceUsed(), TTAMachine::ExecutionPipeline::latency(), TTAMachine::PipelineElement::name(), newResources_, operation_, TTAMachine::HWOperation::parentUnit(), TTAMachine::HWOperation::pipeline(), TTAMachine::FunctionUnit::pipelineElement(), TTAMachine::FunctionUnit::pipelineElementCount(), resourceGrid_, WxConversion::toWxString(), updateLatency(), and USE_MARK.

Referenced by onAddResource(), onDeleteResource(), onOperandLClick(), onResourceLClick(), and TransferDataToWindow().

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 388 of file OperationDialog.cc.

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

References assert, GRID_COLUMN_WIDTH, TTAMachine::ExecutionPipeline::latency(), operandRow(), operands_, operation_, TTAMachine::HWOperation::pipeline(), READ_MARK, TTAMachine::ExecutionPipeline::readOperands(), setOperandType(), WxConversion::toWxString(), updateLatency(), usageGrid_, WRITE_MARK, and TTAMachine::ExecutionPipeline::writtenOperands().

Referenced by onOperandLClick(), onResourceSelection(), TransferDataToWindow(), and updateOperandList().

Here is the call graph for this function:

◆ warnOnResourcesWithoutUsages()

void OperationDialog::warnOnResourcesWithoutUsages ( )
private

Warns if pipeline resources without usages exist

Definition at line 477 of file OperationDialog.cc.

477 {
480 for (std::list<string>::const_iterator iter = newResources_.begin();
481 iter != newResources_.end(); iter++) {
482
483 bool warn = true;
484 for (int cycle = 0; cycle < pipeline->latency(); cycle++) {
485 if (pipeline->isResourceUsed(*iter, cycle)) {
486 warn = false;
487 break;
488 }
489 }
490
491 if (warn) {
492 format fmt = prodeTexts->text(
494 WarningDialog warning(this, WxConversion::toWxString(fmt.str()
495 + *iter));
496 warning.ShowModal();
497 }
498 }
499}
@ MSG_WARN_RES_WITHOUT_USAGES
Warning: Resources without usages.

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

Referenced by onOK().

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.

Referenced by initialize(), onBindOperand(), onDeleteOperand(), onOperandSelection(), and updateOperandList().

◆ 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.

Referenced by updateResourceGrid(), and updateUsageGrid().

◆ latencyText_

wxStaticText* OperationDialog::latencyText_
private

Static text control displaying the operation latency.

Definition at line 116 of file OperationDialog.hh.

Referenced by initialize(), and updateLatency().

◆ name_

wxString OperationDialog::name_
private

Name of the operation.

Definition at line 89 of file OperationDialog.hh.

Referenced by initialize(), onName(), onOK(), and TransferDataToWindow().

◆ newResources_

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

List of unused resources.

Definition at line 110 of file OperationDialog.hh.

Referenced by onAddResource(), onDeleteResource(), onResourceLClick(), updateResourceGrid(), and warnOnResourcesWithoutUsages().

◆ numberControl_

wxSpinCtrl* OperationDialog::numberControl_
private

Spin button control for the bind operand.

Definition at line 95 of file OperationDialog.hh.

Referenced by initialize(), and onAddOperand().

◆ operands_

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

List of unused operands.

Definition at line 113 of file OperationDialog.hh.

Referenced by onAddOperand(), onDeleteOperand(), onOperandLClick(), operandRow(), updateOperandList(), and updateUsageGrid().

◆ operandSizer_

wxStaticBoxSizer* OperationDialog::operandSizer_
private

Static boxsizer for the operand list widgets.

Definition at line 105 of file OperationDialog.hh.

Referenced by createContents(), and setTexts().

◆ operation_

TTAMachine::HWOperation* OperationDialog::operation_
private

◆ portChoice_

wxChoice* OperationDialog::portChoice_
private

Choice widget for the port to bind.

Definition at line 101 of file OperationDialog.hh.

Referenced by initialize(), onBindOperand(), onOperandSelection(), and updateOperandList().

◆ READ_MARK

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

Grid marker for a read.

Definition at line 123 of file OperationDialog.hh.

Referenced by setOperandType(), and updateUsageGrid().

◆ resourceGrid_

wxGrid* OperationDialog::resourceGrid_
private

Resource list widget.

Definition at line 97 of file OperationDialog.hh.

Referenced by initialize(), onGridRClick(), onResourceLClick(), onResourceSelection(), selectedResource(), and updateResourceGrid().

◆ resourceName_

wxString OperationDialog::resourceName_
private

Name of resource to be added.

Definition at line 91 of file OperationDialog.hh.

Referenced by initialize(), onAddResource(), and onName().

◆ resourceSizer_

wxStaticBoxSizer* OperationDialog::resourceSizer_
private

Static boxsizer for the resource grid widgets.

Definition at line 103 of file OperationDialog.hh.

Referenced by createContents(), and setTexts().

◆ usageGrid_

wxGrid* OperationDialog::usageGrid_
private

Operand usage grid widget.

Definition at line 99 of file OperationDialog.hh.

Referenced by initialize(), onOperandLClick(), setOperandType(), and updateUsageGrid().

◆ usageSizer_

wxStaticBoxSizer* OperationDialog::usageSizer_
private

Static boxsizer for the operand usage grid widgets.

Definition at line 107 of file OperationDialog.hh.

Referenced by createContents(), and setTexts().

◆ USE_MARK

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

Grid marker for resource use.

Definition at line 121 of file OperationDialog.hh.

Referenced by updateResourceGrid().

◆ WRITE_MARK

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

Grid marker for a write.

Definition at line 125 of file OperationDialog.hh.

Referenced by setOperandType(), and updateUsageGrid().


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