OpenCores
URL https://opencores.org/ocsvn/mips32/mips32/trunk

Subversion Repositories mips32

[/] [mips32/] [trunk/] [Classic-MIPS/] [source/] [src/] [ALU_Ctr.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jjf
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    18:33:46 12/29/2016 
7
// Design Name: 
8
// Module Name:    ALU_Ctr 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
`include "macros.v"
22
module ALU_Ctr(
23
input wire [5:0] opcode,
24
input wire [5:0] funct,
25
input wire [1:0] ALUOp,
26
output wire [3:0] cmd
27
    );
28
 
29
 
30
        /* the ALU command */
31
        assign cmd = OUT( funct, ALUOp);
32
 
33
         /* the first-level decode */
34
         function [3:0]  OUT;
35
                input [5:0] funct;
36
                input [1:0] ALUOp;
37
                case( ALUOp )
38
                2'b00: OUT = `ALU_ADD;
39
                2'b01: OUT = `ALU_SUB;
40
                2'b10: OUT = DECODE( funct );
41
                2'b11: OUT = DECODE2( opcode );
42
                default: OUT = 4'bxxxx;
43
                endcase
44
         endfunction
45
 
46
         /* the second-level decode */
47
         function [3:0] DECODE;
48
                input [5:0] funct;
49
                case( funct )
50
                `R_OP_AND:      DECODE = `ALU_AND;
51
                `R_OP_OR:       DECODE = `ALU_OR;
52
                `R_OP_ADD:      DECODE = `ALU_ADD;
53
                `R_OP_SUB:      DECODE = `ALU_SUB;
54
                `R_OP_SLT:      DECODE = `ALU_SLT;
55
                `R_OP_NOR:      DECODE = `ALU_NOR;
56
                `R_OP_SLLV:     DECODE = `ALU_SLLV;
57
                `R_OP_SRLV:     DECODE = `ALU_SRLV;
58
                default: DECODE = 4'bxxxx;
59
                endcase
60
         endfunction
61
 
62
         /* the third-level decode */
63
         function [3:0] DECODE2;
64
                input [5:0] opcode;
65
                begin
66
                        case( opcode )
67
                        `OPCODE_I_ADDI: DECODE2 = `ALU_ADD;
68
                        `OPCODE_I_ANDI: DECODE2 = `ALU_AND;
69
                        `OPCODE_I_ORI:   DECODE2 = `ALU_OR;
70
                        `OPCODE_I_XORI: DECODE2 = `ALU_XOR;
71
                        `OPCODE_I_LUI:   DECODE2 = `ALU_LU;
72
                        default:                         DECODE2 = 4'bxxxx;
73
                        endcase
74
                end
75
         endfunction
76
 
77
 
78
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.