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

#include <OTAOperationDialog.hh>

Inheritance diagram for OTAOperationDialog:
Inheritance graph
Collaboration diagram for OTAOperationDialog:
Collaboration graph

Public Member Functions

 OTAOperationDialog (wxWindow *parent, TTAMachine::OperationTriggeredFormat *format)
 
virtual ~OTAOperationDialog ()
 

Private Types

enum  {
  ID_LABEL_OTA_OPERATION = 10000, ID_OTA_OPERATION, ID_LIST, ID_OP_FILTER,
  ID_LINE, ID_OP_FILTER_LABEL
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
void onOK (wxCommandEvent &event)
 
void onOperationFilterChange (wxCommandEvent &event)
 
void onSelectOperation (wxCommandEvent &event)
 
int numberOfInputs () const
 
int numberOfOutputs () const
 
bool validFormatName () const
 
std::set< TCEStringaddRISCVBaseOperations (std::set< TCEString > opset) const
 

Private Attributes

TCEString operation_
 Name of the selected operation. More...
 
wxListBox * operationList_
 Operation list widget. More...
 
TCEString opNameFilter_ = ""
 A string to filter opset list. More...
 
TTAMachine::OperationTriggeredFormatformat_
 

Detailed Description

Dialog for editing telplate slot properties.

Definition at line 42 of file OTAOperationDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_LABEL_OTA_OPERATION 
ID_OTA_OPERATION 
ID_LIST 
ID_OP_FILTER 
ID_LINE 
ID_OP_FILTER_LABEL 

Definition at line 75 of file OTAOperationDialog.hh.

75  {
76  ID_LABEL_OTA_OPERATION = 10000,
78  ID_LIST,
80  ID_LINE,
82  };

Constructor & Destructor Documentation

◆ OTAOperationDialog()

OTAOperationDialog::OTAOperationDialog ( wxWindow *  parent,
TTAMachine::OperationTriggeredFormat format 
)

The Constructor.

Parameters
parentParent window of the dialog.
formatOperationTriggeredFormat format to edit.
operationOperation to edit, NULL if a new operation is being added.

Definition at line 70 of file OTAOperationDialog.cc.

72  :
73  wxDialog(parent, -1, _T("Choose operation"), wxDefaultPosition),
74  operation_(""),
75  format_(format) {
76 
77  createContents(this, true, true);
78  operationList_ = dynamic_cast<wxListBox*>(FindWindow(ID_LIST));
79  FindWindow(wxID_OK)->Disable();
80 }

◆ ~OTAOperationDialog()

OTAOperationDialog::~OTAOperationDialog ( )
virtual

The Destructor.

Definition at line 86 of file OTAOperationDialog.cc.

86  {
87 }

Member Function Documentation

◆ addRISCVBaseOperations()

std::set< TCEString > OTAOperationDialog::addRISCVBaseOperations ( std::set< TCEString opset) const
private

Definition at line 131 of file OTAOperationDialog.cc.

131  {
132  std::map<std::string, int> ops;
133  if (format_->name() == "riscv_r_type") {
134  ops = riscvRTypeOperations;
135  } else if (format_->name() == "riscv_i_type") {
136  ops = riscvITypeOperations;
137  } else if (format_->name() == "riscv_s_type") {
138  ops = riscvSTypeOperations;
139  } else if (format_->name() == "riscv_b_type") {
140  ops = riscvBTypeOperations;
141  } else if (format_->name() == "riscv_u_type") {
142  ops = riscvUTypeOperations;
143  } else if (format_->name() == "riscv_j_type") {
144  ops = riscvJTypeOperations;
145  }
146  for (const auto& op : ops) {
147  const std::string opName = op.first;
148  if (!opNameFilter_.empty() &&
149  opName.find(opNameFilter_) == std::string::npos) {
150  continue;
151  } else if (format_->hasOperation(opName)) {
152  continue;
153  } else if (op.first == "lui") {
154  opset.insert(opName);
155  continue;
156  }
157  const std::string OAName = operationNameTable.at(opName);
158  if (format_->machine()->hasOperation(OAName)) {
159  opset.insert(opName);
160  }
161  }
162  return opset;
163 }

References operationNameTable, riscvBTypeOperations, riscvITypeOperations, riscvJTypeOperations, riscvRTypeOperations, riscvSTypeOperations, and riscvUTypeOperations.

◆ createContents()

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

Creates the dialog widgets.

Parameters
parentParent window of the widgets.

Definition at line 276 of file OTAOperationDialog.cc.

276  {
277 
278  wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
279  // Sizer for leftSizer and rightSizer
280  wxBoxSizer *upperSizer = new wxBoxSizer(wxHORIZONTAL);
281 
282  // Sizer for oplistbox, filterlabel and filterinput
283  wxBoxSizer *leftSizer = new wxBoxSizer(wxVERTICAL);
284  // List of operations
285  wxListBox *opListBox = new wxListBox(parent, ID_LIST, wxDefaultPosition,
286  wxSize(210, 150), 0, NULL, wxLB_SINGLE|wxLB_SORT);
287  leftSizer->Add(opListBox, 0, wxEXPAND|wxALL, 5);
288 
289  // Sizer for opNameFilterLabel and opNameFilter
290  wxBoxSizer *filterSizer = new wxBoxSizer(wxHORIZONTAL);
291  // TextLabel "Filter:"
292  wxStaticText *opNameFilterLabel = new wxStaticText(parent,
293  ID_OP_FILTER_LABEL, wxT("Filter:"), wxDefaultPosition, wxDefaultSize,
294  0);
295  // Operation filter input
296  wxTextCtrl *opNameFilter = new wxTextCtrl(parent, ID_OP_FILTER, wxT(""),
297  wxDefaultPosition, wxDefaultSize, 0);
298  filterSizer->Add(opNameFilterLabel, 0, 0);
299  filterSizer->Add(opNameFilter, 1, wxEXPAND);
300  leftSizer->Add(filterSizer, 0, wxEXPAND|wxALL, 5);
301 
302  upperSizer->Add(leftSizer, 0, wxALL, 5);
303 
304  mainSizer->Add(upperSizer, 1, wxEXPAND);
305 
306  // Static line
307  wxStaticLine *horisontalLine = new wxStaticLine(parent, ID_LINE,
308  wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL);
309  mainSizer->Add(horisontalLine, 0, wxEXPAND|wxALL, 5);
310 
311  // Sizer for Cancel and OK buttons
312  wxBoxSizer *buttonsSizer = new wxBoxSizer(wxHORIZONTAL);
313  // Cancel button
314  wxButton *cancelButton = new wxButton(parent, wxID_CANCEL, wxT("&Cancel"),
315  wxDefaultPosition, wxDefaultSize, 0);
316  buttonsSizer->Add(cancelButton, 0, wxALIGN_CENTER|wxALL, 5);
317  // OK button
318  wxButton *okButton = new wxButton(parent, wxID_OK, wxT("&OK"),
319  wxDefaultPosition, wxDefaultSize, 0);
320  buttonsSizer->Add(okButton, 0, wxALIGN_CENTER|wxALL, 5);
321 
322  mainSizer->Add(buttonsSizer, 0, 0, 5);
323 
324  if (set_sizer) {
325  parent->SetSizer(mainSizer);
326  if (call_fit) {
327  mainSizer->SetSizeHints( parent );
328  }
329  }
330 
331  return mainSizer;
332 }

◆ numberOfInputs()

int OTAOperationDialog::numberOfInputs ( ) const
private

Definition at line 90 of file OTAOperationDialog.cc.

90  {
91  if (format_->name() == "riscv_r_type" ||
92  format_->name() == "riscv_i_type") {
93  return 2;
94  }
95  if (format_->name() == "riscv_s_type" ||
96  format_->name() == "riscv_b_type") {
97  return 3;
98  }
99  if (format_->name() == "riscv_u_type" ||
100  format_->name() == "riscv_j_type") {
101  return 1;
102  }
103  return 0;
104 }

◆ numberOfOutputs()

int OTAOperationDialog::numberOfOutputs ( ) const
private

Definition at line 107 of file OTAOperationDialog.cc.

107  {
108  if (format_->name() == "riscv_r_type" ||
109  format_->name() == "riscv_i_type" ||
110  format_->name() == "riscv_u_type" ||
111  format_->name() == "riscv_j_type") {
112  return 1;
113  }
114  return 0;
115 }

◆ onOK()

void OTAOperationDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the OK button.

Definition at line 225 of file OTAOperationDialog.cc.

225  {
226  if (operationList_->GetSelection() == wxNOT_FOUND) {
227  wxString message = _T("No operation selected.");
228  ErrorDialog dialog(this, message);
229  dialog.ShowModal();
230  return;
231  }
234  }
236  EndModal(wxID_OK);
237 }

