hdlbits-Vector100r

Vector100r

Given a 100-bit input vector [99:0], reverse its bit ordering.

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.

solution

1
2
3
4
5
6
7
8
9
10
module top_module( 
input [99:0] in,
output [99:0] out
);
reg [6:0] i;
always @(*) begin
for (i=0; i<100; i++) // int is a SystemVerilog type. Use integer for pure Verilog.
out[i] = in[99-i];
end
endmodule

hdlbits-Vector100r
http://456-xiao.github.io/2024/08/25/hdlbits-Vector100r/
作者
xyh
发布于
2024年8月25日
许可协议