集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2902|回复: 2

一个简单的总线轮询仲裁器Verilog实现

[复制链接]
ccs 发表于 2010-5-14 06:07:33 | 显示全部楼层 |阅读模式
// Verilog Module demo1_lib.bus_arbitor.arch_name

//
// Created:
//          by - Newhand
//          in - Shanghai ZhangJiang
//          at - 20:39:41 2003-12-03
// using Mentor Graphics HDL Designer(TM)
//
///////////////////////////////////////////////////////////
// Discription:
// Bus Polling Arbitor (BPA)
// 总线上挂3个信号A,B,C,仲裁信号grant[1:0]。
// grant[1:0]=2’b00   A获得总线
// grant[1:0]=2’b01   B获得总线
// grant[1:0]=2’b10   C获得总线
// 总线轮询算法a.如果当前只有一个信号请求,则处理.
// b.如果没有请求,那么A获得总线.
// c.如果同时有多个信号请求,考虑上一个请求信号,
// 如果上一个请求信号是A,那么轮询的是BCA,
// 如果上一个请求信号是B,那么轮询的是CAB,
// 如果上一个请求信号是C,那么轮询的是ABC
//////////////////////////////////////////////////////////
`resetall
`timescale 1ns/10ps
module bus_arbitor(clk_i, en_i, sig_a_i, sig_b_i, sig_c_i, grant_o);
// I/O definition
input      clk_i;
input      en_i;
input      sig_a_i;
input      sig_b_i;
input      sig_c_i;
output   [1:0] grant_o;
// register definition
reg   [1:0] grant_o;
reg  [1:0] ls;
// parameter definition
parameter   s_null = 'd0,
           s_a    = 'd1,
           s_b    = 'd2,
           s_c    = 'd3,
           s_ab   = 'd4,
           s_bc   = 'd5,
           s_ac   = 'd6,
           s_abc  = 'd7;
//module part and FSM
always @(posedge clk_i or negedge en_i)
if(!en_i)// bus disable when negtive en_i
begin
grant_o <= 2'b11;
//cs <= s_null;
ls <= s_null;
end
else
begin
case({sig_a_i, sig_b_i, sig_c_i})// bus enable with FSM
  s_null:
     begin
        grant_o <= 2'b00;
        ls <= s_a;
     end
  s_a:
     begin
        grant_o <= 2'b00;
        ls <= s_a;
     end
  s_b:
     begin
        grant_o <= 2'b01;
        ls <= s_b;
     end
  s_c:
     begin
        grant_o <= 2'b10;
        ls <= s_c;
     end
  s_ab:
     case(ls)// feedback MUX configured
        s_a: begin grant_o <= 2'b01; ls <= s_b; end
        s_b: begin grant_o <= 2'b00; ls <= s_a; end
        s_c: begin grant_o <= 2'b00; ls <= s_a; end
     endcase
  s_bc:
     case(ls)
        s_a: begin grant_o <= 2'b01; ls <= s_b; end
        s_b: begin grant_o <= 2'b10; ls <= s_c; end
        s_c: begin grant_o <= 2'b01; ls <= s_b; end
     endcase
  s_ac:
     case(ls)
        s_a: begin grant_o <= 2'b10; ls <= s_c; end
        s_b: begin grant_o <= 2'b10; ls <= s_c; end
        s_c: begin grant_o <= 2'b00; ls <= s_a; end
     endcase
  s_abc:
     case(ls)
        s_a: begin grant_o <= 2'b01; ls <= s_b; end
        s_b: begin grant_o <= 2'b10; ls <= s_c; end
        s_c: begin grant_o <= 2'b00; ls <= s_a; end
     endcase
  default:
  begin grant_o <= 2'b00; ls <= s_a; end
            
endcase
end
endmodule
xinu2009 发表于 2010-5-16 11:03:55 | 显示全部楼层

谢谢楼主分享,好东西哦!
Sunlife 发表于 2015-5-19 14:57:13 | 显示全部楼层


谢谢楼主分享,好东西哦!
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 19:39 , Processed in 0.064776 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表