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_strobe_o,tx_ctrl_o,rx_ctrl_o,
26 ampl_o,fstart_o,fincr_o);
29 input clk_i; // Master clock @ 64 MHz
30 input [6:0] saddr_i; // Configuration bus address
31 input [31:0] sdata_i; // Configuration bus data
32 input s_strobe_i; // Configuration bus write
34 // Control and configuration outputs
40 output [31:0] fstart_o;
41 output [31:0] fincr_o;
43 // Internal configuration
53 // Configuration from host
54 setting_reg #(`FR_RADAR_MODE) sr_mode(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
55 .out({chirps,md_ena,dr_ena,lp_ena,reset_o}));
57 setting_reg #(`FR_RADAR_TON) sr_ton(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
60 setting_reg #(`FR_RADAR_TSW) sr_tsw(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
63 setting_reg #(`FR_RADAR_TLOOK) sr_tlook(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
66 setting_reg #(`FR_RADAR_TIDLE) sr_tidle(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
69 setting_reg #(`FR_RADAR_AMPL) sr_ampl(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
72 setting_reg #(`FR_RADAR_FSTART) sr_fstart(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
75 setting_reg #(`FR_RADAR_FINCR) sr_fincr(.clock(clk_i),.reset(1'b0),.strobe(s_strobe_i),.addr(saddr_i),.in(sdata_i),
78 // Pulse state machine
81 `define ST_LOOK 4'b0100
82 `define ST_IDLE 4'b1000
87 always @(posedge clk_i)
96 if (count == {16'b0,t_on})
102 count <= count + 32'b1;
105 if (count == {16'b0,t_sw})
111 count <= count + 24'b1;
114 if (count == {16'b0,t_look})
120 count <= count + 32'b1;
129 count <= count + 32'b1;
131 default: // Invalid state, reset state machine
138 assign tx_strobe_o = count[0]; // Drive DAC inputs at 32 MHz
139 assign tx_ctrl_o = (state == `ST_ON);
140 assign rx_ctrl_o = (state == `ST_LOOK);
142 endmodule // radar_control