fix(top): reverse iq in recv

This commit is contained in:
2024-08-02 20:51:37 +08:00
parent 92583b785c
commit 145e8c0930
11 changed files with 1918 additions and 569 deletions
+1646 -342
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
set_property MAX_FANOUT 512 [get_nets *u_RecvTop/mag*] set_property MAX_FANOUT 512 [get_nets *u_RecvTop/mag*]
# set_property MAX_FANOUT 512 [get_nets u_Receiver/mag_valid] # set_property MAX_FANOUT 512 [get_nets u_Receiver/mag_valid]
# set_false_path -through [get_nets u_Receiver/rst] # set_false_path -through [get_nets u_Receiver/rst]
set_false_path -through [get_nets u_RecvTop/SR[0]] # set_false_path -through [get_nets u_RecvTop/SR[0]]
+1 -18
View File
@@ -64,11 +64,6 @@ module PAPR #(
// accumulate ==> average ==> papr // accumulate ==> average ==> papr
wire [MAG_WIDTH-1:0] vec_mag_1024; wire [MAG_WIDTH-1:0] vec_mag_1024;
reg [ 5:0] cnt; reg [ 5:0] cnt;
// shift_1024 shift_1024 (
// .D (vec_mag), // input wire [21 : 0] D
// .CLK(clk), // input wire CLK
// .Q (vec_mag_1024) // output wire [21 : 0] Q
// );
shift_reg #( shift_reg #(
.DATA_WIDTH(MAG_WIDTH), .DATA_WIDTH(MAG_WIDTH),
@@ -144,22 +139,10 @@ module PAPR #(
end end
// ******** Wire & Reg ********
// ******** Assingment ********
// ******** Logic Block ********
// ******** Inst ********
// ******** Debug ********
// NOTE: comment
ila_frame_sync u_ila_frame_sync ( ila_frame_sync u_ila_frame_sync (
.clk (clk), // input wire clk .clk (clk), // input wire clk
.probe0(vec_mag), // input wire [21:0] probe0 .probe0(vec_mag), // input wire [21:0] probe0
.probe1(mag_valid), // input wire [0:0] probe1 .probe1(data_avg), // input wire [21:0] probe0
.probe2(frame_sync) // input wire [0:0] probe2 .probe2(frame_sync) // input wire [0:0] probe2
); );
+52 -38
View File
@@ -20,24 +20,25 @@
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
module RecvTop ( module RecvTop (
input clk, input clk,
input clk_2x, // clk_2x input clk_2x, // clk_2x
input clk_4x, input clk_4x,
input rst, input rst,
input rst2, // TODO: delete the signal input rst2, // TODO: delete the signal
// phy wave // phy wave
input [11:0] dini, input [11:0] dini,
input [11:0] dinq, input [11:0] dinq,
// mgc control // mgc control
output [ 3:0] ad9361_ctrl_in, output [ 3:0] ad9361_ctrl_in,
output wire frame_sync_pulse, // in domain clk output wire flag_mgc_done_pulse, // active high pulse signal
output wire frame_sync_pulse, // in domain clk
//vio //vio
input vio_tsync_inter16, //为1的时候启用内插,从16倍过采样中挑一路 input vio_tsync_inter16, //为1的时候启用内插,从16倍过采样中挑一路
input EQUenable_vio, //为1时启用均衡 input EQUenable_vio, //为1时启用均衡
input [ 7:0] Zerozone_vio, //零域估计,默认值为8'd29 input [ 7:0] Zerozone_vio, //零域估计,默认值为8'd29
input [ 6:0] vio_stopbit, //寻找停止位,默认值为7'd60 input [ 6:0] vio_stopbit, //寻找停止位,默认值为7'd60
// stop signal // stop signal
output flag_stop, //给shx,拉高8个clk表示当前时帧有效数据接收完毕 output flag_stop, //给shx,拉高8个clk表示当前时帧有效数据接收完毕
output [16:0] addr_stop, //给shx,拉高8个clk,与flag_stop对齐,指示位置与最后1bit有效数据的位置对齐 output [16:0] addr_stop, //给shx,拉高8个clk,与flag_stop对齐,指示位置与最后1bit有效数据的位置对齐
// mac frame header // mac frame header
output [63:0] recvNetData, output [63:0] recvNetData,
output recvNetDataNd output recvNetDataNd
@@ -47,7 +48,7 @@ module RecvTop (
wire rst_freq; wire rst_freq;
wire DAGC_rdy; wire DAGC_rdy;
wire framesync; //帧同步峰 wire framesync; //帧同步峰
wire framesync_delay; //帧同步峰,与频率补偿输出对应 wire flag_cfo_done; //帧同步峰,与频率补偿输出对应
wire framesync_tsync; //帧同步标志,与TSync输出对应 wire framesync_tsync; //帧同步标志,与TSync输出对应
wire IntpARdy; //TSync输出nd wire IntpARdy; //TSync输出nd
wire nd_SC_FDE_dout; //SC_FDE输出nd wire nd_SC_FDE_dout; //SC_FDE输出nd
@@ -133,13 +134,14 @@ module RecvTop (
// * MGC module // * MGC module
ad9361_mgc_pin_ctrl u_ad9361_mgc_pin_ctrl ( ad9361_mgc_pin_ctrl u_ad9361_mgc_pin_ctrl (
.clk (clk), .clk (clk),
.rst (rst), .rst (rst),
.start (mgc_start), .start (mgc_start),
.rx_data_i (dini), .rx_data_i (dini),
.rx_data_q (dinq), .rx_data_q (dinq),
.ad9361_ctrl_in(ad9361_ctrl_in), .ad9361_ctrl_in (ad9361_ctrl_in),
.flag_mgc_done (flag_mgc_done) .flag_mgc_done_pulse(flag_mgc_done_pulse),
.flag_mgc_done (flag_mgc_done)
); );
@@ -256,6 +258,7 @@ module RecvTop (
.m_axis_data_tdata (dmf_tdata_interp4_q) .m_axis_data_tdata (dmf_tdata_interp4_q)
); );
wire [7:0] cnt_chu_seq_sync_max_vio;
localparam CNT_CHU_SEQ_SYNC_MAX = 40; //! should not less than 3 due to the minimum rst of aresetn localparam CNT_CHU_SEQ_SYNC_MAX = 40; //! should not less than 3 due to the minimum rst of aresetn
wire [21:0] mag; wire [21:0] mag;
@@ -266,7 +269,7 @@ module RecvTop (
wire rst_frame_sync; // derive from frame sync pulse wire rst_frame_sync; // derive from frame sync pulse
reg [ 7:0] cnt_chu_seq_sync; // frame sync delay to chu seq sample start pos reg [ 7:0] cnt_chu_seq_sync; // frame sync delay to chu seq sample start pos
assign rst_frame_sync = ((cnt_chu_seq_sync >= 1) && (cnt_chu_seq_sync < CNT_CHU_SEQ_SYNC_MAX)); assign rst_frame_sync = ((cnt_chu_seq_sync >= 1) && (cnt_chu_seq_sync < cnt_chu_seq_sync_max_vio));
//* calc the magnitude //* calc the magnitude
MagnitudeEstimator #( MagnitudeEstimator #(
@@ -298,7 +301,7 @@ module RecvTop (
cnt_chu_seq_sync <= 1; cnt_chu_seq_sync <= 1;
end end
// avoid the tailing of the convolution (here we use CNT_CHU_SEQ_SYNC_MAX clocks) // avoid the tailing of the convolution (here we use CNT_CHU_SEQ_SYNC_MAX clocks)
else if (cnt_chu_seq_sync >= 1 && cnt_chu_seq_sync < CNT_CHU_SEQ_SYNC_MAX) begin else if (cnt_chu_seq_sync >= 1 && cnt_chu_seq_sync < cnt_chu_seq_sync_max_vio) begin
cnt_chu_seq_sync <= cnt_chu_seq_sync + 1; cnt_chu_seq_sync <= cnt_chu_seq_sync + 1;
end end
else begin else begin
@@ -310,7 +313,7 @@ module RecvTop (
if (rst) begin if (rst) begin
flag_frame_sync <= 0; flag_frame_sync <= 0;
end end
else if (cnt_chu_seq_sync == CNT_CHU_SEQ_SYNC_MAX) begin else if (cnt_chu_seq_sync == cnt_chu_seq_sync_max_vio) begin
flag_frame_sync <= 1; flag_frame_sync <= 1;
end end
else begin else begin
@@ -380,7 +383,7 @@ module RecvTop (
.datain_q (DAGC_out_q), .datain_q (DAGC_out_q),
.dataout_i (freqdataout_i), .dataout_i (freqdataout_i),
.dataout_q (freqdataout_q), .dataout_q (freqdataout_q),
.framesync_delay(framesync_delay), .framesync_delay(flag_cfo_done),
.data_save (data_save), .data_save (data_save),
.rst_freq (rst_freq) .rst_freq (rst_freq)
); );
@@ -396,7 +399,7 @@ module RecvTop (
.douti (IntpOuti), .douti (IntpOuti),
.doutq (IntpOutq), .doutq (IntpOutq),
.vio_tsync_inter16(vio_tsync_inter16), .vio_tsync_inter16(vio_tsync_inter16),
.framesync (framesync_delay), //帧同步标志 .framesync (flag_cfo_done), //帧同步标志
.framesync_tsync (framesync_tsync), //帧同步标志 .framesync_tsync (framesync_tsync), //帧同步标志
//debug //debug
.cnt_tsync (cnt_tsync), .cnt_tsync (cnt_tsync),
@@ -536,24 +539,35 @@ module RecvTop (
// ***** debug ***** // ***** debug *****
vio_recv_top u_vio_recv_top (
.clk (clk),
.probe_out0(cnt_chu_seq_sync_max_vio)
);
ila_recv_top u_ila_recv_top ( ila_recv_top u_ila_recv_top (
.clk (clk), .clk (clk),
.probe0 (flag_mgc_done), // width: 1 .probe0 (dini), // width: 12
.probe1 (flag_frame_sync), // width: 1 .probe1 (dinq), // width: 12
.probe2 (mf_data_interp4_q), // width: 32 .probe2 (mf_data_interp4_i[29-:12]), // width: 12
.probe3 (mf_data_interp4_i), // width: 32 .probe3 (mf_data_interp4_q[29-:12]), // width: 12
.probe4 (freqestm.freq_out), // width: 14 .probe4 (flag_mgc_done), // width: 1
.probe5 (freqdataout_i), // width: 10 .probe5 (flag_frame_sync), // width: 1
.probe6 (freqdataout_q), // width: 10 .probe6 (flag_cfo_done), // width: 1
.probe7 (nd_SC_FDE_dout), // width: 1 .probe7 (freqdataout_i), // width: 10
.probe8 (SC_FDE_douti), // width: 10 .probe8 (freqdataout_q), // width: 10
.probe9 (SC_FDE_doutq), // width: 10 .probe9 (IntpARdy), // width: 1
.probe10(LDPC_SyncOut), // width: 1 .probe10(IntpOuti), // width: 10
.probe11(LDPC_Rdy), // width: 1 .probe11(IntpOutq), // width: 10
.probe12(LDPC_Dout), // width: 1 .probe12(nd_SC_FDE_dout), // width: 1
.probe13(bad_frames), // width: 9 .probe13(SC_FDE_douti), // width: 10
.probe14(total_frames), // width: 9 .probe14(SC_FDE_doutq), // width: 10
.probe15(mgc_start) // width: 1 .probe15(phase_adjust_rdy), // width: 1
.probe16(phase_adjust_douti), // width: 10
.probe17(phase_adjust_doutq), // width: 10
.probe18(LDPC_Rdy), // width: 1
.probe19(LDPC_Dout), // width: 1
.probe20(good_frames), // width: 9
.probe21(bad_frames) // width: 9
); );
+9 -7
View File
@@ -21,7 +21,8 @@ module ad9361_mgc_pin_ctrl (
input [11:0] rx_data_q, input [11:0] rx_data_q,
// this port is from zynq to ad9361 // this port is from zynq to ad9361
output wire [ 3:0] ad9361_ctrl_in, output wire [ 3:0] ad9361_ctrl_in,
output reg flag_mgc_done = 0 // active high level signal output wire flag_mgc_done_pulse, // active high pulse signal
output reg flag_mgc_done = 0 // active high level signal
); );
@@ -54,14 +55,15 @@ module ad9361_mgc_pin_ctrl (
reg [2:0] ns; reg [2:0] ns;
// ******** Assingment ******** // ******** Assingment ********
assign ad9361_ctrl_in[0] = inc_pulse; assign ad9361_ctrl_in[0] = inc_pulse;
assign ad9361_ctrl_in[1] = dec_pulse; assign ad9361_ctrl_in[1] = dec_pulse;
assign flag_adjust = flag_too_high | flag_too_low; assign flag_adjust = flag_too_high | flag_too_low;
assign inc_pulse = (cs == S_INC); assign inc_pulse = (cs == S_INC);
assign dec_pulse = (cs == S_DEC); assign dec_pulse = (cs == S_DEC);
assign start_posedge = start & ~start_d1; assign start_posedge = start & ~start_d1;
assign flag_mgc_done_pulse = power_measure_done_pulse;
// ******** Logic Block ******** // ******** Logic Block ********
+23 -25
View File
@@ -75,7 +75,7 @@ module net_city (
always @(posedge clk) begin always @(posedge clk) begin
if (rst) begin if (rst) begin
rx_rst <= 1; rx_rst <= 0;
end end
else if (tx_start) begin else if (tx_start) begin
rx_rst <= 1; rx_rst <= 1;
@@ -211,31 +211,29 @@ module net_city (
end end
8'd50: begin 8'd50: begin
if (recv_net_data_nd) begin // if (recv_net_data_nd) begin
if (recv_net_data[23:00] == 24'h7e5a33) begin // if (recv_net_data[23:00] == 24'h7e5a33) begin
state_net <= 8'd51; state_net <= 8'd51;
is_net <= 1'b1; is_net <= 1'b1;
cnt_trans_slot <= cnt_trans_slot + 32'd1;
cnt_inter_slot <= cnt_inter_slot + 32'd1;
recv_id <= recv_net_data[63:56];
recv_video_id01 <= recv_net_data[55:48];
recv_video_id02 <= recv_net_data[47:40];
recv_video_id03 <= recv_net_data[39:32];
recv_connect_node <= recv_net_data[31:24];
// end
// else begin
// state_net <= 8'd200;
// is_net <= 1'b0;
cnt_trans_slot <= cnt_trans_slot + 32'd1; // cnt_trans_slot <= cnt_inter_slot + 32'd1;
cnt_inter_slot <= cnt_inter_slot + 32'd1; // end
// end
recv_id <= recv_net_data[63:56]; // else begin
recv_video_id01 <= recv_net_data[55:48]; // cnt_trans_slot <= cnt_trans_slot + 32'd1;
recv_video_id02 <= recv_net_data[47:40]; // cnt_inter_slot <= cnt_inter_slot + 32'd1;
recv_video_id03 <= recv_net_data[39:32]; // end
recv_connect_node <= recv_net_data[31:24];
end
else begin
state_net <= 8'd200;
is_net <= 1'b0;
cnt_trans_slot <= cnt_inter_slot + 32'd1;
end
end
else begin
cnt_trans_slot <= cnt_trans_slot + 32'd1;
cnt_inter_slot <= cnt_inter_slot + 32'd1;
end
end end
8'd51: begin 8'd51: begin
state_net <= 8'd200; state_net <= 8'd200;
+1 -1
View File
@@ -30,7 +30,7 @@ module power_measure (
); );
localparam CNT_WAIT_9361_MAX = 80; //* 等待周期数 localparam CNT_WAIT_9361_MAX = 80; //* 等待周期数
localparam CNT_MEASURING_MAX = 512; // * 观察64个周期 localparam CNT_MEASURING_MAX = 256; // * 观察64个周期
localparam CNT_ADJUST_TIMES_MAX = 25; localparam CNT_ADJUST_TIMES_MAX = 25;
localparam CNT_AMP_TOO_HIGH_THRESHOLD = 6; localparam CNT_AMP_TOO_HIGH_THRESHOLD = 6;
// ******** Wire & Reg ******** // ******** Wire & Reg ********
+86 -69
View File
@@ -89,6 +89,7 @@ module system_top (
wire tx_data_src_tvalid; wire tx_data_src_tvalid;
// tx signal // tx signal
wire tx_test_flag; wire tx_test_flag;
wire flag_mgc_done_pulse;
// baseband signal // baseband signal
wire [11:0] ad9361_rx_data_i; wire [11:0] ad9361_rx_data_i;
@@ -98,6 +99,13 @@ module system_top (
wire [11:0] ad9361_tx_data_i; wire [11:0] ad9361_tx_data_i;
wire [11:0] ad9361_tx_data_q; wire [11:0] ad9361_tx_data_q;
wire [ 2:0] speed_mode; wire [ 2:0] speed_mode;
// mux
wire bb_tx_iq_reverse;
wire bb_rx_iq_reverse;
wire [11:0] bb_tx_i;
wire [11:0] bb_tx_q;
wire [11:0] bb_rx_i;
wire [11:0] bb_rx_q;
// phy control signal // phy control signal
wire phy_rst_vio; wire phy_rst_vio;
@@ -126,15 +134,20 @@ module system_top (
// ******** Assingment ******** // ******** Assingment ********
assign ad9361_tx_clk = clk_1x; assign ad9361_tx_clk = clk_1x;
assign rst_sys = ~poweron_locked; assign rst_sys = ~poweron_locked;
// ad9361 control // ad9361 control
assign ad9361_enable = gpio_o[0]; // ad9361 enable state machine control assign ad9361_enable = gpio_o[0]; // ad9361 enable state machine control
assign ad9361_en_agc = gpio_o[1]; // ad9361 agc control assign ad9361_en_agc = gpio_o[1]; // ad9361 agc control
assign ad9361_reset_b = gpio_o[2]; // ad9361 reset assign ad9361_reset_b = gpio_o[2]; // ad9361 reset
assign ad9361_txnrx = gpio_o[3]; // ad9361 txnrx assign ad9361_txnrx = gpio_o[3]; // ad9361 txnrx
assign ad9361_tx_data_i = bb_tx_iq_reverse ? bb_tx_q : bb_tx_i;
assign ad9361_tx_data_q = bb_tx_iq_reverse ? bb_tx_i : bb_tx_q;
assign bb_rx_i = bb_rx_iq_reverse ? ad9361_rx_data_q : ad9361_rx_data_i;
assign bb_rx_q = bb_rx_iq_reverse ? ad9361_rx_data_i : ad9361_rx_data_q;
// ******** Logic Block ******** // ******** Logic Block ********
// ******** Inst ******** // ******** Inst ********
@@ -196,7 +209,7 @@ module system_top (
.gpio_t (gpio_t), .gpio_t (gpio_t),
// intr pl to ps // intr pl to ps
.pl2ps_intr2 (intr_2ps), .pl2ps_intr2 (intr_2ps),
.pl2ps_intr3 (pl2ps_intr3), .pl2ps_intr3 (flag_mgc_done_pulse),
// tx fifo // tx fifo
.tx_data_src_count (tx_data_src_count), .tx_data_src_count (tx_data_src_count),
.tx_data_src_tdata (tx_data_src_tdata), .tx_data_src_tdata (tx_data_src_tdata),
@@ -211,44 +224,47 @@ module system_top (
); );
// tdma #( tdma #(
// .SLOT_LEN (750000), // 50MHz--> 15ms .SLOT_LEN (750000), // 50MHz--> 15ms
// .TIC_TO_PS_LEN (700000), .TIC_TO_PS_LEN (700000),
// .TIC_FRAME_SYNC(42344) .TIC_FRAME_SYNC(42344)
// ) u_tdma ( // .SLOT_LEN (625001), // 50MHz--> 15ms
// .clk (clk_1x), // .TIC_TO_PS_LEN (575000),
// .rst (rst_sys), // .TIC_FRAME_SYNC(42344)
// .flag_is_master (0), ) u_tdma (
// .flag_frame_sync(frame_sync_pulse), .clk (clk_1x),
// .intr_2ps (intr_2ps), .rst (rst_sys),
// .tx_start (tx_start), .flag_is_master (flag_is_master),
// .rx_rst (rx_rst) .flag_frame_sync(frame_sync_pulse),
// ); .intr_2ps (intr_2ps),
.tx_start (tx_start),
net_city u_net_city ( .rx_rst (rx_rst)
.clk (clk_1x),
.rst_initial (rst_sys),
.rst_manual (rst_manual),
.tx_start (tx_start),
.trans_net_data (),
.flag_video_send (),
.recv_id (),
.frame_sync (frame_sync_pulse),
.recv_net_data_nd(1),
.recv_net_data (0),
.frame_sync_time (42344),
.id_num (node_id),
.max_slot_num (max_slot_num),
.video_id01 (0),
.video_id02 (0),
.video_id03 (0),
.is_net (),
.flag_to_uc (),
.intr_ps (intr_2ps),
.rx_rst (rx_rst),
.tx_done (tx_done)
); );
// net_city u_net_city (
// .clk (clk_1x),
// .rst_initial (rst_sys),
// .rst_manual (rst_manual),
// .tx_start (tx_start),
// .trans_net_data (),
// .flag_video_send (),
// .recv_id (),
// .frame_sync (frame_sync_pulse),
// .recv_net_data_nd(1'b1),
// .recv_net_data (64'd0),
// .frame_sync_time (42344),
// .id_num (node_id),
// .max_slot_num (max_slot_num),
// .video_id01 (0),
// .video_id02 (0),
// .video_id03 (0),
// .is_net (),
// .flag_to_uc (),
// .intr_ps (intr_2ps),
// .rx_rst (rx_rst),
// .tx_done (tx_done)
// );
// ---- PHY layer logic start // ---- PHY layer logic start
@@ -278,30 +294,31 @@ module system_top (
.tx_data_src_tready(enc_fifo_rd_en), .tx_data_src_tready(enc_fifo_rd_en),
.tx_data_src_tvalid(~enc_fifo_empty), .tx_data_src_tvalid(~enc_fifo_empty),
.hopping_freq (), .hopping_freq (),
.ad9361_tx_data_i (ad9361_tx_data_i), .ad9361_tx_data_i (bb_tx_i),
.ad9361_tx_data_q (ad9361_tx_data_q), .ad9361_tx_data_q (bb_tx_q),
.test (tx_test_flag | phy_tx_test_flag_vio), .test (tx_test_flag | phy_tx_test_flag_vio),
.hop_wait (100) .hop_wait (100)
); );
RecvTop u_RecvTop ( RecvTop u_RecvTop (
.clk (clk_1x), .clk (clk_1x),
.clk_2x (clk_2x), .clk_2x (clk_2x),
.clk_4x (clk_4x), .clk_4x (clk_4x),
.rst (rst_sys | rx_rst | phy_rst), .rst (rst_sys | rx_rst | phy_rst),
.rst2 (rst_sys | phy_rst), .rst2 (rst_sys | phy_rst),
.dini (ad9361_rx_data_i), .dini (bb_rx_i),
.dinq (ad9361_rx_data_q), .dinq (bb_rx_q),
.ad9361_ctrl_in (ad9361_ctrl_in), .ad9361_ctrl_in (ad9361_ctrl_in),
.frame_sync_pulse (frame_sync_pulse), .flag_mgc_done_pulse(flag_mgc_done_pulse),
.vio_tsync_inter16(1), .frame_sync_pulse (frame_sync_pulse),
.EQUenable_vio (1), .vio_tsync_inter16 (1),
.Zerozone_vio (8'd29), .EQUenable_vio (1),
.vio_stopbit (7'd60), .Zerozone_vio (8'd29),
.flag_stop (flag_stop), .vio_stopbit (7'd60),
.addr_stop (addr_stop), .flag_stop (flag_stop),
.recvNetData (recvNetData), .addr_stop (addr_stop),
.recvNetDataNd (recvNetDataNd) .recvNetData (recvNetData),
.recvNetDataNd (recvNetDataNd)
); );
@@ -361,7 +378,7 @@ module system_top (
// .clk (ad9361_rx_clk), // .clk (ad9361_rx_clk),
// .probe0(ad9361_rx_data_i), // .probe0(ad9361_rx_data_i),
// .probe1(ad9361_rx_data_q), // .probe1(ad9361_rx_data_q),
// .probe2(u_ad9361_mgc_pin_ctrl.flag_adjust) // .probe2(u_RecvTop.flag_mgc_done)
// ); // );
// ila_ad9361_tx u_ila_ad9361_tx ( // ila_ad9361_tx u_ila_ad9361_tx (
@@ -381,13 +398,13 @@ module system_top (
intr_2ps_vio_d1 <= intr_2ps_vio; intr_2ps_vio_d1 <= intr_2ps_vio;
end end
vio_phy_control u_vio_phy_control ( vio_phy_control u_vio_phy_control (
.clk (clk_1x), // input wire clk .clk (clk_1x), // input wire clk
.probe_out0(rst_manual), // output wire [0 : 0] .probe_out0(flag_is_master), // output wire [0 : 0]
.probe_out1(node_id), // output wire [7 : 0] .probe_out1(bb_tx_iq_reverse), // output wire [0 : 0]
.probe_out2(max_slot_num), // output wire [7 : 0] .probe_out2(bb_rx_iq_reverse) // output wire [0 : 0]
.probe_out3(intr_2ps_vio), // output wire [0 : 0]
.probe_out4(tx_start_vio) // output wire [0 : 0]
); );
+50 -22
View File
@@ -14,29 +14,36 @@
// ! PLEASE MAKE SURE THE PARAMETER ARE VALID // ! PLEASE MAKE SURE THE PARAMETER ARE VALID
// ! WHEN U INSTANTIATE THIS MODULE // ! WHEN U INSTANTIATE THIS MODULE
module tdma #( module tdma #(
parameter SLOT_LEN = 1250000, parameter SLOT_LEN = 750000,
parameter TIC_TO_PS_LEN = 1200000, parameter TIC_TO_PS_LEN = 700000,
parameter TIC_FRAME_SYNC = 42272 parameter TIC_FRAME_SYNC = 42344
) ( ) (
input clk, input clk,
input rst, input rst,
input flag_is_master, // TODO: refactor it to parameters input flag_is_master, // TODO: refactor it to parameters
input flag_frame_sync, input flag_frame_sync,
output intr_2ps, output intr_2ps,
(* KEEP = "TRUE" *) output tx_start, output tx_start,
(* KEEP = "TRUE" *) output rx_rst output reg rx_rst
); );
// TODO: 需要检查综合后电路是否会被优化 // TODO: 需要检查综合后电路是否会被优化
// BUG: 需要修复bug,重构代码,把主从分开写,通过参数进行优化 // BUG: 需要修复bug,重构代码,把主从分开写,通过参数进行优化
// ******** Wire & Reg ******** // ******** Wire & Reg ********
reg flag_is_tx_slot; reg flag_is_tx_slot;
reg [23:0] cnt;
// ******** Assingment ******** // ******** Assingment ********
assign tx_start = flag_is_master & (cnt == 16'd10);
assign intr_2ps = flag_is_master & (cnt == TIC_TO_PS_LEN - 1);
// ******** Logic Block ******** // ******** Logic Block ********
reg [23:0] cnt;
always @(posedge clk) begin always @(posedge clk) begin
if (rst) begin if (rst) begin
cnt <= 0; cnt <= 0;
@@ -48,7 +55,7 @@ module tdma #(
end end
else begin else begin
// master // master
if (cnt < SLOT_LEN) begin if (cnt < SLOT_LEN - 1) begin
cnt <= cnt + 1; cnt <= cnt + 1;
end end
else begin else begin
@@ -57,26 +64,47 @@ module tdma #(
end end
end end
end end
assign tx_start = flag_is_tx_slot & (cnt == 16'd10);
assign rx_rst = flag_is_tx_slot | (~flag_is_tx_slot & (cnt <= 16'd10));
assign intr_2ps = ~flag_is_tx_slot & (cnt == TIC_TO_PS_LEN);
always @(posedge clk) begin always @(posedge clk) begin
if (rst) begin if (flag_is_master) begin
flag_is_tx_slot <= 0; rx_rst <= 1;
end end
else if (!flag_is_master && flag_frame_sync) begin else begin
flag_is_tx_slot <= 0; rx_rst <= flag_is_master | (cnt <= 16'd4);
end
else if (cnt == 16'd1) begin
flag_is_tx_slot <= ~flag_is_tx_slot;
end end
end end
// always @(posedge clk) begin
// if (rst) begin
// flag_is_tx_slot <= 0;
// end
// else if (!flag_is_master && flag_frame_sync) begin
// flag_is_tx_slot <= 0;
// end
// else if (cnt == 16'd1) begin
// flag_is_tx_slot <= ~flag_is_tx_slot;
// end
// end
// ******** Inst ******** // ******** Inst ********
// ******** Debug ******** // ******** Debug ********
ila_mac_layer u_ila_mac_layer (
.clk (clk),
.probe0(cnt), // width: 24
.probe1(tx_start), // width: 1
.probe2(rx_rst), // width: 1
.probe3(flag_is_master), // width: 1
.probe4(intr_2ps), // width: 1
.probe5(flag_frame_sync) // width: 1
);
endmodule endmodule
+10 -45
View File
@@ -22,60 +22,25 @@
module tb_tdma (); module tb_tdma ();
reg clk = 1; reg clk = 1;
reg clk_tx = 1;
reg rst = 1; reg rst = 1;
always #1 clk <= ~clk; always #1 clk <= ~clk;
initial begin initial begin
#1000 rst <= 1'b0; #10 rst <= 1'b0;
end end
wire flag_frame_sync_m;
reg flag_frame_sync_s = 0;
wire intr_2ps_m;
wire intr_2ps_s;
wire tic_hop_m;
wire tic_hop_s;
wire tx_start_m;
wire tx_start_s;
assign flag_frame_sync_m = 1'b0;
tdma #( tdma #(
.SLOT_LEN (1250000), .SLOT_LEN (625000), // 50MHz--> 15ms
.TIC_TO_PS_LEN (1200000), .TIC_TO_PS_LEN (575000),
.TIC_FRAME_SYNC(42272) .TIC_FRAME_SYNC(42344)
) u_tdma_master ( ) u_tdma (
.clk (clk), .clk (clk),
.rst (rst), .rst (rst),
.flag_is_master (1'b1), .flag_is_master (1),
.flag_frame_sync(flag_frame_sync_m), .flag_frame_sync(0),
.intr_2ps (intr_2ps_m), .intr_2ps (intr_2ps),
// .tic_hop (tic_hop_m), .tx_start (tx_start),
.tx_start (tx_start_m) .rx_rst (rx_rst)
); );
tdma #(
.SLOT_LEN (20000),
.TIC_TO_PS_LEN (18000),
.TIC_FRAME_SYNC(2000)
) u_tdma_slave (
.clk (clk),
.rst (rst),
.flag_is_master (1'b0),
.flag_frame_sync(flag_frame_sync_s),
.intr_2ps (intr_2ps_s),
// .tic_hop (tic_hop_s),
.tx_start (tx_start_s)
);
initial begin
#12000 flag_frame_sync_s <= 1'b1;
#3 flag_frame_sync_s <= 1'b0;
end
endmodule endmodule
+38
View File
@@ -0,0 +1,38 @@
# this is a demo create ip using tcl script
# create a new ip ila named ila_rx2, if the ip already exists, skip create_ip step
create_ip -name ila -vendor xilinx.com -library ip -version 6.2 -module_name ila_tdma
# set the ip property
set_property -dict [list \
CONFIG.C_EN_STRG_QUAL {1} \
CONFIG.C_NUM_OF_PROBES {22} \
CONFIG.C_PROBE0_WIDTH {12} \
CONFIG.C_PROBE1_WIDTH {12} \
CONFIG.C_PROBE2_WIDTH {12} \
CONFIG.C_PROBE3_WIDTH {12} \
CONFIG.C_PROBE4_WIDTH {1} \
CONFIG.C_PROBE5_WIDTH {1} \
CONFIG.C_PROBE6_WIDTH {1} \
CONFIG.C_PROBE7_WIDTH {10} \
CONFIG.C_PROBE8_WIDTH {10} \
CONFIG.C_PROBE9_WIDTH {1} \
CONFIG.C_PROBE10_WIDTH {10} \
CONFIG.C_PROBE11_WIDTH {10} \
CONFIG.C_PROBE12_WIDTH {1} \
CONFIG.C_PROBE13_WIDTH {10} \
CONFIG.C_PROBE14_WIDTH {10} \
CONFIG.C_PROBE15_WIDTH {1} \
CONFIG.C_PROBE16_WIDTH {10} \
CONFIG.C_PROBE17_WIDTH {10} \
CONFIG.C_PROBE18_WIDTH {1} \
CONFIG.C_PROBE19_WIDTH {1} \
CONFIG.C_PROBE20_WIDTH {9} \
CONFIG.C_PROBE21_WIDTH {9} \
] [get_ips ila_recv_top]
set_property -dict [list \
CONFIG.C_NUM_OF_PROBES {6} \
CONFIG.C_PROBE0_WIDTH {24} \
] [get_ips ila_tdma]