我就是这样做的。
对于i在0到MAX / 2生成
REG1(i * 2)0生成
REG1(MAX)以下为原文
You could loop half has many times and multiply by 2, instead. That's how I would do it.
for i in 0 to MAX/2 generate
REG1(i*2) <= even_values_signal_assignment;
REG1(i*2+1) <= odd_values_signal_assignment;
end generate;
You'll need another generate statement to handle the special case where MAX is odd.
if MAX mod 2 > 0 generate
REG1(MAX) <= odd_values_signal_assignment;
end generate;
Or, you could modify the original loop to iterate 0 to MAX/2+1 and qualify the even signal assignment with another if-generate. That way, there would be only 1 "even" equation and one "odd" equation. With the former approach, you risk modifying the odd case in the first loop and forgetting ot modify the special case following.