Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public MultiBitAdder(int iSize)
 {
     Size     = iSize;
     Input1   = new WireSet(Size);
     Input2   = new WireSet(Size);
     Output   = new WireSet(Size);
     Overflow = new Wire();
     FullAdder[] fa = new FullAdder[Size];
     for (int i = 0; i < Size; i++)
     {
         if (fa[i] == null)
         {
             fa[i] = new FullAdder();
         }
         fa[i].ConnectInput1(Input1[i]);
         fa[i].ConnectInput2(Input2[i]);
         Output[i].ConnectInput(fa[i].Output);
         if (i == Size - 1)
         {
             Overflow.ConnectInput(fa[i].CarryOutput);
         }
         else
         {
             fa[i + 1] = new FullAdder();
             fa[i + 1].CarryInput.ConnectInput(fa[i].CarryOutput);
         }
     }
 }
Exemplo n.º 3
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();
            Wire tempCarry = new Wire();

            FullAdder[] tempFullAdder = new FullAdder[Size];
            for (int i = 0; i < Size; i++)
            {
                tempFullAdder[i] = new FullAdder();
            }

            tempCarry.Value = 0;
            tempFullAdder[0].CarryInput.ConnectInput(tempCarry);
            tempFullAdder[0].ConnectInput1(Input1[0]);
            tempFullAdder[0].ConnectInput2(Input2[0]);
            Output[0].ConnectInput(tempFullAdder[0].Output);
            for (int i = 1; i < Size; i++)
            {
                tempCarry = tempFullAdder[i - 1].CarryOutput;
                tempFullAdder[i].CarryInput.ConnectInput(tempCarry);
                tempFullAdder[i].ConnectInput1(Input1[i]);
                tempFullAdder[i].ConnectInput2(Input2[i]);
                Output[i].ConnectInput(tempFullAdder[i].Output);
            }
            Overflow.ConnectInput(tempFullAdder[Size - 1].CarryOutput);
        }
Exemplo n.º 4
0
        // adding 2 binary numbers by using full adder for each bit
        public MultiBitAdder(int iSize)
        {
            //initilaize
            Size     = iSize;
            Input1   = new WireSet(Size);
            Input2   = new WireSet(Size);
            Output   = new WireSet(Size);
            Overflow = new Wire();
            // one extra full addr for the overflow bit
            full_addr_op_array = new FullAdder[Size + 1];

            for (int i = 0; i < Size + 1; i++)
            {
                full_addr_op_array[i] = new FullAdder();
            }

            //carry in the first bit is 0
            full_addr_op_array[0].CarryInput.Value = 0;

            for (int bit = 0; bit < Size; bit++)
            {
                full_addr_op_array[bit].ConnectInput1(Input1[bit]);
                full_addr_op_array[bit].ConnectInput2(Input2[bit]);

                Output[bit].ConnectInput(full_addr_op_array[bit].Output);
                full_addr_op_array[bit + 1].CarryInput.ConnectInput(full_addr_op_array[bit].CarryOutput);
            }
            Overflow.ConnectInput(full_addr_op_array[Size].CarryInput);
        }
Exemplo n.º 5
0
        public MultiBitAdder(int iSize)
        {
            Size     = iSize;
            Input1   = new WireSet(Size);
            Input2   = new WireSet(Size);
            Output   = new WireSet(Size);
            Overflow = new Wire();

            full1 = new FullAdder();

            full1.ConnectInput1(Input1[0]);
            full1.ConnectInput2(Input2[0]);
            Output[0].ConnectInput(full1.Output);

            for (int i = 1; i < Input1.Size; i++)
            {
                Wire temp_S = full1.Output;
                Wire temp_C = full1.CarryOutput;

                full1 = new FullAdder();

                full1.CarryInput.ConnectInput(temp_C);
                full1.ConnectInput1(Input1[i]);
                full1.ConnectInput2(Input2[i]);
                Output[i].ConnectInput(full1.Output);
            }


            Overflow.ConnectInput(full1.CarryOutput); // updating the overflow.
        }
