Imported Upstream version 3.0
[debian/gnuradio] / usrp / fpga / sdr_lib / rx_chain.v
1 // -*- verilog -*-
2 //
3 //  USRP - Universal Software Radio Peripheral
4 //
5 //  Copyright (C) 2003 Matt Ettus
6 //
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.
11 //
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.
16 //
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
20 //
21
22 // Following defines conditionally include RX path circuitry
23
24 `include "usrp_std.vh"
25 module rx_chain
26   (input clock,
27    input reset,
28    input enable,
29    input wire [7:0] decim_rate,
30    input sample_strobe,
31    input decimator_strobe,
32    output wire hb_strobe,
33    input [6:0] serial_addr, input [31:0] serial_data, input serial_strobe,
34    input wire [15:0] i_in,
35    input wire [15:0] q_in,
36    output wire [15:0] i_out,
37    output wire [15:0] q_out,
38    output wire [15:0] debugdata,output wire [15:0] debugctrl
39    );
40
41    parameter FREQADDR = 0;
42    parameter PHASEADDR = 0;
43    
44    wire [31:0] phase;
45    wire [15:0] bb_i, bb_q;
46    wire [15:0] hb_in_i, hb_in_q;
47    
48    assign      debugdata = hb_in_i;
49
50 `ifdef RX_NCO_ON
51     phase_acc #(FREQADDR,PHASEADDR,32) rx_phase_acc
52      (.clk(clock),.reset(reset),.enable(enable),
53       .serial_addr(serial_addr),.serial_data(serial_data),.serial_strobe(serial_strobe),
54       .strobe(sample_strobe),.phase(phase) );
55
56    cordic rx_cordic
57      ( .clock(clock),.reset(reset),.enable(enable), 
58        .xi(i_in),.yi(q_in),.zi(phase[31:16]),
59        .xo(bb_i),.yo(bb_q),.zo() );
60 `else
61    assign bb_i = i_in;
62    assign bb_q = q_in;
63    assign sample_strobe = 1;
64 `endif // !`ifdef RX_NCO_ON
65    
66 `ifdef RX_CIC_ON
67    cic_decim cic_decim_i_0
68      ( .clock(clock),.reset(reset),.enable(enable),
69        .rate(decim_rate),.strobe_in(sample_strobe),.strobe_out(decimator_strobe),
70        .signal_in(bb_i),.signal_out(hb_in_i) );
71 `else
72    assign hb_in_i = bb_i;
73    assign decimator_strobe = sample_strobe;
74 `endif
75    
76 `ifdef RX_HB_ON
77    halfband_decim hbd_i_0
78      ( .clock(clock),.reset(reset),.enable(enable),
79        .strobe_in(decimator_strobe),.strobe_out(hb_strobe),
80        .data_in(hb_in_i),.data_out(i_out),.debugctrl(debugctrl) );
81 `else
82    assign i_out = hb_in_i;
83    assign hb_strobe = decimator_strobe;
84 `endif
85    
86 `ifdef RX_CIC_ON
87    cic_decim cic_decim_q_0
88      ( .clock(clock),.reset(reset),.enable(enable),
89        .rate(decim_rate),.strobe_in(sample_strobe),.strobe_out(decimator_strobe),
90        .signal_in(bb_q),.signal_out(hb_in_q) );
91 `else
92    assign hb_in_q = bb_q;
93 `endif
94
95 `ifdef RX_HB_ON
96    halfband_decim hbd_q_0
97      ( .clock(clock),.reset(reset),.enable(enable),
98        .strobe_in(decimator_strobe),.strobe_out(),
99        .data_in(hb_in_q),.data_out(q_out) );   
100 `else
101    assign q_out = hb_in_q;
102 `endif
103
104
105 endmodule // rx_chain