OpenASIP 2.2
Loading...
Searching...
No Matches
VLIWConnectICCmd.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2017 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 VLIWConnectICCmd.cc
26 *
27 * Definition of VLIWConnectICCmd class.
28 *
29 * @author Alex Hirvonen 2017 (alex.hirvonen-no.spam-gmail.com)
30 * @note rating: red
31 */
32
33
34#include <wx/docview.h>
35#include <string>
36
37#include "VLIWConnectICCmd.hh"
38#include "ProDeConstants.hh"
39#include "Machine.hh"
40#include "Model.hh"
41#include "MDFDocument.hh"
42#include "FileSystem.hh"
43#include "DSDBManager.hh"
44#include "ProDe.hh"
46
47
48using namespace TTAMachine;
49
50
54
55
57
58
59/**
60 * Executes the command.
61 *
62 * @return True, if the command was succesfully executed, false otherwise.
63 */
64bool
66
67 assert(view() != NULL);
68
69 TTAMachine::Machine* machine = dynamic_cast<MDFDocument*>(
70 view()->GetDocument())->getModel()->getMachine();
71
72 Model* model = dynamic_cast<MDFDocument*>(
73 view()->GetDocument())->getModel();
74
75 model->pushToStack();
76
77 // open up a temporary dsdb
78 const std::string dsdbFile = "tmp.dsdb";
80 DSDBManager* dsdb = DSDBManager::createNew(dsdbFile);
81 RowID archID = dsdb->addArchitecture(*machine);
82
84 RowID confID = dsdb->addConfiguration(confIn);
85
86 // load VLIWConnectIC explorer plugin
87 DesignSpaceExplorer explorer;
89 explorer.loadExplorerPlugin("VLIWConnectIC", dsdb);
90 plugin->setDSDB(*dsdb);
91
92 try {
93 std::vector<RowID> result = plugin->explore(confID, 0);
94 // store the new machine
95 TTAMachine::Machine& newMachine =
96 *dsdb->architecture(confID+result.size());
97 machine->copyFromMachine(newMachine);
98 } catch (Exception const& e) {
99 std::cerr << "Could not create VLIW Connect IC" << std::endl;
101 model->popFromStack();
102 return false;
103 }
105 model->notifyObservers();
106
107 return true;
108}
109
110/**
111 * Returns id of this command.
112 */
113int
117
118
119/**
120 * Creates and returns a new instance of this command.
121 */
124 return new VLIWConnectICCmd();
125}
126
127
128/**
129 * Returns short version of the command name.
130 */
131std::string
135
136
137/**
138 * Returns true when the command is executable, false when not.
139 *
140 * This command is executable when a document is open.
141 *
142 * @return True, if a document is open.
143 */
144bool
146
147 wxDocManager* manager = wxGetApp().docManager();
148 wxView* view = manager->GetCurrentView();
149
150 if (view == NULL) {
151 return false;
152 }
153
154 Model* model = dynamic_cast<MDFDocument*>(
155 view->GetDocument())->getModel();
156
157 if (model == NULL) {
158 return false;
159 }
160 return true;
161}
#define assert(condition)
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
#define ILLEGAL_ROW_ID
TTAMachine::Machine * machine
the architecture definition of the estimated processor
RowID addArchitecture(const TTAMachine::Machine &mom)
TTAMachine::Machine * architecture(RowID id) const
static DSDBManager * createNew(const std::string &file)
RowID addConfiguration(const MachineConfiguration &conf)
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
virtual void setDSDB(DSDBManager &dsdb)
static DesignSpaceExplorerPlugin * loadExplorerPlugin(const std::string &pluginName, DSDBManager *dsdb=NULL)
wxView * view() const
static bool removeFileOrDirectory(const std::string &path)
Definition Model.hh:50
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
void popFromStack(bool modified=false)
Definition Model.cc:195
static const std::string CMD_SNAME_VLIW_CONNECT_IC
Command name for the "VLIW Connect IC" command.
virtual void copyFromMachine(Machine &machine)
Definition Machine.cc:884
virtual ~VLIWConnectICCmd()
virtual bool Do()
virtual bool isEnabled()
virtual VLIWConnectICCmd * create() const
virtual int id() const
virtual std::string shortName() const