OpenASIP  2.0
PortState.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 PortState.cc
26  *
27  * Declaration of PortState class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2006 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #include "PortState.hh"
35 #include "Application.hh"
36 #include "SimValue.hh"
37 #include "FUState.hh"
38 
39 using std::string;
40 
41 //////////////////////////////////////////////////////////////////////////////
42 // PortState
43 //////////////////////////////////////////////////////////////////////////////
44 
45 /**
46  * Constructor.
47  *
48  * @param parent The parent FU state object of the port.
49  * @param width The bit width of the port.
50  */
51 PortState::PortState(FUState& parent, int width) :
52  RegisterState(width), parent_(&parent) {
53 }
54 
55 /**
56  * Constructor for RegisterState which shares the actual register storage.
57  *
58  * @param parent The parent FU state object of the port.
59  * @param sharedRegister The register which is shared with this.
60  */
62  FUState& parent, SimValue& sharedRegister) :
63  RegisterState(sharedRegister), parent_(&parent) {
64 
65 }
66 
67 
68 /**
69  * Destructor.
70  */
72 }
73 
74 /**
75  * Returns the parent of the port.
76  *
77  * @return The parent of the port.
78  */
79 FUState&
81  return *parent_;
82 }
83 
84 //////////////////////////////////////////////////////////////////////////////
85 // NullPortState
86 //////////////////////////////////////////////////////////////////////////////
87 
89 
90 /**
91  * Returns the instance of NullPortState.
92  *
93  * @return The instance of NullPortState.
94  */
97  if (instance_ == NULL) {
98  instance_ = new NullPortState();
99  }
100  return *instance_;
101 }
102 
103 /**
104  * Constructor.
105  */
107 }
108 
109 /**
110  * Destructor.
111  */
113 }
114 
115 /**
116  * Aborts the program with error message.
117  */
118 void
120  Application::abortWithError("setValue()");
121 }
122 
123 /**
124  * Aborts the program with error message.
125  *
126  * @return Never returns.
127  */
128 const SimValue&
130  Application::abortWithError("value()");
131  return NullSimValue::instance();
132 }
133 
134 /**
135  * Aborts the program with error message.
136  *
137  * @return Never returns.
138  */
139 FUState&
141  Application::abortWithError("parent()");
142  return NullFUState::instance();
143 }
NullPortState::parent
virtual FUState & parent() const
Definition: PortState.cc:140
PortState::parent_
FUState * parent_
Parent of the port.
Definition: PortState.hh:61
NullSimValue::instance
static SimValue & instance()
Definition: SimValue.cc:1642
FUState.hh
NullPortState::instance
static NullPortState & instance()
Definition: PortState.cc:96
PortState::parent
virtual FUState & parent() const
Definition: PortState.cc:80
NullPortState::NullPortState
NullPortState()
Definition: PortState.cc:106
SimValue
Definition: SimValue.hh:96
FUState
Definition: FUState.hh:58
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
NullPortState::instance_
static NullPortState * instance_
Unique instance of NullPortState class.
Definition: PortState.hh:94
NullFUState::instance
static NullFUState & instance()
Definition: FUState.cc:392
Application.hh
NullPortState::~NullPortState
virtual ~NullPortState()
Definition: PortState.cc:112
PortState
Definition: PortState.hh:51
NullFUState
Definition: FUState.hh:152
PortState::~PortState
virtual ~PortState()
Definition: PortState.cc:71
NullPortState::setValue
virtual void setValue(const SimValue &value)
Definition: PortState.cc:119
PortState::PortState
PortState(FUState &parent, int width)
Definition: PortState.cc:51
SimValue.hh
NullPortState::value
virtual const SimValue & value() const
Definition: PortState.cc:129
RegisterState
Definition: RegisterState.hh:50
NullPortState
Definition: PortState.hh:76
PortState.hh