63#include "params/Gem5ToTlmBridge32.hh"
64#include "params/Gem5ToTlmBridge64.hh"
65#include "params/Gem5ToTlmBridge128.hh"
66#include "params/Gem5ToTlmBridge256.hh"
67#include "params/Gem5ToTlmBridge512.hh"
121 extraPacketToPayloadSteps.push_back(std::move(step));
134 auto *tlmSenderState =
139 if (tlmSenderState !=
nullptr) {
141 trans = &tlmSenderState->trans;
145 for (
auto &step : extraPacketToPayloadSteps) {
146 step(packet, *trans);
160 unsigned int size = packet->
getSize();
161 unsigned char *
data = packet->
getPtr<
unsigned char>();
170 }
else if (packet->
isRead()) {
172 }
else if (packet->
isWrite()) {
184 std::shared_ptr<AtomicOpFunctor>(
185 packet->
req->getAtomicOpFunctor()->clone()),
186 packet->
req->isAtomicReturn());
191 for (
auto &step : extraPacketToPayloadSteps) {
192 step(packet, *trans);
216template <
unsigned int BITWIDTH>
226 blockingRequest =
nullptr;
229 if (needToSendRequestRetry) {
230 needToSendRequestRetry =
false;
231 bridgeResponsePort.sendRetryReq();
240 bool need_retry =
false;
250 need_retry = !bridgeResponsePort.sendTimingResp(packet);
254 blockingResponse = &trans;
259 socket->nb_transport_fw(trans, fw_phase, delay);
261 packetMap.erase(&trans);
267template <
unsigned int BITWIDTH>
276 auto it = backdoorMap.contains(
r);
277 if (it != backdoorMap.end())
282 if (!socket->get_direct_mem_ptr(trans, dmi_data))
293 backdoorMap.insert(dmi_r, backdoor);
299template <
unsigned int BITWIDTH>
304 "Should not see packets where cache is responding");
313 socket->b_transport(*trans, delay);
321 return delay.
value();
324template <
unsigned int BITWIDTH>
330 "Should not see packets where cache is responding");
339 socket->b_transport(*trans, delay);
341 if (trans->is_dmi_allowed())
342 backdoor = getBackdoor(*trans);
346 backdoor = getBackdoor(*trans);
355 return delay.
value();
358template <
unsigned int BITWIDTH>
364 "unimplemented func.: recvFunctionalSnoop");
368template <
unsigned int BITWIDTH>
373 "Should not see packets where cache is responding");
381 if (blockingRequest) {
382 needToSendRequestRetry =
true;
430 status = socket->nb_transport_fw(*trans, phase, delay);
435 blockingRequest = trans;
436 packetMap.emplace(trans, packet);
441 blockingRequest = trans;
442 packetMap.emplace(trans, packet);
443 auto cb = [
this, trans, phase]() { pec(*trans, phase); };
456template <
unsigned int BITWIDTH>
462 "unimplemented func.: recvTimingSnoopResp");
466template <
unsigned int BITWIDTH>
470 panic(
"tryTiming(PacketPtr) isn't implemented.");
473template <
unsigned int BITWIDTH>
481 blockingResponse =
nullptr;
486 bool need_retry = !bridgeResponsePort.sendTimingResp(packet);
492 socket->nb_transport_fw(*trans, phase, delay);
494 packetMap.erase(trans);
499template <
unsigned int BITWIDTH>
507 unsigned int bytes = socket->transport_dbg(*trans);
508 if (bytes != trans->get_data_length()) {
510 "debug transport was not completed");
516template <
unsigned int BITWIDTH>
536 backdoor = getBackdoor(*trans);
541template <
unsigned int BITWIDTH>
546 auto cb = [
this, &trans, phase]() { pec(trans, phase); };
553template <
unsigned int BITWIDTH>
561 auto it = backdoorMap.intersects(
r);
562 if (it == backdoorMap.end())
565 it->second->invalidate();
567 backdoorMap.erase(it);
571template <
unsigned int BITWIDTH>
575 bridgeResponsePort(
std::string(
name()) +
".gem5", *this),
576 socket(
"tlm_socket"),
579 needToSendRequestRetry(false), blockingResponse(nullptr),
580 addrRanges(params.addr_ranges.begin(), params.addr_ranges.end())
584template <
unsigned int BITWIDTH>
588 if (if_name ==
"gem5")
589 return bridgeResponsePort;
590 else if (if_name ==
"tlm")
596template <
unsigned int BITWIDTH>
600 bridgeResponsePort.sendRangeChange();
603 socket.register_invalidate_direct_mem_ptr(
611gem5::Gem5ToTlmBridge32Params::create()
const
618gem5::Gem5ToTlmBridge64Params::create()
const
625gem5::Gem5ToTlmBridge128Params::create()
const
632gem5::Gem5ToTlmBridge256Params::create()
const
639gem5::Gem5ToTlmBridge512Params::create()
const
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
const AddrRange & range() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
bool needsResponse() const
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
T * getPtr()
get a pointer to the data ptr.
RequestPtr req
A pointer to the original request.
bool cacheResponding() const
Ports are used to interface objects to each other.
@ NO_ACCESS
The request should not cause a memory access.
virtual void before_end_of_elaboration()
virtual gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1)
static sc_time from_value(sc_dt::uint64)
sc_dt::uint64 value() const
void before_end_of_elaboration() override
void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
void recvMemBackdoorReq(const gem5::MemBackdoorReq &req, gem5::MemBackdoorPtr &backdoor)
tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
gem5::MemBackdoorPtr getBackdoor(tlm::tlm_generic_payload &trans)
gem5::Gem5ToTlmBridgeBaseParams Params
Gem5ToTlmBridge(const Params &p, const sc_core::sc_module_name &mn)
void recvFunctionalSnoop(gem5::PacketPtr packet)
gem5::Tick recvAtomic(gem5::PacketPtr packet)
gem5::Tick recvAtomicBackdoor(gem5::PacketPtr pkt, gem5::MemBackdoorPtr &backdoor)
bool tryTiming(gem5::PacketPtr packet)
bool recvTimingSnoopResp(gem5::PacketPtr packet)
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
bool recvTimingReq(gem5::PacketPtr packet)
void recvFunctional(gem5::PacketPtr packet)
unsigned char * get_dmi_ptr() const
sc_dt::uint64 get_start_address() const
sc_dt::uint64 get_end_address() const
bool is_read_allowed() const
bool is_write_allowed() const
void set_data_ptr(unsigned char *data)
T * set_auto_extension(T *ext)
void set_response_status(const tlm_response_status response_status)
void set_address(const sc_dt::uint64 address)
void set_command(const tlm_command command)
sc_dt::uint64 get_address() const
tlm_response_status get_response_status() const
void set_data_length(const unsigned int length)
unsigned int get_data_length() const
void set_streaming_width(const unsigned int streaming_width)
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
static const Priority Default_Pri
Default is zero for historical reasons.
#define panic(...)
This implements a cprintf based panic() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 Arm Limited All rights reserved.
const PortID InvalidPortID
Tick curTick()
The universal simulation clock.
uint64_t Tick
Tick count type.
const sc_time SC_ZERO_TIME
Gem5SystemC::MemoryManager mm
Instantiate a tlm memory manager that takes care about all the tlm transactions in the system.
void addPacketToPayloadConversionStep(PacketToPayloadConversionStep step)
Notify the Gem5ToTlm bridge that we need an extra step to properly convert a gem5 packet to tlm paylo...
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to TLM payload by copying all the relevant information to new payload.
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PacketToPayloadConversionStep
static EventBase::Priority getPriorityOfTlmPhase(const tlm::tlm_phase &phase)
Helper function to help set priority of phase change events of tlm transactions.
void setPacketResponse(PacketPtr pkt, tlm::tlm_generic_payload &trans)
Overload hash function for BasicBlockRange type.
@ TLM_COMMAND_ERROR_RESPONSE
@ TLM_INCOMPLETE_RESPONSE
#define SC_REPORT_FATAL(msg_type, msg)
const std::string & name()