3 // USRP - Universal Software Radio Peripheral
5 // Copyright (C) 2007 Corgan Enterprises LLC
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
22 `include "../../../../usrp/firmware/include/fpga_regs_common.v"
23 `include "../../../../usrp/firmware/include/fpga_regs_standard.v"
25 module sounder(clk_i, saddr_i, sdata_i, s_strobe_i,
26 tx_strobe_i, tx_dac_i_o,tx_dac_q_o,
27 rx_strobe_i, rx_adc_i_i,rx_adc_q_i,
28 rx_strobe_o, rx_imp_i_o,rx_imp_q_o);
31 input clk_i; // Master clock @ 64 MHz
32 input [6:0] saddr_i; // Configuration bus address
33 input [31:0] sdata_i; // Configuration bus data
34 input s_strobe_i; // Configuration bus write
37 input tx_strobe_i; // 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
42 input rx_strobe_i; // Indicates receive sample ready from ADC
43 output rx_strobe_o; // Indicates output samples ready for Rx FIFO
44 input [15:0] rx_adc_i_i; // I channel input from ADC interface module
45 input [15:0] rx_adc_q_i; // Q channel input from ADC interface module
46 output [15:0] rx_imp_i_o; // I channel impulse response to Rx FIFO
47 output [15:0] rx_imp_q_o; // Q channel impulse response to Rx FIFO
59 setting_reg #(`FR_USER_0) sr_mode
60 ( .clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
61 .out({loopback,receive,transmit,reset}) );
63 setting_reg #(`FR_USER_1) sr_lfsr_degree
64 ( .clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),.out(degree) );
66 lfsr_constants constants(.degree_i(degree),.mask_o(mask),.len_o(len));
68 // Loopback implementation
69 wire [13:0] tx_i, tx_q;
70 wire [15:0] tx_i_ext, tx_q_ext;
71 wire [15:0] rx_i, rx_q;
73 sign_extend #(14,16) tx_i_extender(tx_i, tx_i_ext);
74 sign_extend #(14,16) tx_q_extender(tx_q, tx_q_ext);
76 assign tx_dac_i_o = loopback ? 14'b0 : tx_i;
77 assign tx_dac_q_o = loopback ? 14'b0 : tx_q;
78 assign rx_i = loopback ? tx_i_ext : rx_adc_i_i;
79 assign rx_q = loopback ? tx_q_ext : rx_adc_q_i;
81 sounder_tx transmitter
82 ( .clk_i(clk_i),.rst_i(reset),.ena_i(transmit),
83 .strobe_i(tx_strobe_i),.mask_i(mask),
84 .tx_i_o(tx_i),.tx_q_o(tx_q) );
87 ( .clk_i(clk_i),.rst_i(reset),.ena_i(receive),
88 .rx_strobe_i(rx_strobe_i),.tx_strobe_i(tx_strobe_i),.mask_i(mask),.degree_i(degree),.len_i(len),
89 .rx_in_i_i(rx_i),.rx_in_q_i(rx_q),.rx_i_o(rx_imp_i_o),.rx_q_o(rx_imp_q_o),
90 .rx_strobe_o(rx_strobe_o),.loop_i(loopback));