Пример #1
0
        public MosfetModelGenerator()
        {
            // Default MOS levels
            Levels.Add(1, (string name, string type, string version) =>
            {
                var m = new Mosfet1Model(name);
                switch (type.ToLower())
                {
                case "nmos": m.SetParameter("nmos", true); break;

                case "pmos": m.SetParameter("pmos", true); break;
                }

                return(m);
            });

            Levels.Add(2, (string name, string type, string version) =>
            {
                var m = new Mosfet2Model(name);
                switch (type.ToLower())
                {
                case "nmos": m.SetParameter("nmos", true); break;

                case "pmos": m.SetParameter("pmos", true); break;
                }

                return(m);
            });

            Levels.Add(3, (string name, string type, string version) =>
            {
                var m = new Mosfet3Model(name);
                switch (type.ToLower())
                {
                case "nmos": m.SetParameter("nmos", true); break;

                case "pmos": m.SetParameter("pmos", true); break;
                }

                return(m);
            });
        }
Пример #2
0
        public void When_MOS1PMOSDifferentialPair_Expect_Reference()
        {
            var model = new Mosfet1Model("Model");

            model.SetParameter("pmos", true);
            model.SetParameter("vto", -0.7);
            model.SetParameter("kp", 12.57e-4);

            var ckt = new Circuit(
                new NodeMapper("VDD", "B12", "B13", "CTRL", "B14", "TH"),
                model,
                new VoltageSource("Vsupply", "VDD", "0", 5.0),
                new CurrentSource("IBBIAS", "VDD", "B12", 10e-6),
                new Mosfet1("MB1", "B13", "CTRL", "B12", "VDD", "Model"),
                new Mosfet1("MB2", "B14", "TH", "B12", "VDD", "Model"),
                new Resistor("RBD1", "B13", "0", 10e3),
                new Resistor("RBD2", "B14", "0", 10e3),

                // These resistors seem to be necessary for convergence... Any higher and the operating point can't be calculated
                // new Resistor("Racc1", "B12", "B13", 1e6),
                // new Resistor("Racc2", "B12", "B14", 1e6),

                new VoltageSource("INA", "CTRL", "0", 3.333333333),
                new VoltageSource("INB", "TH", "0", 1.6631)
                );

            // Calculate the operating point
            var op = new OP("op");

            op.ExportSimulationData += (sender, args) =>
            {
                var v = op.RealState.Solution;
            };

            // Disable source stepping and see if it converges
            var config = op.Configurations.Get <BaseConfiguration>();

            // config.SourceSteps = 0;

            op.Run(ckt);
        }
Пример #3
0
        public void When_NMOSIVCharacteristic_Expect_NoException()
        {
            // <example_DC>
            // Make the bipolar junction transistor
            var nmos = new Mosfet1("M1")
            {
                Model = "example"
            };

            nmos.Connect("d", "g", "0", "0");
            var nmosmodel = new Mosfet1Model("example");

            nmosmodel.SetParameter("kp", 150.0e-3);

            // Build the circuit
            var ckt = new Circuit(
                new VoltageSource("Vgs", "g", "0", 0),
                new VoltageSource("Vds", "d", "0", 0),
                nmosmodel,
                nmos
                );

            // Sweep the base current and vce voltage
            var dc = new DC("DC 1", new[]
            {
                new SweepConfiguration("Vgs", 0, 3, 0.2),
                new SweepConfiguration("Vds", 0, 5, 0.1),
            });

            // Export the collector current
            var currentExport = new RealPropertyExport(dc, "M1", "id");

            // Run the simulation
            dc.ExportSimulationData += (sender, args) =>
            {
                var vgsVoltage = dc.Sweeps[0].CurrentValue;
                var vdsVoltage = dc.Sweeps[1].CurrentValue;
                var current    = currentExport.Value;
            };
            dc.Run(ckt);
            // </example_DC>
        }
Пример #4
0
        public void When_NMOSIVCharacteristic_Expect_NoException()
        {
            // <example_DC>
            // Create the mosfet and its model
            var nmos      = new Mosfet1("M1", "d", "g", "0", "0", "example");
            var nmosmodel = new Mosfet1Model("example");

            nmosmodel.SetParameter("kp", 150.0e-3);

            // Build the circuit
            var ckt = new Circuit(
                new VoltageSource("Vgs", "g", "0", 0),
                new VoltageSource("Vds", "d", "0", 0),
                nmosmodel,
                nmos
                );

            // Sweep the base current and vce voltage
            var dc = new DC("DC 1", new[]
            {
                new ParameterSweep("Vgs", new LinearSweep(0, 3, 0.2)),
                new ParameterSweep("Vds", new LinearSweep(0, 5, 0.1)),
            });

            // Export the collector current
            var currentExport = new RealPropertyExport(dc, "M1", "id");

            // Run the simulation
            dc.ExportSimulationData += (sender, args) =>
            {
                var vgsVoltage = dc.GetCurrentSweepValue()[0];
                var vdsVoltage = dc.GetCurrentSweepValue()[1];
                var current    = currentExport.Value;
            };
            dc.Run(ckt);
            // </example_DC>
        }