module univ_barrel8 (
input [7:0] x,
input [2:0] sh,
input [2:0] mode,
output reg [7:0] y
);
always @* begin
case (mode)
3'b001: y = x << sh;
3'b010: y = x >> sh;
3'b011: y = {{8{x[7]}},x} >> sh;
3'b100: y = ({x,x} << sh) >> 8;
3'b101: y = ({x,x} >> sh);
default: y = x;
endcase
end
endmodule