OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
wxListBox * operationList_
 Operation list widget.
 
TCEString opNameFilter_ = ""
 A string to filter opset list.
 
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.

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}
TCEString operation_
Name of the selected operation.
TTAMachine::OperationTriggeredFormat * format_
wxListBox * operationList_
Operation list widget.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)

◆ ~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 141 of file OTAOperationDialog.cc.

141 {
142 std::map<std::string, int> ops;
155 }
156 for (const auto& op : ops) {
157 const std::string opName = op.first;
158 if (!opNameFilter_.empty() &&
159 opName.find(opNameFilter_) == std::string::npos) {
160 continue;
161 } else if (format_->hasOperation(opName)) {
162 continue;
163 } else if (op.first == "lui") {
164 opset.insert(opName);
165 continue;
166 }
167 const std::string OAName = RISCVFields::RISCVOperationNameTable.at(opName);
168 if (format_->machine()->hasOperation(OAName)) {
169 opset.insert(opName);
170 }
171 }
172 return opset;
173}
TCEString opNameFilter_
A string to filter opset list.
virtual Machine * machine() const
virtual TCEString name() const
bool hasOperation(const TCEString &opName) const
Definition Machine.cc:1042
bool hasOperation(const std::string &opName) const
const std::string RISCV_S_TYPE_NAME
const std::map< std::string, int > RISCVSTypeOperations
const std::string RISCV_B_TYPE_NAME
const std::map< std::string, int > RISCVJTypeOperations
const std::map< std::string, int > RISCVITypeOperations
const std::string RISCV_J_TYPE_NAME
const std::map< std::string, int > RISCVUTypeOperations
const std::string RISCV_R_TYPE_NAME
const std::string RISCV_I_TYPE_NAME
const std::string RISCV_U_TYPE_NAME
const std::map< std::string, int > RISCVRTypeOperations
Definition RISCVFields.hh:8
const std::map< std::string, int > RISCVBTypeOperations
const std::map< std::string, std::string > RISCVOperationNameTable

References format_, TTAMachine::OperationTriggeredFormat::hasOperation(), TTAMachine::Machine::hasOperation(), TTAMachine::Component::machine(), TTAMachine::Component::name(), opNameFilter_, RISCVFields::RISCV_B_TYPE_NAME, RISCVFields::RISCV_I_TYPE_NAME, RISCVFields::RISCV_J_TYPE_NAME, RISCVFields::RISCV_R_TYPE_NAME, RISCVFields::RISCV_S_TYPE_NAME, RISCVFields::RISCV_U_TYPE_NAME, RISCVFields::RISCVBTypeOperations, RISCVFields::RISCVITypeOperations, RISCVFields::RISCVJTypeOperations, RISCVFields::RISCVOperationNameTable, RISCVFields::RISCVRTypeOperations, RISCVFields::RISCVSTypeOperations, and RISCVFields::RISCVUTypeOperations.

Referenced by TransferDataToWindow().

Here is the call graph for this function:

◆ 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 289 of file OTAOperationDialog.cc.

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

References ID_LINE, ID_LIST, ID_OP_FILTER, and ID_OP_FILTER_LABEL.

◆ numberOfInputs()

int OTAOperationDialog::numberOfInputs ( ) const
private

◆ numberOfOutputs()

int OTAOperationDialog::numberOfOutputs ( ) const
private

◆ onOK()

void OTAOperationDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the OK button.

Definition at line 238 of file OTAOperationDialog.cc.

238 {
239 if (operationList_->GetSelection() == wxNOT_FOUND) {
240 wxString message = _T("No operation selected.");
241 ErrorDialog dialog(this, message);
242 dialog.ShowModal();
243 return;
244 }
247 }
249 EndModal(wxID_OK);
250}
virtual bool TransferDataFromWindow()

References TTAMachine::OperationTriggeredFormat::addOperation(), format_, TTAMachine::OperationTriggeredFormat::hasOperation(), operation_, operationList_, and TransferDataFromWindow().

Here is the call graph for this function:

◆ onOperationFilterChange()

void OTAOperationDialog::onOperationFilterChange ( wxCommandEvent &  event)
private

Event handler for opset filtering.

Definition at line 270 of file OTAOperationDialog.cc.

