Skip to content

Commit

Permalink
ad_dds_sine_cordic: Fix sine pic to pic amplitude.
Browse files Browse the repository at this point in the history
When the tool calculates the X value for different phase widths, we
get rounding errors for every width in the interval [8;24].
Depending on the width thess errors cause overflows or smaller amplitudes
of the sine waves.
The error is not linear nor proportional with the phase. To fix the issue
a simple aproximation was chosen.
  • Loading branch information
AndreiGrozav committed Jul 18, 2018
1 parent 6a18536 commit 3dc7be3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/common/ad_dds_sine_cordic.v
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ module ad_dds_sine_cordic #(
localparam ANGLE_ROT_VAL_22 = 0.0000136603783400;
localparam ANGLE_ROT_VAL_23 = 0.0000068301891700;

// 1.64676025812 = system gain
// 1.64676025812 =~ system gain

localparam X_FSCALE = 1 << (CORDIC_DW);
localparam [CORDIC_DW-1:0] X_VALUE = ((X_FSCALE/2)/1.64676025812)-3; // ((2^N)/2)/1.647...
localparam APROX_DW_GAIN_ERR = (CORDIC_DW < 21) ? 4 :
(CORDIC_DW <= 24) ? 7 : 0;
// ((2^N)/2)/1.647...
localparam [CORDIC_DW-1:0] X_VALUE = ((X_FSCALE/2)/(1.64676))-APROX_DW_GAIN_ERR;

// Registers Declarations

Expand Down

0 comments on commit 3dc7be3

Please sign in to comment.