怎么改写
reg test[3:0];
always @(posedge clk) begin
//int i=0;
if(rst) begin
test[0] <=0;
test[1] <=0;
test[2] <=0;
test[3] <=0;
end
else begin
if(test[0]==0) begin
if(wea )
test[0] <= 1;
end
else if(test[1]==0) begin //优先级
if(wea )
test[1] <= 1;
end
else if(test[2]==0) begin
if(wea )
test[2] <= 1;
end
else if(test[3]==0) begin
if(wea )
test[3] <= 1;
end
end
end
实现
reg test[3:0];
always @(posedge clk)
if(rst)
test = '{default:0};
else
foreach(test[i])
if(test[i]==0) begin
if(wea )
test[0] <= 1;
break;
end