module univ_barrel8(
input [7:0] x,
input [2:0] sh,
input [2:0] mode,
output reg [7:0] y
);
localparam PASS = 3'b000;
localparam LSL = 3'b001;
localparam LSR = 3'b010;
localparam ASR = 3'b011;
localparam ROL = 3'b100;
localparam ROR = 3'b101;
always @(*) begin
case (mode)
PASS: y = x;
LSL: y = x << sh;
LSR: y = x >> sh;
ASR: y = $signed(x) >>> sh;
ROL: y = (x << sh) | (x >> (8 - sh));
ROR: y = (x >> sh) | (x << (8 - sh));
default: y = x;
endcase
end
endmodule