Example #1
0
        public void sr_latch_circuit_reset()
        {
            var srLatch = new SRLatch(TTLGateTypeEnum.Perfect);

            srLatch.S.Add(0);
            srLatch.R.Add(5);
            srLatch.RunCircuit();

            Assert.True(srLatch.CircuitCompletedSuccessfully);
            Assert.Equal(5, srLatch.Q(0));
            Assert.Equal(0, srLatch.QBar(0));
        }
Example #2
0
        private void SimulateSRLatch()
        {
            bool carryInSignalHigh = true;

            for (int i = 0; i < 200; i++)
            {
                if (i % 30 == 0 && i > 0)
                {
                    carryInSignalHigh = !carryInSignalHigh;
                }

                if (i < 100)
                {
                    signalGenerator1.AddSample(carryInSignalHigh ? 5 : 0);
                    signalGenerator2.AddSample(5);
                }
                else
                {
                    signalGenerator1.AddSample(5);
                    signalGenerator2.AddSample(carryInSignalHigh ? 5 : 0);
                }
            }

            for (int i = 0; i < 200; i++)
            {
                if (i == 0)
                {
                    srLatch.S.Add(5);
                    srLatch.R.Add(0);
                }
                else
                {
                    srLatch.S.Add(signalGenerator1.Output(i));
                    srLatch.R.Add(signalGenerator2.Output(i));
                }
            }

            srLatch.RunCircuit();
        }