Imported Upstream version 3.2.2
[debian/gnuradio] / gr-gpio / src / fpga / 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 "config.vh"    // resolved relative to project root
25
26 module rx_chain
27   (input clock,
28    input reset,
29    input enable,
30    input wire [7:0] decim_rate,
31    input sample_strobe,
32    input decimator_strobe,
33    output wire hb_strobe,
34    input [6:0] serial_addr, input [31:0] serial_data, input serial_strobe,
35    input wire [15:0] i_in,
36    input wire [15:0] q_in,
37    output wire [15:0] i_out,
38    output wire [15:0] q_out,
39    output wire [15:0] debugdata,output wire [15:0] debugctrl
40    );
41
42    parameter FREQADDR = 0;
43    parameter PHASEADDR = 0;
44    
45    wire [31:0] phase;
46    wire [15:0] bb_i, bb_q;
47    wire [15:0] hb_in_i, hb_in_q;
48    
49    assign       debugdata = hb_in_i;
50
51 `ifdef RX_NCO_ON
52     phase_acc #(FREQADDR,PHASEADDR,32) rx_phase_acc
53      (.clk(clock),.reset(reset),.enable(enable),
54       .serial_addr(serial_addr),.serial_data(serial_data),.serial_strobe(serial_strobe),
55       .strobe(sample_strobe),.phase(phase) );
56
57    cordic rx_cordic
58      ( .clock(clock),.reset(reset),.enable(enable), 
59        .xi(i_in),.yi(q_in),.zi(phase[31:16]),
60        .xo(bb_i),.yo(bb_q),.zo() );
61 `else
62    assign bb_i = i_in;
63    assign bb_q = q_in;
64    assign sample_strobe = 1;
65 `endif // !`ifdef RX_NCO_ON
66
67 `ifdef RX_INTEG_ON
68    integrator integ_decim_i_0
69      ( .clock(clock),.reset(reset),.enable(enable),
70        .rate(decim_rate),.strobe_in(sample_strobe),.strobe_out(decimator_strobe),
71        .signal_in(bb_i),.signal_out(i_out) );
72
73    assign hb_strobe = decimator_strobe;
74 `else
75 `ifdef RX_CIC_ON
76    cic_decim cic_decim_i_0
77      ( .clock(clock),.reset(reset),.enable(enable),
78        .rate(decim_rate),.strobe_in(sample_strobe),.strobe_out(decimator_strobe),
79        .signal_in(bb_i),.signal_out(hb_in_i) );
80 `else
81    assign hb_in_i = bb_i;
82    assign decimator_strobe = sample_strobe;
83 `endif
84    
85 `ifdef RX_HB_ON
86    halfband_decim hbd_i_0
87      ( .clock(clock),.reset(reset),.enable(enable),
88        .strobe_in(decimator_strobe),.strobe_out(hb_strobe),
89        .data_in(hb_in_i),.data_out(i_out),.debugctrl(debugctrl) );
90 `else
91    assign i_out = hb_in_i;
92    assign hb_strobe = decimator_strobe;
93 `endif
94 `endif // RX_INTEG_ON
95
96 `ifdef RX_INTEG_ON
97    integrator integ_decim_q_0
98      ( .clock(clock),.reset(reset),.enable(enable),
99        .rate(decim_rate),.strobe_in(sample_strobe),.strobe_out(decimator_strobe),
100        .signal_in(bb_q),.signal_out(q_out) );
101 `else   
102 `ifdef RX_CIC_ON
103    cic_decim cic_decim_q_0
104      ( .clock(clock),.reset(reset),.enable(enable),
105        .rate(decim_rate),.strobe_in(sample_strobe),.strobe_out(decimator_strobe),
106        .signal_in(bb_q),.signal_out(hb_in_q) );
107 `else
108    assign hb_in_q = bb_q;
109 `endif
110
111 `ifdef RX_HB_ON
112    halfband_decim hbd_q_0
113      ( .clock(clock),.reset(reset),.enable(enable),
114        .strobe_in(decimator_strobe),.strobe_out(),
115        .data_in(hb_in_q),.data_out(q_out) );   
116 `else
117    assign q_out = hb_in_q;
118 `endif
119 `endif // RX_INTEG_ON
120
121 endmodule // rx_chain