From 59c4a2bfc2fc4d9f6f98628b28f4eff6151d6844 Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Thu, 13 Oct 2011 17:20:17 -0700 Subject: dsp: make rounding a single bit work again --- usrp2/sdr_lib/round.v | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/usrp2/sdr_lib/round.v b/usrp2/sdr_lib/round.v index 5b83981c6..26d5a4cf4 100644 --- a/usrp2/sdr_lib/round.v +++ b/usrp2/sdr_lib/round.v @@ -32,12 +32,20 @@ module round output [bits_out-1:0] out, output [bits_in-bits_out:0] err); - wire round_corr; - wire round_corr_trunc = 0; - wire round_corr_rtz = (in[bits_in-1] & |in[bits_in-bits_out-1:0]); - wire round_corr_nearest = in[bits_in-bits_out-1]; - wire round_corr_nearest_safe = (~in[bits_in-1] & (&in[bits_in-2:bits_out])) ? 0 : + wire round_corr,round_corr_trunc,round_corr_rtz,round_corr_nearest,round_corr_nearest_safe; + + assign round_corr_trunc = 0; + assign round_corr_rtz = (in[bits_in-1] & |in[bits_in-bits_out-1:0]); + assign round_corr_nearest = in[bits_in-bits_out-1]; + + generate + if(bits_in-bits_out > 1) + assign round_corr_nearest_safe = (~in[bits_in-1] & (&in[bits_in-2:bits_out])) ? 0 : round_corr_nearest; + else + assign round_corr_nearest_safe = round_corr_nearest; + endgenerate + assign round_corr = round_to_nearest ? round_corr_nearest_safe : trunc ? round_corr_trunc : -- cgit v1.2.3