forked from hlpaa/ProjetoX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imm_Gen.sv
52 lines (40 loc) · 1.15 KB
/
imm_Gen.sv
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
`timescale 1ns / 1ps
module imm_Gen (
input logic [31:0] inst_code,
output logic [31:0] Imm_out
);
always_comb
case (inst_code[6:0])
7'b0000011: /*I-type load part*/
Imm_out = {inst_code[31] ? 20'hFFFFF : 20'b0, inst_code[31:20]};
7'b0100011: /*S-type*/
Imm_out = {inst_code[31] ? 20'hFFFFF : 20'b0, inst_code[31:25], inst_code[11:7]};
7'b1100011: /*B-type*/
Imm_out = {
inst_code[31] ? 19'h7FFFF : 19'b0,
inst_code[31],
inst_code[7],
inst_code[30:25],
inst_code[11:8],
1'b0
};
7'b0010011: /*I_TYPE integer part*/
Imm_out = {inst_code[31] ? 20'hFFFFF : 20'b0, inst_code[31:20]};
7'b0110111: // LUI
Imm_out = {inst_code[31], inst_code[31:12], 12'b0};
7'b1101111: // JAL
Imm_out = {
inst_code[31] ? 11'h7FF : 11'b0,
inst_code[31],
inst_code[19:12],
inst_code[20],
inst_code[30:21],
1'b0
};
7'b1100111: // JALR
Imm_out = {
inst_code[31] ? 20'hFFFFF : 20'b0, inst_code[31:20]
};
default: Imm_out = {32'b0};
endcase
endmodule