当前位置: 首页 > news >正文

AD9361 Evaluation Software配置脚本转换工具

最近在玩一个开源的AD9361项目,AD9361采用纯逻辑配置,不需要ARM或者MicroBlaze。其中,先是用AD9361 Evaluation Software生成配置脚本,再转换成ad9361_lut.v。

在网上查了一圈,有个转换工具叫bit_converter,也有人用python写了转换脚本,但一点下载,都是要收费的。

好在皇天不负有心人,哈哈,我给《AD9361-FM-Radio-Verilog-CMOS-main》的作者发了封邮件,然后在GITHUB上留言,大佬速度回复,并提供了转换的python脚本。

extract.py代码如下:

import re# with open('default.txt', 'r') as f:
with open('my_lut.txt', 'r') as f:for line in f.readlines():scan_line = re.search('ad9361_cmd_data[\s]=[\s]{(.*)};', line)if scan_line:print(scan_line.group(1).strip().replace('\t', ' '))

main.py代码如下:

import re
from art import *lut_str = "\t\t13'd{:<4d}:\tad9361_cmd_data\t= {{1'b{}, 10'h{}, 8'h{}}};"tmp = '=' * 50 + '\n'
# tmp += text2art("SITLINV")
# tmp += '=' * 50 + '\n'
tmp += text2art("BRIANSUNE")
tmp += '=' * 50 + '\n'
tmp += 'File Name: ad9361_lut.v' + '\n'
tmp += '=' * 50 + '\n'
tmp += 'Programed By: BrianSune\n'
tmp += 'Contact: briansune@gmail.com\n'output_str = ''.join('// {}\n'.format(tps) for tps in tmp.split('\n'))
output_str += '\nfunction [18 : 0] ad9361_cmd_data;\n'
output_str += 'input [12 : 0] index;\n'
output_str += '''
begincase(index)13'd0   :\tad9361_cmd_data\t= {1'b1, 10'h000, 8'h00};
'''# print(output_str)lut_idx = 1
output_str2 = ''check_list = []
wait_list = []path = r'E:\资料\AD9361 FM RADIO\AD9361-FM-Radio-Verilog-CMOS-main\adi_tool'
# path = r'C:\Users\briansuneZ\Desktop\golden_ad9361_bist_lvds_rx'
# path = r'C:\Users\briansuneZ\Desktop\golden_ad9361_bist_loop_lvds'
path += r'\ad9361_ini'with open(path, 'r') as f:for line in f.readlines():wr_re = re.search(r'SPIWrite[\s]+([0-9A-F]+),([0-9A-F]+)[\s]*[/ ]*(.*)', line)rd_re = re.search(r'SPIRead[\s]+([0-9A-F]+)[\s]*[/ ]*(.*)', line)cal_re = re.search(r'WAIT_CALDONE[\s]+.*[/]+ (.*0x([0-9A-F]+).*)', line)if wr_re:# print(wr_re.groups())tmp_str = lut_str.format(lut_idx, 1, wr_re.group(1), wr_re.group(2))if wr_re.group(3):tmp_str += '\t// {}'.format(wr_re.group(3))tmp_str += '\n'output_str2 += tmp_strlut_idx += 1if rd_re:# print(rd_re.groups())tmp_str = lut_str.format(lut_idx, 0, rd_re.group(1), '00')if rd_re.group(2):tmp_str += '\t// {}'.format(rd_re.group(2))tmp_str += '\n'output_str2 += tmp_strcheck_list.append('{} {}'.format(lut_idx, rd_re.group(2)))lut_idx += 1if cal_re:# print(cal_re.groups())tmp_str = lut_str.format(lut_idx, 0, cal_re.group(2), '00')tmp_str += '\t// {}\n'.format(cal_re.group(1))output_str2 += tmp_strcheck_list.append('{} {}'.format(lut_idx, cal_re.group(1)))lut_idx += 1if line.strip() == 'ReadPartNumber':output_str2 += lut_str.format(lut_idx, 0, '037', '00') + '\t// ReadPartNumber\n'check_list.append('{} {}'.format(lut_idx, 'part num'))lut_idx += 1if line[0:4] == 'WAIT':wait_list.append('{} {}'.format(lut_idx - 1, line.strip()))output_str += output_str2
output_str += lut_str.format(lut_idx, 1, '014', '68')
output_str += '''endcase
end
endfunction
'''# print(output_str)
with open('ad9361_lut.v', 'w') as wf:wf.write(output_str)[print(ck) for ck in check_list]
print('\n\n')
[print(wi) for wi in wait_list]

如果运行报错,要安装一下art,命令如下:

pip install art

最后,向briansune大佬致敬,还是国际友人有开源精神!

http://www.lryc.cn/news/261673.html

相关文章:

  • Centos7 配置Git
  • python工具方法 44 数据仿真生成(粘贴目标切片到背景图像上,数据标签校验)
  • Llama 架构分析
  • vue3前端 md5工具类
  • Unity触摸 射线穿透UI解决
  • 基于QTreeWidget实现带Checkbox的多级组织结构选择树
  • 探索 Vim:一个强大的文本编辑器
  • K8S(十)—容器探针
  • [C错题本]
  • tomcat启动异常:子容器启动失败(a child container failed during start)
  • JAVA序列化(创建可复用的 Java 对象)
  • 如何使用自动化工具编写测试用例?
  • redis底层数据结构之skiplist实现
  • mjpg-streamer配置其它端口访问视频
  • C++相关闲碎记录(15)
  • 汽车IVI中控开发入门及进阶(十一):ALSA音频
  • Gradle 之初体验
  • 【Spark精讲】Spark内存管理
  • C语言实现Hoare版快速排序(递归版)
  • git 避免输入用户名 密码 二进制/文本 文件冲突解决
  • [OpenWrt]RAX3000一根线实现上网和看IPTV
  • 最新50万字312道Java经典面试题52道场景题总结(附答案PDF)
  • ​html.parser --- 简单的 HTML 和 XHTML 解析器​
  • 赵传和源代码就是设计-UMLChina建模知识竞赛第4赛季第23轮
  • Leaflet.Graticule源码分析以及经纬度汉化展示
  • html 中vue3 的setup里调用element plus的弹窗 提示
  • 对话系统之解码策略(Top-k Top-p Temperature)
  • 《面向机器学习的数据标注规程》摘录
  • VGG(pytorch)
  • celery/schedules.py源码精读