OpenASIP  2.0
RegisterState.hh
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 RegisterState.hh
26  *
27  * Declaration of RegisterState class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_REGISTER_STATE_HH
35 #define TTA_REGISTER_STATE_HH
36 
37 #include <string>
38 
39 #include "StateData.hh"
40 #include "SimValue.hh"
41 
42 
43 //////////////////////////////////////////////////////////////////////////////
44 // RegisterState
45 //////////////////////////////////////////////////////////////////////////////
46 
47 /**
48  * Class that represents the contents of a register.
49  */
50 class RegisterState : public StateData {
51 public:
52  RegisterState(int width, bool constantZero = false);
53  RegisterState(SimValue& sharedRegister);
54  virtual ~RegisterState();
55 
56  virtual void setValue(const SimValue& value);
57  virtual const SimValue& value() const;
58 
59 protected:
60  /// Value of the RegisterState. @todo Fix this mutable mess.
61  /// It's needed because OutputPortState needs to mask the value_ in
62  /// its value() implementation.
64 
65 private:
66  /// Copying not allowed.
68  /// Assignment not allowed.
70  /// Is the storage of this RegisterState shared with someone else?
71  bool shared_;
72  /// Is this register constant zero?
74 };
75 
76 //////////////////////////////////////////////////////////////////////////////
77 // NullRegisterState
78 //////////////////////////////////////////////////////////////////////////////
79 
80 /**
81  * Models non-existing RegisterState.
82  */
84 public:
85  static NullRegisterState& instance();
86 
87  virtual ~NullRegisterState();
88 
89  virtual void setValue(const SimValue& value);
90  virtual const SimValue& value() const;
91 
92 private:
94  /// Copying not allowed.
96  /// Assignment not allowed.
98 
99  /// Unique instance of NullRegisterState.
101 };
102 
103 #endif
RegisterState::shared_
bool shared_
Is the storage of this RegisterState shared with someone else?
Definition: RegisterState.hh:71
RegisterState::constantZero_
bool constantZero_
Is this register constant zero?
Definition: RegisterState.hh:73
NullRegisterState::instance
static NullRegisterState & instance()
Definition: RegisterState.cc:108
NullRegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:141
NullRegisterState::setValue
virtual void setValue(const SimValue &value)
Definition: RegisterState.cc:131
SimValue
Definition: SimValue.hh:96
RegisterState::RegisterState
RegisterState(int width, bool constantZero=false)
Definition: RegisterState.cc:50
NullRegisterState
Definition: RegisterState.hh:83
RegisterState::value
virtual const SimValue & value() const
Definition: RegisterState.cc:92
RegisterState::~RegisterState
virtual ~RegisterState()
Definition: RegisterState.cc:68
NullRegisterState::operator=
NullRegisterState & operator=(const NullRegisterState &)
Assignment not allowed.
NullRegisterState::instance_
static NullRegisterState * instance_
Unique instance of NullRegisterState.
Definition: RegisterState.hh:100
StateData.hh
RegisterState::value_
SimValue & value_
Value of the RegisterState.
Definition: RegisterState.hh:63
NullRegisterState::NullRegisterState
NullRegisterState()
Definition: RegisterState.cc:118
SimValue.hh
RegisterState
Definition: RegisterState.hh:50
StateData
Definition: StateData.hh:44
NullRegisterState::~NullRegisterState
virtual ~NullRegisterState()
Definition: RegisterState.cc:124
RegisterState::setValue
virtual void setValue(const SimValue &value)
Definition: RegisterState.cc:80
RegisterState::operator=
RegisterState & operator=(const RegisterState &)
Assignment not allowed.