public override bool TestGate()
        {
            BitwiseDemux bwdm;
            Demux        m_gLocalDemux;
            Wire         w_local = new Wire();

            for (int l = 0; l < 2; l++)
            {
                w_local.Value = l;

                for (int j = 0; j < Math.Pow(2, Size); j++)
                {
                    bwdm = new BitwiseDemux(Size);
                    bwdm.Input.ConnectInput(InitTestVariables(j));
                    bwdm.ConnectControl(w_local);

                    for (int i = 0; i < Size; i++)
                    {
                        m_gLocalDemux = new Demux();
                        m_gLocalDemux.ConnectInput(bwdm.Input[i]);
                        m_gLocalDemux.ConnectControl(bwdm.Control);
                        if (bwdm.Output1[i].Value != m_gLocalDemux.Output1.Value || bwdm.Output2[i].Value != m_gLocalDemux.Output2.Value)
                        {
                            return(false);
                        }
                    }
                    //// UNCOMMENT THIS LINES TO SEE THE DEBUG PRINT
                    //System.Console.WriteLine("    Testing input " + " -> " + WStoString(bwdm.Input));
                    //System.Console.WriteLine("    Testing control " + " -> " + bwdm.Control);
                    //System.Console.WriteLine("    Testing output1 " + " -> " + WStoString(bwdm.Output1));
                    //System.Console.WriteLine("    Testing output2 " + " -> " + WStoString(bwdm.Output2));
                }
            }
            return(true);
        }
Exemple #2
0
        private void ConnectInput(CompleteBinaryTree <Demux> demuxGates)
        {
            Demux demuxGate = demuxGates.Root;

            demuxGate.Input.ConnectInput(Input);
            demuxGate.ConnectControl(Control[ControlBits - 1]);
        }
Exemple #3
0
        // checks each bit of the input and making demux operation on them
        // and connects the outputs
        public BitwiseDemux(int iSize)
        {
            Size    = iSize;
            Control = new Wire();
            Input   = new WireSet(Size);
            Output1 = new WireSet(Size);
            Output2 = new WireSet(Size);

            for (int bit = 0; bit < Size; bit++)
            {
                demux_op = new Demux();
                demux_op.ConnectInput(Input[bit]);
                demux_op.ConnectControl(Control);
                Output1[bit].ConnectInput(demux_op.Output1);
                Output2[bit].ConnectInput(demux_op.Output2);
            }
        }
Exemple #4
0
        public BitwiseDemux(int iSize)
        {
            Size    = iSize;
            Control = new Wire();
            Input   = new WireSet(Size);
            Output1 = new WireSet(iSize);
            Output2 = new WireSet(iSize);



            for (int i = 0; i < Size; i++)
            {
                demux = new Demux();
                demux.ConnectControl(Control);
                demux.ConnectInput(Input[i]);

                Output1[i].ConnectInput(demux.Output1);
                Output2[i].ConnectInput(demux.Output2);
            }
        }
Exemple #5
0
        public BitwiseDemux(int iSize)
        {
            Size    = iSize;
            Control = new Wire();
            Input   = new WireSet(Size);

            //your code here
            Output1 = new WireSet(Size);
            Output2 = new WireSet(Size);

            m_gates = new Demux[Size];
            for (int i = 0; i < Size; i++)
            {
                var gate = new Demux();
                m_gates[i] = gate;

                gate.ConnectControl(Control);
                gate.ConnectInput(Input[i]);
                Output1[i].ConnectInput(gate.Output1);
                Output2[i].ConnectInput(gate.Output2);
            }
        }
Exemple #6
0
        private void BuildDeuxGatesTree(CompleteBinaryTree <Demux> demuxGates)
        {
            int iControl = 0;

            for (int depth = demuxGates.Height - 1; depth >= 0; depth--)
            {
                foreach (var itemIndexPair in demuxGates.GetDepthEnumerator(depth))
                {
                    int   index = itemIndexPair.Index;
                    Demux demux = itemIndexPair.Item;
                    Demux left  = demuxGates.LeftChild(index);
                    Demux right = demuxGates.RightChild(index);

                    left.Input.ConnectInput(demux.Output1);
                    left.ConnectControl(Control[iControl]);
                    right.Input.ConnectInput(demux.Output2);
                    right.ConnectControl(Control[iControl]);
                }

                iControl++;
            }
        }