diff options
author | Martin Braun <martin.braun@ettus.com> | 2014-10-07 09:39:25 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2014-10-07 09:39:25 +0200 |
commit | 5bd58bc309e959537e3e820abfa39ee629b140a5 (patch) | |
tree | 81e3a611134e02d9118f0aa846b7146234849fe8 /firmware/usrp2/bin/divisors.py | |
parent | 9f6a11173aef5e661100268bd746963d713adb91 (diff) | |
download | uhd-5bd58bc309e959537e3e820abfa39ee629b140a5.tar.gz uhd-5bd58bc309e959537e3e820abfa39ee629b140a5.tar.bz2 uhd-5bd58bc309e959537e3e820abfa39ee629b140a5.zip |
Reorganized firmware/ subdirectory (x300->usrp3, zpu->usrp2)
Diffstat (limited to 'firmware/usrp2/bin/divisors.py')
-rwxr-xr-x | firmware/usrp2/bin/divisors.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/firmware/usrp2/bin/divisors.py b/firmware/usrp2/bin/divisors.py new file mode 100755 index 000000000..d31bd4dad --- /dev/null +++ b/firmware/usrp2/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() + |