namespace sc_gem5
{
+PacketPtr
+payload2packet(MasterID masterId, tlm::tlm_generic_payload &trans)
+{
+ MemCmd cmd;
+
+ switch (trans.get_command()) {
+ case tlm::TLM_READ_COMMAND:
+ cmd = MemCmd::ReadReq;
+ break;
+ case tlm::TLM_WRITE_COMMAND:
+ cmd = MemCmd::WriteReq;
+ break;
+ case tlm::TLM_IGNORE_COMMAND:
+ return nullptr;
+ default:
+ SC_REPORT_FATAL("TlmToGem5Bridge",
+ "received transaction with unsupported command");
+ }
+
+ Request::Flags flags;
+ auto req = std::make_shared<Request>(
+ trans.get_address(), trans.get_data_length(), flags, masterId);
+
+ /*
+ * Allocate a new Packet. The packet will be deleted when it returns from
+ * the gem5 world as a response.
+ */
+ auto pkt = new Packet(req, cmd);
+ pkt->dataStatic(trans.get_data_ptr());
+
+ return pkt;
+}
+
template <unsigned int BITWIDTH>
void
TlmToGem5Bridge<BITWIDTH>::sendEndReq(tlm::tlm_generic_payload &trans)
extension->setPipeThrough();
pkt = extension->getPacket();
} else {
- pkt = generatePacket(trans);
+ pkt = payload2packet(masterId, trans);
}
auto tlmSenderState = new TlmSenderState(trans);
}
}
-template <unsigned int BITWIDTH>
-PacketPtr
-TlmToGem5Bridge<BITWIDTH>::generatePacket(tlm::tlm_generic_payload &trans)
-{
- MemCmd cmd;
-
- switch (trans.get_command()) {
- case tlm::TLM_READ_COMMAND:
- cmd = MemCmd::ReadReq;
- break;
- case tlm::TLM_WRITE_COMMAND:
- cmd = MemCmd::WriteReq;
- break;
- case tlm::TLM_IGNORE_COMMAND:
- return nullptr;
- default:
- SC_REPORT_FATAL("TlmToGem5Bridge",
- "received transaction with unsupported command");
- }
-
- Request::Flags flags;
- auto req = std::make_shared<Request>(
- trans.get_address(), trans.get_data_length(), flags, masterId);
-
- /*
- * Allocate a new Packet. The packet will be deleted when it returns from
- * the gem5 world as a response.
- */
- auto pkt = new Packet(req, cmd);
- pkt->dataStatic(trans.get_data_ptr());
-
- return pkt;
-}
-
template <unsigned int BITWIDTH>
void
TlmToGem5Bridge<BITWIDTH>::destroyPacket(PacketPtr pkt)
extension->setPipeThrough();
pkt = extension->getPacket();
} else {
- pkt = generatePacket(trans);
+ pkt = payload2packet(masterId, trans);
}
MemBackdoorPtr backdoor = nullptr;
extension->setPipeThrough();
bmp.sendFunctional(extension->getPacket());
} else {
- auto pkt = generatePacket(trans);
+ auto pkt = payload2packet(masterId, trans);
if (pkt) {
bmp.sendFunctional(pkt);
destroyPacket(pkt);
extension->setPipeThrough();
pkt = extension->getPacket();
} else {
- pkt = generatePacket(trans);
+ pkt = payload2packet(masterId, trans);
pkt->req->setFlags(Request::NO_ACCESS);
}