定义输出为vote;输出为pass;则代码为:
module voter7(vote,pass);input [6:0] vote;output pass;reg [2:0] sum;integer i;reg pass;always @(vote)beginsum = 0;for(i=0;i<=6;i=i+1) //for语句if(vote[i])sum = sum +1;if(sum[2]) //若超过4人赞成,则pass=1pass = 1;elsepass = 0;endendmodule