OpenASIP 2.2
Loading...
Searching...
No Matches
AddRFCmd.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 AddRFCmd.cc
26 *
27 * Definition of AddRFCmd class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <wx/wx.h>
34#include <wx/docview.h>
35
36#include "AddRFCmd.hh"
37#include "RFDialog.hh"
38#include "Model.hh"
39#include "MDFDocument.hh"
40#include "ProDeConstants.hh"
41#include "ModelConstants.hh"
42#include "ErrorDialog.hh"
43#include "ProDe.hh"
44#include "RegisterFile.hh"
45#include "Machine.hh"
46#include "Conversion.hh"
47
48using std::string;
49using namespace TTAMachine;
50
51/**
52 * The Constructor.
53 */
55 EditorCommand(ProDeConstants::CMD_NAME_ADD_RF) {
56}
57
58
59
60/**
61 * Executes the command.
62 *
63 * @return true, if the command was succesfully executed, false otherwise.
64 */
65bool
67
68 assert(parentWindow() != NULL);
69 assert(view() != NULL);
70
71 Model* model = dynamic_cast<MDFDocument*>(
72 view()->GetDocument())->getModel();
73
74 model->pushToStack();
75
76 // Generate name for the new RF.
80 int i = 1;
81 while (navigator.hasItem(newName)) {
84 i++;
85 }
86
87 RegisterFile* rf = new RegisterFile(
93
94 rf->setMachine(*(model->getMachine()));
95
96 RFDialog dialog(parentWindow(), rf);
97
98 if (dialog.ShowModal() == wxID_OK) {
99 model->notifyObservers();
100 return true;
101 } else {
102 // register file creation was cancelled
103 model->popFromStack();
104 return false;
105 }
106}
107
108
109/**
110 * Returns id of this command.
111 *
112 * @return ID for this command to be used in menus and toolbars.
113 */
114int
118
119
120/**
121 * Creates and returns a new instance of this command.
122 *
123 * @return Newly created instance of this command.
124 */
127 return new AddRFCmd();
128}
129
130/**
131 * Returns short version of the command name.
132 *
133 * @return Short name of the command to be used in the toolbar.
134 */
135string
139
140
141/**
142 * Returns true when the command is executable, false when not.
143 *
144 * This command is executable when a document is open.
145 *
146 * @return True, if a document is open.
147 */
148bool
150 wxDocManager* manager = wxGetApp().docManager();
151 if (manager->GetCurrentView() != NULL) {
152 return true;
153 }
154 return false;
155}
#define assert(condition)
virtual int id() const
Definition AddRFCmd.cc:115
virtual bool Do()
Definition AddRFCmd.cc:66
virtual std::string shortName() const
Definition AddRFCmd.cc:136
virtual AddRFCmd * create() const
Definition AddRFCmd.cc:126
virtual bool isEnabled()
Definition AddRFCmd.cc:149
static std::string toString(const T &source)
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static const int DEFAULT_RF_MAX_READS
Default maximum read ports of register file.
static const int DEFAULT_WIDTH
Default bit width.
static const int DEFAULT_RF_MAX_WRITES
Default maximum read ports while writing for a register file.
static const int DEFAULT_RF_SIZE
Default register file type.
static const int DEFAULT_RF_GUARD_LATENCY
Default local RF guard latency.
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
TTAMachine::Machine * getMachine()
Definition Model.cc:88
static const std::string CMD_SNAME_ADD_RF
Command name for the "Add Register File" command.
static const std::string COMP_NEW_NAME_PREFIX_RF
Prefix for new register file names.
bool hasItem(const std::string &name) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
@ NORMAL
Used for general register allocation.
virtual void setMachine(Machine &mach)
Definition Unit.cc:253