Esempio n. 1
0
        public override bool TestGate()
        {
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 0;
            NotOutput.Value = 1;
            Console.WriteLine("Case 1: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 0;
            NotOutput.Value = 0;
            Console.WriteLine("Case 2: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            InputX.SetValue(6);
            InputY.SetValue(5);

            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 0;
            NotOutput.Value = 1;
            if (Output.Get2sComplement() != -7 || Zero.Value != 0 || Negative.Value != 1)
            {
                return(false);
            }

            ZeroX.Value     = 1;
            ZeroY.Value     = 1;
            NotX.Value      = 0;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 0;
            if (Output.Get2sComplement() != 0 || Zero.Value != 1 || Negative.Value != 0)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public override bool TestGate()
        {
            Console.WriteLine("TESTING FOR X=5, Y=3");
            //1
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 0;
            Console.WriteLine("Case 1: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");
            //2
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 2: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //3
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 1;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 0;
            Console.WriteLine("Case 3: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //4
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 0;
            NotOutput.Value = 0;
            Console.WriteLine("Case 4: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //5
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 0;
            NotOutput.Value = 0;
            Console.WriteLine("Case 5: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //6
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 0;
            NotOutput.Value = 1;
            Console.WriteLine("Case 6: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //7
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 0;
            NotOutput.Value = 1;
            Console.WriteLine("Case 7: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //8
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 8: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //9
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 9: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //10
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 1;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 10: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //11
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 1;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 11: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //12
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 1;
            NotY.Value      = 1;
            F.Value         = 1;
            NotOutput.Value = 0;
            Console.WriteLine("Case 12: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //13
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 1;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 0;
            Console.WriteLine("Case 13: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //14
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 0;
            Console.WriteLine("Case 14: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //15
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 15: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //16
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 0;
            NotY.Value      = 1;
            F.Value         = 1;
            NotOutput.Value = 1;
            Console.WriteLine("Case 16: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //17
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 0;
            ZeroY.Value     = 0;
            NotY.Value      = 0;
            F.Value         = 0;
            NotOutput.Value = 0;
            Console.WriteLine("Case 17: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            //18
            InputX.Set2sComplement(5);
            InputY.Set2sComplement(5);
            ZeroX.Value     = 0;
            NotX.Value      = 1;
            ZeroY.Value     = 0;
            NotY.Value      = 1;
            F.Value         = 0;
            NotOutput.Value = 1;
            Console.WriteLine("Case 18: " + Output.Get2sComplement());
            Console.WriteLine("Negative?: " + Negative.Value);
            Console.WriteLine("Zero?: " + Zero.Value);
            Console.WriteLine("");

            return(true);
            //    throw new NotImplementedException();
        }