Example #1
0
        private void BuildMuxGatesTree(CompleteBinaryTree <MuxGate> muxGates)
        {
            int iControl = 1;

            for (int depth = muxGates.Height - 1; depth >= 0; depth--)
            {
                foreach (var itemIndexPair in muxGates.GetDepthEnumerator(depth))
                {
                    int     index = itemIndexPair.Index;
                    MuxGate gate  = itemIndexPair.Item;
                    gate.ConnectInput1(muxGates.LeftChild(index).Output);
                    gate.ConnectInput2(muxGates.RightChild(index).Output);
                    gate.ConnectControl(Control[iControl]);
                }

                iControl++;
            }
        }
Example #2
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++;
            }
        }