OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
GenerateProcessorDialog Class Reference

#include <GenerateProcessorDialog.hh>

Inheritance diagram for GenerateProcessorDialog:
Inheritance graph
Collaboration diagram for GenerateProcessorDialog:
Collaboration graph

Public Member Functions

 GenerateProcessorDialog (wxWindow *parent, TTAMachine::Machine &machine, const IDF::MachineImplementation &impl)
 
virtual ~GenerateProcessorDialog ()
 

Private Types

enum  {
  ID_GENERATE_BEM , ID_LOAD_BEM , ID_SAVE_BEM , ID_BROWSE_BEM_LOAD ,
  ID_BEM_LOAD_PATH , ID_BROWSE_BEM_SAVE , ID_BEM_SAVE_PATH , ID_TARGET ,
  ID_BROWSE_TARGET , ID_LINE , ID_VHDL , ID_VERILOG
}
 Widget IDs. More...
 

Private Member Functions

void onOK (wxCommandEvent &event)
 
void onBrowseBEMLoad (wxCommandEvent &event)
 
void onBrowseBEMSave (wxCommandEvent &event)
 
void onBrowseTargetDir (wxCommandEvent &event)
 
ProGe::ICDecoderGeneratorPluginloadICDecoderGeneratorPlugin (const std::string &pluginFile, const std::string &pluginName)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

TTAMachine::Machinemachine_
 Processor architecture.
 
const IDF::MachineImplementationimpl_
 Processor implementation definition.
 
BinaryEncodingbem_
 Binary Encosing Map.
 

Detailed Description

Dialog for generating processor implementation using ProGe.

Definition at line 56 of file GenerateProcessorDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Widget IDs.

Enumerator
ID_GENERATE_BEM 
ID_LOAD_BEM 
ID_SAVE_BEM 
ID_BROWSE_BEM_LOAD 
ID_BEM_LOAD_PATH 
ID_BROWSE_BEM_SAVE 
ID_BEM_SAVE_PATH 
ID_TARGET 
ID_BROWSE_TARGET 
ID_LINE 
ID_VHDL 
ID_VERILOG 

Definition at line 84 of file GenerateProcessorDialog.hh.

Constructor & Destructor Documentation

◆ GenerateProcessorDialog()

GenerateProcessorDialog::GenerateProcessorDialog ( wxWindow *  parent,
TTAMachine::Machine machine,
const IDF::MachineImplementation impl 
)

The Constructor.

Parameters
parenParent window of the dialog.
machineProcessor architecture.
impProcessor implementation definition.

Definition at line 87 of file GenerateProcessorDialog.cc.

90 :
91 wxDialog(parent, -1, _T("Generate Processor"), wxDefaultPosition),
92 machine_(machine), impl_(impl), bem_(NULL) {
93
94 createContents(this, true, true);
95}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
BinaryEncoding * bem_
Binary Encosing Map.
const IDF::MachineImplementation & impl_
Processor implementation definition.
TTAMachine::Machine & machine_
Processor architecture.

◆ ~GenerateProcessorDialog()

GenerateProcessorDialog::~GenerateProcessorDialog ( )
virtual

The Destructor.

Definition at line 101 of file GenerateProcessorDialog.cc.

101 {
102 if (bem_ != NULL) {
103 delete bem_;
104 }
105}

References bem_.

Member Function Documentation

◆ createContents()

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

Craetes the dialog contents.

Definition at line 358 of file GenerateProcessorDialog.cc.

359 {
360
361 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
362
363 wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );
364
365 //HDL type radio buttons
366 wxStaticBox *hdl_box = new wxStaticBox( parent, -1, wxT("HDL type selection:") );
367 wxStaticBoxSizer *hdl_boxsizer = new wxStaticBoxSizer( hdl_box, wxVERTICAL );
368
369 wxRadioButton *vhdl_item = new wxRadioButton( parent, ID_VHDL, wxT("VHDL"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
370 vhdl_item->SetValue( TRUE );
371
372 wxRadioButton *verilog_item = new wxRadioButton( parent, ID_VERILOG, wxT("Verilog"), wxDefaultPosition, wxDefaultSize, 0 );
373
374 hdl_boxsizer->Add( vhdl_item, 0, wxALL, 5 );
375 hdl_boxsizer->Add( verilog_item, 0, wxALL, 5 );
376 item1->Add( hdl_boxsizer, 0, wxGROW|wxALL, 5 );
377 //
378
379 wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("Binary Encoding Map:") );
380 wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
381
382 wxRadioButton *item4 = new wxRadioButton( parent, ID_GENERATE_BEM, wxT("Generate new"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
383 item4->SetValue( TRUE );
384 item2->Add( item4, 0, wxALL, 5 );
385
386 wxBoxSizer *item5 = new wxBoxSizer( wxVERTICAL );
387
388 wxBoxSizer *item6 = new wxBoxSizer( wxHORIZONTAL );
389
390 wxCheckBox *item7 = new wxCheckBox( parent, ID_SAVE_BEM, wxT("Save to file:"), wxDefaultPosition, wxDefaultSize, 0 );
391 item6->Add( item7, 0, wxLEFT, 5 );
392
393 item5->Add( item6, 0, wxALL, 5 );
394
395 wxBoxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );
396
397 wxTextCtrl *item9 = new wxTextCtrl( parent, ID_BEM_SAVE_PATH, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
398 item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
399
400 wxButton *item10 = new wxButton( parent, ID_BROWSE_BEM_SAVE, wxT("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
401 item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
402
403 item5->Add( item8, 0, wxALL, 5 );
404
405 item2->Add( item5, 0, wxGROW|wxALL, 5 );
406
407 wxRadioButton *item11 = new wxRadioButton( parent, ID_LOAD_BEM, wxT("Load from file"), wxDefaultPosition, wxDefaultSize, 0 );
408 item2->Add( item11, 0, wxALL, 5 );
409
410 wxBoxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
411
412 wxTextCtrl *item13 = new wxTextCtrl( parent, ID_BEM_LOAD_PATH, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
413 item12->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
414
415 wxButton *item14 = new wxButton( parent, ID_BROWSE_BEM_LOAD, wxT("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
416 item12->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
417
418 item2->Add( item12, 0, wxALL, 5 );
419
420 item1->Add( item2, 0, wxGROW|wxALL, 5 );
421
422 item1->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
423
424 wxStaticBox *item16 = new wxStaticBox( parent, -1, wxT("Target directory:") );
425 wxStaticBoxSizer *item15 = new wxStaticBoxSizer( item16, wxVERTICAL );
426
427 wxBoxSizer *item17 = new wxBoxSizer( wxHORIZONTAL );
428
429 wxTextCtrl *item18 = new wxTextCtrl( parent, ID_TARGET, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
430 item17->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
431
432 wxButton *item19 = new wxButton( parent, ID_BROWSE_TARGET, wxT("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
433 item17->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
434
435 item15->Add( item17, 0, wxALL, 5 );
436
437 item1->Add( item15, 0, wxGROW|wxALL, 5 );
438
439 wxStaticLine *item20 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
440 item1->Add( item20, 0, wxGROW|wxALL, 5 );
441
442 wxBoxSizer *item21 = new wxBoxSizer( wxHORIZONTAL );
443
444 wxButton *item22 = new wxButton( parent, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
445 item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
446
447 wxButton *item23 = new wxButton( parent, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
448 item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
449
450 item1->Add( item21, 0, wxALL, 5 );
451
452 item0->Add( item1, 0, wxGROW|wxALL, 5 );
453
454 if (set_sizer)
455 {
456 parent->SetSizer( item0 );
457 if (call_fit)
458 item0->SetSizeHints( parent );
459 }
460
461 return item0;
462}
const string TRUE
Value used for true in attribute and element values.

References ID_BEM_LOAD_PATH, ID_BEM_SAVE_PATH, ID_BROWSE_BEM_LOAD, ID_BROWSE_BEM_SAVE, ID_BROWSE_TARGET, ID_GENERATE_BEM, ID_LINE, ID_LOAD_BEM, ID_SAVE_BEM, ID_TARGET, ID_VERILOG, ID_VHDL, and TRUE.

◆ loadICDecoderGeneratorPlugin()

ProGe::ICDecoderGeneratorPlugin * GenerateProcessorDialog::loadICDecoderGeneratorPlugin ( const std::string &  pluginFile,
const std::string &  pluginName 
)
private

Loads the given IC/decoder generator plugin.

Parameters
pluginFileThe file that implements the plugin.
pluginNameName of the plugin.

Definition at line 318 of file GenerateProcessorDialog.cc.

320 {
321
322 PluginTools pluginTool;
323
324 // initialize the plugin tool
325 vector<string> pluginPaths = Environment::icDecoderPluginPaths();
326 for (vector<string>::const_iterator iter = pluginPaths.begin();
327 iter != pluginPaths.end(); iter++) {
328 try {
329 pluginTool.addSearchPath(*iter);
330 } catch (const FileNotFound&) {
331 }
332 }
333
334 try {
335 pluginTool.registerModule(pluginFile);
336 } catch (Exception& e) {
337 wxString message = _T("Error loading IC/Decoder generator plugin:\n");
338 message.Append(WxConversion::toWxString(e.errorMessage()));
339 ErrorDialog dialog(this, message);
340 dialog.ShowModal();
341 return NULL;
342 }
343
346
347 pluginTool.importSymbol(
348 "create_generator_plugin_" + pluginName, creator, pluginFile);
349
350 ProGe::ICDecoderGeneratorPlugin* plugin = creator(machine_, *bem_);
351 return plugin;
352}
static std::vector< std::string > icDecoderPluginPaths(bool libraryPathsOnly=false)
std::string errorMessage() const
Definition Exception.cc:123
void importSymbol(const std::string &symbolName, T *&target, const std::string &module)
void addSearchPath(const std::string &searchPath)
void registerModule(const std::string &module)
static wxString toWxString(const std::string &source)

References PluginTools::addSearchPath(), bem_, Exception::errorMessage(), Environment::icDecoderPluginPaths(), PluginTools::importSymbol(), machine_, PluginTools::registerModule(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onBrowseBEMLoad()

void GenerateProcessorDialog::onBrowseBEMLoad ( wxCommandEvent &  event)
private

Event handler for the ben loading Browse... button.

Definition at line 264 of file GenerateProcessorDialog.cc.

264 {
265
266 wxTextCtrl* ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(ID_BEM_LOAD_PATH));
267
268 wxFileDialog dialog(
269 this, _T("Choose a file"), _T(""), _T(""),
270 _T("Binary Encoding Maps (*.bem)|*.bem|All files|*"),
271 (wxOPEN | wxFILE_MUST_EXIST));
272
273 if (dialog.ShowModal() == wxID_OK) {
274 if (bem_ != NULL) {
275 delete bem_;
276 bem_ = NULL;
277 ctrl->SetValue(_T(""));
278 }
279 string path = WxConversion::toString(dialog.GetPath());
280 try {
281 BEMSerializer serializer;
282 serializer.setSourceFile(path);
283 bem_ = serializer.readBinaryEncoding();
284 } catch (Exception& e) {
285 wxString message = _T("Error loading binary encoding map:\n");
286 message.Append(WxConversion::toWxString(e.errorMessage()));
287 ErrorDialog dialog(this, message);
288 dialog.ShowModal();
289 return;
290 }
291 ctrl->SetValue(dialog.GetPath());
292 }
293}
BinaryEncoding * readBinaryEncoding()
static std::string toString(const wxString &source)
void setSourceFile(const std::string &fileName)

References bem_, Exception::errorMessage(), ID_BEM_LOAD_PATH, BEMSerializer::readBinaryEncoding(), XMLSerializer::setSourceFile(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onBrowseBEMSave()

void GenerateProcessorDialog::onBrowseBEMSave ( wxCommandEvent &  event)
private

Event handler for the bem saving Browse... button.

Definition at line 245 of file GenerateProcessorDialog.cc.

245 {
246
247 wxString fileTypes = _T("Binary Encoding Map (.bem)|*.bem|");
248 wxFileDialog dialog(
249 this, _T("Choose a file"), _T("."), _T(""), fileTypes,
250 wxSAVE | wxOVERWRITE_PROMPT);
251
252 if (dialog.ShowModal() == wxID_OK) {
253 wxTextCtrl* ctrl = dynamic_cast<wxTextCtrl*>(
255 ctrl->SetValue(dialog.GetPath());
256 }
257}

References ID_BEM_SAVE_PATH.

◆ onBrowseTargetDir()

void GenerateProcessorDialog::onBrowseTargetDir ( wxCommandEvent &  event)
private

Event handler for the target directory Browse... button.

Definition at line 300 of file GenerateProcessorDialog.cc.

300 {
301
302 wxDirDialog dialog(
303 this, _T("Choose a directory"), _T(""), wxDD_NEW_DIR_BUTTON);
304
305 if (dialog.ShowModal() == wxID_OK) {
306 wxTextCtrl* ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(ID_TARGET));
307 ctrl->SetValue(dialog.GetPath());
308 }
309}

References ID_TARGET.

◆ onOK()

void GenerateProcessorDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the OK button.

Definition at line 111 of file GenerateProcessorDialog.cc.

111 {
112
113 std::ostringstream errorStream;
114 std::ostringstream warningStream;
115
116 // Binary encoding map.
117 if (dynamic_cast<wxRadioButton*>(
118 FindWindow(ID_GENERATE_BEM))->GetValue()) {
119
120 // Generate new bem.
121 if (bem_ != NULL) {
122 delete bem_;
123 bem_ = NULL;
124 }
125 BEMGenerator generator(machine_);
126 bem_ = generator.generate();
127
128 if (dynamic_cast<wxCheckBox*>(FindWindow(ID_SAVE_BEM))->IsChecked()) {
129 wxTextCtrl* ctrl =
130 dynamic_cast<wxTextCtrl*>(FindWindow(ID_BEM_SAVE_PATH));
131 string bemPath = WxConversion::toString(ctrl->GetValue());
132 if (bemPath != "") {
133 BEMSerializer serializer;
134 serializer.setDestinationFile(bemPath);
135 try {
136 serializer.writeBinaryEncoding(*bem_);
137 } catch (Exception& e) {
138 wxString message = _T("Error saving BEM:");
139 message.Append(WxConversion::toWxString(e.errorMessage()));
140 ErrorDialog dialog(this, message);
141 dialog.ShowModal();
142 return;
143 }
144 } else {
145 wxString message = _T("BEM target file not defined.");
146 ErrorDialog dialog(this, message);
147 dialog.ShowModal();
148 return;
149 }
150 }
151
152 } else {
153 if (bem_ == NULL) {
154 wxString message = _T("Error: No binary encoding map loaded.");
155 ErrorDialog dialog(this, message);
156 dialog.ShowModal();
157 return;
158 }
159 }
160
161 // Target directory.
162 wxTextCtrl* ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(ID_TARGET));
163 string targetDir = WxConversion::toString(ctrl->GetValue());
164 if (!FileSystem::fileExists(targetDir) ||
165 !FileSystem::fileIsDirectory(targetDir)) {
166
167 wxString message = _T("Target directory '");
168 message.Append(WxConversion::toWxString(targetDir));
169 message.Append(_T("' does not exist."));
170 ErrorDialog dialog(this, message);
171 dialog.ShowModal();
172 return;
173 }
174
176 options.outputDirectory = targetDir;
177 options.sharedOutputDirectory = targetDir;
178 options.generateTestbench = true;
179 options.validate();
180 // validate() would override this based on the given string option
181 wxRadioButton *VHDLItem = (wxRadioButton *) FindWindow(ID_VHDL);
182 options.language = (VHDLItem->GetValue()) ? ProGe::VHDL : ProGe::Verilog;
183
184 ProGe::ProGeUI progeUI;
185 try {
186 std::ostringstream verboseStream;
187
188
189 progeUI.loadMachine(machine_);
190 progeUI.loadBinaryEncoding(*bem_);
192 progeUI.generateProcessor(options, 1,
193 errorStream, warningStream, verboseStream);
194 } catch (Exception& e) {
195 wxString message = WxConversion::toWxString(e.errorMessage());
196 ErrorDialog dialog(this, message);
197 dialog.ShowModal();
198 return;
199 }
200
201 string testBenchDir = targetDir + FileSystem::DIRECTORY_SEPARATOR + "tb";
202 try {
203 progeUI.generateTestBench(options.language, testBenchDir, targetDir);
204 } catch (const Exception& e) {
205 std::cerr << e.errorMessage() << std::endl;
206 wxString message = WxConversion::toWxString(e.errorMessage());
207 ErrorDialog dialog(this, message);
208 dialog.ShowModal();
209 }
210
211 try {
212 progeUI.generateScripts(options.language, targetDir, targetDir,
213 targetDir, testBenchDir, "52390");
214 } catch (const Exception& e) {
215 std::cerr << "Warning: Processor Generator failed to "
216 << "generate simulation/compilation scripts."
217 << std::endl;
218 std::cerr << e.errorMessage() << std::endl;
219 }
220
221 string warningMessages = warningStream.str();
222 if (warningMessages != "") {
223 WarningDialog dialog(this, WxConversion::toWxString(warningMessages));
224 dialog.ShowModal();
225 }
226
227 string errorMessages = errorStream.str();
228 if (errorMessages != "") {
229 ErrorDialog dialog(this, WxConversion::toWxString(errorMessages));
230 dialog.ShowModal();
231 return;
232 }
233
234 wxString message = _T("Processor was succesfully generated.");
235 InformationDialog dialog(this, message);
236 dialog.ShowModal();
237
238 EndModal(wxID_OK);
239}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
void writeBinaryEncoding(const BinaryEncoding &bem)
static const std::string DIRECTORY_SEPARATOR
static bool fileIsDirectory(const std::string fileName)
static bool fileExists(const std::string fileName)
void loadBinaryEncoding(const BinaryEncoding &bem)
Definition ProGeUI.cc:170
void generateScripts(const ProGe::HDL language, const std::string &dstDir, const std::string &progeOutDir, const std::string &sharedOutDir, const std::string &testBenchDir, const std::string &simulationRuntime)
Definition ProGeUI.cc:416
void loadMachineImplementation(const IDF::MachineImplementation &idf)
Definition ProGeUI.cc:175
void generateProcessor(const ProGeOptions &options, int imemWidthInMAUs, std::ostream &errorStream, std::ostream &warningStream, std::ostream &verboseStream)
Definition ProGeUI.cc:298
void generateTestBench(const ProGe::HDL language, const std::string &dstDir, const std::string &progeOutDir)
Definition ProGeUI.cc:375
void loadMachine(const TTAMachine::Machine &adf)
Definition ProGeUI.cc:165
void setDestinationFile(const std::string &fileName)
Definition FUGen.hh:54
@ Verilog
Verilog.
Definition ProGeTypes.hh:42
@ VHDL
VHDL.
Definition ProGeTypes.hh:41

References bem_, FileSystem::DIRECTORY_SEPARATOR, Exception::errorMessage(), FileSystem::fileExists(), FileSystem::fileIsDirectory(), BEMGenerator::generate(), ProGe::ProGeUI::generateProcessor(), ProGe::ProGeUI::generateScripts(), ProGe::ProGeUI::generateTestBench(), ID_BEM_SAVE_PATH, ID_GENERATE_BEM, ID_SAVE_BEM, ID_TARGET, ID_VHDL, impl_, ProGe::ProGeUI::loadBinaryEncoding(), ProGe::ProGeUI::loadMachine(), ProGe::ProGeUI::loadMachineImplementation(), machine_, options, XMLSerializer::setDestinationFile(), WxConversion::toString(), WxConversion::toWxString(), ProGe::Verilog, ProGe::VHDL, and BEMSerializer::writeBinaryEncoding().

Here is the call graph for this function:

Member Data Documentation

◆ bem_

BinaryEncoding* GenerateProcessorDialog::bem_
private

Binary Encosing Map.

Definition at line 81 of file GenerateProcessorDialog.hh.

Referenced by loadICDecoderGeneratorPlugin(), onBrowseBEMLoad(), onOK(), and ~GenerateProcessorDialog().

◆ impl_

const IDF::MachineImplementation& GenerateProcessorDialog::impl_
private

Processor implementation definition.

Definition at line 79 of file GenerateProcessorDialog.hh.

Referenced by onOK().

◆ machine_

TTAMachine::Machine& GenerateProcessorDialog::machine_
private

Processor architecture.

Definition at line 77 of file GenerateProcessorDialog.hh.

Referenced by loadICDecoderGeneratorPlugin(), and onOK().


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