⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ticks.py

📁 M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作为模拟平台
💻 PY
字号:
import systps = 1.0e12         # default to 1 THz (1 Tick == 1 ps)tps_fixed = False    # once set to true, can't be changed# fix the global frequency and tell C++ about itdef fixGlobalFrequency():    import internal    global tps, tps_fixed    if not tps_fixed:        tps_fixed = True        internal.core.setClockFrequency(int(tps))        print "Global frequency set at %d ticks per second" % int(tps)def setGlobalFrequency(ticksPerSecond):    import convert    global tps, tps_fixed    if tps_fixed:        raise AttributeError, \              "Global frequency already fixed at %f ticks/s." % tps    if isinstance(ticksPerSecond, (int, long)):        tps = ticksPerSecond    elif isinstance(ticksPerSecond, float):        tps = ticksPerSecond    elif isinstance(ticksPerSecond, str):        tps = round(convert.anyToFrequency(ticksPerSecond))    else:        raise TypeError, \              "wrong type '%s' for ticksPerSecond" % type(ticksPerSecond)# how big does a rounding error need to be before we warn about it?frequency_tolerance = 0.001  # 0.1%def fromSeconds(value):    if not isinstance(value, float):        raise TypeError, "can't convert '%s' to type tick" % type(value)    # once someone needs to convert to seconds, the global frequency    # had better be fixed    if not tps_fixed:        raise AttributeError, \              "In order to do conversions, the global frequency must be fixed"    if value == 0:        return 0    # convert the value from time to ticks    value *= tps    int_value = int(round(value))    err = (value - int_value) / value    if err > frequency_tolerance:        print >>sys.stderr, "Warning: rounding error > tolerance"        print >>sys.stderr, "    %f rounded to %d" % (value, int_value)    return int_value__all__ = [ 'setGlobalFrequency', 'fixGlobalFrequency', 'fromSeconds',            'frequency_tolerance' ]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -