public AluOutput Apply(IByte a, IByte b, bool carryIn, Op op)
        {
            var opDecoder = _byteDecoder.Decode(op.One, op.Two, op.Three);

            var xOr              = _byteXOr.Apply(a, b);
            var or               = _byteOr.Apply(a, b);
            var and              = _byteAnd.Apply(a, b);
            var not              = _inverter.Invert(a);
            var shiftLeft        = _leftByteShifter.Shift(a, carryIn);
            var shiftRight       = _rightByteShifter.Shift(a, carryIn);
            var adder            = _byteAdder.Add(a, b, carryIn);
            var comparatorResult = _byteComparator.AreEqual(a, b, true, false);

            var enabledAdd        = _byteEnabler.Apply(adder.Sum, opDecoder[0]);
            var enabledShiftRight = _byteEnabler.Apply(shiftRight.Ouput, opDecoder[1]);
            var enabledShiftLeft  = _byteEnabler.Apply(shiftLeft.Ouput, opDecoder[2]);
            var enabledNot        = _byteEnabler.Apply(not, opDecoder[3]);
            var enabledAnd        = _byteEnabler.Apply(and, opDecoder[4]);
            var enabledOr         = _byteEnabler.Apply(or, opDecoder[5]);
            var enabledXOr        = _byteEnabler.Apply(xOr, opDecoder[6]);
            var enabledComparator = _byteEnabler.Apply(comparatorResult.output, opDecoder[7]);

            var carryOutAdd        = _and.Apply(adder.CarryOut, opDecoder[0]);
            var carryOutShiftRight = _and.Apply(shiftRight.ShiftOut, opDecoder[1]);
            var carryOutShiftLeft  = _and.Apply(shiftLeft.ShiftOut, opDecoder[2]);
            var carryOut           = _or.Apply(carryOutAdd, carryOutShiftRight, carryOutShiftLeft);

            var output = _aluWire.Apply(enabledAdd, enabledShiftLeft, enabledShiftRight, enabledNot, enabledAnd,
                                        enabledOr, enabledXOr, enabledComparator);
            var zero = _isZeroGate.IsZero(output);

            var aluOutput = new AluOutput
            {
                ALarger  = comparatorResult.ALarger,
                CarryOut = carryOut,
                Equal    = comparatorResult.equal,
                Output   = output,
                Zero     = zero
            };

            _updateFlags(new Caez {
                C = aluOutput.CarryOut, A = aluOutput.ALarger, E = aluOutput.Equal, Z = aluOutput.Zero
            });
            _updateAcc(aluOutput.Output);
            return(aluOutput);
        }
Пример #2
0
 protected override bool[] GetShifter(IRegister <IByte> inputRegister)
 {
     var(ouput, shiftOut) = _leftByteShifter.Shift(inputRegister.Output, ShiftIn);
     ShiftOut             = shiftOut;
     return(ouput.ToBits());
 }