Exemplo n.º 1
0
        public void Calculate(Register AX, Register BX, bool SubtractFlag, bool clock)
        {
            var FA = new fullAdder();

            data.reset();
            FA.setCarryIn(SubtractFlag);
            for (int i = 0; i < CS.wordsize; i++)
            {
                var x1 = new XOR();
                x1.setI(1, SubtractFlag);
                x1.setI(2, BX.getBit(i));
                FA.setI(1, AX.getBit(i));
                FA.setI(2, x1.getO());
                FA.Calculate();
                FA.setCarryIn(FA.getCarryOut());
                data.setBit(i, FA.getO(), clock);
            }
        }
Exemplo n.º 2
0
        public void Calculate()
        {
            var a1 = new AND();
            var a2 = new AND();
            var x1 = new XOR();
            var x2 = new XOR();
            var o1 = new OR();

            a1.setI(1, getI(1));
            a1.setI(2, getI(2));
            x1.setI(1, getI(1));
            x1.setI(2, getI(2));
            x2.setI(1, x1.getO());
            x2.setI(2, getCarryIn());
            a2.setI(1, x1.getO());
            a2.setI(2, getCarryIn());
            setO(x2.getO());
            o1.setI(1, a1.getO());
            o1.setI(2, a2.getO());
            setCarryOut(o1.getO());
        }