OpenASIP  2.0
Port.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 Port.hh
26  *
27  * Declaration of Port 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_PORT_HH
35 #define TTA_PORT_HH
36 
37 #include <string>
38 
39 #include "MachinePart.hh"
40 #include "Exception.hh"
41 
42 class ObjctState;
43 
44 namespace TTAMachine {
45 
46 class Socket;
47 class Unit;
48 class RegisterFile;
49 class FunctionUnit;
50 
51 /**
52  * Represents a port between function units and sockets.
53  */
54 class Port : public SubComponent {
55 public:
56  Port(const std::string& name, Unit& parentUnit);
57  Port(const ObjectState* state, Unit& parentUnit);
58  virtual ~Port();
59 
60  virtual std::string name() const;
61  virtual void setName(const std::string& name);
62  virtual int width() const = 0;
63  virtual void attachSocket(Socket& socket);
64  virtual void detachSocket(Socket& socket);
65  virtual void detachAllSockets();
66  Unit* parentUnit() const;
67  virtual Socket* inputSocket() const;
68  virtual Socket* outputSocket() const;
69  virtual Socket* unconnectedSocket(int index) const;
70  virtual int socketCount() const;
71  virtual bool isConnectedTo(const Socket& socket) const;
72 
73  virtual ObjectState* saveState() const;
74  virtual void loadState(const ObjectState* state);
75 
76  virtual bool isOutput() const;
77  virtual bool isInput() const;
78 
79  /// ObjectState name for Port.
80  static const std::string OSNAME_PORT;
81  /// ObjectState attribute key for the name of the port.
82  static const std::string OSKEY_NAME;
83  /// ObjectState attribute key for the name of the connected socket.
84  static const std::string OSKEY_FIRST_SOCKET;
85  /// ObjectState attribute key for the name of the other connected socket.
86  static const std::string OSKEY_SECOND_SOCKET;
87 
88  struct PairComparator {
89  bool operator()(
90  const std::pair<const Port*, const Port*>& pp1,
91  const std::pair<const Port*, const Port*>& pp2) const;
92  };
93 
94 protected:
95  Port(const std::string& name, FunctionUnit& parentUnit);
96 
97 private:
98  /// Copying forbidden.
99  Port(const Port&);
100  /// Assingment forbidden.
101  Port& operator=(const Port&);
102 
103  void loadStateWithoutReferences(const ObjectState* state);
104  void attachSocket(const std::string& socketName);
105 
106  /// Name of the port.
107  std::string name_;
108  /// Parent unit.
110  /// Connection to the first socket.
112  /// Connection to the second socket.
114 };
115 }
116 
117 #include "Port.icc"
118 
119 #endif
TTAMachine::Port::unconnectedSocket
virtual Socket * unconnectedSocket(int index) const
Definition: Port.cc:323
TTAMachine::Port::Port
Port(const std::string &name, Unit &parentUnit)
Definition: Port.cc:67
TTAMachine::Port::inputSocket
virtual Socket * inputSocket() const
Definition: Port.cc:261
TTAMachine::SubComponent
Definition: MachinePart.hh:168
TTAMachine::Port::saveState
virtual ObjectState * saveState() const
Definition: Port.cc:404
Exception.hh
TTAMachine::Port::PairComparator::operator()
bool operator()(const std::pair< const Port *, const Port * > &pp1, const std::pair< const Port *, const Port * > &pp2) const
Definition: Port.cc:549
TTAMachine::Port::width
virtual int width() const =0
ObjectState
Definition: ObjectState.hh:59
TTAMachine::Port::OSKEY_SECOND_SOCKET
static const std::string OSKEY_SECOND_SOCKET
ObjectState attribute key for the name of the other connected socket.
Definition: Port.hh:86
MachinePart.hh
TTAMachine::Port::OSNAME_PORT
static const std::string OSNAME_PORT
ObjectState name for Port.
Definition: Port.hh:80
TTAMachine::Port::socketCount
virtual int socketCount() const
Definition: Port.cc:375
TTAMachine::Port::name_
std::string name_
Name of the port.
Definition: Port.hh:107
TTAMachine::Port::setName
virtual void setName(const std::string &name)
Definition: Port.cc:155
TTAMachine::Port::loadState
virtual void loadState(const ObjectState *state)
Definition: Port.cc:459
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::Port::~Port
virtual ~Port()
Definition: Port.cc:117
TTAMachine::Port::attachSocket
virtual void attachSocket(Socket &socket)
Definition: Port.cc:191
TTAMachine::Unit
Definition: Unit.hh:51
TTAMachine::Port
Definition: Port.hh:54
TTAMachine::Port::PairComparator
Definition: Port.hh:88
TTAMachine::Socket
Definition: Socket.hh:53
TTAMachine::Port::operator=
Port & operator=(const Port &)
Assingment forbidden.
TTAMachine::Port::detachSocket
virtual void detachSocket(Socket &socket)
Definition: Port.cc:237
TTAMachine::Port::parentUnit_
Unit * parentUnit_
Parent unit.
Definition: Port.hh:109
TTAMachine::Port::isOutput
virtual bool isOutput() const
Definition: Port.cc:308
Port.icc
TTAMachine::Port::socket2_
Socket * socket2_
Connection to the second socket.
Definition: Port.hh:113
TTAMachine::Port::socket1_
Socket * socket1_
Connection to the first socket.
Definition: Port.hh:111
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
TTAMachine::Port::OSKEY_NAME
static const std::string OSKEY_NAME
ObjectState attribute key for the name of the port.
Definition: Port.hh:82
TTAMachine::Port::loadStateWithoutReferences
void loadStateWithoutReferences(const ObjectState *state)
Definition: Port.cc:434
TTAMachine::Port::outputSocket
virtual Socket * outputSocket() const
Definition: Port.cc:281
TTAMachine::Port::isInput
virtual bool isInput() const
Definition: Port.cc:298
TTAMachine::Port::isConnectedTo
virtual bool isConnectedTo(const Socket &socket) const
Definition: Port.cc:393
TTAMachine
Definition: Assembler.hh:48
TTAMachine::Port::detachAllSockets
virtual void detachAllSockets()
Definition: Port.cc:536
TTAMachine::Port::OSKEY_FIRST_SOCKET
static const std::string OSKEY_FIRST_SOCKET
ObjectState attribute key for the name of the connected socket.
Definition: Port.hh:84
TTAMachine::Port::parentUnit
Unit * parentUnit() const