summaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/divisors.py
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-10 11:57:58 -0800
committerJosh Blum <josh@joshknows.com>2010-02-10 11:57:58 -0800
commitd088a11bf7c257ba45bf0c37a41e5038b302bc44 (patch)
tree8bbb4d90285a181c603c117de4504e73066afe48 /firmware/microblaze/divisors.py
parente2044e13ec4ad94e9739402257134abd92cf1521 (diff)
downloaduhd-d088a11bf7c257ba45bf0c37a41e5038b302bc44.tar.gz
uhd-d088a11bf7c257ba45bf0c37a41e5038b302bc44.tar.bz2
uhd-d088a11bf7c257ba45bf0c37a41e5038b302bc44.zip
Copied a snapshot of the usrp2 firmware into the microblaze firmware directory in the uhd repo.
Added erllc copyrights to the files created and modified at erllc.
Diffstat (limited to 'firmware/microblaze/divisors.py')
-rwxr-xr-xfirmware/microblaze/divisors.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/firmware/microblaze/divisors.py b/firmware/microblaze/divisors.py
new file mode 100755
index 000000000..d31bd4dad
--- /dev/null
+++ b/firmware/microblaze/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()
+