270 {
271 std::string pattern(event.GetString().mb_str());
272 std::string::iterator it;
273 it = std::remove_if(pattern.begin(), pattern.end(), [](const char& c) {
274 return c == ' ';
275 });
276 pattern.erase(it, pattern.end());
277 for (auto& c : pattern) c = toupper(c);
278 opNameFilter_ = pattern;
281}
virtual bool TransferDataToWindow()
TCEString lower() const
Definition TCEString.cc:78

References TCEString::lower(), opNameFilter_, and 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 259 of file OTAOperationDialog.cc.

259 {
260 FindWindow(wxID_OK)->Enable(operationList_->GetSelection() != wxNOT_FOUND);
261
262 operation_ = WxConversion::toString(operationList_->GetStringSelection());
263}
static std::string toString(const wxString &source)

References operation_, operationList_, and 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 229 of file OTAOperationDialog.cc.

229 {
230 operation_ = WxConversion::toString(operationList_->GetStringSelection());
231 return true;
232}

References operation_, operationList_, and WxConversion::toString().

Referenced by onOK().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool OTAOperationDialog::TransferDataToWindow ( )
privatevirtual

Transfers data to the opset list.

Definition at line 180 of file OTAOperationDialog.cc.

180 {
181
182 operationList_->Clear();
183
184 std::set<TCEString> opset;
191 for (int i = 0; i < nav.count(); i++) {
192 FunctionUnit* fu = nav.item(i);
193 for (int j = 0; j < fu->operationCount(); j++) {
194 HWOperation* op = fu->operation(j);
195 TCEString opName =op->name();
196 opName = opName.lower();
197 if (!opNameFilter_.empty() &&
198 opName.find(opNameFilter_) == std::string::npos) {
199 continue;
200 } else if (format_->hasOperation(opName)) {
201 continue;
202 } else if (op->numberOfInputs() != numberOfInputs()) {
203 continue;
204 } else if (op->numberOfOutputs() != numberOfOutputs()) {
205 continue;
206 } else if (MapTools::containsValue(
208 continue;
209 }
210 opset.insert(opName);
211 }
212 }
213 }
214
215 opset = addRISCVBaseOperations(opset);
216
217
218 for (const auto& opName : opset) {
220 }
221
222 return true;
223}
static bool containsValue(const MapType &aMap, const ValueType &aValue)
std::set< TCEString > addRISCVBaseOperations(std::set< TCEString > opset) const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
const std::string & name() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
static wxString toWxString(const std::string &source)

References addRISCVBaseOperations(), MapTools::containsValue(), TTAMachine::Machine::Navigator< ComponentType >::count(), format_, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::OperationTriggeredFormat::hasOperation(), TTAMachine::Machine::Navigator< ComponentType >::item(), TCEString::lower(), TTAMachine::Component::machine(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAMachine::HWOperation::numberOfInputs(), numberOfInputs(), TTAMachine::HWOperation::numberOfOutputs(), numberOfOutputs(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), operationList_, opNameFilter_, RISCVFields::RISCV_R1_TYPE_NAME, RISCVFields::RISCV_R1R_TYPE_NAME, RISCVFields::RISCV_R3R_TYPE_NAME, RISCVFields::RISCV_R_TYPE_NAME, RISCVFields::RISCVOperationNameTable, and WxConversion::toWxString().

Referenced by onOperationFilterChange().

Here is the call graph for this function:

◆ validFormatName()

bool OTAOperationDialog::validFormatName ( ) const
private

Member Data Documentation

◆ format_

TTAMachine::OperationTriggeredFormat* OTAOperationDialog::format_
private

◆ operation_

TCEString OTAOperationDialog::operation_
private

Name of the selected operation.

Definition at line 66 of file OTAOperationDialog.hh.

Referenced by onOK(), onSelectOperation(), and TransferDataFromWindow().

◆ operationList_

wxListBox* OTAOperationDialog::operationList_
private

Operation list widget.

Definition at line 68 of file OTAOperationDialog.hh.

Referenced by onOK(), onSelectOperation(), TransferDataFromWindow(), and TransferDataToWindow().

◆ opNameFilter_

TCEString OTAOperationDialog::opNameFilter_ = ""
private

A string to filter opset list.

Definition at line 70 of file OTAOperationDialog.hh.

Referenced by addRISCVBaseOperations(), onOperationFilterChange(), and TransferDataToWindow().


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