예제 #1
0
        private void InitBasicElements()
        {
            _cplmtor = new TComplementor();
            _adder   = new TAdder();

            if (_adder.BitWidth != _cplmtor.BitWidth)
            {
                throw new ArgumentException("Bit width between adder and complementor are not match.");
            }

            _xorGate  = new XORGate();
            _subNexus = new CrossNexus(null, _cplmtor.Invert, _adder.CarryInput, _xorGate.Input1);

            _cplmtor.Outputs.Connect(_adder.Number2Inputs);
            _adder.CarryOutput.ConnectTo(_xorGate.Input2);
        }
예제 #2
0
        private void Init8BitsTest()
        {
            _8BitsNumber1Switches = new Switches(8);
            _8BitsNumber2Switches = new Switches(8);
            Init8BitsLights();
            _carryInPowerFor8Bits  = new PowerSupplier();
            _carryOutLightFor8Bits = new IndicatorLight();

            _8BitsAdder = new Adder8Bits();

            _8BitsAdder.Number1Inputs.Connect(_8BitsNumber1Switches.Outputs);
            _8BitsAdder.Number2Inputs.Connect(_8BitsNumber2Switches.Outputs);
            _8BitsAdder.CarryInput.ConnectTo(_carryInPowerFor8Bits.Output);
            _8BitsAdder.SumOutputs.Connect(_8BitsSumLights.Select(l => l.Input as InputEndpoint));
            _8BitsAdder.CarryOutput.ConnectTo(_carryOutLightFor8Bits.Input);
        }