diff options
author | Couriersud <couriersud@users.noreply.github.com> | 2013-12-31 15:35:08 +0000 |
---|---|---|
committer | Couriersud <couriersud@users.noreply.github.com> | 2013-12-31 15:35:08 +0000 |
commit | a8a62c3212fe7b0793d580d3fcbacd190485aa30 (patch) | |
tree | b5a43fa5d88898b81d22a1a751396558add6fa77 /nl_examples | |
parent | ce8e8234f0b1316c06d9871bc35e55751351f466 (diff) |
Enhanced the netlist parser and cleaned pong.c. Also added a folder nl_examples which contains standalone netlist examples. [couriersud]
The examples have a ".c" suffix. In eclipse, I get automatic syntax parsing and error notifications. The parser treats "#" preprocessor defines/includes just as comments.
All of these examples can be run through nltool:
./nltool -f nl_examples/opamp.c -t 1 -l OUT
runs the opamp example for 1 second of emulation time and logs the terminal named "OUT" to "netlist_log_OUT.log".
I'll post a simple script to the list to visualize those logs using gnuplot.
Diffstat (limited to 'nl_examples')
-rw-r--r-- | nl_examples/7400_astable.c | 33 | ||||
-rw-r--r-- | nl_examples/ne555_astable.c | 49 | ||||
-rw-r--r-- | nl_examples/opamp.c | 59 |
3 files changed, 141 insertions, 0 deletions
diff --git a/nl_examples/7400_astable.c b/nl_examples/7400_astable.c new file mode 100644 index 00000000000..d16e43392fd --- /dev/null +++ b/nl_examples/7400_astable.c @@ -0,0 +1,33 @@ +/* + * 7400_astable.c + * + */ + +#include "netlist/devices/net_lib.h" + +NETLIST_START(7400_astable) + + /* + * Astable multivibrator using two 7400 gates (or inverters) + * + */ + + /* Standard stuff */ + + NETDEV_SOLVER(Solver) + NETDEV_PARAM(Solver.FREQ, 48000) + + // astable NAND Multivibrator + NETDEV_R(R1, 1000) + NETDEV_C(C1, 1e-6) + TTL_7400_NAND(n1,R1.1,R1.1) + TTL_7400_NAND(n2,R1.2,R1.2) + NET_C(n1.Q, R1.2) + NET_C(n2.Q, C1.1) + NET_C(C1.2, R1.1) + + NETDEV_LOG(log2, C1.2) + //NETDEV_LOG(log2, n1.Q) + NETDEV_LOG(log3, n2.Q) + +NETLIST_END() diff --git a/nl_examples/ne555_astable.c b/nl_examples/ne555_astable.c new file mode 100644 index 00000000000..86cda0f869c --- /dev/null +++ b/nl_examples/ne555_astable.c @@ -0,0 +1,49 @@ +/* + * ne555_astable.c + * + */ + +#include "netlist/devices/net_lib.h" + +NETLIST_START(ne555_astable) + + /* + * Astable ne555 + * + */ + + /* Standard stuff */ + + NETDEV_SOLVER(Solver) + NETDEV_PARAM(Solver.FREQ, 48000) + + NETDEV_ANALOG_CONST(V5, 5) // 5V + + /* Wiring up the ne555 */ + + // astable NE555, 1.13 ms period + + NETDEV_R(RA, 5000) + NETDEV_R(RB, 3000) + NETDEV_C(C, 0.15e-6) + NETDEV_NE555(555) + + NET_C(GND, 555.GND) + NET_C(V5, 555.VCC) + NET_C(V5, 555.RESET) + + NET_C(RA.1, 555.VCC) + NET_C(RA.2, 555.DISCH) + + NET_C(RB.1, 555.DISCH) + NET_C(RB.2, 555.TRIG) + + NET_C(RB.2, 555.THRESH) + + NET_C(555.TRIG, C.1) + NET_C(C.2, GND) + + NETDEV_LOG(log2, C.1) + NETDEV_LOG(log3, 555.OUT) + +NETLIST_END() diff --git a/nl_examples/opamp.c b/nl_examples/opamp.c new file mode 100644 index 00000000000..6999b2ec57b --- /dev/null +++ b/nl_examples/opamp.c @@ -0,0 +1,59 @@ +/* + * opamp.c + * + */ + + +#include "netlist/devices/net_lib.h" + +NETLIST_START(opamp) + + /* Opamp model from + * + * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm + * + * Bandwidth 10Mhz + * + * This one is connected as a impedance changer + */ + + /* Standard stuff */ + + NETDEV_CLOCK(clk) + NETDEV_PARAM(clk.FREQ, 1000) // 1000 Hz + NETDEV_SOLVER(Solver) + NETDEV_PARAM(Solver.FREQ, 48000) + + /* Wiring up the opamp */ + + NET_C(PLUS, clk) + NET_C(MINUS, OUT) + + /* The opamp model */ + + NETDEV_VCCS(G1) + NETDEV_PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000 + NETDEV_R(RP1, 1000) + NETDEV_C(CP1, 1.59e-6) // <== change to 1.59e-3 for 10Khz bandwidth + NETDEV_VCVS(EBUF) + NETDEV_PARAM(EBUF.RO, 50) + NETDEV_PARAM(EBUF.G, 1) + + NET_ALIAS(PLUS, G1.IP) // Positive input + NET_ALIAS(MINUS, G1.IN) // Negative input + NET_ALIAS(OUT, EBUF.OP) // Opamp output ... + + NET_C(EBUF.ON, GND) + + NET_C(G1.ON, GND) + NET_C(RP1.2, GND) + NET_C(CP1.2, GND) + NET_C(EBUF.IN, GND) + + NET_C(RP1.1, G1.OP) + NET_C(CP1.1, RP1.1) + NET_C(EBUF.IP, RP1.1) + + //NETDEV_LOG(logX, OUT) + //NETDEV_LOG(logY, 4V) +NETLIST_END() |