Exemplo n.º 6
0
        public Add4()
        {
            input0 = new Nibble();
            input1 = new Nibble();
            output0 = new Nibble();
            carry = new Bit();

            carry.Bittype = Bit.BitType.Output;

            input0.Draggable = false;
            input1.Draggable = false;
            output0.Draggable = false;
            carry.Draggable = false;

            input0.Deletable = false;
            input1.Deletable = false;
            output0.Deletable = false;
            carry.Deletable = false;

            fa1 = new FullAdder();
            fa2 = new FullAdder();
            fa3 = new FullAdder();
            fa4 = new FullAdder();

            Connections.CrossConnect(input0.OutputPoint0, fa1.Input0);
            Connections.CrossConnect(input1.OutputPoint0, fa1.Input1);
            Connections.CrossConnect(fa1.OutputC, fa2.InputC);
            Connections.CrossConnect(input0.OutputPoint1, fa2.Input0);
            Connections.CrossConnect(input1.OutputPoint1, fa2.Input1);
            Connections.CrossConnect(fa2.OutputC, fa3.InputC);
            Connections.CrossConnect(input0.OutputPoint2, fa3.Input0);
            Connections.CrossConnect(input1.OutputPoint2, fa3.Input1);
            Connections.CrossConnect(fa3.OutputC, fa4.InputC);
            Connections.CrossConnect(input0.OutputPoint3, fa4.Input0);
            Connections.CrossConnect(input1.OutputPoint3, fa4.Input1);
            Connections.CrossConnect(fa4.OutputC, carry.InputPoint);
            Connections.CrossConnect(fa1.OutputS, output0.InputPoint0);
            Connections.CrossConnect(fa2.OutputS, output0.InputPoint1);
            Connections.CrossConnect(fa3.OutputS, output0.InputPoint2);
            Connections.CrossConnect(fa4.OutputS, output0.InputPoint3);

            fa1.InputC.IO = false;

            Controls.Add(input0);
            Controls.Add(input1);
            Controls.Add(output0);
            Controls.Add(carry);

            this.ContextMenuStrip = cms;
        }
Exemplo n.º 7
0
        public MultiBitAdder(int iSize)
        {
            Size   = iSize;
            Input1 = new WireSet(Size);
            Input2 = new WireSet(Size);
            Output = new WireSet(Size);
            //your code here
            fa = new FullAdder[Size];

            for (int i = 0; i < Size; i++)
            {
                fa[i] = new FullAdder();
                fa[i].ConnectInput1(Input1[i]);
                fa[i].ConnectInput2(Input2[i]);
                Output[i].ConnectInput(fa[i].Output);
                if (i > 0)
                {
                    fa[i].CarryInput.ConnectInput(fa[i - 1].CarryOutput);
                }
            }
            fa[0].CarryInput.Value = 0;
        }
