Beispiel #1
0
        public MultiBitAdder(int iSize)
        {
            Size   = iSize;
            Input1 = new WireSet(Size);
            Input2 = new WireSet(Size);
            Output = new WireSet(Size);
            //your code here

            Overflow = new Wire();

            var firstAdder = new HalfAdder();

            m_firstAdder = firstAdder;
            firstAdder.ConnectInput1(Input1[0]);
            firstAdder.ConnectInput2(Input2[0]);
            Output[0].ConnectInput(firstAdder.Output);

            var prevCout = firstAdder.CarryOutput;

            m_fullAdders = new FullAdder[iSize - 1];
            for (int i = 1; i < iSize; i++)
            {
                var adder = new FullAdder();
                m_fullAdders[i - 1] = adder;
                adder.ConnectInput1(Input1[i]);
                adder.ConnectInput2(Input2[i]);
                adder.CarryInput.ConnectInput(prevCout);
                Output[i].ConnectInput(adder.Output);
                prevCout = adder.CarryOutput;
            }

            Overflow.ConnectInput(prevCout);
        }
Beispiel #2
0
        // full addr operation is accomplished by using 2 half addrs and or gate for the output carrier
        public FullAdder()
        {
            // initilaize the gates
            CarryInput       = new Wire();
            CarryOutput      = new Wire();
            first_half_addr  = new HalfAdder();
            second_half_addr = new HalfAdder();
            or_op            = new OrGate();

            //connecting the first addr
            first_half_addr.ConnectInput1(Input1);
            first_half_addr.ConnectInput2(Input2);

            //connecting the second addr
            second_half_addr.ConnectInput1(first_half_addr.Output);
            second_half_addr.ConnectInput2(CarryInput);

            //or_op for the carry output
            or_op.ConnectInput1(second_half_addr.CarryOutput);
            or_op.ConnectInput2(first_half_addr.CarryOutput);

            //connecting the outputs
            Output.ConnectInput(second_half_addr.Output);
            CarryOutput.ConnectInput(or_op.Output);
        }
Beispiel #3
0
 public FullAdder()
 {
     CarryInput = new Wire();
     //your code here
     CarryOutput = new Wire();
     ha1         = new HalfAdder();
     ha2         = new HalfAdder();
     or          = new OrGate();
     ha2.ConnectInput1(ha1.Output);
     ha2.ConnectInput2(CarryInput);
     or.ConnectInput1(ha1.CarryOutput);
     or.ConnectInput2(ha2.CarryOutput);
     Input1      = ha1.Input1;
     Input2      = ha1.Input2;
     CarryOutput = or.Output;
     Output      = ha2.Output;
 }
Beispiel #4
0
        //your code here


        public FullAdder()
        {
            CarryInput = new Wire();
            //your code here
            HalfAdder ha1 = new HalfAdder();
            HalfAdder ha2 = new HalfAdder();
            OrGate    or  = new OrGate();

            ha1.ConnectInput1(Input1);
            ha1.ConnectInput2(Input2);
            ha2.ConnectInput2(CarryInput);
            ha2.ConnectInput1(ha1.Output);
            or.ConnectInput2(ha1.CarryOutput);
            or.ConnectInput1(ha2.CarryOutput);
            Output      = ha2.Output;
            CarryOutput = or.Output;
        }
Beispiel #5
0
        public FullAdder()
        {
            CarryInput = new Wire();

            //your code here
            ha  = new HalfAdder();
            ha2 = new HalfAdder();
            og  = new OrGate();

            ha.ConnectInput1(Input1);
            ha.ConnectInput2(Input2);
            ha2.ConnectInput1(ha.Output);
            ha2.ConnectInput2(CarryInput);
            og.ConnectInput1(ha2.CarryOutput);
            og.ConnectInput2(ha.CarryOutput);

            Output      = ha2.Output;
            CarryOutput = og.Output;
        }
Beispiel #6
0
        public FullAdder()
        {
            CarryInput  = new Wire();
            CarryOutput = new Wire();
            half1       = new HalfAdder();
            half2       = new HalfAdder();
            or          = new OrGate();

            half1.ConnectInput1(Input1);
            half1.ConnectInput2(Input2);


            half2.ConnectInput1(CarryInput);
            half2.ConnectInput2(half1.Output);

            or.ConnectInput1(half1.CarryOutput);
            or.ConnectInput2(half2.CarryOutput);

            CarryOutput.ConnectInput(or.Output);
            Output.ConnectInput(half2.Output);
        }
Beispiel #7
0
        public FullAdder()
        {
            CarryInput  = new Wire();
            CarryOutput = new Wire();

            var halfAdd1 = new HalfAdder();
            var halfAdd2 = new HalfAdder();
            var gOr      = new OrGate();

            halfAdd2.ConnectInput2(CarryInput);
            halfAdd2.ConnectInput1(halfAdd1.Output);

            gOr.ConnectInput1(halfAdd1.CarryOutput);
            gOr.ConnectInput2(halfAdd2.CarryOutput);

            Input1 = halfAdd1.Input1;
            Input2 = halfAdd1.Input2;

            CarryOutput = gOr.Output;
            Output      = halfAdd2.Output;
        }
Beispiel #8
0
        public FullAdder()
        {
            CarryInput = new Wire();
            //your code here
            CarryOutput  = new Wire();
            m_halfAdder1 = new HalfAdder();
            m_halfAdder2 = new HalfAdder();
            m_xorGate    = new XorGate();

            m_halfAdder1.ConnectInput1(Input1);
            m_halfAdder1.ConnectInput2(Input2);

            m_halfAdder2.ConnectInput1(m_halfAdder1.Output);
            m_halfAdder2.ConnectInput2(CarryInput);

            m_xorGate.ConnectInput1(m_halfAdder1.CarryOutput);
            m_xorGate.ConnectInput2(m_halfAdder2.CarryOutput);

            Output.ConnectInput(m_halfAdder2.Output);
            CarryOutput.ConnectInput(m_xorGate.Output);
        }
Beispiel #9
0
        public FullAdder()
        {
            CarryInput = new Wire();
            //your code here

            CarryOutput = new Wire();

            m_gHf = new HalfAdder();
            m_gHf.ConnectInput1(Input1);
            m_gHf.ConnectInput2(Input2);

            m_gHfCin = new HalfAdder();
            m_gHfCin.ConnectInput1(m_gHf.Output);
            m_gHfCin.ConnectInput2(CarryInput);
            Output.ConnectInput(m_gHfCin.Output);

            m_gOrCout = new OrGate();
            m_gOrCout.ConnectInput1(m_gHf.CarryOutput);
            m_gOrCout.ConnectInput2(m_gHfCin.CarryOutput);
            CarryOutput.ConnectInput(m_gOrCout.Output);
        }