data/full_repos/permissive/135475029/lab_9/src/ControlUnit.v
data/verilator_xmls/95e2e283-b6e2-4d0b-bcff-0f2eac73abdf.xml
module ControlUnit(
      input  [5:0] Op,
      input  [5:0] Funct,
      output       Jump,
      output       MemtoReg,
      output       MemWrite,
      output       Branch,
      output [5:0] ALUControl,
      output       ALUSrc,
      output       RegDst,
      output       RegWrite
    );
	 


localparam [5:0] OP_RTYPE = 6'b000000;
localparam [5:0] OP_LW    = 6'b100011;
localparam [5:0] OP_SW    = 6'b101011;
localparam [5:0] OP_BEQ   = 6'b000100;
localparam [5:0] OP_ADDI  = 6'b001000;
localparam [5:0] OP_J     = 6'b000010;













assign RegWrite = (Op == OP_RTYPE) | (Op == OP_LW) | ( Op == OP_ADDI) ; 	 


assign ALUSrc   = (Op == OP_LW) | (Op == OP_SW) | (Op == OP_ADDI) ;


assign RegDst   = (Op == OP_RTYPE);
assign Branch   = (Op == OP_BEQ);
assign MemWrite = (Op == OP_SW);
assign MemtoReg = (Op == OP_LW);
assign Jump     = (Op == OP_J);










assign ALUControl = ALUSrc ? 6'b100000 :
                    Branch ? 6'b100010 :
					             Funct;
	 


endmodule
module ControlUnit(
      input  [5:0] Op,
      input  [5:0] Funct,
      output       Jump,
      output       MemtoReg,
      output       MemWrite,
      output       Branch,
      output [5:0] ALUControl,
      output       ALUSrc,
      output       RegDst,
      output       RegWrite
    );

	 


localparam [5:0] OP_RTYPE = 6'b000000;
localparam [5:0] OP_LW    = 6'b100011;
localparam [5:0] OP_SW    = 6'b101011;
localparam [5:0] OP_BEQ   = 6'b000100;
localparam [5:0] OP_ADDI  = 6'b001000;
localparam [5:0] OP_J     = 6'b000010;













assign RegWrite = (Op == OP_RTYPE) | (Op == OP_LW) | ( Op == OP_ADDI) ; 	 


assign ALUSrc   = (Op == OP_LW) | (Op == OP_SW) | (Op == OP_ADDI) ;


assign RegDst   = (Op == OP_RTYPE);
assign Branch   = (Op == OP_BEQ);
assign MemWrite = (Op == OP_SW);
assign MemtoReg = (Op == OP_LW);
assign Jump     = (Op == OP_J);










assign ALUControl = ALUSrc ? 6'b100000 :
                    Branch ? 6'b100010 :
					             Funct;
	 


endmodule