OpenASIP  2.0
SpecialRegisterPort.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 SpecialRegisterPort.cc
26  *
27  * Implementation of SpecialRegisterPort class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 
35 #include "SpecialRegisterPort.hh"
36 #include "ControlUnit.hh"
37 #include "ObjectState.hh"
38 
39 using std::string;
40 
41 namespace TTAMachine {
42 
43 const std::string SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT = "sr_port";
44 
45 /**
46  * The constructor.
47  *
48  * @param name Name of the port.
49  * @param width Bit width of the port.
50  * @param parent The function unit to which the port belongs.
51  * @exception InvalidName If the given name is not a valid component name.
52  * @exception OutOfRange If the given bit width is less or equal to zero.
53  * @exception ComponentAlreadyExists If the function unit already has another
54  * port by the same name or another port
55  * that sets operation code.
56  */
58  const std::string& name, int width, ControlUnit& parent)
59  : BaseFUPort(name, width, parent) {}
60 
61 /**
62  * The constructor.
63  *
64  * Loads the state of the object from the given ObjectState tree.
65  *
66  * @param state The ObjectState tree.
67  * @param parent The parent unit of the port.
68  * @exception ObjectStateLoadingException If an error occurs while loading
69  * the state.
70  */
72  : BaseFUPort(state, parent) {}
73 
74 /**
75  * The destructor.
76  */
78 }
79 
80 
81 /**
82  * Always returns false. SpecialRegisterPort cannot be triggering.
83  *
84  * @return false
85  */
86 bool
88  return false;
89 }
90 
91 
92 /**
93  * Always returns false. SpecialRegisterPort cannot be operation code
94  * setting.
95  *
96  * @return false
97  */
98 bool
100  return false;
101 }
102 
103 
104 /**
105  * Saves the state of the object to an ObjectState tree and returns it.
106  *
107  * @return The newly created ObjectState tree.
108  */
113  return state;
114 }
115 
116 
117 /**
118  * Loads the state of the object from the given ObjectState tree.
119  *
120  * @param state An ObjectState instance representing state of a
121  * SpecialRegisterPort.
122  * @exception ObjectStateLoadingException If the given ObjectState instance
123  * is invalid.
124  */
125 void
127  if (state->name() != OSNAME_SPECIAL_REG_PORT) {
128  const string procName = "SpecialRegisterPort::loadState";
129  throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
130  }
131 
132  BaseFUPort::loadState(state);
133 }
134 }
ObjectStateLoadingException
Definition: Exception.hh:551
TTAMachine::SpecialRegisterPort::SpecialRegisterPort
SpecialRegisterPort(const std::string &name, int width, ControlUnit &parent)
Definition: SpecialRegisterPort.cc:57
TTAMachine::SpecialRegisterPort::loadState
virtual void loadState(const ObjectState *state)
Definition: SpecialRegisterPort.cc:126
TTAMachine::BaseFUPort
Definition: BaseFUPort.hh:44
ObjectState
Definition: ObjectState.hh:59
ObjectState::setName
void setName(const std::string &name)
TTAMachine::SpecialRegisterPort::saveState
virtual ObjectState * saveState() const
Definition: SpecialRegisterPort.cc:110
TTAMachine::BaseFUPort::loadState
virtual void loadState(const ObjectState *state)
Definition: BaseFUPort.cc:153
TTAMachine::SpecialRegisterPort::isOpcodeSetting
virtual bool isOpcodeSetting() const
Definition: SpecialRegisterPort.cc:99
TTAMachine::Unit
Definition: Unit.hh:51
TTAMachine::ControlUnit
Definition: ControlUnit.hh:50
ObjectState.hh
ObjectState::name
std::string name() const
TTAMachine::SpecialRegisterPort::isTriggering
virtual bool isTriggering() const
Definition: SpecialRegisterPort.cc:87
TTAMachine::BaseFUPort::saveState
virtual ObjectState * saveState() const
Definition: BaseFUPort.cc:136
TTAMachine::SpecialRegisterPort::OSNAME_SPECIAL_REG_PORT
static const std::string OSNAME_SPECIAL_REG_PORT
ObjectState name for special register port.
Definition: SpecialRegisterPort.hh:62
ControlUnit.hh
SpecialRegisterPort.hh
TTAMachine
Definition: Assembler.hh:48
TTAMachine::SpecialRegisterPort::~SpecialRegisterPort
virtual ~SpecialRegisterPort()
Definition: SpecialRegisterPort.cc:77