sc_time.cc (12983:fb1f462ae89e) | sc_time.cc (12986:761e57785c6a) |
---|---|
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 --- 14 unchanged lines hidden (view full) --- 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" | 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 --- 14 unchanged lines hidden (view full) --- 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 "python/pybind11/pybind.hh" |
|
31#include "systemc/ext/core/sc_time.hh" 32 33namespace sc_core 34{ 35 36namespace 37{ 38 --- 10 unchanged lines hidden (view full) --- 49 [SC_FS] = 1.0e-15, 50 [SC_PS] = 1.0e-12, 51 [SC_NS] = 1.0e-9, 52 [SC_US] = 1.0e-6, 53 [SC_MS] = 1.0e-3, 54 [SC_SEC] = 1.0 55}; 56 | 32#include "systemc/ext/core/sc_time.hh" 33 34namespace sc_core 35{ 36 37namespace 38{ 39 --- 10 unchanged lines hidden (view full) --- 50 [SC_FS] = 1.0e-15, 51 [SC_PS] = 1.0e-12, 52 [SC_NS] = 1.0e-9, 53 [SC_US] = 1.0e-6, 54 [SC_MS] = 1.0e-3, 55 [SC_SEC] = 1.0 56}; 57 |
58void 59fixTimeResolution() 60{ 61 static bool fixed = false; 62 if (fixed) 63 return; 64 65 auto ticks = pybind11::module::import("m5.ticks"); 66 auto fix_global_frequency = ticks.attr("fixGlobalFrequency"); 67 fix_global_frequency(); 68 fixed = true; 69} 70 |
|
57} // anonymous namespace 58 59sc_time::sc_time() : val(0) {} 60 61sc_time::sc_time(double d, sc_time_unit tu) 62{ 63 val = 0; 64 if (d != 0) { | 71} // anonymous namespace 72 73sc_time::sc_time() : val(0) {} 74 75sc_time::sc_time(double d, sc_time_unit tu) 76{ 77 val = 0; 78 if (d != 0) { |
79 fixTimeResolution(); |
|
65 //XXX Assuming the time resolution is 1ps. 66 double scale = TimeUnitScale[tu] / TimeUnitScale[SC_PS]; 67 // Accellera claims there is a linux bug, and that these next two 68 // lines work around them. 69 volatile double tmp = d * scale + 0.5; 70 val = static_cast<uint64_t>(tmp); 71 } 72} --- 278 unchanged lines hidden --- | 80 //XXX Assuming the time resolution is 1ps. 81 double scale = TimeUnitScale[tu] / TimeUnitScale[SC_PS]; 82 // Accellera claims there is a linux bug, and that these next two 83 // lines work around them. 84 volatile double tmp = d * scale + 0.5; 85 val = static_cast<uint64_t>(tmp); 86 } 87} --- 278 unchanged lines hidden --- |