-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEXT.v
157 lines (151 loc) · 4.64 KB
/
EXT.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2023/05/06 16:42:43
// Design Name:
// Module Name: EXT
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module EXT(
input clk,
input ena,
input [4:0]op,
input [31:0]ins,
output reg [31:0]ext_out
);
reg [17:0]tmp;
always @(*)begin
if(ena)begin
if(ins[31:26]==6'b00_0000)begin
case(ins[5:0])
6'b10_0000:begin
//op=ADD;
end
6'b10_0001:begin
//op=ADDU;
end
6'b10_0010:begin
//op=SUB;
end
6'b10_0011:begin
//op=SUBU;
end
6'b10_0100:begin
//op=AND;
end
6'b10_0101:begin
//op=OR;
end
6'b10_0110:begin
//op=XOR;
end
6'b10_0111:begin
//op=NOR;
end
6'b10_1010:begin
//op=SLT;
end
6'b10_1011:begin
//op=SLTU;
end
6'b00_0000:begin
//op=SLL;
ext_out<=$unsigned(ins[10:6]);
end
6'b00_0010:begin
//op=SRL;
ext_out<=$unsigned(ins[10:6]);
end
6'b00_0011:begin
//op=SRA;
ext_out<=$unsigned(ins[10:6]);
end
6'b00_0100:begin
//op=SLLV;
end
6'b00_0110:begin
//op=SRLV;
end
6'b00_0111:begin
//op=SRAV;
end
6'b00_1000:begin
//op=JR;
end
endcase
end
else begin
case(ins[31:26])
6'b00_1000:begin
//op=ADDI;
ext_out<=$signed(ins[15:0]);
end
6'b00_1001:begin
//op=ADDIU;
ext_out<=$signed(ins[15:0]);
end
6'b00_1100:begin
//op=ANDI;
ext_out<=$unsigned(ins[15:0]);
end
6'b00_1101:begin
//op=ORI;
ext_out<=$unsigned(ins[15:0]);
end
6'b00_1110:begin
//op=XORI;
ext_out<=$unsigned(ins[15:0]);
end
6'b10_0011:begin
//op=LW;
ext_out<=$unsigned(ins[15:0]);
end
6'b10_1011:begin
//op=SW;
ext_out<=$unsigned(ins[15:0]);
end
6'b00_0100:begin
//op=BEQ;
tmp<={ins[15:0],2'b00};
ext_out<=$unsigned(tmp);
end
6'b00_0101:begin
//op=BNE;
tmp<={ins[15:0],2'b00};
ext_out<=$unsigned(tmp);
end
6'b00_1010:begin
//op=SLTI;
ext_out<=$signed(ins[15:0]);
end
6'b00_1011:begin
//op=SLTIU;
ext_out<=$signed(ins[15:0]);
end
6'b00_1111:begin
//op=LUI;
ext_out<=$unsigned(ins[15:0]);
end
6'b00_0010:begin
//op=J;
end
6'b00_0011:begin
//op=JAI;
end
endcase
end
end
end
endmodule