-
Notifications
You must be signed in to change notification settings - Fork 2
/
val2_generator.v
52 lines (44 loc) · 1.58 KB
/
val2_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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
`include "settings.h"
module Val2_Generator
(
input [`SHIFTER_OPERAND_WIDTH-1:0] shifter_operand,
input imm, is_for_memory,
input [`WORD_WIDTH-1:0] val_Rm,
output reg [`WORD_WIDTH-1:0] val2_out
);
reg [`WORD_WIDTH-1:0] _32bit_immd_temp;
integer i;
always @(*) begin
if(is_for_memory == 1'b1)
val2_out = {20'b0, shifter_operand};
else if(imm == 1'b1) begin
_32bit_immd_temp = {24'b0, shifter_operand[7:0]};
for (i=0; i<{shifter_operand[11:8], 1'b0}; i=i+1) begin
_32bit_immd_temp = {_32bit_immd_temp[0], _32bit_immd_temp[`WORD_WIDTH-1:1]};
end
val2_out = _32bit_immd_temp;
end
else begin
case (shifter_operand[6:5])
00: begin
val2_out = val_Rm << shifter_operand[11:7];
end
01: begin
val2_out = val_Rm >> shifter_operand[11:7];
end
10: begin
val2_out = val_Rm >>> shifter_operand[11:7];
end
11: begin
val2_out = val_Rm;
for (i=0; i<{shifter_operand[11:7]}; i=i+1) begin
val2_out = {val2_out[0], val2_out[`WORD_WIDTH-1:1]};
end
end
default:begin
val2_out = val_Rm << shifter_operand[11:7];
end
endcase
end
end
endmodule