Imported Upstream version 3.2.2
[debian/gnuradio] / gr-radar-mono / src / fpga / lib / cordic_nco.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 module cordic_nco(clk_i,rst_i,ena_i,strobe_i,ampl_i,freq_i,phs_i,data_i_o,data_q_o);
23    input clk_i;
24    input rst_i;
25    input ena_i;
26    input strobe_i;
27
28    input [15:0] ampl_i;
29    input [31:0] freq_i;
30    input [31:0] phs_i;
31
32    output [15:0] data_i_o;
33    output [15:0] data_q_o;
34
35    reg [31:0] phase_reg;
36    wire [31:0] phase = phase_reg + phs_i;
37    wire [15:0] ampl;
38    
39    always @(posedge clk_i)
40      begin
41         if (rst_i | ~ena_i)
42           phase_reg <= 32'b0;
43         else if (strobe_i)
44           phase_reg <= phase_reg + freq_i;
45      end
46
47    assign ampl = ena_i ? ampl_i : 16'b0;
48
49    cordic tx_cordic
50      (.clock(clk_i),.reset(rst_i),.enable(strobe_i), 
51        .xi(ampl),.yi(16'b0),.zi(phase[31:16]),
52        .xo(data_i_o),.yo(data_q_o),.zo());
53           
54 endmodule // cordic_nco