-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadv_instr.v
44 lines (40 loc) · 859 Bytes
/
adv_instr.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
// Alden Rivera 0416329
// Jorge Pineda 0416330
`timescale 1ns / 1ps
module adv_instr(
instr,
regs,
regt,
result
);
input [32-1:0] instr;
input signed [32-1:0] regs;
input signed [32-1:0] regt;
output reg signed [32-1:0] result;
//disposable registers
reg signed [5-1:0] shamt;
reg [16-1:0] imm;
reg [32-1:0] ext_imm;
always@(*)
begin
shamt = instr[10:6];
imm = instr[15:0];
if(instr[15]==1'b1)
ext_imm = {16'b1111111111111111,instr[15:0]};
else
ext_imm = {16'b0000000000000000,instr[15:0]};
case(instr[31:26]) //case based on OP field
6'b000000:
begin
if(instr[5:0] == 6'b000011) //SRA
result = regt >>> shamt;
else //SRAV
result = regt >>> regs;
end
6'b001111: //LUI
result = (imm*(2**16));
6'b001101: //ORI
result = regs | ext_imm;
endcase
end
endmodule