/*Write your code here*/
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