def test_branch_if_not_equal_true(self):
        execute = Execute()
        alu_branch_output = True
        branch_address = create_sized_binary_num(
            ExecuteStageTest.pc_value +
            (decode_signed_binary_number(ExecuteStageTest.immediate, 32) << 2),
            32)[:32]

        ALUOp = 0b01
        function_field = create_sized_binary_num(4, 6)
        opcode = '000101'
        ALUSrc = False
        MemWrite = False
        MemtoReg = False
        MemRead = False
        Branch = True
        jump = False
        jump_address = None

        execute.receive_data(ExecuteStageTest.data1, ExecuteStageTest.data2,
                             ExecuteStageTest.immediate,
                             ExecuteStageTest.pc_value, jump_address)
        execute.receive_control_information(ALUOp, function_field, opcode,
                                            ALUSrc, MemWrite, MemtoReg,
                                            MemRead, Branch, jump)
        self.assertEqual(alu_branch_output, execute.alu_branch)
        self.assertEqual(branch_address, execute.branch_address)
    def test_receive_values_and_update_addi(self):
        execute = Execute()
        expected_result = create_sized_binary_num(
            decode_signed_binary_number(ExecuteStageTest.data1, 32) +
            decode_signed_binary_number(ExecuteStageTest.immediate, 32),
            32)[:32]

        ALUOp = 0b11
        function_field = '100000'
        opcode = create_sized_binary_num(8, 6)
        ALUSrc = True
        MemWrite = False
        MemtoReg = False
        MemRead = False
        Branch = False
        jump = False
        jump_address = None

        execute.receive_data(ExecuteStageTest.data1, ExecuteStageTest.data2,
                             ExecuteStageTest.immediate,
                             ExecuteStageTest.pc_value, jump_address)
        execute.receive_control_information(ALUOp, function_field, opcode,
                                            ALUSrc, MemWrite, MemtoReg,
                                            MemRead, Branch, jump)
        self.assertEqual(expected_result, execute.alu_output)
    def test_slt_set(self):
        execute = Execute()
        expected_result = create_sized_binary_num(1, 32)[:32]

        ALUOp = 0b10
        function_field = create_sized_binary_num(42, 6)
        opcode = None
        ALUSrc = False
        MemWrite = False
        MemtoReg = False
        MemRead = False
        Branch = False
        jump = False
        jump_address = None

        execute.receive_data(ExecuteStageTest.data2, ExecuteStageTest.data1,
                             ExecuteStageTest.immediate,
                             ExecuteStageTest.pc_value, jump_address)
        execute.receive_control_information(ALUOp, function_field, opcode,
                                            ALUSrc, MemWrite, MemtoReg,
                                            MemRead, Branch, jump)
        self.assertEqual(expected_result, execute.alu_output)