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., 51 Franklin Street, Boston, MA 02110-1301 USA
24 #(parameter bw = 16, parameter N = 4, parameter log2_of_max_rate = 7)
31 input [bw-1:0] signal_in,
32 output reg [bw-1:0] signal_out);
34 localparam maxbitgain = N * log2_of_max_rate;
36 wire [bw+maxbitgain-1:0] signal_in_ext;
37 reg [bw+maxbitgain-1:0] integrator [0:N-1];
38 reg [bw+maxbitgain-1:0] differentiator [0:N-1];
39 reg [bw+maxbitgain-1:0] pipeline [0:N-1];
40 reg [bw+maxbitgain-1:0] sampler;
44 sign_extend #(bw,bw+maxbitgain)
45 ext_input (.in(signal_in),.out(signal_in_ext));
47 always @(posedge clock)
51 else if (enable && strobe_in)
53 integrator[0] <= integrator[0] + signal_in_ext;
55 integrator[i] <= integrator[i] + integrator[i-1];
58 always @(posedge clock)
65 differentiator[i] <= 0;
68 else if (enable && strobe_out)
70 sampler <= integrator[N-1];
71 differentiator[0] <= sampler;
72 pipeline[0] <= sampler - differentiator[0];
75 differentiator[i] <= pipeline[i-1];
76 pipeline[i] <= pipeline[i-1] - differentiator[i];
78 end // if (enable && strobe_out)
80 wire [bw-1:0] signal_out_unreg;
83 cic_dec_shifter(rate,pipeline[N-1],signal_out_unreg);
85 always @(posedge clock)
86 signal_out <= signal_out_unreg;
88 endmodule // cic_decim