コード例 #1
0
        public void perfect_gate_logic_test(double A, double B, double S, double Cout)
        {
            var halfAdder = new HalfAdder(TTLGateTypeEnum.Perfect);

            halfAdder.A.Add(A);
            halfAdder.B.Add(B);
            halfAdder.RunCircuit();

            Assert.Equal(S, halfAdder.S(0));
            Assert.Equal(Cout, halfAdder.Cout(0));
        }
コード例 #2
0
        static void HalfAdderTest2()
        {
            var signalGenerator1 = new SignalGenerator();
            var signalGenerator2 = new SignalGenerator();

            bool signalHigh     = true;
            bool longSignalHigh = true;

            for (int i = 0; i < 200; i++)
            {
                if (i % 20 == 0)
                {
                    signalHigh = !signalHigh;
                }

                if (i % 40 == 0)
                {
                    longSignalHigh = !longSignalHigh;
                }

                signalGenerator1.AddSample(signalHigh ? 5 : 0);
                signalGenerator2.AddSample(longSignalHigh ? 5 : 0);
            }

            var adder1Circuit = new HalfAdder(TTLGateTypeEnum.LS);

            for (int i = 0; i < 200; i++)
            {
                adder1Circuit.A.Add(signalGenerator1.Output(i));
                adder1Circuit.B.Add(signalGenerator2.Output(i));
            }

            adder1Circuit.RunCircuit();



            for (int i = 0; i < 200; i++)
            {
                _logger.Debug($"T:{i:000} IN1:{signalGenerator1.Output(i)} IN2:{signalGenerator2.Output(i)}  S:{adder1Circuit.S(i)}  C:{adder1Circuit.Cout(i)}");
            }
        }