aboutsummaryrefslogtreecommitdiff
path: root/src/shift_unit.v
blob: d0aa9d3fea931ab7e5e8bdd1713f4c7813f7a755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module shift_unit #(
  parameter N = 32
)(
  input signed [N-1:0] src0,
  input  [N-1:0] shamt,
  input [1:0] op, // 00: SLL, 01: SRL, 11: SRA
  output reg [N-1:0] result
);

always @ (*) begin
  case (op)
  2'b00: result <= src0 << shamt % N;
  2'b01: result <= src0 >> shamt % N;
  2'b11: result <= src0 >>> shamt % N;
  endcase
end

endmodule