-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVal_Generator.v
29 lines (28 loc) · 907 Bytes
/
Val_Generator.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Val_Generator(
input [31:0] valRm,
input imm, isMem,
input [11:0] shiftOperand,
output reg[31:0] valOut
);
integer shiftValue=0;
always@(valRm, imm, shiftOperand, isMem)
begin
valOut = 32'b0;
if(isMem) begin
valOut = shiftOperand;
end
else if(imm) begin
shiftValue = (shiftOperand[11:8])*2;
valOut = (shiftOperand[7:0]<<(32-shiftValue)) | (shiftOperand[7:0]>>(shiftValue));
end
else if(~shiftOperand[4]) begin
shiftValue = (shiftOperand[11:7]);
case(shiftOperand[6:5])
2'b00: valOut = valRm << shiftValue;
2'b01: valOut = valRm >> shiftValue;
2'b10: valOut = valRm >>> shiftValue;
2'b11: valOut = (valRm >> shiftValue) | (valRm << (32-shiftValue));
endcase
end
end
endmodule