diff options
author | Josh Blum <josh@joshknows.com> | 2010-04-30 11:11:09 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-04-30 11:11:09 -0700 |
commit | 29ea5f89b6f52dd5ad7fb0173ef5699f9c5f4ebf (patch) | |
tree | 557ea5a852716707ecfae03d2083dd7de3f954ce /host/lib/ic_reg_maps/gen_ad9510_regs.py | |
parent | e837c65eb2b49f8fc2516f4eba45eafaa9b7b76b (diff) | |
parent | 333937760305f9c7c8dfb1db95f4821a800ce043 (diff) | |
download | uhd-29ea5f89b6f52dd5ad7fb0173ef5699f9c5f4ebf.tar.gz uhd-29ea5f89b6f52dd5ad7fb0173ef5699f9c5f4ebf.tar.bz2 uhd-29ea5f89b6f52dd5ad7fb0173ef5699f9c5f4ebf.zip |
Merge branch 'reg_maps'
Diffstat (limited to 'host/lib/ic_reg_maps/gen_ad9510_regs.py')
-rwxr-xr-x | host/lib/ic_reg_maps/gen_ad9510_regs.py | 104 |
1 files changed, 35 insertions, 69 deletions
diff --git a/host/lib/ic_reg_maps/gen_ad9510_regs.py b/host/lib/ic_reg_maps/gen_ad9510_regs.py index 2dc19c691..83236c921 100755 --- a/host/lib/ic_reg_maps/gen_ad9510_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9510_regs.py @@ -16,14 +16,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -import sys -from common import * - ######################################################################## # Template for raw text data describing registers # name addr[bit range inclusive] default optional enums ######################################################################## -REGS_DATA_TMPL="""\ +REGS_TMPL="""\ ######################################################################## ## serial control port config ######################################################################## @@ -46,14 +43,14 @@ reset_all_counters 9[0] 0 ncounter_reset 9[1] 0 rcounter_reset 9[2] 0 cp_current_setting 9[4:6] 0 0_60ma, 1_2ma, 1_8ma, 2_4ma, 3_0ma, 3_6ma, 4_2ma, 4_8ma -pll_power_down A[0:1] 0 normal=0, async_pd=1, sync_pd=3 -prescaler_value A[2:4] 0 div1, div2, 2_3, 4_5, 8_9, 16_17, 32_33, div3 -b_counter_bypass A[6] 0 -ref_counter_msb B[0:5] 0 -ref_counter_lsb C[0:7] 0 -antibacklash_pw D[0:1] 0 1_3ns, 2_9ns, 6_0ns -dld_window D[5] 0 9_5ns, 3_5ns -lock_detect_disable D[6] 0 enb, dis +pll_power_down 0xA[0:1] 0 normal=0, async_pd=1, sync_pd=3 +prescaler_value 0xA[2:4] 0 div1, div2, 2_3, 4_5, 8_9, 16_17, 32_33, div3 +b_counter_bypass 0xA[6] 0 +ref_counter_msb 0xB[0:5] 0 +ref_counter_lsb 0xC[0:7] 0 +antibacklash_pw 0xD[0:1] 0 1_3ns, 2_9ns, 6_0ns +dld_window 0xD[5] 0 9_5ns, 3_5ns +lock_detect_disable 0xD[6] 0 enb, dis ######################################################################## ## fine delay adjust ######################################################################## @@ -103,71 +100,40 @@ soft_sync 58[2] 0 dist_power_down 58[3] 0 sync_power_down 58[4] 0 function_pin_select 58[5:6] 0 resetb, syncb, test, pdb -update_registers 5A[0] 0 +update_registers 0x5A[0] 0 """ ######################################################################## -# Header and Source templates below +# Template for methods in the body of the struct ######################################################################## -HEADER_TEXT=""" -#import time - -/*********************************************************************** - * This file was generated by $file on $time.strftime("%c") - **********************************************************************/ - -\#ifndef INCLUDED_AD9510_REGS_HPP -\#define INCLUDED_AD9510_REGS_HPP - -\#include <boost/cstdint.hpp> - -struct ad9510_regs_t{ -#for $reg in $regs - #if $reg.get_enums() - enum $(reg.get_name())_t{ - #for $i, $enum in enumerate($reg.get_enums()) - #set $end_comma = ',' if $i < len($reg.get_enums())-1 else '' - $(reg.get_name().upper())_$(enum[0].upper()) = $enum[1]$end_comma +BODY_TMPL="""\ +boost::uint8_t get_reg(boost::uint16_t addr){ + boost::uint8_t reg = 0; + switch(addr){ + #for $addr in sorted(set(map(lambda r: r.get_addr(), $regs))) + case $addr: + #for $reg in filter(lambda r: r.get_addr() == addr, $regs) + reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); #end for - } $reg.get_name(); - #else - boost::$reg.get_stdint_type() $reg.get_name(); - #end if -#end for - - ad9510_regs_t(void){ -#for $reg in $regs - $reg.get_name() = $reg.get_default(); -#end for - } - - boost::uint8_t get_reg(boost::uint16_t addr){ - boost::uint8_t reg = 0; - switch(addr){ - #for $addr in sorted(set(map(lambda r: r.get_addr(), $regs))) - case $addr: - #for $reg in filter(lambda r: r.get_addr() == addr, $regs) - reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); - #end for - break; - #end for - } - return reg; - } - - boost::uint32_t get_write_reg(boost::uint16_t addr){ - return (boost::uint32_t(addr) << 8) | get_reg(addr); - } - - boost::uint32_t get_read_reg(boost::uint16_t addr){ - return (boost::uint32_t(addr) << 8) | (1 << 15); + break; + #end for } + return reg; +} -}; +boost::uint32_t get_write_reg(boost::uint16_t addr){ + return (boost::uint32_t(addr) << 8) | get_reg(addr); +} -\#endif /* INCLUDED_AD9510_REGS_HPP */ +boost::uint32_t get_read_reg(boost::uint16_t addr){ + return (boost::uint32_t(addr) << 8) | (1 << 23); +} """ if __name__ == '__main__': - regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) - open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) + import common; common.generate( + name='ad9510_regs', + regs_tmpl=REGS_TMPL, + body_tmpl=BODY_TMPL, + file=__file__, + ) |