3 // USRP - Universal Software Radio Peripheral
5 // Copyright (C) 2003 Matt Ettus
6 // Copyright (C) 2008 Corgan Enterprises LLC
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA
24 // NOTE: This only works for a max decim rate of 256
25 // NOTE: Signal "rate" is ONE LESS THAN the actual rate
27 module integ_shifter(rate,signal_in,signal_out);
29 parameter maxbitgain = 8;
32 input wire [bw+maxbitgain-1:0] signal_in;
33 output reg [bw-1:0] signal_out;
37 // Nearest without overflow -- ceil(log2(rate+1))
41 else if (rate >= 8'd64)
43 else if (rate >= 8'd32)
45 else if (rate >= 8'd16)
47 else if (rate >= 8'd8)
49 else if (rate >= 8'd4)
51 else if (rate >= 8'd2)
58 5'd1 : signal_out = signal_in[1+bw-1:1];
59 5'd2 : signal_out = signal_in[2+bw-1:2];
60 5'd3 : signal_out = signal_in[3+bw-1:3];
61 5'd4 : signal_out = signal_in[4+bw-1:4];
62 5'd5 : signal_out = signal_in[5+bw-1:5];
63 5'd6 : signal_out = signal_in[6+bw-1:6];
64 5'd7 : signal_out = signal_in[7+bw-1:7];
65 default : signal_out = signal_in[8+bw-1:8];
66 endcase // case(shift)
68 endmodule // integ_shifter