3 // USRP - Universal Software Radio Peripheral
5 // Copyright (C) 2003 Matt Ettus
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 module cic_int_shifter(rate,signal_in,signal_out);
26 parameter log2_of_max_rate = 7;
27 parameter maxbitgain = (N-1)*log2_of_max_rate;
30 input wire [bw+maxbitgain-1:0] signal_in;
31 output reg [bw-1:0] signal_out;
33 function [2:0] log_ceil;
35 log_ceil = val[6] ? 3'd7 : val[5] ? 3'd6 : val[4] ? 3'd5 :
36 val[3] ? 3'd4 : val[2] ? 3'd3 : val[1] ? 3'd2 : 3'd1;
37 endfunction // log_ceil
39 function [4:0] bitgain;
42 8'd4 : bitgain = 2*(N-1);
43 8'd8 : bitgain = 3*(N-1);
44 8'd16 : bitgain = 4*(N-1);
45 8'd32 : bitgain = 5*(N-1);
46 8'd64 : bitgain = 6*(N-1);
47 8'd128 : bitgain = 7*(N-1);
52 8'd9,8'd10 : bitgain = 10;
54 8'd13,8'd14,8'd15 : bitgain = 12;
55 8'd17,8'd18,8'd19,8'd20 : bitgain = 13;
56 8'd21,8'd22,8'd23,8'd24,8'd25 : bitgain = 14;
57 8'd26,8'd27,8'd28,8'd29,8'd30,8'd31 : bitgain = 15;
58 8'd33,8'd34,8'd35,8'd36,8'd37,8'd38,8'd39,8'd40 : bitgain = 16;
59 8'd41,8'd42,8'd43,8'd44,8'd45,8'd46,8'd47,8'd48,8'd49,8'd50 : bitgain = 17;
60 8'd51,8'd52,8'd53,8'd54,8'd55,8'd56,8'd57,8'd58,8'd59,8'd60,8'd61,8'd62,8'd63 : bitgain = 18;
61 8'd65,8'd66,8'd67,8'd68,8'd69,8'd70,8'd71,8'd72,8'd73,8'd74,8'd75,8'd76,8'd77,8'd78,8'd79,8'd80 : bitgain = 19;
62 8'd81,8'd82,8'd83,8'd84,8'd85,8'd86,8'd87,8'd88,8'd89,8'd90,8'd91,8'd92,8'd93,8'd94,8'd95,8'd96,8'd97,8'd98,8'd99,8'd100,8'd101 : bitgain = 20;
64 default : bitgain = 21;
66 endfunction // bitgain
68 wire [4:0] shift = bitgain(rate+1);
70 // We should be able to do this, but can't ....
71 // assign signal_out = signal_in[shift+bw-1:shift];
75 5'd6 : signal_out = signal_in[6+bw-1:6];
76 5'd9 : signal_out = signal_in[9+bw-1:9];
77 5'd12 : signal_out = signal_in[12+bw-1:12];
78 5'd15 : signal_out = signal_in[15+bw-1:15];
79 5'd18 : signal_out = signal_in[18+bw-1:18];
80 5'd21 : signal_out = signal_in[21+bw-1:21];
82 5'd7 : signal_out = signal_in[7+bw-1:7];
83 5'd8 : signal_out = signal_in[8+bw-1:8];
84 5'd10 : signal_out = signal_in[10+bw-1:10];
85 5'd11 : signal_out = signal_in[11+bw-1:11];
86 5'd13 : signal_out = signal_in[13+bw-1:13];
87 5'd14 : signal_out = signal_in[14+bw-1:14];
88 5'd16 : signal_out = signal_in[16+bw-1:16];
89 5'd17 : signal_out = signal_in[17+bw-1:17];
90 5'd19 : signal_out = signal_in[19+bw-1:19];
91 5'd20 : signal_out = signal_in[20+bw-1:20];
94 default : signal_out = signal_in[21+bw-1:21];
95 endcase // case(shift)
97 endmodule // cic_int_shifter