◆ onOperationFilterChange()

void OTAOperationDialog::onOperationFilterChange ( wxCommandEvent &  event)
private

Event handler for opset filtering.

Definition at line 257 of file OTAOperationDialog.cc.

257  {
258  std::string pattern(event.GetString().mb_str());
259  std::string::iterator it;
260  it = std::remove_if(pattern.begin(), pattern.end(), [](const char& c) {
261  return c == ' ';
262  });
263  pattern.erase(it, pattern.end());
264  for (auto& c : pattern) c = toupper(c);
265  opNameFilter_ = pattern;
268 }

References TransferDataToWindow().

Here is the call graph for this function:

◆ onSelectOperation()

void OTAOperationDialog::onSelectOperation ( wxCommandEvent &  event)
private

Event handler for the operation list selections.

Enables and disables the OK button. Displays operation description and ports count.

Definition at line 246 of file OTAOperationDialog.cc.

246  {
247  FindWindow(wxID_OK)->Enable(operationList_->GetSelection() != wxNOT_FOUND);
248 
249  operation_ = WxConversion::toString(operationList_->GetStringSelection());
250 }

References WxConversion::toString().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool OTAOperationDialog::TransferDataFromWindow ( )
privatevirtual

Reads user choices from the dialog widgets.

Definition at line 216 of file OTAOperationDialog.cc.

