-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImmGen.v
More file actions
28 lines (27 loc) · 842 Bytes
/
ImmGen.v
File metadata and controls
28 lines (27 loc) · 842 Bytes
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
`timescale 1ns / 1ps
module ImmGen ( InstCode , ImmOut );
// The input and output signals
input [31:0] InstCode ;
output reg [31:0] ImmOut ;
// The ImmGen modules behaviour
always @ ( InstCode )
begin
case ( InstCode [6:0])
// I - type - Load
7'b0000011 :
ImmOut = { InstCode[31]? {20{1'b1 }}:20'b0 , InstCode [31:20]};
// I - type - non - Load
7'b0010011 :
ImmOut = { InstCode [31]? {20{1'b1 }}:20'b0 , InstCode [31:20]};
// S - type - Store
7'b0100011 :
ImmOut = { InstCode [31]? {20{1'b1 }}:20'b0 , InstCode [31:25] ,
InstCode [11:7]};
// U - type
7'b0010111 :
ImmOut = { InstCode [31:12] , 12'b0 };
default :
ImmOut = {32'b0 };
endcase
end
endmodule