OpenASIP  2.0
SlotField.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 SlotField.hh
26  *
27  * Declaration of SlotField class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_SLOT_FIELD_HH
34 #define TTA_SLOT_FIELD_HH
35 
36 #include <vector>
37 #include "InstructionField.hh"
38 #include "BinaryEncoding.hh"
39 
40 class SocketEncoding;
41 class MoveSlot;
42 class NOPEncoding;
43 
44 /**
45  * SlotField is an abstract base class that models the properties common to
46  * SourceField and DestinationField classes.
47  *
48  * SlotField contains and manages the encodings for sockets. Encodings
49  * for different sources and destinations consists of two parts:
50  * socket ID and optional socket code. Socket ID determines the
51  * socket. Socket code determines the port (and opcode) the socket is
52  * connected to. Socket ID may be on either left or right side of the
53  * socket code in the source or destination field. If socket ID is on
54  * the left side of socket code, socket ID is aligned to the left end
55  * of the whole source/destination field. In the other case, socket ID
56  * is aligned to the right end of the source/destination field.
57  */
58 class SlotField : public InstructionField {
59 public:
60  virtual ~SlotField();
61 
62  MoveSlot* parent() const;
63 
64  void addSocketEncoding(SocketEncoding& encoding);
65  void removeSocketEncoding(SocketEncoding& encoding);
66 
67  int socketEncodingCount() const;
68  SocketEncoding& socketEncoding(int index) const;
69  bool hasSocketEncoding(const std::string& socket) const;
70  SocketEncoding& socketEncoding(const std::string& socket) const;
71 
72  void setNoOperationEncoding(NOPEncoding& encoding);
74  bool hasNoOperationEncoding() const;
76 
78 
79  // methods inherited from InstructionField
80  virtual int width() const;
81  virtual int childFieldCount() const;
82  virtual InstructionField& childField(int position) const;
83 
84  // methods inherited from Serializable interface
85  virtual void loadState(const ObjectState* state);
86  virtual ObjectState* saveState() const;
87 
88  /// ObjectState name for slot field.
89  static const std::string OSNAME_SLOT_FIELD;
90  /// ObjectState attribute key for component ID position.
91  static const std::string OSKEY_COMPONENT_ID_POSITION;
92 
93 protected:
95  SlotField(const ObjectState* state, MoveSlot& parent);
96 
97 private:
98  /// A container type for socket encodings.
99  typedef std::vector<SocketEncoding*> SocketEncodingTable;
100 
101  void clearSocketEncodings();
103 
104  /// The NOP encoding.
106  /// The container for socket encodings.
108  /// Position of the socket and bridge IDs within the field.
110 };
111 
112 #endif
113 
114 
SlotField::noOperationEncoding
NOPEncoding & noOperationEncoding() const
Definition: SlotField.cc:281
InstructionField.hh
MoveSlot
Definition: MoveSlot.hh:60
SlotField::componentIDPos_
BinaryEncoding::Position componentIDPos_
Position of the socket and bridge IDs within the field.
Definition: SlotField.hh:109
SlotField::hasSocketEncoding
bool hasSocketEncoding(const std::string &socket) const
Definition: SlotField.cc:188
SlotField::saveState
virtual ObjectState * saveState() const
Definition: SlotField.cc:388
SlotField::childFieldCount
virtual int childFieldCount() const
Definition: SlotField.cc:333
ObjectState
Definition: ObjectState.hh:59
SlotField::hasNoOperationEncoding
bool hasNoOperationEncoding() const
Definition: SlotField.cc:267
SlotField::socketEncoding
SocketEncoding & socketEncoding(int index) const
Definition: SlotField.cc:170
SlotField::removeSocketEncoding
void removeSocketEncoding(SocketEncoding &encoding)
Definition: SlotField.cc:143
InstructionField
Definition: InstructionField.hh:43
SlotField::setNoOperationEncoding
void setNoOperationEncoding(NOPEncoding &encoding)
Definition: SlotField.cc:234
SlotField::clearNoOperationEncoding
void clearNoOperationEncoding()
Definition: SlotField.cc:422
BinaryEncoding::Position
Position
Definition: BinaryEncoding.hh:63
SlotField::encodings_
SocketEncodingTable encodings_
The container for socket encodings.
Definition: SlotField.hh:107
BinaryEncoding.hh
SlotField::clearSocketEncodings
void clearSocketEncodings()
Definition: SlotField.cc:413
SlotField::width
virtual int width() const
Definition: SlotField.cc:307
SlotField::nopEncoding_
NOPEncoding * nopEncoding_
The NOP encoding.
Definition: SlotField.hh:105
SlotField::componentIDPosition
BinaryEncoding::Position componentIDPosition() const
Definition: SlotField.cc:296
SlotField::~SlotField
virtual ~SlotField()
Definition: SlotField.cc:88
SlotField::unsetNoOperationEncoding
void unsetNoOperationEncoding()
Definition: SlotField.cc:253
NOPEncoding
Definition: NOPEncoding.hh:44
SlotField::addSocketEncoding
void addSocketEncoding(SocketEncoding &encoding)
Definition: SlotField.cc:121
SlotField::SocketEncodingTable
std::vector< SocketEncoding * > SocketEncodingTable
A container type for socket encodings.
Definition: SlotField.hh:99
SlotField::childField
virtual InstructionField & childField(int position) const
Definition: SlotField.cc:345
SlotField::OSNAME_SLOT_FIELD
static const std::string OSNAME_SLOT_FIELD
ObjectState name for slot field.
Definition: SlotField.hh:89
SlotField
Definition: SlotField.hh:58
SlotField::socketEncodingCount
int socketEncodingCount() const
Definition: SlotField.cc:156
SlotField::OSKEY_COMPONENT_ID_POSITION
static const std::string OSKEY_COMPONENT_ID_POSITION
ObjectState attribute key for component ID position.
Definition: SlotField.hh:91
SlotField::SlotField
SlotField(BinaryEncoding::Position componentIDPos, MoveSlot &parent)
Definition: SlotField.cc:60
SocketEncoding
Definition: SocketEncoding.hh:51
SlotField::parent
MoveSlot * parent() const
Definition: SlotField.cc:98
SlotField::loadState
virtual void loadState(const ObjectState *state)
Definition: SlotField.cc:358