sc_slave_port.hh revision 12047
112047Schristian.menard@tu-dresden.de/* 212047Schristian.menard@tu-dresden.de * Copyright (c) 2015, University of Kaiserslautern 312047Schristian.menard@tu-dresden.de * Copyright (c) 2016, Dresden University of Technology (TU Dresden) 412047Schristian.menard@tu-dresden.de * All rights reserved. 512047Schristian.menard@tu-dresden.de * 612047Schristian.menard@tu-dresden.de * Redistribution and use in source and binary forms, with or without 712047Schristian.menard@tu-dresden.de * modification, are permitted provided that the following conditions are 812047Schristian.menard@tu-dresden.de * met: 912047Schristian.menard@tu-dresden.de * 1012047Schristian.menard@tu-dresden.de * 1. Redistributions of source code must retain the above copyright notice, 1112047Schristian.menard@tu-dresden.de * this list of conditions and the following disclaimer. 1212047Schristian.menard@tu-dresden.de * 1312047Schristian.menard@tu-dresden.de * 2. Redistributions in binary form must reproduce the above copyright 1412047Schristian.menard@tu-dresden.de * notice, this list of conditions and the following disclaimer in the 1512047Schristian.menard@tu-dresden.de * documentation and/or other materials provided with the distribution. 1612047Schristian.menard@tu-dresden.de * 1712047Schristian.menard@tu-dresden.de * 3. Neither the name of the copyright holder nor the names of its 1812047Schristian.menard@tu-dresden.de * contributors may be used to endorse or promote products derived from 1912047Schristian.menard@tu-dresden.de * this software without specific prior written permission. 2012047Schristian.menard@tu-dresden.de * 2112047Schristian.menard@tu-dresden.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2212047Schristian.menard@tu-dresden.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2312047Schristian.menard@tu-dresden.de * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2412047Schristian.menard@tu-dresden.de * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 2512047Schristian.menard@tu-dresden.de * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2612047Schristian.menard@tu-dresden.de * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2712047Schristian.menard@tu-dresden.de * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2812047Schristian.menard@tu-dresden.de * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 2912047Schristian.menard@tu-dresden.de * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 3012047Schristian.menard@tu-dresden.de * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3112047Schristian.menard@tu-dresden.de * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3212047Schristian.menard@tu-dresden.de * 3312047Schristian.menard@tu-dresden.de * Authors: Matthias Jung 3412047Schristian.menard@tu-dresden.de * Christian Menard 3512047Schristian.menard@tu-dresden.de */ 3612047Schristian.menard@tu-dresden.de 3712047Schristian.menard@tu-dresden.de#ifndef __SC_SLAVE_PORT_HH__ 3812047Schristian.menard@tu-dresden.de#define __SC_SLAVE_PORT_HH__ 3912047Schristian.menard@tu-dresden.de 4012047Schristian.menard@tu-dresden.de#include <systemc> 4112047Schristian.menard@tu-dresden.de#include <tlm> 4212047Schristian.menard@tu-dresden.de 4312047Schristian.menard@tu-dresden.de#include "mem/external_slave.hh" 4412047Schristian.menard@tu-dresden.de#include "sc_mm.hh" 4512047Schristian.menard@tu-dresden.de#include "sc_peq.hh" 4612047Schristian.menard@tu-dresden.de#include "sim_control.hh" 4712047Schristian.menard@tu-dresden.de 4812047Schristian.menard@tu-dresden.denamespace Gem5SystemC 4912047Schristian.menard@tu-dresden.de{ 5012047Schristian.menard@tu-dresden.de 5112047Schristian.menard@tu-dresden.de// forward declaration 5212047Schristian.menard@tu-dresden.declass Gem5SlaveTransactor; 5312047Schristian.menard@tu-dresden.de 5412047Schristian.menard@tu-dresden.de/** 5512047Schristian.menard@tu-dresden.de * Test that gem5 is at the same time as SystemC 5612047Schristian.menard@tu-dresden.de */ 5712047Schristian.menard@tu-dresden.de#define CAUGHT_UP do { \ 5812047Schristian.menard@tu-dresden.de assert(curTick() == sc_core::sc_time_stamp().value()); \ 5912047Schristian.menard@tu-dresden.de} while (0) 6012047Schristian.menard@tu-dresden.de 6112047Schristian.menard@tu-dresden.de/** 6212047Schristian.menard@tu-dresden.de * This is a gem5 slave port that translates gem5 packets to TLM transactions. 6312047Schristian.menard@tu-dresden.de * 6412047Schristian.menard@tu-dresden.de * Upon receiving a packet (recvAtomic, recvTiningReq, recvFunctional) the port 6512047Schristian.menard@tu-dresden.de * creates a new TLM payload and initializes it with information from the gem5 6612047Schristian.menard@tu-dresden.de * packet. The original packet is added as an extension to the TLM payload. 6712047Schristian.menard@tu-dresden.de * Then the port issues a TLM transaction in the SystemC world. By storing the 6812047Schristian.menard@tu-dresden.de * original packet as a payload extension, the packet can be restored and send 6912047Schristian.menard@tu-dresden.de * back to the gem5 world upon receiving a response from the SystemC world. 7012047Schristian.menard@tu-dresden.de */ 7112047Schristian.menard@tu-dresden.declass SCSlavePort : public ExternalSlave::Port 7212047Schristian.menard@tu-dresden.de{ 7312047Schristian.menard@tu-dresden.de public: 7412047Schristian.menard@tu-dresden.de /** One instance of pe and the related callback needed */ 7512047Schristian.menard@tu-dresden.de //payloadEvent<SCSlavePort> pe; 7612047Schristian.menard@tu-dresden.de void pec(PayloadEvent<SCSlavePort> * pe, 7712047Schristian.menard@tu-dresden.de tlm::tlm_generic_payload& trans, const tlm::tlm_phase& phase); 7812047Schristian.menard@tu-dresden.de 7912047Schristian.menard@tu-dresden.de /** 8012047Schristian.menard@tu-dresden.de * A transaction after BEGIN_REQ has been sent but before END_REQ, which 8112047Schristian.menard@tu-dresden.de * is blocking the request channel (Exlusion Rule, see IEEE1666) 8212047Schristian.menard@tu-dresden.de */ 8312047Schristian.menard@tu-dresden.de tlm::tlm_generic_payload *blockingRequest; 8412047Schristian.menard@tu-dresden.de 8512047Schristian.menard@tu-dresden.de /** 8612047Schristian.menard@tu-dresden.de * Did another gem5 request arrive while currently blocked? 8712047Schristian.menard@tu-dresden.de * This variable is needed when a retry should happen 8812047Schristian.menard@tu-dresden.de */ 8912047Schristian.menard@tu-dresden.de bool needToSendRequestRetry; 9012047Schristian.menard@tu-dresden.de 9112047Schristian.menard@tu-dresden.de /** 9212047Schristian.menard@tu-dresden.de * A response which has been asked to retry by gem5 and so is blocking 9312047Schristian.menard@tu-dresden.de * the response channel 9412047Schristian.menard@tu-dresden.de */ 9512047Schristian.menard@tu-dresden.de tlm::tlm_generic_payload *blockingResponse; 9612047Schristian.menard@tu-dresden.de 9712047Schristian.menard@tu-dresden.de protected: 9812047Schristian.menard@tu-dresden.de /** The gem5 Port slave interface */ 9912047Schristian.menard@tu-dresden.de Tick recvAtomic(PacketPtr packet); 10012047Schristian.menard@tu-dresden.de void recvFunctional(PacketPtr packet); 10112047Schristian.menard@tu-dresden.de bool recvTimingReq(PacketPtr packet); 10212047Schristian.menard@tu-dresden.de bool recvTimingSnoopResp(PacketPtr packet); 10312047Schristian.menard@tu-dresden.de void recvRespRetry(); 10412047Schristian.menard@tu-dresden.de void recvFunctionalSnoop(PacketPtr packet); 10512047Schristian.menard@tu-dresden.de 10612047Schristian.menard@tu-dresden.de Gem5SlaveTransactor* transactor; 10712047Schristian.menard@tu-dresden.de 10812047Schristian.menard@tu-dresden.de public: 10912047Schristian.menard@tu-dresden.de /** The TLM initiator interface */ 11012047Schristian.menard@tu-dresden.de tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload& trans, 11112047Schristian.menard@tu-dresden.de tlm::tlm_phase& phase, 11212047Schristian.menard@tu-dresden.de sc_core::sc_time& t); 11312047Schristian.menard@tu-dresden.de 11412047Schristian.menard@tu-dresden.de SCSlavePort(const std::string &name_, 11512047Schristian.menard@tu-dresden.de const std::string &systemc_name, 11612047Schristian.menard@tu-dresden.de ExternalSlave &owner_); 11712047Schristian.menard@tu-dresden.de 11812047Schristian.menard@tu-dresden.de void bindToTransactor(Gem5SlaveTransactor* transactor); 11912047Schristian.menard@tu-dresden.de 12012047Schristian.menard@tu-dresden.de friend PayloadEvent<SCSlavePort>; 12112047Schristian.menard@tu-dresden.de}; 12212047Schristian.menard@tu-dresden.de 12312047Schristian.menard@tu-dresden.declass SCSlavePortHandler : public ExternalSlave::Handler 12412047Schristian.menard@tu-dresden.de{ 12512047Schristian.menard@tu-dresden.de private: 12612047Schristian.menard@tu-dresden.de Gem5SimControl& control; 12712047Schristian.menard@tu-dresden.de 12812047Schristian.menard@tu-dresden.de public: 12912047Schristian.menard@tu-dresden.de SCSlavePortHandler(Gem5SimControl& control) : control(control) {} 13012047Schristian.menard@tu-dresden.de 13112047Schristian.menard@tu-dresden.de ExternalSlave::Port *getExternalPort(const std::string &name, 13212047Schristian.menard@tu-dresden.de ExternalSlave &owner, 13312047Schristian.menard@tu-dresden.de const std::string &port_data); 13412047Schristian.menard@tu-dresden.de}; 13512047Schristian.menard@tu-dresden.de 13612047Schristian.menard@tu-dresden.de} 13712047Schristian.menard@tu-dresden.de 13812047Schristian.menard@tu-dresden.de#endif // __SC_SLAVE_PORT_H__ 139