ad_dds: Add selectable phase width option.
parent
7b553997ab
commit
a7f5746afb
|
@ -54,16 +54,16 @@ module ad_dds #(
|
||||||
|
|
||||||
// interface
|
// interface
|
||||||
|
|
||||||
input clk,
|
input clk,
|
||||||
input rst,
|
input rst,
|
||||||
input dac_dds_format,
|
input dac_dds_format,
|
||||||
input dac_data_sync,
|
input dac_data_sync,
|
||||||
input [ 15:0] tone_1_scale,
|
input [ 15:0] tone_1_scale,
|
||||||
input [ 15:0] tone_2_scale,
|
input [ 15:0] tone_2_scale,
|
||||||
input [ 15:0] tone_1_init_offset,
|
input [ 15:0] tone_1_init_offset,
|
||||||
input [ 15:0] tone_2_init_offset,
|
input [ 15:0] tone_2_init_offset,
|
||||||
input [ PHASE_DW-1:0] tone_1_freq_word,
|
input [ PHASE_DW-1:0] tone_1_freq_word,
|
||||||
input [ PHASE_DW-1:0] tone_2_freq_word,
|
input [ PHASE_DW-1:0] tone_2_freq_word,
|
||||||
output reg [DDS_DW*CLK_RATIO-1:0] dac_dds_data
|
output reg [DDS_DW*CLK_RATIO-1:0] dac_dds_data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -122,6 +122,7 @@ module ad_dds #(
|
||||||
// phase to amplitude convertor
|
// phase to amplitude convertor
|
||||||
ad_dds_2 #(
|
ad_dds_2 #(
|
||||||
.DDS_DW (DDS_DW),
|
.DDS_DW (DDS_DW),
|
||||||
|
.PHASE_DW (PHASE_DW),
|
||||||
.DDS_TYPE (DDS_TYPE),
|
.DDS_TYPE (DDS_TYPE),
|
||||||
.CORDIC_DW (CORDIC_DW),
|
.CORDIC_DW (CORDIC_DW),
|
||||||
.CORDIC_PHASE_DW (CORDIC_PHASE_DW))
|
.CORDIC_PHASE_DW (CORDIC_PHASE_DW))
|
||||||
|
|
|
@ -45,7 +45,7 @@ module ad_dds_1 #(
|
||||||
|
|
||||||
// interface
|
// interface
|
||||||
|
|
||||||
input clk,
|
input clk,
|
||||||
input [DDS_P_DW-1:0] angle,
|
input [DDS_P_DW-1:0] angle,
|
||||||
input [ 15:0] scale,
|
input [ 15:0] scale,
|
||||||
output reg [DDS_D_DW-1:0] dds_data);
|
output reg [DDS_D_DW-1:0] dds_data);
|
||||||
|
@ -65,23 +65,13 @@ module ad_dds_1 #(
|
||||||
generate
|
generate
|
||||||
if (DDS_TYPE == DDS_CORDIC_TYPE) begin
|
if (DDS_TYPE == DDS_CORDIC_TYPE) begin
|
||||||
|
|
||||||
// the cordic module input angle width must be equal with it's width
|
|
||||||
// at this point the phase is only generated on 16 bits
|
|
||||||
wire [DDS_P_DW-1:0] angle_s;
|
|
||||||
|
|
||||||
if (DDS_P_DW >= 16) begin
|
|
||||||
assign angle_s = {angle,{DDS_P_DW-15{1'b0}}};
|
|
||||||
end else begin
|
|
||||||
assign angle_s = {angle[15:16-DDS_P_DW],1'b0};
|
|
||||||
end
|
|
||||||
|
|
||||||
ad_dds_sine_cordic #(
|
ad_dds_sine_cordic #(
|
||||||
.CORDIC_DW(DDS_D_DW),
|
.CORDIC_DW(DDS_D_DW),
|
||||||
.PHASE_DW(DDS_P_DW),
|
.PHASE_DW(DDS_P_DW),
|
||||||
.DELAY_DW(1))
|
.DELAY_DW(1))
|
||||||
i_dds_sine (
|
i_dds_sine (
|
||||||
.clk (clk),
|
.clk (clk),
|
||||||
.angle (angle_s),
|
.angle (angle),
|
||||||
.sine (sine_s),
|
.sine (sine_s),
|
||||||
.cosine (),
|
.cosine (),
|
||||||
.ddata_in (1'b0),
|
.ddata_in (1'b0),
|
||||||
|
|
|
@ -41,6 +41,8 @@ module ad_dds_2 #(
|
||||||
parameter DISABLE = 0,
|
parameter DISABLE = 0,
|
||||||
// Range = 8-24
|
// Range = 8-24
|
||||||
parameter DDS_DW = 16,
|
parameter DDS_DW = 16,
|
||||||
|
// Range = 8-24
|
||||||
|
parameter PHASE_DW = 16,
|
||||||
// Set 1 for CORDIC or 2 for Polynomial
|
// Set 1 for CORDIC or 2 for Polynomial
|
||||||
parameter DDS_TYPE = 1,
|
parameter DDS_TYPE = 1,
|
||||||
// Range = 8-24
|
// Range = 8-24
|
||||||
|
@ -50,13 +52,13 @@ module ad_dds_2 #(
|
||||||
|
|
||||||
// interface
|
// interface
|
||||||
|
|
||||||
input clk,
|
input clk,
|
||||||
input dds_format,
|
input dds_format,
|
||||||
input [ 15:0] dds_phase_0,
|
input [PHASE_DW-1:0] dds_phase_0,
|
||||||
input [ 15:0] dds_scale_0,
|
input [ 15:0] dds_scale_0,
|
||||||
input [ 15:0] dds_phase_1,
|
input [PHASE_DW-1:0] dds_phase_1,
|
||||||
input [ 15:0] dds_scale_1,
|
input [ 15:0] dds_scale_1,
|
||||||
output [DDS_DW-1:0] dds_data);
|
output [ DDS_DW-1:0] dds_data);
|
||||||
|
|
||||||
// Local parameters
|
// Local parameters
|
||||||
|
|
||||||
|
@ -80,8 +82,10 @@ module ad_dds_2 #(
|
||||||
|
|
||||||
// internal signals
|
// internal signals
|
||||||
|
|
||||||
wire [15:0] dds_data_0_s;
|
wire [DDS_D_DW-1:0] dds_data_0_s;
|
||||||
wire [15:0] dds_data_1_s;
|
wire [DDS_D_DW-1:0] dds_data_1_s;
|
||||||
|
wire [DDS_P_DW-1:0] dds_phase_0_s;
|
||||||
|
wire [DDS_P_DW-1:0] dds_phase_1_s;
|
||||||
|
|
||||||
// disable DDS
|
// disable DDS
|
||||||
generate
|
generate
|
||||||
|
@ -120,6 +124,15 @@ module ad_dds_2 #(
|
||||||
dds_scale_1_d <= dds_scale_1;
|
dds_scale_1_d <= dds_scale_1;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
// phase
|
||||||
|
if (DDS_P_DW >= PHASE_DW) begin
|
||||||
|
assign dds_phase_0_s = {dds_phase_0,{DDS_P_DW-(PHASE_DW-1){1'b0}}};
|
||||||
|
assign dds_phase_1_s = {dds_phase_1,{DDS_P_DW-(PHASE_DW-1){1'b0}}};
|
||||||
|
end else begin
|
||||||
|
assign dds_phase_0_s = {dds_phase_0[(PHASE_DW-1):PHASE_DW-DDS_P_DW],1'b0};
|
||||||
|
assign dds_phase_1_s = {dds_phase_1[(PHASE_DW-1):PHASE_DW-DDS_P_DW],1'b0};
|
||||||
|
end
|
||||||
|
|
||||||
// dds-1
|
// dds-1
|
||||||
|
|
||||||
ad_dds_1 #(
|
ad_dds_1 #(
|
||||||
|
@ -128,7 +141,7 @@ module ad_dds_2 #(
|
||||||
.DDS_P_DW(CORDIC_PHASE_DW))
|
.DDS_P_DW(CORDIC_PHASE_DW))
|
||||||
i_dds_1_0 (
|
i_dds_1_0 (
|
||||||
.clk (clk),
|
.clk (clk),
|
||||||
.angle (dds_phase_0),
|
.angle (dds_phase_0_s),
|
||||||
.scale (dds_scale_0_d),
|
.scale (dds_scale_0_d),
|
||||||
.dds_data (dds_data_0_s));
|
.dds_data (dds_data_0_s));
|
||||||
|
|
||||||
|
@ -140,7 +153,7 @@ module ad_dds_2 #(
|
||||||
.DDS_P_DW(DDS_P_DW))
|
.DDS_P_DW(DDS_P_DW))
|
||||||
i_dds_1_1 (
|
i_dds_1_1 (
|
||||||
.clk (clk),
|
.clk (clk),
|
||||||
.angle (dds_phase_1),
|
.angle (dds_phase_1_s),
|
||||||
.scale (dds_scale_1_d),
|
.scale (dds_scale_1_d),
|
||||||
.dds_data (dds_data_1_s));
|
.dds_data (dds_data_1_s));
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue