1.软件版本
Quartusii12.1
2.设计过程
DDFS的工作过程为:在参考时钟fc的作用下,相位累加器对频率控制字FCW进行线性累加,将其高W位作为地址码通过波形查值表ROM变换,产生D位对应信号波形的数字序列,再由数模转换器DAC将其转化为阶梯模拟电压波形后由具有内插作用的低通滤波器LPF将其平滑为连续的正弦波形作为输出。
一个N位的相位累加器对应相位圆2N上个相位点,其最低相位分辨率为θmin= Δθ=2π/2N。在图2中N为4,则有16个相位值和16个幅度码相对应。该幅度存储于波形存储器中,在频率控制字FCW的作用下,相位累加器给出不同的相位码,对波形存储器寻址,完成相位--幅度变换,经DAC变成阶梯正弦波信号,再通过低通滤波器平滑,便得到模拟正弦波输出。
DDFS可以很容易实现正弦信号和余弦信号正交两路输出,这只需要用相位累加器的输出同时驱动固化有正弦信号波形的ROM 和余弦波形的ROM,并各自经过D/A转换器和低通滤波器输出即可。
3.ROM压缩和地址映射模块
这里ROM的地址压缩采用了正弦信号的对称性特点进行设计的,压缩比为1:4,即在ROM中存储四分之一个周期。然后通过地址的映射,来产生所要的地址信息。具体的做法如下所示:
首先在ROM中存储1/4个正弦周期:
那么地址映射过程如下所示,这里以地址位宽14位为例
对于0~4095:
地址不变,直接输入寻址。
对于4095~8191:
输入地址做如下所示:8191 – 当前输入地址。
对于8192~12287:
输入地址做如下所示:当前输入地址 - 8192。
对于12288~16383:
输入地址做如下所示:4095 - (当前输入地址 – 12288)。
4.部分源码
// Copyright (C) 1991-2010 Altera Corporation
// Your use of Altera Corporation's design tools, logic functions
// and other software and tools, and its AMPP partner logic
// functions, and any output files from any of the foregoing
// (including device programming or simulation files), and any
// associated documentation or information are expressly subject
// to the terms and conditions of the Altera Program License
// Subscription Agreement, Altera MegaCore Function License
// Agreement, or other applicable license agreement, including,
// without limitation, that your use is for the sole purpose of
// programming logic devices manufactured by Altera and sold by
// Altera or its authorized distributors. Please refer to the
// applicable agreement for further details.
// PROGRAM "Quartus II"
// VERSION "Version 10.0 Build 262 08/18/2010 Service Pack 1 SJ Full Version"
// CREATED "Sat May 19 07:38:24 2012"
module tops(
clk,
rst,
i_fkw,
i_phase,
cube,
nsins,
o_addresssss,
phase,
sins
);
input wire clk;
input wire rst;
input wire [27:0] i_fkw;
input wire [13:0] i_phase;
output wire cube;
output wire [15:0] nsins;
output wire [11:0] o_addresssss;
output wire [1:0] phase;
output wire [15:0] sins;
wire [15:0] SYNTHESIZED_WIRE_7;
wire [1:0] SYNTHESIZED_WIRE_8;
wire [11:0] SYNTHESIZED_WIRE_2;
assign o_addresssss = SYNTHESIZED_WIRE_2;
assign phase = SYNTHESIZED_WIRE_8;
phase_dds b2v_inst(
.i_clk(clk),
.i_rst(rst),
.i_FKW(i_fkw),
.i_phases(i_phase),
.o_addresssss(SYNTHESIZED_WIRE_2),
.o_phase(SYNTHESIZED_WIRE_8));
cube_gen b2v_inst10(
.i_data(SYNTHESIZED_WIRE_7),
.i_phase(SYNTHESIZED_WIRE_8),
.o_cube(cube));
dds_rom b2v_inst2(
.i_clk(clk),
.i_rst(rst),
.i_address(SYNTHESIZED_WIRE_2),
.o_data(SYNTHESIZED_WIRE_7));
sin_gen b2v_inst6(
.i_data(SYNTHESIZED_WIRE_7),
.i_phase(SYNTHESIZED_WIRE_8),
.o_sin(sins));
nsin_gen b2v_inst7(
.i_data(SYNTHESIZED_WIRE_7),
.i_phase(SYNTHESIZED_WIRE_8),
.o_sin(nsins));
endmodule
5.仿真结果
资源占用如下所示:
整个系统的代码如下所示:
A35-13