3 // USRP - Universal Software Radio Peripheral
5 // Copyright (C) 2008 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"
26 (input clock, input reset, input enable,
28 input wire [6:0] serial_addr, input wire [31:0] serial_data, input serial_strobe,
29 input wire [15:0] io_rx_a_in, input wire [15:0] io_rx_b_in,
30 //input wire [15:0] io_tx_a_in, input wire [15:0] io_tx_b_in,
31 output reg rx_dig0_i, output reg rx_dig0_q,
32 output reg rx_dig1_i, output reg rx_dig1_q );
34 // Buffer at input to chip
36 reg rx_dig_rx_a_a,rx_dig_rx_b_a,rx_dig_rx_a_b,rx_dig_rx_b_b;
37 //TODO possibly use a flancter here
38 //This code can optionally be extended to do streaming input from gpio of tx boards
39 //The code can also be extended to input more bits
41 always @(posedge clock)
43 //This is the first point where is determined which physical input gpio pins are used for streaming digital input
44 //The other point is the code which overrides these pins as input (oe = 0)
45 //rx_dig_tx_a_a <= #1 io_tx_a_in[14];
46 //rx_dig_tx_b_a <= #1 io_tx_a_in[15];
47 rx_dig_rx_a_a <= #1 io_rx_a_in[14];
48 rx_dig_rx_b_a <= #1 io_rx_a_in[15];
49 //rx_dig_tx_a_b <= #1 io_tx_b_in[14];
50 //rx_dig_tx_b_b <= #1 io_tx_b_in[15];
51 rx_dig_rx_a_b <= #1 io_rx_b_in[14];
52 rx_dig_rx_b_b <= #1 io_rx_b_in[15];
55 // Now mux to the appropriate outputs
56 wire [3:0] ddc3mux,ddc2mux,ddc1mux,ddc0mux;
58 wire [3:0] rx_numchan;//not used here
59 //TODO This setting reg readout is a duplicate of the one in adc_interface.v.
60 // Change code so this is done in only one place, or give this code its own register.
61 setting_reg #(`FR_RX_MUX) sr_rxmux(.clock(clock),.reset(reset),.strobe(serial_strobe),.addr(serial_addr),
62 .in(serial_data),.out({ddc3mux,ddc2mux,ddc1mux,ddc0mux,rx_realsignals,rx_numchan[3:1]}));
63 //assign rx_numchan[0] = 1'b0;
65 always @(posedge clock)
66 if (out_strobe) //out_strobe determines the time at which the digital inputs are sampled (with a delay of one sample)
68 rx_dig0_i <= #1 ddc0mux[1] ? (ddc0mux[0] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc0mux[0] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
69 rx_dig0_q <= #1 rx_realsignals ? 1'b0 : ddc0mux[3] ? (ddc0mux[2] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc0mux[2] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
70 rx_dig1_i <= #1 ddc1mux[1] ? (ddc1mux[0] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc1mux[0] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
71 rx_dig1_q <= #1 rx_realsignals ? 1'b0 : ddc1mux[3] ? (ddc1mux[2] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc1mux[2] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
72 //rx_dig2_i <= #1 ddc2mux[1] ? (ddc2mux[0] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc2mux[0] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
73 //rx_dig2_q <= #1 rx_realsignals ? 1'b0 : ddc2mux[3] ? (ddc2mux[2] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc2mux[2] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
74 //rx_dig3_i <= #1 ddc3mux[1] ? (ddc3mux[0] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc3mux[0] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
75 //rx_dig3_q <= #1 rx_realsignals ? 1'b0 : ddc3mux[3] ? (ddc3mux[2] ? rx_dig_rx_b_b : rx_dig_rx_a_b) : (ddc3mux[2] ? rx_dig_rx_b_a : rx_dig_rx_a_a);
78 endmodule // gpio_input