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
23 // Integrate and dump decimation filter
25 // Functionally equivalent to single-stage CIC decimator, simpler code
26 // Results in single sample impulse response at decimated rate
29 ( clock,reset,enable,rate,strobe_in,strobe_out,signal_in,signal_out);
31 parameter maxbitgain = 8;
40 input [bw-1:0] signal_in;
41 wire [bw-1:0] signal_out_unreg;
42 output [bw-1:0] signal_out;
43 reg [bw-1:0] signal_out;
45 wire [bw+maxbitgain-1:0] signal_in_ext;
46 reg [bw+maxbitgain-1:0] accum;
47 reg [bw+maxbitgain-1:0] dump;
49 sign_extend #(bw,bw+maxbitgain)
50 ext_input (.in(signal_in),.out(signal_in_ext));
52 // Integrate samples, dump on strobe out
53 always @(posedge clock)
59 else if (enable && strobe_in)
61 accum <= accum + signal_in_ext;
65 accum <= signal_in_ext;
68 // Normalize for integration bit gain
70 shifter(rate,dump,signal_out_unreg);
72 always @(posedge clock)
73 signal_out <= #1 signal_out_unreg;
75 endmodule // integrator