root / host / lib / ic_reg_maps / gen_adf4360_regs.py @ caff65d7
History | View | Annotate | Download (3.7 KB)
| 1 | e6151334 | Josh Blum | #!/usr/bin/env python
|
|---|---|---|---|
| 2 | #
|
||
| 3 | 6779af92 | Josh Blum | # Copyright 2010 Ettus Research LLC
|
| 4 | #
|
||
| 5 | # This program is free software: you can redistribute it and/or modify
|
||
| 6 | e6151334 | Josh Blum | # it under the terms of the GNU General Public License as published by
|
| 7 | 6779af92 | Josh Blum | # the Free Software Foundation, either version 3 of the License, or
|
| 8 | # (at your option) any later version.
|
||
| 9 | #
|
||
| 10 | # This program is distributed in the hope that it will be useful,
|
||
| 11 | e6151334 | Josh Blum | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 13 | # GNU General Public License for more details.
|
||
| 14 | 6779af92 | Josh Blum | #
|
| 15 | e6151334 | Josh Blum | # You should have received a copy of the GNU General Public License
|
| 16 | 6779af92 | Josh Blum | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 17 | #
|
||
| 18 | e6151334 | Josh Blum | |
| 19 | ########################################################################
|
||
| 20 | # Template for raw text data describing registers
|
||
| 21 | # name addr[bit range inclusive] default optional enums
|
||
| 22 | ########################################################################
|
||
| 23 | 2bba9ca0 | Josh Blum | REGS_TMPL="""\
|
| 24 | e6151334 | Josh Blum | ########################################################################
|
| 25 | ## address 0
|
||
| 26 | ########################################################################
|
||
| 27 | core_power_level 0[2:3] 0 5ma, 10ma, 15ma, 20ma
|
||
| 28 | 0718961e | Josh Blum | counter_operation 0[4] 0 normal, reset
|
| 29 | e6151334 | Josh Blum | muxout_control 0[5:7] 0 3state, dld, ndiv, dvdd, rdiv, nchan_od_ld, sdo, dgnd
|
| 30 | phase_detector_polarity 0[8] 0 neg, pos
|
||
| 31 | 0718961e | Josh Blum | charge_pump_output 0[9] 0 normal, 3state
|
| 32 | e6151334 | Josh Blum | cp_gain_0 0[10] 0 set1, set2
|
| 33 | mute_till_ld 0[11] 0 dis, enb
|
||
| 34 | output_power_level 0[12:13] 0 3_5ma, 5_0ma, 7_5ma, 11_0ma
|
||
| 35 | 0718961e | Josh Blum | #set $current_setting_enums = ', '.join(map(lambda x: x+"ma", "0_31 0_62 0_93 1_25 1_56 1_87 2_18 2_50".split()))
|
| 36 | e6151334 | Josh Blum | current_setting1 0[14:16] 0 $current_setting_enums
|
| 37 | current_setting2 0[17:19] 0 $current_setting_enums
|
||
| 38 | power_down 0[20:21] 0 normal_op=0, async_pd=1, sync_pd=3
|
||
| 39 | prescaler_value 0[22:23] 0 8_9, 16_17, 32_33
|
||
| 40 | ########################################################################
|
||
| 41 | ## address 2
|
||
| 42 | ########################################################################
|
||
| 43 | a_counter 2[2:6] 0
|
||
| 44 | b_counter 2[8:20] 0
|
||
| 45 | cp_gain_1 2[21] 0 set1, set2
|
||
| 46 | divide_by_2_output 2[22] 0 fund, div2
|
||
| 47 | divide_by_2_prescaler 2[23] 0 fund, div2
|
||
| 48 | ########################################################################
|
||
| 49 | ## address 1
|
||
| 50 | ########################################################################
|
||
| 51 | r_counter 1[2:15] 0
|
||
| 52 | ablpw 1[16:17] 0 3_0ns, 1_3ns, 6_0ns
|
||
| 53 | lock_detect_precision 1[18] 0 3cycles, 5cycles
|
||
| 54 | test_mode_bit 1[19] 0
|
||
| 55 | band_select_clock_div 1[20:21] 0 1, 2, 4, 8
|
||
| 56 | """
|
||
| 57 | |||
| 58 | ########################################################################
|
||
| 59 | 2bba9ca0 | Josh Blum | # Template for methods in the body of the struct
|
| 60 | e6151334 | Josh Blum | ########################################################################
|
| 61 | 2bba9ca0 | Josh Blum | BODY_TMPL="""\
|
| 62 | enum addr_t{
|
||
| 63 | ADDR_CONTROL = 0,
|
||
| 64 | ADDR_NCOUNTER = 2,
|
||
| 65 | ADDR_RCOUNTER = 1
|
||
| 66 | };
|
||
| 67 | e6151334 | Josh Blum |
|
| 68 | 2bba9ca0 | Josh Blum | boost::uint32_t get_reg(addr_t addr){
|
| 69 | boost::uint32_t reg = addr & 0x3;
|
||
| 70 | switch(addr){
|
||
| 71 | 33393776 | Josh Blum | #for $addr in sorted(set(map(lambda r: r.get_addr(), $regs)))
|
| 72 | 2bba9ca0 | Josh Blum | case $addr:
|
| 73 | #for $reg in filter(lambda r: r.get_addr() == addr, $regs)
|
||
| 74 | reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift();
|
||
| 75 | e6151334 | Josh Blum | #end for
|
| 76 | 2bba9ca0 | Josh Blum | break;
|
| 77 | #end for
|
||
| 78 | e6151334 | Josh Blum | }
|
| 79 | 2bba9ca0 | Josh Blum | return reg;
|
| 80 | }
|
||
| 81 | e6151334 | Josh Blum | """
|
| 82 | |||
| 83 | if __name__ == '__main__': |
||
| 84 | 2bba9ca0 | Josh Blum | import common; common.generate( |
| 85 | name='adf4360_regs',
|
||
| 86 | regs_tmpl=REGS_TMPL, |
||
| 87 | body_tmpl=BODY_TMPL, |
||
| 88 | file=__file__, |
||
| 89 | ) |