From bcc548f91418322b02f4033285093956f38b0413 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Mon, 13 Sep 2021 11:17:58 +0300 Subject: [PATCH] SImplified reverse_vector.sv code --- reverse_vector.sv | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/reverse_vector.sv b/reverse_vector.sv index d4dec4a..1db6cb2 100644 --- a/reverse_vector.sv +++ b/reverse_vector.sv @@ -22,32 +22,18 @@ reverse_vector #( module reverse_vector #( parameter - WIDTH = 8 // WIDTH must be >=2 + WIDTH = 8 )( input [(WIDTH-1):0] in, output logic [(WIDTH-1):0] out ); - -genvar i; - -generate - for (i = 0; i < (WIDTH/2) ; i++) begin : gen1 - always_comb begin - out[i] = in[WIDTH-1-i]; - out[WIDTH-1-i] = in[i]; - end // always_comb - 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 // for -endgenerate - + integer i; + always_comb begin + for (i = 0; i < WIDTH ; i++) begin : gen_reverse + out[i] = in[(WIDTH-1)-i]; + end // for + end // always_comb endmodule +