OpenASIP  2.0
FullyConnectBussesCmd.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 FullyConnectBussesCmd.cc
26  *
27  * Definition of FullyConnectBussesCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 
34 #include <wx/docview.h>
35 
36 #include "FullyConnectBussesCmd.hh"
37 #include "ProDeConstants.hh"
38 #include "Model.hh"
39 #include "MDFDocument.hh"
40 #include "Machine.hh"
41 #include "MachineTester.hh"
42 #include "ProDe.hh"
43 #include "FunctionUnit.hh"
44 #include "FUPort.hh"
45 #include "Socket.hh"
46 #include "HWOperation.hh"
47 #include "ExecutionPipeline.hh"
48 #include "ControlUnit.hh"
49 #include "SpecialRegisterPort.hh"
50 #include "FullyConnectedCheck.hh"
51 #include "MachineCheckResults.hh"
52 
53 
54 using std::string;
55 using namespace TTAMachine;
56 
57 /**
58  * The Constructor.
59  */
61  EditorCommand(ProDeConstants::CMD_NAME_FULLY_CONNECT_BUSSES) {
62 }
63 
64 
65 /**
66  * The Destructor.
67  */
69 
70 
71 /**
72  * Executes the command.
73  *
74  * @return True, if the command was succesfully executed, false otherwise.
75  */
76 bool
78 
79  assert(view() != NULL);
80 
81  Model* model = dynamic_cast<MDFDocument*>(
82  view()->GetDocument())->getModel();
83 
84  model->pushToStack();
85 
86  Machine& machine = *model->getMachine();
87 
88  FullyConnectedCheck checker;
89  checker.fix(machine);
90 
91  model->notifyObservers();
92  return true;
93 }
94 
95 /**
96  * Returns id of this command.
97  */
98 int
101 }
102 
103 
104 /**
105  * Creates and returns a new instance of this command.
106  */
109  return new FullyConnectBussesCmd();
110 }
111 
112 
113 /**
114  * Returns short version of the command name.
115  */
116 string
119 }
120 
121 
122 /**
123  * Returns true when the command is executable, false when not.
124  *
125  * This command is executable when a document is open.
126  *
127  * @return True, if a document is open.
128  */
129 bool
131 
132  wxDocManager* manager = wxGetApp().docManager();
133  wxView* view = manager->GetCurrentView();
134 
135  if (view == NULL) {
136  return false;
137  }
138 
139  Model* model = dynamic_cast<MDFDocument*>(
140  view->GetDocument())->getModel();
141 
142  if (model == NULL) {
143  return false;
144  }
145 
146  FullyConnectedCheck checker;
147  MachineCheckResults results;
148  if (!checker.check(*model->getMachine(), results)) {
149  return checker.canFix(*model->getMachine());
150  } else {
151  return false;
152  }
153 }
ProDe.hh
MDFDocument.hh
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
ExecutionPipeline.hh
FullyConnectBussesCmd::id
virtual int id() const
Definition: FullyConnectBussesCmd.cc:99
FullyConnectedCheck::canFix
virtual bool canFix(const TTAMachine::Machine &mach) const
Definition: FullyConnectedCheck.cc:78
Socket.hh
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
FullyConnectedCheck.hh
FullyConnectedCheck::fix
virtual std::string fix(TTAMachine::Machine &mach) const
Definition: FullyConnectedCheck.cc:267
FullyConnectBussesCmd::~FullyConnectBussesCmd
virtual ~FullyConnectBussesCmd()
Definition: FullyConnectBussesCmd.cc:68
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
ProDeConstants::CMD_SNAME_FULLY_CONNECT_BUSSES
static const std::string CMD_SNAME_FULLY_CONNECT_BUSSES
Command name for the "Fully connect busses" command.
Definition: ProDeConstants.hh:243
HWOperation.hh
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
Model.hh
FullyConnectBussesCmd::create
virtual FullyConnectBussesCmd * create() const
Definition: FullyConnectBussesCmd.cc:108
ProDeConstants::COMMAND_FULLY_CONNECT_BUSSES
@ COMMAND_FULLY_CONNECT_BUSSES
Definition: ProDeConstants.hh:454
MachineCheckResults
Definition: MachineCheckResults.hh:46
Machine.hh
FullyConnectBussesCmd
Definition: FullyConnectBussesCmd.hh:49
FullyConnectBussesCmd::Do
virtual bool Do()
Definition: FullyConnectBussesCmd.cc:77
MDFDocument
Definition: MDFDocument.hh:51
FullyConnectBussesCmd::FullyConnectBussesCmd
FullyConnectBussesCmd()
Definition: FullyConnectBussesCmd.cc:60
ProDeConstants.hh
FullyConnectedCheck::check
virtual bool check(const TTAMachine::Machine &mach) const
Definition: FullyConnectedCheck.cc:99
MachineTester.hh
FullyConnectBussesCmd::shortName
virtual std::string shortName() const
Definition: FullyConnectBussesCmd.cc:117
MachineCheckResults.hh
Model
Definition: Model.hh:50
FullyConnectedCheck
Definition: FullyConnectedCheck.hh:51
FullyConnectBussesCmd::isEnabled
virtual bool isEnabled()
Definition: FullyConnectBussesCmd.cc:130
FUPort.hh
ControlUnit.hh
SpecialRegisterPort.hh
EditorCommand
Definition: EditorCommand.hh:46
FullyConnectBussesCmd.hh
ProDeConstants
Definition: ProDeConstants.hh:43
TTAMachine
Definition: Assembler.hh:48
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88
TTAMachine::Machine
Definition: Machine.hh:73
FunctionUnit.hh