ticks.py (6654:4c84e771cca7) ticks.py (9528:d05714c2ab9c)
1# Copyright (c) 2007 The Regents of The University of Michigan
2# All rights reserved.
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: Nathan Binkert
28
29import sys
1# Copyright (c) 2007 The Regents of The University of Michigan
2# All rights reserved.
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: Nathan Binkert
28
29import sys
30from m5.util import warn
30
31tps = 1.0e12 # default to 1 THz (1 Tick == 1 ps)
32tps_fixed = False # once set to true, can't be changed
33
34# fix the global frequency and tell C++ about it
35def fixGlobalFrequency():
36 import internal
37 global tps, tps_fixed

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

76 return 0
77
78 # convert the value from time to ticks
79 value *= tps
80
81 int_value = int(round(value))
82 err = (value - int_value) / value
83 if err > frequency_tolerance:
31
32tps = 1.0e12 # default to 1 THz (1 Tick == 1 ps)
33tps_fixed = False # once set to true, can't be changed
34
35# fix the global frequency and tell C++ about it
36def fixGlobalFrequency():
37 import internal
38 global tps, tps_fixed

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

77 return 0
78
79 # convert the value from time to ticks
80 value *= tps
81
82 int_value = int(round(value))
83 err = (value - int_value) / value
84 if err > frequency_tolerance:
84 print >>sys.stderr, "Warning: rounding error > tolerance"
85 print >>sys.stderr, " %f rounded to %d" % (value, int_value)
85 warn("rounding error > tolerance\n %f rounded to %d", value,
86 int_value)
86 return int_value
87
88__all__ = [ 'setGlobalFrequency', 'fixGlobalFrequency', 'fromSeconds',
89 'frequency_tolerance' ]
87 return int_value
88
89__all__ = [ 'setGlobalFrequency', 'fixGlobalFrequency', 'fromSeconds',
90 'frequency_tolerance' ]