3 // USRP - Universal Software Radio Peripheral
5 // Copyright (C) 2007 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 "../lib/radar_config.vh"
24 module radar_control(clk_i,saddr_i,sdata_i,s_strobe_i,
25 reset_o,tx_side_o,dbg_o,
26 tx_strobe_o,tx_ctrl_o,rx_ctrl_o,
27 ampl_o,fstart_o,fincr_o);
30 input clk_i; // Master clock @ 64 MHz
31 input [6:0] saddr_i; // Configuration bus address
32 input [31:0] sdata_i; // Configuration bus data
33 input s_strobe_i; // Configuration bus write
35 // Control and configuration outputs
43 output [31:0] fstart_o;
44 output [31:0] fincr_o;
46 // Internal configuration
56 // Configuration from host
58 setting_reg #(`FR_RADAR_MODE) sr_mode(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
60 assign reset_o = mode[0];
61 assign tx_side_o = mode[1];
62 assign lp_ena = mode[2];
63 assign md_ena = mode[3];
64 assign dr_ena = mode[4];
65 assign chirps = mode[6:5];
66 assign dbg_o = mode[7];
68 setting_reg #(`FR_RADAR_TON) sr_ton(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
71 setting_reg #(`FR_RADAR_TSW) sr_tsw(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
74 setting_reg #(`FR_RADAR_TLOOK) sr_tlook(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
77 setting_reg #(`FR_RADAR_TIDLE) sr_tidle(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
80 setting_reg #(`FR_RADAR_AMPL) sr_ampl(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
83 setting_reg #(`FR_RADAR_FSTART) sr_fstart(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
86 setting_reg #(`FR_RADAR_FINCR) sr_fincr(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
89 // Pulse state machine
92 `define ST_LOOK 4'b0100
93 `define ST_IDLE 4'b1000
98 always @(posedge clk_i)
107 if (count == {16'b0,t_on})
113 count <= count + 32'b1;
116 if (count == {16'b0,t_sw})
122 count <= count + 32'b1;
125 if (count == {16'b0,t_look})
131 count <= count + 32'b1;
140 count <= count + 32'b1;
142 default: // Invalid state, reset state machine
149 assign tx_strobe_o = count[0]; // Drive DAC inputs at 32 MHz
150 assign tx_ctrl_o = (state == `ST_ON);
151 assign rx_ctrl_o = (state == `ST_LOOK);
153 endmodule // radar_control