Example #1
0
        public bool Xnor(bool A, bool B)
        {
            NOT not = new NOT();
            XOR xor = new XOR();

            return(not.Not(xor.Xor(A, B)));
        }
Example #2
0
        public bool Nor(bool A, bool B)
        {
            NOT not = new NOT();
            OR  or  = new OR();

            return(not.Not(or.Or(A, B)));
        }
Example #3
0
        public bool Nand(bool A, bool B)
        {
            NOT not = new NOT();
            AND and = new AND();

            return(not.Not(and.And(A, B)));
        }
Example #4
0
        public bool Xor(bool A, bool B)
        {
            AND and = new AND();
            NOT not = new NOT();
            OR  or  = new OR();

            bool A_or_B         = or.Or(A, B);
            bool A_and_B_negado = not.Not(and.And(A, B));
            bool saida          = and.And(A_or_B, A_and_B_negado);

            return(saida);
        }
Example #5
0
        public bool Somador(bool A, bool B, bool vem1, ref bool vai1)
        {
            NOT not = new NOT();
            AND and = new AND();
            OR  or  = new OR();
            XOR xor = new XOR();

            bool A_xor_B                     = xor.Xor(A, B);                    // (A XOR B)
            bool A_and_B                     = and.And(A, B);                    // (A AND B)
            bool Vem1_xor_A_xor_B            = xor.Xor(A_xor_B, vem1);           // ((Vem1 XOR A) XOR B)
            bool Vem1_and_A_xor_B            = and.And(A_xor_B, vem1);           // (Vem1 AND (A XOR B))
            bool Vem1_and_A_xor_B_or_A_and_B = or.Or(Vem1_and_A_xor_B, A_and_B); // ((Vem1 AND (A XOR B)) OR (A AND B))

            bool Saida = Vem1_xor_A_xor_B;                                       // ((Vem1 XOR A) XOR B)

            vai1 = Vem1_and_A_xor_B_or_A_and_B;                                  // ((Vem1 AND (A XOR B)) OR (A AND B))

            return(Saida);
        }
Example #6
0
        public bool Subtrator(bool A, bool B, bool Bi, ref bool Bo)
        {
            // Bi = Borrow in - Bo Borrow out

            NOT not = new NOT();
            AND and = new AND();
            OR  or  = new OR();
            XOR xor = new XOR();

            bool A_xor_B                               = xor.Xor(A, B);                              // (A XOR B)
            bool A_xor_B_xor_Bi                        = xor.Xor(A_xor_B, Bi);                       // ((A XOR B) XOR Bi)
            bool notA_and_B                            = and.And(not.Not(A), B);                     // (NOT(A) AND B)
            bool notA_and_Bi                           = and.And(not.Not(A), Bi);                    // (NOT(A) AND Bi)
            bool B_and_Bi                              = and.And(B, Bi);                             // (B AND Bi)
            bool notA_and_B_or_notA_and_Bi             = or.Or(notA_and_B, notA_and_Bi);             // ((NOT(A) AND Bi) OR (NOT(A) AND Bi))
            bool notA_and_B_or_notA_and_Bi_or_B_and_Bi = or.Or(notA_and_B_or_notA_and_Bi, B_and_Bi); // ((NOT(A) AND B) OR (NOT(A) AND Bi) OR (B AND Bi))

            bool Saida = A_xor_B_xor_Bi;                                                             // ((A XOR B) XOR Bi)

            Bo = notA_and_B_or_notA_and_Bi_or_B_and_Bi;                                              // ((NOT(A) AND B) OR (NOT(A) AND Bi) OR (B AND Bi))

            return(Saida);
        }