Imported Upstream version 3.2.2
[debian/gnuradio] / gr-radar-mono / src / fpga / lib / dac_interface.v
1 // -*- verilog -*-\r
2 //\r
3 //  USRP - Universal Software Radio Peripheral\r
4 //\r
5 //  Copyright (C) 2007 Corgan Enterprises LLC\r
6 //\r
7 //  This program is free software; you can redistribute it and/or modify\r
8 //  it under the terms of the GNU General Public License as published by\r
9 //  the Free Software Foundation; either version 2 of the License, or\r
10 //  (at your option) any later version.\r
11 //\r
12 //  This program is distributed in the hope that it will be useful,\r
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 //  GNU General Public License for more details.\r
16 //\r
17 //  You should have received a copy of the GNU General Public License\r
18 //  along with this program; if not, write to the Free Software\r
19 //  Foundation, Inc., 51 Franklin Street, Boston, MA  02110-1301  USA\r
20 //\r
21 \r
22 `include "../top/config.vh"\r
23 \r
24 module dac_interface(clk_i,rst_i,ena_i,strobe_i,tx_i_i,tx_q_i,tx_data_o,tx_sync_o);\r
25    input clk_i;\r
26    input rst_i;\r
27    input ena_i;\r
28    input strobe_i;\r
29    \r
30    input [13:0] tx_i_i;\r
31    input [13:0] tx_q_i;\r
32 \r
33    output [13:0] tx_data_o;\r
34    output        tx_sync_o;\r
35 \r
36 `ifdef TX_RATE_MAX\r
37    wire clk128;\r
38    reg clk64_d;\r
39    reg [13:0] tx_data_o;\r
40    \r
41    // Create a 128 MHz clock\r
42    dacpll pll128(.areset(rst_i),.inclk0(clk_i),.c0(clk128));\r
43 \r
44    // Register the clk64 clock in the clk128 domain\r
45    always @(posedge clk128)\r
46      clk64_d <= clk_i;\r
47 \r
48    // Register the tx data in the clk128 domain\r
49    always @(posedge clk128)\r
50      tx_data_o <= clk64_d ? tx_i_i : tx_q_i;\r
51 \r
52    assign tx_sync_o = clk64_d;\r
53    \r
54 \r
55 `else // !`ifdef TX_RATE_MAX\r
56    assign tx_data_o = strobe_i ? tx_i_i : tx_q_i;\r
57    assign tx_sync_o = strobe_i;\r
58 `endif // !`ifdef TX_RATE_MAX\r
59    \r
60 endmodule // dac_interface\r