题目:Vector100r
Given a 100-bit input vector [99:0], reverse its bit ordering.
- 给定一个100位输入向量[99:0],反转它的位顺序。
Hint…
- 提示……
A for loop (in a combinational always block or generate block) would be useful here. I would prefer a combinational always block in this case because module instantiations (which require generate blocks) aren’t needed.
- for循环(在组合的always块或generate块中)在这里很有用。在这种情况下,我更喜欢组合always块,因为不需要模块实例化(需要生成块)。
module top_module(
input [99:0] in,
output [99:0] out
);
reg [6:0] i;
always@(*) begin
for(i=7'd0;i<=7'd99;i=i+7'd1)
out[i] = in[7'd99 - i];
end
endmodule