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