Intro
毕设项目:基于FPGA的4GHz信道化接收机。记录一些相关问题。
Fixed-Point Converter
定点化转换是MATLAB仿真的最后一步,也是算法验证和verilog实现之间的桥梁。同时,这也是我在毕设工作中出现问题的第一个部分。
整个定点化都是通过MATLAB的Fixed-Point Converter工具实现的。这个工具使用起来很方便,可以图形化地调节位宽、查看溢出情况。
这一部分出现的问题在工具自带的code review中都会体现,这里记录一些重要的问题。
Complex-Problem
当算法涉及复数时(信号处理中常见),矩阵定义需要注意。
例如这行代码:
1 | y = zeros(1, Nx + Nh - 1); |
由于x和h是复信号,这里会报错:The left-hand side has been constrained to be non-complex, but the right-hand side is complex. To correct this problem, make the right-hand side real using the function REAL, or change the initial assignment to the left-hand side variable to be a complex value using the COMPLEX function.
故我们要用这种方式来定义y矩阵:
1 | y = zeros(1, Nx + Nh - 1) + 0i; |