Imported Upstream version 3.2.2
[debian/gnuradio] / gr-sounder / src / fpga / lib / dac_interface.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 "../top/config.vh"
23
24 module dac_interface(clk_i,rst_i,ena_i,strobe_i,tx_i_i,tx_q_i,tx_data_o,tx_sync_o);
25    input clk_i;
26    input rst_i;
27    input ena_i;
28    input strobe_i;
29    
30    input [13:0] tx_i_i;
31    input [13:0] tx_q_i;
32
33    output [13:0] tx_data_o;
34    output        tx_sync_o;
35
36 `ifdef TX_RATE_MAX
37    wire clk128;
38    reg clk64_d;
39    reg [13:0] tx_data_o;
40    
41    // Create a 128 MHz clock
42    dacpll pll128(.areset(rst_i),.inclk0(clk_i),.c0(clk128));
43
44    // Register the clk64 clock in the clk128 domain
45    always @(posedge clk128)
46      clk64_d <= #1 clk_i;
47
48    // Register the tx data in the clk128 domain
49    always @(posedge clk128)
50      tx_data_o <= #1 clk64_d ? tx_i_i : tx_q_i;
51
52    assign tx_sync_o = clk64_d;
53    
54
55 `else // !`ifdef TX_RATE_MAX
56    assign tx_data_o = strobe_i ? tx_q_i : tx_i_i;
57    assign tx_sync_o = strobe_i;
58 `endif // !`ifdef TX_RATE_MAX
59    
60 endmodule // dac_interface