基于FPGA通原第一天学习总结
一、DDS在通信里的真实作用在FPGA通信系统里DDS 数字本振LO, Local Oscillator以后会一直用它做BPSK载波 sin(ωt)QPSKI/Q正交载波混频乘 DDS解调再乘 DDS二、DDS的核心思想DDS本质就三步① 相位累加器Phase Accumulatorphase phase FCW② 查表LUTsin_out sin(phase)③ 输出DAC / FPGA信号输出三、核心公式1、 频率控制字FCWFCW f_out × 2^N / f_clkf_out输出频率f_clkFPGA时钟N相位累加器位宽常用 32bit2、 相位含义phase ∈ [0, 2π)FPGA里不用π用0 ~ 2^N - 1五、FPGA DDSVerilog实现生成正弦波发生器module dds_basic( input wire clk, input wire rst_n, input wire [31:0] fcw, output reg [7:0] sin_out ); reg [31:0] phase_acc; always (posedge clk or negedge rst_n) begin if (!rst_n) phase_acc 32d0; else phase_acc phase_acc fcw; end wire [7:0] addr phase_acc[31:24]; reg [7:0] sin_lut [0:255]; initial begin $readmemh(sin_lut.hex, sin_lut); end always (posedge clk) begin sin_out sin_lut[addr]; end endmoduletb仿真代码timescale 1ns / 1ps module tb_dds_basic(); reg clk; reg rst_n; reg [31:0] fcw; wire [7:0] sin_out; dds_basic u_dds_basic ( .clk (clk), .rst_n (rst_n), .fcw (fcw), .sin_out (sin_out) ); //时钟生成 (100MHz) initial begin clk 1b0; forever #10 clk ~clk; end initial begin rst_n 1b0; fcw 32d0; #100; rst_n 1b1; #20; // FCW (1MHz * 2^32) / 100MHz 42949672.96 ≈ 42949673 fcw 32d42949673; #5000; // FCW (5MHz * 2^32) / 100MHz 214748364.8 ≈ 214748365 fcw 32d214748365; #5000; end endmodule波形仿真波形仿真能看到通过fcw计算公式输出的正弦波频率是对应上的今天就先到这里了。