Imported Upstream version 3.2.2
[debian/gnuradio] / gr-radar-mono / src / fpga / lib / radar.v
1 // -*- verilog -*-
2 //
3 //  USRP - Universal Software Radio Peripheral
4 //
5 //  Copyright (C) 2007 Corgan Enterprises LLC
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 `include "../lib/radar_config.vh"
23
24 module radar(clk_i,saddr_i,sdata_i,s_strobe_i,
25              tx_side_o,tx_strobe_o,tx_dac_i_o,tx_dac_q_o,
26              rx_adc_i_i,rx_adc_q_i,
27              rx_strobe_o,rx_ech_i_o,rx_ech_q_o,io_tx_ena_o);
28    
29    // System interface
30    input         clk_i;         // Master clock @ 64 MHz
31    input  [6:0]  saddr_i;       // Configuration bus address
32    input  [31:0] sdata_i;       // Configuration bus data
33    input         s_strobe_i;    // Configuration bus write
34    
35    // Transmit subsystem
36    output        tx_side_o;     // Transmitter slot
37    output        tx_strobe_o;   // Generate an transmitter output sample
38    output [13:0] tx_dac_i_o;    // I channel transmitter output to DAC
39    output [13:0] tx_dac_q_o;    // Q channel transmitter output to DAC
40    output        io_tx_ena_o;   // Transmit/Receive switching
41       
42    // Receive subsystem
43    input  [15:0] rx_adc_i_i;    // I channel input from ADC
44    input  [15:0] rx_adc_q_i;    // Q channel input from ADC
45    output        rx_strobe_o;   // Indicates output samples ready for Rx FIFO
46    output [15:0] rx_ech_i_o;    // I channel processed echos to Rx FIFO
47    output [15:0] rx_ech_q_o;    // Q channel processed echos to Rx FIFO
48
49    // Application control
50    wire          reset;         // Master application reset
51    wire          tx_side;       // Transmitter slot
52    wire          debug_enabled; // Enable debugging mode;        
53    wire          tx_enable;     // Transmitter enable
54    wire          rx_enable;     // Receiver enable
55    wire          tx_ctrl;       // Transmitter on control
56    wire          rx_ctrl;       // Receiver on control
57    wire [15:0]   pulse_num;     // Count of pulses since tx_enabled
58          
59    // Configuration
60    wire [15:0]   ampl;          // Pulse amplitude
61    wire [31:0]   fstart;        // Chirp start frequency
62    wire [31:0]   fincr;         // Chirp per strobe frequency increment
63
64    radar_control controller
65      (.clk_i(clk_i),.saddr_i(saddr_i),.sdata_i(sdata_i),.s_strobe_i(s_strobe_i),
66       .reset_o(reset),.tx_side_o(tx_side_o),.dbg_o(debug_enabled),
67       .tx_strobe_o(tx_strobe_o),.tx_ctrl_o(tx_ctrl),.rx_ctrl_o(rx_ctrl),
68       .ampl_o(ampl),.fstart_o(fstart),.fincr_o(fincr),.pulse_num_o(pulse_num),
69       .io_tx_ena_o(io_tx_ena_o));
70
71    radar_tx transmitter
72      ( .clk_i(clk_i),.rst_i(reset),.ena_i(tx_ctrl),.strobe_i(tx_strobe_o),
73        .ampl_i(ampl),.fstart_i(fstart),.fincr_i(fincr),
74        .tx_i_o(tx_dac_i_o),.tx_q_o(tx_dac_q_o) );
75    
76    radar_rx receiver
77      ( .clk_i(clk_i),.rst_i(reset),.ena_i(rx_ctrl),.dbg_i(debug_enabled),
78        .pulse_num_i(pulse_num),.rx_in_i_i(rx_adc_i_i),.rx_in_q_i(rx_adc_q_i),
79        .rx_strobe_o(rx_strobe_o),.rx_i_o(rx_ech_i_o),.rx_q_o(rx_ech_q_o) );
80    
81 endmodule // radar