OpenASIP  2.0
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 
42 class BinaryEncoding;
43 class PortCode;
44 class FUPortCode;
45 class RFPortCode;
46 class IUPortCode;
47 class 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  */
68 class SocketCodeTable : public Serializable {
69 public:
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 
127 private:
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
SocketCodeTable::removeReferences
void removeReferences(SlotField &field) const
Definition: SocketCodeTable.cc:749
BinaryEncoding
Definition: BinaryEncoding.hh:61
SocketCodeTable::rfPortCodeCount
int rfPortCodeCount() const
Definition: SocketCodeTable.cc:471
PortCode
Definition: PortCode.hh:45
SocketCodeTable::rfPortCodes_
RFPortCodeTable rfPortCodes_
RF port codes.
Definition: SocketCodeTable.hh:150
Exception.hh
SocketCodeTable::SocketCodeTable
SocketCodeTable(const std::string &name, BinaryEncoding &parent)
Definition: SocketCodeTable.cc:68
SocketCodeTable::addIUPortCode
void addIUPortCode(IUPortCode &code)
Definition: SocketCodeTable.cc:544
SocketCodeTable::FUPortCodeTable
std::vector< FUPortCode * > FUPortCodeTable
Container type for FU port codes.
Definition: SocketCodeTable.hh:129
SocketCodeTable::fuPortCode
FUPortCode & fuPortCode(int index) const
Definition: SocketCodeTable.cc:308
SocketCodeTable::containsPortCode
bool containsPortCode() const
Definition: SocketCodeTable.cc:833
Serializable
Definition: Serializable.hh:44
SocketCodeTable::hasRFPortCode
bool hasRFPortCode(const std::string &regFile) const
Definition: SocketCodeTable.cc:502
SocketCodeTable::removeRFPortCode
void removeRFPortCode(RFPortCode &code)
Definition: SocketCodeTable.cc:458
IUPortCode
Definition: IUPortCode.hh:41
SocketCodeTable::setExtraBits
void setExtraBits(int bits)
Definition: SocketCodeTable.cc:174
ObjectState
Definition: ObjectState.hh:59
SocketCodeTable::rfPortCode
RFPortCode & rfPortCode(int index) const
Definition: SocketCodeTable.cc:484
RFPortCode
Definition: RFPortCode.hh:44
FUPortCode
Definition: FUPortCode.hh:47
SocketCodeTable::fuPortCodeCount
int fuPortCodeCount() const
Definition: SocketCodeTable.cc:295
SocketCodeTable::fuPortCodes_
FUPortCodeTable fuPortCodes_
FU port codes.
Definition: SocketCodeTable.hh:148
SocketCodeTable::portCodeCount
int portCodeCount() const
Definition: SocketCodeTable.cc:648
SocketCodeTable::removeIUPortCode
void removeIUPortCode(IUPortCode &code)
Definition: SocketCodeTable.cc:574
SocketCodeTable
Definition: SocketCodeTable.hh:68
SocketCodeTable::saveState
virtual ObjectState * saveState() const
Definition: SocketCodeTable.cc:716
SocketCodeTable::parent
BinaryEncoding * parent() const
Definition: SocketCodeTable.cc:126
SocketCodeTable::loadState
virtual void loadState(const ObjectState *state)
Definition: SocketCodeTable.cc:685
SocketCodeTable::RFPortCodeTable
std::vector< RFPortCode * > RFPortCodeTable
Container type for RF port codes.
Definition: SocketCodeTable.hh:131
SocketCodeTable::extraBits
int extraBits() const
Definition: SocketCodeTable.cc:189
SocketCodeTable::iuPortCode
IUPortCode & iuPortCode(int index) const
Definition: SocketCodeTable.cc:600
SocketCodeTable::maxCodeWidth
int maxCodeWidth() const
Definition: SocketCodeTable.cc:212
SocketCodeTable::hasFUPortCode
bool hasFUPortCode(const std::string &fu, const std::string &port) const
Definition: SocketCodeTable.cc:326
SocketCodeTable::hasRFOrIUPortCodeWithoutEncoding
bool hasRFOrIUPortCodeWithoutEncoding() const
Definition: SocketCodeTable.cc:815
SocketCodeTable::hasIUPortCode
bool hasIUPortCode(const std::string &immediateUnit) const
Definition: SocketCodeTable.cc:618
SocketCodeTable::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for name of the table.
Definition: SocketCodeTable.hh:123
Serializable.hh
SocketCodeTable::setName
void setName(const std::string &name)
Definition: SocketCodeTable.cc:150
SocketCodeTable::addFUPortCode
void addFUPortCode(FUPortCode &code)
Definition: SocketCodeTable.cc:249
SocketCodeTable::deleteFUPortCodes
void deleteFUPortCodes()
Definition: SocketCodeTable.cc:793
SocketCodeTable::parent_
BinaryEncoding * parent_
The parent binary encoding map.
Definition: SocketCodeTable.hh:144
SocketCodeTable::iuPortCodeCount
int iuPortCodeCount() const
Definition: SocketCodeTable.cc:587
SocketCodeTable::name_
std::string name_
Name of the table.
Definition: SocketCodeTable.hh:146
SlotField
Definition: SlotField.hh:58
SocketCodeTable::iuPortCodes_
IUPortCodeTable iuPortCodes_
IU port codes.
Definition: SocketCodeTable.hh:152
SocketCodeTable::OSNAME_SOCKET_CODE_TABLE
static const std::string OSNAME_SOCKET_CODE_TABLE
ObjectState name for socket code table.
Definition: SocketCodeTable.hh:121
SocketCodeTable::portCode
PortCode & portCode(int index) const
Definition: SocketCodeTable.cc:662
SocketCodeTable::hasParentSCTable
bool hasParentSCTable(const std::string &name) const
Definition: SocketCodeTable.cc:768
SocketCodeTable::IUPortCodeTable
std::vector< IUPortCode * > IUPortCodeTable
Container type for IU port codes.
Definition: SocketCodeTable.hh:133
SocketCodeTable::extraBits_
int extraBits_
The number of extra bits.
Definition: SocketCodeTable.hh:154
SocketCodeTable::~SocketCodeTable
virtual ~SocketCodeTable()
Definition: SocketCodeTable.cc:100
SocketCodeTable::addRFPortCode
void addRFPortCode(RFPortCode &code)
Definition: SocketCodeTable.cc:428
SocketCodeTable::deleteIUPortCodes
void deleteIUPortCodes()
Definition: SocketCodeTable.cc:802
SocketCodeTable::width
int width() const
Definition: SocketCodeTable.cc:200
SocketCodeTable::deleteRFPortCodes
void deleteRFPortCodes()
Definition: SocketCodeTable.cc:784
SocketCodeTable::name
std::string name() const
Definition: SocketCodeTable.cc:137
SocketCodeTable::OSKEY_EXTRA_BITS
static const std::string OSKEY_EXTRA_BITS
ObjectState attribute key for the number of extra bits.
Definition: SocketCodeTable.hh:125
SocketCodeTable::removeFUPortCode
void removeFUPortCode(FUPortCode &code)
Definition: SocketCodeTable.cc:283