⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctc_tx_fsm.v

📁 上传的是WIMAX系统中
💻 V
📖 第 1 页 / 共 2 页
字号:
        WT2:
            if(~|ctc_fifo2_rddat[1:0])                            
                p_len_next = (ctc_fifo2_rddat[15:0]>>2) + 16'h2;
            else                                              
                p_len_next = (ctc_fifo2_rddat[15:0]>>2) + 16'h3;
        WT3:
            if(~|ctc_fifo3_rddat[1:0])                          
                p_len_next = (ctc_fifo3_rddat[15:0]>>2) + 16'h2;
            else                                              
                p_len_next = (ctc_fifo3_rddat[15:0]>>2) + 16'h3;
        default: begin
            r0_cnt_next = r0_cnt;
            r1_cnt_next = r1_cnt;
            r2_cnt_next = r2_cnt;
            p_len_next  = p_len;
        end 
    endcase
end 
*/
always @(posedge sys_clk or negedge reset_b) begin
    if (~reset_b) begin
        r0_cnt <= 16'b0;
        r1_cnt <= 16'b0;
        r2_cnt <= 16'b0;
        p_len  <= 16'b0;
    end
    else
        case(st_current)
            RD_FIFO1:
                r0_cnt <= 16'b0;
            WR_FIFO1:
                r0_cnt <= r0_cnt + 1'b1;
            RD_FIFO2:
                r1_cnt <= 16'b0;
            WR_FIFO2:
                r1_cnt <= r1_cnt + 1'b1;
            RD_FIFO3:
                r2_cnt <= 16'b0;
            WR_FIFO3:
                r2_cnt <= r2_cnt + 1'b1;
            WT1:
                if(~|ctc_fifo1_rddat[1:0])                          
                    p_len <= (ctc_fifo1_rddat[15:0]>>2) + 16'h2;
                else                                           
                    p_len <= (ctc_fifo1_rddat[15:0]>>2) + 16'h3; 
            WT2:
                if(~|ctc_fifo2_rddat[1:0])                            
                    p_len <= (ctc_fifo2_rddat[15:0]>>2) + 16'h2;
                else                                         
                    p_len <= (ctc_fifo2_rddat[15:0]>>2) + 16'h3;
            WT3:
                if(~|ctc_fifo3_rddat[1:0])                          
                    p_len <= (ctc_fifo3_rddat[15:0]>>2) + 16'h2;
                else                                         
                    p_len <= (ctc_fifo3_rddat[15:0]>>2) + 16'h3;
            default: begin
                r0_cnt <= r0_cnt;
                r1_cnt <= r1_cnt;
                r2_cnt <= r2_cnt;
                p_len  <= p_len;
            end
    endcase
end     
        

 
reg [31:0]  p_data0;
always @(posedge sys_clk or negedge reset_b) begin
    if ( ~reset_b )
        p_data0 <= 32'b0;
    else if ( st_current == WT1 )
        p_data0 <= ctc_fifo1_rddat[31:0];
    else if ( st_current == WT2 )
        p_data0 <= ctc_fifo2_rddat[31:0];
    else if ( st_current == WT3 )
        p_data0 <= ctc_fifo3_rddat[31:0];
end
                  

