/*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]
pass = 3'b000,
lsl = 3'b001,
lsr = 3'b010,
asr = 3'b011,
rol = 3'b100,
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))) & 8'hFF;
ror : y = ((x>>sh)| (x<<(8-sh))) & 8'hFF;
default: y = x;
endcase
end
endmodule