コード例 #1
0
ファイル: ValidatorTest.cs プロジェクト: Bryans91/Adder
        public void TestInfiniteLoop()
        {
            /** Basic circuit **/
            //Adder
            Node not1 = new Not()
            {
                Name = "Not 1"
            };
            Node or1 = new Or()
            {
                Name = "Or 1"
            };

            Node and1 = new And()
            {
                Name = "And 1"
            };
            Node nor1 = new Nor()
            {
                Name = "Nor 1"
            };

            bool input1 = true;
            bool input2 = false;

            //Edges
            not1.AddDefaultInputs("IN1", input1); //input 1

            or1.AddDefaultInputs("IN1", input1);
            or1.AddDefaultInputs("IN2", input2);


            //endpoint AND
            not1.AddOutput(and1);
            or1.AddOutput(and1);

            //endpoint NOR
            not1.AddOutput(nor1);
            or1.AddOutput(nor1);


            //create infinite loop
            or1.OutputList.Add(new Edge(or1, not1));

            Circuit circuit = new Circuit()
            {
                Name = "Circuit 1"
            };

            circuit.Components.Add(not1);
            circuit.Components.Add(or1);
            circuit.Components.Add(and1);
            circuit.Components.Add(nor1);


            circuit.Run(new Validator());
        }
コード例 #2
0
ファイル: NorTests.cs プロジェクト: Fyzxs/FluentTypes
        public void ShouldShortCircuit()
        {
            //Arrange
            Bool subject = new Nor(Bool.True, new ExplodingBool());

            //Act
            bool actual = subject;

            //Assert
            actual.Should().BeFalse();
        }
コード例 #3
0
ファイル: NorTests.cs プロジェクト: Fyzxs/FluentTypes
        public void ShouldReturnFalseIfBothAreTrue()
        {
            //Arrange
            Nor subject = new Nor(Bool.True, Bool.True);

            //Act
            bool actual = subject;

            //Assert
            actual.Should().BeFalse();
        }
コード例 #4
0
        public AbstractValue Evaluate(Nor expr)
        {
            AbstractValue left  = Evaluate(expr.Left);
            AbstractValue right = Evaluate(expr.Right);

            if ((left != null) && (right != null) && (left is STD_LOGIC_VALUE) && (right is STD_LOGIC_VALUE))
            {
                return(STD_LOGIC_VALUE.NOR(left as STD_LOGIC_VALUE, right as STD_LOGIC_VALUE));
            }
            throw new NotImplementedException();
        }
コード例 #5
0
ファイル: NorTest.cs プロジェクト: Bryans91/Adder
        public void TestHandleNegative()
        {
            Node node = new Nor();

            node.AddDefaultInputs("IN1", true);
            node.AddDefaultInputs("IN2", false);
            node.SetDefaultInputs();

            node.Handle();

            Assert.IsFalse(node.Output);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ZakkDiaz/Nandit
        static void Main(string[] args)
        {
            Not not = new Not();
            And and = new And();
            Or  or  = new Or();
            Nor nor = new Nor();

            Console.WriteLine($"Not");
            Test(not, 1);
            Console.WriteLine($"And");
            Test(and, 2);
            Console.WriteLine($"Or");
            Test(or, 2);
            Console.WriteLine($"Nor");
            Test(nor, 2);
        }
コード例 #7
0
ファイル: Cleaner.cs プロジェクト: Bryans91/AdderV2
 public void Visit(Nor visited)
 {
     ResetNode(visited);
 }
コード例 #8
0
 public void Visit(Nor visited)
 {
     PrintStandardNode(visited);
 }
コード例 #9
0
ファイル: Connections.cs プロジェクト: Bryans91/Adder
 public void Visit(Nor visited)
 {
     NodeConnectsTo(visited);
 }
コード例 #10
0
 public void Visit(Nor visited)
 {
     HasCorrectNumberOfInputNodes(visited, 2);
     IsInfinite(visited);
 }
コード例 #11
0
    public void AddPhysicalGate(CircuitDevice circuitDevice)
    {
        Primitive newSimGate;

        switch (circuitDevice.logicType)
        {
        case Utils.LogicType.NOT:
            newSimGate = new Not("replaceMe");
            break;

        case Utils.LogicType.NAND:
            newSimGate = new Nand("replaceMe");
            break;

        case Utils.LogicType.AND:
            newSimGate = new And("replaceMe");
            break;

        case Utils.LogicType.OR:
            newSimGate = new Or("replaceMe");
            break;

        case Utils.LogicType.NOR:
            newSimGate = new Nor("replaceMe");
            break;

        case Utils.LogicType.XOR:
            newSimGate = new Xor("replaceMe");
            break;

        case Utils.LogicType.XNOR:
            newSimGate = new Xnor("replaceMe");
            break;

        case Utils.LogicType.Lever:
            newSimGate = new Lever("replaceMe");
            (circuitDevice as LeverDevice).leverGate = newSimGate as Lever;
            break;

        case Utils.LogicType.Indicator:
            newSimGate = new Indicator("replaceMe");
            break;

        case Utils.LogicType.Clock:
            newSimGate = new Clock("replaceMe");
            break;

        case Utils.LogicType.ShiftRegister4:
            newSimGate = new ShiftRegister("replaceMe", 4);
            break;

        case Utils.LogicType.ShiftRegister8:
            newSimGate = new ShiftRegister("replaceMe", 8);
            break;

        case Utils.LogicType.DFF:
            newSimGate = new DFF("replaceMe");
            break;

        case Utils.LogicType.FA1:
            newSimGate = new Adder("replaceMe", 1);
            break;

        default:
            Debug.LogError("Unknown circuit device type, object name: " + circuitDevice.gameObject.name);
            return;
        }

        newSimGate.position          = circuitDevice.transform.localPosition;
        circuitDevice.associatedGuid = newSimGate.guid;

        circuitSimObject.Add(newSimGate);

        physicalDevices.Add(newSimGate.guid, circuitDevice);
    }