2 * Copyright (c) 2015, University of Kaiserslautern
3 * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the copyright holder nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * Authors: Matthias Jung
37 #ifndef PAYLOAD_EVENT_H_
38 #define PAYLOAD_EVENT_H_
44 #include <sim/eventq.hh>
46 namespace Gem5SystemC {
48 * A 'Fake Payload Event Queue', similar to the TLM PEQs. This helps the
49 * transactors to schedule events in gem5.
51 template <typename OWNER>
52 class PayloadEvent : public Event
56 const std::string eventName;
57 void (OWNER::*handler)(PayloadEvent<OWNER>* pe,
58 tlm::tlm_generic_payload& trans,
59 const tlm::tlm_phase& phase);
62 tlm::tlm_generic_payload* t;
65 void process() { (port.*handler)(this, *t, p); }
68 const std::string name() const { return eventName; }
70 PayloadEvent(OWNER& port_,
71 void (OWNER::*handler_)(PayloadEvent<OWNER>* pe,
72 tlm::tlm_generic_payload& trans,
73 const tlm::tlm_phase& phase),
74 const std::string& event_name)
76 , eventName(event_name)
81 /// Schedule an event into gem5
82 void notify(tlm::tlm_generic_payload& trans, const tlm::tlm_phase& phase,
83 const sc_core::sc_time& delay)
91 * Get time from SystemC as this will always be more up to date
94 Tick nextEventTick = sc_core::sc_time_stamp().value() + delay.value();
96 port.owner.wakeupEventQueue(nextEventTick);
97 port.owner.schedule(this, nextEventTick);