TLM-2.0
2.0.3
Accellera TLM-2.0 proof-of-concept library
Main Page
Namespaces
Classes
Files
File List
File Members
tlm_core
tlm_2
tlm_quantum
tlm_global_quantum.h
Go to the documentation of this file.
1
/*****************************************************************************
2
3
The following code is derived, directly or indirectly, from the SystemC
4
source code Copyright (c) 1996-2014 by all Contributors.
5
All Rights reserved.
6
7
The contents of this file are subject to the restrictions and limitations
8
set forth in the SystemC Open Source License (the "License");
9
You may not use this file except in compliance with such restrictions and
10
limitations. You may obtain instructions on how to receive a copy of the
11
License at http://www.accellera.org/. Software distributed by Contributors
12
under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13
ANY KIND, either express or implied. See the License for the specific
14
language governing rights and limitations under the License.
15
16
*****************************************************************************/
17
18
#ifndef __TLM_GLOBAL_QUANTUM_H__
19
#define __TLM_GLOBAL_QUANTUM_H__
20
21
#include <
systemc
>
22
23
namespace
tlm {
24
25
//
26
// tlm_global_quantum class
27
//
28
// The global quantum is the maximum time an initiator can run ahead of
29
// systemC time. All initiators should synchronize on timingpoints that
30
// are multiples of the global quantum value.
31
//
32
// sc_set_time_resolution can only be called before the first
33
// sc_time object is created. This means that after setting the
34
// global quantum it will not be possible to call sc_set_time_resolution.
35
// If sc_set_time_resolution must be called this must be done before
36
// the global quantum is set.
37
//
38
39
class
tlm_global_quantum
40
{
41
public
:
42
//
43
// Returns a reference to the tlm_global_quantum singleton
44
//
45
static
tlm_global_quantum
&
instance
()
46
{
47
static
tlm_global_quantum
instance_;
48
return
instance_;
49
}
50
51
public
:
52
53
//
54
// Setter/getter for the global quantum
55
//
56
void
set
(
const
sc_core::sc_time
& t)
57
{
58
m_global_quantum
= t;
59
}
60
61
const
sc_core::sc_time
&
get
()
const
62
{
63
return
m_global_quantum
;
64
}
65
66
//
67
// This function will calculate the maximum value for the next local
68
// quantum for an initiator. All initiators should synchronize on
69
// integer multiples of the global quantum value. The value for the
70
// local quantum of an initiator can be smaller, but should never be
71
// greater than the value returned by this method.
72
//
73
sc_core::sc_time
compute_local_quantum
()
74
{
75
if
(
m_global_quantum
!=
sc_core::SC_ZERO_TIME
) {
76
const
sc_core::sc_time
current =
sc_core::sc_time_stamp
();
77
const
sc_core::sc_time
g_quant =
m_global_quantum
;
78
return
g_quant - (current % g_quant);
79
}
else
{
80
return
sc_core::SC_ZERO_TIME
;
81
}
82
}
83
84
protected
:
85
tlm_global_quantum
() :
m_global_quantum
(sc_core::
SC_ZERO_TIME
)
86
{
87
}
88
89
protected
:
90
sc_core::sc_time
m_global_quantum
;
91
};
92
93
}
// namespace tlm
94
95
#endif
tlm::tlm_global_quantum
Definition:
tlm_global_quantum.h:39
systemc
tlm::tlm_global_quantum::tlm_global_quantum
tlm_global_quantum()
Definition:
tlm_global_quantum.h:85
tlm::tlm_global_quantum::set
void set(const sc_core::sc_time &t)
Definition:
tlm_global_quantum.h:56
tlm::tlm_global_quantum::m_global_quantum
sc_core::sc_time m_global_quantum
Definition:
tlm_global_quantum.h:90
sc_core::SC_ZERO_TIME
const sc_time SC_ZERO_TIME
tlm::tlm_global_quantum::compute_local_quantum
sc_core::sc_time compute_local_quantum()
Definition:
tlm_global_quantum.h:73
sc_core::sc_time_stamp
const sc_time & sc_time_stamp()
tlm::tlm_global_quantum::instance
static tlm_global_quantum & instance()
Definition:
tlm_global_quantum.h:45
sc_core::sc_time
Generated on Thu Jun 19 2014 07:42:05 for TLM-2.0 by
1.8.6