summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/examples
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-05-03 17:23:50 +0200
committer couriersud <couriersud@gmx.org>2020-05-03 17:23:50 +0200
commitb2c40086e6b003121e61719da93944f4e360e33d (patch)
tree47e7c257323a89c2e9a529f2c1817fd52d723a50 /src/lib/netlist/examples
parentb5be886e01cd04c410783997dcf8469e1a2733a2 (diff)
netlist: Add two noise sources. [Couriersud]
The two sources act as voltage sources, though noise may also be injected as conductivy or current noise. SYS_NOISE_MT_U: Mersenne Twister uniform noise SYS_NOISE_MT_N: Mersenne Twister normal noise nld_sys_noise is templated: using NETLIB_NAME(sys_noise_mt_u) = NETLIB_NAME(sys_noise)<plib::mt19937_64, plib::uniform_distribution_t>; Thus the approach is scalable. The implementation is state save aware, and thus reproducible results are guaranteed. An example use case is provided as well, see examples/noise.cpp.
Diffstat (limited to 'src/lib/netlist/examples')
-rw-r--r--src/lib/netlist/examples/noise.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/netlist/examples/noise.cpp b/src/lib/netlist/examples/noise.cpp
new file mode 100644
index 00000000000..870d526e477
--- /dev/null
+++ b/src/lib/netlist/examples/noise.cpp
@@ -0,0 +1,36 @@
+// license:CC0
+// copyright-holders:Couriersud
+
+/*
+ * noise.cpp
+ *
+ */
+
+//! [noise_example]
+#include "netlist/devices/net_lib.h"
+
+// ./nltool -t 1 -l X.3 -l X.4 -n oscillator src/lib/netlist/examples/noise.cpp
+// X.3 : Square out
+// X.4 : Triangle out
+
+NETLIST_START(noise)
+
+ SOLVER(Solver, 48000)
+
+ CLOCK(nclk, 2000)
+
+ SYS_NOISE_MT_N(noise, 0.5)
+
+ RES(R1,1000)
+ RES(R2,1000)
+
+ ANALOG_INPUT(VP, 12.0)
+
+ NET_C(nclk.Q, noise.I)
+ NET_C(VP, R1.1, nclk.VCC)
+ NET_C(noise.1, R1.2)
+ NET_C(noise.2, R2.1)
+ NET_C(GND, R2.2, nclk.GND)
+
+NETLIST_END()
+//! [noise_example]