Esempio n. 1
0
        public bool Xor(bool A, bool B)
        {
            bool M0, M1;

            M0 = P1.And(P3.Not(A), B);
            M1 = P1.And(A, P4.Not(B));
            return(P2.Or(M0, M1));
        }
Esempio n. 2
0
        /*
         * Tabela
         * F2 F1 F0 Saída
         * 0  0  0  A and B
         * 0  0  1  A or B
         * 0  1  0  Not A
         * 0  1  1  Not B
         * 1  0  0  A + B
         * 1  0  1  A - B
         * 1  1  0    -
         * 1  1  1    -
         */

        public bool ULA1Bit(bool a, bool b, bool[] F, bool vem1, out bool vai1)
        {
            //a e b são os valores digitados pelo usuário
            //vetor F, reflete a escolha do usuário
            //vem 1 e vai 1 são usados pelo somador

            bool[] M  = new bool[8]; //opções
            bool[] d  = new bool[8]; //aquele que for verdadeiro, será a escolha do usuário
            bool[] Ma = new bool[8]; //habilita opção escolhida

            //calcula cada uma das opções
            M[0] = P0.And(a, b); //0  0  0  A and B
            M[1] = P1.Or(a, b);  // 0  0  1  A or B
            M[2] = P2.Not(a);
            M[3] = P3.Not(b);
            M[4] = add.Ativa(a, b, vem1, out vai1);  //soma
            M[5] = sub.Ativa(a, b, vem1, out vai1);; //subtração
            M[6] = false;                            // sem função
            M[7] = false;                            // sem função

            //descobre qual foi a escolha do usuário
            decod.decodificadorInteiro(F[2], F[1], F[0], out d[0], out d[1], out d[2], out d[3], out d[4], out d[5], out d[6], out d[7]);

            //de acordo com a escolha do usuário, habilita a função escolhida
            Ma[0] = P4.And(M[0], d[0]); //0  0  0  A and B
            Ma[1] = P5.And(M[1], d[1]); // 0  0  1  A or B
            Ma[2] = P6.And(M[2], d[2]);
            Ma[3] = P7.And(M[3], d[3]);
            Ma[4] = P8.And(M[4], d[4]);
            Ma[5] = P9.And(M[5], d[5]);
            Ma[6] = false; // sem função
            Ma[7] = false; // sem função

            return(P10.Or(Ma[0], Ma[1], Ma[2], Ma[3], Ma[4], Ma[5], Ma[6], Ma[7]));
        }
Esempio n. 3
0
        public bool Ativa(bool A, bool B, bool Vem1, out bool Vai1)
        {
            bool M0, M1, M2, SOMA;

            M0   = P0.And(A, B);
            M1   = P3.Xor(A, B);
            M2   = P1.And(M1, Vem1);
            Vai1 = P2.Or(M0, M2);
            SOMA = P4.Xor(M1, Vem1);
            return(SOMA);
        }
        /*
         * Tabela inteiro
         * F2 F1 F0 Saída
         * 0  0  0  A and B
         * 0  0  1  A or B
         * 0  1  0  Not A
         * 0  1  1  Not B
         * 1  0  0  A + B
         * 1  0  1  A - B
         * 1  1  0    -
         * 1  1  1    -
         *
         *
         * Tabela ponto flutuante
         * F0 Saída
         * 0    A + B
         * 1    A - B
         *
         */

        public void decodificadorInteiro(bool F2, bool F1, bool F0, out bool d0, out bool d1, out bool d2, out bool d3, out bool d4, out bool d5, out bool d6, out bool d7)
        {
            PortaNot p0 = new PortaNot();
            PortaNot p1 = new PortaNot();
            PortaNot p2 = new PortaNot();
            PortaAnd p3 = new PortaAnd();
            PortaAnd p4 = new PortaAnd();

            d0 = p3.And(p4.And(p0.Not(F2), p1.Not(F1)), p2.Not(F0)); //000 - negar as três
            d1 = p3.And(p4.And(p0.Not(F2), p1.Not(F1)), F0);         //001 - negar as duas primeiras
            d2 = p3.And(p4.And(p0.Not(F2), F1), p1.Not(F0));         //010 - negar a primeira e a última
            d3 = p3.And(p4.And(p0.Not(F2), F1), F0);                 //011 - negar a primeira
            d4 = p3.And(p4.And(F2, p1.Not(F1)), p2.Not(F0));         //100 - negar as duas últimas
            d5 = p3.And(p4.And(F2, p1.Not(F1)), F0);                 //101 - negar a do meio
            d6 = false;                                              //110 - negar a última
            d7 = false;                                              //111 -
        }