OpenASIP 2.2
Loading...
Searching...
No Matches
RegisterState.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 RegisterState.cc
26 *
27 * Definition 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#include "RegisterState.hh"
35#include "Application.hh"
36
37using std::string;
38
39//////////////////////////////////////////////////////////////////////////////
40// RegisterState
41//////////////////////////////////////////////////////////////////////////////
42
43
44/**
45 * Constructor.
46 *
47 * @param width The width of the register.
48 * @param constantZero Tells whether the register is constant zero
49 */
50RegisterState::RegisterState(int width, bool constantZero) :
51 StateData(), value_(*(new SimValue(width))), shared_(false),
52 constantZero_(constantZero) {
53}
54
55/**
56 * Constructor for RegisterState which shares the actual register storage.
57 *
58 * @param sharedRegister The register which is shared with this.
59 */
61 StateData(), value_(sharedRegister), shared_(true),
62 constantZero_(false) {
63}
64
65/**
66 * Destructor.
67 */
69 if (!shared_) {
70 delete &value_;
71 }
72}
73
74/**
75 * Sets the value for the register.
76 *
77 * @param value Value to be set.
78 */
79void
81 if (!constantZero_) {
82 value_ = value;
83 }
84}
85
86/**
87 * Returns the value of the register.
88 *
89 * @return The value of the register.
90 */
91const SimValue&
93 return value_;
94}
95
96//////////////////////////////////////////////////////////////////////////////
97// NullRegisterState
98//////////////////////////////////////////////////////////////////////////////
99
101
102/**
103 * Returns instance of NullRegisterState.
104 *
105 * @return The instance of NullRegisterState.
106 */
109 if (instance_ == NULL) {
111 }
112 return *instance_;
113}
114
115/**
116 * Constructor.
117 */
120
121/**
122 * Destructor.
123 */
126
127/**
128 * Aborts the program with error message.
129 */
130void
132 Application::abortWithError("setValue()");
133}
134
135/**
136 * Aborts the program with error message.
137 *
138 * @return Never returns.
139 */
140const SimValue&
142 Application::abortWithError("value()");
143 return NullSimValue::instance();
144}
145
find Finds info of the inner loops in the false
virtual void setValue(const SimValue &value)
static NullRegisterState & instance()
static NullRegisterState * instance_
Unique instance of NullRegisterState.
virtual ~NullRegisterState()
virtual const SimValue & value() const
static SimValue & instance()
Definition SimValue.cc:1642
SimValue & value_
Value of the RegisterState.
virtual void setValue(const SimValue &value)
bool constantZero_
Is this register constant zero?
RegisterState(int width, bool constantZero=false)
virtual const SimValue & value() const
bool shared_
Is the storage of this RegisterState shared with someone else?
virtual ~RegisterState()