3 // USRP - Universal Software Radio Peripheral
5 // Copyright (C) 2003 Matt Ettus
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
26 module ddc(input clock,
41 wire [15:0] i_cordic_out, q_cordic_out;
44 wire strobe1, strobe2;
45 reg [3:0] strobe_ctr1,strobe_ctr2;
47 always @(posedge clock)
49 strobe_ctr2 <= #1 4'd0;
51 strobe_ctr2 <= #1 4'd0;
53 strobe_ctr2 <= #1 strobe_ctr2 + 4'd1;
55 always @(posedge clock)
57 strobe_ctr1 <= #1 4'd0;
59 strobe_ctr1 <= #1 4'd0;
61 strobe_ctr1 <= #1 strobe_ctr1 + 4'd1;
64 assign strobe2 = enable & ( strobe_ctr2 == rate2 );
65 assign strobe1 = strobe2 & ( strobe_ctr1 == rate1 );
67 assign strobe = strobe1;
69 function [2:0] log_ceil;
72 log_ceil = val[3] ? 3'd4 : val[2] ? 3'd3 : val[1] ? 3'd2 : 3'd1;
75 wire [2:0] shift1 = log_ceil(rate1);
76 wire [2:0] shift2 = log_ceil(rate2);
78 cordic #(.bitwidth(bw),.zwidth(zw),.stages(16))
79 cordic(.clock(clock), .reset(reset), .enable(enable),
80 .xi(i_in), .yi(q_in), .zi(phase[31:32-zw]),
81 .xo(i_cordic_out), .yo(q_cordic_out), .zo() );
83 cic_decim_2stage #(.bw(bw),.N(4))
84 decim_i(.clock(clock),.reset(reset),.enable(enable),
85 .strobe1(1'b1),.strobe2(strobe2),.strobe3(strobe1),.shift1(shift2),.shift2(shift1),
86 .signal_in(i_cordic_out),.signal_out(i_out));
88 cic_decim_2stage #(.bw(bw),.N(4))
89 decim_q(.clock(clock),.reset(reset),.enable(enable),
90 .strobe1(1'b1),.strobe2(strobe2),.strobe3(strobe1),.shift1(shift2),.shift2(shift1),
91 .signal_in(q_cordic_out),.signal_out(q_out));
93 phase_acc #(.resolution(32))
94 nco (.clk(clock),.reset(reset),.enable(enable),
95 .freq(freq),.phase(phase));