Deleted Added
sdiff udiff text old ( 12989:f5e0cebe6999 ) new ( 13039:0c8ecf92a420 )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Authors: Gabe Black
28 */
29
30#include "base/logging.hh"
31#include "base/types.hh"
32#include "python/pybind11/pybind.hh"
33#include "systemc/ext/core/sc_time.hh"
34
35namespace sc_core
36{
37
38namespace
39{
40

--- 10 unchanged lines hidden (view full) ---

51 [SC_FS] = 1.0e-15,
52 [SC_PS] = 1.0e-12,
53 [SC_NS] = 1.0e-9,
54 [SC_US] = 1.0e-6,
55 [SC_MS] = 1.0e-3,
56 [SC_SEC] = 1.0
57};
58
59void
60fixTimeResolution()
61{
62 static bool fixed = false;
63 if (fixed)
64 return;
65
66 auto ticks = pybind11::module::import("m5.ticks");
67 auto fix_global_frequency = ticks.attr("fixGlobalFrequency");
68 fix_global_frequency();
69 fixed = true;
70}
71
72} // anonymous namespace
73
74sc_time::sc_time() : val(0) {}
75
76sc_time::sc_time(double d, sc_time_unit tu)
77{
78 val = 0;
79 if (d != 0) {
80 fixTimeResolution();
81 //XXX Assuming the time resolution is 1ps.
82 double scale = TimeUnitScale[tu] / TimeUnitScale[SC_PS];
83 // Accellera claims there is a linux bug, and that these next two
84 // lines work around them.
85 volatile double tmp = d * scale + 0.5;
86 val = static_cast<uint64_t>(tmp);
87 }
88}
89
90sc_time::sc_time(const sc_time &t)
91{
92 val = t.val;
93}
94
95sc_time::sc_time(double, bool)

--- 269 unchanged lines hidden ---