`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date: 28.02.2019 15:11:42
// Design Name: 
// Module Name: control
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////


module control(
    input [10:0] instr_opcode,
    output Reg2Loc,
    output ALUSrc,
    output MemtoReg,
    output RegWrite,
    output MemRead,
    output MemWrite,
    output Branch,
    output Uncondbranch,
    output [1:0] ALUOp
);

    reg [9:0] outputs;
    
    assign {Reg2Loc,ALUSrc,MemtoReg,RegWrite,MemRead,MemWrite,Branch,Uncondbranch,ALUOp[1],ALUOp[0]} = outputs;
    
    always@(*)
        casex(instr_opcode)
            // R-format
            11'b1xxxx01x0xx:    begin outputs = 10'b00010000_10; $display("R-format %b",instr_opcode); end
            // LDUR
            11'b11111000010:    begin outputs = 10'bx1111000_00; $display("LDUR %b",instr_opcode); end
            // STUR
            11'b11111000000:    begin outputs = 10'b11x00100_00; $display("STUR %b",instr_opcode); end
            // CBZ
            11'b10110100xxx:    begin outputs = 10'b10x00010_01; $display("CBZ %b",instr_opcode); end
            // B
            11'b000101xxxxx:    begin outputs = 10'bxxx00001_xx; $display("B %b",instr_opcode); end
            // I-format
            11'b1xx100xx00x:    begin outputs = 10'bx1010000_10; $display("I-format %b",instr_opcode); end
            default:            outputs = 10'bx;
        endcase

endmodule
