#!/bin/env python def clocks_calc_mult_shift(from_, to_, maxsec): sftacc = 32; tmp = maxsec * from_ >> 32; while tmp: tmp >>= 1 sftacc -= 1 for sft in xrange(32, 0, -1): tmp = to_ << sft; tmp += (from_ / 2) tmp /= from_ if ((tmp >> sftacc) == 0): break mult = tmp shift = sft return mult, shift for i in xrange(400050000, 500050000, 1000): mult, shift = clocks_calc_mult_shift(i/2, 1000000000, 4) if mult > 0xf0000000: print "CPU Freq:%d, mult:0x%x, shift:%d" % (i, mult, shift)