///**************************************************************************
///生成ctc_fifo1的读请求信号ctc_fifo1_rdreq
///Fang.yongzhong
///**************************************************************************
always @(posedge sys_clk or negedge reset_b) begin
    if(!reset_b)
        ctc_fifo1_rdreq <= 1'b0;
    else
        case(st_next)
            RD_FIFO1:
                ctc_fifo1_rdreq <= 1'b1;
            WR_FIFO1:
                if(r0_cnt<(p_len-2'd2) & !ctc_fifo1_empty)
                    ctc_fifo1_rdreq <= 1'b1;
                else
                    ctc_fifo1_rdreq <= 1'b0;
            default:
                ctc_fifo1_rdreq <= 1'b0;
        endcase
end
///**************************************************************************
///生成ctc_fifo2的读请求信号ctc_fifo2_rdreq
///Fang.yongzhong
///**************************************************************************
always @(posedge sys_clk or negedge reset_b) begin
    if(!reset_b)
        ctc_fifo2_rdreq <= 1'b0;
    else
        case(st_next)
            RD_FIFO2:
                ctc_fifo2_rdreq <= 1'b1;
            WR_FIFO2:
                if(r1_cnt<(p_len-2'd2) & !ctc_fifo2_empty)
                    ctc_fifo2_rdreq <= 1'b1;
                else
                    ctc_fifo2_rdreq <= 1'b0;
            default:
                ctc_fifo2_rdreq <= 1'b0;
        endcase
end
///**************************************************************************
///生成ctc_fifo3的读请求信号ctc_fifo3_rdreq
///Fang.yongzhong
///**************************************************************************
always @(posedge sys_clk or negedge reset_b) begin
    if(!reset_b)
        ctc_fifo3_rdreq <= 1'b0;
    else
        case(st_next)
            RD_FIFO3:
                ctc_fifo3_rdreq <= 1'b1;
            WR_FIFO3:
                if(r2_cnt<(p_len-2'd2) & !ctc_fifo3_empty)
                    ctc_fifo3_rdreq <= 1'b1;
                else
                    ctc_fifo3_rdreq <= 1'b0;
            default:
                ctc_fifo3_rdreq <= 1'b0;
        endcase
end
      
reg core1_poll;
reg core2_poll;
reg core3_poll;
    //生成ctc_post_fifo接口信号
always @(posedge sys_clk or negedge reset_b) begin
    if(!reset_b) begin
         wr_post_ctc_fifo     <= 1'b0;
         dat_wr_post_ctc_fifo <= 32'b0;
         eop_wr_post_ctc_fifo <= 1'b0;
         core1_poll           <= 1'b0;
         core2_poll           <= 1'b0;
         core3_poll           <= 1'b0;
    end
    else if (st_current==WR_FIFO1 && (~|r0_cnt)) begin
        if(!full_post_ctc_fifo)
            wr_post_ctc_fifo <= 1'b1;
        else
            wr_post_ctc_fifo <= 1'b0;
        dat_wr_post_ctc_fifo <= p_data0;
        eop_wr_post_ctc_fifo <= 1'b0;
    end
    else if ((st_next==WR_FIFO1) && (r0_cnt>0)) begin
        dat_wr_post_ctc_fifo <= ctc_fifo1_rddat;
        if(!full_post_ctc_fifo)
            wr_post_ctc_fifo <= 1'b1;
        else
            wr_post_ctc_fifo <= 1'b0;
        if(r0_cnt==p_len-1'b1) begin
            core1_poll <= 1'b1;
            eop_wr_post_ctc_fifo <= 1'b1;
        end
        else begin
            core1_poll <= 1'b0;
            eop_wr_post_ctc_fifo <= 1'b0;
        end
    end
    else if(st_current==WR_FIFO2 && (~|r1_cnt)) begin
        if(!full_post_ctc_fifo)
            wr_post_ctc_fifo <= 1'b1;
        else
            wr_post_ctc_fifo <= 1'b0;
        dat_wr_post_ctc_fifo <= p_data0;
        eop_wr_post_ctc_fifo <= 1'b0;
    end
    else if((st_next==WR_FIFO2) && (r1_cnt>0)) begin
        dat_wr_post_ctc_fifo <= ctc_fifo2_rddat;
        if(!full_post_ctc_fifo)
            wr_post_ctc_fifo <= 1'b1;
        else
            wr_post_ctc_fifo <= 1'b0;
        if(r1_cnt==p_len-1'b1) begin
            core2_poll <= 1'b1;
            eop_wr_post_ctc_fifo <= 1'b1;
        end
        else begin
            core2_poll <= 1'b1;
            eop_wr_post_ctc_fifo <= 1'b0;
        end
    end
    else if (st_current==WR_FIFO3 && (~|r2_cnt)) begin
        if(!full_post_ctc_fifo)
            wr_post_ctc_fifo <= 1'b1;
        else
            wr_post_ctc_fifo <= 1'b0;
        dat_wr_post_ctc_fifo <= p_data0;
        eop_wr_post_ctc_fifo <= 1'b0;
    end
    else if ((st_next==WR_FIFO3) && (r2_cnt>0)) begin
        dat_wr_post_ctc_fifo <= ctc_fifo3_rddat;
        if(!full_post_ctc_fifo)
            wr_post_ctc_fifo <= 1'b1;
        else
            wr_post_ctc_fifo <= 1'b0;
        if(r2_cnt==p_len-1'b1) begin
           core3_poll <= 1'b1;
           eop_wr_post_ctc_fifo <= 1'b1;
        end
        else begin
           core3_poll <= 1'b1;
           eop_wr_post_ctc_fifo <= 1'b0;
        end
    end
    else begin
        wr_post_ctc_fifo     <= 1'b0;
        dat_wr_post_ctc_fifo <= dat_wr_post_ctc_fifo;
        eop_wr_post_ctc_fifo <= 1'b0;
        core1_poll           <= 1'b0;
        core2_poll           <= 1'b0;
        core3_poll           <= 1'b0;
    end
end 

ctc_tx_arb ctc_tx_arb 
(
    .ctc_fifo1_empty         (ctc_fifo1_empty         ),
    .core1_poll              (core1_poll              ),
    .core1_gnt               (core1_gnt               ),
    .ctc_fifo2_empty         (ctc_fifo2_empty         ),
    .core2_poll              (core2_poll              ),
    .core2_gnt               (core2_gnt               ),
    .ctc_fifo3_empty         (ctc_fifo3_empty         ),
    .core3_poll              (core3_poll              ),
    .core3_gnt               (core3_gnt               ),
    .wrusedword_post_ctc_fifo(wrusedword_post_ctc_fifo),
    .sys_clk                 (sys_clk                 ),
    .reset_b                 (reset_b                 )
);


endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -