/*Write your code here*/
module univ_barrel8(x,sh,mode,y);
input [7:0]x;
input [2:0]sh,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