标题: DDS AM FM [打印本页]

作者: xxkxsmy    时间: 2018-7-5 14:09
标题: DDS AM FM
module DDS
(
input clk,
input rst_n,
output [15:0]SineOut,
input wire [31:0] KW//=32'd42950//1KHZ
);
// fc = 100MHz
//输出频率 fo = 1kHz(根据需要可以设为任意值)
//控制参数 KW  = (fo*2^N)/fc = 42950
//参数 N = 2^32,(32为计数器的位宽)
//****************************************/
//wire [31:0] KW=32'd42950;//1KHZ
wire [15:0] Sine;
DDS_Core DDS_Core_inst
(
.clk(clk) , // input  clk_sig
.rst_n(rst_n) , // input  rst_n_sig
.KW(KW) , // input [31:0] KW_sig
.Sine(Sine)  // output [15:0] Sine_sig
);
assign SineOut=Sine+16'h8000;//有符号

endmodule



module DDS_Core
(
input clk,
input rst_n,
input [31:0] KW,
output [15:0] Sine
);
reg [31:0] cnt;
always @(posedge clk,negedge rst_n)
  begin
   if(!rst_n) cnt<=32'd0;
   else cnt<=cnt+KW;
  end
wire [13:0] addr=cnt[31:18];
dds_rom dds_rom_inst (
.address ( addr),
.clock ( clk ),
.q ( Sine )
);
endmodule






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1