2022-05-13 11:24:41 +00:00
|
|
|
`include "openofdm_rx_pre_def.v"
|
|
|
|
|
2017-04-03 16:52:03 +00:00
|
|
|
`timescale 1ns/1ps
|
|
|
|
|
|
|
|
module dot11_tb;
|
|
|
|
`include "common_params.v"
|
|
|
|
|
|
|
|
reg clock;
|
|
|
|
reg reset;
|
|
|
|
reg enable;
|
|
|
|
|
2019-12-10 12:31:16 +00:00
|
|
|
reg [10:0] rssi_half_db;
|
2017-04-03 16:52:03 +00:00
|
|
|
reg[31:0] sample_in;
|
|
|
|
reg sample_in_strobe;
|
|
|
|
reg [15:0] clk_count;
|
|
|
|
|
|
|
|
reg signal_done;
|
|
|
|
|
2022-03-15 15:03:40 +00:00
|
|
|
wire pkt_header_valid;
|
2019-12-10 12:31:16 +00:00
|
|
|
wire pkt_header_valid_strobe;
|
|
|
|
wire [15:0] pkt_len;
|
2017-04-03 16:52:03 +00:00
|
|
|
|
|
|
|
reg set_stb;
|
|
|
|
reg [7:0] set_addr;
|
|
|
|
reg [31:0] set_data;
|
|
|
|
|
2022-03-15 15:03:40 +00:00
|
|
|
wire demod_is_ongoing;
|
|
|
|
wire receiver_rst;
|
|
|
|
|
|
|
|
wire sig_valid = (pkt_header_valid_strobe&pkt_header_valid);
|
2019-12-10 13:09:31 +00:00
|
|
|
|
2022-05-16 07:53:07 +00:00
|
|
|
integer run_out_of_iq_sample;
|
2022-07-15 10:10:03 +00:00
|
|
|
integer iq_count, iq_count_tmp, end_dl_count;
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
// file descriptors
|
|
|
|
integer sample_file_name_fd;
|
|
|
|
|
2023-01-05 15:38:51 +00:00
|
|
|
integer bb_sample_fd;
|
|
|
|
integer power_trigger_fd;
|
2017-04-03 16:52:03 +00:00
|
|
|
integer short_preamble_detected_fd;
|
|
|
|
|
|
|
|
integer long_preamble_detected_fd;
|
|
|
|
integer sync_long_out_fd;
|
|
|
|
|
|
|
|
integer demod_out_fd;
|
2022-01-04 21:18:23 +00:00
|
|
|
integer demod_soft_bits_fd;
|
|
|
|
integer demod_soft_bits_pos_fd;
|
2019-12-10 12:31:16 +00:00
|
|
|
integer deinterleave_erase_out_fd;
|
2017-04-03 16:52:03 +00:00
|
|
|
integer conv_out_fd;
|
|
|
|
integer descramble_out_fd;
|
|
|
|
|
|
|
|
integer signal_fd;
|
2023-01-05 15:38:51 +00:00
|
|
|
integer ht_sig_fd;
|
2017-04-03 16:52:03 +00:00
|
|
|
|
|
|
|
integer byte_out_fd;
|
2022-07-15 10:10:03 +00:00
|
|
|
integer fcs_out_fd;
|
2023-01-05 15:38:51 +00:00
|
|
|
integer status_code_fd;
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
// sync_short
|
|
|
|
integer mag_sq_fd;
|
|
|
|
integer mag_sq_avg_fd;
|
|
|
|
integer prod_fd;
|
|
|
|
integer prod_avg_fd;
|
|
|
|
integer phase_in_fd;
|
|
|
|
integer phase_out_fd;
|
|
|
|
integer delay_prod_avg_mag_fd;
|
|
|
|
|
|
|
|
// sync_long
|
|
|
|
integer sum_fd;
|
|
|
|
integer metric_fd;
|
|
|
|
integer phase_correction_fd;
|
|
|
|
integer next_phase_correction_fd;
|
|
|
|
integer fft_in_fd;
|
|
|
|
|
|
|
|
// equalizer
|
|
|
|
integer new_lts_fd;
|
|
|
|
integer phase_offset_pilot_input_fd;
|
|
|
|
integer phase_offset_lts_input_fd;
|
|
|
|
integer phase_offset_pilot_fd;
|
|
|
|
integer phase_offset_pilot_sum_fd;
|
|
|
|
integer phase_offset_phase_out_fd;
|
|
|
|
integer rot_in_fd;
|
|
|
|
integer rot_out_fd;
|
|
|
|
integer equalizer_prod_fd;
|
|
|
|
integer equalizer_prod_scaled_fd;
|
|
|
|
integer equalizer_mag_sq_fd;
|
|
|
|
integer equalizer_out_fd;
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
integer file_i, file_q, file_rssi_half_db, iq_sample_file;
|
|
|
|
|
2017-04-03 16:52:03 +00:00
|
|
|
initial begin
|
2022-07-15 10:10:03 +00:00
|
|
|
// $dumpfile("dot11.vcd");
|
|
|
|
// $dumpvars;
|
2022-05-16 07:33:19 +00:00
|
|
|
sample_file_name_fd = $fopen("./sample_file_name.txt", "w");
|
|
|
|
$fwrite(sample_file_name_fd, "%s", `SAMPLE_FILE);
|
|
|
|
$fflush(sample_file_name_fd);
|
|
|
|
$fclose(sample_file_name_fd);
|
2022-05-16 07:53:07 +00:00
|
|
|
|
|
|
|
run_out_of_iq_sample = 0;
|
2022-07-15 10:10:03 +00:00
|
|
|
end_dl_count = 0;
|
2017-04-03 16:52:03 +00:00
|
|
|
|
|
|
|
clock = 0;
|
|
|
|
reset = 1;
|
|
|
|
enable = 0;
|
|
|
|
signal_done <= 0;
|
|
|
|
|
|
|
|
# 20 reset = 0;
|
|
|
|
enable = 1;
|
|
|
|
|
|
|
|
set_stb = 1;
|
|
|
|
|
|
|
|
# 20
|
|
|
|
// do not skip sample
|
|
|
|
set_addr = SR_SKIP_SAMPLE;
|
|
|
|
set_data = 0;
|
|
|
|
|
|
|
|
# 20 set_stb = 0;
|
2020-09-02 19:59:37 +00:00
|
|
|
end
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2020-09-02 19:59:37 +00:00
|
|
|
integer file_open_trigger = 0;
|
|
|
|
always @(posedge clock) begin
|
|
|
|
file_open_trigger = file_open_trigger + 1;
|
|
|
|
if (file_open_trigger==1) begin
|
|
|
|
iq_sample_file = $fopen(`SAMPLE_FILE, "r");
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2023-01-05 15:38:51 +00:00
|
|
|
bb_sample_fd = $fopen("./sample_in.txt", "w");
|
|
|
|
power_trigger_fd = $fopen("./power_trigger.txt", "w");
|
2020-09-02 19:59:37 +00:00
|
|
|
short_preamble_detected_fd = $fopen("./short_preamble_detected.txt", "w");
|
|
|
|
long_preamble_detected_fd = $fopen("./sync_long_frame_detected.txt", "w");
|
2023-01-05 15:38:51 +00:00
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
// sync_short
|
|
|
|
mag_sq_fd = $fopen("./mag_sq.txt", "w");
|
|
|
|
mag_sq_avg_fd = $fopen("./mag_sq_avg.txt", "w");
|
|
|
|
prod_fd = $fopen("./prod.txt", "w");
|
|
|
|
prod_avg_fd = $fopen("./prod_avg.txt", "w");
|
|
|
|
phase_in_fd = $fopen("./phase_in.txt", "w");
|
|
|
|
phase_out_fd = $fopen("./phase_out.txt", "w");
|
|
|
|
delay_prod_avg_mag_fd = $fopen("./delay_prod_avg_mag.txt", "w");
|
|
|
|
|
|
|
|
// sync_long
|
|
|
|
sum_fd = $fopen("./sum.txt", "w");
|
|
|
|
metric_fd = $fopen("./metric.txt", "w");
|
|
|
|
phase_correction_fd = $fopen("./phase_correction.txt", "w");
|
|
|
|
next_phase_correction_fd = $fopen("./next_phase_correction.txt", "w");
|
2023-01-05 15:38:51 +00:00
|
|
|
fft_in_fd = $fopen("./fft_in.txt", "w");
|
|
|
|
sync_long_out_fd = $fopen("./sync_long_out.txt", "w");
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
// equalizer
|
|
|
|
new_lts_fd = $fopen("./new_lts.txt", "w");
|
|
|
|
phase_offset_pilot_input_fd = $fopen("./phase_offset_pilot_input.txt", "w");
|
|
|
|
phase_offset_lts_input_fd = $fopen("./phase_offset_lts_input.txt", "w");
|
|
|
|
phase_offset_pilot_fd = $fopen("./phase_offset_pilot.txt", "w");
|
|
|
|
phase_offset_pilot_sum_fd = $fopen("./phase_offset_pilot_sum.txt", "w");
|
|
|
|
phase_offset_phase_out_fd = $fopen("./phase_offset_phase_out.txt", "w");
|
|
|
|
rot_in_fd = $fopen("./rot_in.txt", "w");
|
|
|
|
rot_out_fd = $fopen("./rot_out.txt", "w");
|
|
|
|
equalizer_prod_fd = $fopen("./equalizer_prod.txt", "w");
|
|
|
|
equalizer_prod_scaled_fd = $fopen("./equalizer_prod_scaled.txt", "w");
|
|
|
|
equalizer_mag_sq_fd = $fopen("./equalizer_mag_sq.txt", "w");
|
2023-01-05 15:38:51 +00:00
|
|
|
equalizer_out_fd = $fopen("./equalizer_out.txt", "w");
|
|
|
|
|
|
|
|
// ofdm decoder
|
|
|
|
demod_out_fd = $fopen("./demod_out.txt", "w");
|
|
|
|
demod_soft_bits_fd = $fopen("./demod_soft_bits.txt", "w");
|
|
|
|
demod_soft_bits_pos_fd = $fopen("./demod_soft_bits_pos.txt", "w");
|
|
|
|
deinterleave_erase_out_fd = $fopen("./deinterleave_erase_out.txt", "w");
|
|
|
|
conv_out_fd = $fopen("./conv_out.txt", "w");
|
|
|
|
descramble_out_fd = $fopen("./descramble_out.txt", "w");
|
2022-05-16 07:33:19 +00:00
|
|
|
|
2023-01-05 15:38:51 +00:00
|
|
|
signal_fd = $fopen("./signal_out.txt", "w");
|
|
|
|
ht_sig_fd = $fopen("./ht_sig_out.txt", "w");
|
|
|
|
byte_out_fd = $fopen("./byte_out.txt", "w");
|
2022-07-15 10:10:03 +00:00
|
|
|
fcs_out_fd = $fopen("./fcs_out.txt", "w");
|
2023-01-05 15:38:51 +00:00
|
|
|
status_code_fd = $fopen("./status_code.txt","w");
|
2022-07-15 10:10:03 +00:00
|
|
|
|
2020-09-02 19:59:37 +00:00
|
|
|
end
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
|
|
|
|
2022-01-28 11:17:16 +00:00
|
|
|
always begin
|
|
|
|
`ifdef CLK_SPEED_100M
|
2020-10-08 08:06:03 +00:00
|
|
|
#5 clock = !clock;
|
2022-01-28 11:17:16 +00:00
|
|
|
`elsif CLK_SPEED_200M
|
2020-10-08 08:06:03 +00:00
|
|
|
#2.5 clock = !clock;
|
2022-01-28 11:17:16 +00:00
|
|
|
`elsif CLK_SPEED_240M
|
|
|
|
#2.0833333333 clock = !clock;
|
|
|
|
`elsif CLK_SPEED_400M
|
|
|
|
#1.25 clock = !clock;
|
2020-10-08 08:06:03 +00:00
|
|
|
`endif
|
2022-01-28 11:17:16 +00:00
|
|
|
end
|
2017-04-03 16:52:03 +00:00
|
|
|
|
|
|
|
always @(posedge clock) begin
|
|
|
|
if (reset) begin
|
|
|
|
sample_in <= 0;
|
|
|
|
clk_count <= 0;
|
|
|
|
sample_in_strobe <= 0;
|
2022-05-16 07:53:07 +00:00
|
|
|
iq_count <= 0;
|
2017-04-03 16:52:03 +00:00
|
|
|
end else if (enable) begin
|
2022-01-28 11:17:16 +00:00
|
|
|
`ifdef CLK_SPEED_100M
|
2020-10-08 08:06:03 +00:00
|
|
|
if (clk_count == 4) begin // for 100M; 100/20 = 5
|
2022-01-28 11:17:16 +00:00
|
|
|
`elsif CLK_SPEED_200M
|
2020-10-08 08:06:03 +00:00
|
|
|
if (clk_count == 9) begin // for 200M; 200/20 = 10
|
2022-01-28 11:17:16 +00:00
|
|
|
`elsif CLK_SPEED_240M
|
|
|
|
if (clk_count == 11) begin // for 200M; 240/20 = 12
|
|
|
|
`elsif CLK_SPEED_400M
|
|
|
|
if (clk_count == 19) begin // for 200M; 400/20 = 20
|
2020-10-08 08:06:03 +00:00
|
|
|
`endif
|
2017-04-03 16:52:03 +00:00
|
|
|
sample_in_strobe <= 1;
|
2020-04-27 13:46:16 +00:00
|
|
|
//$fscanf(iq_sample_file, "%d %d %d", file_i, file_q, file_rssi_half_db);
|
2022-05-16 07:53:07 +00:00
|
|
|
iq_count_tmp = $fscanf(iq_sample_file, "%d %d", file_i, file_q);
|
|
|
|
if (iq_count_tmp != 2)
|
|
|
|
run_out_of_iq_sample = 1;
|
|
|
|
|
2019-12-10 12:31:16 +00:00
|
|
|
sample_in[15:0] <= file_q;
|
|
|
|
sample_in[31:16]<= file_i;
|
2020-04-27 13:46:16 +00:00
|
|
|
//rssi_half_db <= file_rssi_half_db;
|
|
|
|
rssi_half_db <= 0;
|
2022-05-16 07:53:07 +00:00
|
|
|
iq_count <= iq_count + 1;
|
2017-04-03 16:52:03 +00:00
|
|
|
clk_count <= 0;
|
|
|
|
end else begin
|
|
|
|
sample_in_strobe <= 0;
|
|
|
|
clk_count <= clk_count + 1;
|
|
|
|
end
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
if (dot11_inst.legacy_sig_stb) begin
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
|
|
|
|
2019-12-10 12:31:16 +00:00
|
|
|
//if (sample_in_strobe && power_trigger) begin
|
|
|
|
if (sample_in_strobe) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(bb_sample_fd, "%d %d %d\n", iq_count, $signed(sample_in[31:16]), $signed(sample_in[15:0]));
|
|
|
|
$fwrite(power_trigger_fd, "%d %d\n", iq_count, dot11_inst.power_trigger);
|
|
|
|
$fflush(bb_sample_fd);
|
|
|
|
$fflush(power_trigger_fd);
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2022-05-16 07:53:07 +00:00
|
|
|
if ((iq_count % 100) == 0) begin
|
|
|
|
$display("%d", iq_count);
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
|
|
|
|
2022-05-16 07:53:07 +00:00
|
|
|
if (run_out_of_iq_sample) begin
|
2022-07-15 10:10:03 +00:00
|
|
|
end_dl_count = end_dl_count+1;
|
|
|
|
end
|
|
|
|
|
|
|
|
if(end_dl_count == 300 ) begin
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(iq_sample_file);
|
|
|
|
|
2023-01-05 15:38:51 +00:00
|
|
|
$fclose(bb_sample_fd);
|
|
|
|
$fclose(power_trigger_fd);
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(short_preamble_detected_fd);
|
|
|
|
$fclose(long_preamble_detected_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
|
|
|
|
// close short preamble detection output files
|
|
|
|
$fclose(mag_sq_fd);
|
|
|
|
$fclose(mag_sq_avg_fd);
|
|
|
|
$fclose(prod_fd);
|
|
|
|
$fclose(prod_avg_fd);
|
|
|
|
$fclose(phase_in_fd);
|
|
|
|
$fclose(phase_out_fd);
|
|
|
|
$fclose(delay_prod_avg_mag_fd);
|
|
|
|
// close long preamble detection output files
|
|
|
|
$fclose(sum_fd);
|
|
|
|
$fclose(metric_fd);
|
|
|
|
$fclose(phase_correction_fd);
|
|
|
|
$fclose(next_phase_correction_fd);
|
|
|
|
$fclose(fft_in_fd);
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(sync_long_out_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
// close equalizer output files
|
|
|
|
$fclose(new_lts_fd);
|
|
|
|
$fclose(phase_offset_pilot_input_fd);
|
|
|
|
$fclose(phase_offset_lts_input_fd);
|
|
|
|
$fclose(phase_offset_pilot_fd);
|
|
|
|
$fclose(phase_offset_pilot_sum_fd);
|
|
|
|
$fclose(phase_offset_phase_out_fd);
|
|
|
|
$fclose(rot_in_fd);
|
|
|
|
$fclose(rot_out_fd);
|
|
|
|
$fclose(equalizer_prod_fd);
|
|
|
|
$fclose(equalizer_prod_scaled_fd);
|
|
|
|
$fclose(equalizer_mag_sq_fd);
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(equalizer_out_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
// close ofdm decode files
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(demod_out_fd);
|
2022-01-04 21:18:23 +00:00
|
|
|
$fclose(demod_soft_bits_fd);
|
|
|
|
$fclose(demod_soft_bits_pos_fd);
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(deinterleave_erase_out_fd);
|
|
|
|
$fclose(conv_out_fd);
|
|
|
|
$fclose(descramble_out_fd);
|
|
|
|
|
|
|
|
$fclose(signal_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fclose(ht_sig_fd);
|
2019-12-10 12:31:16 +00:00
|
|
|
$fclose(byte_out_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fclose(fcs_out_fd);
|
|
|
|
$fclose(status_code_fd);
|
2017-04-03 16:52:03 +00:00
|
|
|
$finish;
|
|
|
|
end
|
|
|
|
end
|
2023-01-05 15:38:51 +00:00
|
|
|
if(dot11_inst.short_preamble_detected) begin
|
|
|
|
$fwrite(short_preamble_detected_fd, "%d %d\n", iq_count, dot11_inst.sync_short_inst.phase_offset);
|
|
|
|
$fflush(short_preamble_detected_fd);
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
2023-01-05 15:38:51 +00:00
|
|
|
if(dot11_inst.long_preamble_detected) begin
|
|
|
|
$fwrite(long_preamble_detected_fd, "%d %d\n", iq_count, dot11_inst.sync_long_inst.addr1);
|
|
|
|
$fflush(long_preamble_detected_fd);
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
2022-07-15 10:10:03 +00:00
|
|
|
if(dot11_inst.fcs_out_strobe) begin
|
|
|
|
$fwrite(fcs_out_fd, "%d %d\n", iq_count, dot11_inst.fcs_ok);
|
|
|
|
$fflush(fcs_out_fd);
|
|
|
|
end
|
2023-01-05 15:38:51 +00:00
|
|
|
if(dot11_inst.state == S_HT_SIG_ERROR || dot11_inst.state == S_SIGNAL_ERROR) begin
|
2023-01-05 15:45:43 +00:00
|
|
|
$fwrite(status_code_fd, "%d %d %d\n", iq_count, dot11_inst.status_code, dot11_inst.state);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fflush(status_code_fd);
|
|
|
|
end
|
2023-01-05 15:45:43 +00:00
|
|
|
if (dot11_inst.legacy_sig_stb || dot11_inst.pkt_header_valid_strobe) begin
|
2017-04-03 16:52:03 +00:00
|
|
|
signal_done <= 1;
|
2023-01-05 15:45:43 +00:00
|
|
|
//$fwrite(signal_fd, "%d %04b %b %012b %b %06b\n", iq_count, dot11_inst.legacy_rate, dot11_inst.legacy_sig_rsvd, dot11_inst.legacy_len, dot11_inst.legacy_sig_parity, dot11_inst.legacy_sig_tail);
|
|
|
|
$fwrite(signal_fd, "%d %d\n", iq_count, dot11_inst.signal_bits);
|
2017-04-03 16:52:03 +00:00
|
|
|
$fflush(signal_fd);
|
|
|
|
end
|
2023-01-05 15:38:51 +00:00
|
|
|
|
|
|
|
if (dot11_inst.ht_sig_stb) begin
|
2023-01-05 15:45:43 +00:00
|
|
|
//$fwrite(ht_sig_fd, "%d %d %d %d %d %d %d %d\n", iq_count, dot11_inst.ht_mcs, dot11.ht_cbw, dot11_inst.ht_len, dot11_inst.ht_rsvd, dot11_inst.ht_aggr, dot11_inst.ht_sgi, dot11_inst.ht_sig_crc_ok);
|
|
|
|
$fwrite(ht_sig_fd, "%d %d %d\n", iq_count, dot11_inst.ht_sig1, dot11_inst.ht_sig2);
|
|
|
|
$fflush(ht_sig_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
end
|
2017-04-03 16:52:03 +00:00
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
if ((dot11_inst.state == S_MPDU_DELIM || dot11_inst.state == S_DECODE_DATA || dot11_inst.state == S_MPDU_PAD) && dot11_inst.ofdm_decoder_inst.demod_out_strobe) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(demod_out_fd, "%d %b %b %b %b %b %b\n",iq_count, dot11_inst.ofdm_decoder_inst.demod_out[0],dot11_inst.ofdm_decoder_inst.demod_out[1],dot11_inst.ofdm_decoder_inst.demod_out[2],dot11_inst.ofdm_decoder_inst.demod_out[3],dot11_inst.ofdm_decoder_inst.demod_out[4],dot11_inst.ofdm_decoder_inst.demod_out[5]);
|
|
|
|
$fwrite(demod_soft_bits_fd, "%d %b %b %b %b %b %b\n",iq_count, dot11_inst.ofdm_decoder_inst.demod_soft_bits[0],dot11_inst.ofdm_decoder_inst.demod_soft_bits[1],dot11_inst.ofdm_decoder_inst.demod_soft_bits[2],dot11_inst.ofdm_decoder_inst.demod_soft_bits[3],dot11_inst.ofdm_decoder_inst.demod_soft_bits[4],dot11_inst.ofdm_decoder_inst.demod_soft_bits[5]);
|
|
|
|
$fwrite(demod_soft_bits_pos_fd, "%d %b %b %b %b\n",iq_count, dot11_inst.ofdm_decoder_inst.demod_soft_bits_pos[0],dot11_inst.ofdm_decoder_inst.demod_soft_bits_pos[1],dot11_inst.ofdm_decoder_inst.demod_soft_bits_pos[2],dot11_inst.ofdm_decoder_inst.demod_soft_bits_pos[3]);
|
2017-04-03 16:52:03 +00:00
|
|
|
$fflush(demod_out_fd);
|
2022-01-04 21:18:23 +00:00
|
|
|
$fflush(demod_soft_bits_fd);
|
|
|
|
$fflush(demod_soft_bits_pos_fd);
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
if ((dot11_inst.state == S_MPDU_DELIM || dot11_inst.state == S_DECODE_DATA || dot11_inst.state == S_MPDU_PAD) && dot11_inst.deinterleave_erase_out_strobe) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(deinterleave_erase_out_fd, "%d %b %b %b %b %b %b %b %b\n", iq_count, dot11_inst.deinterleave_erase_out[0], dot11_inst.deinterleave_erase_out[1], dot11_inst.deinterleave_erase_out[2], dot11_inst.deinterleave_erase_out[3], dot11_inst.deinterleave_erase_out[4], dot11_inst.deinterleave_erase_out[5], dot11_inst.deinterleave_erase_out[6], dot11_inst.deinterleave_erase_out[7]);
|
2019-12-10 12:31:16 +00:00
|
|
|
$fflush(deinterleave_erase_out_fd);
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
if ((dot11_inst.state == S_MPDU_DELIM || dot11_inst.state == S_DECODE_DATA || dot11_inst.state == S_MPDU_PAD) && dot11_inst.conv_decoder_out_stb) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(conv_out_fd, "%d %b\n", iq_count, dot11_inst.conv_decoder_out);
|
2017-04-03 16:52:03 +00:00
|
|
|
$fflush(conv_out_fd);
|
|
|
|
end
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
if ((dot11_inst.state == S_MPDU_DELIM || dot11_inst.state == S_DECODE_DATA || dot11_inst.state == S_MPDU_PAD) && dot11_inst.descramble_out_strobe) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(descramble_out_fd, "%d %b\n", iq_count, dot11_inst.descramble_out);
|
2017-04-03 16:52:03 +00:00
|
|
|
$fflush(descramble_out_fd);
|
|
|
|
end
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
if ((dot11_inst.state == S_MPDU_DELIM || dot11_inst.state == S_DECODE_DATA || dot11_inst.state == S_MPDU_PAD) && dot11_inst.byte_out_strobe) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(byte_out_fd, "%d %02x\n", iq_count, dot11_inst.byte_out);
|
2017-04-03 16:52:03 +00:00
|
|
|
$fflush(byte_out_fd);
|
|
|
|
end
|
|
|
|
|
2022-05-16 07:33:19 +00:00
|
|
|
// sync_short
|
|
|
|
if (dot11_inst.sync_short_inst.mag_sq_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(mag_sq_fd, "%d %d\n", iq_count, dot11_inst.sync_short_inst.mag_sq);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(mag_sq_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_short_inst.mag_sq_avg_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(mag_sq_avg_fd, "%d %d\n", iq_count, dot11_inst.sync_short_inst.mag_sq_avg);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(mag_sq_avg_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_short_inst.prod_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(prod_fd, "%d %d %d\n", iq_count, $signed(dot11_inst.sync_short_inst.prod[63:32]), $signed(dot11_inst.sync_short_inst.prod[31:0]));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(prod_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_short_inst.prod_avg_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(prod_avg_fd, "%d %d %d\n", iq_count, $signed(dot11_inst.sync_short_inst.prod_avg[63:32]), $signed(dot11_inst.sync_short_inst.prod_avg[31:0]));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(prod_avg_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_short_inst.phase_in_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_in_fd, "%d %d %d\n", iq_count, $signed(dot11_inst.sync_short_inst.phase_in_i), $signed(dot11_inst.sync_short_inst.phase_in_q));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_in_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_short_inst.phase_out_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_out_fd, "%d %d\n", iq_count, $signed(dot11_inst.sync_short_inst.phase_out));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_out_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_short_inst.delay_prod_avg_mag_stb && dot11_inst.sync_short_inst.enable && ~dot11_inst.sync_short_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(delay_prod_avg_mag_fd, "%d %d\n", iq_count, dot11_inst.sync_short_inst.delay_prod_avg_mag);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(delay_prod_avg_mag_fd);
|
|
|
|
end
|
|
|
|
|
|
|
|
// sync_long
|
|
|
|
if (dot11_inst.sync_long_inst.sum_stb && dot11_inst.sync_long_inst.enable && ~dot11_inst.sync_long_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(sum_fd, "%d %d %d\n", iq_count, dot11_inst.sync_long_inst.sum_i, dot11_inst.sync_long_inst.sum_q);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(sum_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_long_inst.metric_stb && dot11_inst.sync_long_inst.enable && ~dot11_inst.sync_long_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(metric_fd, "%d %d\n", iq_count, dot11_inst.sync_long_inst.metric);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(metric_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_long_inst.raw_stb && dot11_inst.sync_long_inst.enable && ~dot11_inst.sync_long_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_correction_fd, "%d %d\n", iq_count, dot11_inst.sync_long_inst.phase_correction);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_correction_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(next_phase_correction_fd, "%d %d\n", iq_count, dot11_inst.sync_long_inst.next_phase_correction);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(next_phase_correction_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.sync_long_inst.fft_in_stb && dot11_inst.sync_long_inst.enable && ~dot11_inst.sync_long_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(fft_in_fd, "%d %d %d\n", iq_count, dot11_inst.sync_long_inst.fft_in_re, dot11_inst.sync_long_inst.fft_in_im);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(fft_in_fd);
|
|
|
|
end
|
2023-01-05 15:38:51 +00:00
|
|
|
if (dot11_inst.sync_long_inst.sample_out_strobe) begin
|
|
|
|
$fwrite(sync_long_out_fd, "%d %d %d\n",iq_count, $signed(dot11_inst.sync_long_inst.sample_out[31:16]), $signed(dot11_inst.sync_long_inst.sample_out[15:0]));
|
|
|
|
$fflush(sync_long_out_fd);
|
2022-05-16 07:33:19 +00:00
|
|
|
end
|
|
|
|
// equalizer
|
|
|
|
if ((dot11_inst.equalizer_inst.num_ofdm_sym == 1 || (dot11_inst.equalizer_inst.pkt_ht==1 && dot11_inst.equalizer_inst.num_ofdm_sym==5)) && dot11_inst.equalizer_inst.state == dot11_inst.equalizer_inst.S_CALC_FREQ_OFFSET && dot11_inst.equalizer_inst.sample_in_strobe_dly == 1 && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(new_lts_fd, "%d %d %d\n", iq_count, dot11_inst.equalizer_inst.lts_i_out, dot11_inst.equalizer_inst.lts_q_out);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(new_lts_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.pilot_in_stb && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_offset_pilot_input_fd, "%d %d %d\n", iq_count, dot11_inst.equalizer_inst.input_i, dot11_inst.equalizer_inst.input_q);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_offset_pilot_input_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_offset_lts_input_fd, "%d %d %d\n", iq_count, dot11_inst.equalizer_inst.lts_i_out, dot11_inst.equalizer_inst.lts_q_out);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_offset_lts_input_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.pilot_out_stb && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_offset_pilot_fd, "%d %d %d\n", iq_count, dot11_inst.equalizer_inst.pilot_i, dot11_inst.equalizer_inst.pilot_q);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_offset_pilot_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.phase_in_stb && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_offset_pilot_sum_fd, "%d %d %d\n", iq_count, dot11_inst.equalizer_inst.pilot_sum_i, dot11_inst.equalizer_inst.pilot_sum_q);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_offset_pilot_sum_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.phase_out_stb && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(phase_offset_phase_out_fd, "%d %d\n", iq_count, $signed(dot11_inst.equalizer_inst.phase_out));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(phase_offset_phase_out_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.rot_in_stb && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(rot_in_fd, "%d %d %d %d\n", iq_count, $signed(dot11_inst.equalizer_inst.buf_i_out), $signed(dot11_inst.equalizer_inst.buf_q_out), $signed(dot11_inst.equalizer_inst.sym_phase));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(rot_in_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.rot_out_stb && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(rot_out_fd, "%d %d %d\n", iq_count, dot11_inst.equalizer_inst.rot_i, dot11_inst.equalizer_inst.rot_q);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(rot_out_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.prod_out_strobe && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(equalizer_prod_fd, "%d %d %d\n", iq_count, $signed(dot11_inst.equalizer_inst.prod_i), $signed(dot11_inst.equalizer_inst.prod_q));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(equalizer_prod_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(equalizer_prod_scaled_fd, "%d %d %d\n", iq_count, $signed(dot11_inst.equalizer_inst.prod_i_scaled), $signed(dot11_inst.equalizer_inst.prod_q_scaled));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(equalizer_prod_scaled_fd);
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(equalizer_mag_sq_fd, "%d %d\n", iq_count, dot11_inst.equalizer_inst.mag_sq);
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(equalizer_mag_sq_fd);
|
|
|
|
end
|
|
|
|
if (dot11_inst.equalizer_inst.sample_out_strobe && dot11_inst.equalizer_inst.enable && ~dot11_inst.equalizer_inst.reset) begin
|
2023-01-05 15:38:51 +00:00
|
|
|
$fwrite(equalizer_out_fd, "%d %d %d\n", iq_count, $signed(dot11_inst.equalizer_inst.sample_out[31:16]), $signed(dot11_inst.equalizer_inst.sample_out[15:0]));
|
2022-05-16 07:33:19 +00:00
|
|
|
$fflush(equalizer_out_fd);
|
|
|
|
end
|
|
|
|
|
2017-04-03 16:52:03 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-03-15 15:03:40 +00:00
|
|
|
signal_watchdog signal_watchdog_inst (
|
|
|
|
.clk(clock),
|
|
|
|
.rstn(~reset),
|
|
|
|
.enable(~demod_is_ongoing),
|
|
|
|
|
|
|
|
.i_data(sample_in[31:16]),
|
|
|
|
.q_data(sample_in[15:0]),
|
|
|
|
.iq_valid(sample_in_strobe),
|
|
|
|
|
|
|
|
.signal_len(pkt_len),
|
|
|
|
.sig_valid(sig_valid),
|
|
|
|
|
2022-05-16 07:51:30 +00:00
|
|
|
.max_signal_len_th(16'hFFFF),
|
|
|
|
.dc_running_sum_th(65),
|
2022-03-15 15:03:40 +00:00
|
|
|
|
|
|
|
.receiver_rst(receiver_rst)
|
|
|
|
);
|
|
|
|
|
2017-04-03 16:52:03 +00:00
|
|
|
dot11 dot11_inst (
|
|
|
|
.clock(clock),
|
|
|
|
.enable(enable),
|
2022-05-16 07:52:24 +00:00
|
|
|
.reset(reset | receiver_rst),
|
2019-12-10 12:31:16 +00:00
|
|
|
|
2019-12-10 13:09:31 +00:00
|
|
|
//.set_stb(set_stb),
|
2019-12-10 12:31:16 +00:00
|
|
|
//.set_addr(set_addr),
|
2019-12-10 13:09:31 +00:00
|
|
|
//.set_data(set_data),
|
2019-12-10 12:31:16 +00:00
|
|
|
|
|
|
|
.power_thres(11'd0),
|
2019-12-10 13:09:31 +00:00
|
|
|
.min_plateau(32'd100),
|
2019-12-10 12:31:16 +00:00
|
|
|
|
|
|
|
.rssi_half_db(rssi_half_db),
|
|
|
|
.sample_in(sample_in),
|
|
|
|
.sample_in_strobe(sample_in_strobe),
|
2020-09-02 19:59:37 +00:00
|
|
|
.soft_decoding(1'b1),
|
2022-05-16 07:52:24 +00:00
|
|
|
.force_ht_smoothing(1'b0),
|
|
|
|
.disable_all_smoothing(1'b0),
|
2019-12-10 12:31:16 +00:00
|
|
|
|
2022-03-15 15:03:40 +00:00
|
|
|
.demod_is_ongoing(demod_is_ongoing),
|
|
|
|
.pkt_header_valid(pkt_header_valid),
|
2020-10-08 08:06:03 +00:00
|
|
|
.pkt_header_valid_strobe(pkt_header_valid_strobe),
|
2022-05-16 07:51:01 +00:00
|
|
|
.pkt_len(pkt_len)
|
2017-04-03 16:52:03 +00:00
|
|
|
);
|
|
|
|
|
2020-09-02 19:59:37 +00:00
|
|
|
/*
|
2019-12-10 12:31:16 +00:00
|
|
|
byte_to_word_fcs_sn_insert byte_to_word_fcs_sn_insert_inst (
|
|
|
|
.clk(clock),
|
|
|
|
.rstn((~reset)&(~pkt_header_valid_strobe)),
|
|
|
|
|
|
|
|
.byte_in(byte_out),
|
|
|
|
.byte_in_strobe(byte_out_strobe),
|
|
|
|
.byte_count(byte_count),
|
|
|
|
.num_byte(pkt_len),
|
|
|
|
.fcs_in_strobe(fcs_out_strobe),
|
|
|
|
.fcs_ok(fcs_ok),
|
|
|
|
.rx_pkt_sn_plus_one(0),
|
|
|
|
|
|
|
|
.word_out(word_out),
|
|
|
|
.word_out_strobe(word_out_strobe)
|
|
|
|
);
|
2020-09-02 19:59:37 +00:00
|
|
|
*/
|
|
|
|
|
2017-04-03 16:52:03 +00:00
|
|
|
endmodule
|