diff options
author | couriersud <couriersud@gmx.org> | 2019-03-29 19:44:50 +0100 |
---|---|---|
committer | couriersud <couriersud@gmx.org> | 2019-03-29 19:44:50 +0100 |
commit | 6d17870736edad51142078bbd4d89c610edc78e6 (patch) | |
tree | 43e0676098366a88d3f28892ab64ca9ad1f04b5b | |
parent | e4ff0d3322b1da0c747fd98d3100e4bea840bada (diff) |
netlist: Timing bug fix. Affects regression tests. [Couriersud]
This fixes a rounding issue in the ptime code. This bug surfaced when I
tested netlist with picosecond resolution in ptime.
This will have a small impact on every driver using netlist. For
breakout, it required to adjust the color overlay.
-rw-r--r-- | nl_examples/cmos_inverter_clk.cpp | 63 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptime.h | 2 | ||||
-rw-r--r-- | src/mame/layout/breakout.lay | 6 |
3 files changed, 67 insertions, 4 deletions
diff --git a/nl_examples/cmos_inverter_clk.cpp b/nl_examples/cmos_inverter_clk.cpp new file mode 100644 index 00000000000..e869a478a6c --- /dev/null +++ b/nl_examples/cmos_inverter_clk.cpp @@ -0,0 +1,63 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * cmos_inverter_clk + * + */ + + +#include "netlist/devices/net_lib.h" +#include "netlist/analog/nld_twoterm.h" + +#define USE_CLOCK (1) + +NETLIST_START(cmos_inverter_clk) + /* Standard stuff */ + + //SOLVER(Solver, 480000) + SOLVER(Solver, 1e5) + //SOLVER(Solver, 100000000000) + PARAM(Solver.ACCURACY, 1e-7 ) + PARAM(Solver.NR_LOOPS, 500000) + PARAM(Solver.DYNAMIC_TS, 1) + PARAM(Solver.DYNAMIC_LTE, 1e-5) + PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 2e-8) + ANALOG_INPUT(V5, 5) + +// CLOCK(clk, 0.5e6) + +#if (USE_CLOCK) + CLOCK(V, 5000) + //CLOCK(V, 500000) +#else + VS(V, 5) + PARAM(V.FUNC, "T 5e6 *") +#endif + + MOSFET(P, "PMOS(VTO=-0.5 GAMMA=0.5 TOX=20n)") + MOSFET(M, "NMOS(VTO=0.5 GAMMA=0.5 TOX=20n)") + RES(RG, 1) + + NET_C(P.S, V5) + NET_C(P.D, M.D) +#if (USE_CLOCK) + NET_C(GND, M.S) + NET_C(V.Q, RG.1) +#else + NET_C(GND, M.S, V.N) + NET_C(V.P, RG.1) +#endif + NET_C(RG.2, M.G, P.G) + + // capacitance over D - S +#if 0 + CAP(C, CAP_N(1)) + NET_C(M.D, C.1) + NET_C(M.S, C.2) +#endif +#if 0 + LOG(log_G, M.G) + LOG(log_D, M.D) + LOGD(log_X, RG.1, RG.2) +#endif +NETLIST_END() diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h index 32ccc4f7b0d..250e1b8f683 100644 --- a/src/lib/netlist/plib/ptime.h +++ b/src/lib/netlist/plib/ptime.h @@ -112,7 +112,7 @@ namespace plib static constexpr ptime from_sec(const internal_type s) noexcept { return ptime(s, UINT64_C( 1)); } static constexpr ptime from_hz(const internal_type hz) noexcept { return ptime(1 , hz); } static constexpr ptime from_raw(const internal_type raw) noexcept { return ptime(raw); } - static constexpr ptime from_double(const double t) noexcept { return ptime(static_cast<internal_type>( t * static_cast<double>(RES)), RES); } + static constexpr ptime from_double(const double t) noexcept { return ptime(static_cast<internal_type>(t * static_cast<double>(RES) + 0.5), RES); } static constexpr ptime zero() noexcept { return ptime(0, RES); } static constexpr ptime quantum() noexcept { return ptime(1, RES); } diff --git a/src/mame/layout/breakout.lay b/src/mame/layout/breakout.lay index 1677851b6b0..1d656beb018 100644 --- a/src/mame/layout/breakout.lay +++ b/src/mame/layout/breakout.lay @@ -22,15 +22,15 @@ <color red="1" green="1" blue="0.25" /> </rect> <rect> - <bounds left="0" top="88" right="192" bottom="236" /> + <bounds left="0" top="88" right="192" bottom="231" /> <color red="1" green="1" blue="1" /> </rect> <rect> - <bounds left="0" top="236" right="192" bottom="244" /> + <bounds left="0" top="231" right="192" bottom="238" /> <color red="0.125" green="0.125" blue="1" /> </rect> <rect> - <bounds left="0" top="244" right="192" bottom="258" /> + <bounds left="0" top="238" right="192" bottom="244" /> <color red="1" green="1" blue="1" /> </rect> </element> |