三种方法用Verilog实现多人表决器
生活随笔
收集整理的這篇文章主要介紹了
三种方法用Verilog实现多人表决器
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
module biaojue(
a,b,c,d,e,f);
input a,b,c,d,e;
output f;
reg f;
reg[2:0] count1;
initial count1=0;
always@(a,b,c,d,e)
begin
count1=a+b+c+d+e;
f=count1<3?0:1;//當人數(shù)在三人以下是輸出1
end
endmodule
module biaojue5(
input a,b,c,d,e,
output f
);
assign f=a&b&c||a&b&d||a&b&e||a&c&d||a&c&e||
a&d&e||b&c&d||b&c&e||b&d&e||c&d&e;//直接進行邏輯運算
endmodule
module biaojue(a,out);
input [5:0]a;
output reg [1:0]out;
integer i,count1,count2;
always@(*)begincount1=0;count2=0;i=0;while(i<4)beginif(a[i])count1=count1+1;//決定通過的人數(shù)elsecount2=count2+1;//表決不通過的人數(shù)i=i+1;endif(count1==count2)out=2'b00;else if(count1<count2)out=2'b00;else if(count1>count2)out=2'b01;//或者用if一步實現(xiàn)end
endmodule
三種表決器的實現(xiàn)方法。
總結(jié)
以上是生活随笔為你收集整理的三种方法用Verilog实现多人表决器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 手机整人脚本html,vbs整人代码_手
- 下一篇: firefox火狐浏览器显示多列书签菜单