gem5  v20.1.0.0
AbstractController.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017,2019 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) 2009-2014 Mark D. Hill and David A. Wood
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 
41 #ifndef __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__
42 #define __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__
43 
44 #include <exception>
45 #include <iostream>
46 #include <string>
47 
48 #include "base/addr_range.hh"
49 #include "base/callback.hh"
50 #include "mem/packet.hh"
51 #include "mem/qport.hh"
58 #include "mem/ruby/protocol/AccessPermission.hh"
60 #include "params/RubyController.hh"
61 #include "sim/clocked_object.hh"
62 
63 class Network;
64 class GPUCoalescer;
65 class DMASequencer;
66 
67 // used to communicate that an in_port peeked the wrong message type
68 class RejectException: public std::exception
69 {
70  virtual const char* what() const throw()
71  { return "Port rejected message based on type"; }
72 };
73 
75 {
76  public:
77  typedef RubyControllerParams Params;
78  AbstractController(const Params *p);
79  void init();
80  const Params *params() const { return (const Params *)_params; }
81 
82  NodeID getVersion() const { return m_machineID.getNum(); }
83  MachineType getType() const { return m_machineID.getType(); }
84 
85  void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
86 
87  // return instance name
89  bool isBlocked(Addr) const;
90  void unblock(Addr);
91  bool isBlocked(Addr);
92 
93  virtual MessageBuffer* getMandatoryQueue() const = 0;
94  virtual MessageBuffer* getMemReqQueue() const = 0;
95  virtual MessageBuffer* getMemRespQueue() const = 0;
96  virtual AccessPermission getAccessPermission(const Addr &addr) = 0;
97 
98  virtual void print(std::ostream & out) const = 0;
99  virtual void wakeup() = 0;
100  virtual void resetStats() = 0;
101  virtual void regStats();
102 
103  virtual void recordCacheTrace(int cntrl, CacheRecorder* tr) = 0;
104  virtual Sequencer* getCPUSequencer() const = 0;
105  virtual DMASequencer* getDMASequencer() const = 0;
106  virtual GPUCoalescer* getGPUCoalescer() const = 0;
107 
108  // This latency is used by the sequencer when enqueueing requests.
109  // Different latencies may be used depending on the request type.
110  // This is the hit latency unless the top-level cache controller
111  // introduces additional cycles in the response path.
112  virtual Cycles mandatoryQueueLatency(const RubyRequestType& param_type)
113  { return m_mandatory_queue_latency; }
114 
117  virtual bool functionalReadBuffers(PacketPtr&) = 0;
118  virtual void functionalRead(const Addr &addr, PacketPtr) = 0;
122  virtual int functionalWriteBuffers(PacketPtr&) = 0;
123  virtual int functionalWrite(const Addr &addr, PacketPtr) = 0;
125 
127  virtual void enqueuePrefetch(const Addr &, const RubyRequestType&)
128  { fatal("Prefetches not implemented!");}
129 
133  virtual void collateStats()
134  {fatal("collateStats() should be overridden!");}
135 
137  virtual void initNetQueues() = 0;
138 
140  Port &getPort(const std::string &if_name,
141  PortID idx=InvalidPortID);
142 
143  void recvTimingResp(PacketPtr pkt);
145 
146  const AddrRangeList &getAddrRanges() const { return addrRanges; }
147 
148  public:
149  MachineID getMachineID() const { return m_machineID; }
150  RequestorID getRequestorId() const { return m_id; }
151 
154  { return *(m_delayVCHistogram[index]); }
155 
169  MachineID mapAddressToMachine(Addr addr, MachineType mtype) const;
170 
171  protected:
173  void profileRequest(const std::string &request);
175  void profileMsgDelay(uint32_t virtualNetwork, Cycles delay);
176 
177  void stallBuffer(MessageBuffer* buf, Addr addr);
178  void wakeUpBuffers(Addr addr);
179  void wakeUpAllBuffers(Addr addr);
180  void wakeUpAllBuffers();
181  bool serviceMemoryQueue();
182 
183  protected:
187 
188  // RequestorID used by some components of gem5.
190 
193  std::map<Addr, MessageBuffer*> m_block_map;
194 
196  typedef std::set<MessageBuffer*> MsgBufType;
197  typedef std::map<Addr, MsgVecType* > WaitingBufType;
199 
200  unsigned int m_in_ports;
201  unsigned int m_cur_in_port;
202  const int m_number_of_TBEs;
204  const unsigned int m_buffer_size;
207 
211 
216 
221  class MemoryPort : public RequestPort
222  {
223  private:
224  // Controller that operates this port.
226 
227  public:
228  MemoryPort(const std::string &_name, AbstractController *_controller,
229  PortID id = InvalidPortID);
230 
231  protected:
232  // Function for receiving a timing response from the peer port.
233  // Currently the pkt is handed to the coherence controller
234  // associated with this port.
235  bool recvTimingResp(PacketPtr pkt);
236 
237  void recvReqRetry();
238  };
239 
240  /* Request port to the memory controller. */
242 
243  // State that is stored in packets sent to the memory controller.
245  {
246  // Id of the machine from which the request originated.
248 
250  {}
251  };
252 
253  private:
256 };
257 
258 #endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__
AbstractController::m_clusterID
const NodeID m_clusterID
Definition: AbstractController.hh:186
MachineID.hh
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
AbstractController::blockOnQueue
void blockOnQueue(Addr, MessageBuffer *)
Definition: AbstractController.cc:265
AbstractController::print
virtual void print(std::ostream &out) const =0
CacheRecorder
Definition: CacheRecorder.hh:66
AbstractController::getVersion
NodeID getVersion() const
Definition: AbstractController.hh:82
AbstractController::m_waiting_buffers
WaitingBufType m_waiting_buffers
Definition: AbstractController.hh:198
AbstractController::functionalWriteBuffers
virtual int functionalWriteBuffers(PacketPtr &)=0
The return value indicates the number of messages written with the data from the packet.
AbstractController::m_mandatory_queue_latency
const Cycles m_mandatory_queue_latency
Definition: AbstractController.hh:206
AbstractController::SenderState
Definition: AbstractController.hh:244
Histogram.hh
AbstractController::profileRequest
void profileRequest(const std::string &request)
Profiles original cache requests including PUTs.
AbstractController::recvAtomic
Tick recvAtomic(PacketPtr pkt)
Definition: AbstractController.cc:347
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
AbstractController::MemoryPort::controller
AbstractController * controller
Definition: AbstractController.hh:225
Sequencer
Definition: Sequencer.hh:80
AbstractController::m_delayVCHistogram
std::vector< Stats::Histogram * > m_delayVCHistogram
Definition: AbstractController.hh:215
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
MachineID::getType
MachineType getType() const
Definition: MachineID.hh:48
AbstractController::getMemReqQueue
virtual MessageBuffer * getMemReqQueue() const =0
AbstractController::getMandatoryQueue
virtual MessageBuffer * getMandatoryQueue() const =0
AbstractController::initNetworkPtr
void initNetworkPtr(Network *net_ptr)
Definition: AbstractController.hh:85
GPUCoalescer
Definition: GPUCoalescer.hh:201
DMASequencer
Definition: DMASequencer.hh:56
AbstractController::stallBuffer
void stallBuffer(MessageBuffer *buf, Addr addr)
Definition: AbstractController.cc:113
AbstractController::MemoryPort::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: AbstractController.cc:361
AbstractController::wakeUpAllBuffers
void wakeUpAllBuffers()
Definition: AbstractController.cc:168
AbstractController::getAccessPermission
virtual AccessPermission getAccessPermission(const Addr &addr)=0
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
AbstractController::mapAddressToMachine
MachineID mapAddressToMachine(Addr addr, MachineType mtype) const
Map an address to the correct MachineID.
Definition: AbstractController.cc:353
AbstractController::MemoryPort::MemoryPort
MemoryPort(const std::string &_name, AbstractController *_controller, PortID id=InvalidPortID)
Definition: AbstractController.cc:373
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
AbstractController::getAddrRanges
const AddrRangeList & getAddrRanges() const
Definition: AbstractController.hh:146
AbstractController::addrRanges
const AddrRangeList addrRanges
The address range to which the controller responds on the CPU side.
Definition: AbstractController.hh:255
std::vector< MessageBuffer * >
AbstractController::wakeup
virtual void wakeup()=0
AbstractController
Definition: AbstractController.hh:74
AbstractController::m_cur_in_port
unsigned int m_cur_in_port
Definition: AbstractController.hh:201
AbstractController::serviceMemoryQueue
bool serviceMemoryQueue()
Definition: AbstractController.cc:207
MachineID
Definition: MachineID.hh:38
MachineID::getNum
NodeID getNum() const
Definition: MachineID.hh:49
AbstractController::isBlocked
bool isBlocked(Addr) const
Definition: AbstractController.cc:272
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
AbstractController::functionalReadBuffers
virtual bool functionalReadBuffers(PacketPtr &)=0
These functions are used by ruby system to read/write the data blocks that exist with in the controll...
packet.hh
Stats::Histogram
A simple histogram stat.
Definition: statistics.hh:2654
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
AbstractController::params
const Params * params() const
Definition: AbstractController.hh:80
RequestorID
uint16_t RequestorID
Definition: request.hh:85
AbstractController::wakeUpBuffers
void wakeUpBuffers(Addr addr)
Definition: AbstractController.cc:127
AbstractController::unblock
void unblock(Addr)
Definition: AbstractController.cc:278
AbstractController::SenderState::id
MachineID id
Definition: AbstractController.hh:247
AbstractController::memoryPort
MemoryPort memoryPort
Definition: AbstractController.hh:241
AbstractController::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: AbstractController.cc:94
Packet::SenderState
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition: packet.hh:431
AbstractController::m_in_ports
unsigned int m_in_ports
Definition: AbstractController.hh:200
AbstractController::m_transitions_per_cycle
const int m_transitions_per_cycle
Definition: AbstractController.hh:203
AbstractController::m_net_ptr
Network * m_net_ptr
Definition: AbstractController.hh:191
RejectException::what
virtual const char * what() const
Definition: AbstractController.hh:70
DataBlock.hh
AbstractController::m_is_blocking
bool m_is_blocking
Definition: AbstractController.hh:192
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
Consumer
Definition: Consumer.hh:43
RejectException
Definition: AbstractController.hh:68
AbstractController::functionalRead
virtual void functionalRead(const Addr &addr, PacketPtr)=0
AbstractController::getDelayVCHist
Stats::Histogram & getDelayVCHist(uint32_t index)
Definition: AbstractController.hh:153
AbstractController::functionalMemoryWrite
int functionalMemoryWrite(PacketPtr)
Definition: AbstractController.cc:305
AbstractController::recvTimingResp
void recvTimingResp(PacketPtr pkt)
Definition: AbstractController.cc:315
AbstractController::WaitingBufType
std::map< Addr, MsgVecType * > WaitingBufType
Definition: AbstractController.hh:197
AbstractController::m_block_map
std::map< Addr, MessageBuffer * > m_block_map
Definition: AbstractController.hh:193
AbstractController::m_machineID
MachineID m_machineID
Definition: AbstractController.hh:185
AbstractController::MemoryPort
Port that forwards requests and receives responses from the memory controller.
Definition: AbstractController.hh:221
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
AbstractController::m_delayHistogram
Stats::Histogram m_delayHistogram
Histogram for profiling delay for the messages this controller cares for.
Definition: AbstractController.hh:214
AbstractController::collateStats
virtual void collateStats()
Function for collating statistics from all the controllers of this particular type.
Definition: AbstractController.hh:133
AbstractController::recordCacheTrace
virtual void recordCacheTrace(int cntrl, CacheRecorder *tr)=0
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Network
Definition: Network.hh:76
AbstractController::m_fully_busy_cycles
Stats::Scalar m_fully_busy_cycles
Counter for the number of cycles when the transitions carried out were equal to the maximum allowed.
Definition: AbstractController.hh:210
AbstractController::m_buffer_size
const unsigned int m_buffer_size
Definition: AbstractController.hh:204
AbstractController::getDelayHist
Stats::Histogram & getDelayHist()
Definition: AbstractController.hh:152
AbstractController::functionalWrite
virtual int functionalWrite(const Addr &addr, PacketPtr)=0
addr_range.hh
AbstractController::init
void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: AbstractController.cc:69
AbstractController::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
A function used to return the port associated with this bus object.
Definition: AbstractController.cc:293
MessageBuffer.hh
Consumer.hh
Address.hh
qport.hh
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
clocked_object.hh
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
AbstractController::getType
MachineType getType() const
Definition: AbstractController.hh:83
AbstractController::m_id
const RequestorID m_id
Definition: AbstractController.hh:189
AbstractController::MemoryPort::recvReqRetry
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: AbstractController.cc:368
AbstractController::Params
RubyControllerParams Params
Definition: AbstractController.hh:77
addr
ip6_addr_t addr
Definition: inet.hh:423
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
AbstractController::m_recycle_latency
Cycles m_recycle_latency
Definition: AbstractController.hh:205
NodeID
unsigned int NodeID
Definition: TypeDefines.hh:34
AbstractController::MsgBufType
std::set< MessageBuffer * > MsgBufType
Definition: AbstractController.hh:196
AbstractController::m_version
const NodeID m_version
Definition: AbstractController.hh:184
AbstractController::enqueuePrefetch
virtual void enqueuePrefetch(const Addr &, const RubyRequestType &)
Function for enqueuing a prefetch request.
Definition: AbstractController.hh:127
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
MessageBuffer
Definition: MessageBuffer.hh:68
CacheRecorder.hh
AbstractController::profileMsgDelay
void profileMsgDelay(uint32_t virtualNetwork, Cycles delay)
Profiles the delay associated with messages.
Definition: AbstractController.cc:105
AbstractController::SenderState::SenderState
SenderState(MachineID _id)
Definition: AbstractController.hh:249
AbstractController::mandatoryQueueLatency
virtual Cycles mandatoryQueueLatency(const RubyRequestType &param_type)
Definition: AbstractController.hh:112
AbstractController::getCPUSequencer
virtual Sequencer * getCPUSequencer() const =0
AbstractController::getRequestorId
RequestorID getRequestorId() const
Definition: AbstractController.hh:150
AbstractController::m_number_of_TBEs
const int m_number_of_TBEs
Definition: AbstractController.hh:202
AbstractController::getMemRespQueue
virtual MessageBuffer * getMemRespQueue() const =0
AbstractController::initNetQueues
virtual void initNetQueues()=0
Initialize the message buffers.
AbstractController::MsgVecType
std::vector< MessageBuffer * > MsgVecType
Definition: AbstractController.hh:195
callback.hh
AbstractController::getMachineID
MachineID getMachineID() const
Definition: AbstractController.hh:149
AbstractController::getGPUCoalescer
virtual GPUCoalescer * getGPUCoalescer() const =0
AbstractController::getDMASequencer
virtual DMASequencer * getDMASequencer() const =0
AbstractController::AbstractController
AbstractController(const Params *p)
Definition: AbstractController.cc:50
AbstractController::resetStats
virtual void resetStats()=0
Callback to reset stats.
Definition: AbstractController.cc:84
AbstractController::functionalMemoryRead
void functionalMemoryRead(PacketPtr)
Definition: AbstractController.cc:299

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17