我在以下SystemVerilog代码中使用generate语句时遇到问题。 以下代码在内循环(i)中生成连接,仅适用于j = 0和j = 1的情况;不适用于j = 2和j = 3的情况(即,对于情况j> i)。如果我将i更改为i = 3,则将生成j = 0,j = 1和j = 2的连接。
这应该是一个愚蠢的错误;但我无法弄明白。有人可以帮忙吗?
`define N_PORTS 2
`define N_CHANNELS 4
logic [`N_PORTS-1 : 0] input_to_channel [`N_CHANNELS-1 : 0];
logic [`N_PORTS-1 : 0] to_ch0,
to_ch1,
to_ch2,
to_ch3,
to_ch4,
to_ch5,
to_ch6,
to_ch7;
genvar i,j;
generate
for(j=0; j<`N_CHANNELS; j=j+1)
begin
case (j)
0:
for(i=0; i<`N_PORTS; i=i+1)
begin
assign input_to_channel[j][i] = to_ch0[i];
end
1:
for(i=0; i<`N_PORTS; i=i+1)
begin
assign input_to_channel[j][i] = to_ch1[i];
end
2:
for(i=0; i<`N_PORTS; i=i+1)
begin
assign input_to_channel[j][i] = to_ch2[i];
end
3:
for(i=0; i<`N_PORTS; i=i+1)
begin
assign input_to_channel[j][i] = to_ch3[i];
end
endcase
end
endgenerate