216  {
217  operation_ = WxConversion::toString(operationList_->GetStringSelection());
218  return true;
219 }

References WxConversion::toString().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool OTAOperationDialog::TransferDataToWindow ( )
privatevirtual

Transfers data to the opset list.

Definition at line 170 of file OTAOperationDialog.cc.

170  {
171 
172  operationList_->Clear();
173 
174  std::set<TCEString> opset;
175  if (format_->name() == "riscv_r_type") {
178  for (int i = 0; i < nav.count(); i++) {
179  FunctionUnit* fu = nav.item(i);
180  for (int j = 0; j < fu->operationCount(); j++) {
181  HWOperation* op = fu->operation(j);
182  TCEString opName =op->name();
183  opName = opName.lower();
184  if (!opNameFilter_.empty() &&
185  opName.find(opNameFilter_) == std::string::npos) {
186  continue;
187  } else if (format_->hasOperation(opName)) {
188  continue;
189  } else if (op->numberOfInputs() != numberOfInputs()) {
190  continue;
191  } else if (op->numberOfOutputs() != numberOfOutputs()) {
192  continue;
193  } else if (MapTools::containsValue(
194  operationNameTable, opName)) {
195  continue;
196  }
197  opset.insert(opName);
198  }
199  }
200  }
201 
202  opset = addRISCVBaseOperations(opset);
203 
204 
205  for (const auto& opName : opset) {
206  operationList_->Append(WxConversion::toWxString(opName));
207  }
208 
209  return true;
210 }

References MapTools::containsValue(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), TCEString::lower(), TTAMachine::HWOperation::name(), TTAMachine::HWOperation::numberOfInputs(), TTAMachine::HWOperation::numberOfOutputs(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), operationNameTable, and WxConversion::toWxString().

Referenced by onOperationFilterChange().

Here is the call graph for this function:

◆ validFormatName()

bool OTAOperationDialog::validFormatName ( ) const
private

Definition at line 118 of file OTAOperationDialog.cc.

118  {
119  if (format_->name() == "riscv_r_type" ||
120  format_->name() == "riscv_i_type" ||
121  format_->name() == "riscv_s_type" ||
122  format_->name() == "riscv_b_type" ||
123  format_->name() == "riscv_u_type" ||
124  format_->name() == "riscv_j_type") {
125  return true;
126  }
127  return false;
128 }

Member Data Documentation

◆ format_

TTAMachine::OperationTriggeredFormat* OTAOperationDialog::format_
private

Definition at line 72 of file OTAOperationDialog.hh.

◆ operation_

TCEString OTAOperationDialog::operation_
private

Name of the selected operation.

Definition at line 66 of file OTAOperationDialog.hh.

◆ operationList_

wxListBox* OTAOperationDialog::operationList_
private

Operation list widget.

Definition at line 68 of file OTAOperationDialog.hh.

◆ opNameFilter_

TCEString OTAOperationDialog::opNameFilter_ = ""
private

