gem5  v22.1.0.0
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 
46 #ifndef __MEM_PORT_HH__
47 #define __MEM_PORT_HH__
48 
49 #include "base/addr_range.hh"
50 #include "mem/packet.hh"
51 #include "mem/protocol/atomic.hh"
53 #include "mem/protocol/timing.hh"
54 #include "sim/port.hh"
55 
56 namespace gem5
57 {
58 
59 class SimObject;
60 
62 class MasterPort;
63 class SlavePort;
64 
65 class ResponsePort;
66 
77 class RequestPort: public Port, public AtomicRequestProtocol,
79 {
80  friend class ResponsePort;
81 
82  private:
84 
85  protected:
87 
88  public:
89  RequestPort(const std::string& name, SimObject* _owner,
91  virtual ~RequestPort();
92 
97  void bind(Port &peer) override;
98 
102  void unbind() override;
103 
113  virtual bool isSnooping() const { return false; }
114 
119 
124  void printAddr(Addr a);
125 
126  public:
127  /* The atomic protocol. */
128 
139 
151 
152  public:
153  /* The functional protocol. */
154 
162  void sendFunctional(PacketPtr pkt) const;
163 
164  public:
165  /* The timing protocol. */
166 
178  bool sendTimingReq(PacketPtr pkt);
179 
191  bool tryTiming(PacketPtr pkt) const;
192 
202  bool sendTimingSnoopResp(PacketPtr pkt);
203 
210  virtual void sendRetryResp();
211 
212  protected:
220  virtual void recvRangeChange() { }
221 
225  Tick
227  {
228  panic("%s was not expecting an atomic snoop request\n", name());
229  return 0;
230  }
231 
232  void
234  {
235  panic("%s was not expecting a functional snoop request\n", name());
236  }
237 
238  void
240  {
241  panic("%s was not expecting a timing snoop request.\n", name());
242  }
243 
244  void
246  {
247  panic("%s was not expecting a snoop retry.\n", name());
248  }
249 };
250 
251 class [[deprecated]] MasterPort : public RequestPort
252 {
253  public:
254  MasterPort(const std::string& name, SimObject* _owner,
255  PortID id=InvalidPortID) : RequestPort(name, _owner, id)
256  {}
257 };
258 
268 class ResponsePort : public Port, public AtomicResponseProtocol,
270 {
271  friend class RequestPort;
272 
273  private:
275 
277 
278  protected:
280 
281  public:
282  ResponsePort(const std::string& name, SimObject* _owner,
283  PortID id=InvalidPortID);
284  virtual ~ResponsePort();
285 
291  bool isSnooping() const { return _requestPort->isSnooping(); }
292 
297 
305  virtual AddrRangeList getAddrRanges() const = 0;
306 
310  void unbind() override {}
311  void bind(Port &peer) override {}
312 
313  public:
314  /* The atomic protocol. */
315 
325  Tick
327  {
328  try {
330  } catch (UnboundPortException) {
331  reportUnbound();
332  }
333  }
334 
335  public:
336  /* The functional protocol. */
337 
345  void
347  {
348  try {
350  } catch (UnboundPortException) {
351  reportUnbound();
352  }
353  }
354 
355  public:
356  /* The timing protocol. */
357 
369  bool
371  {
372  try {
374  } catch (UnboundPortException) {
375  reportUnbound();
376  }
377  }
378 
386  void
388  {
389  try {
391  } catch (UnboundPortException) {
392  reportUnbound();
393  }
394  }
395 
400  void
402  {
403  try {
405  } catch (UnboundPortException) {
406  reportUnbound();
407  }
408  }
409 
414  void
416  {
417  try {
419  } catch (UnboundPortException) {
420  reportUnbound();
421  }
422  }
423 
424  protected:
429  void responderUnbind();
430 
435  void responderBind(RequestPort& request_port);
436 
440  Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override;
441 
442  bool
443  tryTiming(PacketPtr pkt) override
444  {
445  panic("%s was not expecting a %s\n", name(), __func__);
446  }
447 
448  bool
450  {
451  panic("%s was not expecting a timing snoop response\n", name());
452  }
453 };
454 
455 class [[deprecated]] SlavePort : public ResponsePort
456 {
457  public:
458  SlavePort(const std::string& name, SimObject* _owner,
459  PortID id=InvalidPortID) : ResponsePort(name, _owner, id)
460  {}
461 };
462 
463 inline Tick
465 {
466  try {
468  } catch (UnboundPortException) {
469  reportUnbound();
470  }
471 }
472 
473 inline Tick
475 {
476  try {
478  pkt, backdoor);
479  } catch (UnboundPortException) {
480  reportUnbound();
481  }
482 }
483 
484 inline void
486 {
487  try {
489  } catch (UnboundPortException) {
490  reportUnbound();
491  }
492 }
493 
494 inline bool
496 {
497  try {
499  } catch (UnboundPortException) {
500  reportUnbound();
501  }
502 }
503 
504 inline bool
506 {
507  try {
509  } catch (UnboundPortException) {
510  reportUnbound();
511  }
512 }
513 
514 inline bool
516 {
517  try {
519  } catch (UnboundPortException) {
520  reportUnbound();
521  }
522 }
523 
524 inline void
526 {
527  try {
529  } catch (UnboundPortException) {
530  reportUnbound();
531  }
532 }
533 
534 } // namespace gem5
535 
536 #endif //__MEM_PORT_HH__
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:58
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:51
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:68
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:49
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:59
MasterPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Definition: port.hh:254
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
void reportUnbound() const
Definition: port.cc:60
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
virtual void sendRetryResp()
Send a retry to the response port that previously attempted a sendTimingResp to this request port and...
Definition: port.hh:525
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: port.hh:239
virtual void recvRangeChange()
Called to receive an address range change from the peer response port.
Definition: port.hh:220
SimObject & owner
Definition: port.hh:86
virtual ~RequestPort()
Definition: port.cc:124
void unbind() override
Unbind this request port and the associated response port.
Definition: port.cc:142
virtual bool isSnooping() const
Determine if this request port is snooping or not.
Definition: port.hh:113
bool tryTiming(PacketPtr pkt) const
Check if the responder can handle a timing request.
Definition: port.hh:505
Tick recvAtomicSnoop(PacketPtr pkt) override
Default implementations.
Definition: port.hh:226
ResponsePort * _responsePort
Definition: port.hh:83
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:464
AddrRangeList getAddrRanges() const
Get the address ranges of the connected responder port.
Definition: port.cc:152
void bind(Port &peer) override
Bind this request port to a response port.
Definition: port.cc:129
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
Definition: port.hh:495
void recvRetrySnoopResp() override
Called by the peer if sendTimingSnoopResp was called on this protocol (causing recvTimingSnoopResp to...
Definition: port.hh:245
bool sendTimingSnoopResp(PacketPtr pkt)
Attempt to send a timing snoop response packet to the response port by calling its corresponding rece...
Definition: port.hh:515
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
Definition: port.cc:118
void sendFunctional(PacketPtr pkt) const
Send a functional request packet, where the data is instantly updated everywhere in the memory system...
Definition: port.hh:485
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:158
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: port.hh:233
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:474
A ResponsePort is a specialization of a port.
Definition: port.hh:270
SimObject & owner
Definition: port.hh:279
bool sendTimingResp(PacketPtr pkt)
Attempt to send a timing response to the request port by calling its corresponding receive function.
Definition: port.hh:370
void sendFunctionalSnoop(PacketPtr pkt) const
Send a functional snoop request packet, where the data is instantly updated everywhere in the memory ...
Definition: port.hh:346
bool tryTiming(PacketPtr pkt) override
Availability request from the peer.
Definition: port.hh:443
void bind(Port &peer) override
Attach to a peer port.
Definition: port.hh:311
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:415
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Default implementations.
Definition: port.cc:198
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: port.hh:449
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:326
ResponsePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Response port.
Definition: port.cc:173
void sendTimingSnoopReq(PacketPtr pkt)
Attempt to send a timing snoop request packet to the request port by calling its corresponding receiv...
Definition: port.hh:387
bool isSnooping() const
Find out if the peer request port is snooping or not.
Definition: port.hh:291
void responderUnbind()
Called by the request port to unbind.
Definition: port.cc:184
bool defaultBackdoorWarned
Definition: port.hh:276
void unbind() override
We let the request port do the work, so these don't do anything.
Definition: port.hh:310
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:296
void responderBind(RequestPort &request_port)
Called by the request port to bind.
Definition: port.cc:191
virtual AddrRangeList getAddrRanges() const =0
Get a list of the non-overlapping address ranges the owner is responsible for.
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition: port.hh:401
virtual ~ResponsePort()
Definition: port.cc:179
RequestPort * _requestPort
Definition: port.hh:274
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
SlavePort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Definition: port.hh:458
void sendRetryResp(TimingResponseProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingResp to this protocol and failed.
Definition: timing.cc:72
bool trySend(TimingResponseProtocol *peer, PacketPtr pkt) const
Check if the peer can handle a timing request.
Definition: timing.cc:56
bool sendReq(TimingResponseProtocol *peer, PacketPtr pkt)
Attempt to send a timing request to the peer by calling its corresponding receive function.
Definition: timing.cc:49
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:64
bool sendResp(TimingRequestProtocol *peer, PacketPtr pkt)
Attempt to send a timing response to the peer by calling its corresponding receive function.
Definition: timing.cc:80
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:87
void sendRetrySnoopResp(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingSnoopResp to this peer and failed.
Definition: timing.cc:101
void sendRetryReq(TimingRequestProtocol *peer)
Send a retry to the peer that previously attempted a sendTimingReq to this protocol and failed.
Definition: timing.cc:95
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
Bitfield< 33 > id
Definition: misc_types.hh:257
Bitfield< 8 > a
Definition: misc_types.hh:66
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
Declaration of the Packet class.
Port Object Declaration.
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:37 for gem5 by doxygen 1.9.1