当前位置: 首页>>代码示例>>C#>>正文


C# Circuit.doTicks方法代码示例

本文整理汇总了C#中Circuit.doTicks方法的典型用法代码示例。如果您正苦于以下问题:C# Circuit.doTicks方法的具体用法?C# Circuit.doTicks怎么用?C# Circuit.doTicks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Circuit的用法示例。


在下文中一共展示了Circuit.doTicks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnalogSwitchTest

        public void AnalogSwitchTest()
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();

            var analogSwitch0 = sim.Create<AnalogSwitch>();

            var grnd = sim.Create<Ground>();

            sim.Connect(logicIn0.leadOut, analogSwitch0.leadIn);
            sim.Connect(logicIn1.leadOut, analogSwitch0.leadSwitch);
            sim.Connect(analogSwitch0.leadOut, grnd.leadIn);

            logicIn0.toggle();
            logicIn1.toggle();

            sim.doTicks(100);
            Assert.AreEqual(0.25, Math.Round(grnd.getCurrent(), 12));

            logicIn1.toggle();
            sim.analyze();
            sim.doTicks(100);
            Assert.AreEqual(5E-10, Math.Round(grnd.getCurrent(), 12));
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:26,代码来源:SimpleTest.cs

示例2: DFlipFlopTest

        public void DFlipFlopTest()
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();

            var dflip0 = sim.Create<DFlipFlop>();

            var logicOut0 = sim.Create<LogicOutput>();
            var logicOut1 = sim.Create<LogicOutput>();

            sim.Connect(logicIn0.leadOut, dflip0.leadD);
            sim.Connect(logicIn1.leadOut, dflip0.leadCLK);

            sim.Connect(logicOut0.leadIn, dflip0.leadQ);
            sim.Connect(logicOut0.leadIn, dflip0.leadQL);

            sim.doTicks(200);

            Debug.Log();
            Debug.Log("D  ", dflip0.getLeadVoltage(0));
            Debug.Log("CLK", dflip0.getLeadVoltage(3));
            Debug.Log(" Q ", dflip0.getLeadVoltage(1));
            Debug.Log("|Q ", dflip0.getLeadVoltage(2));
            Debug.Log();

            logicIn0.toggle();
            logicIn1.toggle();
            sim.analyze();
            sim.doTicks(200);

            Debug.Log();
            Debug.Log("D  ", dflip0.getLeadVoltage(0));
            Debug.Log("CLK", dflip0.getLeadVoltage(3));
            Debug.Log(" Q ", dflip0.getLeadVoltage(1));
            Debug.Log("|Q ", dflip0.getLeadVoltage(2));
            Debug.Log();

            logicIn0.toggle();
            logicIn1.toggle();
            sim.analyze();
            sim.doTicks(200);

            Debug.Log();
            Debug.Log("D  ", dflip0.getLeadVoltage(0));
            Debug.Log("CLK", dflip0.getLeadVoltage(3));
            Debug.Log(" Q ", dflip0.getLeadVoltage(1));
            Debug.Log("|Q ", dflip0.getLeadVoltage(2));
            Debug.Log();

            Assert.Ignore();
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:53,代码来源:ChipTest.cs

