gem5
v20.1.0.0
systemc
ext
tlm_utils
peq_with_get.h
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4
more contributor license agreements. See the NOTICE file distributed
5
with this work for additional information regarding copyright ownership.
6
Accellera licenses this file to you under the Apache License, Version 2.0
7
(the "License"); you may not use this file except in compliance with the
8
License. You may obtain a copy of the License at
9
10
http://www.apache.org/licenses/LICENSE-2.0
11
12
Unless required by applicable law or agreed to in writing, software
13
distributed under the License is distributed on an "AS IS" BASIS,
14
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15
implied. See the License for the specific language governing
16
permissions and limitations under the License.
17
18
*****************************************************************************/
19
20
// 12-Jan-2009 John Aynsley Bug fix. sc_time argument to notify should be const
21
// 20-Mar-2009 John Aynsley Add cancel_all() method
22
23
24
#ifndef __SYSTEMC_EXT_TLM_UTILS_PEQ_WITH_GET_H__
25
#define __SYSTEMC_EXT_TLM_UTILS_PEQ_WITH_GET_H__
26
27
#include <map>
28
29
#include "../core/sc_event.hh"
30
#include "../core/sc_main.hh"
31
#include "../core/sc_object.hh"
32
#include "../core/sc_time.hh"
33
34
namespace
tlm_utils
35
{
36
37
template
<
class
PAYLOAD>
38
class
peq_with_get :
public
sc_core::sc_object
39
{
40
public
:
41
typedef
PAYLOAD
transaction_type
;
42
typedef
std::pair<const sc_core::sc_time, transaction_type *>
pair_type
;
43
44
public
:
45
peq_with_get
(
const
char
*
name
) :
sc_core
::
sc_object
(
name
) {}
46
47
void
48
notify
(
transaction_type
&trans,
const
sc_core::sc_time
&
t
)
49
{
50
m_scheduled_events
.insert(
pair_type
(
t
+
sc_core::sc_time_stamp
(),
51
&trans));
52
m_event
.
notify
(
t
);
53
}
54
55
void
56
notify
(
transaction_type
&trans)
57
{
58
m_scheduled_events
.insert(
pair_type
(
sc_core::sc_time_stamp
(), &trans));
59
m_event
.
notify
();
// Immediate notification.
60
}
61
62
// Needs to be called until it returns NULL
63
transaction_type
*
64
get_next_transaction
()
65
{
66
if
(
m_scheduled_events
.empty()) {
67
return
nullptr
;
68
}
69
70
sc_core::sc_time
now =
sc_core::sc_time_stamp
();
71
if
(
m_scheduled_events
.begin()->first <= now) {
72
transaction_type
*trans =
m_scheduled_events
.begin()->second;
73
m_scheduled_events
.erase(
m_scheduled_events
.begin());
74
return
trans;
75
}
76
77
m_event
.
notify
(
m_scheduled_events
.begin()->first - now);
78
79
return
nullptr
;
80
}
81
82
sc_core::sc_event
&
get_event
() {
return
m_event
; }
83
84
// Cancel all events from the event queue.
85
void
86
cancel_all
()
87
{
88
m_scheduled_events
.clear();
89
m_event
.
cancel
();
90
}
91
92
private
:
93
std::multimap<const sc_core::sc_time, transaction_type *>
94
m_scheduled_events
;
95
sc_core::sc_event
m_event
;
96
};
97
98
}
// namespace tlm_utils
99
100
#endif
/* __SYSTEMC_EXT_TLM_UTILS_PEQ_WITH_GET_H__ */
tlm_utils::peq_with_get::get_next_transaction
transaction_type * get_next_transaction()
Definition:
peq_with_get.h:98
tlm_utils::peq_with_get::transaction_type
PAYLOAD transaction_type
Definition:
peq_with_get.h:75
sc_core
Definition:
messages.cc:31
tlm_utils::peq_with_get::notify
void notify(transaction_type &trans, const sc_core::sc_time &t)
Definition:
peq_with_get.h:82
tlm_utils::peq_with_get::get_event
sc_core::sc_event & get_event()
Definition:
peq_with_get.h:116
tlm_utils::peq_with_get::m_scheduled_events
std::multimap< const sc_core::sc_time, transaction_type * > m_scheduled_events
Definition:
peq_with_get.h:128
tlm_utils::peq_with_get::pair_type
std::pair< const sc_core::sc_time, transaction_type * > pair_type
Definition:
peq_with_get.h:76
tlm_utils::peq_with_get::peq_with_get
peq_with_get(const char *name)
Definition:
peq_with_get.h:79
sc_core::sc_event
Definition:
sc_event.hh:169
sc_core::sc_time
Definition:
sc_time.hh:49
std::pair
STL pair class.
Definition:
stl.hh:58
sc_core::sc_object
Definition:
sc_object.hh:50
sc_core::sc_event::notify
void notify()
Definition:
sc_event.cc:337
tlm_utils
Definition:
convenience_socket_bases.h:29
tlm_utils::peq_with_get::m_event
sc_core::sc_event m_event
Definition:
peq_with_get.h:129
sc_core::sc_event::cancel
void cancel()
Definition:
sc_event.cc:340
ArmISA::t
Bitfield< 5 > t
Definition:
miscregs_types.hh:67
tlm_utils::peq_with_get::cancel_all
void cancel_all()
Definition:
peq_with_get.h:120
sc_core::sc_object::name
const char * name() const
Definition:
sc_object.cc:44
sc_core::sc_object::sc_object
sc_object()
Definition:
sc_object.cc:133
sc_core::sc_time_stamp
const sc_time & sc_time_stamp()
Definition:
sc_main.cc:128
Generated on Wed Sep 30 2020 14:02:16 for gem5 by
doxygen
1.8.17