gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
port.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2002-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * Authors: Ron Dreslinski
41  * Andreas Hansson
42  * William Wang
43  */
44 
50 #ifndef __MEM_PORT_HH__
51 #define __MEM_PORT_HH__
52 
53 #include "base/addr_range.hh"
54 #include "mem/packet.hh"
55 
56 class MemObject;
57 
63 class Port
64 {
65 
66  private:
67 
69  std::string portName;
70 
71  protected:
72 
77  const PortID id;
78 
81 
89  Port(const std::string& _name, MemObject& _owner, PortID _id);
90 
94  virtual ~Port();
95 
96  public:
97 
99  const std::string name() const { return portName; }
100 
102  PortID getId() const { return id; }
103 
104 };
105 
107 class BaseSlavePort;
108 
115 class BaseMasterPort : public Port
116 {
117 
118  protected:
119 
121 
122  BaseMasterPort(const std::string& name, MemObject* owner,
123  PortID id = InvalidPortID);
124  virtual ~BaseMasterPort();
125 
126  public:
127 
128  virtual void bind(BaseSlavePort& slave_port) = 0;
129  virtual void unbind() = 0;
130  BaseSlavePort& getSlavePort() const;
131  bool isConnected() const;
132 
133 };
134 
139 class BaseSlavePort : public Port
140 {
141 
142  protected:
143 
145 
146  BaseSlavePort(const std::string& name, MemObject* owner,
147  PortID id = InvalidPortID);
148  virtual ~BaseSlavePort();
149 
150  public:
151 
152  BaseMasterPort& getMasterPort() const;
153  bool isConnected() const;
154 
155 };
156 
158 class SlavePort;
159 
168 {
169 
170  friend class SlavePort;
171 
172  private:
173 
175 
176  public:
177 
178  MasterPort(const std::string& name, MemObject* owner,
179  PortID id = InvalidPortID);
180  virtual ~MasterPort();
181 
186  void bind(BaseSlavePort& slave_port);
187 
191  void unbind();
192 
203 
211  void sendFunctional(PacketPtr pkt);
212 
224  bool sendTimingReq(PacketPtr pkt);
225 
235  bool sendTimingSnoopResp(PacketPtr pkt);
236 
243  virtual void sendRetryResp();
244 
254  virtual bool isSnooping() const { return false; }
255 
260 
264  void printAddr(Addr a);
265 
266  protected:
267 
272  {
273  panic("%s was not expecting an atomic snoop request\n", name());
274  return 0;
275  }
276 
280  virtual void recvFunctionalSnoop(PacketPtr pkt)
281  {
282  panic("%s was not expecting a functional snoop request\n", name());
283  }
284 
288  virtual bool recvTimingResp(PacketPtr pkt) = 0;
289 
293  virtual void recvTimingSnoopReq(PacketPtr pkt)
294  {
295  panic("%s was not expecting a timing snoop request\n", name());
296  }
297 
303  virtual void recvReqRetry() = 0;
304 
310  virtual void recvRetrySnoopResp()
311  {
312  panic("%s was not expecting a snoop retry\n", name());
313  }
314 
322  virtual void recvRangeChange() { }
323 };
324 
331 class SlavePort : public BaseSlavePort
332 {
333 
334  friend class MasterPort;
335 
336  private:
337 
339 
340  public:
341 
342  SlavePort(const std::string& name, MemObject* owner,
343  PortID id = InvalidPortID);
344  virtual ~SlavePort();
345 
356 
364  void sendFunctionalSnoop(PacketPtr pkt);
365 
377  bool sendTimingResp(PacketPtr pkt);
378 
386  void sendTimingSnoopReq(PacketPtr pkt);
387 
392  void sendRetryReq();
393 
398  void sendRetrySnoopResp();
399 
405  bool isSnooping() const { return _masterPort->isSnooping(); }
406 
410  void sendRangeChange() const {
411  if (!_masterPort)
412  fatal("%s cannot sendRangeChange() without master port", name());
414  }
415 
423  virtual AddrRangeList getAddrRanges() const = 0;
424 
425  protected:
426 
431  void unbind();
432 
437  void bind(MasterPort& master_port);
438 
442  virtual Tick recvAtomic(PacketPtr pkt) = 0;
443 
447  virtual void recvFunctional(PacketPtr pkt) = 0;
448 
452  virtual bool recvTimingReq(PacketPtr pkt) = 0;
453 
457  virtual bool recvTimingSnoopResp(PacketPtr pkt)
458  {
459  panic("%s was not expecting a timing snoop response\n", name());
460  }
461 
467  virtual void recvRespRetry() = 0;
468 
469 };
470 
471 #endif //__MEM_PORT_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
MemObject & owner
A reference to the MemObject that owns this port.
Definition: port.hh:80
Ports are used to interface memory objects to each other.
Definition: port.hh:63
PortID getId() const
Get the port id.
Definition: port.hh:102
virtual void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the slave port.
Definition: port.hh:293
virtual void recvRangeChange()
Called to receive an address range change from the peer slave port.
Definition: port.hh:322
Port(const std::string &_name, MemObject &_owner, PortID _id)
Abstract base class for ports.
Definition: port.cc:54
const PortID InvalidPortID
Definition: types.hh:182
virtual void recvRespRetry()=0
Called by the master port if sendTimingResp was called on this slave port (causing recvTimingResp to ...
#define panic(...)
Definition: misc.hh:153
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:99
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the slave port by calling its corresponding receive...
Definition: port.cc:187
void bind(MasterPort &master_port)
Called by the master port to bind.
Definition: port.cc:230
Bitfield< 8 > a
Definition: miscregs.hh:1377
Tick sendAtomicSnoop(PacketPtr pkt)
Send an atomic snoop request packet, where the data is moved and the state is updated in zero time...
Definition: port.cc:237
virtual void recvFunctional(PacketPtr pkt)=0
Receive a functional request packet from the master port.
void sendFunctionalSnoop(PacketPtr pkt)
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition: port.cc:244
BaseSlavePort * _baseSlavePort
Definition: port.hh:120
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
Definition: port.cc:180
A SlavePort is a specialisation of a port.
Definition: port.hh:331
virtual void sendRetryResp()
Send a retry to the slave port that previously attempted a sendTimingResp to this master port and fai...
Definition: port.cc:194
MasterPort * _masterPort
Definition: port.hh:338
virtual Tick recvAtomic(PacketPtr pkt)=0
Receive an atomic request packet from the master port.
void sendRetrySnoopResp()
Send a retry to the master port that previously attempted a sendTimingSnoopResp to this slave port an...
Definition: port.cc:271
A BaseSlavePort is a protocol-agnostic slave port, responsible only for the structural connection to ...
Definition: port.hh:139
virtual bool recvTimingResp(PacketPtr pkt)=0
Receive a timing response from the slave port.
virtual ~Port()
Virtual destructor due to inheritance.
Definition: port.cc:59
BaseMasterPort * _baseMasterPort
Definition: port.hh:144
SlavePort * _slavePort
Definition: port.hh:174
virtual ~SlavePort()
Definition: port.cc:218
bool isSnooping() const
Find out if the peer master port is snooping or not.
Definition: port.hh:405
virtual void unbind()=0
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the master port by calling its corresponding receive function...
Definition: port.cc:251
void unbind()
Unbind this master port and the associated slave port.
Definition: port.cc:149
virtual void recvReqRetry()=0
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the slave port.
Definition: port.hh:280
uint64_t Tick
Tick count type.
Definition: types.hh:63
#define fatal(...)
Definition: misc.hh:163
virtual void recvRetrySnoopResp()
Called by the slave port if sendTimingSnoopResp was called on this master port (causing recvTimingSno...
Definition: port.hh:310
virtual ~BaseMasterPort()
Definition: port.cc:69
void unbind()
Called by the master port to unbind.
Definition: port.cc:223
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void printAddr(Addr a)
Inject a PrintReq for the given address to print the state of that address throughout the memory syst...
Definition: port.cc:200
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
BaseSlavePort(const std::string &name, MemObject *owner, PortID id=InvalidPortID)
Definition: port.cc:89
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:410
BaseMasterPort & getMasterPort() const
Definition: port.cc:100
std::string portName
Descriptive name (for DPRINTF output)
Definition: port.hh:69
virtual ~MasterPort()
Definition: port.cc:123
bool isConnected() const
Definition: port.cc:84
virtual bool recvTimingReq(PacketPtr pkt)=0
Receive a timing request from the master port.
AddrRangeList getAddrRanges() const
Get the address ranges of the connected slave port.
Definition: port.cc:160
virtual void bind(BaseSlavePort &slave_port)=0
Declaration of the Packet class.
virtual AddrRangeList getAddrRanges() const =0
Get a list of the non-overlapping address ranges the owner is responsible for.
const PortID id
A numeric identifier to distinguish ports in a vector, and set to InvalidPortID in case this port is ...
Definition: port.hh:77
void sendRetryReq()
Send a retry to the master port that previously attempted a sendTimingReq to this slave port and fail...
Definition: port.cc:265
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
Definition: mem_object.hh:60
A BaseMasterPort is a protocol-agnostic master port, responsible only for the structural connection t...
Definition: port.hh:115
SlavePort(const std::string &name, MemObject *owner, PortID id=InvalidPortID)
Slave port.
Definition: port.cc:213
bool isConnected() const
Definition: port.cc:110
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the master port by calling its corresponding receive...
Definition: port.cc:258
void bind(BaseSlavePort &slave_port)
Bind this master port to a slave port.
Definition: port.cc:128
BaseSlavePort & getSlavePort() const
Definition: port.cc:74
virtual Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from the slave port.
Definition: port.hh:271
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
virtual bool isSnooping() const
Determine if this master port is snooping or not.
Definition: port.hh:254
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time...
Definition: port.cc:166
MasterPort(const std::string &name, MemObject *owner, PortID id=InvalidPortID)
Master port.
Definition: port.cc:118
BaseMasterPort(const std::string &name, MemObject *owner, PortID id=InvalidPortID)
Definition: port.cc:63
virtual bool recvTimingSnoopResp(PacketPtr pkt)
Receive a timing snoop response from the master port.
Definition: port.hh:457
void sendFunctional(PacketPtr pkt)
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition: port.cc:173
virtual ~BaseSlavePort()
Definition: port.cc:95

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6