1.向量下标可以是个wire类型的变量
Vector indices can be variable, as long as the synthesizer can figure out that the width of the bits being selected is constant. In particular, selecting one bit out of a vector using a variable index will work.
module aa(
input [255:0] in,
input [7:0] sel,
output out );
assign out=in[sel];
endmodule
But,
It’s not always good at this. An error saying “… is not a constant” means it couldn’t prove that the select width is constant. In particular, in[ sel * 4+3 : sel*4 ] does not work.FOR EXAMPLE