Esempio n. 1
0
        public void OrGate()
        {
            var or = new OrGate(t, t, t, t, f);
            Assert.IsTrue(or[0]);

            or.Inputs = new[] { f, f, f, f, f };
            Assert.IsFalse(or[0]);

            or.Inputs = new IInputsOutput[] { f,f,f,f,f,f,f,f,f,f,t };
            Assert.IsTrue(or[0]);
        }
Esempio n. 2
0
        public void CustomXor()
        {
            // a XOR b = (a AND ¬b) OR (¬a AND b)
            Wire a = new Wire(f), b = new Wire(f);
            var xor = new OrGate(new AndGate(a, new Inverter(b)), new AndGate(new Inverter(a), b));

            Assert.AreEqual(false ^ false, xor[0]);

            a.Inputs[0] = f; b.Inputs[0] = t;
            Assert.AreEqual(false ^ true, xor[0]);

            a.Inputs[0] = t; b.Inputs[0] = f;
            Assert.AreEqual(true ^ false, xor[0]);

            a.Inputs[0] = t; b.Inputs[0] = t;
            Assert.AreEqual(true ^ true, xor[0]);
        }