Я хотел бы знать, могу ли я поместить приведенный ниже код в цикл for, чтобы я мог параметризировать свой код.Спасибо.
always@(*) begin
if (exist_reg[0] == 'd0) begin
nth_empty_location_descending = 'd1; // specify
end
else if (exist_reg[1] =='d0) begin
nth_empty_location_descending = 'd2;
end
else if (exist_reg[2] =='d0) begin
nth_empty_location_descending = 'd4;
end
else if (exist_reg[3] =='d0) begin
nth_empty_location_descending = 'd8;
end
else if (exist_reg[4] =='d0) begin
nth_empty_location_descending = 'd16;
end
else if (exist_reg[5] =='d0) begin
nth_empty_location_descending = 'd32;
end
else if (exist_reg[6] =='d0) begin
nth_empty_location_descending = 'd64;
end
else if (exist_reg[7] =='d0) begin
nth_empty_location_descending = 'd128;
end
else if (exist_reg[8] =='d0) begin
nth_empty_location_descending = 'd256;
end
else if (exist_reg[9] =='d0) begin
nth_empty_location_descending = 'd512;
end
else begin
nth_empty_location_descending = 'd0;
end
end
Это в основном проверка битов «exist_reg», если он встречает любой бит слева направо, равен нулю, то он возрастает в этом бите в регистре «nth_empty_location_descending» (какой-нибудь лучший подход?),Теперь я хочу создать параметризованный код для ширины регистра.В настоящее время это 10-битный код.Спасибо экспертам.