gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
port.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015,2017 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 #include "mem/protocol/atomic.hh"
57 #include "mem/protocol/timing.hh"
58 #include "sim/port.hh"
59 
60 class SimObject;
61 
63 class SlavePort;
64 
75 class MasterPort : public Port, public AtomicRequestProtocol,
77 {
78  friend class SlavePort;
79 
80  private:
82 
83  protected:
85 
86  public:
87  MasterPort(const std::string& name, SimObject* _owner,
89  virtual ~MasterPort();
90 
95  void bind(Port &peer) override;
96 
100  void unbind() override;
101 
111  virtual bool isSnooping() const { return false; }
112 
117 
122  void printAddr(Addr a);
123 
124  public:
125  /* The atomic protocol. */
126 
137 
149 
150  public:
151  /* The functional protocol. */
152 
160  void sendFunctional(PacketPtr pkt) const;
161 
162  public:
163  /* The timing protocol. */
164 
176  bool sendTimingReq(PacketPtr pkt);
177 
189  bool tryTiming(PacketPtr pkt) const;
190 
200  bool sendTimingSnoopResp(PacketPtr pkt);
201 
208  virtual void sendRetryResp();
209 
210  protected:
218  virtual void recvRangeChange() { }
219 
223  Tick
225  {
226  panic("%s was not expecting an atomic snoop request\n", name());
227  return 0;
228  }
229 
230  void
232  {
233  panic("%s was not expecting a functional snoop request\n", name());
234  }
235 
236  void
238  {
239  panic("%s was not expecting a timing snoop request.\n", name());
240  }
241 
242  void
244  {
245  panic("%s was not expecting a snoop retry.\n", name());
246  }
247 };
248 
258 class SlavePort : public Port, public AtomicResponseProtocol,
260 {
261  friend class MasterPort;
262 
263  private:
266 
267  protected:
269 
270  public:
271  SlavePort(const std::string& name, SimObject* _owner,
272  PortID id=InvalidPortID);
273  virtual ~SlavePort();
274 
280  bool isSnooping() const { return _masterPort->isSnooping(); }
281 
285  void
287  {
288  fatal_if(!_masterPort,
289  "%s cannot sendRangeChange() without master port.", name());
290  _masterPort->recvRangeChange();
291  }
292 
300  virtual AddrRangeList getAddrRanges() const = 0;
301 
305  void unbind() override {}
306  void bind(Port &peer) override {}
307 
308  public:
309  /* The atomic protocol. */
310 
320  Tick
322  {
323  return AtomicResponseProtocol::sendSnoop(_masterPort, pkt);
324  }
325 
326  public:
327  /* The functional protocol. */
328 
336  void
338  {
339  FunctionalResponseProtocol::sendSnoop(_masterPort, pkt);
340  }
341 
342  public:
343  /* The timing protocol. */
344 
356  bool
358  {
359  return TimingResponseProtocol::sendResp(_masterPort, pkt);
360  }
361 
369  void
371  {
372  TimingResponseProtocol::sendSnoopReq(_masterPort, pkt);
373  }
374 
379  void
381  {
383  }
384 
389  void
391  {
393  }
394 
395  protected:
400  void slaveUnbind();
401 
406  void slaveBind(MasterPort& master_port);
407 
411  Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override;
412 
413  bool
414  tryTiming(PacketPtr pkt) override
415  {
416  panic("%s was not expecting a %s\n", name(), __func__);
417  }
418 
419  bool
421  {
422  panic("%s was not expecting a timing snoop response\n", name());
423  }
424 };
425 
426 inline Tick
428 {
430 }
431 
432 inline Tick
434 {
435  return AtomicRequestProtocol::sendBackdoor(_slavePort, pkt, backdoor);
436 }
437 
438 inline void
440 {
442 }
443 
444 inline bool
446 {
448 }
449 
450 inline bool
452 {
454 }
455 
456 inline bool
458 {
460 }
461 
462 inline void
464 {
466 }
467 
468 #endif //__MEM_PORT_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
virtual bool isSnooping() const
Determine if this master port is snooping or not.
Definition: port.hh:111
Ports are used to interface objects to each other.
Definition: port.hh:60
SimObject & owner
Definition: port.hh:268
bool sendSnoopResp(TimingResponseProtocol *peer, PacketPtr pkt)
Attempt to send a timing snoop response packet to it's peer by calling its corresponding receive func...
Definition: timing.cc:65
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:286
virtual void recvRangeChange()
Called to receive an address range change from the peer slave port.
Definition: port.hh:218
Tick recvAtomicSnoop(PacketPtr pkt) override
Default implementations.
Definition: port.hh:224
const PortID InvalidPortID
Definition: types.hh:238
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: port.hh:231
void sendRetryReq(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingReq to this protocol and failed...
Definition: timing.cc:96
bool defaultBackdoorWarned
Definition: port.hh:265
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the slave port by calling its corresponding receive...
Definition: port.hh:457
Bitfield< 8 > a
bool tryTiming(PacketPtr pkt) const
Check if the slave can handle a timing request.
Definition: port.hh:451
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.hh:321
void recvRetrySnoopResp() override
Called by the peer if sendTimingSnoopResp was called on this protocol (causing recvTimingSnoopResp to...
Definition: port.hh:243
Tick sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
Send an atomic request packet like above, but also request a backdoor to the data being accessed...
Definition: port.hh:433
void sendRetryResp(TimingResponseProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingResp to this protocol and failed...
Definition: timing.cc:73
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
Definition: port.hh:445
A SlavePort is a specialisation of a port.
Definition: port.hh:258
virtual void sendRetryResp()
Send a retry to the slave port that previously attempted a sendTimingResp to this master port and fai...
Definition: port.hh:463
MasterPort * _masterPort
Definition: port.hh:264
MasterPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Master port.
Definition: port.cc:57
void sendSnoopReq(TimingRequestProtocol *peer, PacketPtr pkt)
Attempt to send a timing snoop request packet to the peer by calling its corresponding receive functi...
Definition: timing.cc:88
void sendRetrySnoopResp()
Send a retry to the master port that previously attempted a sendTimingSnoopResp to this slave port an...
Definition: port.hh:390
void unbind() override
We let the master port do the work, so these don&#39;t do anything.
Definition: port.hh:305
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition: port.hh:337
SlavePort * _slavePort
Definition: port.hh:81
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the master port by calling its corresponding receive function...
Definition: port.hh:357
void sendSnoop(FunctionalRequestProtocol *peer, PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition: functional.cc:60
bool sendReq(TimingResponseProtocol *peer, PacketPtr pkt)
Attempt to send a timing request to the peer by calling its corresponding receive function...
Definition: timing.cc:50
void sendRetrySnoopResp(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingSnoopResp to this peer and failed...
Definition: timing.cc:102
Tick sendSnoop(AtomicRequestProtocol *peer, PacketPtr pkt)
Send an atomic snoop request packet, where the data is moved and the state is updated in zero time...
Definition: atomic.cc:69
uint64_t Tick
Tick count type.
Definition: types.hh:63
bool sendResp(TimingRequestProtocol *peer, PacketPtr pkt)
Attempt to send a timing response to the peer by calling its corresponding receive function...
Definition: timing.cc:81
SimObject & owner
Definition: port.hh:84
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:203
void bind(Port &peer) override
Bind this master port to a slave port.
Definition: port.cc:67
bool isSnooping() const
Find out if the peer master port is snooping or not.
Definition: port.hh:280
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:99
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: port.hh:237
bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition: port.hh:414
Port Object Declaration.
virtual ~MasterPort()
Definition: port.cc:62
bool trySend(TimingResponseProtocol *peer, PacketPtr pkt) const
Check if the peer can handle a timing request.
Definition: timing.cc:57
void bind(Port &peer) override
Attach to a peer port.
Definition: port.hh:306
AddrRangeList getAddrRanges() const
Get the address ranges of the connected slave port.
Definition: port.cc:93
Declaration of the Packet class.
void sendRetryReq()
Send a retry to the master port that previously attempted a sendTimingReq to this slave port and fail...
Definition: port.hh:380
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
void send(FunctionalResponseProtocol *peer, PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition: functional.cc:50
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the master port by calling its corresponding receive...
Definition: port.hh:370
Tick send(AtomicResponseProtocol *peer, PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time...
Definition: atomic.cc:52
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition: port.hh:439
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
void unbind() override
Unbind this master port and the associated slave port.
Definition: port.cc:82
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: port.hh:420
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time...
Definition: port.hh:427
friend class SlavePort
Definition: port.hh:78
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
Tick sendBackdoor(AtomicResponseProtocol *peer, PacketPtr pkt, MemBackdoorPtr &backdoor)
Send an atomic request packet like above, but also request a backdoor to the data being accessed...
Definition: atomic.cc:59

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13