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);
35 localparam maxbitgain = (N-1)*log2_of_max_rate;
37 wire [bw+maxbitgain-1:0] signal_in_ext;
38 reg [bw+maxbitgain-1:0] integrator [0:N-1];
39 reg [bw+maxbitgain-1:0] differentiator [0:N-1];
40 reg [bw+maxbitgain-1:0] pipeline [0:N-1];
42 sign_extend #(bw,bw+maxbitgain)
43 ext_input (.in(signal_in),.out(signal_in_ext));
45 //FIXME Note that this section has pipe and diff reversed
46 // It still works, but is confusing
47 always @(posedge clock)
51 else if (enable & strobe_out)
54 integrator[0] <= integrator[0] + pipeline[N-1];
56 integrator[i] <= integrator[i] + integrator[i-1];
59 always @(posedge clock)
64 differentiator[i] <= 0;
68 else if (enable && strobe_in)
70 differentiator[0] <= signal_in_ext;
71 pipeline[0] <= signal_in_ext - differentiator[0];
74 differentiator[i] <= pipeline[i-1];
75 pipeline[i] <= pipeline[i-1] - differentiator[i];
79 wire [bw-1:0] signal_out_unreg;
81 cic_int_shifter(rate,integrator[N-1],signal_out_unreg);
83 always @(posedge clock)
84 signal_out <= signal_out_unreg;
86 endmodule // cic_interp