gem5  v21.2.0.0
token_port.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __MEM_TOKEN_PORT_HH__
33 #define __MEM_TOKEN_PORT_HH__
34 
35 #include "mem/port.hh"
36 #include "sim/clocked_object.hh"
37 
38 namespace gem5
39 {
40 
41 class TokenManager;
42 class TokenResponsePort;
43 
45 {
46  private:
47  /* Manager to track tokens between this token port pair. */
49 
50  public:
51  TokenRequestPort(const std::string& name, SimObject* owner,
52  PortID id = InvalidPortID) :
53  RequestPort(name, owner, id), tokenManager(nullptr)
54  { }
55 
60  void bind(Port &peer) override;
61 
65  void unbind() override {}
66 
71  void recvTokens(int num_tokens);
72 
76  bool haveTokens(int num_tokens);
77 
82  void acquireTokens(int num_tokens);
83 
88  void setTokenManager(TokenManager *_tokenManager);
89 };
90 
92 {
93  private:
95 
97 
98  void recvRespRetry() override;
99 
100  public:
102  PortID id = InvalidPortID) :
104  { }
106 
112  void bind(Port &peer) override;
113 
117  void unbind() override;
118 
122  void sendTokens(int num_tokens);
123 
124  bool sendTimingResp(PacketPtr pkt);
125 
126  /* There is no storage here so the packet will not be found. */
127  bool trySatisfyFunctional(PacketPtr) { return false; }
128 };
129 
131 {
132  protected:
133  /* Maximum tokens possible */
135 
136  /* Number of currently available tokens */
138 
139  public:
140  TokenManager(int init_tokens);
142 
146  int getMaxTokenCount() const;
147 
151  void recvTokens(int num_tokens);
152 
156  bool haveTokens(int num_tokens);
157 
161  void acquireTokens(int num_tokens);
162 };
163 
164 } // namespace gem5
165 
166 #endif
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::TokenResponsePort::TokenResponsePort
TokenResponsePort(const std::string &name, ClockedObject *owner, PortID id=InvalidPortID)
Definition: token_port.hh:101
gem5::TokenRequestPort::tokenManager
TokenManager * tokenManager
Definition: token_port.hh:48
gem5::Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
gem5::TokenManager::haveTokens
bool haveTokens(int num_tokens)
Query is num_tokens tokens are available.
Definition: token_port.cc:167
gem5::TokenManager::~TokenManager
~TokenManager()
Definition: token_port.hh:141
gem5::TokenManager
Definition: token_port.hh:130
gem5::Port::id
const PortID id
A numeric identifier to distinguish ports in a vector, and set to InvalidPortID in case this port is ...
Definition: port.hh:79
gem5::TokenManager::availableTokens
int availableTokens
Definition: token_port.hh:137
gem5::TokenRequestPort::recvTokens
void recvTokens(int num_tokens)
Receive tokens returned by the response port.
Definition: token_port.cc:48
gem5::TokenRequestPort::bind
void bind(Port &peer) override
Bind this request port to response port.
Definition: token_port.cc:42
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::TokenManager::maxTokens
int maxTokens
Definition: token_port.hh:134
gem5::TokenResponsePort::unbind
void unbind() override
Unbind this response port and associated request port.
Definition: token_port.cc:109
gem5::TokenRequestPort::setTokenManager
void setTokenManager(TokenManager *_tokenManager)
Specify a token manger, which will handle tracking of tokens for a TokenRequestPort/ResponseRequestPo...
Definition: token_port.cc:72
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::TokenRequestPort::haveTokens
bool haveTokens(int num_tokens)
Query if there are at least num_tokens tokens available to acquire.
Definition: token_port.cc:56
gem5::TokenResponsePort::respQueue
std::deque< PacketPtr > respQueue
Definition: token_port.hh:96
gem5::TokenManager::TokenManager
TokenManager(int init_tokens)
Definition: token_port.cc:142
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::TokenResponsePort::recvRespRetry
void recvRespRetry() override
Called by the peer if sendTimingResp was called on this protocol (causing recvTimingResp to be called...
Definition: token_port.cc:116
port.hh
gem5::TokenRequestPort::acquireTokens
void acquireTokens(int num_tokens)
Acquire tokens by decrementing the number of available tokens across the port.
Definition: token_port.cc:64
gem5::TokenResponsePort::trySatisfyFunctional
bool trySatisfyFunctional(PacketPtr)
Definition: token_port.hh:127
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::TokenResponsePort::~TokenResponsePort
~TokenResponsePort()
Definition: token_port.hh:105
gem5::ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:268
gem5::ResponsePort::owner
SimObject & owner
Definition: port.hh:279
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::TokenResponsePort::sendTokens
void sendTokens(int num_tokens)
Return num_tokens tokens back to the request port.
Definition: token_port.cc:78
clocked_object.hh
std::deque
STL deque class.
Definition: stl.hh:44
gem5::TokenResponsePort::bind
void bind(Port &peer) override
Bind this response port to a request port.
Definition: token_port.cc:87
gem5::TokenManager::recvTokens
void recvTokens(int num_tokens)
Increment the number of available tokens by num_tokens.
Definition: token_port.cc:155
gem5::TokenManager::getMaxTokenCount
int getMaxTokenCount() const
Return the maximum possible tokens.
Definition: token_port.cc:149
gem5::TokenResponsePort::sendTimingResp
bool sendTimingResp(PacketPtr pkt)
Definition: token_port.cc:131
gem5::RequestPort::owner
SimObject & owner
Definition: port.hh:86
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::TokenResponsePort
Definition: token_port.hh:91
gem5::TokenResponsePort::tokenRequestPort
TokenRequestPort * tokenRequestPort
Definition: token_port.hh:94
gem5::TokenManager::acquireTokens
void acquireTokens(int num_tokens)
Decrement the number of available tokens by num_tokens.
Definition: token_port.cc:173
gem5::TokenRequestPort::TokenRequestPort
TokenRequestPort(const std::string &name, SimObject *owner, PortID id=InvalidPortID)
Definition: token_port.hh:51
gem5::TokenRequestPort
Definition: token_port.hh:44
gem5::TokenRequestPort::unbind
void unbind() override
Unbind port.
Definition: token_port.hh:65

Generated on Tue Dec 21 2021 11:34:34 for gem5 by doxygen 1.8.17