Exemplo n.º 8
0
        public MultiBitAdder(int iSize)
        {
            Size     = iSize;
            Overflow = new Wire();
            Input1   = new WireSet(iSize);
            Input2   = new WireSet(iSize);
            Output   = new WireSet(iSize);
            var fullAdders = new FullAdder[iSize];

            try
            {
                for (int i = 0; i < iSize; i++)
                {
                    if (i == 0)
                    {
                        fullAdders[i] = new FullAdder();
                        fullAdders[i].CarryInput.Value = 0;
                        fullAdders[i].ConnectInput1(Input1[i]);
                        fullAdders[i].ConnectInput2(Input2[i]);
                        Output[i].ConnectInput(fullAdders[i].Output);
                        continue;
                    }

                    fullAdders[i] = new FullAdder();
                    fullAdders[i].ConnectInput1(Input1[i]);
                    fullAdders[i].ConnectInput2(Input2[i]);
                    fullAdders[i].CarryInput.ConnectInput(fullAdders[i - 1].CarryOutput);
                    Output[i].ConnectInput(fullAdders[i].Output);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Overflow = fullAdders[iSize - 1].CarryOutput;
            }
        }
Exemplo n.º 9
0
 public MultiBitAdder(int iSize)
 {
     Size   = iSize;
     Input1 = new WireSet(Size);
     Input2 = new WireSet(Size);
     Output = new WireSet(Size);
     //your code here
     FA       = new FullAdder[iSize];
     Overflow = new Wire();
     FA[0]    = new FullAdder();
     FA[0].ConnectInput1(Input1[0]);
     FA[0].ConnectInput2(Input2[0]);
     FA[0].CarryInput.Value = 0;
     Output[0].ConnectInput(FA[0].Output);
     for (int i = 1; i < iSize; i++)
     {
         FA[i] = new FullAdder();
         FA[i].ConnectInput1(Input1[i]);
         FA[i].ConnectInput2(Input2[i]);
         FA[i].CarryInput.ConnectInput(FA[i - 1].CarryOutput);
         Output[i].ConnectInput(FA[i].Output);
     }
     Overflow.ConnectInput(FA[Size - 1].CarryOutput);
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            OrGate               or        = new OrGate();
            XorGate              xor       = new XorGate();
            AndGate              and       = new AndGate();
            MuxGate              mux       = new MuxGate();
            Demux                demux     = new Demux();
            HalfAdder            halfAdder = new HalfAdder();
            FullAdder            fullAdder = new FullAdder();
            WireSet              wireSet   = new WireSet(9);
            BitwiseAndGate       bwag      = new BitwiseAndGate(2);
            BitwiseNotGate       bwng      = new BitwiseNotGate(3);
            BitwiseOrGate        bwog      = new BitwiseOrGate(2);
            BitwiseMux           bwm       = new BitwiseMux(2);
            BitwiseDemux         bwd       = new BitwiseDemux(2);
            MultiBitAndGate      mbag      = new MultiBitAndGate(4);
            MultiBitAdder        mba       = new MultiBitAdder(3);
            BitwiseMultiwayMux   bwmwm     = new BitwiseMultiwayMux(5, 4);
            BitwiseMultiwayDemux bwmwd     = new BitwiseMultiwayDemux(4, 4);
            SingleBitRegister    sbr       = new SingleBitRegister();
            MultiBitRegister     mbr       = new MultiBitRegister(4);

            if (!sbr.TestGate())
            {
                Console.WriteLine("SingleBitRegisterbugbug");
            }
            if (!mbr.TestGate())
            {
                Console.WriteLine("MultiBitRegisterbugbug");
            }
            ALU alu = new ALU(4);

            if (!alu.TestGate())
            {
                Console.WriteLine("ALUbugbug");
            }
            if (!bwmwd.TestGate())
            {
                Console.WriteLine("BitwiseMultiwayDemuxbugbug");
            }
            if (!bwmwm.TestGate())
            {
                Console.WriteLine("BitwiseMultiwayMuxbugbug");
            }
            if (!mba.TestGate())
            {
                Console.WriteLine("MultiBitAdderbugbug");
            }
            if (!mbag.TestGate())
            {
                Console.WriteLine("MultiBitAndGatebugbug");
            }
            if (!bwd.TestGate())
            {
                Console.WriteLine("BitWiseDemuxbugbug");
            }
            if (!bwm.TestGate())
            {
                Console.WriteLine("BitWiseMuxbugbug");
            }
            if (!bwog.TestGate())
            {
                Console.WriteLine("BitWiseOrGatebugbug");
            }
            if (!bwng.TestGate())
            {
                Console.WriteLine("BitWiseNotGatebugbug");
            }
            if (!bwag.TestGate())
            {
                Console.WriteLine("BitWiseAndGatebugbug");
            }
            wireSet.SetValue(137);
            wireSet.Set2sComplement(-32);
            if (!and.TestGate())
            {
                Console.WriteLine("andbugbug");
            }
            if (!or.TestGate())
            {
                Console.WriteLine("orbugbug");
            }
            if (!xor.TestGate())
            {
                Console.WriteLine("xorbugbug");
            }
            if (!mux.TestGate())
            {
                Console.WriteLine("muxbugbug");
            }
            if (!demux.TestGate())
            {
                Console.WriteLine("demuxbugbug");
            }
            if (!halfAdder.TestGate())
            {
                Console.WriteLine("HAbugbug");
            }
            if (!fullAdder.TestGate())
            {
                Console.WriteLine("FAbugbug");
            }
            Memory memory = new Memory(2, 6);

            if (!memory.TestGate())
            {
                Console.WriteLine("Membugbug");
            }
            Console.WriteLine("done");
            Console.ReadLine();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            AndGate   and   = new AndGate();
            OrGate    or    = new OrGate();
            XorGate   xor   = new XorGate();
            MuxGate   mux   = new MuxGate();
            Demux     demux = new Demux();
            HalfAdder ha    = new HalfAdder();
            FullAdder fa    = new FullAdder();

            if (!and.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done And");

            if (!or.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done Or");

            if (!xor.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done Xor");

            if (!mux.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done Mux");

            if (!demux.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done Demux");

            if (!ha.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done HalfAdder");

            if (!fa.TestGate())
            {
                Console.WriteLine("bugbug");
            }



            Console.WriteLine("done FullAdder");



            WireSet num = new WireSet(4);

            num.SetValue(6);
            Console.WriteLine(num.ToString());
            Console.WriteLine(num.GetValue());

            Console.WriteLine("trying 2's complement");
            WireSet num2 = new WireSet(4);

            num2.Set2sComplement(6);
            Console.WriteLine(num2.Get2sComplement());
            WireSet num3 = new WireSet(4);

            num3.Set2sComplement(-2);
            Console.WriteLine(num3.Get2sComplement());

            BitwiseAndGate BWAnd = new BitwiseAndGate(3);

            BWAnd.TestGate();

            BitwiseNotGate BWNot = new BitwiseNotGate(3);

            BWNot.TestGate();

            BitwiseOrGate BWOr = new BitwiseOrGate(3);

            BWOr.TestGate();

            BitwiseMux BWMux = new BitwiseMux(3);

            BWMux.TestGate();

            BitwiseDemux BWDemux = new BitwiseDemux(3);

            BWDemux.TestGate();

            MultiBitAndGate multiAnd = new MultiBitAndGate(3);

            multiAnd.TestGate();

            MultiBitAdder multiAdd = new MultiBitAdder(5);

            multiAdd.TestGate();

            BitwiseMultiwayMux multimux = new BitwiseMultiwayMux(8, 2);

            WireSet[] inp = new WireSet[4];
            inp[0] = new WireSet(8);
            inp[0].Set2sComplement(1);
            multimux.ConnectInput(0, inp[0]);
            inp[1] = new WireSet(8);
            inp[1].Set2sComplement(2);
            multimux.ConnectInput(1, inp[1]);
            inp[2] = new WireSet(8);
            inp[2].Set2sComplement(3);
            multimux.ConnectInput(2, inp[2]);
            inp[3] = new WireSet(8);
            inp[3].Set2sComplement(4);
            multimux.ConnectInput(3, inp[3]);



            WireSet control = new WireSet(2);

            control.Set2sComplement(3);
            multimux.ConnectControl(control);

            multimux.TestGate();

            BitwiseMultiwayDemux multidemux = new BitwiseMultiwayDemux(8, 1);


            ALU alu = new ALU(16);

            alu.TestGate();



            SingleBitRegister sbr = new SingleBitRegister();

            if (sbr.TestGate())
            {
                Console.WriteLine("sbr IS OK");
            }

            MultiBitRegister mbr = new MultiBitRegister(8);

            if (mbr.TestGate())
            {
                Console.WriteLine("mbr IS OK");
            }

            Memory mem = new Memory(3, 6);

            if (mem.TestGate())
            {
                Console.WriteLine("mem IS OK");
            }



            Console.ReadLine();
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            //This is an example of a testing code that you should run for all the gates that you create
//
//            //Create a gate
//            AndGate and = new AndGate();
//            //Test that the unit testing works properly
//            if (!and.TestGate())
//                Console.WriteLine("bugbug");
//
//            //test or gate
//            OrGate or = new OrGate();
//            if (or.TestGate())
//                Console.WriteLine("done or");
//
            //test xor gate
//            XorGate xor = new XorGate();
//            if (xor.TestGate())
//                Console.WriteLine("done xor");
//
//            MultiBitAndGate mbaGate = new MultiBitAndGate(4);
//            if (mbaGate.TestGate())
//                Console.WriteLine("done mba");
//
//            MultiBitOrGate mboGate = new MultiBitOrGate(4);
//            if (mboGate.TestGate())
//                Console.WriteLine("done mbo");
//
//            MuxGate mux = new MuxGate();
//            if (mux.TestGate())
//                Console.WriteLine("done mux");
//
//            Demux demux = new Demux();
//            if (demux.TestGate())
//                Console.WriteLine("done demux");
//
//            BitwiseAndGate bwAg = new BitwiseAndGate(4);
//            if (bwAg.TestGate())
//                Console.WriteLine("done bwAg");
//
//            BitwiseNotGate bwNg = new BitwiseNotGate(4);
//            if (bwNg.TestGate())
//                Console.WriteLine("done bwNg");
////
//            BitwiseOrGate bwOg = new BitwiseOrGate(4);
//            if (bwOg.TestGate())
//                Console.WriteLine("done bwOg");
//
//
//            WireSet ws = new WireSet(4);
//            ws.SetValue(8);
//            Console.WriteLine(ws.ToString());
////
//            BitwiseMux bwMux = new BitwiseMux(4);
//            if (bwMux.TestGate())
//                Console.WriteLine("done bwMux");
//
//            BitwiseDemux bwDemux = new BitwiseDemux(4);
//            if (bwDemux.TestGate())
//                Console.WriteLine("done bwDemux");
//
//            BitwiseMultiwayMux bwMwMux = new BitwiseMultiwayMux(3,3);
//            if (bwMwMux.TestGate())
//                Console.WriteLine("done bwMwMux");


            OrGate               or        = new OrGate();
            XorGate              xor       = new XorGate();
            AndGate              and       = new AndGate();
            MuxGate              mux       = new MuxGate();
            Demux                demux     = new Demux();
            HalfAdder            halfAdder = new HalfAdder();
            FullAdder            fullAdder = new FullAdder();
            WireSet              wireSet   = new WireSet(9);
            BitwiseAndGate       bwag      = new BitwiseAndGate(2);
            BitwiseNotGate       bwng      = new BitwiseNotGate(3);
            BitwiseOrGate        bwog      = new BitwiseOrGate(2);
            BitwiseMux           bwm       = new BitwiseMux(2);
            BitwiseDemux         bwd       = new BitwiseDemux(2);
            MultiBitAndGate      mbag      = new MultiBitAndGate(4);
            MultiBitAdder        mba       = new MultiBitAdder(3);
            BitwiseMultiwayMux   bwmwm     = new BitwiseMultiwayMux(5, 4);
            BitwiseMultiwayDemux bwmwd     = new BitwiseMultiwayDemux(4, 4);
            SingleBitRegister    sbr       = new SingleBitRegister();
            MultiBitRegister     mbr       = new MultiBitRegister(4);

            wireSet.SetValue(137);
            wireSet.Set2sComplement(-32);
            if (halfAdder.TestGate())
            {
                Console.WriteLine("HAbugbug");
            }
            if (fullAdder.TestGate())
            {
                Console.WriteLine("FAbugbug");
            }
            if (mba.TestGate())
            {
                Console.WriteLine("MultiBitAdderbugbug");
            }
            ALU alu = new ALU(16);

            if (alu.TestGate())
            {
                Console.WriteLine("ALU bugbug");
            }

            Console.WriteLine("FINISH HIM");
        }
Exemplo n.º 13
0
        public ALU(int iSize)
        {
            Size      = iSize;
            InputX    = new WireSet(Size);
            InputY    = new WireSet(Size);
            ZeroX     = new Wire();
            ZeroY     = new Wire();
            NotX      = new Wire();
            NotY      = new Wire();
            F         = new Wire();
            NotOutput = new Wire();
            Negative  = new Wire();
            Zero      = new Wire();


            //Create and connect all the internal components

            //init the muxes
            Zx        = new BitwiseMux(iSize);
            Zy        = new BitwiseMux(iSize);
            nX        = new BitwiseMux(iSize);
            nY        = new BitwiseMux(iSize);
            f         = new BitwiseMux(iSize);
            nO        = new BitwiseMux(iSize);
            notX      = new BitwiseNotGate(iSize);
            notY      = new BitwiseNotGate(iSize);
            notOutput = new BitwiseNotGate(iSize);
            and       = new BitwiseAndGate(iSize);
            fullAdder = new FullAdder();


            WireSet zeros = new WireSet(iSize);

            for (int i = 0; i < zeros.Size; i++)
            {
                zeros[i].ConnectInput(Zero);
            }
            Zx.ConnectInput1(InputX);
            Zx.ConnectInput2(zeros);
            Zx.ConnectControl(ZeroX);

            /*for (int i = 0; i < zeros.Size; i++)
             * {
             *  zeros[i].ConnectInput(Zero);
             * }*/
            Zy.ConnectInput1(InputY);
            Zy.ConnectInput2(zeros);
            Zy.ConnectControl(ZeroY);

            nX.ConnectInput1(Zx.Output);
            notX.ConnectInput(Zx.Output);
            nX.ConnectInput2(notX.Output);
            nX.ConnectControl(NotX);

            nY.ConnectInput1(Zy.Output);
            notY.ConnectInput(Zy.Output);
            nY.ConnectInput2(notY.Output);
            nY.ConnectControl(NotY);

            and.ConnectInput1(nX.Output);
            and.ConnectInput2(nY.Output);

            WireSet addResult = new WireSet(iSize);

            fullAdder.ConnectInput1(nX.Output[0]);
            fullAdder.ConnectInput2(nY.Output[0]);
            Wire Co = fullAdder.CarryOutput;

            addResult[0].ConnectInput(fullAdder.Output);
            for (int i = 1; i < iSize; i++)
            {
                fullAdder = new FullAdder();
                fullAdder.ConnectInput1(nX.Output[i]);
                fullAdder.ConnectInput2(nY.Output[i]);
                fullAdder.CarryInput.ConnectInput(Co);
                Co = new Wire();
                Co.ConnectInput(fullAdder.CarryOutput);
                addResult[i].ConnectInput(fullAdder.Output);
            }

            f.ConnectInput1(and.Output);
            f.ConnectInput2(addResult);
            f.ConnectControl(F);

            nO.ConnectInput1(f.Output);
            notOutput.ConnectInput(f.Output);
            nO.ConnectInput2(notOutput.Output);
            nO.ConnectControl(NotOutput);

            Output = nO.Output;
        }
Exemplo n.º 14
0
 private void fullAdderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FullAdder fa = new FullAdder();
     fa.Location = calcLocation();
     fa.Size = s.Equals(LogicGate.small) ? LGComponent.small : s.Equals(LogicGate.medium) ? LGComponent.medium : LGComponent.large;
     fa.Font = new Font(fa.Font.FontFamily, fs);
     fa.Name = fa.GetType().Name + namecntr++;
     this.Controls.Add(fa);
 }