fpga/usrp3: Fix DC truncation bias by adding rounding to DDC chain.

A digital DC bias caused by various truncations in the DDC chain was
previously noticable with small signal levels, especially with high
decimation rates. This patch eliminates the bias by replacing the
truncation with rounding or simply keeping more bits for longer where it
makes sense.

This is essentially a forward port of a similar prior fix to the usrp2
DDC chain: https://github.com/EttusResearch/fpga/pull/4.

Signed-off-by: Ryan Volz <ryan.volz@gmail.com>


Original-commit: a57c162a0d11ab82a83c911a94272ceb6f7ff70a
This commit is contained in:
Ryan Volz
2024-06-11 10:20:08 +02:00
committed by Joerg Hofrichter
parent 523212fa04
commit 1451ae066b
3 changed files with 88 additions and 29 deletions
+14 -2
View File
@@ -110,13 +110,25 @@ module small_hb_dec
localparam ACCWIDTH = 30;
reg [ACCWIDTH-1:0] accum;
wire [ACCWIDTH-1:0] prod_acc_rnd;
round #(
.bits_in (36),
.bits_out (ACCWIDTH),
.round_to_zero (1),
.round_to_nearest(0),
.trunc (0)
) round_prod (
.in(prod),
.out(prod_acc_rnd)
);
always @(posedge clk)
if(rst)
accum <= 0;
else if(go_d2)
accum <= {middle_d1[17],middle_d1[17],middle_d1,{(16+ACCWIDTH-36){1'b0}}} + {prod[35:36-ACCWIDTH]};
accum <= {middle_d1[17],middle_d1[17],middle_d1,{(16+ACCWIDTH-36){1'b0}}} + prod_acc_rnd;
else if(go_d3)
accum <= accum + {prod[35:36-ACCWIDTH]};
accum <= accum + prod_acc_rnd;
wire [WIDTH:0] accum_rnd;
wire [WIDTH-1:0] accum_rnd_clip;