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

#include <AddGCUCmd.hh>

Inheritance diagram for AddGCUCmd:
Inheritance graph
Collaboration diagram for AddGCUCmd:
Collaboration graph

Public Member Functions

 AddGCUCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddGCUCmdcreate () const
 
virtual std::string shortName () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
virtual std::string icon () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Static Private Attributes

static const std::string RA_PORT_NAME = "ra"
 Name for the return address port.
 
static const std::string OP_PORT_NAME = "pc"
 Name for the jump/call operand port.
 
static const std::string OPNAME_JUMP = "jump"
 Name string for the jump operation.
 
static const std::string OPNAME_CALL = "call"
 Name string for the call operation.
 

Detailed Description

Command for adding new global control unit to the Machine.

Displays a global control unit dialog and creates a new global control unit according to the dialog output.

Definition at line 44 of file AddGCUCmd.hh.

Constructor & Destructor Documentation

◆ AddGCUCmd()

AddGCUCmd::AddGCUCmd ( )

The Constructor.

Definition at line 66 of file AddGCUCmd.cc.

66 :
68}
static const std::string CMD_NAME_ADD_GCU
Command name for the "Add Global Control Unit" command.

Referenced by create().

Member Function Documentation

◆ create()

AddGCUCmd * AddGCUCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 151 of file AddGCUCmd.cc.

151 {
152 return new AddGCUCmd();
153}

References AddGCUCmd().

Here is the call graph for this function:

◆ Do()

bool AddGCUCmd::Do ( )
virtual

Executes the command.

Returns
true, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 78 of file AddGCUCmd.cc.

78 {
79
80 assert(parentWindow() != NULL);
81 assert(view() != NULL);
82
83 Model* model = dynamic_cast<MDFDocument*>(
84 view()->GetDocument())->getModel();
85
86
87 // check that the machine doesn't have a global control unit yet
88 if (model->getMachine()->controlUnit() != NULL) {
90 format fmt = generator->text(ProDeTextGenerator::MSG_ERROR_ONE_GCU);
91 string title = fmt.str();
92 wxString message = WxConversion::toWxString(title);
93 InformationDialog info(parentWindow(), message);
94 info.ShowModal();
95 return false;
96 }
97
98 model->pushToStack();
99
100 // Add default ports.
101 ControlUnit* gcu = new ControlUnit(
103
104 FUPort* opPort = new FUPort(OP_PORT_NAME, 32, *gcu, true, true);
105 SpecialRegisterPort* raPort =
106 new SpecialRegisterPort(RA_PORT_NAME, 32, *gcu);
107
108 gcu->setReturnAddressPort(*raPort);
109
110 // Add default operations.
111 HWOperation* jump = new HWOperation(OPNAME_JUMP, *gcu);
112 jump->bindPort(1, *opPort);
113 jump->pipeline()->addPortRead(1, 0, 1);
114
115 HWOperation* call = new HWOperation(OPNAME_CALL, *gcu);
116 call->bindPort(1, *opPort);
117 call->pipeline()->addPortRead(1, 0, 1);
118
119 gcu->setMachine(*(model->getMachine()));
120
121 GCUDialog dialog(parentWindow(), gcu);
122 if (dialog.ShowModal() == wxID_OK) {
123 model->notifyObservers();
124 return true;
125 } else {
126 model->popFromStack();
127 return false;
128 }
129
130 return false;
131}
#define assert(condition)
static const std::string RA_PORT_NAME
Name for the return address port.
Definition AddGCUCmd.hh:55
static const std::string OPNAME_CALL
Name string for the call operation.
Definition AddGCUCmd.hh:61
static const std::string OPNAME_JUMP
Name string for the jump operation.
Definition AddGCUCmd.hh:59
static const std::string OP_PORT_NAME
Name for the jump/call operand port.
Definition AddGCUCmd.hh:57
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
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 COMP_DEFAULT_NAME_GCU
Default name for new control units.
static ProDeTextGenerator * instance()
@ MSG_ERROR_ONE_GCU
Error: Multiple control units.
void setReturnAddressPort(const SpecialRegisterPort &port)
virtual void setMachine(Machine &mach)
void addPortRead(int operand, int start, int duration)
ExecutionPipeline * pipeline() const
virtual void bindPort(int operand, const FUPort &port)
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References TTAMachine::ExecutionPipeline::addPortRead(), assert, TTAMachine::HWOperation::bindPort(), ProDeConstants::COMP_DEFAULT_NAME_GCU, TTAMachine::Machine::controlUnit(), Model::getMachine(), ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR_ONE_GCU, Model::notifyObservers(), OP_PORT_NAME, OPNAME_CALL, OPNAME_JUMP, GUICommand::parentWindow(), TTAMachine::HWOperation::pipeline(), Model::popFromStack(), Model::pushToStack(), RA_PORT_NAME, TTAMachine::ControlUnit::setMachine(), TTAMachine::ControlUnit::setReturnAddressPort(), Texts::TextGenerator::text(), WxConversion::toWxString(), and EditorCommand::view().

Here is the call graph for this function:

◆ id()

int AddGCUCmd::id ( ) const
virtual

Returns id of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 140 of file AddGCUCmd.cc.

References ProDeConstants::COMMAND_ADD_GCU.

◆ isEnabled()

bool AddGCUCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a document is open.

Returns
True, if a document is open.

Reimplemented from EditorCommand.

Definition at line 176 of file AddGCUCmd.cc.

176 {
177 wxDocManager* manager = wxGetApp().docManager();
178 if (manager->GetCurrentView() != NULL) {
179 return true;
180 }
181 return false;
182}

◆ shortName()

string AddGCUCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short name of the command to be used in the toolbar.

Reimplemented from GUICommand.

Definition at line 163 of file AddGCUCmd.cc.

163 {
165}
static const std::string CMD_SNAME_ADD_GCU
Command name for the "Add Global Control Unit" command.

References ProDeConstants::CMD_SNAME_ADD_GCU.

Member Data Documentation

◆ OP_PORT_NAME

const std::string AddGCUCmd::OP_PORT_NAME = "pc"
staticprivate

Name for the jump/call operand port.

Definition at line 57 of file AddGCUCmd.hh.

Referenced by Do().

◆ OPNAME_CALL

const std::string AddGCUCmd::OPNAME_CALL = "call"
staticprivate

Name string for the call operation.

Definition at line 61 of file AddGCUCmd.hh.

Referenced by Do().

◆ OPNAME_JUMP

const std::string AddGCUCmd::OPNAME_JUMP = "jump"
staticprivate

Name string for the jump operation.

Definition at line 59 of file AddGCUCmd.hh.

Referenced by Do().

◆ RA_PORT_NAME

const std::string AddGCUCmd::RA_PORT_NAME = "ra"
staticprivate

Name for the return address port.

Definition at line 55 of file AddGCUCmd.hh.

Referenced by Do().


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