1
0
mirror of https://github.com/pConst/basic_verilog.git synced 2025-01-14 06:42:54 +08:00

SImplified reverse_vector.sv code

This commit is contained in:
Konstantin Pavlov 2021-09-13 11:17:58 +03:00
parent 0e19b10433
commit bcc548f914

View File

@ -22,32 +22,18 @@ reverse_vector #(
module reverse_vector #( parameter module reverse_vector #( parameter
WIDTH = 8 // WIDTH must be >=2 WIDTH = 8
)( )(
input [(WIDTH-1):0] in, input [(WIDTH-1):0] in,
output logic [(WIDTH-1):0] out output logic [(WIDTH-1):0] out
); );
integer i;
genvar i;
generate
for (i = 0; i < (WIDTH/2) ; i++) begin : gen1
always_comb begin always_comb begin
out[i] = in[WIDTH-1-i]; for (i = 0; i < WIDTH ; i++) begin : gen_reverse
out[WIDTH-1-i] = in[i]; out[i] = in[(WIDTH-1)-i];
end // always_comb
end // for end // for
endgenerate
// additional assign needed when WIDTH is odd
generate
if ( WIDTH%2 ) begin : gen2
always_comb begin
out[WIDTH/2] = in[WIDTH/2];
end // always_comb end // always_comb
end // for
endgenerate
endmodule endmodule