A string to filter opset list.

Definition at line 70 of file OTAOperationDialog.hh.


The documentation for this class was generated from the following files:
riscvRTypeOperations
const std::map< std::string, int > riscvRTypeOperations
Definition: RISCVFields.hh:6
TTAMachine::Machine::hasOperation
bool hasOperation(const TCEString &opName) const
Definition: Machine.cc:1048
WxConversion::toWxString
static wxString toWxString(const std::string &source)
TCEString::lower
TCEString lower() const
Definition: TCEString.cc:78
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
riscvSTypeOperations
const std::map< std::string, int > riscvSTypeOperations
Definition: RISCVFields.hh:27
TTAMachine::HWOperation
Definition: HWOperation.hh:52
OTAOperationDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: OTAOperationDialog.cc:170
OTAOperationDialog::ID_OP_FILTER
@ ID_OP_FILTER
Definition: OTAOperationDialog.hh:79
FindWindow
Definition: FindWindow.hh:49
riscvJTypeOperations
const std::map< std::string, int > riscvJTypeOperations
Definition: RISCVFields.hh:37
TTAMachine::Machine::Navigator::count
int count() const
OTAOperationDialog::ID_LINE
@ ID_LINE
Definition: OTAOperationDialog.hh:80
OTAOperationDialog::TransferDataFromWindow
virtual bool TransferDataFromWindow()
Definition: OTAOperationDialog.cc:216
OTAOperationDialog::ID_LIST
@ ID_LIST
Definition: OTAOperationDialog.hh:78
operationNameTable
const std::map< std::string, std::string > operationNameTable
Definition: RISCVFields.hh:39
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
riscvUTypeOperations
const std::map< std::string, int > riscvUTypeOperations
Definition: RISCVFields.hh:34
OTAOperationDialog::operationList_
wxListBox * operationList_
Operation list widget.
Definition: OTAOperationDialog.hh:68
ErrorDialog
Definition: ErrorDialog.hh:42
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
OTAOperationDialog::ID_OTA_OPERATION
@ ID_OTA_OPERATION
Definition: OTAOperationDialog.hh:77
OTAOperationDialog::numberOfOutputs
int numberOfOutputs() const
Definition: OTAOperationDialog.cc:107
OTAOperationDialog::format_
TTAMachine::OperationTriggeredFormat * format_
Definition: OTAOperationDialog.hh:72
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
TTAMachine::HWOperation::numberOfInputs
int numberOfInputs() const
Definition: HWOperation.cc:384
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
OTAOperationDialog::addRISCVBaseOperations
std::set< TCEString > addRISCVBaseOperations(std::set< TCEString > opset) const
Definition: OTAOperationDialog.cc:131
OTAOperationDialog::numberOfInputs
int numberOfInputs() const
Definition: OTAOperationDialog.cc:90
TTAMachine::OperationTriggeredFormat::addOperation
void addOperation(const std::string &op)
Definition: OperationTriggeredFormat.cc:113
OTAOperationDialog::ID_OP_FILTER_LABEL
@ ID_OP_FILTER_LABEL
Definition: OTAOperationDialog.hh:81
OTAOperationDialog::ID_LABEL_OTA_OPERATION
@ ID_LABEL_OTA_OPERATION
Definition: OTAOperationDialog.hh:76
MapTools::containsValue
static bool containsValue(const MapType &aMap, const ValueType &aValue)
TTAMachine::Component::machine
virtual Machine * machine() const
riscvBTypeOperations
const std::map< std::string, int > riscvBTypeOperations
Definition: RISCVFields.hh:30
TCEString
Definition: TCEString.hh:53
riscvITypeOperations
const std::map< std::string, int > riscvITypeOperations
Definition: RISCVFields.hh:17
OTAOperationDialog::operation_
TCEString operation_
Name of the selected operation.
Definition: OTAOperationDialog.hh:66
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::HWOperation::numberOfOutputs
int numberOfOutputs() const
Definition: HWOperation.cc:404
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
OTAOperationDialog::opNameFilter_
TCEString opNameFilter_
A string to filter opset list.
Definition: OTAOperationDialog.hh:70
WxConversion::toString
static std::string toString(const wxString &source)
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::OperationTriggeredFormat::hasOperation
bool hasOperation(const std::string &opName) const
Definition: OperationTriggeredFormat.cc:141
OTAOperationDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: OTAOperationDialog.cc:276