单AXI总线多通道仲裁状态机V2.0(代码+tb文件)

9 篇文章 0 订阅
5 篇文章 0 订阅

纯做记录;

暂不放完。

参考:【数字IC设计】循环优先级仲裁器 的 verilog实现(原理、源码、仿真)_轮询仲裁器verilog代码-CSDN博客

V1.0:修好了有效在高位的问题,增加了状态机方便控制AXI接口地址等;

循环优先级仲裁~位屏蔽仲裁算法_循环优先级仲裁器-CSDN博客

module  Aribe_LoopPrior_State_v1 (
    input   wire            I_clk                       ,
    input   wire            I_Rst_n                     ,
    //Port
    //ch0
    input   wire            I_ch0_req                   ,
    input   wire            I_ch0_start                 ,
    input   wire            I_ch0_end                   ,
    output  wire            O_ch0_vaild                 ,
    //ch1
    input   wire            I_ch1_req                   ,
    input   wire            I_ch1_start                 ,
    input   wire            I_ch1_end                   ,
    output  wire            O_ch1_vaild                 ,
    //ch2
    input   wire            I_ch2_req                   ,
    input   wire            I_ch2_start                 ,
    input   wire            I_ch2_end                   ,
    output  wire            O_ch2_vaild                 ,
    //ch3
    input   wire            I_ch3_req                   ,
    input   wire            I_ch3_start                 ,
    input   wire            I_ch3_end                   ,
    output  wire            O_ch3_vaild                 ,
    //AXI Port
);

    //-----------------------------------------------------------------//
        localparam  state_idle  = 10'b0000_0000_01;
        localparam  state_aribe = 10'b0000_0000_10;

        localparam  state_ch0_0 = 10'b0000_0001_00;
        localparam  state_ch0_1 = 10'b0000_0010_00;

        localparam  state_ch1_0 = 10'b0000_0100_00;
        localparam  state_ch1_1 = 10'b0000_1000_00;

        localparam  state_ch2_0 = 10'b0001_0000_00;
        localparam  state_ch2_1 = 10'b0010_0000_00;

        localparam  state_ch3_0 = 10'b0100_0000_00;
        localparam  state_ch3_1 = 10'b1000_0000_00;
`timescale  1ns / 1ps

module tb_Aribe_LoopPrior_State_v1;

// Aribe_LoopPrior_State_v1 Parameters
parameter PERIOD  = 10;


// Aribe_LoopPrior_State_v1 Inputs
reg   I_clk                                ;
reg   I_Rst_n                              ;
reg   I_ch0_req                            ;
reg   I_ch0_start                          ;
reg   I_ch0_end                            ;
reg   I_ch1_req                            ;
reg   I_ch1_start                          ;
reg   I_ch1_end                            ;
reg   I_ch2_req                            ;
reg   I_ch2_start                          ;
reg   I_ch2_end                            ;
reg   I_ch3_req                            ;
reg   I_ch3_start                          ;
reg   I_ch3_end                            ;

// Aribe_LoopPrior_State_v1 Outputs
wire  O_ch0_vaild                          ;
wire  O_ch1_vaild                          ;
wire  O_ch2_vaild                          ;
wire  O_ch3_vaild                          ;

initial begin
    I_clk = 0;
end
always #(PERIOD/2) I_clk = ~ I_clk;

initial begin
    I_Rst_n <= 1'b0;
    repeat (100) @(posedge I_clk);
    I_Rst_n <= 1'b1;
end

initial begin  
    repeat (10) @(posedge I_clk);
    I_ch0_start <= 1'b0;
    I_ch0_end   <= 1'b0;
    I_ch1_start <= 1'b0;
    I_ch1_end   <= 1'b0;
    I_ch2_start <= 1'b0;
    I_ch2_end   <= 1'b0;
    I_ch3_start <= 1'b0;
    I_ch3_end   <= 1'b0;
    {I_ch3_req, I_ch2_req, I_ch1_req, I_ch0_req} <= 4'b0000;
    @(posedge I_Rst_n);
    {I_ch3_req, I_ch2_req, I_ch1_req, I_ch0_req} <= 4'b1011;
    repeat (1) @(posedge I_clk);
    {I_ch3_req, I_ch2_req, I_ch1_req, I_ch0_req} <= 4'b0000;
    @(posedge O_ch0_vaild);
    repeat (2) @(posedge I_clk);
    I_ch0_start <= 1'b1;
    repeat (1) @(posedge I_clk);
    I_ch0_start <= 1'b0;
    repeat (64) @(posedge I_clk);
    I_ch0_end <= 1'b1;
    repeat (1) @(posedge I_clk);
    I_ch0_end <= 1'b0;
    repeat (64) @(posedge I_clk); 
    {I_ch3_req, I_ch2_req, I_ch1_req, I_ch0_req} <= 4'b1001;
    repeat (1) @(posedge I_clk);
    {I_ch3_req, I_ch2_req, I_ch1_req, I_ch0_req} <= 4'b0000;
    @(posedge O_ch3_vaild);
    repeat (2) @(posedge I_clk);
    I_ch3_start <= 1'b1;
    repeat (1) @(posedge I_clk);
    I_ch3_start <= 1'b0;
    repeat (64) @(posedge I_clk);
    I_ch3_end <= 1'b1;
    repeat (1) @(posedge I_clk);
    I_ch3_end <= 1'b0;
    repeat (64) @(posedge I_clk); 
end

Aribe_LoopPrior_State_v1  u_Aribe_LoopPrior_State_v1 (
    .I_clk                   ( I_clk         ),
    .I_Rst_n                 ( I_Rst_n       ),
    .I_ch0_req               ( I_ch0_req     ),
    .I_ch0_start             ( I_ch0_start   ),
    .I_ch0_end               ( I_ch0_end     ),
    .I_ch1_req               ( I_ch1_req     ),
    .I_ch1_start             ( I_ch1_start   ),
    .I_ch1_end               ( I_ch1_end     ),
    .I_ch2_req               ( I_ch2_req     ),
    .I_ch2_start             ( I_ch2_start   ),
    .I_ch2_end               ( I_ch2_end     ),
    .I_ch3_req               ( I_ch3_req     ),
    .I_ch3_start             ( I_ch3_start   ),
    .I_ch3_end               ( I_ch3_end     ),

    .O_ch0_vaild             ( O_ch0_vaild   ),
    .O_ch1_vaild             ( O_ch1_vaild   ),
    .O_ch2_vaild             ( O_ch2_vaild   ),
    .O_ch3_vaild             ( O_ch3_vaild   )
);
endmodule

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值