OpenASIP 2.2
Loading...
Searching...
No Matches
FUImplementationDialog.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file FUImplementationDialog.cc
26 *
27 * Implementation of FUImplementationDialog class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <wx/wx.h>
34#include <wx/listctrl.h>
35#include <wx/statline.h>
36#include <wx/spinctrl.h>
37
38#include <vector>
39#include <iostream>
40
42#include "FUImplementation.hh"
43#include "FUExternalPort.hh"
46
50
51#include "FunctionUnit.hh"
52#include "FUPort.hh"
53#include "HWOperation.hh"
54
57
58#include "InformationDialog.hh"
59#include "WxConversion.hh"
60#include "WidgetTools.hh"
61#include "Conversion.hh"
62#include "ErrorDialog.hh"
63
64using namespace HDB;
65using namespace TTAMachine;
66
67BEGIN_EVENT_TABLE(FUImplementationDialog, wxDialog)
69 ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort)
70
72 ID_ADD_EXTERNAL_PORT, FUImplementationDialog::onAddExternalPort)
74 ID_EDIT_EXTERNAL_PORT, FUImplementationDialog::onEditExternalPort)
76 ID_DELETE_EXTERNAL_PORT,
77 FUImplementationDialog::onDeleteExternalPort)
78
79 EVT_BUTTON(ID_ADD_PARAMETER, FUImplementationDialog::onAddParameter)
80 EVT_BUTTON(ID_EDIT_PARAMETER, FUImplementationDialog::onEditParameter)
81 EVT_BUTTON(ID_DELETE_PARAMETER, FUImplementationDialog::onDeleteParameter)
82
83#ifdef ALLOW_OPCODE_EDITING
86#endif
87
91 EVT_BUTTON(ID_MOVE_SOURCE_DOWN,
92 FUImplementationDialog::onMoveSourceFileDown)
93
95 ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection)
97 ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection)
99 ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortActivation)
100
102 ID_EXTERNAL_PORT_LIST,
103 FUImplementationDialog::onExternalPortSelection)
105 ID_EXTERNAL_PORT_LIST,
106 FUImplementationDialog::onExternalPortActivation)
108 ID_EXTERNAL_PORT_LIST,
109 FUImplementationDialog::onExternalPortSelection)
110
112 ID_PARAMETER_LIST, FUImplementationDialog::onParameterSelection)
114 ID_PARAMETER_LIST, FUImplementationDialog::onParameterActivation)
116 ID_PARAMETER_LIST, FUImplementationDialog::onParameterSelection)
117#ifdef ALLOW_OPCODE_EDITING
122#endif
124
126 ID_SOURCE_LIST, FUImplementationDialog::onSourceFileSelection)
128 ID_SOURCE_LIST, FUImplementationDialog::onSourceFileSelection)
129
131
132/**
133 * The Constructor.
134 *
135 * @param parent Parent window of the dialog.
136 * @param id Window identifier for the dialog window.
137 * @param implementation FU implementation to modify.
138 */
140 wxWindow* parent, wxWindowID id, FUImplementation& implementation,
141 const TTAMachine::FunctionUnit& architecture) :
142 wxDialog(parent, id, _T("Function Unit Implementation")),
143 implementation_(implementation), architecture_(architecture),
144 opcodeWarningShowed_(false) {
145
146 createContents(this, true, true);
147
148 // Initialize list widgets.
149 archPortList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_ARCH_PORT_LIST));
150 externalPortList_ =
151 dynamic_cast<wxListCtrl*>(FindWindow(ID_EXTERNAL_PORT_LIST));
152 parameterList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_PARAMETER_LIST));
153 sourceList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_SOURCE_LIST));
154 opcodeList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_OPCODE_LIST));
155
156 // Create columns in list widgets.
157 archPortList_->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 130);
158
159 archPortList_->InsertColumn(
160 1, _T("architecture port"), wxLIST_FORMAT_LEFT, 130);
161
162 externalPortList_->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 260);
163
164 parameterList_->InsertColumn(
165 0, _T("parameter"), wxLIST_FORMAT_LEFT, 180);
166
167 parameterList_->InsertColumn(
168 1, _T("value"), wxLIST_FORMAT_LEFT, 80);
169
170 opcodeList_->InsertColumn(
171 0, _T("operation"), wxLIST_FORMAT_LEFT, 180);
172
173 opcodeList_->InsertColumn(
174 1, _T("opcode"), wxLIST_FORMAT_LEFT, 80);
175
176 sourceList_->InsertColumn(
177 0, _T("source file"), wxLIST_FORMAT_LEFT, 260);
178
179 // Read string attributes from the FUImplementation object.
180 // If implementation attributes are empty, use default values
181 name_ = WxConversion::toWxString(implementation_.moduleName());
182 opcodePort_ = WxConversion::toWxString(implementation_.opcodePort());
183 if (implementation_.clkPort().empty()) {
184 clkPort_ = WxConversion::toWxString("clk");
185 } else {
186 clkPort_ = WxConversion::toWxString(implementation_.clkPort());
187 }
188 if (implementation_.rstPort().empty()) {
189 rstPort_ = WxConversion::toWxString("rstx");
190 } else {
191 rstPort_ = WxConversion::toWxString(implementation_.rstPort());
192 }
193 if (implementation_.glockPort().empty()) {
194 gLockPort_ = WxConversion::toWxString("glock");
195 } else {
196 gLockPort_ = WxConversion::toWxString(implementation_.glockPort());
197 }
198 gLockReqPort_ = WxConversion::toWxString(implementation_.glockReqPort());
199
200
201 // Set text field validators.
202 FindWindow(ID_NAME)->SetValidator(
203 wxTextValidator(wxFILTER_ASCII, &name_));
204 FindWindow(ID_OPCODE_PORT)->SetValidator(
205 wxTextValidator(wxFILTER_ASCII, &opcodePort_));
206 FindWindow(ID_CLK_PORT)->SetValidator(
207 wxTextValidator(wxFILTER_ASCII, &clkPort_));
208 FindWindow(ID_RST_PORT)->SetValidator(
209 wxTextValidator(wxFILTER_ASCII, &rstPort_));
210 FindWindow(ID_GLOCK_PORT)->SetValidator(
211 wxTextValidator(wxFILTER_ASCII, &gLockPort_));
212 FindWindow(ID_GLOCK_REQ_PORT)->SetValidator(
213 wxTextValidator(wxFILTER_ASCII, &gLockReqPort_));
214
215
216 // Disable conditional buttons initially.
217 FindWindow(ID_EDIT_ARCH_PORT)->Disable();
218 FindWindow(ID_EDIT_EXTERNAL_PORT)->Disable();
219 FindWindow(ID_DELETE_EXTERNAL_PORT)->Disable();
220 FindWindow(ID_EDIT_PARAMETER)->Disable();
221 FindWindow(ID_DELETE_PARAMETER)->Disable();
222#ifdef ALLOW_OPCODE_EDITING
223 FindWindow(ID_SET_OPCODE)->Disable();
224 FindWindow(ID_CLEAR_OPCODE)->Disable();
225#endif
226 FindWindow(ID_DELETE_SOURCE)->Disable();
227 FindWindow(ID_MOVE_SOURCE_UP)->Disable();
228 FindWindow(ID_MOVE_SOURCE_DOWN)->Disable();
229
230 update(true);
231}
232
233/**
234 * The Destructor.
235 */
238
239/**
240 * Update handler
241 * Updates UI values to reflect new state. If called from constructor,
242 * fills default values for opcodes.
243 *
244 * @param onInit Set true whe called from constructor
245 */
246void
248
249 // Update architecture port list.
250 archPortList_->DeleteAllItems();
251 for (int i = 0; i < implementation_.architecturePortCount(); i++) {
252
253 wxString portName = WxConversion::toWxString(
255
256 std::string archPortName =
258
259 const FUPort* port = architecture_.operationPort(archPortName);
260
261 // Append operation operands bound to this port to the
262 // otherwise meaningless port name.
263 archPortName += ":";
264 for (int j = 0; j < architecture_.operationCount(); j++) {
265 const HWOperation* operation = architecture_.operation(j);
266 if (operation->isBound(*port)) {
267
268 std::string io = Conversion::toString(operation->io(*port));
269 std::string operationName = operation->name();
270 archPortName =
271 archPortName + " " + operationName + "[" + io + "]";
272 }
273 }
274 archPortList_->InsertItem(i, portName);
275 archPortList_->SetItem(i, 1, WxConversion::toWxString(archPortName));
276 }
277
278 // Update external port list.
279 externalPortList_->DeleteAllItems();
280 for (int i = 0; i < implementation_.externalPortCount(); i++) {
281 wxString portName = WxConversion::toWxString(
283 externalPortList_->InsertItem(i, portName);
284 }
285
286 // Update parameter list.
287 parameterList_->DeleteAllItems();
288 for (int i = 0; i < implementation_.parameterCount(); i++) {
289 const FUImplementation::Parameter parameter =
291 wxString param = WxConversion::toWxString(parameter.type);
292 param.Append(_T(": "));
293 param.Append(WxConversion::toWxString(parameter.name));
294 parameterList_->InsertItem(i, param);
295 parameterList_->SetItem(
296 i, 1, WxConversion::toWxString(parameter.value));
297 }
298
299 // Update source file list.
300 sourceList_->DeleteAllItems();
301 for (int i = 0; i < implementation_.implementationFileCount(); i++) {
302 wxString fileName = WxConversion::toWxString(
304 sourceList_->InsertItem(i, fileName);
305 }
307 sourceList_->SetColumnWidth(0, wxLIST_AUTOSIZE);
308 }
309
310 // Update operation list.
311 opcodeList_->DeleteAllItems();
312 // arrange operations in alphabetical order
313 std::set<std::string> opcodeSet;
314 for (int i = 0; i < architecture_.operationCount(); i++) {
315 std::string operation = architecture_.operation(i)->name();
316 opcodeSet.insert(operation);
317 }
318 // operation opcodes should be generated according to the alphabetical
319 // order
320 int index = 0;
321 for (std::set<std::string>::iterator i = opcodeSet.begin();
322 i != opcodeSet.end(); i++) {
323 std::string operation = *i;
324 wxString opcode = _T("");
325 if (implementation_.hasOpcode(operation)) {
326 int opcodeIndex = implementation_.opcode(operation);
327 if (opcodeIndex != index && !opcodeWarningShowed_) {
328#ifdef ALLOW_OPCODE_EDITING
329 // show warning about future incompatibility
330 wxMessageDialog errorDialog(
331 this,
332 _T("Illegal opcodes. Design might not work in future. "
333 "Opcode IDs must be generated according to the "
334 "alphabetical order of operation names. Please fix "
335 "FU's vhdl code and HDB entry"),
336 _T("Illegal opcodes"), wxOK);
337#else
338 // operations must be in alphaberical order
339 wxMessageDialog errorDialog(
340 this,
341 _T("Illegal opcodes. Design won't work. Opcode IDs must "
342 "be generated according to the alphabetical order of "
343 "operation names."),
344 _T("Illegal opcodes"), wxOK);
345#endif
347 errorDialog.ShowModal();
348 }
349 opcode =
351 }
352#ifndef ALLOW_OPCODE_EDITING
353 else {
354 // add default opcode (without ability to modify it)
355 opcode = WxConversion::toWxString(index);
356 }
357#else
358 else if (onInit) {
359 // add default opcode
360 opcode = WxConversion::toWxString(index);
361 implementation_.setOpcode(operation, index);
362 }
363#endif
364 wxString operationName = WxConversion::toWxString(operation);
365 opcodeList_->InsertItem(index, operationName);
366 opcodeList_->SetItem(index, 1, opcode);
367 ++index;
368 }
369
370 wxListEvent dummy;
374}
375
376/**
377 * Event handler for the edit architecture port button.
378 *
379 * Opens a FUPortImplementationdialog for modifying the selected architecure
380 * port.
381 */
382void
384
386
387 if (port == NULL) {
388 return;
389 }
390
391 const BaseFUPort& archPort =
393
394 FUPortImplementationDialog dialog(this, -1, *port, archPort);
395
396 dialog.ShowModal();
397 update();
398}
399
400
401/**
402 * Event handler for the architecture port list selection changes.
403 *
404 * Updates edit/delete architecture port enabeld/disabled states.
405 */
406void
408 if (selectedArchPort() == NULL) {
409 FindWindow(ID_EDIT_ARCH_PORT)->Disable();
410 } else {
411 FindWindow(ID_EDIT_ARCH_PORT)->Enable();
412 }
413}
414
415/**
416 * Event handler for the architecture port list activateion
417 *
418 * Opens a FUPortImplementationdialog for modifying the selected architecure
419 * port.
420 */
421void
424
425 assert(port != NULL);
426
427 const BaseFUPort& archPort =
429
430 FUPortImplementationDialog dialog(this, -1, *port, archPort);
431
432 dialog.ShowModal();
433 update();
434}
435
436
437/**
438 * Event handler for the add external port button.
439 *
440 * Opens a FUExternalPortDialog for adding a new external port.
441 */
442void
444
445 FUExternalPort* port = new FUExternalPort(
446 "", IN, "", "", implementation_);
447
448 FUExternalPortDialog dialog(this, -1, *port, implementation_);
449
450 if (dialog.ShowModal() != wxID_OK) {
452 return;
453 }
454
455 update();
456}
457
458
459/**
460 * Event handler for the edit external port button.
461 *
462 * Opens a FUExternalPort for modifying the selected external port.
463 */
464void
466
468
469 if (port == NULL) {
470 return;
471 }
472
473 FUExternalPortDialog dialog(this, -1, *port, implementation_);
474
475 dialog.ShowModal();
476 update();
477}
478
479/**
480 * Event handler for the activate external port list item
481 *
482 * Opens a FUExternalPort for modifying the selected external port.
483 */
484void
486
488 assert(port != NULL);
489
490 FUExternalPortDialog dialog(this, -1, *port, implementation_);
491
492 dialog.ShowModal();
493 update();
494}
495
496
497
498/**
499 * Event handler for the delete external port button.
500 *
501 * Deletes the selected external port.
502 */
503void
505
507
508 if (port == NULL) {
509 return;
510 }
511
513 update();
514}
515
516/**
517 * Event handler for the external port list selection changes.
518 *
519 * Updates edit/delete external port enabeld/disabled states.
520 */
521void
523 if (selectedExternalPort() == NULL) {
526 } else {
529 }
530}
531
532
533/**
534 * Event handler for the add parameter button.
535 *
536 * Opens a ImplementationParameterDialog for adding a new parameter.
537 */
538void
540
542
543 ImplementationParameterDialog dialog(this, -1, parameter);
544
545 if (dialog.ShowModal() != wxID_OK) {
546 return;
547 }
548
549 try {
551 parameter.name, parameter.type, parameter.value);
552 } catch (IllegalParameters& e) {
553 wxString message = _T("FU implementation already contains ");
554 message.Append(_T("a parameter\nwith name '"));
555 message.Append(WxConversion::toWxString(parameter.name));
556 message.Append(_T("'."));
557 ErrorDialog dialog(this, message);
558 dialog.ShowModal();
559 return;
560 }
561
562 update();
563}
564
565
566/**
567 * Event handler for the edit parameter button.
568 *
569 * Opens a FUImplementationParamaeterDialog for modifying the selected
570 * parameter.
571 */
572void
574
576 std::string oldName = parameter.name;
577
578 ImplementationParameterDialog dialog(this, -1, parameter);
579
580 if (dialog.ShowModal() == wxID_OK) {
583 parameter.name, parameter.type, parameter.value);
584
585 // update external port parameter dependencies if needed
586 for (int i = 0; i < implementation_.externalPortCount(); i++) {
588 if (port.unsetParameterDependency(oldName)) {
589 port.setParameterDependency(parameter.name);
590 }
591 }
592 }
593
594 update();
595}
596
597/**
598 * Event handler for the parameter list activateion.
599 *
600 * Opens a FUImplementationParamaeterDialog for modifying the selected
601 * parameter.
602 */
603void
605
607 std::string oldName = parameter.name;
608
609 ImplementationParameterDialog dialog(this, -1, parameter);
610
611 if (dialog.ShowModal() == wxID_OK) {
614 parameter.name, parameter.type, parameter.value);
615
616 // update external port parameter dependencies if needed
617 for (int i = 0; i < implementation_.externalPortCount(); i++) {
619 if (port.unsetParameterDependency(oldName)) {
620 port.setParameterDependency(parameter.name);
621 }
622 }
623 }
624
625 update();
626}
627
628/**
629 * Event handler for the delete parameter button.
630 *
631 * Deletes the selected parameter.
632 */
633void
635
637
639
640 // update external port parameter dependencies
641 for (int i = 0; i < implementation_.externalPortCount(); i++) {
643 port.unsetParameterDependency(parameter.name);
644 }
645
646 update();
647}
648
649/**
650 * Event handler for the parameter list selection changes.
651 *
652 * Updates edit/delete parameter enabled/disabled states.
653 */
654void
656 if (selectedParameter().name == "") {
658 FindWindow(ID_EDIT_PARAMETER)->Disable();
659 } else {
661 FindWindow(ID_EDIT_PARAMETER)->Enable();
662 }
663}
664
665
666
667
668/**
669 * Returns pointer to the architecture port selected in the architecture port
670 * list.
671 *
672 * @return Selected architecture port.
673 */
676
677 long item = -1;
678 item = archPortList_->GetNextItem(
679 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
680
681 if (item == -1) {
682 return NULL;
683 }
684
685 return &implementation_.architecturePort(item);
686}
687
688/**
689 * Returns pointer to the external port selected in the external port list.
690 *
691 * @return Selected external port.
692 */
695
696 long item = -1;
697 item = externalPortList_->GetNextItem(
698 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
699
700 if (item == -1) {
701 return NULL;
702 }
703
704 return &implementation_.externalPort(item);
705}
706
707/**
708 * Returns copy of the selected parameter in the parameter list.
709 *
710 * @return Selected parameter.
711 */
714
715 long item = -1;
716 item = parameterList_->GetNextItem(
717 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
718
719 if (item == -1) {
720 FUImplementation::Parameter empty = {"", "", ""};
721 return empty;
722 }
723
724 return implementation_.parameter(item);
725}
726
727#ifdef ALLOW_OPCODE_EDITING
728/**
729 * Event handler for the opcode list selection changes.
730 *
731 * Updates the enabled/disabled state of the set and clear opcode buttons.
732 */
733void
735 std::string operation = WidgetTools::lcStringSelection(opcodeList_, 0);
736 if (operation == "") {
737 FindWindow(ID_SET_OPCODE)->Disable();
738 FindWindow(ID_CLEAR_OPCODE)->Disable();
739 } else {
740 FindWindow(ID_SET_OPCODE)->Enable();
741 if (implementation_.hasOpcode(operation)) {
742 FindWindow(ID_CLEAR_OPCODE)->Enable();
743 } else {
744 FindWindow(ID_CLEAR_OPCODE)->Disable();
745 }
746 }
747}
748
749
750/**
751 * Event handler for the clear opcode button.
752 *
753 * Clears the opcode of the selected operation.
754 */
755void
757
758 std::string operation = WidgetTools::lcStringSelection(opcodeList_, 0);
759
760 if (operation == "") {
761 return;
762 }
763
764 implementation_.unsetOpcode(operation);
765
766 update();
767}
768
769/**
770 * Event handler for the set opcode button.
771 *
772 * Sets the opcode for the selected operation.
773 */
774void
776
777 std::string operation = WidgetTools::lcStringSelection(opcodeList_, 0);
778
779 if (operation == "") {
780 return;
781 }
782
783 int opcode = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_OPCODE))->GetValue();
784
785 for (int i = 0; i < architecture_.operationCount(); i++) {
786 std::string operation = architecture_.operation(i)->name();
787 if (implementation_.hasOpcode(operation) &&
788 implementation_.opcode(operation) == opcode) {
789
790 wxString message = _T("Opcode ");
791 message.Append(WxConversion::toWxString(opcode));
792 message.Append(_T(" is already used by operation "));
793 message.Append(WxConversion::toWxString(operation));
794 message.Append(_T("."));
795 InformationDialog dialog(this, message);
796 dialog.ShowModal();
797 return;
798 }
799 }
800
801 implementation_.setOpcode(operation, opcode);
802
803 update();
804}
805#endif
806
807/**
808 * Event handler for the add source file button.
809 *
810 * Opens a source file dialog for adding a new implementation file to the list.
811 */
812void
814
817
818 BlockImplementationFileDialog dialog(this, -1, *file);
819
820 if (dialog.ShowModal() == wxID_OK) {
822 update();
823 } else {
824 delete file;
825 }
826
827 FindWindow(ID_DELETE_SOURCE)->Disable();
828 FindWindow(ID_MOVE_SOURCE_UP)->Disable();
830}
831
832/**
833 * Event handler for the delete source file button.
834 *
835 * Removes the selected source file.
836 */
837void
839
840 std::string fileName = WidgetTools::lcStringSelection(sourceList_, 0);
841
842 for (int i = 0; i < implementation_.implementationFileCount(); i++) {
844 if (file.pathToFile() == fileName) {
846 }
847 }
848
849 FindWindow(ID_DELETE_SOURCE)->Disable();
850 FindWindow(ID_MOVE_SOURCE_UP)->Disable();
852
853 update();
854}
855
856/**
857 * Event handler for the move source file up button.
858 *
859 * Moves the selected source file up on the files list.
860 */
861void
863
865 std::string fileName =
867 std::vector<std::string> pathToFileList;
868 int originalImplementationFileCount =
870
871 for (int i = 0; i < originalImplementationFileCount; i++) {
873 pathToFileList.push_back(file.pathToFile());
875 }
876
877 for (unsigned int i = 1; i < pathToFileList.size(); i++) {
878 if (pathToFileList.at(i) == fileName) {
879 pathToFileList.erase(pathToFileList.begin() + i);
880 pathToFileList.insert(
881 pathToFileList.begin() + i - 1, fileName);
882 break;
883 }
884 }
885
886 for (unsigned int i = 0; i < pathToFileList.size(); i++) {
888 new BlockImplementationFile(pathToFileList.at(i),
891 }
892
893 pathToFileList.clear();
894 update();
895
896 for (int i = 0; i < implementation_.implementationFileCount(); i++) {
897 if (implementation_.file(i).pathToFile() == fileName) {
898 sourceList_->SetItemState(i, wxLIST_STATE_SELECTED,
899 wxLIST_STATE_SELECTED);
900 }
901 }
902 }
903}
904
905/**
906 * Event handler for the move source file down button.
907 *
908 * Moves the selected source file down on the files list.
909 */
910void
913 std::string fileName =
915 std::vector<std::string> pathToFileList;
916
917 int originalImplementationFileCount =
919
920 for (int i = 0; i < originalImplementationFileCount; i++) {
922 pathToFileList.push_back(file.pathToFile());
924 }
925
926 for (unsigned int i = 0; i < (pathToFileList.size() - 1); i++) {
927 if (pathToFileList.at(i) == fileName) {
928 pathToFileList.erase(pathToFileList.begin() + i);
929 pathToFileList.insert(
930 pathToFileList.begin() + i + 1, fileName);
931 break;
932 }
933 }
934
935 for (unsigned int i = 0; i < pathToFileList.size(); i++) {
937 new BlockImplementationFile(pathToFileList.at(i),
940 }
941
942 pathToFileList.clear();
943 update();
944
945 for (int i = 0; i < implementation_.implementationFileCount(); i++) {
946 if (implementation_.file(i).pathToFile() == fileName) {
947 sourceList_->SetItemState(i, wxLIST_STATE_SELECTED,
948 wxLIST_STATE_SELECTED);
949 }
950 }
951 }
952}
953
954/**
955 * Event handler for the source file list selection changes.
956 *
957 * Updates delete source file and move up/down buttons enabled/disabled
958 * states.
959 */
960void
963 FindWindow(ID_DELETE_SOURCE)->Disable();
964 FindWindow(ID_MOVE_SOURCE_UP)->Disable();
966 } else {
967 FindWindow(ID_DELETE_SOURCE)->Enable();
968 FindWindow(ID_MOVE_SOURCE_UP)->Enable();
970 }
971}
972
973/**
974 * Event handler for the OK button.
975 *
976 * Validates the dialog data and updates the FUImplementation object string
977 * attributes.
978 */
979void
981
982 TransferDataFromWindow();
983
984 name_ = name_.Trim(true).Trim(false);
985 clkPort_ = clkPort_.Trim(true).Trim(false);
986 rstPort_ = rstPort_.Trim(true).Trim(false);
987 gLockPort_ = gLockPort_.Trim(true).Trim(false);
988 gLockReqPort_ = gLockReqPort_.Trim(true).Trim(false);
989 opcodePort_ = opcodePort_.Trim(true).Trim(false);
990
991 if (name_.IsEmpty()) {
992 wxString message = _T("Name field must not be empty.");
993 InformationDialog dialog(this, message);
994 dialog.ShowModal();
995 return;
996 }
997
998 for (int i = 0; i < implementation_.architecturePortCount(); i++) {
999 if (implementation_.architecturePort(i).name() == "") {
1000 wxString message =
1001 _T("No name specified for the architecture port '");
1002 std::string port =
1004 message.Append(WxConversion::toWxString(port));
1005 message.Append(_T("'."));
1006 InformationDialog dialog(this, message);
1007 dialog.ShowModal();
1008 return;
1009 }
1010 for (int k = i+1; k < implementation_.architecturePortCount(); k++) {
1013 wxString message =
1014 _T("Ports '");
1015 std::string port =
1017 message.Append(WxConversion::toWxString(port));
1018 message.Append(_T("' and '"));
1019 port =
1021 message.Append(WxConversion::toWxString(port));
1022 message.Append(_T("' have the same name."));
1023 InformationDialog dialog(this, message);
1024 dialog.ShowModal();
1025 return;
1026 }
1027 }
1028 }
1029#ifdef ALLOW_OPCODE_EDITING
1030 if (architecture_.operationCount() > 1) {
1031 for (int i = 0; i < architecture_.operationCount(); i++) {
1033 architecture_.operation(i)->name())) {
1034
1035 wxString message =
1036 _T("No opcode specified for the operation '");
1037 std::string operation = architecture_.operation(i)->name();
1038 message.Append(WxConversion::toWxString(operation));
1039 message.Append(_T("'."));
1040 InformationDialog dialog(this, message);
1041 dialog.ShowModal();
1042 return;
1043 }
1044 }
1045 }
1046#endif
1047
1054
1055 EndModal(wxID_OK);
1056
1057}
1058
1059
1060/**
1061 * Creates the dialog contents.
1062 */
1063wxSizer*
1065 wxWindow *parent, bool call_fit, bool set_sizer) {
1066 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1067
1068 wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
1069
1070 wxFlexGridSizer *item2 = new wxFlexGridSizer( 2, 0, 0 );
1071
1072 wxStaticText *item3 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
1073 item2->Add( item3, 0, wxALIGN_RIGHT|wxALL, 5 );
1074
1075 wxTextCtrl *item4 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(160,-1), 0 );
1076 item2->Add( item4, 0, wxGROW|wxALL, 5 );
1077
1078 wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_OPCODE_PORT_NAME, wxT("Opcode port:"), wxDefaultPosition, wxDefaultSize, 0 );
1079 item2->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
1080
1081 wxTextCtrl *item6 = new wxTextCtrl( parent, ID_OPCODE_PORT, wxT(""), wxDefaultPosition, wxSize(160,-1), 0 );
1082 item2->Add( item6, 0, wxGROW|wxALL, 5 );
1083
1084 wxStaticText *item7 = new wxStaticText( parent, ID_LABEL_CLK_PORT, wxT("Clock port:"), wxDefaultPosition, wxDefaultSize, 0 );
1085 item2->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
1086
1087 wxTextCtrl *item8 = new wxTextCtrl( parent, ID_CLK_PORT, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
1088 item2->Add( item8, 0, wxGROW|wxALL, 5 );
1089
1090 wxStaticText *item9 = new wxStaticText( parent, ID_LABEL_GLOCK_PORT, wxT("Global lock port:"), wxDefaultPosition, wxDefaultSize, 0 );
1091 item2->Add( item9, 0, wxALIGN_RIGHT|wxALL, 5 );
1092
1093 wxTextCtrl *item10 = new wxTextCtrl( parent, ID_GLOCK_PORT, wxT(""), wxDefaultPosition, wxSize(150,-1), 0 );
1094 item2->Add( item10, 0, wxGROW|wxALL, 5 );
1095
1096 wxStaticText *item11 = new wxStaticText( parent, ID_LABEL_RST_PORT, wxT("Reset port:"), wxDefaultPosition, wxDefaultSize, 0 );
1097 item2->Add( item11, 0, wxALIGN_RIGHT|wxALL, 5 );
1098
1099 wxTextCtrl *item12 = new wxTextCtrl( parent, ID_RST_PORT, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
1100 item2->Add( item12, 0, wxGROW|wxALL, 5 );
1101
1102 wxStaticText *item13 = new wxStaticText( parent, ID_LABEL_GLOCK_REQ_PORT, wxT("Global lock req. port:"), wxDefaultPosition, wxDefaultSize, 0 );
1103 item2->Add( item13, 0, wxALIGN_RIGHT|wxALL, 5 );
1104
1105 wxTextCtrl *item14 = new wxTextCtrl( parent, ID_GLOCK_REQ_PORT, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
1106 item2->Add( item14, 0, wxGROW|wxALL, 5 );
1107
1108 item1->Add( item2, 0, wxALL, 5 );
1109
1110 wxStaticBox *item16 = new wxStaticBox( parent, -1, wxT("Source files:") );
1111
1112 wxStaticBoxSizer *item15 = new wxStaticBoxSizer( item16, wxVERTICAL );
1113
1114 wxFlexGridSizer *item17_1 = new wxFlexGridSizer( 2, 0, 0 );
1115
1116 wxListCtrl *item17 = new wxListCtrl( parent, ID_SOURCE_LIST, wxDefaultPosition, wxSize(300,150), wxLC_REPORT|wxSUNKEN_BORDER );
1117 item17_1->Add( item17, 0, wxGROW|wxALL, 5 );
1118
1119 wxBoxSizer *item17_3 = new wxBoxSizer( wxVERTICAL );
1120
1121 wxButton *item60 = new wxButton( parent, ID_MOVE_SOURCE_UP, wxT("▴"), wxDefaultPosition, wxSize(20, 20), 0 );
1122 item17_3->Add( item60, 0, wxALIGN_CENTER|wxALL, 5 );
1123
1124 wxButton *item61 = new wxButton( parent, ID_MOVE_SOURCE_DOWN, wxT("▾"), wxDefaultPosition, wxSize(20, 20), 0 );
1125 item17_3->Add( item61, 0, wxALIGN_CENTER|wxALL, 5 );
1126
1127 item17_1->Add( item17_3, 0, wxALIGN_RIGHT|wxALIGN_CENTER, 5 );
1128
1129 item15->Add( item17_1, 0, wxGROW|wxALL, 5 );
1130
1131 wxBoxSizer *item18 = new wxBoxSizer( wxHORIZONTAL );
1132
1133 wxButton *item19 = new wxButton( parent, ID_ADD_SOURCE, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1134 item18->Add( item19, 0, wxALL, 5 );
1135
1136 wxButton *item20 = new wxButton( parent, ID_DELETE_SOURCE, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1137 item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
1138
1139 item15->Add( item18, 0, 0, 5 );
1140
1141 item1->Add( item15, 0, wxGROW|wxALL, 5 );
1142
1143 wxStaticBox *item22 = new wxStaticBox( parent, -1, wxT("Architecture ports:") );
1144 wxStaticBoxSizer *item21 = new wxStaticBoxSizer( item22, wxVERTICAL );
1145
1146 wxListCtrl *item23 = new wxListCtrl( parent, ID_ARCH_PORT_LIST, wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
1147 item21->Add( item23, 0, wxGROW|wxALL, 5 );
1148
1149 wxBoxSizer *item24 = new wxBoxSizer( wxHORIZONTAL );
1150
1151 wxButton *item25 = new wxButton( parent, ID_EDIT_ARCH_PORT, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1152 item24->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
1153
1154 item21->Add( item24, 0, 0, 5 );
1155
1156 item1->Add( item21, 0, wxGROW|wxALL, 5 );
1157
1158 wxStaticBox *item27 = new wxStaticBox( parent, -1, wxT("Opcodes:") );
1159 wxStaticBoxSizer *item26 = new wxStaticBoxSizer( item27, wxVERTICAL );
1160
1161 wxListCtrl *item28 = new wxListCtrl( parent, ID_OPCODE_LIST, wxDefaultPosition, wxSize(260,120), wxLC_REPORT|wxSUNKEN_BORDER );
1162 item26->Add( item28, 0, wxGROW|wxALL, 5 );
1163
1164 wxBoxSizer *item29 = new wxBoxSizer( wxHORIZONTAL );
1165#ifdef ALLOW_OPCODE_EDITING
1166 wxSpinCtrl *item30 = new wxSpinCtrl( parent, ID_OPCODE, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 100, 0 );
1167 item29->Add( item30, 0, wxALIGN_CENTER|wxALL, 5 );
1168
1169 wxButton *item31 = new wxButton( parent, ID_SET_OPCODE, wxT("Set"), wxDefaultPosition, wxDefaultSize, 0 );
1170 item29->Add( item31, 0, wxALIGN_CENTER|wxALL, 5 );
1171
1172 wxButton *item32 = new wxButton( parent, ID_CLEAR_OPCODE, wxT("Clear"), wxDefaultPosition, wxDefaultSize, 0 );
1173 item29->Add( item32, 0, wxALIGN_CENTER|wxALL, 5 );
1174#endif
1175 item26->Add( item29, 0, 0, 5 );
1176
1177 item1->Add( item26, 0, wxGROW|wxALL, 5 );
1178
1179 wxStaticBox *item34 = new wxStaticBox( parent, -1, wxT("External ports:") );
1180 wxStaticBoxSizer *item33 = new wxStaticBoxSizer( item34, wxVERTICAL );
1181
1182 wxListCtrl *item35 = new wxListCtrl( parent, ID_EXTERNAL_PORT_LIST, wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
1183 item33->Add( item35, 0, wxGROW|wxALL, 5 );
1184
1185 wxBoxSizer *item36 = new wxBoxSizer( wxHORIZONTAL );
1186
1187 wxButton *item37 = new wxButton( parent, ID_ADD_EXTERNAL_PORT, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1188 item36->Add( item37, 0, wxALL, 5 );
1189
1190 wxButton *item38 = new wxButton( parent, ID_EDIT_EXTERNAL_PORT, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1191 item36->Add( item38, 0, wxALIGN_CENTER|wxALL, 5 );
1192
1193 wxButton *item39 = new wxButton( parent, ID_DELETE_EXTERNAL_PORT, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1194 item36->Add( item39, 0, wxALIGN_CENTER|wxALL, 5 );
1195
1196 item33->Add( item36, 0, wxALIGN_CENTER, 5 );
1197
1198 item1->Add( item33, 0, wxGROW|wxALL, 5 );
1199
1200 wxStaticBox *item41 = new wxStaticBox( parent, -1, wxT("Parameters:") );
1201 wxStaticBoxSizer *item40 = new wxStaticBoxSizer( item41, wxVERTICAL );
1202
1203 wxListCtrl *item42 = new wxListCtrl( parent, ID_PARAMETER_LIST, wxDefaultPosition, wxSize(260,120), wxLC_REPORT|wxSUNKEN_BORDER );
1204 item40->Add( item42, 0, wxGROW|wxALL, 5 );
1205
1206 wxBoxSizer *item43 = new wxBoxSizer( wxHORIZONTAL );
1207
1208 wxButton *item44 = new wxButton( parent, ID_ADD_PARAMETER, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
1209 item43->Add( item44, 0, wxALIGN_CENTER|wxALL, 5 );
1210
1211 wxButton *item45 = new wxButton( parent, ID_EDIT_PARAMETER, wxT("Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
1212 item43->Add( item45, 0, wxALIGN_CENTER|wxALL, 5 );
1213
1214 wxButton *item46 = new wxButton( parent, ID_DELETE_PARAMETER, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1215 item43->Add( item46, 0, wxALIGN_CENTER|wxALL, 5 );
1216
1217 item40->Add( item43, 0, 0, 5 );
1218
1219 item1->Add( item40, 0, wxGROW|wxALL, 5 );
1220
1221 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
1222
1223 wxStaticLine *item47 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
1224 item0->Add( item47, 0, wxGROW|wxALL, 5 );
1225
1226 wxBoxSizer *item48 = new wxBoxSizer( wxHORIZONTAL );
1227
1228 wxButton *item49 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
1229 item48->Add( item49, 0, wxALIGN_CENTER|wxALL, 5 );
1230
1231 wxButton *item50 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
1232 item48->Add( item50, 0, wxALIGN_CENTER|wxALL, 5 );
1233
1234 item0->Add( item48, 0, wxALL, 5 );
1235
1236 if (set_sizer)
1237 {
1238 parent->SetSizer( item0 );
1239 if (call_fit)
1240 item0->SetSizeHints( parent );
1241 }
1242
1243 return item0;
1244}
#define assert(condition)
END_EVENT_TABLE() using namespace IDF
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection EVT_LIST_ITEM_DESELECTED(ID_ARCH_PORT_LIST, FUImplementationDialog::onArchPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_ARCH_PORT_LIST
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation EVT_LIST_ITEM_SELECTED(ID_EXTERNAL_PORT_LIST, FUImplementationDialog::onExternalPortSelection) EVT_LIST_ITEM_ACTIVATED(ID_EXTERNAL_PORT_LIST
FUImplementationDialog::onAddExternalPort FUImplementationDialog::onDeleteExternalPort FUImplementationDialog::onArchPortSelection FUImplementationDialog::onArchPortActivation FUImplementationDialog::onExternalPortActivation FUImplementationDialog::onParameterSelection EVT_LIST_ITEM_ACTIVATED(ID_PARAMETER_LIST, FUImplementationDialog::onParameterActivation) EVT_LIST_ITEM_DESELECTED(ID_PARAMETER_LIST
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
find Finds info of the inner loops in the false
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
static std::string toString(const T &source)
wxListCtrl * sourceList_
Pointer to the source file list widget.
void onOpcodeSelection(wxListEvent &event)
const TTAMachine::FunctionUnit & architecture_
Function unit architecture the FUImplementation implements.
void onArchPortActivation(wxListEvent &event)
void onAddParameter(wxCommandEvent &event)
void onMoveSourceFileDown(wxCommandEvent &event)
void onAddExternalPort(wxCommandEvent &event)
void onAddSourceFile(wxCommandEvent &event)
void onDeleteSourceFile(wxCommandEvent &event)
wxListCtrl * opcodeList_
Pointer to the opcode list widget.
void onClearOpcode(wxCommandEvent &event)
void onDeleteExternalPort(wxCommandEvent &event)
void onParameterActivation(wxListEvent &event)
HDB::FUExternalPort * selectedExternalPort()
void onSetOpcode(wxCommandEvent &event)
wxListCtrl * parameterList_
Pointer to the parameter list widget.
void onArchPortSelection(wxListEvent &event)
void onSourceFileSelection(wxListEvent &event)
void onExternalPortSelection(wxListEvent &event)
void update(bool onInit=false)
void onOK(wxCommandEvent &event)
void onMoveSourceFileUp(wxCommandEvent &event)
wxListCtrl * externalPortList_
Pointer to the external port list widget.
void onEditParameter(wxCommandEvent &event)
void onEditArchitecturePort(wxCommandEvent &event)
void onEditExternalPort(wxCommandEvent &event)
HDB::FUImplementation & implementation_
FU Implementation to modify.
void onExternalPortActivation(wxListEvent &event)
wxListCtrl * archPortList_
Pointer to the architecture port list widget.
void onDeleteParameter(wxCommandEvent &event)
HDB::FUPortImplementation * selectedArchPort()
HDB::FUImplementation::Parameter selectedParameter()
void onParameterSelection(wxListEvent &event)
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
bool setParameterDependency(const std::string &parameter)
std::string name() const
bool unsetParameterDependency(const std::string &parameter)
void removeParameter(const std::string &name)
FUPortImplementation & architecturePort(int index) const
void setGlockReqPort(const std::string &name)
Parameter parameter(int index) const
void unsetOpcode(const std::string &operation)
void setOpcodePort(const std::string &name)
bool hasOpcode(const std::string &operation) const
void deleteExternalPort(FUExternalPort *port)
void addParameter(const std::string &name, const std::string &type, const std::string &value)
FUExternalPort & externalPort(int index) const
int opcode(const std::string &operation) const
void setOpcode(const std::string &operation, int opcode)
std::string architecturePort() const
void setModuleName(const std::string &name)
void setClkPort(const std::string &name)
void addImplementationFile(BlockImplementationFile *file)
void removeImplementationFile(const BlockImplementationFile &file)
void setRstPort(const std::string &name)
BlockImplementationFile & file(int index) const
void setGlockPort(const std::string &name)
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual FUPort * operationPort(const std::string &name) const
virtual BaseFUPort * port(const std::string &name) const
int io(const FUPort &port) const
const std::string & name() const
bool isBound(const FUPort &port) const
static std::string lcStringSelection(wxListCtrl *list, int column)
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)
@ IN
Input port.
Definition HDBTypes.hh:41
std::string value
Value of the parameter.
Definition HDBTypes.hh:49
std::string type
Type of the parameter.
Definition HDBTypes.hh:48
std::string name
Name of the parameter.
Definition HDBTypes.hh:47