笔记:从Aurora 8b/10b 到Aurora 64b/66b (三):自定义PHY层收发

news/2024/11/20 1:44:40/文章来源:https://www.cnblogs.com/VerweileDoch/p/18346835

相较于8/10来说没那么复杂,需要考虑的情况只有八种;

但是gearbox的控制需要额外的心思:每三十二周期所有操作都需要停止;

这一点在收发都需要注意;

RX:

核心思想是利用header做检测,将夹杂在数据流中的控制包滤除掉;

module gt_phy_rx (input   wire            i_rx_clk            ,input   wire            i_rx_reset          ,input   wire  [63:00]   i_rx_data           ,input   wire            i_rx_data_valid     ,input   wire  [01:00]   i_rx_header         ,input   wire            i_rx_headervalid    ,output  wire            m_axis_valid        ,output  wire            m_axis_last         ,output  wire  [63:00]   m_axis_data         ,output  wire  [07:00]   m_axis_keep         ,input   wire            m_axis_ready         
);localparam  P_FrameHeader_CONTROL = 2'b10;localparam  P_FrameHeader_DATA    = 2'b01;localparam  P_FLAG_START          = 8'h71;localparam  P_FLAG_END_0          = 8'h8E;localparam  P_FLAG_END_1          = 8'h99;localparam  P_FLAG_END_2          = 8'hA5;localparam  P_FLAG_END_3          = 8'hB2;localparam  P_FLAG_END_4          = 8'hC3;localparam  P_FLAG_END_5          = 8'hD4;localparam  P_FLAG_END_6          = 8'hE8;localparam  P_FLAG_END_7          = 8'hFF;
reg   [63:00]   r_i_rx_data           ;reg             r_i_rx_data_valid     ;reg   [01:00]   r_i_rx_header         ;reg             r_i_rx_headervalid    ;reg   [63:00]   r_d1_i_rx_data        ;reg             r_d1_i_rx_data_valid  ;reg   [01:00]   r_d1_i_rx_header      ;reg             r_d1_i_rx_headervalid ;reg   [63:00]   r_d2_i_rx_data        ;reg             r_d2_i_rx_data_valid  ;reg   [01:00]   r_d2_i_rx_header      ;reg             r_d2_i_rx_headervalid ;reg             r_receiving           ;reg             r_m_axis_valid        ;reg             r_m_axis_last         ;reg             r_d1_m_axis_last      ;reg   [63:00]   r_m_axis_data         ;reg   [07:00]   r_m_axis_keep         ;reg             ro_m_axis_valid       ;reg             ro_m_axis_last        ;reg   [63:00]   ro_m_axis_data        ;reg   [07:00]   ro_m_axis_keep        ;wire            w_data_frame             ;wire            w_sof                    ;wire            w_sof_pre                ;wire            w_eof                    ;wire            w_eof_pre                ;reg             r_d1_eof                 ;reg   [07:00]   r_eof_local              ;reg   [07:00]   r_eof_local_pre          ;reg   [07:00]   r_d1_eof_local           ;reg   [07:00]   r_d2_eof_local           ;reg             r_i_valid                ;reg             r_d1_i_valid             ;assign m_axis_valid = ro_m_axis_valid;  assign m_axis_last  = ro_m_axis_last ;  assign m_axis_data  = ro_m_axis_data ; assign m_axis_keep  = ro_m_axis_keep ; always @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginro_m_axis_data  <= 0;ro_m_axis_keep  <= 0;end else beginro_m_axis_data  <= (r_m_axis_valid)?{r_m_axis_data[07:00],r_m_axis_data[15:08],r_m_axis_data[23:16],r_m_axis_data[31:24],r_m_axis_data[39:32],r_m_axis_data[47:40],r_m_axis_data[55:48],r_m_axis_data[63:56]}:0;ro_m_axis_keep  <= (r_m_axis_valid)?{r_m_axis_keep[0],r_m_axis_keep[1],r_m_axis_keep[2],r_m_axis_keep[3],r_m_axis_keep[4],r_m_axis_keep[5],r_m_axis_keep[6],r_m_axis_keep[7]}:0;endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginro_m_axis_valid <= 0;end else if(m_axis_valid && m_axis_last) beginro_m_axis_valid <= 0;end else if(r_m_axis_valid) beginro_m_axis_valid <= 1'b1;end else beginro_m_axis_valid <= 0;endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginro_m_axis_last <= 0;end else if(m_axis_valid && m_axis_last) beginro_m_axis_last <= 1'b0;end else if(r_m_axis_last == 1'b1) beginro_m_axis_last <= 1'b1;
        endendalways @(posedge i_rx_clk) begin  r_d1_i_valid           <= r_i_valid           ;r_d1_eof_local         <= r_eof_local         ;r_d1_eof               <= w_eof               ;r_d1_m_axis_last       <= r_m_axis_last       ;endalways @(*) beginif(w_sof_pre||w_eof_pre||w_data_frame) beginr_i_valid <= 1'b1;end else beginr_i_valid <= 1'b0;
        endendalways @(*) beginif((r_d1_i_valid && r_receiving)||m_axis_last) beginr_m_axis_valid <= 1'b1;end else beginr_m_axis_valid <= 1'b0;
        endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginr_i_rx_data            <= 0;r_i_rx_data_valid      <= 0;r_i_rx_header          <= 0;r_i_rx_headervalid     <= 0;end else if(m_axis_last == 1'b1) beginr_i_rx_data            <= 0;r_i_rx_data_valid      <= 0;r_i_rx_header          <= 0;r_i_rx_headervalid     <= 0;  end else if(r_i_valid) beginr_i_rx_data            <= i_rx_data           ;r_i_rx_data_valid      <= i_rx_data_valid     ;r_i_rx_header          <= i_rx_header         ;r_i_rx_headervalid     <= i_rx_headervalid    ;end else beginr_i_rx_data            <= r_i_rx_data         ;r_i_rx_data_valid      <= r_i_rx_data_valid   ;r_i_rx_header          <= r_i_rx_header       ;r_i_rx_headervalid     <= r_i_rx_headervalid  ;endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginr_d1_i_rx_data         <= 0;r_d1_i_rx_data_valid   <= 0;r_d1_i_rx_header       <= 0;r_d1_i_rx_headervalid  <= 0;end else if(m_axis_last) beginr_d1_i_rx_data         <= 0;r_d1_i_rx_data_valid   <= 0;r_d1_i_rx_header       <= 0;r_d1_i_rx_headervalid  <= 0;end else if(r_d1_i_valid) beginr_d1_i_rx_data         <= r_i_rx_data         ;r_d1_i_rx_data_valid   <= r_i_rx_data_valid   ;r_d1_i_rx_header       <= r_i_rx_header       ;r_d1_i_rx_headervalid  <= r_i_rx_headervalid  ;end else beginr_d1_i_rx_data         <= r_d1_i_rx_data          ;r_d1_i_rx_data_valid   <= r_d1_i_rx_data_valid    ;r_d1_i_rx_header       <= r_d1_i_rx_header        ;r_d1_i_rx_headervalid  <= r_d1_i_rx_headervalid   ;endendassign  w_data_frame = (i_rx_header == P_FrameHeader_DATA)&&(i_rx_headervalid)&&(i_rx_data_valid);assign  w_sof     = (r_i_rx_header == P_FrameHeader_CONTROL)&&(r_i_rx_headervalid)&&(r_i_rx_data_valid)&&(r_i_rx_data[07:00] == P_FLAG_START);assign  w_sof_pre = (i_rx_header == P_FrameHeader_CONTROL)&&(i_rx_headervalid)&&(i_rx_data_valid)&&(i_rx_data[07:00] == P_FLAG_START);assign  w_eof = (r_i_rx_header == P_FrameHeader_CONTROL)&&(r_i_rx_headervalid)&&(r_i_rx_data_valid)&&((r_i_rx_data[07:00] ==  P_FLAG_END_0 )|| (r_i_rx_data[07:00] ==  P_FLAG_END_1 )||(r_i_rx_data[07:00] ==  P_FLAG_END_2 )|| (r_i_rx_data[07:00] ==  P_FLAG_END_3 )|| (r_i_rx_data[07:00] ==  P_FLAG_END_4 )|| (r_i_rx_data[07:00] ==  P_FLAG_END_5 )|| (r_i_rx_data[07:00] ==  P_FLAG_END_6 )|| (r_i_rx_data[07:00] ==  P_FLAG_END_7 ));assign  w_eof_pre = (i_rx_header == P_FrameHeader_CONTROL)&&(i_rx_headervalid)&&(i_rx_data_valid)&&((i_rx_data[07:00] ==  P_FLAG_END_0 )|| (i_rx_data[07:00] ==  P_FLAG_END_1 )||(i_rx_data[07:00] ==  P_FLAG_END_2 )|| (i_rx_data[07:00] ==  P_FLAG_END_3 )|| (i_rx_data[07:00] ==  P_FLAG_END_4 )|| (i_rx_data[07:00] ==  P_FLAG_END_5 )|| (i_rx_data[07:00] ==  P_FLAG_END_6 )|| (i_rx_data[07:00] ==  P_FLAG_END_7 ));always @(*) beginif((r_i_rx_header == P_FrameHeader_CONTROL)&&(r_i_rx_headervalid)&&(r_i_rx_data_valid)) begincase (r_i_rx_data[07:00])P_FLAG_END_0:r_eof_local <= 8;P_FLAG_END_1:r_eof_local <= 1;P_FLAG_END_2:r_eof_local <= 2;P_FLAG_END_3:r_eof_local <= 3;P_FLAG_END_4:r_eof_local <= 4;P_FLAG_END_5:r_eof_local <= 5;P_FLAG_END_6:r_eof_local <= 6;P_FLAG_END_7:r_eof_local <= 7;default: r_eof_local <= 0;endcaseend else beginr_eof_local <= 0;endendalways @(*) beginif((i_rx_header == P_FrameHeader_CONTROL)&&(i_rx_headervalid)&&(i_rx_data_valid)) begincase (i_rx_data[07:00])P_FLAG_END_0:r_eof_local_pre <= 8;P_FLAG_END_1:r_eof_local_pre <= 1;P_FLAG_END_2:r_eof_local_pre <= 2;P_FLAG_END_3:r_eof_local_pre <= 3;P_FLAG_END_4:r_eof_local_pre <= 4;P_FLAG_END_5:r_eof_local_pre <= 5;P_FLAG_END_6:r_eof_local_pre <= 6;P_FLAG_END_7:r_eof_local_pre <= 7;default: r_eof_local_pre <= 0;endcaseend else beginr_eof_local_pre <= 0;endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginr_receiving <= 0;end else if(r_d1_eof_local == 7 && r_d1_eof == 1'b1) begin  r_receiving <= 0;end else if(r_d1_eof_local == 6 && r_d1_eof == 1'b1) beginr_receiving <= 0;end else if(r_d1_eof_local == 5 && r_d1_eof == 1'b1) beginr_receiving <= 0;end else if(r_d1_eof_local == 4 && r_d1_eof == 1'b1) beginr_receiving <= 0;end else if(r_d1_eof_local == 3 && r_d1_eof == 1'b1) beginr_receiving <= 0;end else if(r_d1_eof_local == 2 && r_d1_eof == 1'b1) beginr_receiving <= 0;end else if(r_eof_local == 1 && w_eof == 1'b1) beginr_receiving <= 0;end else if(r_eof_local == 8 && w_eof == 1'b1) beginr_receiving <= 0;end else if(w_sof) beginr_receiving <= 1'b1;end else beginr_receiving <= r_receiving;endendalways @(*) beginif(r_d1_eof_local == 7 && r_d1_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_d1_eof_local == 6 && r_d1_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_d1_eof_local == 5 && r_d1_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_d1_eof_local == 4 && r_d1_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_d1_eof_local == 3 && r_d1_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_d1_eof_local == 2 && r_d1_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_eof_local == 1 && w_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else if(r_eof_local == 8 && w_eof == 1'b1) beginr_m_axis_last <= 1'b1;end else beginr_m_axis_last <= 1'b0;
        endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginr_m_axis_data <= 0;end else if(r_eof_local == 7 && w_eof == 1'b1) beginr_m_axis_data  <= {{2{8'h0}},r_i_rx_data[63-:48]};end else if(r_eof_local_pre == 7 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local == 6 && w_eof == 1'b1) beginr_m_axis_data  <= {{3{8'h0}},r_i_rx_data[55-:40]};end else if(r_eof_local_pre == 6 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local == 5 && w_eof == 1'b1) beginr_m_axis_data  <= {{4{8'h0}},r_i_rx_data[47-:32]};end else if(r_eof_local_pre == 5 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local == 4 && w_eof == 1'b1) beginr_m_axis_data  <= {{5{8'h0}},r_i_rx_data[39-:24]};end else if(r_eof_local_pre == 4 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local == 3 && w_eof == 1'b1) beginr_m_axis_data  <= {{6{8'h0}},r_i_rx_data[31-:16]};end else if(r_eof_local_pre == 3 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local == 2 && w_eof == 1'b1) beginr_m_axis_data  <= {{7{8'h0}},r_i_rx_data[23-:08]};end else if(r_eof_local_pre == 2 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local_pre == 1 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {i_rx_data[15:08],r_i_rx_data[63-:56]};end else if(r_eof_local_pre == 8 && w_eof_pre == 1'b1) beginr_m_axis_data  <= {{8'h0},r_i_rx_data[63-:56]};end else beginr_m_axis_data  <= {i_rx_data[07:00],r_i_rx_data[63-:56]};endendalways @(posedge i_rx_clk) beginif(i_rx_reset == 1'b1) beginr_m_axis_keep <= 8'b0000_0000;end else if(r_eof_local == 7 && w_eof == 1'b1) beginr_m_axis_keep <= 8'b0011_1111;end else if(r_eof_local == 6 && w_eof == 1'b1) beginr_m_axis_keep <= 8'b0001_1111;end else if(r_eof_local == 5 && w_eof == 1'b1) beginr_m_axis_keep <= 8'b0000_1111;end else if(r_eof_local == 4 && w_eof == 1'b1) beginr_m_axis_keep <= 8'b0000_0111;end else if(r_eof_local == 3 && w_eof == 1'b1) beginr_m_axis_keep <= 8'b0000_0011;end else if(r_eof_local == 2 && w_eof == 1'b1) beginr_m_axis_keep <= 8'b0000_0001;end else if(r_eof_local_pre == 1 && w_eof_pre == 1'b1) beginr_m_axis_keep <= 8'b1111_1111;end else if(r_eof_local_pre == 8 && w_eof_pre == 1'b1) beginr_m_axis_keep <= 8'b0111_1111;
        endendendmodule
View Code

TX:

只需要在gearbox需要暂停的时候停止即可;

module gt_phy_tx (input   wire            i_tx_clk            ,input   wire            i_tx_reset          ,output  wire  [63:00]   o_tx_data           ,          output  wire  [01:00]   o_tx_header         ,    output  wire  [06:00]   o_tx_sequence       ,   input   wire            s_axis_valid        ,input   wire            s_axis_last         ,input   wire  [63:00]   s_axis_data         ,input   wire  [07:00]   s_axis_keep         ,output  wire            s_axis_ready            
);localparam  P_FrameHeader_CONTROL = 2'b10;localparam  P_FrameHeader_DATA    = 2'b01;localparam  P_FLAG_IDLE           = 8'h17;localparam  P_FLAG_START          = 8'h71;localparam  P_FLAG_END_0          = 8'h8E;localparam  P_FLAG_END_1          = 8'h99;localparam  P_FLAG_END_2          = 8'hA5;localparam  P_FLAG_END_3          = 8'hB2;localparam  P_FLAG_END_4          = 8'hC3;localparam  P_FLAG_END_5          = 8'hD4;localparam  P_FLAG_END_6          = 8'hE8;localparam  P_FLAG_END_7          = 8'hFF;localparam  P_ST_INIT             = 1;localparam  P_ST_IDLE             = 2;localparam  P_ST_FRAMESTART       = 3;localparam  P_ST_DATALOADS        = 4;localparam  P_ST_END1             = 5;localparam  P_ST_END2             = 6;reg             r_s_axis_ready      ;reg             r_s_axis_valid      ;reg   [07:00]   r_s_axis_keep       ;reg   [07:00]   r_st_current        ;    reg   [07:00]   r_st_next           ;   reg             r1_w_data_wr_en     ;reg             r2_w_data_wr_en     ; reg             r3_w_data_wr_en     ;      reg   [15:00]   r_valid_cnt         ;wire            w_data_wr_en        ; wire  [63:00]   w_data_wr_data      ;reg             r_data_rd_en        ;wire  [63:00]   w_data_rd_data      ;wire  [63:00]   w_data_rd_data_conv ;reg   [63:00]   r1_data_rd_data     ;reg   [63:00]   r2_data_rd_data     ;wire            w_full              ;wire            w_empty             ;wire  [09:00]   w_data_count        ;reg   [05:00]   r_o_tx_sequence     ;wire            w_sequence_check    ;wire            w_send_valid        ;reg   [15:00]   r_send_cnt          ;reg   [01:00]   r_o_tx_header       ;       reg   [63:00]   r_o_tx_data         ;assign  w_data_wr_data = s_axis_data;assign  w_data_wr_en   = (s_axis_valid)&&(s_axis_ready);assign  w_data_rd_data_conv = {w_data_rd_data[07-:8],w_data_rd_data[15-:8],w_data_rd_data[23-:8],w_data_rd_data[31-:8],w_data_rd_data[39-:8],w_data_rd_data[47-:8],w_data_rd_data[55-:8],w_data_rd_data[63-:8]};assign  o_tx_sequence = {1'b0,r_o_tx_sequence[05:00]};assign  o_tx_header   = r_o_tx_header;assign  o_tx_data     = r_o_tx_data;assign  s_axis_ready  = r_s_axis_ready;assign  w_sequence_check = r_o_tx_sequence == 31;assign  w_send_valid = (r_data_rd_en)&&(!w_sequence_check);always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_o_tx_sequence <= 0;end else if(r_o_tx_sequence == 'd32) beginr_o_tx_sequence <= 0;end else beginr_o_tx_sequence <= r_o_tx_sequence + 1'b1;
        endend   Gt_txfifo Gt_txfifo (.clk            ( i_tx_clk          ), // input wire clk.srst           ( i_tx_reset        ), // input wire srst.din            ( w_data_wr_data    ), // input wire [63 : 0] din.wr_en          ( w_data_wr_en      ), // input wire wr_en.rd_en          ( w_send_valid      ), // input wire rd_en.dout           ( w_data_rd_data    ), // output wire [63 : 0] dout.full           ( w_full            ), // output wire full.empty          ( w_empty           ), // output wire empty.data_count     ( w_data_count      )  // output wire [9 : 0] data_count
    );always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_o_tx_header  <= 2'b00;r_o_tx_data    <= 0;end else if(r_st_current == P_ST_FRAMESTART && w_send_valid) beginr_o_tx_header  <= P_FrameHeader_CONTROL;r_o_tx_data    <= {w_data_rd_data_conv[55:0],P_FLAG_START};end else if(r_st_current == P_ST_DATALOADS && w_send_valid) beginr_o_tx_header  <= P_FrameHeader_DATA;r_o_tx_data    <= {w_data_rd_data_conv[55:0],r1_data_rd_data[63-:8]};end else if(r_st_current == P_ST_END1 && w_send_valid) begincase (r_s_axis_keep)8'b1111_1111:beginr_o_tx_header <= P_FrameHeader_DATA;r_o_tx_data   <= {w_data_rd_data_conv[55:00],r1_data_rd_data[63-:8]};end 8'b1111_1110:beginr_o_tx_header <= P_FrameHeader_DATA;r_o_tx_data   <= {w_data_rd_data_conv[55:00],r1_data_rd_data[63-:8]};end 8'b1111_1100:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {w_data_rd_data_conv[47:00],r1_data_rd_data[63-:8],P_FLAG_END_7};end 8'b1111_1000:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{1{7'h16}},1'b0,w_data_rd_data_conv[39:00],r1_data_rd_data[63-:8],P_FLAG_END_6};end 8'b1111_0000:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{2{7'h16}},2'b0,w_data_rd_data_conv[31:00],r1_data_rd_data[63-:8],P_FLAG_END_5};end 8'b1110_0000:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{3{7'h16}},3'b0,w_data_rd_data_conv[23:00],r1_data_rd_data[63-:8],P_FLAG_END_4};end 8'b1100_0000:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{4{7'h16}},4'b0,w_data_rd_data_conv[15:00],r1_data_rd_data[63-:8],P_FLAG_END_3};end 8'b1000_0000:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{5{7'h16}},5'b0,w_data_rd_data_conv[07:00],r1_data_rd_data[63-:8],P_FLAG_END_2};end default: beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{8{7'h16}},P_FLAG_IDLE};
                    end endcaseend else if(r_st_current == P_ST_END2) begincase (r_s_axis_keep)8'b1111_1111:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{6{7'h16}},6'b0,r1_data_rd_data[63-:8],P_FLAG_END_1};end 8'b1111_1110:beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{7{7'h16}},7'b0,P_FLAG_END_0};end default: beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{8{7'h16}},P_FLAG_IDLE};
                    end endcaseend else beginr_o_tx_header <= P_FrameHeader_CONTROL;r_o_tx_data   <= {{8{7'h16}},P_FLAG_IDLE};
        endend always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr1_data_rd_data <=  0;end else if(w_send_valid) beginr1_data_rd_data <= w_data_rd_data_conv;endend always @(posedge i_tx_clk) beginr1_w_data_wr_en <= w_data_wr_en;r2_w_data_wr_en <= r1_w_data_wr_en;r3_w_data_wr_en <= r2_w_data_wr_en;r2_data_rd_data <= r1_data_rd_data;end  always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_data_rd_en <= 1'b0;end else if(w_send_valid == 1'b1 && r_send_cnt == r_valid_cnt - 1'b1) beginr_data_rd_en <= 1'b0;end else if(r_st_current == P_ST_FRAMESTART) beginr_data_rd_en <= 1'b1;end else beginr_data_rd_en <= r_data_rd_en;endend always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_send_cnt <= 0;end else if(w_send_valid == 1'b1 && r_send_cnt == r_valid_cnt - 1'b1) beginr_send_cnt <= 0;end else if(w_send_valid == 1'b1) beginr_send_cnt <= r_send_cnt + 1'b1;
        endend  always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_valid_cnt <= 0;end else if(w_send_valid == 1'b1 && r_send_cnt == r_valid_cnt - 1'b1) beginr_valid_cnt <= 0;end else if(w_data_wr_en == 1'b1) beginr_valid_cnt <= r_valid_cnt + 1'b1;end else beginr_valid_cnt <= r_valid_cnt;endendalways @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_st_current <= P_ST_INIT;            end else beginr_st_current <= r_st_next;endend   always @(*) begincase (r_st_current)P_ST_INIT:beginr_st_next <= P_ST_IDLE;end P_ST_IDLE:beginif(r3_w_data_wr_en == 1) beginr_st_next <= P_ST_FRAMESTART;end else beginr_st_next <= P_ST_IDLE;endendP_ST_FRAMESTART:beginif(w_send_valid) beginr_st_next <= P_ST_DATALOADS;end else beginr_st_next <= P_ST_FRAMESTART;endendP_ST_DATALOADS:beginif(w_send_valid == 1'b1 && r_send_cnt == r_valid_cnt - 2 ) beginr_st_next <= P_ST_END1;end else beginr_st_next <= P_ST_DATALOADS;endendP_ST_END1:beginif(w_send_valid) begincase (r_s_axis_keep)8'b1111_1111: r_st_next <= P_ST_END2;8'b1111_1110: r_st_next <= P_ST_END2;8'b1111_1100: r_st_next <= P_ST_IDLE;8'b1111_1000: r_st_next <= P_ST_IDLE;8'b1111_0000: r_st_next <= P_ST_IDLE;8'b1110_0000: r_st_next <= P_ST_IDLE;8'b1100_0000: r_st_next <= P_ST_IDLE;8'b1000_0000: r_st_next <= P_ST_IDLE;default: r_st_next <= P_ST_INIT;endcaseend else beginr_st_next <= P_ST_END1;endendP_ST_END2:beginr_st_next <= P_ST_IDLE;enddefault:beginr_st_next <= P_ST_INIT;endendcaseend always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_s_axis_keep <= 0;end else if(s_axis_last) beginr_s_axis_keep <= s_axis_keep;endend  always @(posedge i_tx_clk) beginif(i_tx_reset == 1'b1) beginr_s_axis_ready <= 1'b1;end else if(s_axis_last) beginr_s_axis_ready <= 1'b0;end else if(r_st_current == P_ST_IDLE) beginr_s_axis_ready <= 1'b1;end else beginr_s_axis_ready <= r_s_axis_ready;endend       
endmodule
View Code

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/779213.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

esp32安装circuitpython

安装Thonny https://thonny.org/ 在Thonny中安装circuitpython 在配置解释器中选择circuitython然后点击右下角“安装或更新...“variant这里我选择了 DOIT esp32 Development Board(试过其他的一些个,不知道为什么安装完之后会无限重启,所以最后选择了这个) 烧录完之后,重…

Linux内核学习—— 1内核体系结构

一 内核体系结构 1内核模式与体系结构 2内核中断概括 3进程管理概括 二 内核源码结构 三 内核引导程序 操作系统结构: 用户应用程序 操作系统服务层 内核(文件系统,内存管理,进程管理,驱动管理) 硬件系统 驱动 操作系统工作方式:把做操作系统从用户态切换到内核态(用户应…

设置windows系统下的tomcat开机自启

设置前的准备工作(配置系统环境变量) 新增CATALINA_HOME变量,变量值为tomcat的安装路径在Path中添加: %CATALINA_HOME%\bin结合安装版本问题,分正常安装版本tomcat和免安装tomcat(无service.bat)两种情况。 一、正常安装版本(tomcat安装文件有service.bat文件) 说明:安装…

基于vscode搭建freertos环境

前言 目前网上windows仿真freertos的资料都是比较久远的,不太适合现有的开发,因此重新整理了一下资料. 目标: 使用Vscode进行FreeRTOS开发和仿真. 关键词: freertos, vscode,llvm,cmake,windows 环境配置 编译器目前使用的是llvm-MinGW-msvcrt:Releases mstorsjo/llvm-mingw (…

QWen2-72B-Instruct模型安装部署过程

最近在给我们的客户私有化部署我们的TorchV系统,客户给的资源足够充裕,借此机会记录下部署千问72B模型的过程,分享给大家! 一、基础信息操作系统:Ubuntu 22.04.3 LTSGPU: A800(80GB) * 8内存:1TB二、软件信息 Python: 3.10 Pytorch:2.3.0 Transformers:4.43.0 vLLM:0.…

塑胶件的结构设计:超声波焊接篇(中)

04 超声波焊接效果的影响因素 一、塑胶材料因素 上篇已经介绍的适合超声波焊接的材料选择,一般情况下两种材料满足Tg或熔点接近、化学相容性良好和熔体流动指数接近这三个条件,基本可认为是可焊接的,但需要注意以下几点: 1、热塑性塑胶又分为非结晶性(也叫无定形)塑胶和…

简易秀投票解决方案功能展示与案例分析

简易秀投票小程序作为一款功能丰富、操作简便的投票工具,其功能案例分析可以从以下几个方面进行: 一、功能概述 简易秀投票小程序支持多种投票类型和丰富的设置选项,主要包括: 1.多样化的投票类型:支持视频投票、音频投票、图文投票、文字投票等多种类型,满足不同场景下的…

周易智慧小程序:功能特色与用户体验案例分析

一、引言 随着人们对传统文化的兴趣日益增长,结合现代科技手段的周易智慧小程序应运而生。这类小程序不仅传承了《周易》的古老智慧,还通过创新的功能设计和用户体验优化,让更多人能够轻松接触并理解周易文化。二、功能特色分析 智能化占卜系统: 1.采用先进的人工智能算法,…

鸿蒙应用开发——新建一个项目

鸿蒙应用开发——新建一个项目鸿蒙应用开发——新建一个项目 一、点击Files->New->Create Project二、选择项目属性(Application是应用,Atomic Service是元服务开发)三、NEXT,NEXT设置相关信息四、Finish时光宓宓,岁月静好。 来自戈小戈,转载请注明原文链接:https…

Labview程序内保留小数位数

Labview程序内保留小数位数 程序如图:举例如下:

Cisco Nexus Dashboard 3.2(1e) - 云和数据中心网络管理软件

Cisco Nexus Dashboard 3.2(1e) - 云和数据中心网络管理软件Cisco Nexus Dashboard 3.2(1e) - 云和数据中心网络管理软件 跨数据中心和云实现集中配置、运行和分析 请访问原文链接:https://sysin.org/blog/cisco-nexus-dashboard/,查看最新版。原创作品,转载请保留出处。 Ci…

Nessus Professional 10.8.0 Auto Installer for RHEL 9/AlmaLinux 9/Rocky Linux 9

Nessus Professional 10.8.0 Auto Installer for RHEL 9/AlmaLinux 9/Rocky Linux 9Nessus Professional 10.8.0 Auto Installer for RHEL 9/AlmaLinux 9/Rocky Linux 9 发布 Nessus 试用版自动化安装程序,支持 macOS Sonoma、RHEL 9 和 Ubuntu 24.04 请访问原文链接:https:/…