src/systemc/tlm_bridge/gem5_to_tlm.cc
/**
 * Convert a gem5 packet to a TLM payload by copying all the relevant
 * information to new tlm payload.
 */
Convert a gem5 packet to a TLM payload by copying all the relevant
information to new tlm payload.
Convert a gem5 packet to a TLM payload by copying all the relevant information to new tlm payload .
tlm::tlm_generic_payload *
packet2payload(PacketPtr packet)
{
    tlm::tlm_generic_payload *trans = mm.allocate();
    trans->acquire();
    trans->set_address(packet->getAddr());
    sc_assert(trans->has_mm());
    unsigned int size = packet->getSize();
    unsigned char *data = packet->getPtr<unsigned char>();
    trans->set_data_length(size);
    trans->set_streaming_width(size);
    trans->set_data_ptr(data);
    if ((packet->req->getFlags() & Request::NO_ACCESS) != 0) {
        trans->set_command(tlm::TLM_IGNORE_COMMAND);
    } else if (packet->isRead()) {
        trans->set_command(tlm::TLM_READ_COMMAND);
    } else if (packet->isWrite()) {
        trans->set_command(tlm::TLM_WRITE_COMMAND);
    } else {
        trans->set_command(tlm::TLM_IGNORE_COMMAND);
    }
    auto *extension = new Gem5SystemC::Gem5Extension(packet);
    trans->set_auto_extension(extension);
    if (packet->isAtomicOp()) {
        auto *atomic_ex = new Gem5SystemC::AtomicExtension(
            std::shared_ptr<AtomicOpFunctor>(
                packet->req->getAtomicOpFunctor()->clone()),
            packet->req->isAtomicReturn());
        trans->set_auto_extension(atomic_ex);
    }
    for (auto &step : extraPacketToPayloadSteps) {
        step(packet, *trans);
    }
    return trans;
}
tlm :: tlm_generic_payload * packet2payload ( PacketPtr packet ) { tlm :: tlm_generic_payload * trans = mm . allocate ( ) ; trans -> acquire ( ) ; trans -> set_address ( packet -> getAddr ( ) ) ; sc_assert ( trans -> has_mm ( ) ) ; unsigned int size = packet -> getSize ( ) ; unsigned char * data = packet -> getPtr < unsigned char > ( ) ; trans -> set_data_length ( size ) ; trans -> set_streaming_width ( size ) ; trans -> set_data_ptr ( data ) ; if ( ( packet -> req -> getFlags ( ) & Request :: NO_ACCESS ) != 0 ) { trans -> set_command ( tlm :: TLM_IGNORE_COMMAND ) ; } else if ( packet -> isRead ( ) ) { trans -> set_command ( tlm :: TLM_READ_COMMAND ) ; } else if ( packet -> isWrite ( ) ) { trans -> set_command ( tlm :: TLM_WRITE_COMMAND ) ; } else { trans -> set_command ( tlm :: TLM_IGNORE_COMMAND ) ; } auto * extension = new Gem5SystemC :: Gem5Extension ( packet ) ; trans -> set_auto_extension ( extension ) ; if ( packet -> isAtomicOp ( ) ) { auto * atomic_ex = new Gem5SystemC :: AtomicExtension ( std :: shared_ptr < AtomicOpFunctor > ( packet -> req -> getAtomicOpFunctor ( ) -> clone ( ) ) , packet -> req -> isAtomicReturn ( ) ) ; trans -> set_auto_extension ( atomic_ex ) ; } for ( auto & step : extraPacketToPayloadSteps ) { step ( packet , * trans ) ; } return trans ; }
Convert a gem5 packet to a TLM payload by copying all the relevant
 information to new tlm payload.
Convert a gem5 packet to a TLM payload by copying all the relevant information to new tlm payload .
/* Check if this transaction was allocated by mm */ /* Do nothing */ // Attach the packet pointer to the TLM transaction to keep track. // Apply all conversion steps necessary in this specific setup.