示例3: AndGateTest

        public void AndGateTest(int in0, int in1, bool out0)
        {
            /*string js = System.IO.File.ReadAllText(string.Format("./{0}.json", "AndGateTest"));
            Circuit sim = JsonSerializer.DeserializeFromString<Circuit>(js);
            var voltage0 = sim.getElm(0) as LogicInputElm;
            var voltage1 = sim.getElm(1) as LogicInputElm;
            var logicOut = sim.getElm(2) as LogicOutputElm;*/

            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var logicOut = sim.Create<LogicOutput>();

            var gate = sim.Create<AndGate>();

            sim.Connect(logicIn0, 0, gate, 0);
            sim.Connect(logicIn1, 0, gate, 1);
            sim.Connect(logicOut.leadIn, gate.leadOut);

            //string js = JsonSerializer.SerializeToString(sim);
            //System.IO.File.WriteAllText(string.Format("./{0}.json", "AndGateTest"), js);

            logicIn0.setPosition(in0);
            logicIn1.setPosition(in1);

            sim.analyze();
            sim.doTicks(100);

            Assert.AreEqual(out0, logicOut.isHigh());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:31,代码来源:GateTest.cs

示例4: TwoToOneMuxTest

        public void TwoToOneMuxTest(int int0, int int1, int int2, bool out0)
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var logicIn2 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();

            var tri0 = sim.Create<TriStateBuffer>();
            var tri1 = sim.Create<TriStateBuffer>();

            var invert0 = sim.Create<Inverter>();

            sim.Connect(logicIn0.leadOut, tri0.leadIn);
            sim.Connect(logicIn1.leadOut, tri1.leadIn);

            sim.Connect(logicIn2.leadOut, tri0.leadGate);
            sim.Connect(logicIn2.leadOut, invert0.leadIn);
            sim.Connect(invert0.leadOut, tri1.leadGate);

            sim.Connect(tri0.leadOut, tri1.leadOut);

            logicIn0.setPosition(int0);
            logicIn1.setPosition(int1);
            logicIn2.setPosition(int2);

            sim.doTicks(100);

            Debug.Log(out0, tri0.getLeadVoltage(1), tri1.getLeadVoltage(1));
            Assert.AreEqual(out0, logicOut0.isHigh());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:32,代码来源:TriStateBufferTest.cs

示例5: DarlingtonPairTest

        public void DarlingtonPairTest(bool In0, double i0)
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create<VoltageInput>();

            var res0 = sim.Create<Resistor>(2000000);
            var res1 = sim.Create<Resistor>(300);

            var switch0 = sim.Create<SwitchSPST>();

            var npn0 = sim.Create<Transistor>(false);
            var npn1 = sim.Create<Transistor>(false);

            var groun0 = sim.Create<Ground>();

            sim.Connect(volt0.leadPos, res0.leadIn);
            sim.Connect(volt0.leadPos, res1.leadIn);

            sim.Connect(switch0, 0, res0, 1);

            sim.Connect(npn0, 0, switch0, 1);
            sim.Connect(npn0.leadCollector, res1.leadOut);
            sim.Connect(npn0.leadEmitter, npn1.leadBase);

            sim.Connect(npn1.leadCollector, res1.leadOut);
            sim.Connect(npn1.leadEmitter, groun0.leadIn);

            if(In0) switch0.toggle();

            sim.doTicks(100);

            Assert.AreEqual(i0, Math.Round(groun0.getCurrent(), 12));
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:34,代码来源:TransistorTest.cs

示例6: CMOSInverterTest

        public void CMOSInverterTest(bool in0, bool out0)
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();

            var volt0 = sim.Create<VoltageInput>(Voltage.WaveType.DC);
            var grnd0 = sim.Create<Ground>();

            var pmosf0 = sim.Create<PMosfet>();
            var nmosf0 = sim.Create<NMosfet>();

            sim.Connect(logicIn0.leadOut, pmosf0.leadGate);
            sim.Connect(logicIn0.leadOut, nmosf0.leadGate);

            sim.Connect(pmosf0.leadSrc, volt0.leadPos);
            sim.Connect(pmosf0.leadDrain, nmosf0.leadDrain);
            sim.Connect(nmosf0.leadSrc, grnd0.leadIn);

            sim.Connect(logicOut0.leadIn, pmosf0.leadDrain);

            if(in0) logicIn0.toggle();

            sim.doTicks(1000);

            Assert.AreEqual(out0, logicOut0.isHigh());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:28,代码来源:MosfetTest.cs

示例7: NANDTest

        public void NANDTest(bool in0, bool in1, bool in2, double in3)
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create<VoltageInput>();
            var res0 = sim.Create<Resistor>(5000);
            var nmos0 = sim.Create<NMosfet>();
            var nmos1 = sim.Create<NMosfet>();
            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();
            var grnd0 = sim.Create<Ground>();

            sim.Connect(volt0.leadPos, res0.leadIn);
            sim.Connect(res0.leadOut, nmos0.leadDrain);

            sim.Connect(logicOut0.leadIn, nmos0.leadDrain);
            sim.Connect(nmos0.leadGate, logicIn0.leadOut);

            sim.Connect(nmos0.leadSrc, nmos1.leadDrain);

            sim.Connect(nmos1.leadGate, logicIn1.leadOut);
            sim.Connect(nmos1.leadSrc, grnd0.leadIn);

            if(in0) logicIn0.toggle();
            if(in1) logicIn1.toggle();

            sim.doTicks(100);

            Assert.AreEqual(in2, logicOut0.isHigh());
            Assert.AreEqual(in3, Math.Round(grnd0.getCurrent(), 3));
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:32,代码来源:NMOSTest.cs

示例8: LawOfResistorsInSeriesTest

        public void LawOfResistorsInSeriesTest(int in0)
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create<DCVoltageSource>();
            var volt1 = sim.Create<DCVoltageSource>();
            var resCompare = sim.Create<Resistor>(in0 * 100);

            List<Resistor> resistors = new List<Resistor>();
            for(int i = 0; i < in0; i++)
                resistors.Add(sim.Create<Resistor>());

            sim.Connect(volt0.leadPos, resistors.First().leadIn);

            for(int i = 1; i < in0 - 1; i++)
                sim.Connect(resistors[i - 1].leadOut, resistors[i].leadIn);

            sim.Connect(volt0.leadNeg, resistors.Last().leadOut);

            sim.Connect(volt1.leadPos, resCompare.leadIn);
            sim.Connect(resCompare.leadOut, volt1.leadNeg);

            sim.doTicks(100);

            Assert.AreEqual(Math.Round(resistors.Last().getCurrent(), 12), Math.Round(resCompare.getCurrent(), 12));
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:26,代码来源:ResistorTest.cs

示例9: CurrentSourceTest

        public void CurrentSourceTest(double current)
        {
            Circuit sim = new Circuit();

            var source0 = sim.Create<CurrentSource>();
            source0.sourceCurrent = current;
            var res0 = sim.Create<Resistor>();

            sim.Connect(source0.leadOut, res0.leadIn);
            sim.Connect(res0.leadOut, source0.leadIn);

            var source1 = sim.Create<CurrentSource>();
            source1.sourceCurrent = current;
            var res1 = sim.Create<Resistor>();

            sim.Connect(source1.leadOut, res1.leadOut);
            sim.Connect(res1.leadIn, source1.leadIn);

            sim.doTicks(100);

            Assert.AreEqual(current, res0.getCurrent());
            Assert.AreEqual(-current, res1.getCurrent());
            Assert.AreEqual(current * res0.resistance, res0.getVoltageDelta());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:24,代码来源:SimpleTest.cs

示例10: InverterTest

        public void InverterTest(int in0, bool out0)
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var invert0 = sim.Create<Inverter>();
            var logicOut = sim.Create<LogicOutput>();

            sim.Connect(logicIn0.leadOut, invert0.leadIn);
            sim.Connect(invert0.leadOut, logicOut.leadIn);

            logicIn0.setPosition(in0);
            sim.analyze();

            sim.doTicks(100);

            Assert.AreEqual(out0, logicOut.isHigh());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:18,代码来源:SimpleTest.cs

示例11: InductorTest

        public void InductorTest(double inductance)
        {
            Circuit sim = new Circuit();

            var source0 = sim.Create<DCVoltageSource>();
            var inductor0 = sim.Create<InductorElm>(inductance);

            sim.Connect(source0.leadPos, inductor0.leadIn);
            sim.Connect(inductor0.leadOut, source0.leadNeg);

            double cycleTime = 1 / source0.frequency;
            double quarterCycleTime = cycleTime / 4;

            sim.doTicks((int)(cycleTime / sim.timeStep));

            double flux = inductor0.inductance * inductor0.getCurrent();	// F = I x L
            Assert.AreEqual(inductor0.getCurrent(), flux / inductor0.inductance); // I = F / L
            Assert.AreEqual(inductor0.inductance, flux / inductor0.getCurrent()); // L = F / I
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:19,代码来源:SimpleTest.cs

示例12: TriStateBufferTest

        public void TriStateBufferTest(int in0, int in1, bool in3)
        {
            Circuit sim = new Circuit();

            var logicIn0 = sim.Create<LogicInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();
            var tri0 = sim.Create<TriStateBuffer>();

            sim.Connect(logicIn0.leadOut, tri0.leadIn);
            sim.Connect(logicIn1.leadOut, tri0.leadGate);
            sim.Connect(logicOut0.leadIn, tri0.leadOut);

            logicIn0.setPosition(in0);
            logicIn1.setPosition(in1);

            sim.doTicks(100);

            Assert.AreEqual(in3, logicOut0.isHigh());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:20,代码来源:SimpleTest.cs

示例13: TwoToOneMuxTest

        public void TwoToOneMuxTest(int in0, int in1, int in2, bool out0)
        {
            Circuit sim = new Circuit();

            // tri-state buffer 0

            var volt0 = sim.Create<VoltageInput>();
            var logicIn0 = sim.Create<LogicInput>();
            var nand0 = sim.Create<NandGate>();
            var and0 = sim.Create<AndGate>();
            var invert0 = sim.Create<Inverter>();
            var pmos0 = sim.Create<PMosfet>();
            var nmos0 = sim.Create<NMosfet>();
            var grnd0 = sim.Create<Ground>();

            sim.Connect(nand0, 0, and0, 1);
            sim.Connect(nand0, 1, logicIn0, 0);
            sim.Connect(nand0, 1, invert0, 0);
            sim.Connect(invert0, 1, and0, 0);

            sim.Connect(logicIn0.leadOut, invert0.leadIn);

            sim.Connect(pmos0.leadGate, nand0.leadOut);
            sim.Connect(nmos0.leadGate, and0.leadOut);
            sim.Connect(volt0.leadPos, pmos0.leadSrc);
            sim.Connect(pmos0.leadDrain, nmos0.leadDrain);
            sim.Connect(nmos0.leadSrc, grnd0.leadIn);

            // tri-state buffer 1

            var volt1 = sim.Create<VoltageInput>();
            var logicIn1 = sim.Create<LogicInput>();
            var nand1 = sim.Create<NandGate>();
            var and1 = sim.Create<AndGate>();
            var invert1 = sim.Create<Inverter>();
            var pmos1 = sim.Create<PMosfet>();
            var nmos1 = sim.Create<NMosfet>();
            var grnd1 = sim.Create<Ground>();

            sim.Connect(nand1, 0, and1, 1);
            sim.Connect(nand1, 1, logicIn1, 0);
            sim.Connect(nand1, 1, invert1, 0);
            sim.Connect(invert1, 1, and1, 0);

            sim.Connect(logicIn1.leadOut, invert1.leadIn);

            sim.Connect(pmos1.leadGate, nand1.leadOut);
            sim.Connect(nmos1.leadGate, and1.leadOut);
            sim.Connect(volt1.leadPos, pmos1.leadSrc);
            sim.Connect(pmos1.leadDrain, nmos1.leadDrain);
            sim.Connect(nmos1.leadSrc, grnd1.leadIn);

            //

            var invert2 = sim.Create<Inverter>();
            var logicIn2 = sim.Create<LogicInput>();
            var logicOut0 = sim.Create<LogicOutput>();

            var or0 = sim.Create<OrGate>();

            sim.Connect(invert2, 1, nand0, 0);
            sim.Connect(invert2, 1, and0, 1);
            sim.Connect(invert2, 0, nand1, 0);
            sim.Connect(invert2, 0, and1, 1);

            sim.Connect(logicIn2, 0, and1, 1);
            sim.Connect(or0, 0, nmos0, 2);
            sim.Connect(or0, 1, nmos1, 2);
            sim.Connect(or0.leadOut, logicOut0.leadIn);

            logicIn0.setPosition(in0);
            logicIn1.setPosition(in1);
            logicIn2.setPosition(in2);

            sim.analyze();
            sim.doTicks(100);

            Assert.AreEqual(out0, logicOut0.isHigh());
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:79,代码来源:GateTest.cs

示例14: NMosfetTest

        public void NMosfetTest()
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create<VoltageInput>(Voltage.WaveType.DC);
            volt0.maxVoltage = 3.5;

            var volt1 = sim.Create<VoltageInput>(Voltage.WaveType.DC);
            volt1.maxVoltage = 5;

            var nmosf0 = sim.Create<NMosfet>();

            var grnd0 = sim.Create<Ground>();

            sim.Connect(volt0.leadPos, nmosf0.leadGate);
            sim.Connect(volt1.leadPos, nmosf0.leadDrain);
            sim.Connect(grnd0.leadIn, nmosf0.leadSrc);

            sim.doTicks(100);

            Debug.Log("n-Vds", nmosf0.getVoltageDelta(), nmosf0.getState());
            Assert.AreEqual(0.04, Math.Round(volt1.getCurrent(), 6));
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:23,代码来源:MosfetTest.cs

示例15: NPNTransistorTest

        public void NPNTransistorTest()
        {
            Circuit sim = new Circuit();

            var npn0 = sim.Create<Transistor>(false);

            var baseVoltage = sim.Create<VoltageInput>(Voltage.WaveType.DC);
            baseVoltage.maxVoltage = 0.7025;

            var collectorVoltage = sim.Create<VoltageInput>(Voltage.WaveType.DC);
            collectorVoltage.maxVoltage = 2;

            var ground = sim.Create<Ground>();

            var baseWire = sim.Create<Wire>();
            var collectorWire = sim.Create<Wire>();
            var emitterWire = sim.Create<Wire>();

            sim.Connect(baseVoltage.leadPos, baseWire.leadIn);
            sim.Connect(baseWire.leadOut, npn0.leadBase);

            sim.Connect(collectorVoltage.leadPos, collectorWire.leadIn);
            sim.Connect(collectorWire.leadOut, npn0.leadCollector);

            sim.Connect(ground.leadIn, emitterWire.leadIn);
            sim.Connect(emitterWire.leadOut, npn0.leadEmitter);

            sim.doTicks(100);

            TestUtils.Compare(baseWire.getCurrent(), 0.00158254, 8);
            TestUtils.Compare(collectorWire.getCurrent(), 0.15825359, 8);
            TestUtils.Compare(emitterWire.getCurrent(), -0.15983612, 8);
        }
开发者ID:DotNetSparky,项目名称:SharpCircuit,代码行数:33,代码来源:TransistorTest.cs


注:本文中的Circuit.doTicks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。