Exemplo n.º 1
0
        public void ExecuteFullAdder_compareWITHHA()
        {
            int[] inputC_B = new int[2] {1,1};
            int[] inputB_A = new int[2] {1,1 };
            int[] inputOr = new int[2] {0, 0 };

            int[] outputExpectC_B = new int[2] { 0, 1 };
            int[] outputExpectB_A = new int[2] { 0, 1 };
            int[] outputTest = new int[2];
            int[] outputExpect = new int[2] { 0, 1 };

             var oHalfAdder = new HalfAdder();
            int[] outputC_B = oHalfAdder.ExecuteAdder(inputC_B);
            Assert.AreEqual(outputExpectC_B[0], outputC_B[0]);
            Assert.AreEqual(outputExpectC_B[1], outputC_B[1]);

            int[] outputB_A = oHalfAdder.ExecuteAdder(inputB_A);
            Assert.AreEqual(outputExpectB_A[0], outputB_A[0]);
            Assert.AreEqual(outputExpectB_A[1], outputB_A[1]);

            var oGate = new OrGate();
            oGate.Input = inputOr;
            outputTest[0]= oGate.Operate();
            outputTest[1] = outputB_A[1];

            Assert.AreEqual(outputTest[0], outputExpect[0]);
            Assert.AreEqual(outputTest[1], outputExpect[1]);
        }
Exemplo n.º 2
0
        public int[] ExecuteAdder(int[] x)
        {
            int[] result = new int[2];
            int[] Input = new int[2];
            int[] Output = new int[2];

            Input[0] = x[0];
            Input[1] = x[1];
            var oHalfAdd = new HalfAdder();
            Output = oHalfAdd.ExecuteAdder(Input);
            result[0] = Output[0];

            Input[0] = Output[1];
            Input[1] = x[2];
            Output = oHalfAdd.ExecuteAdder(Input);
            result[1] = Output[1];

            Input[0] = result[0];
            Input[1] = Output[0];
            var oOr = new OrGate();
            oOr.Input = Input;
            result[0] = oOr.Operate();
            return result;
        }
Exemplo n.º 3
0
        public int[] ExecuteAdder(int[] x)
        {
            int[] result = new int[2];
            int[] temp = new int[2];

            var oOr = new OrGate();
            oOr.Input = x;
            result[0] = oOr.Operate();

            var oAnd = new AndGate();
            oAnd.Input = x;
            result[1] = oAnd.Operate();

            temp[0] = result[0];

            var oInv = new InvGate();
            oInv.InputSingle = result[1];
            temp[1] = oInv.Operate();

            oAnd.Input = temp;
            result[0] = oAnd.Operate();
            return result;
        }