aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/zpu/bin/divisors.py
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-19 22:23:46 -0800
committerJosh Blum <josh@joshknows.com>2011-01-19 22:23:46 -0800
commit9239878b0b81c3a368bf11cfc2fe48bfb05ff902 (patch)
treef41a5e58eac89b35cb99537a0a0b64662384a9f2 /firmware/zpu/bin/divisors.py
parentfc138381ee4bd8d191795230b7447071a85e1f28 (diff)
parent7d918c5f6acc9a5d2c8ae03e2e67b403f7efd5ff (diff)
downloaduhd-9239878b0b81c3a368bf11cfc2fe48bfb05ff902.tar.gz
uhd-9239878b0b81c3a368bf11cfc2fe48bfb05ff902.tar.bz2
uhd-9239878b0b81c3a368bf11cfc2fe48bfb05ff902.zip
Merge branch 'next'
Conflicts: host/lib/usrp/usrp2/codec_impl.cpp
Diffstat (limited to 'firmware/zpu/bin/divisors.py')
-rwxr-xr-xfirmware/zpu/bin/divisors.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/firmware/zpu/bin/divisors.py b/firmware/zpu/bin/divisors.py
new file mode 100755
index 000000000..d31bd4dad
--- /dev/null
+++ b/firmware/zpu/bin/divisors.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+speeds = (9600, 19200, 38400, 57600, 115200, 230400)
+
+master_clk = 100e6
+wb_clk = master_clk / 2
+
+def divisor(speed):
+ div0 = wb_clk // (speed * 16)
+ div1 = div0 + 1
+ actual0 = actual_speed(div0)
+ actual1 = actual_speed(div1)
+ if abs(actual0 - speed) < abs(actual1 - speed):
+ return div0
+ else:
+ return div1
+
+def actual_speed(divisor):
+ return (wb_clk // divisor) / 16
+
+def doit(speed):
+ div = divisor(speed)
+ actual = actual_speed(div)
+ rel_error = (actual - speed) / speed
+ print "target: %6d divisor: %6d actual: %11.4f %6.3f%%" % (speed, div, actual, rel_error*100)
+
+def main():
+ print "wb_clk = %f" % (wb_clk,)
+ for s in speeds:
+ doit(s)
+
+if __name__ == '__main__':
+ main()
+