1 Star 1 Fork 2

gwh/openofdm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gen_atan_lut.py 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Jinghao Shi 提交于 2017-04-03 12:52 . scripts init
#!/usr/bin/env python
"""
Generate atan Look Up Table (LUT)
Key = math.tan(phase)*SIZE -- phase \in [0, math.pi/4)
Value = int(math.atan(phase)*SIZE*2)
SIZE is LUT size. The value is scaled up by SIZE*2 so that adjacent LUT values
can be distinguished.
"""
SIZE = 2**8
SCALE = 512
import argparse
import math
import os
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--out')
args = parser.parse_args()
if args.out is None:
args.out = os.path.join(os.getcwd(), 'atan_lut.mif')
coe_out = '%s.coe' % (os.path.splitext(args.out)[0])
data = []
with open(args.out, 'w') as f:
for i in range(SIZE):
key = float(i)/SIZE
val = int(round(math.atan(key)*SCALE))
data.append(val)
print '%f -> %d' % (key, val)
f.write('{0:09b}\n'.format(val))
print "LUT SIZE %d, SCALE %d" % (SIZE, SCALE)
print "MIL file saved as %s" % (args.out)
with open(coe_out, 'w') as f:
f.write('memory_initialization_radix=2;\n')
f.write('memory_initialization_vector=\n')
f.write(',\n'.join(['{0:09b}'.format(l) for l in data]))
f.write(';')
print "COE file saved as %s" % (coe_out)
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gongwenhong/openofdm.git
git@gitee.com:gongwenhong/openofdm.git
gongwenhong
openofdm
openofdm
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385