-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaludec.v
76 lines (74 loc) · 2.06 KB
/
aludec.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
`timescale 1ns / 1ps
`include "define_alu_control.vh"
`include "define_instr_dec.vh"
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2017/10/23 15:27:24
// Design Name:
// Module Name: aludec
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module aludec(
input wire [31:0] instrD,
output reg[4:0] alucontrol
);
wire [5:0] op,funct;
assign op=instrD[31:26];
assign funct=instrD[5:0];
always @(*) begin
if (op==`OP_RTYPE) begin
case(funct)
//logic arithmetic
`FUNC_AND: alucontrol = `SIG_ALU_AND;
`FUNC_OR: alucontrol = `SIG_ALU_OR;
`FUNC_XOR: alucontrol = `SIG_ALU_XOR;
`FUNC_NOR: alucontrol = `SIG_ALU_NOR;
//shift arithmetic
`FUNC_SLL: alucontrol = `SIG_ALU_SLL ;
`FUNC_SRL : alucontrol = `SIG_ALU_SRL ;
`FUNC_SRA : alucontrol = `SIG_ALU_SRA ;
`FUNC_SLLV: alucontrol = `SIG_ALU_SLLV;
`FUNC_SRLV: alucontrol = `SIG_ALU_SRLV;
`FUNC_SRAV: alucontrol = `SIG_ALU_SRAV;
//hilo
`FUNC_MFHI: alucontrol = `ALU_MFHI;
`FUNC_MFLO: alucontrol = `ALU_MFLO;
`FUNC_MTHI: alucontrol = `ALU_MTHI;
`FUNC_MTLO: alucontrol = `ALU_MTLO;
//arith
`FUNC_ADD: alucontrol = `ALU_ADD;
`FUNC_ADDU: alucontrol = `ALU_ADDU;
`FUNC_SUB: alucontrol = `ALU_SUB;
`FUNC_SUBU: alucontrol = `ALU_SUBU;
`FUNC_SLT: alucontrol = `ALU_SLT;
`FUNC_SLTU: alucontrol = `ALU_SLTU;
default: alucontrol = `SIG_ALU_FAIL;
endcase
end
else begin
case(op)
`OP_ANDI: alucontrol = `SIG_ALU_AND;
`OP_XORI: alucontrol = `SIG_ALU_XOR;
`OP_LUI: alucontrol = `SIG_ALU_LUI;
`OP_ORI: alucontrol = `SIG_ALU_OR;
`OP_ADDI: alucontrol = `ALU_ADD;
`OP_ADDIU:alucontrol = `ALU_ADDU;
`OP_SLTI: alucontrol = `ALU_SLT;
`OP_SLTIU:alucontrol = `ALU_SLTU;
default: alucontrol=`SIG_ALU_FAIL;
endcase
end
end
endmodule