Esempio n. 1
0
        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);
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }