How do you plan to solve it?
module univ_barrel8 (
input [7:0] x,
input [2:0] sh,
input [2:0] mode,
output reg [7:0] y
);
localparam [2:0]
M_PASS = 3'b000,
M_LSL = 3'b001,
M_LSR = 3'b010,
M_ASR = 3'b011,
M_ROL = 3'b100,
M_ROR = 3'b101;
always @* begin
case (mode)
M_PASS: y = x;
M_LSL : y = (x << sh) & 8'hFF;
M_LSR : y = (x >> sh);
M_ASR : y = $signed(x) >>> sh;
M_ROL : y = ((x << sh) | (x >> (8 - sh))) & 8'hFF;
M_ROR : y = ((x >> sh) | (x << (8 - sh))) & 8'hFF;
default: y = x;
endcase
end
endmodule