OpenASIP 2.2
Loading...
Searching...
No Matches
RegisterFile.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 RegisterFile.hh
26 *
27 * Declaration of RegisterFile class.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 * @note reviewed 17 Jun 2004 by jn, pj, jm, ll
31 * @note rating: red
32 */
33
34#ifndef TTA_REGISTER_FILE_HH
35#define TTA_REGISTER_FILE_HH
36
37#include <string>
38
39#include "MachinePart.hh"
40#include "BaseRegisterFile.hh"
41
42namespace TTAMachine {
43
44/**
45 * Represents a register-file in TTA processor.
46 */
48public:
49 /// Type of the register file indicates how the RF is used.
50 enum Type {
51 NORMAL, ///< Used for general register allocation.
52 RESERVED, ///< Used for custom, user controlled register allocation.
53 VOLATILE ///< Used for user-controlled I/O communication.
54 };
55
57 const std::string& name, unsigned int size, unsigned int width,
58 unsigned int maxReads, unsigned int maxwrites,
59 unsigned int guardLatency, Type type, bool zeroRegister = false);
60 explicit RegisterFile(const ObjectState* state);
61 virtual ~RegisterFile();
62 virtual RegisterFile* copy() const;
63
64 virtual int maxReads() const;
65 virtual int maxWrites() const;
66 virtual RegisterFile::Type type() const;
67
68 virtual bool isNormal() const;
69 virtual bool isVolatile() const;
70 virtual bool isReserved() const;
71
72 virtual void setName(const std::string& name);
73 virtual void setMaxReads(int maxReads);
74 virtual void setMaxWrites(int maxWrites);
75 virtual void setType(RegisterFile::Type type);
76 virtual void setNumberOfRegisters(int registers);
77
78 virtual int guardLatency() const;
79 virtual void setGuardLatency(int latency);
80
81 virtual void unsetMachine();
82
83 virtual ObjectState* saveState() const;
84 virtual void loadState(const ObjectState* state);
85
86 virtual bool isArchitectureEqual(const RegisterFile& rf) const;
87
88 virtual bool isUsedAsGuard() const;
89
90 virtual bool zeroRegister() const;
91 virtual void setZeroRegister(const bool& value);
92
93 /// ObjectState name for RegisterFile.
94 static const std::string OSNAME_REGISTER_FILE;
95 /// ObjectState attribute key for register file type.
96 static const std::string OSKEY_TYPE;
97 /// ObjectState attribute value for normal register file type.
98 static const std::string OSVALUE_NORMAL;
99 /// ObjectState attribute value for reserved register file type.
100 static const std::string OSVALUE_RESERVED;
101 /// ObjectState attribute value for volatile register file type.
102 static const std::string OSVALUE_VOLATILE;
103 /// ObjectState attribute key for maximum simultaneous readers.
104 static const std::string OSKEY_MAX_READS;
105 /// ObjectState attribute key for maximum simultaneous writers.
106 static const std::string OSKEY_MAX_WRITES;
107 /// ObjectState attribute key for the guard latency.
108 static const std::string OSKEY_GUARD_LATENCY;
109 /// ObjectState attribute key for zero register flag.
110 static const std::string OSKEY_ZERO_REGISTER;
111
112
113 Port* firstReadPort() const;
114 Port* firstWritePort() const;
115
116protected:
117
118private:
119 bool updateMaxReadsAndWrites() const;
120 /// Copying forbidden, use the copy() method.
122 /// Assingment forbidden.
124
125 void loadStateWithoutReferences(const ObjectState* state);
126 void deleteGuards(int registers) const;
127
128 /// Max number of ports that can read a register all in the same cycle.
129 mutable int maxReads_;
130 /// Max number of ports that can read a register all in the same cycle.
131 mutable int maxWrites_;
132 /// The guard latency of the register file.
134
135 /// Type of the register file.
137 // True if the first index is hard coded to zero
139};
140}
141
142#endif
143
virtual int size() const
virtual int width() const
virtual TCEString name() const
static const std::string OSKEY_MAX_WRITES
ObjectState attribute key for maximum simultaneous writers.
virtual void setType(RegisterFile::Type type)
virtual void loadState(const ObjectState *state)
RegisterFile & operator=(const RegisterFile &)
Assingment forbidden.
virtual bool isArchitectureEqual(const RegisterFile &rf) const
virtual void setZeroRegister(const bool &value)
virtual RegisterFile * copy() const
static const std::string OSKEY_MAX_READS
ObjectState attribute key for maximum simultaneous readers.
virtual int maxReads() const
virtual ObjectState * saveState() const
Port * firstReadPort() const
int maxWrites_
Max number of ports that can read a register all in the same cycle.
Type type_
Type of the register file.
virtual bool isVolatile() const
virtual bool isReserved() const
virtual void setMaxWrites(int maxWrites)
virtual void setName(const std::string &name)
int maxReads_
Max number of ports that can read a register all in the same cycle.
static const std::string OSKEY_ZERO_REGISTER
ObjectState attribute key for zero register flag.
virtual bool zeroRegister() const
virtual void setMaxReads(int maxReads)
static const std::string OSKEY_GUARD_LATENCY
ObjectState attribute key for the guard latency.
void deleteGuards(int registers) const
Type
Type of the register file indicates how the RF is used.
@ VOLATILE
Used for user-controlled I/O communication.
@ NORMAL
Used for general register allocation.
@ RESERVED
Used for custom, user controlled register allocation.
virtual bool isNormal() const
RegisterFile(const RegisterFile &)
Copying forbidden, use the copy() method.
virtual void setGuardLatency(int latency)
static const std::string OSVALUE_RESERVED
ObjectState attribute value for reserved register file type.
virtual int guardLatency() const
static const std::string OSVALUE_VOLATILE
ObjectState attribute value for volatile register file type.
static const std::string OSKEY_TYPE
ObjectState attribute key for register file type.
virtual RegisterFile::Type type() const
static const std::string OSNAME_REGISTER_FILE
ObjectState name for RegisterFile.
virtual bool isUsedAsGuard() const
virtual void setNumberOfRegisters(int registers)
virtual void unsetMachine()
virtual int maxWrites() const
void loadStateWithoutReferences(const ObjectState *state)
Port * firstWritePort() const
int guardLatency_
The guard latency of the register file.
static const std::string OSVALUE_NORMAL
ObjectState attribute value for normal register file type.
bool updateMaxReadsAndWrites() const