OpenASIP 2.2
Loading...
Searching...
No Matches
SocketCodeTable.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 SocketCodeTable.hh
26 *
27 * Declaration of SocketCodeTable class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_SOCKET_CODE_TABLE_HH
34#define TTA_SOCKET_CODE_TABLE_HH
35
36#include <string>
37#include <vector>
38
39#include "Exception.hh"
40#include "Serializable.hh"
41
42class BinaryEncoding;
43class PortCode;
44class FUPortCode;
45class RFPortCode;
46class IUPortCode;
47class SlotField;
48
49/**
50 * If a socket is attached to several ports, each port is identified
51 * by a different control code. This control code forms the variable
52 * part of the socket encoding and is defined by SocketCodeTable
53 * class.
54 *
55 * The SocketCodeTable class contains objects that represent port
56 * control codes, namely FUPortCode, RFPortCode and
57 * IUPortCode. Because a single SocketCodeTable instance is shared by
58 * several socket encodings, it is not owned by SocketEncoding
59 * objects. Instead, socket code tables are owned by BinaryEncoding
60 * class, which provides methods to access and handle them.
61 *
62 * Port codes consists of one or two parts: port ID and/or register
63 * index. Port IDs are aligned to the left end of the field and
64 * register indices to the right end. That is, if port ID + register
65 * index do not take all the bits of the width reserved for the table,
66 * there are unused bits between port ID and register index.
67 */
69public:
70 SocketCodeTable(const std::string& name, BinaryEncoding& parent);
72 virtual ~SocketCodeTable();
73
74 BinaryEncoding* parent() const;
75
76 std::string name() const;
77 void setName(const std::string& name);
78
79 void setExtraBits(int bits);
80 int extraBits() const;
81 int width() const;
82 int maxCodeWidth() const;
83
84 void addFUPortCode(FUPortCode& code);
85 void removeFUPortCode(FUPortCode& code);
86 int fuPortCodeCount() const;
87 FUPortCode& fuPortCode(int index) const;
88
89 bool hasFUPortCode(const std::string& fu, const std::string& port) const;
90 bool hasFUPortCode(
91 const std::string& fu, const std::string& port,
92 const std::string& operation) const;
94 const std::string& fu, const std::string& port) const;
96 const std::string& fu, const std::string& port,
97 const std::string& operation) const;
98
99 void addRFPortCode(RFPortCode& code);
100 void removeRFPortCode(RFPortCode& code);
101 int rfPortCodeCount() const;
102 RFPortCode& rfPortCode(int index) const;
103 bool hasRFPortCode(const std::string& regFile) const;
104 RFPortCode& rfPortCode(const std::string& regFile) const;
105
106 void addIUPortCode(IUPortCode& code);
107 void removeIUPortCode(IUPortCode& code);
108 int iuPortCodeCount() const;
109 IUPortCode& iuPortCode(int index) const;
110 bool hasIUPortCode(const std::string& immediateUnit) const;
111 IUPortCode& iuPortCode(const std::string& immediateUnit) const;
112
113 int portCodeCount() const;
114 PortCode& portCode(int index) const;
115
116 // methods inherited from Serializable interface
117 virtual void loadState(const ObjectState* state);
118 virtual ObjectState* saveState() const;
119
120 /// ObjectState name for socket code table.
121 static const std::string OSNAME_SOCKET_CODE_TABLE;
122 /// ObjectState attribute key for name of the table.
123 static const std::string OSKEY_NAME;
124 /// ObjectState attribute key for the number of extra bits.
125 static const std::string OSKEY_EXTRA_BITS;
126
127private:
128 /// Container type for FU port codes.
129 typedef std::vector<FUPortCode*> FUPortCodeTable;
130 /// Container type for RF port codes.
131 typedef std::vector<RFPortCode*> RFPortCodeTable;
132 /// Container type for IU port codes.
133 typedef std::vector<IUPortCode*> IUPortCodeTable;
134
135 void removeReferences(SlotField& field) const;
136 bool hasParentSCTable(const std::string& name) const;
137 void deleteRFPortCodes();
138 void deleteFUPortCodes();
139 void deleteIUPortCodes();
141 bool containsPortCode() const;
142
143 /// The parent binary encoding map.
145 /// Name of the table.
146 std::string name_;
147 /// FU port codes.
149 /// RF port codes.
151 /// IU port codes.
153 /// The number of extra bits.
155};
156
157#endif
FUPortCode & fuPortCode(int index) const
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
void setName(const std::string &name)
void addFUPortCode(FUPortCode &code)
void setExtraBits(int bits)
int portCodeCount() const
std::vector< FUPortCode * > FUPortCodeTable
Container type for FU port codes.
virtual ~SocketCodeTable()
int extraBits_
The number of extra bits.
void removeReferences(SlotField &field) const
void removeFUPortCode(FUPortCode &code)
RFPortCode & rfPortCode(int index) const
virtual void loadState(const ObjectState *state)
void removeIUPortCode(IUPortCode &code)
int extraBits() const
bool hasRFPortCode(const std::string &regFile) const
static const std::string OSKEY_NAME
ObjectState attribute key for name of the table.
int fuPortCodeCount() const
std::string name_
Name of the table.
std::string name() const
PortCode & portCode(int index) const
std::vector< IUPortCode * > IUPortCodeTable
Container type for IU port codes.
bool hasIUPortCode(const std::string &immediateUnit) const
IUPortCode & iuPortCode(int index) const
static const std::string OSNAME_SOCKET_CODE_TABLE
ObjectState name for socket code table.
int rfPortCodeCount() const
int maxCodeWidth() const
bool hasRFOrIUPortCodeWithoutEncoding() const
bool hasFUPortCode(const std::string &fu, const std::string &port) const
void addIUPortCode(IUPortCode &code)
bool hasParentSCTable(const std::string &name) const
virtual ObjectState * saveState() const
void addRFPortCode(RFPortCode &code)
int iuPortCodeCount() const
BinaryEncoding * parent() const
void removeRFPortCode(RFPortCode &code)
FUPortCodeTable fuPortCodes_
FU port codes.
bool containsPortCode() const
BinaryEncoding * parent_
The parent binary encoding map.
RFPortCodeTable rfPortCodes_
RF port codes.
IUPortCodeTable iuPortCodes_
IU port codes.
std::vector< RFPortCode * > RFPortCodeTable
Container type for RF port codes.