现在,虽然相位累加器非常精确,但输出受到查找表中条目数量有限的影响:从一个条目转到下一个条目时,输出值会“跳跃”。 这对于低输出频率特别敏感,但也会影响高输出频率,这会在输出频谱中引入不需要的频率。
本文引用地址:我们将解决这个问题。 为了便于理解,让我们回到 15 位相位累加器。
// sine without linear interpolationreg [14:0] phase_acc; // 15bitalways @(posedge clk) phase_acc <= phase_acc + 15'h1;sine_lookup my_sine(.clk(clk), .addr(phase_acc[14:4]), .value(sine_lookup_output));
上面的代码每 16 个时钟从一个查找表移动到下一个查找表。 这使得输出每 16 个时钟“跳跃”一次。
改善这种情况的有效方法是使用相位累加器的最低 4 位(到目前为止未使用)在两个连续的查找表条目之间进行线性。 这很容易做到(使用两个查找表而不是一个查找表)。
// sine with linear interpolationreg [14:0] phase_acc;always @(posedge clk) phase_acc <= phase_acc + 15'h1;// use two lookup tables to get two successive table valueswire [16:0] sine1_lv, sine2_lv; sine_lookup my_sine1(.clk(clk), .addr(phase_acc[14:4] ), .value(sine1_lv));sine_lookup my_sine2(.clk(clk), .addr(phase_acc[14:4]+11'h1), .value(sine2_lv));// now the 4 LSB bits from the phase accumulator need to be delayed// (to match the latency introduced by the lookup tables)reg [3:0] phase_LSB_delay1; always @(posedge clk) phase_LSB_delay1 <= phase_LSB[3:0];reg [3:0] phase_LSB_delay2; always @(posedge clk) phase_LSB_delay2 <= phase_LSB_delay1;reg [3:0] phase_LSB_delay3; always @(posedge clk) phase_LSB_delay3 <= phase_LSB_delay2;// before we can use them to do the interpolationwire [4:0] sine1_mf = 5'h10 - phase_LSB_delay3;wire [3:0] sine2_mf = phase_LSB_delay3;reg [20:0] sine_p; always @(posedge clk) sine_p <= sine1_lv*sine1_mf + sine2_lv*sine2_mf;assign DAC_data_out = sine_p[20:11];
两个查找表包含相同的值。 我们从一个值中提取一个值,从另一个值中提取它的相邻值(“phase_acc+1”),这样我们就可以在两个值之间线性。
使我们能够从 中获得更好的分辨率,同时保持查找表大小合理。 我们的查找表创建具有 2048 个值的正弦函数。在每个值之间,我们插值 15 个点,因此我们最终得到 2048*16=32768 个正弦点,就像有更大的查找表一样。
改进的想法
使用 32 位相位累加器覆盖各种频率(或查看 Saxo-Q 的 USB 控制的 32 位 示例)。
减少查找表的要求(仅使用一个,或使用迭代方法(如 CORDIC))。
使用 sin(x)/x 滤波器而不是线性插值。
使用抖动来提高DAC分辨率。
实验轮到你来了!
上一篇:
下一篇:(总)
相关文章









