data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v
1: b'%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:2: Cannot find include file: Constants.v\n`include "Constants.v" \n         ^~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/100975158/MIPS32_Full/Processor,data/full_repos/permissive/100975158/Constants.v\n             data/full_repos/permissive/100975158/MIPS32_Full/Processor,data/full_repos/permissive/100975158/Constants.v.v\n             data/full_repos/permissive/100975158/MIPS32_Full/Processor,data/full_repos/permissive/100975158/Constants.v.sv\n             Constants.v\n             Constants.v.v\n             Constants.v.sv\n             obj_dir/Constants.v\n             obj_dir/Constants.v.v\n             obj_dir/Constants.v.sv\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:39: Define or directive not defined: \'`SIG_NOP\'\n            signals <= `SIG_NOP;\n                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:39: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            signals <= `SIG_NOP;\n                               ^\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:44: Define or directive not defined: \'`OPCODE_TYPE_R\'\n                `OPCODE_TYPE_R: begin\n                ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:44: syntax error, unexpected \':\', expecting endcase\n                `OPCODE_TYPE_R: begin\n                              ^\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:46: Define or directive not defined: \'`FUNCT_ADD\'\n                        `FUNCT_ADD  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:47: Define or directive not defined: \'`SIG_ADD\'\n                            signals <= `SIG_ADD;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:49: Define or directive not defined: \'`FUNCT_ADDU\'\n                        `FUNCT_ADDU : begin\n                        ^~~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:49: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_ADDU : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:50: Define or directive not defined: \'`SIG_ADDU\'\n                            signals <= `SIG_ADDU;\n                                       ^~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:52: Define or directive not defined: \'`FUNCT_AND\'\n                        `FUNCT_AND  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:52: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_AND  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:53: Define or directive not defined: \'`SIG_AND\'\n                            signals <= `SIG_AND;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:55: Define or directive not defined: \'`FUNCT_JR\'\n                        `FUNCT_JR   : begin\n                        ^~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:55: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_JR   : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:56: Define or directive not defined: \'`SIG_JR\'\n                            signals <= `SIG_JR;\n                                       ^~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:58: Define or directive not defined: \'`FUNCT_NOR\'\n                        `FUNCT_NOR  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:58: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_NOR  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:59: Define or directive not defined: \'`SIG_NOR\'\n                            signals <= `SIG_NOR;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:61: Define or directive not defined: \'`FUNCT_OR\'\n                        `FUNCT_OR   : begin\n                        ^~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:61: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_OR   : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:62: Define or directive not defined: \'`SIG_OR\'\n                            signals <= `SIG_OR;\n                                       ^~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:64: Define or directive not defined: \'`FUNCT_SLL\'\n                        `FUNCT_SLL  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:64: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_SLL  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:65: Define or directive not defined: \'`SIG_SLL\'\n                            signals <= `SIG_SLL;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:67: Define or directive not defined: \'`FUNCT_SLT\'\n                        `FUNCT_SLT  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:67: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_SLT  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:68: Define or directive not defined: \'`SIG_SLT\'\n                            signals <= `SIG_SLT;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:70: Define or directive not defined: \'`FUNCT_SRL\'\n                        `FUNCT_SRL  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:70: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_SRL  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:71: Define or directive not defined: \'`SIG_SRL\'\n                            signals <= `SIG_SRL;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:73: Define or directive not defined: \'`FUNCT_SUB\'\n                        `FUNCT_SUB  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:73: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_SUB  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:74: Define or directive not defined: \'`SIG_SUB\'\n                            signals <= `SIG_SUB;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:76: Define or directive not defined: \'`FUNCT_SUBU\'\n                        `FUNCT_SUBU : begin\n                        ^~~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:76: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_SUBU : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:77: Define or directive not defined: \'`SIG_SUBU\'\n                            signals <= `SIG_SUBU;\n                                       ^~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:79: Define or directive not defined: \'`FUNCT_XOR\'\n                        `FUNCT_XOR  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:79: syntax error, unexpected begin, expecting IDENTIFIER or PACKAGE-IDENTIFIER or TYPE-IDENTIFIER or new\n                        `FUNCT_XOR  : begin\n                                      ^~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:80: Define or directive not defined: \'`SIG_XOR\'\n                            signals <= `SIG_XOR;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:83: Define or directive not defined: \'`SIG_NOP\'\n                            signals <= `SIG_NOP;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:88: Define or directive not defined: \'`OPCODE_TYPE_R_EX\'\n                `OPCODE_TYPE_R_EX: begin\n                ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:90: Define or directive not defined: \'`FUNCT_MUL\'\n                        `FUNCT_MUL  : begin\n                        ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:91: Define or directive not defined: \'`SIG_MUL\'\n                            signals <= `SIG_MUL;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:94: Define or directive not defined: \'`SIG_NOP\'\n                            signals <= `SIG_NOP;\n                                       ^~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:99: Define or directive not defined: \'`OPCODE_ADDI\'\n                `OPCODE_ADDI        : begin\n                ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:100: Define or directive not defined: \'`SIG_ADDI\'\n                    signals <= `SIG_ADDI;\n                               ^~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:103: Define or directive not defined: \'`OPCODE_ADDIU\'\n                `OPCODE_ADDIU       : begin\n                ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:104: Define or directive not defined: \'`SIG_ADDIU\'\n                    signals <= `SIG_ADDIU;\n                               ^~~~~~~~~~\n%Error: data/full_repos/permissive/100975158/MIPS32_Full/Processor/ControlUnity.v:107: Define or directive not defined: \'`OPCODE_SLTI\'\n                `OPCODE_SLTI        : begin\n                ^~~~~~~~~~~~\n%Error: Exiting due to too many errors encountered; --error-limit=50\n'
module ControlUnity (
    input       id_stall,
    input [5:0] id_opcode,
    input [5:0] id_funct,
    input       id_cmp_eq,

    output              if_flush,
    output reg [7:0]    id_signal_forwarding,
    output     [1:0]    id_pc_source_sel,
    output              id_sign_extend,
    output              id_jump_link,
    output              id_reg_dst,
    output              id_alu_src,
    output              id_branch_delay_slot,
    output reg [4:0]    id_alu_op,
    output              id_mem_write,
    output              id_mem_read,
    output              id_mem_to_reg,
    output              id_reg_write
);

    wire branch, branch_eq, branch_ne;

    reg [8:0] signals;
    assign id_pc_source_sel[0]  = signals[7];
    assign id_jump_link         = signals[6];
    assign id_alu_src           = signals[5];
    assign id_reg_dst           = signals[4];
    assign id_mem_read          = signals[3];
    assign id_mem_write         = signals[2];
    assign id_mem_to_reg        = signals[1];
    assign id_reg_write         = signals[0];

    always @ ( * ) begin
        if (id_stall) begin
            signals <= `SIG_NOP;
        end

        else begin
            case (id_opcode)
                `OPCODE_TYPE_R: begin
                    case (id_funct)
                        `FUNCT_ADD  : begin
                            signals <= `SIG_ADD;
                        end
                        `FUNCT_ADDU : begin
                            signals <= `SIG_ADDU;
                        end
                        `FUNCT_AND  : begin
                            signals <= `SIG_AND;
                        end
                        `FUNCT_JR   : begin
                            signals <= `SIG_JR;
                        end
                        `FUNCT_NOR  : begin
                            signals <= `SIG_NOR;
                        end
                        `FUNCT_OR   : begin
                            signals <= `SIG_OR;
                        end
                        `FUNCT_SLL  : begin
                            signals <= `SIG_SLL;
                        end
                        `FUNCT_SLT  : begin
                            signals <= `SIG_SLT;
                        end
                        `FUNCT_SRL  : begin
                            signals <= `SIG_SRL;
                        end
                        `FUNCT_SUB  : begin
                            signals <= `SIG_SUB;
                        end
                        `FUNCT_SUBU : begin
                            signals <= `SIG_SUBU;
                        end
                        `FUNCT_XOR  : begin
                            signals <= `SIG_XOR;
                        end
                        default     : begin
                            signals <= `SIG_NOP;
                        end
                    endcase
                end

                `OPCODE_TYPE_R_EX: begin
                    case (id_funct)
                        `FUNCT_MUL  : begin
                            signals <= `SIG_MUL;
                        end
                        default     : begin
                            signals <= `SIG_NOP;
                        end
                    endcase
                end

                `OPCODE_ADDI        : begin
                    signals <= `SIG_ADDI;
                end

                `OPCODE_ADDIU       : begin
                    signals <= `SIG_ADDIU;
                end

                `OPCODE_SLTI        : begin
                    signals <= `SIG_SLTI;
                end
                `OPCODE_J           : begin
                    signals <= `SIG_J;
                end
                `OPCODE_JAL         : begin
                    signals <= `SIG_JAL;
                end
                `OPCODE_BEQ         : begin
                    signals <= `SIG_BEQ;
                end
                `OPCODE_BNE         : begin
                    signals <= `SIG_BNE;
                end
                `OPCODE_LW          : begin
                    signals <= `SIG_LW;
                end
                `OPCODE_SW          : begin
                    signals <= `SIG_SW;
                end
                default             : begin
                    signals <= `SIG_NOP;
                end
            endcase
        end
    end

    always @ ( * ) begin
        case (id_opcode)
            `OPCODE_TYPE_R : begin
                case (id_funct)
                    `FUNCT_ADD  : id_signal_forwarding <= `HAZ_ADD;
                    `FUNCT_ADDU : id_signal_forwarding <= `HAZ_ADDU;
                    `FUNCT_AND  : id_signal_forwarding <= `HAZ_AND;
                    `FUNCT_JR   : id_signal_forwarding <= `HAZ_JR;
                    `FUNCT_NOR  : id_signal_forwarding <= `HAZ_NOR;
                    `FUNCT_OR   : id_signal_forwarding <= `HAZ_OR;
                    `FUNCT_SLL  : id_signal_forwarding <= `HAZ_SLL;
                    `FUNCT_SLT  : id_signal_forwarding <= `HAZ_SLT;
                    `FUNCT_SLTU : id_signal_forwarding <= `HAZ_SLTU;
                    `FUNCT_SRL  : id_signal_forwarding <= `HAZ_SRL;
                    `FUNCT_SUB  : id_signal_forwarding <= `HAZ_SUB;
                    `FUNCT_SUBU : id_signal_forwarding <= `HAZ_SUBU;
                    `FUNCT_XOR  : id_signal_forwarding <= `HAZ_XOR;
                    default     : id_signal_forwarding <= 8'hxx;
                endcase
            end
            `OPCODE_TYPE_R_EX : begin
                case (id_funct)
                    `FUNCT_MUL  : id_signal_forwarding <= `HAZ_MUL;
				    default     : id_signal_forwarding <= 8'hxx;
                endcase
            end
            `OPCODE_ADDI        : id_signal_forwarding <=  `HAZ_ADDI;
            `OPCODE_ADDIU       : id_signal_forwarding <=  `HAZ_ADDIU;
            `OPCODE_SLTI        : id_signal_forwarding <=  `HAZ_SLTI;
            `OPCODE_SLTIU       : id_signal_forwarding <=  `HAZ_SLTIU;
            `OPCODE_J           : id_signal_forwarding <=  `HAZ_J;
            `OPCODE_JAL         : id_signal_forwarding <=  `HAZ_JAL;
            `OPCODE_BEQ         : id_signal_forwarding <=  `HAZ_BEQ;
            `OPCODE_BNE         : id_signal_forwarding <=  `HAZ_BNE;
            `OPCODE_LW          : id_signal_forwarding <=  `HAZ_LW;
            `OPCODE_SW          : id_signal_forwarding <=  `HAZ_SW;
            default             : id_signal_forwarding <=  8'hxx;
        endcase
    end

    always @ ( * ) begin
        if (id_stall) begin
            id_alu_op <= `ALUOP_ADDU;
        end
        else begin
            case (id_opcode)
                `OPCODE_TYPE_R : begin
                    case (id_funct)
                        `FUNCT_ADD      : id_alu_op <= `ALUOP_ADD;
                        `FUNCT_ADDU     : id_alu_op <= `ALUOP_ADDU;
                        `FUNCT_AND      : id_alu_op <= `ALUOP_AND;
                        `FUNCT_NOR      : id_alu_op <= `ALUOP_NOR;
                        `FUNCT_OR       : id_alu_op <= `ALUOP_OR;
                        `FUNCT_SLL      : id_alu_op <= `ALUOP_SLL;
                        `FUNCT_SLT      : id_alu_op <= `ALUOP_SLT;
                        `FUNCT_SLTU     : id_alu_op <= `ALUOP_SLTU;
                        `FUNCT_SRL      : id_alu_op <= `ALUOP_SRL;
                        `FUNCT_SUB      : id_alu_op <= `ALUOP_SUB;
                        `FUNCT_SUBU     : id_alu_op <= `ALUOP_SUBU;
                        `FUNCT_XOR      : id_alu_op <= `ALUOP_XOR;
                        default         : id_alu_op <= `ALUOP_ADDU;
                    endcase
                end
                `OPCODE_TYPE_R_EX : begin
                    case (id_funct)
                        `FUNCT_MUL      : id_alu_op <= `ALUOP_MUL;
                        default         : id_alu_op <= `ALUOP_ADDU;
                    endcase
                end
                `OPCODE_ADDI        : id_alu_op <= `ALUOP_ADD;
                `OPCODE_ADDIU       : id_alu_op <= `ALUOP_ADDU;
                `OPCODE_JAL         : id_alu_op <= `ALUOP_ADDU;
                `OPCODE_LW          : id_alu_op <= `ALUOP_ADDU;
                `OPCODE_SLTI        : id_alu_op <= `ALUOP_SLT;
                `OPCODE_SLTIU       : id_alu_op <= `ALUOP_SLTU;
                `OPCODE_SW          : id_alu_op <= `ALUOP_ADDU;
                default             : id_alu_op <= `ALUOP_ADDU;
            endcase
        end
    end


    assign branch_eq = id_opcode[2] & ~id_opcode[1] & ~id_opcode[0] &  id_cmp_eq;

    assign branch_ne = id_opcode[2] & ~id_opcode[1] &  id_opcode[0] & ~id_cmp_eq;


    assign branch = (branch_eq | branch_ne);


    assign id_pc_source_sel[1] = (signals[8] & ~signals[7]) ? branch : signals[8];

    assign if_flush = 0;


    assign id_branch_delay_slot = (branch & signals[8]) | (signals[7]);


    assign id_sign_extend = (id_opcode[5:2] != 4'b0011);

endmodule
module ControlUnity (
    input       id_stall,
    input [5:0] id_opcode,
    input [5:0] id_funct,
    input       id_cmp_eq,

    output              if_flush,
    output reg [7:0]    id_signal_forwarding,
    output     [1:0]    id_pc_source_sel,
    output              id_sign_extend,
    output              id_jump_link,
    output              id_reg_dst,
    output              id_alu_src,
    output              id_branch_delay_slot,
    output reg [4:0]    id_alu_op,
    output              id_mem_write,
    output              id_mem_read,
    output              id_mem_to_reg,
    output              id_reg_write
);


    wire branch, branch_eq, branch_ne;

    reg [8:0] signals;
    assign id_pc_source_sel[0]  = signals[7];
    assign id_jump_link         = signals[6];
    assign id_alu_src           = signals[5];
    assign id_reg_dst           = signals[4];
    assign id_mem_read          = signals[3];
    assign id_mem_write         = signals[2];
    assign id_mem_to_reg        = signals[1];
    assign id_reg_write         = signals[0];

    always @ ( * ) begin
        if (id_stall) begin
            signals <= `SIG_NOP;
        end

        else begin
            case (id_opcode)
                `OPCODE_TYPE_R: begin
                    case (id_funct)
                        `FUNCT_ADD  : begin
                            signals <= `SIG_ADD;
                        end
                        `FUNCT_ADDU : begin
                            signals <= `SIG_ADDU;
                        end
                        `FUNCT_AND  : begin
                            signals <= `SIG_AND;
                        end
                        `FUNCT_JR   : begin
                            signals <= `SIG_JR;
                        end
                        `FUNCT_NOR  : begin
                            signals <= `SIG_NOR;
                        end
                        `FUNCT_OR   : begin
                            signals <= `SIG_OR;
                        end
                        `FUNCT_SLL  : begin
                            signals <= `SIG_SLL;
                        end
                        `FUNCT_SLT  : begin
                            signals <= `SIG_SLT;
                        end
                        `FUNCT_SRL  : begin
                            signals <= `SIG_SRL;
                        end
                        `FUNCT_SUB  : begin
                            signals <= `SIG_SUB;
                        end
                        `FUNCT_SUBU : begin
                            signals <= `SIG_SUBU;
                        end
                        `FUNCT_XOR  : begin
                            signals <= `SIG_XOR;
                        end
                        default     : begin
                            signals <= `SIG_NOP;
                        end
                    endcase
                end

                `OPCODE_TYPE_R_EX: begin
                    case (id_funct)
                        `FUNCT_MUL  : begin
                            signals <= `SIG_MUL;
                        end
                        default     : begin
                            signals <= `SIG_NOP;
                        end
                    endcase
                end

                `OPCODE_ADDI        : begin
                    signals <= `SIG_ADDI;
                end

                `OPCODE_ADDIU       : begin
                    signals <= `SIG_ADDIU;
                end

                `OPCODE_SLTI        : begin
                    signals <= `SIG_SLTI;
                end
                `OPCODE_J           : begin
                    signals <= `SIG_J;
                end
                `OPCODE_JAL         : begin
                    signals <= `SIG_JAL;
                end
                `OPCODE_BEQ         : begin
                    signals <= `SIG_BEQ;
                end
                `OPCODE_BNE         : begin
                    signals <= `SIG_BNE;
                end
                `OPCODE_LW          : begin
                    signals <= `SIG_LW;
                end
                `OPCODE_SW          : begin
                    signals <= `SIG_SW;
                end
                default             : begin
                    signals <= `SIG_NOP;
                end
            endcase
        end
    end

    always @ ( * ) begin
        case (id_opcode)
            `OPCODE_TYPE_R : begin
                case (id_funct)
                    `FUNCT_ADD  : id_signal_forwarding <= `HAZ_ADD;
                    `FUNCT_ADDU : id_signal_forwarding <= `HAZ_ADDU;
                    `FUNCT_AND  : id_signal_forwarding <= `HAZ_AND;
                    `FUNCT_JR   : id_signal_forwarding <= `HAZ_JR;
                    `FUNCT_NOR  : id_signal_forwarding <= `HAZ_NOR;
                    `FUNCT_OR   : id_signal_forwarding <= `HAZ_OR;
                    `FUNCT_SLL  : id_signal_forwarding <= `HAZ_SLL;
                    `FUNCT_SLT  : id_signal_forwarding <= `HAZ_SLT;
                    `FUNCT_SLTU : id_signal_forwarding <= `HAZ_SLTU;
                    `FUNCT_SRL  : id_signal_forwarding <= `HAZ_SRL;
                    `FUNCT_SUB  : id_signal_forwarding <= `HAZ_SUB;
                    `FUNCT_SUBU : id_signal_forwarding <= `HAZ_SUBU;
                    `FUNCT_XOR  : id_signal_forwarding <= `HAZ_XOR;
                    default     : id_signal_forwarding <= 8'hxx;
                endcase
            end
            `OPCODE_TYPE_R_EX : begin
                case (id_funct)
                    `FUNCT_MUL  : id_signal_forwarding <= `HAZ_MUL;
				    default     : id_signal_forwarding <= 8'hxx;
                endcase
            end
            `OPCODE_ADDI        : id_signal_forwarding <=  `HAZ_ADDI;
            `OPCODE_ADDIU       : id_signal_forwarding <=  `HAZ_ADDIU;
            `OPCODE_SLTI        : id_signal_forwarding <=  `HAZ_SLTI;
            `OPCODE_SLTIU       : id_signal_forwarding <=  `HAZ_SLTIU;
            `OPCODE_J           : id_signal_forwarding <=  `HAZ_J;
            `OPCODE_JAL         : id_signal_forwarding <=  `HAZ_JAL;
            `OPCODE_BEQ         : id_signal_forwarding <=  `HAZ_BEQ;
            `OPCODE_BNE         : id_signal_forwarding <=  `HAZ_BNE;
            `OPCODE_LW          : id_signal_forwarding <=  `HAZ_LW;
            `OPCODE_SW          : id_signal_forwarding <=  `HAZ_SW;
            default             : id_signal_forwarding <=  8'hxx;
        endcase
    end

    always @ ( * ) begin
        if (id_stall) begin
            id_alu_op <= `ALUOP_ADDU;
        end
        else begin
            case (id_opcode)
                `OPCODE_TYPE_R : begin
                    case (id_funct)
                        `FUNCT_ADD      : id_alu_op <= `ALUOP_ADD;
                        `FUNCT_ADDU     : id_alu_op <= `ALUOP_ADDU;
                        `FUNCT_AND      : id_alu_op <= `ALUOP_AND;
                        `FUNCT_NOR      : id_alu_op <= `ALUOP_NOR;
                        `FUNCT_OR       : id_alu_op <= `ALUOP_OR;
                        `FUNCT_SLL      : id_alu_op <= `ALUOP_SLL;
                        `FUNCT_SLT      : id_alu_op <= `ALUOP_SLT;
                        `FUNCT_SLTU     : id_alu_op <= `ALUOP_SLTU;
                        `FUNCT_SRL      : id_alu_op <= `ALUOP_SRL;
                        `FUNCT_SUB      : id_alu_op <= `ALUOP_SUB;
                        `FUNCT_SUBU     : id_alu_op <= `ALUOP_SUBU;
                        `FUNCT_XOR      : id_alu_op <= `ALUOP_XOR;
                        default         : id_alu_op <= `ALUOP_ADDU;
                    endcase
                end
                `OPCODE_TYPE_R_EX : begin
                    case (id_funct)
                        `FUNCT_MUL      : id_alu_op <= `ALUOP_MUL;
                        default         : id_alu_op <= `ALUOP_ADDU;
                    endcase
                end
                `OPCODE_ADDI        : id_alu_op <= `ALUOP_ADD;
                `OPCODE_ADDIU       : id_alu_op <= `ALUOP_ADDU;
                `OPCODE_JAL         : id_alu_op <= `ALUOP_ADDU;
                `OPCODE_LW          : id_alu_op <= `ALUOP_ADDU;
                `OPCODE_SLTI        : id_alu_op <= `ALUOP_SLT;
                `OPCODE_SLTIU       : id_alu_op <= `ALUOP_SLTU;
                `OPCODE_SW          : id_alu_op <= `ALUOP_ADDU;
                default             : id_alu_op <= `ALUOP_ADDU;
            endcase
        end
    end


    assign branch_eq = id_opcode[2] & ~id_opcode[1] & ~id_opcode[0] &  id_cmp_eq;

    assign branch_ne = id_opcode[2] & ~id_opcode[1] &  id_opcode[0] & ~id_cmp_eq;


    assign branch = (branch_eq | branch_ne);


    assign id_pc_source_sel[1] = (signals[8] & ~signals[7]) ? branch : signals[8];

    assign if_flush = 0;


    assign id_branch_delay_slot = (branch & signals[8]) | (signals[7]);


    assign id_sign_extend = (id_opcode[5:2] != 4'b0011);

endmodule