finish coding and testing of online acq; add sample data

串行在线捕获程序已经完成编写,并进行了仿真和测试(对飞和814均可用);增加了在电子所使用转台测试的幅相采集数据
This commit is contained in:
2023-05-08 19:13:53 +08:00
parent e07389e326
commit 2d4650a3b6
2835 changed files with 408373 additions and 181193 deletions
@@ -0,0 +1,167 @@
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2023/05/06 15:37:29
// Design Name:
// Module Name: rf_auto_switch_freq
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module rf_auto_switch_freq(
input clk ,
input rst ,
// vio control
input start , // rise-edge active, if start, change freq word to the first
input rf_ctrl_mode , // 1 : auto switch, 0 : manual switch
input switch_next_freq , // rise-edge active
input switch_last_freq , // rise-edge active
input [15:0] cnt_valid_to_switch , // clock number from valid to switch
// input
input [10:0] freq_hop_words_vio ,
input hop_words_valid_vio ,
input freq_hop_switch_vio ,
// output
output reg [10:0] freq_hop_words_auto = 11'd0 ,
output reg hop_words_valid_auto = 1'd0 ,
output reg freq_hop_switch_auto = 1'd0
);
//************************* rise-edge detect ***********************************
reg start_d1 = 1'b0;
reg start_d2 = 1'b0;
reg start_pulse = 1'b0;
reg switch_next_freq_d1 = 1'b0;
reg switch_next_freq_d2 = 1'b0;
reg [9:0] switch_next_freq_pulse = 10'd0;
reg switch_last_freq_d1 = 1'b0;
reg switch_last_freq_d2 = 1'b0;
reg [9:0] switch_last_freq_pulse = 10'd0;
always @ (posedge clk)
if(rst) begin
start_d1 <= 1'b0;
start_d2 <= 1'b0;
start_pulse <= 1'b0;
switch_next_freq_d1 <= 1'b0;
switch_next_freq_d2 <= 1'b0;
switch_next_freq_pulse <= 10'd0;
switch_last_freq_d1 <= 1'b0;
switch_last_freq_d2 <= 1'b0;
switch_last_freq_pulse <= 10'd0;
end else begin
start_d1 <= start;
start_d2 <= start_d1;
start_pulse <= start_d1 & ~start_d2;
switch_next_freq_d1 <= switch_next_freq;
switch_next_freq_d2 <= switch_next_freq_d1;
switch_next_freq_pulse[0] <= switch_next_freq_d1 & ~switch_next_freq_d2;
switch_next_freq_pulse[9:1] <= switch_next_freq_pulse[8:0];
switch_last_freq_d1 <= switch_last_freq;
switch_last_freq_d2 <= switch_last_freq_d1;
switch_last_freq_pulse[0] <= switch_last_freq_d1 & ~switch_last_freq_d2;
switch_last_freq_pulse[9:1] <= switch_last_freq_pulse[8:0];
end
//******************** local freq word control *********************************
reg [10:0] local_freq_word = 11'd0;
reg local_freq_word_valid = 1'b0;
reg local_freq_word_switch = 1'b0;
reg [7:0] freq_word_cnt = 8'd0; // range 0 -> 80
wire [10:0] rom_freq_word_dout;
// 2 clock latency
rom_freq_word rom_freq_word_inst(
.clka (clk ),
.addra (freq_word_cnt[6:0] ),
.douta (rom_freq_word_dout )
);
always @ (posedge clk)
if(rst | start_pulse)
freq_word_cnt <= 8'd0;
else if(freq_word_cnt == 8'd80 && switch_next_freq_pulse[0])
freq_word_cnt <= 8'd0;
else if(freq_word_cnt == 8'd0 && switch_last_freq_pulse[0])
freq_word_cnt <= 8'd80;
else if(switch_next_freq_pulse[0])
freq_word_cnt <= freq_word_cnt + 1'b1;
else if(switch_last_freq_pulse[0])
freq_word_cnt <= freq_word_cnt - 1'b1;
else
freq_word_cnt <= freq_word_cnt;
always @ (posedge clk)
if(rst | start_pulse)
local_freq_word_valid <= 1'b0;
else if(switch_next_freq_pulse[4] | switch_last_freq_pulse[4])
local_freq_word_valid <= 1'b1;
else
local_freq_word_valid <= 1'b0;
reg [15:0] freq_word_valid_cnt = 16'd0;
always @ (posedge clk)
if(rst | start_pulse)
freq_word_valid_cnt <= 16'd0;
else if(freq_word_valid_cnt == cnt_valid_to_switch)
freq_word_valid_cnt <= 16'd0;
else if(local_freq_word_valid)
freq_word_valid_cnt <= freq_word_valid_cnt + 1'b1;
else if(freq_word_valid_cnt != 16'd0)
freq_word_valid_cnt <= freq_word_valid_cnt + 1'b1;
else
freq_word_valid_cnt <= freq_word_valid_cnt;
always @ (posedge clk)
if(rst | start_pulse)
local_freq_word_switch <= 1'b0;
else if(freq_word_valid_cnt == cnt_valid_to_switch)
local_freq_word_switch <= 1'b1;
else
local_freq_word_switch <= 1'b0;
always @ (posedge clk)
if(rst | start_pulse)
local_freq_word <= 11'd0;
else
local_freq_word <= rom_freq_word_dout;
//******************** output freq switch signal *******************************
// freq_hop_words_auto
always @ (posedge clk)
if(rst | start_pulse)
freq_hop_words_auto <= 11'd0;
else if(rf_ctrl_mode)
freq_hop_words_auto <= local_freq_word;
else
freq_hop_words_auto <= freq_hop_words_vio;
// hop_words_valid_auto
always @ (posedge clk)
if(rst | start_pulse)
hop_words_valid_auto <= 1'b0;
else if(rf_ctrl_mode)
hop_words_valid_auto <= local_freq_word_valid;
else
hop_words_valid_auto <= hop_words_valid_vio;
// freq_hop_switch_auto
always @ (posedge clk)
if(rst | start_pulse)
freq_hop_switch_auto <= 1'b0;
else if(rf_ctrl_mode)
freq_hop_switch_auto <= local_freq_word_switch;
else
freq_hop_switch_auto <= freq_hop_switch_vio;
endmodule
+53 -14
View File
@@ -264,6 +264,7 @@ wire [5:0] rx_gain_manual ;
wire [10:0] freq_hop_words_vio ;
wire hop_words_valid_vio ;
wire freq_hop_switch_vio ;
wire freq_hop_switch_out ;
wire [11:0] tx_gain;
@@ -276,7 +277,38 @@ assign rx_gain_5bit = rx_gain[5];
assign rx_gain_4bit = rx_gain[4];
assign rx_gain_3bit = rx_gain[3];
rf_control u_rf_control(
// rf auto switch frequency function
wire rf_auto_start_vio ;
wire rf_ctrl_mode_vio ;
wire switch_next_freq_vio;
wire switch_last_freq_vio;
wire [15:0] cnt_valid_to_switch_vio;
wire [10:0] freq_hop_words_auto ;
wire hop_words_valid_auto;
wire freq_hop_switch_auto;
rf_auto_switch_freq u_rf_auto_switch_freq(
.clk (sys_clk ),
.rst (sys_rst ),
// vio control
.start (rf_auto_start_vio ), // rise-edge active, if start, change freq word to the first
.rf_ctrl_mode (rf_ctrl_mode_vio ), // 1 : auto switch, 0 : manual switch
.switch_next_freq (switch_next_freq_vio ), // rise-edge active
.switch_last_freq (switch_last_freq_vio ), // rise-edge active
.cnt_valid_to_switch (cnt_valid_to_switch_vio ),
// input
.freq_hop_words_vio (freq_hop_words_vio[10:0] ),
.hop_words_valid_vio (hop_words_valid_vio ),
.freq_hop_switch_vio (freq_hop_switch_vio ),
// output
.freq_hop_words_auto (freq_hop_words_auto[10:0] ),
.hop_words_valid_auto (hop_words_valid_auto ),
.freq_hop_switch_auto (freq_hop_switch_auto )
);
rf_control u_rf_control
(
.clk (sys_clk ),
.rst (sys_rst ),
@@ -292,9 +324,9 @@ rf_control u_rf_control(
.rf_vio_set (rf_vio_set ),
//vio hop control
.freq_hop_words_vio (freq_hop_words_vio[10:0] ),
.hop_words_valid_vio (hop_words_valid_vio ),
.freq_hop_switch_vio (freq_hop_switch_vio ),
.freq_hop_words_vio (freq_hop_words_auto[10:0] ),
.hop_words_valid_vio (hop_words_valid_auto ),
.freq_hop_switch_vio (freq_hop_switch_auto ),
//tx hop control
.tx_freq_hop_words (11'b0 ),
@@ -318,6 +350,7 @@ rf_control u_rf_control(
.freq_hop_switch_out (freq_hop_switch_out )
);
////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Tx Baseband Signals //////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -429,16 +462,22 @@ vio_manual_ctrl u_vio_manual_ctrl
vio_rf_control u_vio_rf_control
(
.clk (sys_clk ), // input wire clk
.probe_out0 (gain_on_vio ), // output wire [0 : 0] probe_out0
.probe_out1 (rf_txrx_vio[1:0] ), // output wire [1 : 0] probe_out1
.probe_out2 (rf_vio_set ), // output wire [0 : 0] probe_out2
.probe_out3 (tx_gain_manual[5:0] ), // output wire [5 : 0] probe_out3
.probe_out4 (rx_gain_manual[5:0] ), // output wire [5 : 0] probe_out4
.probe_out5 (freq_hop_words_vio[10:0] ), // output wire [10 : 0] probe_out5
.probe_out6 (hop_words_valid_vio ), // output wire [0 : 0] probe_out6
.probe_out7 (freq_hop_switch_vio ), // output wire [0 : 0] probe_out7
.probe_out8 (self_check_dout ) // output wire [0 : 0] probe_out8
.clk (sys_clk ), // input wire clk
.probe_out0 (gain_on_vio ), // output wire [0 : 0] probe_out0
.probe_out1 (rf_txrx_vio[1:0] ), // output wire [1 : 0] probe_out1
.probe_out2 (rf_vio_set ), // output wire [0 : 0] probe_out2
.probe_out3 (tx_gain_manual[5:0] ), // output wire [5 : 0] probe_out3
.probe_out4 (rx_gain_manual[5:0] ), // output wire [5 : 0] probe_out4
.probe_out5 (freq_hop_words_vio[10:0] ), // output wire [10 : 0] probe_out5
.probe_out6 (hop_words_valid_vio ), // output wire [0 : 0] probe_out6
.probe_out7 (freq_hop_switch_vio ), // output wire [0 : 0] probe_out7
.probe_out8 (self_check_dout ), // output wire [0 : 0] probe_out8
.probe_out9 (rf_auto_start_vio ), // output wire [0 : 0] probe_out9
.probe_out10 (rf_ctrl_mode_vio ), // output wire [0 : 0] probe_out10
.probe_out11 (switch_next_freq_vio ), // output wire [0 : 0] probe_out11
.probe_out12 (switch_last_freq_vio ), // output wire [0 : 0] probe_out12
.probe_out13 (cnt_valid_to_switch_vio[15:0] ), // output wire [15: 0] probe_out13
.probe_in0 (freq_hop_words_auto[10:0] ) // input wire [10: 0] probe_in0
);
endmodule