gem5 v24.0.0.0
Loading...
Searching...
No Matches
port_wrapper.hh File Reference

PortWrapper Object Declaration. More...

#include <functional>
#include "mem/port.hh"

Go to the source code of this file.

Classes

class  gem5::RequestPortWrapper
 The RequestPortWrapper converts inherit-based RequestPort into callback-based. More...
 
class  gem5::ResponsePortWrapper
 The ResponsePortWrapper converts inherit-based ResponsePort into callback-based. More...
 

Namespaces

namespace  gem5
 Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
 

Detailed Description

PortWrapper Object Declaration.

The RequestPortWrapper and ResponsePortWrapper converts inherit-based RequestPort and ResponsePort into callback-based. This help reducing redundant code and increase code reusability in most cases, allowing composition over inheritance pattern.

Example usage:

class MySimObject : public SimObject { public: ResponsePortWrapper inPort;

MySimObject(...) : inPort("in_port", this)... { inPort.setGetAddrRangesCallback([this]() { return getRange(); });

inPort.setAtomicCallbacks([this](PacketPtr packet) { // process the packet ... return Tick(); }); }

private: AddrRangeList getRange() const {...} };

Definition in file port_wrapper.hh.


Generated on Tue Jun 18 2024 16:24:08 for gem5 by doxygen 1.11.0