From 9ea16d24e26218e505ef2a947ad89c99e19abc78 Mon Sep 17 00:00:00 2001 From: couriersud Date: Tue, 10 Sep 2019 21:42:28 +0200 Subject: [PATCH] nl_examples: commit some long overdue changes. (nw) --- nl_examples/7414.cpp | 33 +++++++++++++++++++++++++++++++++ nl_examples/cccs.c | 39 +++++++++++++++++++++++++++++++++++++++ nl_examples/cs.cpp | 27 +++++++++++++++++++++++++++ nl_examples/vs.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 nl_examples/7414.cpp create mode 100644 nl_examples/cccs.c create mode 100644 nl_examples/cs.cpp create mode 100644 nl_examples/vs.c diff --git a/nl_examples/7414.cpp b/nl_examples/7414.cpp new file mode 100644 index 00000000000..0fcfde9a7f4 --- /dev/null +++ b/nl_examples/7414.cpp @@ -0,0 +1,33 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * 7414.c + * + */ + +#include "netlist/devices/net_lib.h" + +NETLIST_START(7414_astable) + + /* + * Simple oscillator with 74LS14 + * + * ./nltool -f nl_examples/7414.cpp -l C37.1 -l U4A1.Q + * + */ + + /* Standard stuff */ + + SOLVER(Solver, 48000) + PARAM(Solver.ACCURACY, 1e-8) + + TTL_74LS14_GATE(U4A1) + //TTL_7404_GATE(U4A1) + RES(R39, 2200) + CAP(C37, CAP_U(1)) + NET_C(U4A1.A, R39.2, C37.1) + NET_C(GND, C37.2) + NET_C(GND, U4A1.GND) + NET_C(R39.1, U4A1.Q) + +NETLIST_END() diff --git a/nl_examples/cccs.c b/nl_examples/cccs.c new file mode 100644 index 00000000000..a1244677d20 --- /dev/null +++ b/nl_examples/cccs.c @@ -0,0 +1,39 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * cccs.c + * + */ + + +#include "netlist/devices/net_lib.h" + +NETLIST_START(cccs) + + CLOCK(clk, 1000) // 1000 Hz + SOLVER(Solver, 48000) + PARAM(Solver.ACCURACY, 1e-12) + PARAM(Solver.METHOD, "MAT_CR") + + CCCS(VV) + PARAM(VV.G, 1) + PARAM(VV.RI, 1e-3) + + RES(R2, 1000) + RES(R1, 1000) + NET_C(clk, VV.IP) + NET_C(VV.IN, R1.1) + NET_C(R1.2, GND) + + NET_C(R2.1, VV.OP) + NET_C(R2.2, GND) + NET_C(VV.ON, GND) + + /* Simple current source */ + + CS(CS1, 1) + RES(R3, 1) + NET_C(R3.1, CS1.P) + NET_C(GND, CS1.N, R3.2) + +NETLIST_END() diff --git a/nl_examples/cs.cpp b/nl_examples/cs.cpp new file mode 100644 index 00000000000..8229c5bc032 --- /dev/null +++ b/nl_examples/cs.cpp @@ -0,0 +1,27 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * cs.c + * + */ + + +#include "netlist/devices/net_lib.h" + +NETLIST_START(cs) + + SOLVER(Solver, 48000) + PARAM(Solver.ACCURACY, 1e-12) + PARAM(Solver.METHOD, "MAT_CR") + + /* Positive current flows into pin 1 of the current source + * Thus we observe a negative voltage on R1.1 ! + */ + CS(CS1, 1e-3) + RES(R1, 1000) + + NET_C(CS1.1, R1.1) + NET_C(GND, CS1.2, R1.2) + + LOG(log_P, R1.1) +NETLIST_END() diff --git a/nl_examples/vs.c b/nl_examples/vs.c new file mode 100644 index 00000000000..7d72398e297 --- /dev/null +++ b/nl_examples/vs.c @@ -0,0 +1,32 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * vs_cs.c + * + * Voltage and current source test + * + */ + +#include "netlist/devices/net_lib.h" + +NETLIST_START(vs) + + /* Standard stuff */ + + SOLVER(Solver, 480) + PARAM(Solver.ACCURACY, 1e-6) + PARAM(Solver.METHOD, "MAT_CR") + PARAM(Solver.DYNAMIC_TS, 1) + + RES(R1, 1000) + VS(VS1, 1) + PARAM(VS1.R, 1) + PARAM(VS1.FUNC, "T 10000.0 * sin 1.0 +") + NET_C(R1.1, VS1.P) + NET_C(R1.2, VS1.N) + NET_C(GND, VS1.N) + + //LOG(tt, VS1.P) + //LOG(tt1, R1.1) + +NETLIST_END()