summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/formats/a26_cas.cpp2
-rw-r--r--src/lib/formats/a5105_dsk.cpp2
-rw-r--r--src/lib/formats/abc800_dsk.cpp2
-rw-r--r--src/lib/formats/abcfd2_dsk.cpp2
-rw-r--r--src/lib/formats/ace_tap.cpp2
-rw-r--r--src/lib/formats/acorn_dsk.cpp10
-rw-r--r--src/lib/formats/adam_cas.cpp2
-rw-r--r--src/lib/formats/adam_dsk.cpp2
-rw-r--r--src/lib/formats/agat840k_hle_dsk.cpp2
-rw-r--r--src/lib/formats/aim_dsk.cpp2
-rw-r--r--src/lib/formats/ami_dsk.cpp2
-rw-r--r--src/lib/formats/ap2_dsk.cpp12
-rw-r--r--src/lib/formats/ap_dsk35.cpp4
-rw-r--r--src/lib/formats/apf_apt.cpp2
-rw-r--r--src/lib/formats/apollo_dsk.cpp2
-rw-r--r--src/lib/formats/applix_dsk.cpp2
-rw-r--r--src/lib/formats/asst128_dsk.cpp2
-rw-r--r--src/lib/formats/atari_dsk.cpp2
-rw-r--r--src/lib/formats/atom_tap.cpp2
-rw-r--r--src/lib/formats/basicdsk.cpp6
-rw-r--r--src/lib/formats/bw12_dsk.cpp2
-rw-r--r--src/lib/formats/bw2_dsk.cpp2
-rw-r--r--src/lib/formats/c3040_dsk.cpp2
-rw-r--r--src/lib/formats/c4040_dsk.cpp2
-rw-r--r--src/lib/formats/camplynx_dsk.cpp2
-rw-r--r--src/lib/formats/cassimg.cpp4
-rw-r--r--src/lib/formats/cbm_tap.cpp2
-rw-r--r--src/lib/formats/cgen_cas.cpp2
-rw-r--r--src/lib/formats/comx35_dsk.cpp2
-rw-r--r--src/lib/formats/concept_dsk.cpp2
-rw-r--r--src/lib/formats/coupedsk.cpp2
-rw-r--r--src/lib/formats/cqm_dsk.cpp4
-rw-r--r--src/lib/formats/csw_cas.cpp4
-rw-r--r--src/lib/formats/d71_dsk.cpp2
-rw-r--r--src/lib/formats/d80_dsk.cpp2
-rw-r--r--src/lib/formats/d81_dsk.cpp2
-rw-r--r--src/lib/formats/d82_dsk.cpp2
-rw-r--r--src/lib/formats/d88_dsk.cpp2
-rw-r--r--src/lib/formats/dcp_dsk.cpp2
-rw-r--r--src/lib/formats/dim_dsk.cpp4
-rw-r--r--src/lib/formats/dip_dsk.cpp2
-rw-r--r--src/lib/formats/dmk_dsk.cpp2
-rw-r--r--src/lib/formats/dmv_dsk.cpp2
-rw-r--r--src/lib/formats/ds9_dsk.cpp2
-rw-r--r--src/lib/formats/dsk_dsk.cpp4
-rw-r--r--src/lib/formats/dvk_mx_dsk.cpp2
-rw-r--r--src/lib/formats/ep64_dsk.cpp2
-rw-r--r--src/lib/formats/esq16_dsk.cpp2
-rw-r--r--src/lib/formats/esq8_dsk.cpp2
-rw-r--r--src/lib/formats/excali64_dsk.cpp2
-rw-r--r--src/lib/formats/fc100_cas.cpp2
-rw-r--r--src/lib/formats/fdd_dsk.cpp2
-rw-r--r--src/lib/formats/fdi_dsk.cpp2
-rw-r--r--src/lib/formats/flopimg.cpp12
-rw-r--r--src/lib/formats/fm7_cas.cpp2
-rw-r--r--src/lib/formats/fmsx_cas.cpp2
-rw-r--r--src/lib/formats/fmtowns_dsk.cpp2
-rw-r--r--src/lib/formats/gtp_cas.cpp2
-rw-r--r--src/lib/formats/hect_dsk.cpp2
-rw-r--r--src/lib/formats/hect_tap.cpp2
-rw-r--r--src/lib/formats/hp_ipc_dsk.cpp2
-rw-r--r--src/lib/formats/hxcmfm_dsk.cpp2
-rw-r--r--src/lib/formats/imageutl.cpp2
-rw-r--r--src/lib/formats/imd_dsk.cpp4
-rw-r--r--src/lib/formats/img_dsk.cpp378
-rw-r--r--src/lib/formats/img_dsk.h55
-rw-r--r--src/lib/formats/ioprocs.cpp6
-rw-r--r--src/lib/formats/ioprocs.h4
-rw-r--r--src/lib/formats/ipf_dsk.cpp2
-rw-r--r--src/lib/formats/iq151_dsk.cpp2
-rw-r--r--src/lib/formats/itt3030_dsk.cpp2
-rw-r--r--src/lib/formats/jvc_dsk.cpp8
-rw-r--r--src/lib/formats/kaypro_dsk.cpp2
-rw-r--r--src/lib/formats/kc85_dsk.cpp2
-rw-r--r--src/lib/formats/kc_cas.cpp2
-rw-r--r--src/lib/formats/kim1_cas.cpp2
-rw-r--r--src/lib/formats/lviv_lvt.cpp2
-rw-r--r--src/lib/formats/m5_dsk.cpp2
-rw-r--r--src/lib/formats/mbee_cas.cpp2
-rw-r--r--src/lib/formats/mfi_dsk.cpp2
-rw-r--r--src/lib/formats/mm_dsk.cpp2
-rw-r--r--src/lib/formats/ms0515_dsk.cpp2
-rw-r--r--src/lib/formats/mz_cas.cpp4
-rw-r--r--src/lib/formats/nanos_dsk.cpp2
-rw-r--r--src/lib/formats/naslite_dsk.cpp2
-rw-r--r--src/lib/formats/nes_dsk.cpp4
-rw-r--r--src/lib/formats/nfd_dsk.cpp2
-rw-r--r--src/lib/formats/orao_cas.cpp2
-rw-r--r--src/lib/formats/oric_tap.cpp2
-rw-r--r--src/lib/formats/p6001_cas.cpp2
-rw-r--r--src/lib/formats/pc98_dsk.cpp4
-rw-r--r--src/lib/formats/pc98fdi_dsk.cpp2
-rw-r--r--src/lib/formats/pc_dsk.cpp4
-rw-r--r--src/lib/formats/phc25_cas.cpp2
-rw-r--r--src/lib/formats/pmd_cas.cpp2
-rw-r--r--src/lib/formats/ppg_dsk.cpp2
-rw-r--r--src/lib/formats/primoptp.cpp2
-rw-r--r--src/lib/formats/pyldin_dsk.cpp2
-rw-r--r--src/lib/formats/ql_dsk.cpp2
-rw-r--r--src/lib/formats/rk_cas.cpp2
-rw-r--r--src/lib/formats/rx50_dsk.cpp2
-rw-r--r--src/lib/formats/sc3000_bit.cpp2
-rw-r--r--src/lib/formats/sdf_dsk.cpp2
-rw-r--r--src/lib/formats/sf7000_dsk.cpp2
-rw-r--r--src/lib/formats/smx_dsk.cpp2
-rw-r--r--src/lib/formats/sol_cas.cpp2
-rw-r--r--src/lib/formats/sorc_cas.cpp2
-rw-r--r--src/lib/formats/sorc_dsk.cpp4
-rw-r--r--src/lib/formats/sord_cas.cpp4
-rw-r--r--src/lib/formats/spc1000_cas.cpp2
-rw-r--r--src/lib/formats/st_dsk.cpp2
-rw-r--r--src/lib/formats/svi_cas.cpp2
-rw-r--r--src/lib/formats/tandy2k_dsk.cpp2
-rw-r--r--src/lib/formats/td0_dsk.cpp4
-rw-r--r--src/lib/formats/thom_cas.cpp4
-rw-r--r--src/lib/formats/thom_dsk.cpp4
-rw-r--r--src/lib/formats/ti99_dsk.cpp6
-rw-r--r--src/lib/formats/tiki100_dsk.cpp2
-rw-r--r--src/lib/formats/trd_dsk.cpp2
-rw-r--r--src/lib/formats/trs_cas.cpp2
-rw-r--r--src/lib/formats/tvc_cas.cpp2
-rw-r--r--src/lib/formats/tvc_dsk.cpp2
-rw-r--r--src/lib/formats/tzx_cas.cpp2
-rw-r--r--src/lib/formats/uef_cas.cpp6
-rw-r--r--src/lib/formats/vg5k_cas.cpp2
-rw-r--r--src/lib/formats/vt_cas.cpp2
-rw-r--r--src/lib/formats/wavfile.cpp4
-rw-r--r--src/lib/formats/x07_cas.cpp2
-rw-r--r--src/lib/formats/x1_tap.cpp2
-rw-r--r--src/lib/formats/xdf_dsk.cpp2
-rw-r--r--src/lib/formats/zx81_p.cpp2
-rw-r--r--src/lib/netlist/analog/nld_fourterm.h15
-rw-r--r--src/lib/netlist/analog/nld_generic_models.h23
-rw-r--r--src/lib/netlist/analog/nld_mosfet.cpp6
-rw-r--r--src/lib/netlist/analog/nld_opamps.cpp2
-rw-r--r--src/lib/netlist/analog/nld_switches.cpp11
-rw-r--r--src/lib/netlist/analog/nlid_fourterm.cpp20
-rw-r--r--src/lib/netlist/analog/nlid_fourterm.h57
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.cpp5
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.h9
-rw-r--r--src/lib/netlist/build/makefile6
-rw-r--r--src/lib/netlist/devices/net_lib.cpp3
-rw-r--r--src/lib/netlist/devices/net_lib.h4
-rw-r--r--src/lib/netlist/devices/nld_2716.cpp2
-rw-r--r--src/lib/netlist/devices/nld_4006.cpp100
-rw-r--r--src/lib/netlist/devices/nld_4006.h50
-rw-r--r--src/lib/netlist/devices/nld_4020.cpp1
-rw-r--r--src/lib/netlist/devices/nld_4066.cpp10
-rw-r--r--src/lib/netlist/devices/nld_7485.cpp3
-rw-r--r--src/lib/netlist/devices/nld_7493.cpp2
-rw-r--r--src/lib/netlist/devices/nld_82S126.cpp2
-rw-r--r--src/lib/netlist/devices/nld_log.cpp2
-rw-r--r--src/lib/netlist/devices/nld_r2r_dac.cpp3
-rw-r--r--src/lib/netlist/devices/nld_r2r_dac.h5
-rw-r--r--src/lib/netlist/devices/nld_system.cpp2
-rw-r--r--src/lib/netlist/devices/nlid_cmos.h41
-rw-r--r--src/lib/netlist/devices/nlid_proxy.cpp4
-rw-r--r--src/lib/netlist/devices/nlid_system.h20
-rw-r--r--src/lib/netlist/devices/nlid_truthtable.cpp12
-rw-r--r--src/lib/netlist/devices/nlid_truthtable.h2
-rw-r--r--src/lib/netlist/examples/7400_astable.c44
-rw-r--r--src/lib/netlist/examples/74123_mstable.c48
-rw-r--r--src/lib/netlist/examples/7414.cpp18
-rw-r--r--src/lib/netlist/examples/9602_mstable.c56
-rw-r--r--src/lib/netlist/examples/LM3900_test.cpp56
-rw-r--r--src/lib/netlist/examples/bjt.c50
-rw-r--r--src/lib/netlist/examples/bjt_eb.c46
-rw-r--r--src/lib/netlist/examples/bjt_eb_pnp.c34
-rw-r--r--src/lib/netlist/examples/breakout.c490
-rw-r--r--src/lib/netlist/examples/cccs.c24
-rw-r--r--src/lib/netlist/examples/cd4066.c48
-rw-r--r--src/lib/netlist/examples/cdelay.c40
-rw-r--r--src/lib/netlist/examples/cmos_inverter.cpp16
-rw-r--r--src/lib/netlist/examples/cmos_inverter_clk.cpp16
-rw-r--r--src/lib/netlist/examples/congo_bongo.c10
-rw-r--r--src/lib/netlist/examples/cs.cpp8
-rw-r--r--src/lib/netlist/examples/diode.c28
-rw-r--r--src/lib/netlist/examples/kidniki.c88
-rw-r--r--src/lib/netlist/examples/mm5837_noise.c22
-rw-r--r--src/lib/netlist/examples/msx_mixer_stage.c78
-rw-r--r--src/lib/netlist/examples/ne555_astable.c50
-rw-r--r--src/lib/netlist/examples/nmos_fet.cpp44
-rw-r--r--src/lib/netlist/examples/norton_opamp.c190
-rw-r--r--src/lib/netlist/examples/opamp.c134
-rw-r--r--src/lib/netlist/examples/opamp_amplification_curve.cpp54
-rw-r--r--src/lib/netlist/examples/rc.c30
-rw-r--r--src/lib/netlist/examples/rl.c32
-rw-r--r--src/lib/netlist/examples/sn74ls629_osc.c30
-rw-r--r--src/lib/netlist/examples/test.c146
-rw-r--r--src/lib/netlist/examples/todo.c132
-rw-r--r--src/lib/netlist/examples/vccs.c28
-rw-r--r--src/lib/netlist/examples/vccs1.c42
-rw-r--r--src/lib/netlist/examples/vs.c10
-rw-r--r--src/lib/netlist/examples/vs_cs.c26
-rw-r--r--src/lib/netlist/macro/nlm_base.cpp4
-rw-r--r--src/lib/netlist/macro/nlm_cd4xxx.cpp49
-rw-r--r--src/lib/netlist/macro/nlm_cd4xxx.h6
-rw-r--r--src/lib/netlist/macro/nlm_opamp.cpp41
-rw-r--r--src/lib/netlist/macro/nlm_opamp.h18
-rw-r--r--src/lib/netlist/macro/nlm_other.cpp2
-rw-r--r--src/lib/netlist/macro/nlm_ttl74xx.cpp2
-rw-r--r--src/lib/netlist/nl_base.cpp107
-rw-r--r--src/lib/netlist/nl_base.h179
-rw-r--r--src/lib/netlist/nl_config.h53
-rw-r--r--src/lib/netlist/nl_errstr.h6
-rw-r--r--src/lib/netlist/nl_factory.cpp4
-rw-r--r--src/lib/netlist/nl_factory.h4
-rw-r--r--src/lib/netlist/nl_parser.cpp82
-rw-r--r--src/lib/netlist/nl_parser.h4
-rw-r--r--src/lib/netlist/nl_setup.cpp274
-rw-r--r--src/lib/netlist/nl_setup.h45
-rw-r--r--src/lib/netlist/nltypes.h13
-rw-r--r--src/lib/netlist/plib/gmres.h3
-rw-r--r--src/lib/netlist/plib/mat_cr.h12
-rw-r--r--src/lib/netlist/plib/palloc.h47
-rw-r--r--src/lib/netlist/plib/parray.h20
-rw-r--r--src/lib/netlist/plib/pconfig.h2
-rw-r--r--src/lib/netlist/plib/pexception.h13
-rw-r--r--src/lib/netlist/plib/pfmtlog.h2
-rw-r--r--src/lib/netlist/plib/pfunction.cpp44
-rw-r--r--src/lib/netlist/plib/pfunction.h10
-rw-r--r--src/lib/netlist/plib/plists.h15
-rw-r--r--src/lib/netlist/plib/pmain.cpp5
-rw-r--r--src/lib/netlist/plib/pmath.h90
-rw-r--r--src/lib/netlist/plib/pmempool.h8
-rw-r--r--src/lib/netlist/plib/poptions.cpp12
-rw-r--r--src/lib/netlist/plib/poptions.h6
-rw-r--r--src/lib/netlist/plib/ppmf.h4
-rw-r--r--src/lib/netlist/plib/ppreprocessor.cpp64
-rw-r--r--src/lib/netlist/plib/ppreprocessor.h2
-rw-r--r--src/lib/netlist/plib/pstate.h2
-rw-r--r--src/lib/netlist/plib/pstonum.h6
-rw-r--r--src/lib/netlist/plib/pstream.h9
-rw-r--r--src/lib/netlist/plib/pstring.cpp8
-rw-r--r--src/lib/netlist/plib/pstring.h19
-rw-r--r--src/lib/netlist/plib/ptime.h119
-rw-r--r--src/lib/netlist/plib/ptokenizer.cpp2
-rw-r--r--src/lib/netlist/plib/ptokenizer.h4
-rw-r--r--src/lib/netlist/plib/ptypes.h52
-rw-r--r--src/lib/netlist/plib/putil.cpp21
-rw-r--r--src/lib/netlist/plib/putil.h44
-rw-r--r--src/lib/netlist/plib/vector_ops.h14
-rw-r--r--src/lib/netlist/prg/nltool.cpp104
-rw-r--r--src/lib/netlist/prg/nlwav.cpp8
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.cpp72
-rw-r--r--src/lib/netlist/solver/nld_matrix_solver.h78
-rw-r--r--src/lib/netlist/solver/nld_ms_direct.h12
-rw-r--r--src/lib/netlist/solver/nld_ms_direct1.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_direct2.h2
-rw-r--r--src/lib/netlist/solver/nld_ms_direct_lu.h8
-rw-r--r--src/lib/netlist/solver/nld_ms_gcr.h6
-rw-r--r--src/lib/netlist/solver/nld_ms_gmres.h4
-rw-r--r--src/lib/netlist/solver/nld_ms_sm.h8
-rw-r--r--src/lib/netlist/solver/nld_ms_sor.h4
-rw-r--r--src/lib/netlist/solver/nld_ms_sor_mat.h60
-rw-r--r--src/lib/netlist/solver/nld_ms_w.h8
-rw-r--r--src/lib/netlist/solver/nld_solver.cpp55
-rw-r--r--src/lib/netlist/tools/nl_convert.cpp218
-rw-r--r--src/lib/netlist/tools/nl_convert.h40
-rw-r--r--src/lib/util/avhuff.cpp18
-rw-r--r--src/lib/util/avhuff.h2
-rw-r--r--src/lib/util/aviio.cpp22
-rw-r--r--src/lib/util/aviio.h4
-rw-r--r--src/lib/util/bitmap.cpp2
-rw-r--r--src/lib/util/cdrom.cpp8
-rw-r--r--src/lib/util/chd.cpp22
-rw-r--r--src/lib/util/chdcd.cpp10
-rw-r--r--src/lib/util/chdcodec.cpp34
-rw-r--r--src/lib/util/chdcodec.h2
-rw-r--r--src/lib/util/corealloc.h2
-rw-r--r--src/lib/util/corefile.cpp17
-rw-r--r--src/lib/util/corefile.h2
-rw-r--r--src/lib/util/corestr.cpp4
-rw-r--r--src/lib/util/corestr.h2
-rw-r--r--src/lib/util/coretmpl.h140
-rw-r--r--src/lib/util/coreutil.cpp2
-rw-r--r--src/lib/util/delegate.cpp4
-rw-r--r--src/lib/util/flac.cpp4
-rw-r--r--src/lib/util/harddisk.cpp4
-rw-r--r--src/lib/util/hash.cpp2
-rw-r--r--src/lib/util/hashing.cpp2
-rw-r--r--src/lib/util/huffman.cpp22
-rw-r--r--src/lib/util/huffman.h4
-rw-r--r--src/lib/util/jedparse.cpp16
-rw-r--r--src/lib/util/md5.cpp2
-rw-r--r--src/lib/util/opresolv.cpp17
-rw-r--r--src/lib/util/opresolv.h4
-rw-r--r--src/lib/util/options.cpp21
-rw-r--r--src/lib/util/options.h4
-rw-r--r--src/lib/util/palette.cpp15
-rw-r--r--src/lib/util/palette.h2
-rw-r--r--src/lib/util/plaparse.cpp10
-rw-r--r--src/lib/util/png.cpp14
-rw-r--r--src/lib/util/pool.cpp8
-rw-r--r--src/lib/util/sha1.cpp6
-rw-r--r--src/lib/util/unicode.h2
-rw-r--r--src/lib/util/unzip.cpp2
-rw-r--r--src/lib/util/vbiparse.cpp2
-rw-r--r--src/lib/util/wavwrite.cpp2
-rw-r--r--src/lib/util/xmlfile.cpp13
-rw-r--r--src/lib/util/xmlfile.h4
-rw-r--r--src/lib/util/zippath.cpp4
302 files changed, 3506 insertions, 2585 deletions
diff --git a/src/lib/formats/a26_cas.cpp b/src/lib/formats/a26_cas.cpp
index 5030c2bfe0f..0074da6aba3 100644
--- a/src/lib/formats/a26_cas.cpp
+++ b/src/lib/formats/a26_cas.cpp
@@ -6,7 +6,7 @@ Atari 2600 SuperCharger support
*/
-#include <assert.h>
+#include <cassert>
#include "formats/a26_cas.h"
diff --git a/src/lib/formats/a5105_dsk.cpp b/src/lib/formats/a5105_dsk.cpp
index 33d7f15e1fd..f44c8c5f263 100644
--- a/src/lib/formats/a5105_dsk.cpp
+++ b/src/lib/formats/a5105_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/a5105_dsk.h"
diff --git a/src/lib/formats/abc800_dsk.cpp b/src/lib/formats/abc800_dsk.cpp
index e61a0a1d1ff..af1f92ec75c 100644
--- a/src/lib/formats/abc800_dsk.cpp
+++ b/src/lib/formats/abc800_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/abc800_dsk.h"
diff --git a/src/lib/formats/abcfd2_dsk.cpp b/src/lib/formats/abcfd2_dsk.cpp
index 8cc87ae20cd..94684f0ef5d 100644
--- a/src/lib/formats/abcfd2_dsk.cpp
+++ b/src/lib/formats/abcfd2_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/abcfd2_dsk.h"
diff --git a/src/lib/formats/ace_tap.cpp b/src/lib/formats/ace_tap.cpp
index 56b4bd877c8..522050f612a 100644
--- a/src/lib/formats/ace_tap.cpp
+++ b/src/lib/formats/ace_tap.cpp
@@ -10,7 +10,7 @@ For more information see:
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "ace_tap.h"
diff --git a/src/lib/formats/acorn_dsk.cpp b/src/lib/formats/acorn_dsk.cpp
index d8992b9ad5a..d0f0bdb93aa 100644
--- a/src/lib/formats/acorn_dsk.cpp
+++ b/src/lib/formats/acorn_dsk.cpp
@@ -45,6 +45,11 @@ int acorn_ssd_format::find_size(io_generic *io, uint32_t form_factor)
if (memcmp(cat, "\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd", 4) == 0 && size == (uint64_t)compute_track_size(f) * f.track_count * f.head_count)
return i;
+ // test for HADFS - test pattern at sector 70
+ io_generic_read(io, cat, 0x04610, 8);
+ if (memcmp(cat, "\x00\x28\x43\x29\x4a\x47\x48\x00", 4) == 0 && size == (uint64_t)compute_track_size(f) * f.track_count * f.head_count)
+ return i;
+
// read sector count from side 0 catalogue
io_generic_read(io, cat, 0x100, 8);
sectors0 = ((cat[6] & 3) << 8) + cat[7];
@@ -170,6 +175,11 @@ int acorn_dsd_format::find_size(io_generic *io, uint32_t form_factor)
if (memcmp(cat, "\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd", 4) == 0 && size == (uint64_t)compute_track_size(f) * f.track_count * f.head_count)
return i;
+ // test for HADFS - test pattern at sector 70
+ io_generic_read(io, cat, 0x08c10, 8);
+ if (memcmp(cat, "\x00\x28\x43\x29\x4a\x47\x48\x00", 4) == 0 && size == (uint64_t)compute_track_size(f) * f.track_count * f.head_count)
+ return i;
+
// read sector count from side 0 catalogue
io_generic_read(io, cat, 0x100, 8);
sectors0 = ((cat[6] & 3) << 8) + cat[7];
diff --git a/src/lib/formats/adam_cas.cpp b/src/lib/formats/adam_cas.cpp
index 3de9413cb90..5d24eed2543 100644
--- a/src/lib/formats/adam_cas.cpp
+++ b/src/lib/formats/adam_cas.cpp
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
-#include <assert.h>
+#include <cassert>
#include "cassimg.h"
#include "adam_cas.h"
diff --git a/src/lib/formats/adam_dsk.cpp b/src/lib/formats/adam_dsk.cpp
index e78e94a4763..3010aa309b2 100644
--- a/src/lib/formats/adam_dsk.cpp
+++ b/src/lib/formats/adam_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/adam_dsk.h"
diff --git a/src/lib/formats/agat840k_hle_dsk.cpp b/src/lib/formats/agat840k_hle_dsk.cpp
index 52cdd4668be..682b0edd7ad 100644
--- a/src/lib/formats/agat840k_hle_dsk.cpp
+++ b/src/lib/formats/agat840k_hle_dsk.cpp
@@ -12,7 +12,7 @@
************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/agat840k_hle_dsk.h"
diff --git a/src/lib/formats/aim_dsk.cpp b/src/lib/formats/aim_dsk.cpp
index 3bc2c2b5b5f..5abc410d57c 100644
--- a/src/lib/formats/aim_dsk.cpp
+++ b/src/lib/formats/aim_dsk.cpp
@@ -12,7 +12,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "aim_dsk.h"
diff --git a/src/lib/formats/ami_dsk.cpp b/src/lib/formats/ami_dsk.cpp
index 8a757e6a4c9..ba04067f752 100644
--- a/src/lib/formats/ami_dsk.cpp
+++ b/src/lib/formats/ami_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/ami_dsk.h"
diff --git a/src/lib/formats/ap2_dsk.cpp b/src/lib/formats/ap2_dsk.cpp
index a2fa0ee188a..9e71303ece5 100644
--- a/src/lib/formats/ap2_dsk.cpp
+++ b/src/lib/formats/ap2_dsk.cpp
@@ -8,9 +8,9 @@
*********************************************************************/
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
+#include <cstdlib>
+#include <cstring>
+#include <cassert>
#include "ap2_dsk.h"
#include "basicdsk.h"
@@ -496,19 +496,19 @@ static uint32_t apple2_get_track_size(floppy_image_legacy *floppy, int head, int
LEGACY_FLOPPY_OPTIONS_START( apple2 )
LEGACY_FLOPPY_OPTION( apple2_do, "do,dsk,bin", "Apple ][ DOS order disk image", apple2_dsk_identify, apple2_do_construct, nullptr,
HEADS([1])
- TRACKS([APPLE2_TRACK_COUNT])
+ TRACKS([40]) // APPLE2_TRACK_COUNT
SECTORS([16])
SECTOR_LENGTH([256])
FIRST_SECTOR_ID([0]))
LEGACY_FLOPPY_OPTION( apple2_po, "po,dsk,bin", "Apple ][ ProDOS order disk image", apple2_dsk_identify, apple2_po_construct, nullptr,
HEADS([1])
- TRACKS([APPLE2_TRACK_COUNT])
+ TRACKS([40]) // APPLE2_TRACK_COUNT
SECTORS([16])
SECTOR_LENGTH([256])
FIRST_SECTOR_ID([0]))
LEGACY_FLOPPY_OPTION( apple2_nib, "dsk,nib", "Apple ][ Nibble order disk image", apple2_nib_identify, apple2_nib_construct, nullptr,
HEADS([1])
- TRACKS([APPLE2_TRACK_COUNT])
+ TRACKS([40]) // APPLE2_TRACK_COUNT
SECTORS([16])
SECTOR_LENGTH([256])
FIRST_SECTOR_ID([0]))
diff --git a/src/lib/formats/ap_dsk35.cpp b/src/lib/formats/ap_dsk35.cpp
index c18ea8c65d4..677cfcc9463 100644
--- a/src/lib/formats/ap_dsk35.cpp
+++ b/src/lib/formats/ap_dsk35.cpp
@@ -98,8 +98,8 @@
*********************************************************************/
-#include <stdio.h>
-#include <assert.h>
+#include <cstdio>
+#include <cassert>
#include "emu.h" // logerror
#include "ap_dsk35.h"
diff --git a/src/lib/formats/apf_apt.cpp b/src/lib/formats/apf_apt.cpp
index de919b0bddd..28793f0f853 100644
--- a/src/lib/formats/apf_apt.cpp
+++ b/src/lib/formats/apf_apt.cpp
@@ -34,7 +34,7 @@ e. A checksum byte (8-bit addition)
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/apf_apt.h"
diff --git a/src/lib/formats/apollo_dsk.cpp b/src/lib/formats/apollo_dsk.cpp
index b2fef28be71..213286dd85b 100644
--- a/src/lib/formats/apollo_dsk.cpp
+++ b/src/lib/formats/apollo_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/apollo_dsk.h"
diff --git a/src/lib/formats/applix_dsk.cpp b/src/lib/formats/applix_dsk.cpp
index 59a0d4c06f5..70a52c42ccb 100644
--- a/src/lib/formats/applix_dsk.cpp
+++ b/src/lib/formats/applix_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/applix_dsk.h"
diff --git a/src/lib/formats/asst128_dsk.cpp b/src/lib/formats/asst128_dsk.cpp
index fe64cc725ee..e0c90636484 100644
--- a/src/lib/formats/asst128_dsk.cpp
+++ b/src/lib/formats/asst128_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/asst128_dsk.h"
diff --git a/src/lib/formats/atari_dsk.cpp b/src/lib/formats/atari_dsk.cpp
index d73cbf8185f..4008ec32fe3 100644
--- a/src/lib/formats/atari_dsk.cpp
+++ b/src/lib/formats/atari_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/atari_dsk.h"
diff --git a/src/lib/formats/atom_tap.cpp b/src/lib/formats/atom_tap.cpp
index 881433ef1a8..1c8c3642838 100644
--- a/src/lib/formats/atom_tap.cpp
+++ b/src/lib/formats/atom_tap.cpp
@@ -40,7 +40,7 @@
*/
-#include <assert.h>
+#include <cassert>
#include "atom_tap.h"
#include "csw_cas.h"
diff --git a/src/lib/formats/basicdsk.cpp b/src/lib/formats/basicdsk.cpp
index 9de079232e0..c654362309e 100644
--- a/src/lib/formats/basicdsk.cpp
+++ b/src/lib/formats/basicdsk.cpp
@@ -8,9 +8,9 @@
*********************************************************************/
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
+#include <cstdlib>
+#include <cstring>
+#include <cassert>
#include "basicdsk.h"
diff --git a/src/lib/formats/bw12_dsk.cpp b/src/lib/formats/bw12_dsk.cpp
index 06c8be72347..407db641d9c 100644
--- a/src/lib/formats/bw12_dsk.cpp
+++ b/src/lib/formats/bw12_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/bw12_dsk.h"
diff --git a/src/lib/formats/bw2_dsk.cpp b/src/lib/formats/bw2_dsk.cpp
index 3dc46e9b225..297f78f863f 100644
--- a/src/lib/formats/bw2_dsk.cpp
+++ b/src/lib/formats/bw2_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/bw2_dsk.h"
diff --git a/src/lib/formats/c3040_dsk.cpp b/src/lib/formats/c3040_dsk.cpp
index 78786979953..b5c35f9d2e5 100644
--- a/src/lib/formats/c3040_dsk.cpp
+++ b/src/lib/formats/c3040_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/c3040_dsk.h"
diff --git a/src/lib/formats/c4040_dsk.cpp b/src/lib/formats/c4040_dsk.cpp
index e6314f69261..69d371525c1 100644
--- a/src/lib/formats/c4040_dsk.cpp
+++ b/src/lib/formats/c4040_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/c4040_dsk.h"
diff --git a/src/lib/formats/camplynx_dsk.cpp b/src/lib/formats/camplynx_dsk.cpp
index c58b12b9423..46cd4f2a55d 100644
--- a/src/lib/formats/camplynx_dsk.cpp
+++ b/src/lib/formats/camplynx_dsk.cpp
@@ -19,7 +19,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/camplynx_dsk.h"
diff --git a/src/lib/formats/cassimg.cpp b/src/lib/formats/cassimg.cpp
index 816af2dccfd..4f5d9320754 100644
--- a/src/lib/formats/cassimg.cpp
+++ b/src/lib/formats/cassimg.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "imageutl.h"
#include "cassimg.h"
diff --git a/src/lib/formats/cbm_tap.cpp b/src/lib/formats/cbm_tap.cpp
index e621651f577..7ef8015c6f9 100644
--- a/src/lib/formats/cbm_tap.cpp
+++ b/src/lib/formats/cbm_tap.cpp
@@ -94,7 +94,7 @@ Unfortunately, I have no such a .tap file to test, so my implementation
below could be not working. FP ]
*/
-#include <assert.h>
+#include <cassert>
#include "cbm_tap.h"
diff --git a/src/lib/formats/cgen_cas.cpp b/src/lib/formats/cgen_cas.cpp
index be4b9397f89..de47a45375d 100644
--- a/src/lib/formats/cgen_cas.cpp
+++ b/src/lib/formats/cgen_cas.cpp
@@ -19,7 +19,7 @@ We now support these three types below...
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/cgen_cas.h"
diff --git a/src/lib/formats/comx35_dsk.cpp b/src/lib/formats/comx35_dsk.cpp
index aa8603f3c1c..a06f1a2dd6c 100644
--- a/src/lib/formats/comx35_dsk.cpp
+++ b/src/lib/formats/comx35_dsk.cpp
@@ -36,7 +36,7 @@
*/
-#include <assert.h>
+#include <cassert>
#include "formats/comx35_dsk.h"
diff --git a/src/lib/formats/concept_dsk.cpp b/src/lib/formats/concept_dsk.cpp
index eea65064fc7..b8c010af852 100644
--- a/src/lib/formats/concept_dsk.cpp
+++ b/src/lib/formats/concept_dsk.cpp
@@ -10,7 +10,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "flopimg.h"
#include "formats/concept_dsk.h"
diff --git a/src/lib/formats/coupedsk.cpp b/src/lib/formats/coupedsk.cpp
index 045e42b7bb5..967896195f1 100644
--- a/src/lib/formats/coupedsk.cpp
+++ b/src/lib/formats/coupedsk.cpp
@@ -8,7 +8,7 @@
**************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/coupedsk.h"
#include "flopimg.h"
diff --git a/src/lib/formats/cqm_dsk.cpp b/src/lib/formats/cqm_dsk.cpp
index e2bde8fcf8c..c38f06bde1c 100644
--- a/src/lib/formats/cqm_dsk.cpp
+++ b/src/lib/formats/cqm_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "flopimg.h"
#define CQM_HEADER_SIZE 133
diff --git a/src/lib/formats/csw_cas.cpp b/src/lib/formats/csw_cas.cpp
index 84aab50d3b8..9edea5c3ff7 100644
--- a/src/lib/formats/csw_cas.cpp
+++ b/src/lib/formats/csw_cas.cpp
@@ -22,10 +22,10 @@ Offset Value Type Description
*/
-#include <string.h>
+#include <cstring>
#include <zlib.h>
-#include <assert.h>
+#include <cassert>
#include "uef_cas.h"
#include "csw_cas.h"
diff --git a/src/lib/formats/d71_dsk.cpp b/src/lib/formats/d71_dsk.cpp
index af1186948c6..16c8efea2e9 100644
--- a/src/lib/formats/d71_dsk.cpp
+++ b/src/lib/formats/d71_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/d71_dsk.h"
diff --git a/src/lib/formats/d80_dsk.cpp b/src/lib/formats/d80_dsk.cpp
index e08ef22f6b9..d350411b159 100644
--- a/src/lib/formats/d80_dsk.cpp
+++ b/src/lib/formats/d80_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/d80_dsk.h"
diff --git a/src/lib/formats/d81_dsk.cpp b/src/lib/formats/d81_dsk.cpp
index 714b9c3cd9e..a7f01c9c92e 100644
--- a/src/lib/formats/d81_dsk.cpp
+++ b/src/lib/formats/d81_dsk.cpp
@@ -73,7 +73,7 @@ PER SECTOR ORGANIZATION:
*/
-#include <assert.h>
+#include <cassert>
#include "formats/d81_dsk.h"
diff --git a/src/lib/formats/d82_dsk.cpp b/src/lib/formats/d82_dsk.cpp
index 00de1f5fd7c..0d79ad891ae 100644
--- a/src/lib/formats/d82_dsk.cpp
+++ b/src/lib/formats/d82_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/d82_dsk.h"
diff --git a/src/lib/formats/d88_dsk.cpp b/src/lib/formats/d88_dsk.cpp
index c2bf9772e7d..30073d1874d 100644
--- a/src/lib/formats/d88_dsk.cpp
+++ b/src/lib/formats/d88_dsk.cpp
@@ -29,7 +29,7 @@
*
*/
- #include <assert.h>
+ #include <cassert>
#include "flopimg.h"
#include "imageutl.h"
diff --git a/src/lib/formats/dcp_dsk.cpp b/src/lib/formats/dcp_dsk.cpp
index 179552409f8..c245d4ff0e3 100644
--- a/src/lib/formats/dcp_dsk.cpp
+++ b/src/lib/formats/dcp_dsk.cpp
@@ -20,7 +20,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "dcp_dsk.h"
diff --git a/src/lib/formats/dim_dsk.cpp b/src/lib/formats/dim_dsk.cpp
index 67c04adc2bf..ac9930e4782 100644
--- a/src/lib/formats/dim_dsk.cpp
+++ b/src/lib/formats/dim_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "dim_dsk.h"
#include "basicdsk.h"
diff --git a/src/lib/formats/dip_dsk.cpp b/src/lib/formats/dip_dsk.cpp
index 310eab56a73..573f3768072 100644
--- a/src/lib/formats/dip_dsk.cpp
+++ b/src/lib/formats/dip_dsk.cpp
@@ -14,7 +14,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "dip_dsk.h"
diff --git a/src/lib/formats/dmk_dsk.cpp b/src/lib/formats/dmk_dsk.cpp
index 5ca0a3b8781..4b3336b4bcb 100644
--- a/src/lib/formats/dmk_dsk.cpp
+++ b/src/lib/formats/dmk_dsk.cpp
@@ -13,7 +13,7 @@ TODO:
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "dmk_dsk.h"
diff --git a/src/lib/formats/dmv_dsk.cpp b/src/lib/formats/dmv_dsk.cpp
index 02469ed74d4..b64fea5b318 100644
--- a/src/lib/formats/dmv_dsk.cpp
+++ b/src/lib/formats/dmv_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/dmv_dsk.h"
diff --git a/src/lib/formats/ds9_dsk.cpp b/src/lib/formats/ds9_dsk.cpp
index 0866d78d58f..cd241c3a319 100644
--- a/src/lib/formats/ds9_dsk.cpp
+++ b/src/lib/formats/ds9_dsk.cpp
@@ -14,7 +14,7 @@
************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/ds9_dsk.h"
diff --git a/src/lib/formats/dsk_dsk.cpp b/src/lib/formats/dsk_dsk.cpp
index db9d54920e5..7994f60f3ce 100644
--- a/src/lib/formats/dsk_dsk.cpp
+++ b/src/lib/formats/dsk_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "imageutl.h"
#include "flopimg.h"
diff --git a/src/lib/formats/dvk_mx_dsk.cpp b/src/lib/formats/dvk_mx_dsk.cpp
index 477dd07690f..37de4111948 100644
--- a/src/lib/formats/dvk_mx_dsk.cpp
+++ b/src/lib/formats/dvk_mx_dsk.cpp
@@ -18,7 +18,7 @@
************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "flopimg.h"
#include "formats/dvk_mx_dsk.h"
diff --git a/src/lib/formats/ep64_dsk.cpp b/src/lib/formats/ep64_dsk.cpp
index 80981bf698e..f47615c76d9 100644
--- a/src/lib/formats/ep64_dsk.cpp
+++ b/src/lib/formats/ep64_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/ep64_dsk.h"
diff --git a/src/lib/formats/esq16_dsk.cpp b/src/lib/formats/esq16_dsk.cpp
index 1f6e86f295f..72e27ebfad5 100644
--- a/src/lib/formats/esq16_dsk.cpp
+++ b/src/lib/formats/esq16_dsk.cpp
@@ -10,7 +10,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "flopimg.h"
#include "formats/esq16_dsk.h"
diff --git a/src/lib/formats/esq8_dsk.cpp b/src/lib/formats/esq8_dsk.cpp
index c575fe0db2f..b7f69c85afc 100644
--- a/src/lib/formats/esq8_dsk.cpp
+++ b/src/lib/formats/esq8_dsk.cpp
@@ -12,7 +12,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "flopimg.h"
#include "formats/esq8_dsk.h"
diff --git a/src/lib/formats/excali64_dsk.cpp b/src/lib/formats/excali64_dsk.cpp
index 5d41c39f4e6..cc255052800 100644
--- a/src/lib/formats/excali64_dsk.cpp
+++ b/src/lib/formats/excali64_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/excali64_dsk.h"
diff --git a/src/lib/formats/fc100_cas.cpp b/src/lib/formats/fc100_cas.cpp
index 5004da147d3..42b99ad3f0e 100644
--- a/src/lib/formats/fc100_cas.cpp
+++ b/src/lib/formats/fc100_cas.cpp
@@ -10,7 +10,7 @@ it's all a guess.
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "fc100_cas.h"
diff --git a/src/lib/formats/fdd_dsk.cpp b/src/lib/formats/fdd_dsk.cpp
index 5e34c4ad7df..f5eb6ea19a5 100644
--- a/src/lib/formats/fdd_dsk.cpp
+++ b/src/lib/formats/fdd_dsk.cpp
@@ -31,7 +31,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "fdd_dsk.h"
diff --git a/src/lib/formats/fdi_dsk.cpp b/src/lib/formats/fdi_dsk.cpp
index c703f29cc69..57083f1230e 100644
--- a/src/lib/formats/fdi_dsk.cpp
+++ b/src/lib/formats/fdi_dsk.cpp
@@ -16,7 +16,7 @@
*/
-#include <assert.h>
+#include <cassert>
#include "imageutl.h"
#include "flopimg.h"
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp
index ea812506f50..79d97b1bf71 100644
--- a/src/lib/formats/flopimg.cpp
+++ b/src/lib/formats/flopimg.cpp
@@ -8,12 +8,12 @@
*********************************************************************/
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <limits.h>
-#include <assert.h>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
+#include <cctype>
+#include <climits>
+#include <cassert>
#include "emu.h" // emu_fatalerror
#include "osdcore.h"
diff --git a/src/lib/formats/fm7_cas.cpp b/src/lib/formats/fm7_cas.cpp
index 32cd08e3b27..f275866d31b 100644
--- a/src/lib/formats/fm7_cas.cpp
+++ b/src/lib/formats/fm7_cas.cpp
@@ -4,7 +4,7 @@
* Fujitsu FM-7 series cassette handling
*/
-#include <assert.h>
+#include <cassert>
#include "fm7_cas.h"
diff --git a/src/lib/formats/fmsx_cas.cpp b/src/lib/formats/fmsx_cas.cpp
index 6da8fc47f81..3b00b81dc92 100644
--- a/src/lib/formats/fmsx_cas.cpp
+++ b/src/lib/formats/fmsx_cas.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Sean Young
-#include <assert.h>
+#include <cassert>
#include "formats/fmsx_cas.h"
diff --git a/src/lib/formats/fmtowns_dsk.cpp b/src/lib/formats/fmtowns_dsk.cpp
index 633b53fcd87..13d1408ba4b 100644
--- a/src/lib/formats/fmtowns_dsk.cpp
+++ b/src/lib/formats/fmtowns_dsk.cpp
@@ -8,7 +8,7 @@
* Created on: 23/03/2014
*/
- #include <assert.h>
+ #include <cassert>
#include "formats/fmtowns_dsk.h"
diff --git a/src/lib/formats/gtp_cas.cpp b/src/lib/formats/gtp_cas.cpp
index fd3a16932b3..0a5c34d140c 100644
--- a/src/lib/formats/gtp_cas.cpp
+++ b/src/lib/formats/gtp_cas.cpp
@@ -6,7 +6,7 @@
Miodrag Milanovic
*/
-#include <assert.h>
+#include <cassert>
#include "gtp_cas.h"
diff --git a/src/lib/formats/hect_dsk.cpp b/src/lib/formats/hect_dsk.cpp
index 4cd36008540..cf8fc2cacc4 100644
--- a/src/lib/formats/hect_dsk.cpp
+++ b/src/lib/formats/hect_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/hect_dsk.h"
#include "formats/basicdsk.h"
diff --git a/src/lib/formats/hect_tap.cpp b/src/lib/formats/hect_tap.cpp
index 4f823fb24e5..78f1bad2e42 100644
--- a/src/lib/formats/hect_tap.cpp
+++ b/src/lib/formats/hect_tap.cpp
@@ -14,7 +14,7 @@ You can find some *.K7 file on serveral server in France
Updated 3/1/10 : use real value for timing.
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "hect_tap.h"
diff --git a/src/lib/formats/hp_ipc_dsk.cpp b/src/lib/formats/hp_ipc_dsk.cpp
index 8b9efce0120..66485b461be 100644
--- a/src/lib/formats/hp_ipc_dsk.cpp
+++ b/src/lib/formats/hp_ipc_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/hp_ipc_dsk.h"
diff --git a/src/lib/formats/hxcmfm_dsk.cpp b/src/lib/formats/hxcmfm_dsk.cpp
index dcc4718c114..390e07ff3f8 100644
--- a/src/lib/formats/hxcmfm_dsk.cpp
+++ b/src/lib/formats/hxcmfm_dsk.cpp
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
-#include <assert.h>
+#include <cassert>
#include "hxcmfm_dsk.h"
diff --git a/src/lib/formats/imageutl.cpp b/src/lib/formats/imageutl.cpp
index 6ab427115e0..6bf2bbd3323 100644
--- a/src/lib/formats/imageutl.cpp
+++ b/src/lib/formats/imageutl.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
-#include <ctype.h>
+#include <cctype>
#include "imageutl.h"
int compute_log2(int val)
diff --git a/src/lib/formats/imd_dsk.cpp b/src/lib/formats/imd_dsk.cpp
index 51337a7f890..4ae22724fb9 100644
--- a/src/lib/formats/imd_dsk.cpp
+++ b/src/lib/formats/imd_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "flopimg.h"
struct imddsk_tag
diff --git a/src/lib/formats/img_dsk.cpp b/src/lib/formats/img_dsk.cpp
new file mode 100644
index 00000000000..0dfcc7a359f
--- /dev/null
+++ b/src/lib/formats/img_dsk.cpp
@@ -0,0 +1,378 @@
+// license:BSD-3-Clause
+// copyright-holders: F. Ulivi
+/*********************************************************************
+
+ img_dsk.cpp
+
+ "IMG" disk format
+
+ This format is just a raw image of every sector on SSDD 8" floppy
+ disks as used in Intel MDS-II systems.
+ Files with this format have no header/trailer and are exactly
+ 512512 bytes in size (52 sectors, 1 head, 77 tracks,
+ 128 bytes per sector).
+
+*********************************************************************/
+
+#include "emu.h"
+#include "img_dsk.h"
+
+// Debugging
+#define VERBOSE 0
+#define LOG(...) do { if (VERBOSE) printf(__VA_ARGS__); } while (false)
+
+constexpr unsigned CELL_SIZE = 1200; // Bit cell size (1 µs)
+constexpr uint8_t INDEX_AM = 0x0c; // Index address mark
+constexpr uint8_t ID_AM = 0x0e; // ID address mark
+constexpr uint8_t DATA_AM = 0x0b; // Data address mark
+constexpr uint8_t AM_CLOCK = 0x70; // Clock pattern of AM
+constexpr unsigned PREIDX_GAP = 45; // Size of pre-index gap
+constexpr unsigned SYNC_00_LEN = 18; // 00's in sync (gaps 1, 2, 3)
+constexpr unsigned SYNC_FF_LEN = 10; // FF's in sync (gaps 1, 2, 3)
+constexpr int ID_DATA_OFFSET = 35 * 16; // Nominal distance (in cells) between ID & DATA AM
+// Size of image file
+constexpr unsigned IMG_IMAGE_SIZE = IMG_TRACKS * IMG_HEADS * IMG_SECTORS * IMG_SECTOR_SIZE;
+constexpr uint16_t CRC_POLY = 0x1021; // CRC-CCITT
+
+img_format::img_format()
+{
+}
+
+int img_format::identify(io_generic *io, uint32_t form_factor)
+{
+ uint64_t size = io_generic_size(io);
+
+ if (((form_factor == floppy_image::FF_8) || (form_factor == floppy_image::FF_UNKNOWN)) &&
+ size == IMG_IMAGE_SIZE) {
+ return 50;
+ } else {
+ return 0;
+ }
+}
+
+bool img_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
+{
+ uint64_t size = io_generic_size(io);
+ if (size != IMG_IMAGE_SIZE) {
+ return false;
+ }
+ image->set_variant(floppy_image::SSDD);
+
+ // Suck in the whole image
+ std::vector<uint8_t> image_data(size);
+ io_generic_read(io, (void *)image_data.data(), 0, size);
+
+ for (unsigned cyl = 0; cyl < IMG_TRACKS; cyl++) {
+ std::vector<uint32_t> track_data;
+
+ write_gap(track_data, 0 , PREIDX_GAP);
+ write_mmfm_byte(track_data , INDEX_AM , AM_CLOCK);
+
+ // Compute interleave factor and skew for current track
+ unsigned il_factor;
+ unsigned skew;
+ if (cyl == 0) {
+ il_factor = 1;
+ skew = 51;
+ } else if (cyl == 1) {
+ il_factor = 4;
+ skew = 48;
+ } else {
+ il_factor = 5;
+ skew = (47 + 45 * (cyl - 2)) % 52;
+ }
+ std::vector<uint8_t> sector_list = interleaved_sectors(il_factor);
+
+ for (unsigned sector = 0; sector < IMG_SECTORS; sector++) {
+ unsigned real_sector = sector_list[ (sector + skew) % IMG_SECTORS ];
+ unsigned offset_in_image = (real_sector - 1 + cyl * IMG_SECTORS) * IMG_SECTOR_SIZE;
+ write_sector(track_data , cyl , real_sector , &image_data[ offset_in_image ]);
+ }
+ fill_with_gap4(track_data);
+ generate_track_from_levels(cyl , 0 , track_data , 0 , image);
+ }
+ return true;
+}
+
+bool img_format::save(io_generic *io, floppy_image *image)
+{
+ for (int cyl = 0; cyl < IMG_TRACKS; cyl++) {
+ uint8_t bitstream[ 21000 ];
+ int bitstream_size;
+ generate_bitstream_from_track(cyl , 0 , CELL_SIZE , bitstream , bitstream_size , image , 0);
+ int pos = 0;
+ unsigned track_no , sector_no;
+ uint8_t sector_data[ IMG_SECTOR_SIZE ];
+ while (get_next_sector(bitstream , bitstream_size , pos , track_no , sector_no , sector_data)) {
+ if (track_no == cyl && sector_no >= 1 && sector_no <= IMG_SECTORS) {
+ unsigned offset_in_image = (cyl * IMG_SECTORS + sector_no - 1) * IMG_SECTOR_SIZE;
+ io_generic_write(io, sector_data, offset_in_image, IMG_SECTOR_SIZE);
+ }
+ }
+ }
+ return true;
+}
+
+const char *img_format::name() const
+{
+ return "img";
+}
+
+const char *img_format::description() const
+{
+ return "MDS-II floppy disk image";
+}
+
+const char *img_format::extensions() const
+{
+ return "img";
+}
+
+bool img_format::supports_save() const
+{
+ return true;
+}
+
+std::vector<uint8_t> img_format::interleaved_sectors(unsigned il_factor)
+{
+ std::vector<uint8_t> out(IMG_SECTORS);
+ unsigned idx = 0;
+ for (unsigned s = 0; s < IMG_SECTORS; s++) {
+ while (out[ idx ] != 0) {
+ if (++idx >= IMG_SECTORS) {
+ idx = 0;
+ }
+ }
+ out[ idx ] = s + 1;
+ idx += il_factor;
+ if (idx >= IMG_SECTORS) {
+ idx -= IMG_SECTORS;
+ }
+ }
+ return out;
+}
+
+void img_format::write_mmfm_bit(std::vector<uint32_t> &buffer , bool data_bit , bool clock_bit)
+{
+ bool had_transition = buffer.size() < 2 ? false : bit_r(buffer, buffer.size() - 1) || bit_r(buffer , buffer.size() - 2);
+ clock_bit = !data_bit && (clock_bit || !had_transition);
+ bit_w(buffer , clock_bit , CELL_SIZE);
+ bit_w(buffer , data_bit , CELL_SIZE);
+
+ if (BIT(m_crc , 15) ^ data_bit) {
+ m_crc = (m_crc << 1) ^ CRC_POLY;
+ } else {
+ m_crc <<= 1;
+ }
+}
+
+void img_format::write_mmfm_byte(std::vector<uint32_t> &buffer , uint8_t data , uint8_t clock)
+{
+ for (int i = 7; i >= 0; i--) {
+ write_mmfm_bit(buffer , BIT(data , i) , BIT(clock , i));
+ }
+}
+
+void img_format::write_sync(std::vector<uint32_t> &buffer)
+{
+ write_gap(buffer , SYNC_00_LEN , SYNC_FF_LEN);
+}
+
+void img_format::write_crc(std::vector<uint32_t> &buffer , uint16_t crc)
+{
+ // Note that CRC is stored with MSB (x^15) first
+ for (unsigned i = 0; i < 16; i++) {
+ write_mmfm_bit(buffer , BIT(crc , 15 - i) , 0);
+ }
+}
+
+void img_format::write_gap(std::vector<uint32_t> &buffer , unsigned size_00 , unsigned size_ff)
+{
+ for (unsigned i = 0; i < size_00; ++i) {
+ write_mmfm_byte(buffer, 0);
+ }
+ for (unsigned i = 0; i < size_ff; ++i) {
+ write_mmfm_byte(buffer, 0xff);
+ }
+}
+
+void img_format::write_sector(std::vector<uint32_t> &buffer , uint8_t track_no , uint8_t sect_no , const uint8_t *sect_data)
+{
+ // **** On-disk format of a sector ****
+ //
+ // | Offset | Size | Value | Content |
+ // |--------+------+-------+----------------------|
+ // | 0 | 18 | 00 | Gap 1/3 |
+ // | 18 | 10 | ff | Gap 1/3 |
+ // | 28 | 1 | 0e | ID AM (clock = 70) |
+ // | 29 | 1 | xx | Track no. |
+ // | 30 | 1 | 00 | N/U |
+ // | 31 | 1 | xx | Sector no. |
+ // | 32 | 1 | 00 | N/U |
+ // | 33 | 2 | xx | ID CRC |
+ // | 35 | 18 | 00 | Gap 2 |
+ // | 53 | 10 | ff | Gap 2 |
+ // | 63 | 1 | 0b | Data AM (clock = 70) |
+ // | 64 | 128 | xx | Sector data |
+ // | 192 | 2 | xx | Data CRC |
+ // | 194 | | | |
+
+ // Gap1
+ write_sync(buffer);
+ // ID AM
+ m_crc = 0;
+ write_mmfm_byte(buffer , ID_AM , AM_CLOCK);
+ // Track #
+ write_mmfm_byte(buffer , track_no);
+ write_mmfm_byte(buffer , 0);
+ // Sector #
+ write_mmfm_byte(buffer , sect_no);
+ write_mmfm_byte(buffer , 0);
+ // ID CRC
+ write_crc(buffer , m_crc);
+ // Gap 2
+ write_sync(buffer);
+ // Data AM
+ m_crc = 0;
+ write_mmfm_byte(buffer , DATA_AM , AM_CLOCK);
+ for (unsigned i = 0; i < IMG_SECTOR_SIZE; i++) {
+ // Data
+ write_mmfm_byte(buffer , sect_data[ i ]);
+ }
+ // Data CRC
+ write_crc(buffer , m_crc);
+}
+
+void img_format::fill_with_gap4(std::vector<uint32_t> &buffer)
+{
+ // Cell count in a track (1 µs cells in a 1/6 s track)
+ unsigned cell_count = (500000 * 120) / 360;
+ unsigned cells_in_buffer = buffer.size();
+ // Size of gap 4
+ unsigned gap_4 = (cell_count - cells_in_buffer) / 16;
+ // Gap 4
+ write_gap(buffer , gap_4 , 0);
+ // Last cell to round everything up to 2E+8
+ if (buffer.size() * CELL_SIZE < 200000000) {
+ bit_w(buffer , false , 200000000 - buffer.size() * CELL_SIZE);
+ }
+}
+
+std::vector<uint8_t> img_format::get_next_id_n_block(const uint8_t *bitstream , int bitstream_size , int& pos , int& start_pos)
+{
+ std::vector<uint8_t> res;
+ uint8_t data_sr;
+ uint8_t clock_sr;
+
+ // Look for either sync + ID AM or sync + DATA AM
+ do {
+ unsigned cnt_trans = 0;
+ while (pos < bitstream_size && cnt_trans < 34) {
+ bool bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ pos++;
+ if (cnt_trans < 32) {
+ if (!(BIT(cnt_trans , 0) ^ bit)) {
+ cnt_trans++;
+ } else {
+ cnt_trans = 0;
+ }
+ } else if (cnt_trans == 32) {
+ if (!bit) {
+ start_pos = pos;
+ cnt_trans++;
+ } else {
+ cnt_trans = 0;
+ }
+ } else if (!bit) {
+ cnt_trans++;
+ } else {
+ cnt_trans = 32;
+ }
+ }
+
+ if (pos == bitstream_size) {
+ // End of track reached
+ return res;
+ }
+
+ // Get AM
+ data_sr = clock_sr = 0;
+ for (unsigned i = 0; i < 7; ++i) {
+ bool bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ pos++;
+ clock_sr = (clock_sr << 1) | bit;
+ bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ pos++;
+ data_sr = (data_sr << 1) | bit;
+ }
+ if (pos >= bitstream_size) {
+ return res;
+ }
+ } while (clock_sr != AM_CLOCK);
+
+ // ID blocks: Track no. + 0 + sector no. + 0 + CRC
+ // Data blocks: Sector data + CRC
+ res.push_back(data_sr);
+ unsigned to_dump;
+ if (data_sr == ID_AM) {
+ to_dump = 4;
+ } else if (data_sr == DATA_AM) {
+ to_dump = IMG_SECTOR_SIZE;
+ } else {
+ to_dump = 0;
+ }
+
+ pos++;
+ for (unsigned i = 0; i < to_dump && pos < bitstream_size; i++) {
+ data_sr = 0;
+ unsigned j;
+ for (j = 0; j < 8 && pos < bitstream_size; j++) {
+ bool bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ pos += 2;
+ data_sr = (data_sr << 1) | bit;
+ }
+ if (j == 8) {
+ res.push_back(data_sr);
+ }
+ }
+ return res;
+}
+
+bool img_format::get_next_sector(const uint8_t *bitstream , int bitstream_size , int& pos , unsigned& track , unsigned& sector , uint8_t *sector_data)
+{
+ std::vector<uint8_t> block;
+ while (true) {
+ // Scan for ID block first
+ int id_pos = 0;
+ while (true) {
+ if (block.size() == 0) {
+ block = get_next_id_n_block(bitstream , bitstream_size , pos , id_pos);
+ if (block.size() == 0) {
+ return false;
+ }
+ }
+ if (block[ 0 ] == ID_AM && block.size() >= 5) {
+ track = block[ 1 ];
+ sector = block[ 3 ];
+ break;
+ } else {
+ block.clear();
+ }
+ }
+ // Then for DATA block
+ int data_pos = 0;
+ block = get_next_id_n_block(bitstream , bitstream_size , pos , data_pos);
+ if (block.size() == 0) {
+ return false;
+ }
+ if (block[ 0 ] == DATA_AM && block.size() >= (IMG_SECTOR_SIZE + 1) && abs((data_pos - id_pos) - ID_DATA_OFFSET) <= 64) {
+ break;
+ }
+ }
+
+ memcpy(sector_data , block.data() + 1 , IMG_SECTOR_SIZE);
+
+ return true;
+}
+
+const floppy_format_type FLOPPY_IMG_FORMAT = &floppy_image_format_creator<img_format>;
diff --git a/src/lib/formats/img_dsk.h b/src/lib/formats/img_dsk.h
new file mode 100644
index 00000000000..f1ac7aef3c0
--- /dev/null
+++ b/src/lib/formats/img_dsk.h
@@ -0,0 +1,55 @@
+// license:BSD-3-Clause
+// copyright-holders: F. Ulivi
+/*********************************************************************
+
+ img_dsk.h
+
+ "IMG" disk format for SSDD Intel MDS-II 8" disks
+
+*********************************************************************/
+#ifndef MAME_FORMATS_IMG_DSK_H
+#define MAME_FORMATS_IMG_DSK_H
+
+#pragma once
+
+#include "flopimg.h"
+
+#include <vector>
+
+// Geometry constants
+constexpr unsigned IMG_TRACKS = 77;
+constexpr unsigned IMG_HEADS = 1;
+constexpr unsigned IMG_SECTORS = 52;
+constexpr unsigned IMG_SECTOR_SIZE = 128;
+
+class img_format : public floppy_image_format_t
+{
+public:
+ img_format();
+
+ virtual int identify(io_generic *io, uint32_t form_factor) override;
+ virtual bool load(io_generic *io, uint32_t form_factor, floppy_image *image) override;
+ virtual bool save(io_generic *io, floppy_image *image) override;
+ virtual const char *name() const override;
+ virtual const char *description() const override;
+ virtual const char *extensions() const override;
+ virtual bool supports_save() const override;
+
+private:
+ uint16_t m_crc;
+
+ static std::vector<uint8_t> interleaved_sectors(unsigned il_factor);
+ void write_mmfm_bit(std::vector<uint32_t> &buffer , bool data_bit , bool clock_bit);
+ void write_mmfm_byte(std::vector<uint32_t> &buffer , uint8_t data , uint8_t clock = 0);
+ void write_sync(std::vector<uint32_t> &buffer);
+ void write_crc(std::vector<uint32_t> &buffer , uint16_t crc);
+ void write_gap(std::vector<uint32_t> &buffer , unsigned size_00 , unsigned size_ff);
+ void write_sector(std::vector<uint32_t> &buffer , uint8_t track_no , uint8_t sect_no , const uint8_t *sect_data);
+ void fill_with_gap4(std::vector<uint32_t> &buffer);
+ std::vector<uint8_t> get_next_id_n_block(const uint8_t *bitstream , int bitstream_size , int& pos , int& start_pos);
+ bool get_next_sector(const uint8_t *bitstream , int bitstream_size , int& pos , unsigned& track , unsigned& sector , uint8_t *sector_data);
+};
+
+extern const floppy_format_type FLOPPY_IMG_FORMAT;
+
+#endif // MAME_FORMATS_IMG_DSK_H
diff --git a/src/lib/formats/ioprocs.cpp b/src/lib/formats/ioprocs.cpp
index 69943c13dc0..34810153f9a 100644
--- a/src/lib/formats/ioprocs.cpp
+++ b/src/lib/formats/ioprocs.cpp
@@ -1,8 +1,8 @@
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <cstdio>
+#include <cstring>
+#include <cassert>
#include "osdcore.h"
#include "ioprocs.h"
#include "corefile.h"
diff --git a/src/lib/formats/ioprocs.h b/src/lib/formats/ioprocs.h
index c569e52dd2b..5b45b4a1450 100644
--- a/src/lib/formats/ioprocs.h
+++ b/src/lib/formats/ioprocs.h
@@ -12,8 +12,8 @@
#pragma once
-#include <stdint.h>
-#include <stdlib.h>
+#include <cstdint>
+#include <cstdlib>
diff --git a/src/lib/formats/ipf_dsk.cpp b/src/lib/formats/ipf_dsk.cpp
index da50e850ea8..ed6505fd385 100644
--- a/src/lib/formats/ipf_dsk.cpp
+++ b/src/lib/formats/ipf_dsk.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
-#include <assert.h>
+#include <cassert>
#include "ipf_dsk.h"
const floppy_format_type FLOPPY_IPF_FORMAT = &floppy_image_format_creator<ipf_format>;
diff --git a/src/lib/formats/iq151_dsk.cpp b/src/lib/formats/iq151_dsk.cpp
index dcffad85751..b085cca0d37 100644
--- a/src/lib/formats/iq151_dsk.cpp
+++ b/src/lib/formats/iq151_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/iq151_dsk.h"
diff --git a/src/lib/formats/itt3030_dsk.cpp b/src/lib/formats/itt3030_dsk.cpp
index 305ab644233..4a4a795c7d3 100644
--- a/src/lib/formats/itt3030_dsk.cpp
+++ b/src/lib/formats/itt3030_dsk.cpp
@@ -10,7 +10,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/itt3030_dsk.h"
diff --git a/src/lib/formats/jvc_dsk.cpp b/src/lib/formats/jvc_dsk.cpp
index 5035e989f22..f5de872c672 100644
--- a/src/lib/formats/jvc_dsk.cpp
+++ b/src/lib/formats/jvc_dsk.cpp
@@ -150,8 +150,8 @@ bool jvc_format::parse_header(io_generic *io, int &header_size, int &tracks, int
switch (header_size)
{
- case 5: emu_fatalerror("jvc_format: sector attribute flag unsupported\n");
- break;
+ case 5:
+ throw emu_fatalerror("jvc_format: sector attribute flag unsupported\n");
case 4: base_sector_id = header[3];
// no break
case 3: sector_size = 128 << header[2];
@@ -184,7 +184,7 @@ bool jvc_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
// safety check
if (sector_count * sector_size > 10000)
- emu_fatalerror("jvc_format: incorrect track layout\n");
+ throw emu_fatalerror("jvc_format: incorrect track layout\n");
int file_offset = header_size;
@@ -253,7 +253,7 @@ bool jvc_format::save(io_generic *io, floppy_image *image)
for (int i = 0; i < 18; i++)
{
if (sectors[1 + i].size != 256)
- emu_fatalerror("jvc_format: invalid sector size: %d\n", sectors[1 + i].size);
+ throw emu_fatalerror("jvc_format: invalid sector size: %d\n", sectors[1 + i].size);
io_generic_write(io, sectors[1 + i].data, file_offset, sectors[1 + i].size);
file_offset += sectors[1 + i].size;
diff --git a/src/lib/formats/kaypro_dsk.cpp b/src/lib/formats/kaypro_dsk.cpp
index e9924ce11c9..6b3996d842c 100644
--- a/src/lib/formats/kaypro_dsk.cpp
+++ b/src/lib/formats/kaypro_dsk.cpp
@@ -16,7 +16,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/kaypro_dsk.h"
diff --git a/src/lib/formats/kc85_dsk.cpp b/src/lib/formats/kc85_dsk.cpp
index 84111ff1171..0648289af71 100644
--- a/src/lib/formats/kc85_dsk.cpp
+++ b/src/lib/formats/kc85_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/kc85_dsk.h"
diff --git a/src/lib/formats/kc_cas.cpp b/src/lib/formats/kc_cas.cpp
index 713def9ac83..ee3d392e86f 100644
--- a/src/lib/formats/kc_cas.cpp
+++ b/src/lib/formats/kc_cas.cpp
@@ -13,7 +13,7 @@
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "kc_cas.h"
diff --git a/src/lib/formats/kim1_cas.cpp b/src/lib/formats/kim1_cas.cpp
index 1bfccc7f8a0..b7853ee967e 100644
--- a/src/lib/formats/kim1_cas.cpp
+++ b/src/lib/formats/kim1_cas.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol
-#include <assert.h>
+#include <cassert>
#include "kim1_cas.h"
diff --git a/src/lib/formats/lviv_lvt.cpp b/src/lib/formats/lviv_lvt.cpp
index 09e91eac9fd..3a94114d421 100644
--- a/src/lib/formats/lviv_lvt.cpp
+++ b/src/lib/formats/lviv_lvt.cpp
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Krzysztof Strzecha
/* .LVT tape images */
-#include <assert.h>
+#include <cassert>
#include "lviv_lvt.h"
diff --git a/src/lib/formats/m5_dsk.cpp b/src/lib/formats/m5_dsk.cpp
index 9652eedbb72..764dfeea6f1 100644
--- a/src/lib/formats/m5_dsk.cpp
+++ b/src/lib/formats/m5_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/m5_dsk.h"
diff --git a/src/lib/formats/mbee_cas.cpp b/src/lib/formats/mbee_cas.cpp
index 24024f66f5d..181bca6aac0 100644
--- a/src/lib/formats/mbee_cas.cpp
+++ b/src/lib/formats/mbee_cas.cpp
@@ -56,7 +56,7 @@ TAP - has an ID header of TAP_DGOS_BEE or MBEE, null terminated.
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "mbee_cas.h"
diff --git a/src/lib/formats/mfi_dsk.cpp b/src/lib/formats/mfi_dsk.cpp
index b6a8a18460a..0f118ce620f 100644
--- a/src/lib/formats/mfi_dsk.cpp
+++ b/src/lib/formats/mfi_dsk.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
-#include <assert.h>
+#include <cassert>
#include "mfi_dsk.h"
#include <zlib.h>
diff --git a/src/lib/formats/mm_dsk.cpp b/src/lib/formats/mm_dsk.cpp
index 0634c0e3ede..0268b46bf89 100644
--- a/src/lib/formats/mm_dsk.cpp
+++ b/src/lib/formats/mm_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/mm_dsk.h"
diff --git a/src/lib/formats/ms0515_dsk.cpp b/src/lib/formats/ms0515_dsk.cpp
index d16e8dbbf73..c89dae8018f 100644
--- a/src/lib/formats/ms0515_dsk.cpp
+++ b/src/lib/formats/ms0515_dsk.cpp
@@ -10,7 +10,7 @@
#include "formats/ms0515_dsk.h"
-#include <assert.h>
+#include <cassert>
ms0515_format::ms0515_format() : wd177x_format(formats)
{
diff --git a/src/lib/formats/mz_cas.cpp b/src/lib/formats/mz_cas.cpp
index cfcf9f36ed8..e7af23aafb4 100644
--- a/src/lib/formats/mz_cas.cpp
+++ b/src/lib/formats/mz_cas.cpp
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "mz_cas.h"
#ifndef VERBOSE
diff --git a/src/lib/formats/nanos_dsk.cpp b/src/lib/formats/nanos_dsk.cpp
index 1536d0677c8..ef466f024a0 100644
--- a/src/lib/formats/nanos_dsk.cpp
+++ b/src/lib/formats/nanos_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/nanos_dsk.h"
diff --git a/src/lib/formats/naslite_dsk.cpp b/src/lib/formats/naslite_dsk.cpp
index cea109c2dc2..fdd63ca0ecc 100644
--- a/src/lib/formats/naslite_dsk.cpp
+++ b/src/lib/formats/naslite_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/naslite_dsk.h"
diff --git a/src/lib/formats/nes_dsk.cpp b/src/lib/formats/nes_dsk.cpp
index 60dbba5dafa..dd311862ca7 100644
--- a/src/lib/formats/nes_dsk.cpp
+++ b/src/lib/formats/nes_dsk.cpp
@@ -9,8 +9,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "formats/nes_dsk.h"
#include "formats/basicdsk.h"
diff --git a/src/lib/formats/nfd_dsk.cpp b/src/lib/formats/nfd_dsk.cpp
index 4d9d8fab980..e677f4ff6f5 100644
--- a/src/lib/formats/nfd_dsk.cpp
+++ b/src/lib/formats/nfd_dsk.cpp
@@ -77,7 +77,7 @@
*********************************************************************/
- #include <assert.h>
+ #include <cassert>
#include "nfd_dsk.h"
diff --git a/src/lib/formats/orao_cas.cpp b/src/lib/formats/orao_cas.cpp
index 2d0f96b2a14..9a2ac05547e 100644
--- a/src/lib/formats/orao_cas.cpp
+++ b/src/lib/formats/orao_cas.cpp
@@ -5,7 +5,7 @@
Tape support for Orao TAP format
*/
-#include <assert.h>
+#include <cassert>
#include "orao_cas.h"
diff --git a/src/lib/formats/oric_tap.cpp b/src/lib/formats/oric_tap.cpp
index c9f84dc7c2a..dcee2f0bd2d 100644
--- a/src/lib/formats/oric_tap.cpp
+++ b/src/lib/formats/oric_tap.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Kevin Thacker
-#include <assert.h>
+#include <cassert>
#include "oric_tap.h"
diff --git a/src/lib/formats/p6001_cas.cpp b/src/lib/formats/p6001_cas.cpp
index 37e1ffcfa2c..3319e377b3d 100644
--- a/src/lib/formats/p6001_cas.cpp
+++ b/src/lib/formats/p6001_cas.cpp
@@ -4,7 +4,7 @@
* NEC PC-6001 cassette format handling
*/
-#include <assert.h>
+#include <cassert>
#include "p6001_cas.h"
diff --git a/src/lib/formats/pc98_dsk.cpp b/src/lib/formats/pc98_dsk.cpp
index 3d85a4380dd..1add267da8f 100644
--- a/src/lib/formats/pc98_dsk.cpp
+++ b/src/lib/formats/pc98_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "formats/pc98_dsk.h"
diff --git a/src/lib/formats/pc98fdi_dsk.cpp b/src/lib/formats/pc98fdi_dsk.cpp
index 5b37b1ede37..37cdae18ff7 100644
--- a/src/lib/formats/pc98fdi_dsk.cpp
+++ b/src/lib/formats/pc98fdi_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "pc98fdi_dsk.h"
pc98fdi_format::pc98fdi_format()
diff --git a/src/lib/formats/pc_dsk.cpp b/src/lib/formats/pc_dsk.cpp
index e4d7e02f47d..193291c8265 100644
--- a/src/lib/formats/pc_dsk.cpp
+++ b/src/lib/formats/pc_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "formats/pc_dsk.h"
#include "formats/basicdsk.h"
diff --git a/src/lib/formats/phc25_cas.cpp b/src/lib/formats/phc25_cas.cpp
index 2cc9ea013e6..197c3db50ae 100644
--- a/src/lib/formats/phc25_cas.cpp
+++ b/src/lib/formats/phc25_cas.cpp
@@ -29,7 +29,7 @@ enough to make it work.
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "phc25_cas.h"
diff --git a/src/lib/formats/pmd_cas.cpp b/src/lib/formats/pmd_cas.cpp
index 79e8820b4bb..a046580bc17 100644
--- a/src/lib/formats/pmd_cas.cpp
+++ b/src/lib/formats/pmd_cas.cpp
@@ -10,7 +10,7 @@
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "pmd_cas.h"
diff --git a/src/lib/formats/ppg_dsk.cpp b/src/lib/formats/ppg_dsk.cpp
index dd08a841e00..0c844a753fc 100644
--- a/src/lib/formats/ppg_dsk.cpp
+++ b/src/lib/formats/ppg_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/ppg_dsk.h"
diff --git a/src/lib/formats/primoptp.cpp b/src/lib/formats/primoptp.cpp
index 5c6779b6613..906a08239a6 100644
--- a/src/lib/formats/primoptp.cpp
+++ b/src/lib/formats/primoptp.cpp
@@ -3,7 +3,7 @@
/* .PTP Microkey Primo tape images */
-#include <assert.h>
+#include <cassert>
#include "primoptp.h"
diff --git a/src/lib/formats/pyldin_dsk.cpp b/src/lib/formats/pyldin_dsk.cpp
index de43ab1947b..89a75ce5555 100644
--- a/src/lib/formats/pyldin_dsk.cpp
+++ b/src/lib/formats/pyldin_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/pyldin_dsk.h"
pyldin_format::pyldin_format() : upd765_format(formats)
diff --git a/src/lib/formats/ql_dsk.cpp b/src/lib/formats/ql_dsk.cpp
index b3ceb233218..6be088439cc 100644
--- a/src/lib/formats/ql_dsk.cpp
+++ b/src/lib/formats/ql_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/ql_dsk.h"
diff --git a/src/lib/formats/rk_cas.cpp b/src/lib/formats/rk_cas.cpp
index 18504fcb130..b522fea2f3b 100644
--- a/src/lib/formats/rk_cas.cpp
+++ b/src/lib/formats/rk_cas.cpp
@@ -5,7 +5,7 @@
Tape support for RK format
*/
-#include <assert.h>
+#include <cassert>
#include "rk_cas.h"
diff --git a/src/lib/formats/rx50_dsk.cpp b/src/lib/formats/rx50_dsk.cpp
index a58a8c5e59c..18bac995146 100644
--- a/src/lib/formats/rx50_dsk.cpp
+++ b/src/lib/formats/rx50_dsk.cpp
@@ -29,7 +29,7 @@
FORMAT A: /F:160 on DOS; turn MEDIACHK ON
************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "flopimg.h"
#include "formats/rx50_dsk.h"
diff --git a/src/lib/formats/sc3000_bit.cpp b/src/lib/formats/sc3000_bit.cpp
index c656b54ee95..6e3600b7aeb 100644
--- a/src/lib/formats/sc3000_bit.cpp
+++ b/src/lib/formats/sc3000_bit.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "sc3000_bit.h"
diff --git a/src/lib/formats/sdf_dsk.cpp b/src/lib/formats/sdf_dsk.cpp
index b2cd4a4e7ab..a1a0c921da7 100644
--- a/src/lib/formats/sdf_dsk.cpp
+++ b/src/lib/formats/sdf_dsk.cpp
@@ -12,7 +12,7 @@
*********************************************************************/
#include "sdf_dsk.h"
-#include <assert.h>
+#include <cassert>
sdf_format::sdf_format()
{
diff --git a/src/lib/formats/sf7000_dsk.cpp b/src/lib/formats/sf7000_dsk.cpp
index 31d0c37ab15..8e063ceba35 100644
--- a/src/lib/formats/sf7000_dsk.cpp
+++ b/src/lib/formats/sf7000_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/sf7000_dsk.h"
diff --git a/src/lib/formats/smx_dsk.cpp b/src/lib/formats/smx_dsk.cpp
index 9158a586c13..7ddcc1ae35f 100644
--- a/src/lib/formats/smx_dsk.cpp
+++ b/src/lib/formats/smx_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/smx_dsk.h"
diff --git a/src/lib/formats/sol_cas.cpp b/src/lib/formats/sol_cas.cpp
index ac668535b51..4672ff95080 100644
--- a/src/lib/formats/sol_cas.cpp
+++ b/src/lib/formats/sol_cas.cpp
@@ -34,7 +34,7 @@ SVT - The full explanation may be found on the Solace web site,
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "sol_cas.h"
diff --git a/src/lib/formats/sorc_cas.cpp b/src/lib/formats/sorc_cas.cpp
index 10fb26197f1..50585d444c7 100644
--- a/src/lib/formats/sorc_cas.cpp
+++ b/src/lib/formats/sorc_cas.cpp
@@ -25,7 +25,7 @@ header and leader bytes.
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "sorc_cas.h"
diff --git a/src/lib/formats/sorc_dsk.cpp b/src/lib/formats/sorc_dsk.cpp
index 7a1b734f780..35d293be3fc 100644
--- a/src/lib/formats/sorc_dsk.cpp
+++ b/src/lib/formats/sorc_dsk.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "sorc_dsk.h"
#include "basicdsk.h"
diff --git a/src/lib/formats/sord_cas.cpp b/src/lib/formats/sord_cas.cpp
index bc11c388915..145cd3c3221 100644
--- a/src/lib/formats/sord_cas.cpp
+++ b/src/lib/formats/sord_cas.cpp
@@ -8,8 +8,8 @@
**************************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "sord_cas.h"
#define SORDM5_WAVESAMPLES_HEADER 1
diff --git a/src/lib/formats/spc1000_cas.cpp b/src/lib/formats/spc1000_cas.cpp
index d13021b0047..2e48980da3d 100644
--- a/src/lib/formats/spc1000_cas.cpp
+++ b/src/lib/formats/spc1000_cas.cpp
@@ -21,7 +21,7 @@ IPL: This seems a quickload format containing RAM dump, not a real tape
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "spc1000_cas.h"
diff --git a/src/lib/formats/st_dsk.cpp b/src/lib/formats/st_dsk.cpp
index 9808dc56ff9..36fe9a01970 100644
--- a/src/lib/formats/st_dsk.cpp
+++ b/src/lib/formats/st_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/st_dsk.h"
diff --git a/src/lib/formats/svi_cas.cpp b/src/lib/formats/svi_cas.cpp
index c681c36d9dd..fcb2142c4e3 100644
--- a/src/lib/formats/svi_cas.cpp
+++ b/src/lib/formats/svi_cas.cpp
@@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Sean Young
-#include <assert.h>
+#include <cassert>
#include "svi_cas.h"
diff --git a/src/lib/formats/tandy2k_dsk.cpp b/src/lib/formats/tandy2k_dsk.cpp
index e08865c9493..f811483251d 100644
--- a/src/lib/formats/tandy2k_dsk.cpp
+++ b/src/lib/formats/tandy2k_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/tandy2k_dsk.h"
diff --git a/src/lib/formats/td0_dsk.cpp b/src/lib/formats/td0_dsk.cpp
index b7c418af53c..4dc3ed53cbf 100644
--- a/src/lib/formats/td0_dsk.cpp
+++ b/src/lib/formats/td0_dsk.cpp
@@ -14,8 +14,8 @@
* Edited and translated to English by Kenji RIKITAKE
*/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "pool.h"
#include "flopimg.h"
diff --git a/src/lib/formats/thom_cas.cpp b/src/lib/formats/thom_cas.cpp
index 45f89ac2a29..a00c2c3234b 100644
--- a/src/lib/formats/thom_cas.cpp
+++ b/src/lib/formats/thom_cas.cpp
@@ -8,8 +8,8 @@
**********************************************************************/
-#include <math.h>
-#include <assert.h>
+#include <cmath>
+#include <cassert>
#include "pool.h"
#include "cassimg.h"
diff --git a/src/lib/formats/thom_dsk.cpp b/src/lib/formats/thom_dsk.cpp
index c8563fc1135..d525641c29f 100644
--- a/src/lib/formats/thom_dsk.cpp
+++ b/src/lib/formats/thom_dsk.cpp
@@ -10,8 +10,8 @@
*********************************************************************/
-#include <string.h>
-#include <assert.h>
+#include <cstring>
+#include <cassert>
#include "thom_dsk.h"
#include "basicdsk.h"
diff --git a/src/lib/formats/ti99_dsk.cpp b/src/lib/formats/ti99_dsk.cpp
index b248c9dd594..a82600feaa6 100644
--- a/src/lib/formats/ti99_dsk.cpp
+++ b/src/lib/formats/ti99_dsk.cpp
@@ -40,9 +40,9 @@
********************************************************************/
-#include <string.h>
-#include <time.h>
-#include <assert.h>
+#include <cstring>
+#include <ctime>
+#include <cassert>
#include <iomanip>
#include "emu.h" // osd_printf_* (in osdcore.h)
diff --git a/src/lib/formats/tiki100_dsk.cpp b/src/lib/formats/tiki100_dsk.cpp
index 2258f29c47a..9dd6555c9ff 100644
--- a/src/lib/formats/tiki100_dsk.cpp
+++ b/src/lib/formats/tiki100_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/tiki100_dsk.h"
diff --git a/src/lib/formats/trd_dsk.cpp b/src/lib/formats/trd_dsk.cpp
index 4766a3426e3..fd823e4aaba 100644
--- a/src/lib/formats/trd_dsk.cpp
+++ b/src/lib/formats/trd_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/trd_dsk.h"
diff --git a/src/lib/formats/trs_cas.cpp b/src/lib/formats/trs_cas.cpp
index a6701ed1263..582abf8869c 100644
--- a/src/lib/formats/trs_cas.cpp
+++ b/src/lib/formats/trs_cas.cpp
@@ -6,7 +6,7 @@ Support for TRS80 .cas cassette images
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/trs_cas.h"
diff --git a/src/lib/formats/tvc_cas.cpp b/src/lib/formats/tvc_cas.cpp
index 9177491278c..3cea37cc1bf 100644
--- a/src/lib/formats/tvc_cas.cpp
+++ b/src/lib/formats/tvc_cas.cpp
@@ -8,7 +8,7 @@
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "tvc_cas.h"
diff --git a/src/lib/formats/tvc_dsk.cpp b/src/lib/formats/tvc_dsk.cpp
index 8a2254cb7cc..303a5c2c09d 100644
--- a/src/lib/formats/tvc_dsk.cpp
+++ b/src/lib/formats/tvc_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/tvc_dsk.h"
diff --git a/src/lib/formats/tzx_cas.cpp b/src/lib/formats/tzx_cas.cpp
index 28d363df433..a4b2b30ed81 100644
--- a/src/lib/formats/tzx_cas.cpp
+++ b/src/lib/formats/tzx_cas.cpp
@@ -27,7 +27,7 @@ TODO:
*/
-#include <assert.h>
+#include <cassert>
#include "tzx_cas.h"
#include "formats/imageutl.h"
diff --git a/src/lib/formats/uef_cas.cpp b/src/lib/formats/uef_cas.cpp
index 78247887eb5..d19eb9b2e47 100644
--- a/src/lib/formats/uef_cas.cpp
+++ b/src/lib/formats/uef_cas.cpp
@@ -18,9 +18,9 @@ Not nice, but it works...
*/
-#include <string.h>
-#include <math.h>
-#include <assert.h>
+#include <cstring>
+#include <cmath>
+#include <cassert>
#include <zlib.h>
#include "uef_cas.h"
diff --git a/src/lib/formats/vg5k_cas.cpp b/src/lib/formats/vg5k_cas.cpp
index 898507e7139..cb8ab9636c5 100644
--- a/src/lib/formats/vg5k_cas.cpp
+++ b/src/lib/formats/vg5k_cas.cpp
@@ -5,7 +5,7 @@
Support for VG-5000 .k7 cassette images
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "vg5k_cas.h"
diff --git a/src/lib/formats/vt_cas.cpp b/src/lib/formats/vt_cas.cpp
index 9dbc68f8074..a8c30f8d25f 100644
--- a/src/lib/formats/vt_cas.cpp
+++ b/src/lib/formats/vt_cas.cpp
@@ -1,6 +1,6 @@
// license:GPL-2.0+
// copyright-holders:Juergen Buchmueller
-#include <assert.h>
+#include <cassert>
#include "formats/vt_cas.h"
diff --git a/src/lib/formats/wavfile.cpp b/src/lib/formats/wavfile.cpp
index 072be6c92a2..1408984079c 100644
--- a/src/lib/formats/wavfile.cpp
+++ b/src/lib/formats/wavfile.cpp
@@ -8,8 +8,8 @@
*********************************************************************/
-#include <stdio.h>
-#include <assert.h>
+#include <cstdio>
+#include <cassert>
#include "wavfile.h"
#include "cassimg.h"
diff --git a/src/lib/formats/x07_cas.cpp b/src/lib/formats/x07_cas.cpp
index b49d7c8d643..131693f2da1 100644
--- a/src/lib/formats/x07_cas.cpp
+++ b/src/lib/formats/x07_cas.cpp
@@ -6,7 +6,7 @@
********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "x07_cas.h"
diff --git a/src/lib/formats/x1_tap.cpp b/src/lib/formats/x1_tap.cpp
index b4fe65b8e8c..88c962bf53b 100644
--- a/src/lib/formats/x1_tap.cpp
+++ b/src/lib/formats/x1_tap.cpp
@@ -21,7 +21,7 @@
*
*/
-#include <assert.h>
+#include <cassert>
#include "x1_tap.h"
diff --git a/src/lib/formats/xdf_dsk.cpp b/src/lib/formats/xdf_dsk.cpp
index c77d685d9be..698b8799abc 100644
--- a/src/lib/formats/xdf_dsk.cpp
+++ b/src/lib/formats/xdf_dsk.cpp
@@ -8,7 +8,7 @@
*********************************************************************/
-#include <assert.h>
+#include <cassert>
#include "formats/xdf_dsk.h"
diff --git a/src/lib/formats/zx81_p.cpp b/src/lib/formats/zx81_p.cpp
index 9fa5814385f..709bdccfc4c 100644
--- a/src/lib/formats/zx81_p.cpp
+++ b/src/lib/formats/zx81_p.cpp
@@ -31,7 +31,7 @@ medium transfer rate is approx. 307 bps (38 bytes/sec) for files that contain
*****************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "zx81_p.h"
#include "tzx_cas.h"
diff --git a/src/lib/netlist/analog/nld_fourterm.h b/src/lib/netlist/analog/nld_fourterm.h
index dcd32744263..9f0d7760c3b 100644
--- a/src/lib/netlist/analog/nld_fourterm.h
+++ b/src/lib/netlist/analog/nld_fourterm.h
@@ -14,14 +14,17 @@
// Macros
// ----------------------------------------------------------------------------------------
-#define VCCS(name) \
- NET_REGISTER_DEV(VCCS, name)
+#define VCCS(name, G) \
+ NET_REGISTER_DEVEXT(VCCS, G)
-#define CCCS(name) \
- NET_REGISTER_DEV(CCCS, name)
+#define CCCS(name, G) \
+ NET_REGISTER_DEVEXT(CCCS, name, G)
-#define VCVS(name) \
- NET_REGISTER_DEV(VCVS, name)
+#define VCVS(name, G) \
+ NET_REGISTER_DEVEXT(VCVS, name, G)
+
+#define CCVS(name, G) \
+ NET_REGISTER_DEVEXT(CCVS, name, G)
#define LVCCS(name) \
NET_REGISTER_DEV(LVCCS, name)
diff --git a/src/lib/netlist/analog/nld_generic_models.h b/src/lib/netlist/analog/nld_generic_models.h
index a5d035ed32b..799c28c5a28 100644
--- a/src/lib/netlist/analog/nld_generic_models.h
+++ b/src/lib/netlist/analog/nld_generic_models.h
@@ -138,11 +138,9 @@ namespace analog
, m_Vmin(nlconst::zero()) // not used in MOS model
, m_Is(nlconst::zero())
, m_logIs(nlconst::zero())
- , m_n(nlconst::zero())
, m_gmin(nlconst::magic(1e-15))
, m_VtInv(nlconst::zero())
, m_Vcrit(nlconst::zero())
- , m_name(name)
{
set_param(
nlconst::magic(1e-15)
@@ -153,16 +151,19 @@ namespace analog
void update_diode(nl_fptype nVd) noexcept
{
- nl_fptype IseVDVt(nlconst::zero());
-
if (TYPE == diode_e::BIPOLAR)
{
//printf("%s: %g %g\n", m_name.c_str(), nVd, (nl_fptype) m_Vd);
if (nVd > m_Vcrit)
{
- const nl_fptype d = std::min(+fp_constants<nl_fptype>::DIODE_MAXDIFF(), nVd - m_Vd);
+ // if the old voltage is less than zero and new is above
+ // make sure we move enough so that matrix and current
+ // changes.
+ const nl_fptype old = std::max(nlconst::zero(), m_Vd());
+ const nl_fptype d = std::min(+fp_constants<nl_fptype>::DIODE_MAXDIFF(), nVd - old);
const nl_fptype a = plib::abs(d) * m_VtInv;
- m_Vd = m_Vd + nlconst::magic(d < 0 ? -1.0 : 1.0) * plib::log1p(a) * m_Vt;
+ m_Vd = old + nlconst::magic(d < 0 ? -1.0 : 1.0) * plib::log1p(a) * m_Vt;
+ //printf("new VD: %g\n", (nl_fptype)m_Vd);
}
else
m_Vd = std::max(-fp_constants<nl_fptype>::DIODE_MAXDIFF(), nVd);
@@ -175,7 +176,7 @@ namespace analog
}
else
{
- IseVDVt = plib::exp(m_logIs + m_Vd * m_VtInv);
+ const auto IseVDVt = plib::exp(m_logIs + m_Vd * m_VtInv);
m_Id = IseVDVt - m_Is;
m_G = IseVDVt * m_VtInv + m_gmin;
}
@@ -191,7 +192,7 @@ namespace analog
else // log stepping should already be done in mosfet
{
m_Vd = nVd;
- IseVDVt = plib::exp(std::min(+fp_constants<nl_fptype>::DIODE_MAXVOLT(), m_logIs + m_Vd * m_VtInv));
+ const auto IseVDVt = plib::exp(std::min(+fp_constants<nl_fptype>::DIODE_MAXVOLT(), m_logIs + m_Vd * m_VtInv));
m_Id = IseVDVt - m_Is;
m_G = IseVDVt * m_VtInv + m_gmin;
}
@@ -202,10 +203,9 @@ namespace analog
{
m_Is = Is;
m_logIs = plib::log(Is);
- m_n = n;
m_gmin = gmin;
- m_Vt = m_n * temp * nlconst::k_b() / nlconst::Q_e();
+ m_Vt = n * temp * nlconst::k_b() / nlconst::Q_e();
m_Vmin = nlconst::magic(-5.0) * m_Vt;
@@ -231,13 +231,10 @@ namespace analog
nl_fptype m_Vmin;
nl_fptype m_Is;
nl_fptype m_logIs;
- nl_fptype m_n;
nl_fptype m_gmin;
nl_fptype m_VtInv;
nl_fptype m_Vcrit;
-
- pstring m_name;
};
diff --git a/src/lib/netlist/analog/nld_mosfet.cpp b/src/lib/netlist/analog/nld_mosfet.cpp
index fff7b8d03eb..4817f6cc00c 100644
--- a/src/lib/netlist/analog/nld_mosfet.cpp
+++ b/src/lib/netlist/analog/nld_mosfet.cpp
@@ -476,7 +476,11 @@ namespace analog
const nl_fptype Vctrl = (is_forward ? Vgs : Vgd) - Vth;
- nl_fptype Ids(0), gm(0), gds(0), gmb(0);
+ nl_fptype Ids(0);
+ nl_fptype gm(0);
+ nl_fptype gds(0);
+ nl_fptype gmb(0);
+
const nl_fptype absVds = plib::abs(Vds);
if (Vctrl <= nlconst::zero())
diff --git a/src/lib/netlist/analog/nld_opamps.cpp b/src/lib/netlist/analog/nld_opamps.cpp
index 6a1502dab00..8af6ab28170 100644
--- a/src/lib/netlist/analog/nld_opamps.cpp
+++ b/src/lib/netlist/analog/nld_opamps.cpp
@@ -112,7 +112,7 @@ namespace netlist
if (m_type < 1 || m_type > 3)
{
log().fatal(MF_OPAMP_UNKNOWN_TYPE(m_type));
- plib::pthrow<nl_exception>(MF_OPAMP_UNKNOWN_TYPE(m_type));
+ throw nl_exception(MF_OPAMP_UNKNOWN_TYPE(m_type));
}
if (m_type == 1)
diff --git a/src/lib/netlist/analog/nld_switches.cpp b/src/lib/netlist/analog/nld_switches.cpp
index 9861b4fd1e5..a5d68228af1 100644
--- a/src/lib/netlist/analog/nld_switches.cpp
+++ b/src/lib/netlist/analog/nld_switches.cpp
@@ -108,13 +108,13 @@ namespace netlist
m_R1.set_R(R_OFF);
m_R2.set_R(R_ON);
}
-
- //m_R1.update_dev(time);
- //m_R2.update_dev(time);
}
NETLIB_UPDATE_PARAM(switch2)
{
+ // FIXME: We only need to update the net first if this is a time stepping net
+ m_R1.solve_now();
+ m_R2.solve_now();
if (!m_POS())
{
m_R1.set_R(R_ON);
@@ -125,9 +125,8 @@ namespace netlist
m_R1.set_R(R_OFF);
m_R2.set_R(R_ON);
}
-
- m_R1.solve_now();
- m_R2.solve_now();
+ m_R1.solve_later();
+ m_R2.solve_later();
}
} //namespace analog
diff --git a/src/lib/netlist/analog/nlid_fourterm.cpp b/src/lib/netlist/analog/nlid_fourterm.cpp
index 8b1240c7f82..0478a73fb50 100644
--- a/src/lib/netlist/analog/nlid_fourterm.cpp
+++ b/src/lib/netlist/analog/nlid_fourterm.cpp
@@ -108,12 +108,26 @@ NETLIB_RESET(VCVS)
m_ON2.set_conductivity(m_gfac);
}
+// ----------------------------------------------------------------------------------------
+// nld_CCVS
+// ----------------------------------------------------------------------------------------
+
+NETLIB_RESET(CCVS)
+{
+ m_gfac = plib::reciprocal(m_RO());
+ NETLIB_NAME(VCCS)::reset();
+
+ m_OP2.set_conductivity(m_gfac);
+ m_ON2.set_conductivity(m_gfac);
+}
+
} //namespace analog
namespace devices {
- NETLIB_DEVICE_IMPL_NS(analog, VCVS, "VCVS", "")
- NETLIB_DEVICE_IMPL_NS(analog, VCCS, "VCCS", "")
- NETLIB_DEVICE_IMPL_NS(analog, CCCS, "CCCS", "")
+ NETLIB_DEVICE_IMPL_NS(analog, VCVS, "VCVS", "G")
+ NETLIB_DEVICE_IMPL_NS(analog, VCCS, "VCCS", "G")
+ NETLIB_DEVICE_IMPL_NS(analog, CCCS, "CCCS", "G")
+ NETLIB_DEVICE_IMPL_NS(analog, CCVS, "CCVS", "G")
NETLIB_DEVICE_IMPL_NS(analog, LVCCS, "LVCCS", "")
} // namespace devices
} // namespace netlist
diff --git a/src/lib/netlist/analog/nlid_fourterm.h b/src/lib/netlist/analog/nlid_fourterm.h
index c7ec2524b9b..862fe8f79e5 100644
--- a/src/lib/netlist/analog/nlid_fourterm.h
+++ b/src/lib/netlist/analog/nlid_fourterm.h
@@ -36,9 +36,9 @@ namespace analog {
NETLIB_OBJECT(VCCS)
{
public:
- NETLIB_CONSTRUCTOR(VCCS)
+ NETLIB_CONSTRUCTOR_EX(VCCS, nl_fptype ari = nlconst::magic(1e9))
, m_G(*this, "G", nlconst::one())
- , m_RI(*this, "RI", nlconst::magic(1e9))
+ , m_RI(*this, "RI", ari)
, m_OP(*this, "OP", &m_IP)
, m_ON(*this, "ON", &m_IP)
, m_IP(*this, "IP", &m_IN) // <= this should be NULL and terminal be filtered out prior to solving...
@@ -126,7 +126,7 @@ namespace analog {
NETLIB_OBJECT_DERIVED(CCCS, VCCS)
{
public:
- NETLIB_CONSTRUCTOR_DERIVED(CCCS, VCCS)
+ NETLIB_CONSTRUCTOR_DERIVED_PASS(CCCS, VCCS, nlconst::one())
{
m_gfac = plib::reciprocal(m_RI());
}
@@ -191,6 +191,57 @@ namespace analog {
};
+ // ----------------------------------------------------------------------------------------
+ // nld_CCVS
+ // ----------------------------------------------------------------------------------------
+
+ //
+ // Voltage controlled voltage source
+ //
+ // Parameters:
+ // G Default: 1
+ // RO Default: 1 (would be typically 50 for an op-amp
+ //
+ // IP ---+ +--+---- OP
+ // | | |
+ // RI I RO
+ // RI => G => I RO V(OP) - V(ON) = (V(IP)-V(IN)) / RI * G
+ // RI I RO
+ // | | |
+ // IN ---+ +--+---- ON
+ //
+ // G=1 ==> 1A ==> 1V
+ //
+ // RI = 1
+ //
+ // Internal GI = G / RO
+ //
+
+ NETLIB_OBJECT_DERIVED(CCVS, VCCS)
+ {
+ public:
+ NETLIB_CONSTRUCTOR_DERIVED_PASS(CCVS, VCCS, nlconst::one())
+ , m_RO(*this, "RO", nlconst::one())
+ , m_OP2(*this, "_OP2", &m_ON2)
+ , m_ON2(*this, "_ON2", &m_OP2)
+ {
+ connect(m_OP2, m_OP1);
+ connect(m_ON2, m_ON1);
+ }
+
+ NETLIB_RESETI();
+
+ param_fp_t m_RO;
+
+ private:
+ //NETLIB_UPDATEI();
+ //NETLIB_UPDATE_PARAMI();
+
+ terminal_t m_OP2;
+ terminal_t m_ON2;
+ };
+
+
} // namespace analog
} // namespace netlist
diff --git a/src/lib/netlist/analog/nlid_twoterm.cpp b/src/lib/netlist/analog/nlid_twoterm.cpp
index e06a9cf275a..5aa312bc64a 100644
--- a/src/lib/netlist/analog/nlid_twoterm.cpp
+++ b/src/lib/netlist/analog/nlid_twoterm.cpp
@@ -66,6 +66,7 @@ namespace analog
NETLIB_UPDATE_PARAM(POT)
{
+ // FIXME: We only need to update the net first if this is a time stepping net
m_R1.solve_now();
m_R2.solve_now();
@@ -76,6 +77,8 @@ namespace analog
v = nlconst::one() - v;
m_R1.set_R(std::max(m_R() * v, exec().gmin()));
m_R2.set_R(std::max(m_R() * (nlconst::one() - v), exec().gmin()));
+ m_R1.solve_later();
+ m_R2.solve_later();
}
@@ -97,6 +100,7 @@ namespace analog
NETLIB_UPDATE_PARAM(POT2)
{
+ // FIXME: We only need to update the net first if this is a time stepping net
m_R1.solve_now();
nl_fptype v = m_Dial();
@@ -106,6 +110,7 @@ namespace analog
if (m_Reverse())
v = nlconst::one() - v;
m_R1.set_R(std::max(m_R() * v, exec().gmin()));
+ m_R1.solve_later();
}
// ----------------------------------------------------------------------------------------
diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h
index 396b4e938c9..d869144cbe2 100644
--- a/src/lib/netlist/analog/nlid_twoterm.h
+++ b/src/lib/netlist/analog/nlid_twoterm.h
@@ -64,7 +64,7 @@ namespace analog
{
plib::unused_var(d1);
if (b)
- plib::pthrow<nl_exception>("bselect with netlist and b==true");
+ throw nl_exception("bselect with netlist and b==true");
return d2;
}
@@ -167,8 +167,10 @@ namespace analog
NETLIB_UPDATE_PARAMI()
{
+ // FIXME: We only need to update the net first if this is a time stepping net
solve_now();
set_R(std::max(m_R(), exec().gmin()));
+ solve_later();
}
private:
@@ -283,6 +285,7 @@ namespace analog
protected:
//NETLIB_UPDATEI();
+ //FIXME: should be able to change
NETLIB_UPDATE_PARAMI() { }
private:
@@ -484,13 +487,15 @@ namespace analog
NETLIB_UPDATE_PARAMI()
{
+ // FIXME: We only need to update the net first if this is a time stepping net
+ //FIXME: works only for CS without function
solve_now();
const auto zero(nlconst::zero());
set_mat(zero, zero, -m_I(),
zero, zero, m_I());
+ solve_later();
}
-
private:
state_var<nl_fptype> m_t;
param_fp_t m_I;
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile
index cc8b62ac287..af72486c46f 100644
--- a/src/lib/netlist/build/makefile
+++ b/src/lib/netlist/build/makefile
@@ -14,7 +14,7 @@ VSBUILD = $(SRC)/buildVS
DOC = $(SRC)/documentation
TIDY_DB = ../compile_commands.json
-TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,cert-*,-android-*,
+TIDY_FLAGSX = -checks=*,-google*,-hicpp*,readability*,-fuchsia*,cert-*,-android-*,
TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast,
TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-owning-memory,
TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds-constant-array-index,
@@ -25,7 +25,8 @@ TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-
TIDY_FLAGSX += -bugprone-macro-parentheses,-misc-macro-parentheses,
TIDY_FLAGSX += -bugprone-too-small-loop-variable,
TIDY_FLAGSX += -modernize-use-trailing-return-type,
-TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay
+TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+TIDY_FLAGSX += -readability-magic-numbers,-readability-implicit-bool-conversion,-readability-braces-around-statements
space :=
space +=
@@ -106,6 +107,7 @@ NLOBJS := \
$(NLOBJ)/devices/nld_2102A.o \
$(NLOBJ)/devices/nld_2716.o \
$(NLOBJ)/devices/nld_tms4800.o \
+ $(NLOBJ)/devices/nld_4006.o \
$(NLOBJ)/devices/nld_4020.o \
$(NLOBJ)/devices/nld_4066.o \
$(NLOBJ)/devices/nld_4316.o \
diff --git a/src/lib/netlist/devices/net_lib.cpp b/src/lib/netlist/devices/net_lib.cpp
index db57f3f8b81..6685f6231d9 100644
--- a/src/lib/netlist/devices/net_lib.cpp
+++ b/src/lib/netlist/devices/net_lib.cpp
@@ -38,6 +38,7 @@ namespace devices
LIB_ENTRY(VCVS)
LIB_ENTRY(VCCS)
LIB_ENTRY(CCCS)
+ LIB_ENTRY(CCVS)
LIB_ENTRY(LVCCS)
LIB_ENTRY(opamp)
LIB_ENTRY(nc_pin)
@@ -133,6 +134,8 @@ namespace devices
LIB_ENTRY(9334)
LIB_ENTRY(AM2847)
// FIXME: duplicate?
+ LIB_ENTRY(CD4006)
+ LIB_ENTRY(CD4006_dip)
LIB_ENTRY(CD4020_WI)
LIB_ENTRY(CD4020)
LIB_ENTRY(CD4066_GATE)
diff --git a/src/lib/netlist/devices/net_lib.h b/src/lib/netlist/devices/net_lib.h
index 159d1a24c36..bae49e160f2 100644
--- a/src/lib/netlist/devices/net_lib.h
+++ b/src/lib/netlist/devices/net_lib.h
@@ -43,13 +43,13 @@
#else
#define SOLVER(name, freq) \
- NET_REGISTER_DEV(SOLVER, name) \
- PARAM(name.FREQ, freq)
+ NET_REGISTER_DEVEXT(SOLVER, name, freq)
#include "nld_system.h"
#include "nld_2102A.h"
#include "nld_2716.h"
+#include "nld_4006.h"
#include "nld_4020.h"
#include "nld_4066.h"
#include "nld_74107.h"
diff --git a/src/lib/netlist/devices/nld_2716.cpp b/src/lib/netlist/devices/nld_2716.cpp
index 02fbec5b4d0..8455f6f6b6e 100644
--- a/src/lib/netlist/devices/nld_2716.cpp
+++ b/src/lib/netlist/devices/nld_2716.cpp
@@ -83,7 +83,7 @@ namespace netlist
{
unsigned a = 0;
for (std::size_t i=0; i<11; i++)
- a |= (m_A[i]() << i);
+ a |= (m_A[i]() << i);
d = m_ROM[a];
diff --git a/src/lib/netlist/devices/nld_4006.cpp b/src/lib/netlist/devices/nld_4006.cpp
new file mode 100644
index 00000000000..7948e0b92e4
--- /dev/null
+++ b/src/lib/netlist/devices/nld_4006.cpp
@@ -0,0 +1,100 @@
+// license:GPL-2.0+
+// copyright-holders:Couriersud
+/*
+ * nld_4006.c
+ *
+ */
+
+#include "nld_4006.h"
+#include "nlid_system.h"
+
+namespace netlist
+{
+ namespace devices
+ {
+ NETLIB_OBJECT(CD4006)
+ {
+ NETLIB_CONSTRUCTOR(CD4006)
+ NETLIB_FAMILY("CD4XXX")
+ , m_CLOCK(*this, "CLOCK")
+ , m_I(*this, {{"D1", "D2", "D3", "D4"}})
+ , m_Q(*this, {{"D1P4", "D1P4S", "D2P4", "D2P5", "D3P4", "D4P4", "D3P5"}})
+ , m_d(*this, "m_d", 0)
+ , m_last_clock(*this, "m_last_clock", 0)
+ , m_supply(*this, "VDD", "VSS")
+ {
+ }
+
+ NETLIB_RESETI()
+ {
+ }
+
+ NETLIB_UPDATEI()
+ {
+ if (m_last_clock && !m_CLOCK())
+ {
+ m_d[0] >>= 1;
+ m_d[1] >>= 1;
+ m_d[2] >>= 1;
+ m_d[3] >>= 1;
+ // falling, output all but D1P4S
+ m_Q[0].push(m_d[0] & 1, netlist_time::from_nsec(200));
+ m_Q[2].push((m_d[1] >> 1) & 1, netlist_time::from_nsec(200)); // D2 + 4
+ m_Q[3].push( m_d[1] & 1, netlist_time::from_nsec(200)); // D2 + 5
+ m_Q[4].push( m_d[2] & 1, netlist_time::from_nsec(200)); // D3 + 4
+ m_Q[5].push((m_d[3] >> 1) & 1, netlist_time::from_nsec(200)); // D4 + 4
+ m_Q[6].push( m_d[3] & 1, netlist_time::from_nsec(200)); // D5 + 5
+ m_last_clock = m_CLOCK();
+ }
+ else if (!m_last_clock && m_CLOCK())
+ {
+ // rising, output D1P4S
+ m_Q[1].push(m_d[0] & 1, netlist_time::from_nsec(200));
+ m_last_clock = m_CLOCK();
+ }
+ else
+ {
+ m_d[0] = static_cast<uint8_t>((m_d[0] & 0x0f) | (m_I[0]() << 4));
+ m_d[1] = static_cast<uint8_t>((m_d[1] & 0x1f) | (m_I[1]() << 5));
+ m_d[2] = static_cast<uint8_t>((m_d[2] & 0x0f) | (m_I[2]() << 4));
+ m_d[3] = static_cast<uint8_t>((m_d[3] & 0x1f) | (m_I[3]() << 5));
+ }
+ }
+
+ protected:
+ logic_input_t m_CLOCK;
+ object_array_t<logic_input_t, 4> m_I;
+ object_array_t<logic_output_t, 7> m_Q;
+ state_container<std::array<uint8_t, 4>> m_d;
+ state_var<netlist_sig_t> m_last_clock;
+ nld_power_pins m_supply;
+ };
+
+ NETLIB_OBJECT_DERIVED(CD4006_dip, CD4006)
+ {
+ NETLIB_CONSTRUCTOR_DERIVED(CD4006_dip, CD4006)
+ {
+ register_subalias("1", m_I[0]);
+ register_subalias("2", m_Q[1]);
+ register_subalias("3", m_CLOCK);
+ register_subalias("4", m_I[1]);
+ register_subalias("5", m_I[2]);
+ register_subalias("6", m_I[3]);
+ register_subalias("7", "VSS");
+
+ register_subalias("8", m_Q[5]);
+ register_subalias("9", m_Q[6]);
+ register_subalias("10", m_Q[4]);
+ register_subalias("11", m_Q[2]);
+ register_subalias("12", m_Q[3]);
+ register_subalias("13", m_Q[0]);
+ register_subalias("14", "VDD");
+
+ }
+ };
+
+ NETLIB_DEVICE_IMPL(CD4006, "CD4006", "+CLOCK,+D1,+D2,+D3,+D4,+D1P4,+D1P4S,+D2P4,+D2P5,+D3P4,+D4P4,+D3P5,@VCC,@GND")
+ NETLIB_DEVICE_IMPL(CD4006_dip, "CD4006_DIP", "")
+
+ } //namespace devices
+} // namespace netlist
diff --git a/src/lib/netlist/devices/nld_4006.h b/src/lib/netlist/devices/nld_4006.h
new file mode 100644
index 00000000000..77ff7528fc8
--- /dev/null
+++ b/src/lib/netlist/devices/nld_4006.h
@@ -0,0 +1,50 @@
+// license:GPL-2.0+
+// copyright-holders:Couriersud
+/*
+ * nld_4006.h
+ *
+ * CD4006: CMOS 18-Stage Static Register
+ *
+ * Description
+ *
+ * CD4006BMS types are composed of 4 separate shift register sections: two
+ * sections of four stages and two sections of five stages with an output tap
+ * at the fourth stage. Each section has an independent single-rail data path.
+ *
+ * A common clock signal is used for all stages. Data are shifted to the next
+ * stages on negative-going transitions of the clock. Through appropriate
+ * connections of inputs and outputs, multiple register sections of 4, 5, 8,
+ * and 9 stages or single register sections of 10, 12, 13, 14, 16, 17 and 18
+ * stages can be implemented using one CD4006BMS package. Longer shift register
+ * sections can be assembled by using more than one CD4006BMS.
+ *
+ * To facilitate cascading stages when clock rise and fall times are slow,
+ * an optional output (D1 + 4’) that is delayed one-half clockcycle, is
+ * provided.
+ *
+ * +--------------+
+ * D1 |1 ++ 14| VDD
+ * D1+4' |2 13| D1+4
+ * CLOCK |3 12| D2+5
+ * D2 |4 4006 11| D2+4
+ * D3 |5 10| D3+4
+ * D4 |6 9| D4+5
+ * VSS |7 8| D4+4
+ * +--------------+
+ *
+ *
+ * Naming conventions follow SYC datasheet
+ *
+ * FIXME: Timing depends on VDD-VSS
+ *
+ */
+
+#ifndef NLD_4006_H_
+#define NLD_4006_H_
+
+#include "netlist/nl_setup.h"
+
+#define CD4006(name) \
+ NET_REGISTER_DEV(CD4006, name)
+
+#endif /* NLD_4006_H_ */
diff --git a/src/lib/netlist/devices/nld_4020.cpp b/src/lib/netlist/devices/nld_4020.cpp
index 5fae0da4434..d545b59544a 100644
--- a/src/lib/netlist/devices/nld_4020.cpp
+++ b/src/lib/netlist/devices/nld_4020.cpp
@@ -5,7 +5,6 @@
*
*/
-//#include "nlid_cmos.h"
#include "nld_4020.h"
#include "nlid_system.h"
diff --git a/src/lib/netlist/devices/nld_4066.cpp b/src/lib/netlist/devices/nld_4066.cpp
index 70e687b56bb..a45b2ab9e22 100644
--- a/src/lib/netlist/devices/nld_4066.cpp
+++ b/src/lib/netlist/devices/nld_4066.cpp
@@ -23,6 +23,7 @@ namespace netlist
, m_R(*this, "R")
, m_control(*this, "CTL")
, m_base_r(*this, "BASER", nlconst::magic(270.0))
+ , m_last(*this, "m_last", false)
{
}
@@ -34,7 +35,8 @@ namespace netlist
analog::NETLIB_SUB(R_base) m_R;
analog_input_t m_control;
- param_fp_t m_base_r;
+ param_fp_t m_base_r;
+ state_var<bool> m_last;
};
NETLIB_RESET(CD4066_GATE)
@@ -53,6 +55,7 @@ namespace netlist
nl_fptype in = m_control() - m_supply.GND().Q_Analog();
nl_fptype rON = m_base_r() * nlconst::magic(5.0) / sup;
nl_fptype R = -nlconst::one();
+ bool new_state(false);
if (in < low)
{
@@ -61,9 +64,12 @@ namespace netlist
else if (in > high)
{
R = rON;
+ new_state = true;
}
- if (R > nlconst::zero())
+ //printf("%s %f %f %g\n", name().c_str(), sup, in, R);
+ if (R > nlconst::zero() && (m_last != new_state))
{
+ m_last = new_state;
m_R.update();
m_R.set_R(R);
m_R.solve_later();
diff --git a/src/lib/netlist/devices/nld_7485.cpp b/src/lib/netlist/devices/nld_7485.cpp
index 7cf166a807d..60cf53e8bdb 100644
--- a/src/lib/netlist/devices/nld_7485.cpp
+++ b/src/lib/netlist/devices/nld_7485.cpp
@@ -86,7 +86,8 @@ namespace netlist
update_outputs(1, 0, 0);
return;
}
- else if (m_A[i]() < m_B[i]())
+
+ if (m_A[i]() < m_B[i]())
{
update_outputs(0, 1, 0);
return;
diff --git a/src/lib/netlist/devices/nld_7493.cpp b/src/lib/netlist/devices/nld_7493.cpp
index 855bd8a3770..48c2b179073 100644
--- a/src/lib/netlist/devices/nld_7493.cpp
+++ b/src/lib/netlist/devices/nld_7493.cpp
@@ -131,7 +131,7 @@ namespace netlist
NETLIB_HANDLERI(updB)
{
- auto cnt = (++m_bcd &= 0x07);
+ const auto cnt(++m_bcd &= 0x07);
m_QD.push((cnt >> 2) & 1, out_delay3);
m_QC.push((cnt >> 1) & 1, out_delay2);
m_QB.push(cnt & 1, out_delay);
diff --git a/src/lib/netlist/devices/nld_82S126.cpp b/src/lib/netlist/devices/nld_82S126.cpp
index 9ce6697c82e..44c2152dcb5 100644
--- a/src/lib/netlist/devices/nld_82S126.cpp
+++ b/src/lib/netlist/devices/nld_82S126.cpp
@@ -73,7 +73,7 @@ namespace netlist
{
unsigned a = 0;
for (std::size_t i=0; i<8; i++)
- a |= (m_A[i]() << i);
+ a |= (m_A[i]() << i);
o = m_ROM[a];
diff --git a/src/lib/netlist/devices/nld_log.cpp b/src/lib/netlist/devices/nld_log.cpp
index 5dd06c9beca..03165a573ef 100644
--- a/src/lib/netlist/devices/nld_log.cpp
+++ b/src/lib/netlist/devices/nld_log.cpp
@@ -23,7 +23,7 @@ namespace netlist
, m_writer(&m_strm)
{
if (m_strm.fail())
- plib::pthrow<plib::file_open_e>(plib::pfmt("{1}.log")(this->name()));
+ throw plib::file_open_e(plib::pfmt("{1}.log")(this->name()));
m_strm.imbue(std::locale::classic());
}
diff --git a/src/lib/netlist/devices/nld_r2r_dac.cpp b/src/lib/netlist/devices/nld_r2r_dac.cpp
index 8f2c62d2185..361652a373a 100644
--- a/src/lib/netlist/devices/nld_r2r_dac.cpp
+++ b/src/lib/netlist/devices/nld_r2r_dac.cpp
@@ -39,12 +39,13 @@ namespace netlist
NETLIB_UPDATE_PARAM(r2r_dac)
{
+ // FIXME: We only need to update the net first if this is a time stepping net
solve_now();
-
nl_fptype V = m_VIN() / static_cast<nl_fptype>(1 << m_num())
* static_cast<nl_fptype>(m_val());
this->set_G_V_I(plib::reciprocal(m_R()), V, nlconst::zero());
+ solve_later();
}
} //namespace analog
diff --git a/src/lib/netlist/devices/nld_r2r_dac.h b/src/lib/netlist/devices/nld_r2r_dac.h
index 8a4257a3cbf..d440f999d67 100644
--- a/src/lib/netlist/devices/nld_r2r_dac.h
+++ b/src/lib/netlist/devices/nld_r2r_dac.h
@@ -49,9 +49,6 @@
#include "netlist/nl_setup.h"
#define R2R_DAC(name, p_VIN, p_R, p_N) \
- NET_REGISTER_DEV(R2R_DAC, name) \
- NETDEV_PARAMI(name, VIN, p_VIN) \
- NETDEV_PARAMI(name, R, p_R) \
- NETDEV_PARAMI(name, N, p_N)
+ NET_REGISTER_DEVEXT(R2R_DAC, name, p_VIN, p_R, p_N)
#endif /* NLD_R2R_DAC_H_ */
diff --git a/src/lib/netlist/devices/nld_system.cpp b/src/lib/netlist/devices/nld_system.cpp
index b4483b84ad7..8d8b090c5d0 100644
--- a/src/lib/netlist/devices/nld_system.cpp
+++ b/src/lib/netlist/devices/nld_system.cpp
@@ -47,7 +47,7 @@ namespace devices
NETLIB_UPDATE(extclock)
{
- m_Q.push((m_cnt & 1) ^ 1, m_inc[m_cnt] + m_off);
+ m_Q.push((m_cnt & 1) ^ 1, m_inc[m_cnt] + m_off());
m_off = netlist_time::zero();
if (++m_cnt >= m_size)
m_cnt = 0;
diff --git a/src/lib/netlist/devices/nlid_cmos.h b/src/lib/netlist/devices/nlid_cmos.h
deleted file mode 100644
index 03e6e9dd01d..00000000000
--- a/src/lib/netlist/devices/nlid_cmos.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// license:GPL-2.0+
-// copyright-holders:Couriersud
-/*
- * nld_cmos.h
- *
- */
-
-#ifndef NLID_CMOS_H_
-#define NLID_CMOS_H_
-
-#include "netlist/nl_base.h"
-#include "netlist/nl_setup.h"
-
-namespace netlist
-{
-namespace devices
-{
- // FIXME: this needs to be removed
- NETLIB_OBJECT(vdd_vss)
- {
- NETLIB_CONSTRUCTOR(vdd_vss)
- , m_vdd(*this, "VDD")
- , m_vss(*this, "VSS")
- {
- }
-
- NETLIB_UPDATEI() {}
- NETLIB_RESETI() {}
-
- public:
- nl_fptype vdd() { return m_vdd(); }
- nl_fptype vss() { return m_vss(); }
-
- analog_input_t m_vdd;
- analog_input_t m_vss;
- };
-
-} //namespace devices
-} // namespace netlist
-
-#endif /* NLID_CMOS_H_ */
diff --git a/src/lib/netlist/devices/nlid_proxy.cpp b/src/lib/netlist/devices/nlid_proxy.cpp
index 92db2af4d9b..68af102232b 100644
--- a/src/lib/netlist/devices/nlid_proxy.cpp
+++ b/src/lib/netlist/devices/nlid_proxy.cpp
@@ -39,9 +39,9 @@ namespace netlist
if (tp_ct && tp_cn)
{
if (tp_ct && !tp_ct->is_analog())
- plib::pthrow<nl_exception>(plib::pfmt("Not an analog terminal: {1}")(tp_ct->name()));
+ throw nl_exception(plib::pfmt("Not an analog terminal: {1}")(tp_ct->name()));
if (tp_cn && !tp_cn->is_analog())
- plib::pthrow<nl_exception>(plib::pfmt("Not an analog terminal: {1}")(tp_cn->name()));
+ throw nl_exception(plib::pfmt("Not an analog terminal: {1}")(tp_cn->name()));
auto tp_t = static_cast<analog_t* >(tp_ct);
auto tn_t = static_cast<analog_t *>(tp_cn);
diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h
index fcba83f3a2e..ce9970df81e 100644
--- a/src/lib/netlist/devices/nlid_system.h
+++ b/src/lib/netlist/devices/nlid_system.h
@@ -84,6 +84,8 @@ namespace devices
, m_feedback(*this, "FB")
, m_Q(*this, "Q")
, m_freq(*this, "FREQ", nlconst::magic(7159000.0 * 5.0))
+ , m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)")
+ , m_supply(*this)
{
m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two()));
@@ -107,7 +109,10 @@ namespace devices
param_fp_t m_freq;
netlist_time m_inc;
- };
+
+ param_model_t m_FAMILY;
+ NETLIB_NAME(power_pins) m_supply;
+};
// -----------------------------------------------------------------------------
// varclock
@@ -174,8 +179,6 @@ namespace devices
netlist_time::mult_type total = 0;
for (unsigned i=0; i<m_size; i++)
{
- // FIXME: use pstonum_ne
- //pati[i] = plib::pstonum<decltype(pati[i])>(pat[i]);
pati[i] = plib::pstonum<std::int64_t>(pat[i]);
total += pati[i];
}
@@ -230,7 +233,11 @@ namespace devices
NETLIB_UPDATEI() { }
NETLIB_RESETI() { m_Q.initial(0); }
- NETLIB_UPDATE_PARAMI() { m_Q.push(m_IN() & 1, netlist_time::from_nsec(1)); }
+ NETLIB_UPDATE_PARAMI()
+ {
+ //printf("%s %d\n", name().c_str(), m_IN());
+ m_Q.push(m_IN() & 1, netlist_time::from_nsec(1));
+ }
private:
logic_output_t m_Q;
@@ -335,7 +342,6 @@ namespace devices
private:
analog::NETLIB_NAME(twoterm) m_RIN;
- // Fixme: only works if the device is time-stepped - need to rework
analog::NETLIB_NAME(twoterm) m_ROUT;
analog_input_t m_I;
analog_output_t m_Q;
@@ -346,8 +352,6 @@ namespace devices
// -----------------------------------------------------------------------------
// nld_function
- //
- // FIXME: Currently a proof of concept to get congo bongo working
// ----------------------------------------------------------------------------- */
NETLIB_OBJECT(function)
@@ -428,7 +432,7 @@ namespace devices
const nl_fptype R = state ? m_RON() : m_ROFF();
// FIXME: We only need to update the net first if this is a time stepping net
- m_R.update();
+ m_R.solve_now();
m_R.set_R(R);
m_R.solve_later();
}
diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp
index 362784aec87..b213faea082 100644
--- a/src/lib/netlist/devices/nlid_truthtable.cpp
+++ b/src/lib/netlist/devices/nlid_truthtable.cpp
@@ -81,8 +81,8 @@ namespace devices
return ret;
}
- static constexpr const pbitset all_bits() noexcept { return pbitset(~static_cast<T>(0)); }
- static constexpr const pbitset no_bits() noexcept{ return pbitset(static_cast<T>(0)); }
+ static constexpr pbitset all_bits() noexcept { return pbitset(~static_cast<T>(0)); }
+ static constexpr pbitset no_bits() noexcept{ return pbitset(static_cast<T>(0)); }
private:
T m_bs;
};
@@ -162,7 +162,7 @@ namespace devices
void parseline(unsigned cur, std::vector<pstring> list,
tt_bitset state, std::uint_least64_t val, std::vector<uint_least8_t> &timing_index);
- tt_bitset calculate_ignored_inputs(tt_bitset i) const;
+ tt_bitset calculate_ignored_inputs(tt_bitset state) const;
unsigned m_NO;
unsigned m_NI;
@@ -264,7 +264,7 @@ namespace devices
m_family_desc = anetlist.setup().family_from_model(m_family_name);
if (m_family_desc == nullptr)
- plib::pthrow<nl_exception>("family description not found for {1}", m_family_name);
+ throw nl_exception("family description not found for {1}", m_family_name);
return pool.make_unique<tt_type>(anetlist, name, *m_family_desc, *m_ttbl, m_desc);
}
@@ -372,7 +372,7 @@ void truthtable_parser::parseline(unsigned cur, std::vector<pstring> list,
{
// cutoff previous inputs and outputs for ignore
if (m_out_state[nstate] != m_out_state.mask() && m_out_state[nstate] != val)
- plib::pthrow<nl_exception>(plib::pfmt("Error in truthtable: State {1:04} already set, {2} != {3}\n")
+ throw nl_exception(plib::pfmt("Error in truthtable: State {1:04} already set, {2} != {3}\n")
.x(nstate.as_uint())(m_out_state[nstate])(val) );
m_out_state.set(nstate, val);
for (std::size_t j=0; j<m_NO; j++)
@@ -468,7 +468,7 @@ void truthtable_parser::parse(const std::vector<pstring> &truthtable)
for (size_t i=0; i<m_size; i++)
{
if (m_out_state[i] == m_out_state.mask())
- plib::pthrow<nl_exception>(plib::pfmt("truthtable: found element not set {1}\n").x(i) );
+ throw nl_exception(plib::pfmt("truthtable: found element not set {1}\n").x(i) );
m_out_state.set(i, m_out_state[i] | (ign[i] << m_NO));
}
}
diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h
index 2677ce7433a..a8143f909a8 100644
--- a/src/lib/netlist/devices/nlid_truthtable.h
+++ b/src/lib/netlist/devices/nlid_truthtable.h
@@ -142,7 +142,7 @@ namespace devices
template<bool doOUT>
void process() noexcept
{
- netlist_time mt(netlist_time::zero());
+ netlist_time_ext mt(netlist_time_ext::zero());
type_t nstate(0);
type_t ign(m_ign);
diff --git a/src/lib/netlist/examples/7400_astable.c b/src/lib/netlist/examples/7400_astable.c
index 07748a0816a..d20ededb6f7 100644
--- a/src/lib/netlist/examples/7400_astable.c
+++ b/src/lib/netlist/examples/7400_astable.c
@@ -9,27 +9,27 @@
NETLIST_START(7400_astable)
- /*
- * Astable multivibrator using two 7400 gates (or inverters)
- *
- */
-
- /* Standard stuff */
-
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-5)
-
- // astable NAND Multivibrator ==> f ~ 1.0 / (3 * R * C)
- RES(R1, 4700)
- CAP(C1, 0.22e-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)
-
- LOG(logC12, C1.2)
- LOG(logn1Q, n1.Q)
- LOG(logn2Q, n2.Q)
+ /*
+ * Astable multivibrator using two 7400 gates (or inverters)
+ *
+ */
+
+ /* Standard stuff */
+
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-5)
+
+ // astable NAND Multivibrator ==> f ~ 1.0 / (3 * R * C)
+ RES(R1, 4700)
+ CAP(C1, 0.22e-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)
+
+ LOG(logC12, C1.2)
+ LOG(logn1Q, n1.Q)
+ LOG(logn2Q, n2.Q)
NETLIST_END()
diff --git a/src/lib/netlist/examples/74123_mstable.c b/src/lib/netlist/examples/74123_mstable.c
index aa21f4fe215..38e3f5f2072 100644
--- a/src/lib/netlist/examples/74123_mstable.c
+++ b/src/lib/netlist/examples/74123_mstable.c
@@ -9,39 +9,39 @@
NETLIST_START(74123_mstable)
- /*
- * Monoflog
- *
- */
+ /*
+ * Monoflog
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
+ SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5) // 5V
+ ANALOG_INPUT(V5, 5) // 5V
- /* Wiring up the 74123 */
+ /* Wiring up the 74123 */
- CLOCK(clk, 50)
- TTL_74123(mf)
+ CLOCK(clk, 50)
+ TTL_74123(mf)
- RES(R, 10000)
- CAP(C, 1e-6)
+ RES(R, 10000)
+ CAP(C, 1e-6)
- NET_C(GND, mf.GND)
- NET_C(V5, mf.VCC)
+ NET_C(GND, mf.GND)
+ NET_C(V5, mf.VCC)
- NET_C(C.1, mf.C)
- NET_C(mf.C, GND)
- NET_C(C.2, mf.RC, R.2)
- NET_C(R.1, V5)
+ NET_C(C.1, mf.C)
+ NET_C(mf.C, GND)
+ NET_C(C.2, mf.RC, R.2)
+ NET_C(R.1, V5)
- NET_C(mf.CLRQ, V5)
- NET_C(mf.B, V5)
- NET_C(mf.A, clk.Q)
+ NET_C(mf.CLRQ, V5)
+ NET_C(mf.B, V5)
+ NET_C(mf.A, clk.Q)
- LOG(log_C, C.2)
- LOG(log_Q, mf.Q)
- LOG(log_X, clk.Q)
+ LOG(log_C, C.2)
+ LOG(log_Q, mf.Q)
+ LOG(log_X, clk.Q)
NETLIST_END()
diff --git a/src/lib/netlist/examples/7414.cpp b/src/lib/netlist/examples/7414.cpp
index 0fcfde9a7f4..e7c01ce85d3 100644
--- a/src/lib/netlist/examples/7414.cpp
+++ b/src/lib/netlist/examples/7414.cpp
@@ -9,17 +9,17 @@
NETLIST_START(7414_astable)
- /*
- * Simple oscillator with 74LS14
- *
- * ./nltool -f nl_examples/7414.cpp -l C37.1 -l U4A1.Q
- *
- */
+ /*
+ * Simple oscillator with 74LS14
+ *
+ * ./nltool -f nl_examples/7414.cpp -l C37.1 -l U4A1.Q
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-8)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-8)
TTL_74LS14_GATE(U4A1)
//TTL_7404_GATE(U4A1)
diff --git a/src/lib/netlist/examples/9602_mstable.c b/src/lib/netlist/examples/9602_mstable.c
index 8e482c8dfb3..164241886b9 100644
--- a/src/lib/netlist/examples/9602_mstable.c
+++ b/src/lib/netlist/examples/9602_mstable.c
@@ -9,45 +9,45 @@
NETLIST_START(74123_mstable)
- /*
- * Monoflog
- *
- */
+ /*
+ * Monoflog
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
+ SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5) // 5V
+ ANALOG_INPUT(V5, 5) // 5V
- /* Wiring up the 74123 */
+ /* Wiring up the 74123 */
- CLOCK(clk, 50)
- TTL_9602_DIP(mf)
+ CLOCK(clk, 50)
+ TTL_9602_DIP(mf)
- RES(R, 10000)
- CAP(C, 1e-6)
+ RES(R, 10000)
+ CAP(C, 1e-6)
- NET_C(GND, mf.8) //
- NET_C(V5, mf.16) //
+ NET_C(GND, mf.8) //
+ NET_C(V5, mf.16) //
- NET_C(C.1, mf.1)
- NET_C(mf.1, GND) // Test - can be removed
- NET_C(C.2, mf.2, R.2)
- NET_C(R.1, V5)
+ NET_C(C.1, mf.1)
+ NET_C(mf.1, GND) // Test - can be removed
+ NET_C(C.2, mf.2, R.2)
+ NET_C(R.1, V5)
- NET_C(mf.3, V5) // CLR
- NET_C(mf.4, GND) // B
- NET_C(mf.5, clk.Q) // A
+ NET_C(mf.3, V5) // CLR
+ NET_C(mf.4, GND) // B
+ NET_C(mf.5, clk.Q) // A
- LOG(logC, C.2)
- LOG(logQ, mf.6) //Q
- LOG(logX, clk.Q)
+ LOG(logC, C.2)
+ LOG(logQ, mf.6) //Q
+ LOG(logX, clk.Q)
- // avoid non connected inputs
+ // avoid non connected inputs
- NET_C(mf.11, V5)
- NET_C(mf.12, V5)
- NET_C(mf.13, V5)
+ NET_C(mf.11, V5)
+ NET_C(mf.12, V5)
+ NET_C(mf.13, V5)
NETLIST_END()
diff --git a/src/lib/netlist/examples/LM3900_test.cpp b/src/lib/netlist/examples/LM3900_test.cpp
index 0498b4d2f0b..32ceb066864 100644
--- a/src/lib/netlist/examples/LM3900_test.cpp
+++ b/src/lib/netlist/examples/LM3900_test.cpp
@@ -20,14 +20,14 @@
NETLIST_START(main)
- /* Standard stuff */
-
- //VARCLOCK(clk, "0.5 / pow(10, 1 + T * 4)")
- //CLOCK(clk, 1000)
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-10)
- PARAM(Solver.NR_LOOPS, 300)
- PARAM(Solver.DYNAMIC_TS, 1)
+ /* Standard stuff */
+
+ //VARCLOCK(clk, "0.5 / pow(10, 1 + T * 4)")
+ //CLOCK(clk, 1000)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-10)
+ PARAM(Solver.NR_LOOPS, 300)
+ PARAM(Solver.DYNAMIC_TS, 1)
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-7)
VS(vs, 0)
@@ -57,47 +57,47 @@ NETLIST_START(main)
PARAM(vs.R, 0.1)
ALIAS(clk, vs.1)
NET_C(vs.2, GND)
- ANALOG_INPUT(V9, 9)
- ANALOG_INPUT(V12, 12)
- ANALOG_INPUT(VM12, -12)
+ ANALOG_INPUT(V9, 9)
+ ANALOG_INPUT(V12, 12)
+ ANALOG_INPUT(VM12, -12)
- //OPAMP(op, OPAMP_TEST)
+ //OPAMP(op, OPAMP_TEST)
LM3900(op)
- NET_C(op.GND, VM12)
- NET_C(op.VCC, V12)
+ NET_C(op.GND, VM12)
+ NET_C(op.VCC, V12)
- /* Opamp B wired as inverting amplifier connected to output of first opamp */
+ /* Opamp B wired as inverting amplifier connected to output of first opamp */
- RES(R1, 50)
- RES(RP, 500000) // Set to R2 * 2 if VPlus == VCC (see datasheet)
- RES(R2, 500000)
+ RES(R1, 50)
+ RES(RP, 500000) // Set to R2 * 2 if VPlus == VCC (see datasheet)
+ RES(R2, 500000)
- NET_C(op.PLUS, RP.1)
+ NET_C(op.PLUS, RP.1)
//NET_C(RP.2, V9)
NET_C(RP.2, GND)
//NET_C(RP.2, V12)
- NET_C(op.MINUS, R2.2)
- NET_C(op.MINUS, R1.2)
+ NET_C(op.MINUS, R2.2)
+ NET_C(op.MINUS, R1.2)
CAP(C, 10e-6)
NET_C(clk, C.1)
- NET_C(C.2, R1.1)
- NET_C(op.OUT, R2.1)
+ NET_C(C.2, R1.1)
+ NET_C(op.OUT, R2.1)
CAP(CL, 10.0e-6)
- RES(RL, 2000)
- NET_C(RL.2, GND)
- NET_C(RL.1, CL.2)
+ RES(RL, 2000)
+ NET_C(RL.2, GND)
+ NET_C(RL.1, CL.2)
NET_C(CL.1, op.OUT)
AFUNC(f, 1, "A0 * 1000")
NET_C(f.A0, RL.1)
#if 1
- LOG(log_Y, R1.1)
- LOG(log_Z, f)
+ LOG(log_Y, R1.1)
+ LOG(log_Z, f)
#endif
NETLIST_END()
diff --git a/src/lib/netlist/examples/bjt.c b/src/lib/netlist/examples/bjt.c
index 7222ced4445..f28c070910a 100644
--- a/src/lib/netlist/examples/bjt.c
+++ b/src/lib/netlist/examples/bjt.c
@@ -9,38 +9,38 @@
#include "netlist/devices/net_lib.h"
NETLIST_START(bjt)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5)
- ANALOG_INPUT(V3, 3.5)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V3, 3.5)
- /* NPN - example */
+ /* NPN - example */
- QBJT_SW(Q, "BC237B")
- RES(RB, 1000)
- RES(RC, 1000)
+ QBJT_SW(Q, "BC237B")
+ RES(RB, 1000)
+ RES(RC, 1000)
- NET_C(RC.1, V5)
- NET_C(RC.2, Q.C)
- NET_C(RB.1, clk)
- NET_C(RB.2, Q.B)
- NET_C(Q.E, GND)
+ NET_C(RC.1, V5)
+ NET_C(RC.2, Q.C)
+ NET_C(RB.1, clk)
+ NET_C(RB.2, Q.B)
+ NET_C(Q.E, GND)
- /* PNP - example */
+ /* PNP - example */
- QBJT_SW(Q1, "BC556B")
- RES(RB1, 1000)
- RES(RC1, 1000)
+ QBJT_SW(Q1, "BC556B")
+ RES(RB1, 1000)
+ RES(RC1, 1000)
- NET_C(RC1.1, GND)
- NET_C(RC1.2, Q1.C)
- NET_C(RB1.1, clk)
- NET_C(RB1.2, Q1.B)
- NET_C(Q1.E, V3)
+ NET_C(RC1.1, GND)
+ NET_C(RC1.2, Q1.C)
+ NET_C(RB1.1, clk)
+ NET_C(RB1.2, Q1.B)
+ NET_C(Q1.E, V3)
- LOG(logB, Q.B)
- LOG(logC, Q.C)
+ LOG(logB, Q.B)
+ LOG(logC, Q.C)
NETLIST_END()
diff --git a/src/lib/netlist/examples/bjt_eb.c b/src/lib/netlist/examples/bjt_eb.c
index f21735c36ec..a42def2df3b 100644
--- a/src/lib/netlist/examples/bjt_eb.c
+++ b/src/lib/netlist/examples/bjt_eb.c
@@ -10,35 +10,35 @@
#include "netlist/analog/nld_twoterm.h"
NETLIST_START(bjt)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 10000) // 10000 Hz
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-6)
- PARAM(Solver.RESCHED_LOOPS, 30)
- ANALOG_INPUT(V5, 5)
- ANALOG_INPUT(V3, 3.5)
+ CLOCK(clk, 10000) // 10000 Hz
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+ PARAM(Solver.RESCHED_LOOPS, 30)
+ ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V3, 3.5)
- /* NPN - example */
+ /* NPN - example */
- QBJT_EB(Q, "BC237B")
- RES(RB, 1000)
- RES(RC, 1000)
+ QBJT_EB(Q, "BC237B")
+ RES(RB, 1000)
+ RES(RC, 1000)
- NET_C(RC.1, V5)
- NET_C(RC.2, Q.C)
- NET_C(RB.1, clk)
- //NET_C(RB.1, V3)
- NET_C(RB.2, Q.B)
- NET_C(Q.E, GND)
+ NET_C(RC.1, V5)
+ NET_C(RC.2, Q.C)
+ NET_C(RB.1, clk)
+ //NET_C(RB.1, V3)
+ NET_C(RB.2, Q.B)
+ NET_C(Q.E, GND)
- // put some load on Q.C
+ // put some load on Q.C
- RES(RCE, 150000)
- NET_C(RCE.1, Q.C)
- NET_C(RCE.2, GND)
+ RES(RCE, 150000)
+ NET_C(RCE.1, Q.C)
+ NET_C(RCE.2, GND)
- //LOG(logB, Q.B)
- //LOG(logC, Q.C)
+ //LOG(logB, Q.B)
+ //LOG(logC, Q.C)
NETLIST_END()
diff --git a/src/lib/netlist/examples/bjt_eb_pnp.c b/src/lib/netlist/examples/bjt_eb_pnp.c
index 10169b6bd3f..7ca43466300 100644
--- a/src/lib/netlist/examples/bjt_eb_pnp.c
+++ b/src/lib/netlist/examples/bjt_eb_pnp.c
@@ -9,27 +9,27 @@
#include "netlist/devices/net_lib.h"
NETLIST_START(bjt)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5)
- ANALOG_INPUT(V3, 3.5)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V3, 3.5)
- /* PNP - example */
+ /* PNP - example */
- QBJT_EB(Q1, "BC556B")
- RES(RB1, 1000)
- RES(RC1, 1000)
+ QBJT_EB(Q1, "BC556B")
+ RES(RB1, 1000)
+ RES(RC1, 1000)
- NET_C(RC1.1, GND)
- NET_C(RC1.2, Q1.C)
- NET_C(RB1.1, clk)
- NET_C(RB1.2, Q1.B)
- NET_C(Q1.E, V3)
+ NET_C(RC1.1, GND)
+ NET_C(RC1.2, Q1.C)
+ NET_C(RB1.1, clk)
+ NET_C(RB1.2, Q1.B)
+ NET_C(Q1.E, V3)
- LOG(logA, clk)
- LOG(logB, Q1.B)
- LOG(logC, Q1.C)
+ LOG(logA, clk)
+ LOG(logB, Q1.B)
+ LOG(logC, Q1.C)
NETLIST_END()
diff --git a/src/lib/netlist/examples/breakout.c b/src/lib/netlist/examples/breakout.c
index 591ffaf3414..c5919af5e5a 100644
--- a/src/lib/netlist/examples/breakout.c
+++ b/src/lib/netlist/examples/breakout.c
@@ -9,45 +9,45 @@
//2 555 timers
static Astable555Desc b2_555_desc(OHM(560.0), M_OHM(1.8), U_FARAD(0.1));
-static Mono555Desc c9_555_desc(OHM(47.0), U_FARAD(1.0)); // R33, C21
+static Mono555Desc c9_555_desc(OHM(47.0), U_FARAD(1.0)); // R33, C21
//check these values
//static Paddle1HorizontalDesc pad1_desc(15047.0, 47.0, &c9_555_desc);
static CapacitorDesc c32_desc(U_FARAD(0.1));
-static CapacitorDesc c36_desc(N_FARAD(1.0)); //0.001uF = 1nF
+static CapacitorDesc c36_desc(N_FARAD(1.0)); //0.001uF = 1nF
static CapacitorDesc c37_desc(P_FARAD(330.0));
static BufferDesc pad_en_buf_desc(DELAY_NS(15.0), DELAY_NS(15.0)); // Prevents 12ns glitch on PAD_EN_n signal from resetting C9. TODO: is this accurate?
#if 0
static VIDEO_DESC( breakout )
- VIDEO_RESISTANCE(1, K_OHM(0.0))
- VIDEO_RESISTANCE(2, K_OHM(3.9))
- VIDEO_RESISTANCE(3, K_OHM(3.9))
- VIDEO_RESISTANCE(4, K_OHM(3.9))
- VIDEO_RESISTANCE(5, K_OHM(3.9))
- VIDEO_RESISTANCE(6, K_OHM(3.9))
- //VIDEO_RESISTANCE(Video::HBLANK_PIN, K_OHM(0.0))
- VIDEO_ORIENTATION(ROTATE_90)
- VIDEO_CONTRAST(4.0)
-
- // Values guessed based on screenshots. TODO: Make more accurate
- // X, Y, W, H, R, G, B
- VIDEO_OVERLAY( 15.570e-6, 0.0, 1.911e-6, -1.0, 0.80, 0.15, 0.05 ) // Red Bricks
- VIDEO_OVERLAY( 17.481e-6, 0.0, 1.956e-6, -1.0, 0.95, 0.65, 0.05 ) // Amber Bricks
- VIDEO_OVERLAY( 19.437e-6, 0.0, 1.956e-6, -1.0, 0.05, 0.65, 0.25 ) // Green Bricks
- VIDEO_OVERLAY( 21.393e-6, 0.0, 1.955e-6, -1.0, 0.95, 0.95, 0.20 ) // Yellow Bricks
- VIDEO_OVERLAY( 51.345e-6, 0.0, 1.956e-6, -1.0, 0.05, 0.65, 0.95 ) // Blue Paddle
-
- // TODO: Different overlays for cocktail cabinet
+ VIDEO_RESISTANCE(1, K_OHM(0.0))
+ VIDEO_RESISTANCE(2, K_OHM(3.9))
+ VIDEO_RESISTANCE(3, K_OHM(3.9))
+ VIDEO_RESISTANCE(4, K_OHM(3.9))
+ VIDEO_RESISTANCE(5, K_OHM(3.9))
+ VIDEO_RESISTANCE(6, K_OHM(3.9))
+ //VIDEO_RESISTANCE(Video::HBLANK_PIN, K_OHM(0.0))
+ VIDEO_ORIENTATION(ROTATE_90)
+ VIDEO_CONTRAST(4.0)
+
+ // Values guessed based on screenshots. TODO: Make more accurate
+ // X, Y, W, H, R, G, B
+ VIDEO_OVERLAY( 15.570e-6, 0.0, 1.911e-6, -1.0, 0.80, 0.15, 0.05 ) // Red Bricks
+ VIDEO_OVERLAY( 17.481e-6, 0.0, 1.956e-6, -1.0, 0.95, 0.65, 0.05 ) // Amber Bricks
+ VIDEO_OVERLAY( 19.437e-6, 0.0, 1.956e-6, -1.0, 0.05, 0.65, 0.25 ) // Green Bricks
+ VIDEO_OVERLAY( 21.393e-6, 0.0, 1.955e-6, -1.0, 0.95, 0.95, 0.20 ) // Yellow Bricks
+ VIDEO_OVERLAY( 51.345e-6, 0.0, 1.956e-6, -1.0, 0.05, 0.65, 0.95 ) // Blue Paddle
+
+ // TODO: Different overlays for cocktail cabinet
VIDEO_DESC_END
static AUDIO_DESC( breakout )
- AUDIO_RESISTANCE(1, K_OHM(47.0))
- AUDIO_RESISTANCE(2, K_OHM(47.0))
- AUDIO_RESISTANCE(3, K_OHM(47.0))
- AUDIO_RESISTANCE(4, K_OHM(47.0))
- AUDIO_GAIN(3.0)
+ AUDIO_RESISTANCE(1, K_OHM(47.0))
+ AUDIO_RESISTANCE(2, K_OHM(47.0))
+ AUDIO_RESISTANCE(3, K_OHM(47.0))
+ AUDIO_RESISTANCE(4, K_OHM(47.0))
+ AUDIO_GAIN(3.0)
VIDEO_DESC_END
#endif
@@ -63,26 +63,26 @@ static Dipswitch53137Desc dipswitch1_desc("bonus_credit", "Bonus Credit", 3, "No
//static DipswitchDesc dipswitch4_desc("ball_count", "Ball Count", 0, "3", "5");
CIRCUIT_LAYOUT( breakout )
- CHIP("S1", 53137, &dipswitch1_desc)
+ CHIP("S1", 53137, &dipswitch1_desc)
CHIP("S2", DIPSWITCH, &dipswitch2_desc)
CHIP("S3", DIPSWITCH, &dipswitch3_desc)
CHIP("S4", DIPSWITCH, &dipswitch4_desc)
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-7) // works and is sufficient
- //CHIP("CLOCK", CLOCK_14_318_MHZ)
- MAINCLOCK(Y1, 14318000.0)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-7) // works and is sufficient
+ //CHIP("CLOCK", CLOCK_14_318_MHZ)
+ MAINCLOCK(Y1, 14318000.0)
- ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V5, 5)
#define VCC "V5", Q
#define GND "GND", Q
- //CHIP("Y1", CLOCK_14_318_MHZ) //Y1
+ //CHIP("Y1", CLOCK_14_318_MHZ) //Y1
CHIP_CAPACITOR(C32, &c32_desc)
CHIP_CAPACITOR(C36, &c36_desc)
- CHIP_CAPACITOR(C37, &c37_desc)
- CHIP("PAD_EN_BUF", BUFFER, &pad_en_buf_desc)
+ CHIP_CAPACITOR(C37, &c37_desc)
+ CHIP("PAD_EN_BUF", BUFFER, &pad_en_buf_desc)
CHIP("A3", 7474)
CHIP("A4", 7408)
@@ -91,7 +91,7 @@ CIRCUIT_LAYOUT( breakout )
CHIP_9602_Mono(A7, &a7_desc)
CHIP_9602_Mono(A8, &a8_desc)
- CHIP_555_Astable(B2, &b2_555_desc)
+ CHIP_555_Astable(B2, &b2_555_desc)
CHIP("B3", 7402)
CHIP("B4", 9316)
CHIP("B5", 74193)
@@ -107,7 +107,7 @@ CIRCUIT_LAYOUT( breakout )
CHIP("C6", 7486)
CHIP("C7", 9316)
CHIP("C8", 9316)
- CHIP_555_Mono(C9, &c9_555_desc)
+ CHIP_555_Mono(C9, &c9_555_desc)
CHIP("D2", 7432)
CHIP("D3", 7474)
@@ -116,7 +116,7 @@ CIRCUIT_LAYOUT( breakout )
CHIP("D6", 7408)
CHIP("D7", 7411)
CHIP("D8", 7400)
-// CHIP("D9", 4016) //quad bilateral switch
+// CHIP("D9", 4016) //quad bilateral switch
CHIP("E1", 7404)
CHIP("E2", 7486)
@@ -144,7 +144,7 @@ CIRCUIT_LAYOUT( breakout )
CHIP("H4", 7400)
CHIP("H5", 9312)
CHIP("H6", 9310)
- CHIP("H7", 7408) //sometimes looks like N7 on schematic
+ CHIP("H7", 7408) //sometimes looks like N7 on schematic
CHIP("H8", 7474)
CHIP("H9", 7474)
@@ -165,18 +165,18 @@ CIRCUIT_LAYOUT( breakout )
CHIP("K5", 9312)
CHIP("K6", 9310)
CHIP("K7", 7486)
- CHIP("K8", 7474) //TODO: one more than bom?
+ CHIP("K8", 7474) //TODO: one more than bom?
CHIP("K9", 74107)
CHIP("L1", 9316)
CHIP("L2", 7486)
- CHIP("L3", 82S16) //RAM
+ CHIP("L3", 82S16) //RAM
CHIP("L4", 7411)
CHIP("L5", 9312)
CHIP("L6", 9310)
CHIP("L7", 7486)
CHIP("L8", 74193)
- CHIP("L9", 7400) //TODO: 1 more chip than on bom?
+ CHIP("L9", 7400) //TODO: 1 more chip than on bom?
CHIP("M1", 9316)
CHIP("M2", 7483)
@@ -193,232 +193,232 @@ CIRCUIT_LAYOUT( breakout )
CHIP("N4", 7411)
CHIP("N5", 9312)
CHIP("N6", 9310)
- CHIP("N7", 7408) //sometimes looks like H7 on schematic
+ CHIP("N7", 7408) //sometimes looks like H7 on schematic
CHIP_9602_Mono(N8, &n8_desc)
CHIP("N9", 74192)
- //LM380 //speaker amplifier
- //LM323 //regulator
+ //LM380 //speaker amplifier
+ //LM323 //regulator
// CHIP("CREDIT_LIGHT1", LAMP)
// CHIP("CREDIT_LIGHT2", LAMP)
// CHIP("SERVE_LIGHT", LAMP)
- CHIP("PAD1", PADDLE1_HORIZONTAL_INPUT, &pad1_desc)
- PADDLE_CONNECTION("PAD1", "C9")
+ CHIP("PAD1", PADDLE1_HORIZONTAL_INPUT, &pad1_desc)
+ PADDLE_CONNECTION("PAD1", "C9")
- CHIP_LATCH(LATCH)
- CHIP("COIN1", COIN_INPUT)
+ CHIP_LATCH(LATCH)
+ CHIP("COIN1", COIN_INPUT)
- //CHIP("COIN2", COIN_INPUT)
+ //CHIP("COIN2", COIN_INPUT)
- CHIP("START", START_INPUT)
+ CHIP("START", START_INPUT)
- CHIP("SERVE", BUTTONS1_INPUT)
+ CHIP("SERVE", BUTTONS1_INPUT)
- //TODO: coin2 and start 2
+ //TODO: coin2 and start 2
- VIDEO(breakout)
- AUDIO(breakout)
+ VIDEO(breakout)
+ AUDIO(breakout)
#ifdef DEBUG
CHIP("LOG1", VCD_LOG, &vcd_log_desc)
#endif
//HSYNC and VSYNC
- #define H1_d "L1", 14
- #define H2_d "L1", 13
- #define H4_d "L1", 12
- #define H8_d "L1", 11
- #define H8_n "J2", 2
- #define H16_d "K1", 14
- #define H16_n "J2", 6
- #define H32_d "K1", 13
- #define H32_n "J2", 4
- #define H64_d "K1", 12
- #define H128_d "K1", 11
-
- #define V1_d "M1", 14
- #define V2_d "M1", 13
- #define V4_d "M1", 12
- #define V8_d "M1", 11
- #define V16_d "N1", 14
- #define V16_n "J2", 10
- #define V32_d "N1", 13
- #define V64_d "N1", 12
- #define V64I "H7", 11
- #define V64_n "M9", 10
- #define V128_d "N1", 11
-
- #define H1 "L2", 8
- #define H2 "L2", 11
- #define H4 "L2", 3
- #define H8 "L2", 6
- #define H16 "K2", 8
- #define H32 "K2", 11
- #define H64 "K2", 3
- #define H128 "K2", 6
+ #define H1_d "L1", 14
+ #define H2_d "L1", 13
+ #define H4_d "L1", 12
+ #define H8_d "L1", 11
+ #define H8_n "J2", 2
+ #define H16_d "K1", 14
+ #define H16_n "J2", 6
+ #define H32_d "K1", 13
+ #define H32_n "J2", 4
+ #define H64_d "K1", 12
+ #define H128_d "K1", 11
+
+ #define V1_d "M1", 14
+ #define V2_d "M1", 13
+ #define V4_d "M1", 12
+ #define V8_d "M1", 11
+ #define V16_d "N1", 14
+ #define V16_n "J2", 10
+ #define V32_d "N1", 13
+ #define V64_d "N1", 12
+ #define V64I "H7", 11
+ #define V64_n "M9", 10
+ #define V128_d "N1", 11
+
+ #define H1 "L2", 8
+ #define H2 "L2", 11
+ #define H4 "L2", 3
+ #define H8 "L2", 6
+ #define H16 "K2", 8
+ #define H32 "K2", 11
+ #define H64 "K2", 3
+ #define H128 "K2", 6
//#define V1
- #define V2 "M3", 3
- #define V4 "M3", 6
- #define V8 "M3", 11
- #define V16 "N3", 8
- #define V32 "N3", 3
- #define V64 "N3", 6
- #define V128 "N3", 11
-
- #define HSYNC "J1", 2
- #define HSYNC_n "J1", 3
- #define VSYNC "J1", 7
- #define VSYNC_n "J1", 6
- #define PSYNC "J1", 11
- #define PSYNC_n "J1", 10
- #define BSYNC "J1", 15
- #define BSYNC_n "J1", 14
-
- #define BALL "D7", 6
+ #define V2 "M3", 3
+ #define V4 "M3", 6
+ #define V8 "M3", 11
+ #define V16 "N3", 8
+ #define V32 "N3", 3
+ #define V64 "N3", 6
+ #define V128 "N3", 11
+
+ #define HSYNC "J1", 2
+ #define HSYNC_n "J1", 3
+ #define VSYNC "J1", 7
+ #define VSYNC_n "J1", 6
+ #define PSYNC "J1", 11
+ #define PSYNC_n "J1", 10
+ #define BSYNC "J1", 15
+ #define BSYNC_n "J1", 14
+
+ #define BALL "D7", 6
#define BALL_DISPLAY "A4", 6
- #define PLAYFIELD "H4", 3
- #define SCORE "D3", 5
- #define VERT_TRIG_n "H1", 8
+ #define PLAYFIELD "H4", 3
+ #define SCORE "D3", 5
+ #define VERT_TRIG_n "H1", 8
- #define CLOCK "H1", 11
- #define SCLOCK "K1", 15
- #define CKBH "F1", 13
+ #define CLOCK "H1", 11
+ #define SCLOCK "K1", 15
+ #define CKBH "F1", 13
- #define PAD_n "K3", 8
- #define PAD_EN_n "C2", 8
+ #define PAD_n "K3", 8
+ #define PAD_EN_n "C2", 8
//#define P VCC
#define P "V5", Q
- #define COIN "L9", 6
- #define COIN1_n "F8", 5
- #define COIN2_n "H9", 5
- #define CREDIT_1_OR_2 "L9", 3
- #define CREDIT_1_OR_2_n "F9", 8
- #define CREDIT2 "F9", 6
- #define CREDIT2_n "M8", 8
- #define CR_START1 "E8", 5
- #define CR_START1_n "E8", 6 //Schematic shows E8.6 as positive CR_START1, but this can't be right?
- #define CR_START2 "E8", 9
- #define CR_START2_n "E8", 8
- #define CSW1 "F9", 12
- #define CSW2 "F9", 2
-
- #define P2_CONDITIONAL "H1", 3
- #define P2_CONDITIONAL_dash "H7", 8
- #define PLAYER_2 "B4", 14
- #define PLAYER_2_n "M9", 8
-
- #define START_GAME "D8", 6
- #define START_GAME1_n "M9", 4
- #define START_GAME_n "M9", 6
-
- #define BG1_n "K8", 9
- #define BG1 "K8", 8
- #define BG2_n "K8", 5
- #define BG2 "K8", 6
-
- #define FREE_GAME_TONE "N7", 3
- #define BONUS_COIN "L9", 11
+ #define COIN "L9", 6
+ #define COIN1_n "F8", 5
+ #define COIN2_n "H9", 5
+ #define CREDIT_1_OR_2 "L9", 3
+ #define CREDIT_1_OR_2_n "F9", 8
+ #define CREDIT2 "F9", 6
+ #define CREDIT2_n "M8", 8
+ #define CR_START1 "E8", 5
+ #define CR_START1_n "E8", 6 //Schematic shows E8.6 as positive CR_START1, but this can't be right?
+ #define CR_START2 "E8", 9
+ #define CR_START2_n "E8", 8
+ #define CSW1 "F9", 12
+ #define CSW2 "F9", 2
+
+ #define P2_CONDITIONAL "H1", 3
+ #define P2_CONDITIONAL_dash "H7", 8
+ #define PLAYER_2 "B4", 14
+ #define PLAYER_2_n "M9", 8
+
+ #define START_GAME "D8", 6
+ #define START_GAME1_n "M9", 4
+ #define START_GAME_n "M9", 6
+
+ #define BG1_n "K8", 9
+ #define BG1 "K8", 8
+ #define BG2_n "K8", 5
+ #define BG2 "K8", 6
+
+ #define FREE_GAME_TONE "N7", 3
+ #define BONUS_COIN "L9", 11
//#define Q "E9", 6
- #define LAT_Q "E9", 6
- #define Q_n "LATCH", 3
- #define SBD_n "D2", 11
+ #define LAT_Q "E9", 6
+ #define Q_n "LATCH", 3
+ #define SBD_n "D2", 11
- #define PLAY_CP "D2", 8
- #define PLGM2_n "F7", 7
- #define VB_HIT_n "A5", 6
+ #define PLAY_CP "D2", 8
+ #define PLGM2_n "F7", 7
+ #define VB_HIT_n "A5", 6
- #define SERVE_n "SERVE", 1
- #define SERVE_WAIT "A3", 9
+ #define SERVE_n "SERVE", 1
+ #define SERVE_WAIT "A3", 9
#define SERVE_WAIT_n "A3", 8
- #define BRICK_DISPLAY "E3", 1
- #define BRICK_HIT "E6", 5
- #define BRICK_HIT_n "E6", 6
-
- //#define EGL "A4", 3
- #define EGL "C37" , 2
- #define EGL_n "C5", 2
-
- #define RAM_PLAYER1 "E7", 4
- #define A1 "H6", 14
- #define B1 "H6", 13
- #define C1 "H6", 12
- #define D1 "H6", 11
- #define E1 "J6", 14
- #define F1 "J6", 13
- #define G1 "J6", 12
- #define H01 "J6", 11
- #define I1 "K6", 14
- #define J1 "K6", 13
- #define K1 "K6", 12
- #define L1 "K6", 11
- #define A2 "N6", 14
- #define B2 "N6", 13
- #define C2 "N6", 12
- #define D2 "N6", 11
- #define E2 "M6", 14
- #define F2 "M6", 13
- #define G2 "M6", 12
- #define H02 "M6", 11 //TODO: better name for these signals
- #define I2 "L6", 14
- #define J2 "L6", 13
- #define K2 "L6", 12
- #define L2 "L6", 11
-
- #define CX0 "C6", 11
- #define CX1 "C6", 6
- #define X0 "C5", 10
- #define X1 "B6", 3
- #define X2 "C6", 3
- #define Y0 "B6", 11
- #define Y1 "B6", 6
- #define Y2 "A6", 6
- #define DN "C4", 3
- #define PC "D4", 12
- #define PD "D4", 11
- #define SU_n "D5", 8
- #define V_SLOW "C5", 8
-
- #define PLNR "E3", 4
- #define SCI_n "H4", 6
- #define SFL_n "E9", 12 //score flash
- #define TOP_n "E9", 2
-
- #define BP_HIT_n "A5", 8
- #define BTB_HIT_n "C3", 3
-
- #define SET_BRICKS "D3", 9
+ #define BRICK_DISPLAY "E3", 1
+ #define BRICK_HIT "E6", 5
+ #define BRICK_HIT_n "E6", 6
+
+ //#define EGL "A4", 3
+ #define EGL "C37" , 2
+ #define EGL_n "C5", 2
+
+ #define RAM_PLAYER1 "E7", 4
+ #define A1 "H6", 14
+ #define B1 "H6", 13
+ #define C1 "H6", 12
+ #define D1 "H6", 11
+ #define E1 "J6", 14
+ #define F1 "J6", 13
+ #define G1 "J6", 12
+ #define H01 "J6", 11
+ #define I1 "K6", 14
+ #define J1 "K6", 13
+ #define K1 "K6", 12
+ #define L1 "K6", 11
+ #define A2 "N6", 14
+ #define B2 "N6", 13
+ #define C2 "N6", 12
+ #define D2 "N6", 11
+ #define E2 "M6", 14
+ #define F2 "M6", 13
+ #define G2 "M6", 12
+ #define H02 "M6", 11 //TODO: better name for these signals
+ #define I2 "L6", 14
+ #define J2 "L6", 13
+ #define K2 "L6", 12
+ #define L2 "L6", 11
+
+ #define CX0 "C6", 11
+ #define CX1 "C6", 6
+ #define X0 "C5", 10
+ #define X1 "B6", 3
+ #define X2 "C6", 3
+ #define Y0 "B6", 11
+ #define Y1 "B6", 6
+ #define Y2 "A6", 6
+ #define DN "C4", 3
+ #define PC "D4", 12
+ #define PD "D4", 11
+ #define SU_n "D5", 8
+ #define V_SLOW "C5", 8
+
+ #define PLNR "E3", 4
+ #define SCI_n "H4", 6
+ #define SFL_n "E9", 12 //score flash
+ #define TOP_n "E9", 2
+
+ #define BP_HIT_n "A5", 8
+ #define BTB_HIT_n "C3", 3
+
+ #define SET_BRICKS "D3", 9
#define SET_BRICKS_n "D3", 8
- #define BALL_A "B4", 13
- #define BALL_B "B4", 12
- #define BALL_C "B4", 11
+ #define BALL_A "B4", 13
+ #define BALL_B "B4", 12
+ #define BALL_C "B4", 11
- #define FPD1 "F3", 10
- #define FPD1_n "F3", 9
- #define FPD2 "F3", 6
- #define FPD2_n "F3", 7
+ #define FPD1 "F3", 10
+ #define FPD1_n "F3", 9
+ #define FPD2 "F3", 6
+ #define FPD2_n "F3", 7
- #define COUNT "N7", 11
- #define COUNT_1 "N7", 8
- #define COUNT_2 "N7", 6
+ #define COUNT "N7", 11
+ #define COUNT_1 "N7", 8
+ #define COUNT_2 "N7", 6
- #define ATTRACT "E6", 8
- #define ATTRACT_n "E6", 9
+ #define ATTRACT "E6", 8
+ #define ATTRACT_n "E6", 9
- #define BRICK_SOUND "B8", 14
- #define P_HIT_SOUND "B7", 12
+ #define BRICK_SOUND "B8", 14
+ #define P_HIT_SOUND "B7", 12
#define VB_HIT_SOUND "B7", 11
- #define LH_SIDE "J3", 13
- #define RH_SIDE "H2", 3
- #define TOP_BOUND "K4", 6
+ #define LH_SIDE "J3", 13
+ #define RH_SIDE "H2", 3
+ #define TOP_BOUND "K4", 6
// CONNECTION(CREDIT_1_OR_2, "CREDIT_LIGHT1", 1)
// CONNECTION(CREDIT2, "CREDIT_LIGHT2", 1)
@@ -1065,7 +1065,7 @@ CIRCUIT_LAYOUT( breakout )
//COIN2 circuit
//CONNECTION("COIN2", 1, "F9", 1)
- CONNECTION(GND, "F9", 1) //TODO: coin2 not implemented
+ CONNECTION(GND, "F9", 1) //TODO: coin2 not implemented
CONNECTION(CSW2, "F9", 3)
CONNECTION(CSW2, "H9", 10)
@@ -1132,10 +1132,10 @@ CIRCUIT_LAYOUT( breakout )
//TODO: hows this whole latch stuff work? what about Q_n going to COIN1_n and COIN2_n
CONNECTION(CREDIT_1_OR_2_n, "D8", 13)
CONNECTION(EGL, "D8", 12)
- CONNECTION("LATCH", 1, "D8", 11) //set
- CONNECTION("LATCH", 2, COIN1_n) //reset
- //CONNECTION("LATCH", 3, COIN2_n) //set //TODO: coin2 here
- CONNECTION( "LATCH", 3, "E9", 5) //output
+ CONNECTION("LATCH", 1, "D8", 11) //set
+ CONNECTION("LATCH", 2, COIN1_n) //reset
+ //CONNECTION("LATCH", 3, COIN2_n) //set //TODO: coin2 here
+ CONNECTION( "LATCH", 3, "E9", 5) //output
CONNECTION(LAT_Q, "D6", 1)
@@ -1441,21 +1441,21 @@ CIRCUIT_LAYOUT( breakout )
#ifdef DEBUG
- // RAM access
- /*CONNECTION("LOG1", 3, H4) //A
- CONNECTION("LOG1", 4, H8) //B
- CONNECTION("LOG1", 5, H16) //C
- CONNECTION("LOG1", 6, V32) //D
- CONNECTION("LOG1", 7, V64) //E
- CONNECTION("LOG1", 8, V128) //F
- CONNECTION("LOG1", 9, V16) //G
- CONNECTION("LOG1", 10, RAM_PLAYER1) //H
- CONNECTION("LOG1", 11, H32) //I
- CONNECTION("LOG1", 12, H128) //J
- CONNECTION("LOG1", 13, "H4", 8) //K
- CONNECTION("LOG1", 14, "E1", 4) //L
- CONNECTION("LOG1", 15, "F2", 12) //M
- CONNECTION("LOG1", 16, "L3", 6)*/ //N
+ // RAM access
+ /*CONNECTION("LOG1", 3, H4) //A
+ CONNECTION("LOG1", 4, H8) //B
+ CONNECTION("LOG1", 5, H16) //C
+ CONNECTION("LOG1", 6, V32) //D
+ CONNECTION("LOG1", 7, V64) //E
+ CONNECTION("LOG1", 8, V128) //F
+ CONNECTION("LOG1", 9, V16) //G
+ CONNECTION("LOG1", 10, RAM_PLAYER1) //H
+ CONNECTION("LOG1", 11, H32) //I
+ CONNECTION("LOG1", 12, H128) //J
+ CONNECTION("LOG1", 13, "H4", 8) //K
+ CONNECTION("LOG1", 14, "E1", 4) //L
+ CONNECTION("LOG1", 15, "F2", 12) //M
+ CONNECTION("LOG1", 16, "L3", 6)*/ //N
#endif
CIRCUIT_LAYOUT_END
diff --git a/src/lib/netlist/examples/cccs.c b/src/lib/netlist/examples/cccs.c
index a1244677d20..2c7833b19f3 100644
--- a/src/lib/netlist/examples/cccs.c
+++ b/src/lib/netlist/examples/cccs.c
@@ -10,24 +10,24 @@
NETLIST_START(cccs)
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-12)
- PARAM(Solver.METHOD, "MAT_CR")
+ 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)
+ 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(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)
+ NET_C(R2.1, VV.OP)
+ NET_C(R2.2, GND)
+ NET_C(VV.ON, GND)
/* Simple current source */
diff --git a/src/lib/netlist/examples/cd4066.c b/src/lib/netlist/examples/cd4066.c
index c77e6438c0f..1917c1909fc 100644
--- a/src/lib/netlist/examples/cd4066.c
+++ b/src/lib/netlist/examples/cd4066.c
@@ -9,38 +9,38 @@
#include "netlist/devices/net_lib.h"
NETLIST_START(cd4066)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V5, 5)
- CD_4066_DIP(SW)
- RES(R1, 1000)
+ CD_4066_DIP(SW)
+ RES(R1, 1000)
- NET_C(SW.7, GND)
- NET_C(SW.14, V5)
+ NET_C(SW.7, GND)
+ NET_C(SW.14, V5)
- NET_C(SW.13, clk)
- NET_C(SW.1, V5)
+ NET_C(SW.13, clk)
+ NET_C(SW.1, V5)
- NET_C(SW.2, R1.1)
- NET_C(R1.2, GND)
+ NET_C(SW.2, R1.1)
+ NET_C(R1.2, GND)
- // ground anything else
+ // ground anything else
- NET_C(SW.3, GND)
- NET_C(SW.4, GND)
- NET_C(SW.5, GND)
- NET_C(SW.6, GND)
- NET_C(SW.8, GND)
- NET_C(SW.9, GND)
- NET_C(SW.10, GND)
- NET_C(SW.11, GND)
- NET_C(SW.12, GND)
+ NET_C(SW.3, GND)
+ NET_C(SW.4, GND)
+ NET_C(SW.5, GND)
+ NET_C(SW.6, GND)
+ NET_C(SW.8, GND)
+ NET_C(SW.9, GND)
+ NET_C(SW.10, GND)
+ NET_C(SW.11, GND)
+ NET_C(SW.12, GND)
- LOG(logB, clk)
- LOG(logC, R1.1)
+ LOG(logB, clk)
+ LOG(logC, R1.1)
NETLIST_END()
diff --git a/src/lib/netlist/examples/cdelay.c b/src/lib/netlist/examples/cdelay.c
index 5f4f8d04440..273a9fcfab7 100644
--- a/src/lib/netlist/examples/cdelay.c
+++ b/src/lib/netlist/examples/cdelay.c
@@ -9,11 +9,11 @@
NETLIST_START(perf)
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-20)
- MAINCLOCK(clk, 50000000)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-20)
+ MAINCLOCK(clk, 50000000)
- TTL_7400_NAND(n1,clk,clk)
+ TTL_7400_NAND(n1,clk,clk)
NETLIST_END()
@@ -27,27 +27,27 @@ NETLIST_END()
NETLIST_START(cap_delay)
- /*
- * delay circuit
- *
- */
+ /*
+ * delay circuit
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, P_FREQ)
- PARAM(Solver.ACCURACY, 1e-20)
+ SOLVER(Solver, P_FREQ)
+ PARAM(Solver.ACCURACY, 1e-20)
PARAM(Solver.DYNAMIC_TS, P_DTS)
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-6)
- CLOCK(clk, 5000)
+ CLOCK(clk, 5000)
- TTL_7400_NAND(n1,clk,clk)
- CAP(C, 1e-6)
- NET_C(n1.Q, C.2)
- NET_C(GND, C.1)
- TTL_7400_NAND(n2,n1.Q, n1.Q)
+ TTL_7400_NAND(n1,clk,clk)
+ CAP(C, 1e-6)
+ NET_C(n1.Q, C.2)
+ NET_C(GND, C.1)
+ TTL_7400_NAND(n2,n1.Q, n1.Q)
- LOG(logclk, clk)
- LOG(logn1Q, C.2)
- LOG(logn2Q, n1.Q)
+ LOG(logclk, clk)
+ LOG(logn1Q, C.2)
+ LOG(logn2Q, n1.Q)
NETLIST_END()
diff --git a/src/lib/netlist/examples/cmos_inverter.cpp b/src/lib/netlist/examples/cmos_inverter.cpp
index e0936bfd3bc..02ea330cb77 100644
--- a/src/lib/netlist/examples/cmos_inverter.cpp
+++ b/src/lib/netlist/examples/cmos_inverter.cpp
@@ -10,19 +10,19 @@
#include "netlist/analog/nld_twoterm.h"
NETLIST_START(cmos_inverter)
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-7)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-7)
PARAM(Solver.NR_LOOPS, 5000)
PARAM(Solver.METHOD, "MAT_CR")
- ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V5, 5)
VS(IN, 5)
PARAM(IN.FUNC, "T 5 *")
- MOSFET(P, "PMOS(VTO=-1.0 KP=2e-3 LAMBDA=2E-2)")
- MOSFET(M, "NMOS(VTO=1.0 KP=2e-3 LAMBDA=2E-2)")
+ MOSFET(P, "PMOS(VTO=-1.0 KP=2e-3 LAMBDA=2E-2)")
+ MOSFET(M, "NMOS(VTO=1.0 KP=2e-3 LAMBDA=2E-2)")
NET_C(P.S, V5)
NET_C(P.D, M.D)
@@ -36,7 +36,7 @@ NETLIST_START(cmos_inverter)
NET_C(M.D, C.1)
NET_C(M.S, C.2)
#endif
- LOG(log_G, M.G)
- LOG(log_D, M.D)
+ LOG(log_G, M.G)
+ LOG(log_D, M.D)
NETLIST_END()
diff --git a/src/lib/netlist/examples/cmos_inverter_clk.cpp b/src/lib/netlist/examples/cmos_inverter_clk.cpp
index 8b70c46e715..32dbb25a33b 100644
--- a/src/lib/netlist/examples/cmos_inverter_clk.cpp
+++ b/src/lib/netlist/examples/cmos_inverter_clk.cpp
@@ -12,19 +12,19 @@
#define USE_CLOCK (1)
NETLIST_START(cmos_inverter_clk)
- /* Standard stuff */
+ /* Standard stuff */
//SOLVER(Solver, 480000)
SOLVER(Solver, 1e5)
//SOLVER(Solver, 100000000000)
- PARAM(Solver.ACCURACY, 1e-6 )
+ PARAM(Solver.ACCURACY, 1e-6 )
PARAM(Solver.NR_LOOPS, 500000)
PARAM(Solver.DYNAMIC_TS, 1)
PARAM(Solver.DYNAMIC_LTE, 1e-5)
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 2e-9)
- ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V5, 5)
-// CLOCK(clk, 0.5e6)
+// CLOCK(clk, 0.5e6)
#if (USE_CLOCK)
CLOCK(V, 5000)
@@ -35,8 +35,8 @@ NETLIST_START(cmos_inverter_clk)
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)")
+ 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)
@@ -57,8 +57,8 @@ NETLIST_START(cmos_inverter_clk)
NET_C(M.S, C.2)
#endif
#if 1
- LOG(log_G, M.G)
- LOG(log_D, M.D)
+ 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/examples/congo_bongo.c b/src/lib/netlist/examples/congo_bongo.c
index 3ad52e7dced..9c5db529d6c 100644
--- a/src/lib/netlist/examples/congo_bongo.c
+++ b/src/lib/netlist/examples/congo_bongo.c
@@ -10,8 +10,8 @@
/* set to 1 to use optimizations increasing performance significantly */
-#define USE_OPTMIZATIONS 1
-#define USE_FRONTIERS 1
+#define USE_OPTMIZATIONS 1
+#define USE_FRONTIERS 1
/* ----------------------------------------------------------------------------
* Library section header START
@@ -19,7 +19,7 @@
#ifndef __PLIB_PREPROCESSOR__
-#define LM358_DIP(_name) \
+#define LM358_DIP(_name) \
NET_REGISTER_DEV_X(LM358_DIP, _name)
#define G501534_DIP(_name) \
@@ -391,8 +391,8 @@ NETLIST_START(G501534_DIP)
* 12: VCC
* 4: GND
* 1: IN
- * 3: OUT
- * 13: CV
+ * 3: OUT
+ * 13: CV
* 2: RDL - connected via Capacitor to ground
*/
diff --git a/src/lib/netlist/examples/cs.cpp b/src/lib/netlist/examples/cs.cpp
index 8229c5bc032..f9b9741e0ff 100644
--- a/src/lib/netlist/examples/cs.cpp
+++ b/src/lib/netlist/examples/cs.cpp
@@ -10,14 +10,14 @@
NETLIST_START(cs)
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-12)
- PARAM(Solver.METHOD, "MAT_CR")
+ 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)
+ CS(CS1, 1e-3)
RES(R1, 1000)
NET_C(CS1.1, R1.1)
diff --git a/src/lib/netlist/examples/diode.c b/src/lib/netlist/examples/diode.c
index 9a2196c6f24..b628a18af4a 100644
--- a/src/lib/netlist/examples/diode.c
+++ b/src/lib/netlist/examples/diode.c
@@ -7,25 +7,25 @@
#include "netlist/devices/net_lib.h"
NETLIST_START(diode)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48)
- ANALOG_INPUT(V5, 5)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48)
+ ANALOG_INPUT(V5, 5)
//DIODE(D, "1N914")
- DIODE(D, "D(IS=1e-15)")
+ DIODE(D, "D(IS=1e-15)")
- RES(R, RES_K(10))
- RES(R1, RES_K(10))
+ RES(R, RES_K(10))
+ RES(R1, RES_K(10))
- NET_C(clk, D.K)
- NET_C(D.A, R.1)
- NET_C(R.2, V5)
- NET_C(R1.2, GND)
- NET_C(R.1, R1.1)
+ NET_C(clk, D.K)
+ NET_C(D.A, R.1)
+ NET_C(R.2, V5)
+ NET_C(R1.2, GND)
+ NET_C(R.1, R1.1)
- LOG(logB, clk)
- LOG(logC, D.A)
+ LOG(logB, clk)
+ LOG(logC, D.A)
NETLIST_END()
diff --git a/src/lib/netlist/examples/kidniki.c b/src/lib/netlist/examples/kidniki.c
index edbcf5ce203..b05a3b52d9f 100644
--- a/src/lib/netlist/examples/kidniki.c
+++ b/src/lib/netlist/examples/kidniki.c
@@ -67,7 +67,7 @@ NETLIST_START(dummy)
TTL_INPUT(I_BD0, 1)
//CLOCK(I_BD0, 5)
TTL_INPUT(I_CH0, 1)
- //CLOCK(I_CH0, 5 )
+ //CLOCK(I_CH0, 5 )
//TTL_INPUT(I_OH0, 1)
CLOCK(I_OH0, 5)
TTL_INPUT(I_SOUNDIC0, 1)
@@ -351,68 +351,68 @@ NETLIST_END()
NETLIST_START(opamp)
- /* Opamp model from
- *
- * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
- *
- * Bandwidth 1Mhz
- *
- */
+ /* Opamp model from
+ *
+ * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
+ *
+ * Bandwidth 1Mhz
+ *
+ */
- /* Terminal definitions for calling netlists */
+ /* Terminal definitions for calling netlists */
- ALIAS(PLUS, G1.IP) // Positive input
- ALIAS(MINUS, G1.IN) // Negative input
- ALIAS(OUT, EBUF.OP) // Opamp output ...
+ ALIAS(PLUS, G1.IP) // Positive input
+ ALIAS(MINUS, G1.IN) // Negative input
+ ALIAS(OUT, EBUF.OP) // Opamp output ...
- ALIAS(GND, EBUF.ON) // GND terminal
- ALIAS(VCC, DUMMY.I) // VCC terminal
- DUMMY_INPUT(DUMMY)
+ ALIAS(GND, EBUF.ON) // GND terminal
+ ALIAS(VCC, DUMMY.I) // VCC terminal
+ DUMMY_INPUT(DUMMY)
- /* The opamp model */
+ /* The opamp model */
- VCCS(G1)
- PARAM(G1.RI, RES_K(1000))
+ VCCS(G1)
+ PARAM(G1.RI, RES_K(1000))
#if 1
- PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000
- RES(RP1, 1000)
- CAP(CP1, 1.59e-5) // <== change to 1.59e-3 for 10Khz bandwidth
+ PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000
+ RES(RP1, 1000)
+ CAP(CP1, 1.59e-5) // <== change to 1.59e-3 for 10Khz bandwidth
#else
- PARAM(G1.G, 1) // typical OP-AMP amplification 100 * 1000 = 100000
- RES(RP1, 100000)
- CAP(CP1, 1.59e-7) // <== change to 1.59e-3 for 10Khz bandwidth
+ PARAM(G1.G, 1) // typical OP-AMP amplification 100 * 1000 = 100000
+ RES(RP1, 100000)
+ CAP(CP1, 1.59e-7) // <== change to 1.59e-3 for 10Khz bandwidth
#endif
- VCVS(EBUF)
- PARAM(EBUF.RO, 50)
- PARAM(EBUF.G, 1)
+ VCVS(EBUF)
+ PARAM(EBUF.RO, 50)
+ PARAM(EBUF.G, 1)
// PARAM(EBUF.RI, 1e20)
// 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(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(RP1.1, G1.OP)
+ NET_C(CP1.1, RP1.1)
- DIODE(DP,"1N914")
- DIODE(DN,"1N914")
+ DIODE(DP,"1N914")
+ DIODE(DN,"1N914")
- NET_C(DP.K, VCC)
+ NET_C(DP.K, VCC)
#if 1
- NET_C(DP.A, DN.K, RP1.1)
+ NET_C(DP.A, DN.K, RP1.1)
#else
- RES(RDP, 1000)
- RES(RDN, 1000)
- NET_C(RDP.1, DP.A)
- NET_C(RDN.1, DN.K)
- NET_C(RDP.2, RDN.2, RP1.1)
+ RES(RDP, 1000)
+ RES(RDN, 1000)
+ NET_C(RDP.1, DP.A)
+ NET_C(RDN.1, DN.K)
+ NET_C(RDP.2, RDN.2, RP1.1)
#endif
- NET_C(DN.A, GND)
+ NET_C(DN.A, GND)
- NET_C(EBUF.IP, RP1.1)
+ NET_C(EBUF.IP, RP1.1)
NETLIST_END()
diff --git a/src/lib/netlist/examples/mm5837_noise.c b/src/lib/netlist/examples/mm5837_noise.c
index dff1966e1eb..c5237274af0 100644
--- a/src/lib/netlist/examples/mm5837_noise.c
+++ b/src/lib/netlist/examples/mm5837_noise.c
@@ -9,24 +9,24 @@
NETLIST_START(ne555_astable)
- /*
- * Astable ne555
- *
- */
+ /*
+ * Astable ne555
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
+ SOLVER(Solver, 48000)
- ANALOG_INPUT(V12, 12) // 5V
+ ANALOG_INPUT(V12, 12) // 5V
- /* Wiring up the ne555 */
+ /* Wiring up the ne555 */
- // astable NE555, 1.13 ms period
+ // astable NE555, 1.13 ms period
- MM5837_DIP(NOISE)
+ MM5837_DIP(NOISE)
- RES(R, 10000)
+ RES(R, 10000)
NET_C(NOISE.1, NOISE.2, R.2, GND)
NET_C(NOISE.4, V12)
diff --git a/src/lib/netlist/examples/msx_mixer_stage.c b/src/lib/netlist/examples/msx_mixer_stage.c
index 445777eb9cf..413ad271e08 100644
--- a/src/lib/netlist/examples/msx_mixer_stage.c
+++ b/src/lib/netlist/examples/msx_mixer_stage.c
@@ -9,57 +9,57 @@
#include "netlist/devices/net_lib.h"
NETLIST_START(msx)
- /* The BJT is used as an amplifier. RESCHED_LOOPS must be relatively high to
- * allow Newton-Raphson to finish. */
+ /* The BJT is used as an amplifier. RESCHED_LOOPS must be relatively high to
+ * allow Newton-Raphson to finish. */
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-5)
- //PARAM(Solver.CONVERG, 0.3)
- PARAM(Solver.GS_LOOPS, 50)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-5)
+ //PARAM(Solver.CONVERG, 0.3)
+ PARAM(Solver.GS_LOOPS, 50)
- RES(RAY8910, 2345) // Max Voltage
+ RES(RAY8910, 2345) // Max Voltage
- ANALOG_INPUT(V5, 5)
- ANALOG_INPUT(V12, 12)
+ ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V12, 12)
- ANALOG_INPUT(SOUND, 5)
- ANALOG_INPUT(SND, 5)
+ ANALOG_INPUT(SOUND, 5)
+ ANALOG_INPUT(SND, 5)
- NET_MODEL("ss9014 NPN(is=2.87599e-14 bf=377.5 vaf=123 ikf=1.1841 ise=4.7863e-15 ne=1.5 br=4.79 var=11.29 ikr=0.275423 isc=1.44544e-14 nc=1.5 rb=200 irb=1e-5 rbm=10 re=0.56 rc=5 cje=1.7205e-11 vje=0.6905907 mje=0.3193434 tf=5.89463e-10 cjc=6.2956p vjc=0.4164212 mjc=0.2559546 xcjc=0.451391 xtb=1.8881 eg=1.2415 xti=3 fc=0.5 Vceo=45 Icrating=0.1 mfg=Fairchild)")
+ NET_MODEL("ss9014 NPN(is=2.87599e-14 bf=377.5 vaf=123 ikf=1.1841 ise=4.7863e-15 ne=1.5 br=4.79 var=11.29 ikr=0.275423 isc=1.44544e-14 nc=1.5 rb=200 irb=1e-5 rbm=10 re=0.56 rc=5 cje=1.7205e-11 vje=0.6905907 mje=0.3193434 tf=5.89463e-10 cjc=6.2956p vjc=0.4164212 mjc=0.2559546 xcjc=0.451391 xtb=1.8881 eg=1.2415 xti=3 fc=0.5 Vceo=45 Icrating=0.1 mfg=Fairchild)")
- RES(R24, RES_K(51))
- RES(R23, RES_K(5))
- RES(R21, RES_K(51))
- RES(R20, RES_K(1))
- RES(R9, RES_K(10))
- RES(R8, 330)
+ RES(R24, RES_K(51))
+ RES(R23, RES_K(5))
+ RES(R21, RES_K(51))
+ RES(R20, RES_K(1))
+ RES(R9, RES_K(10))
+ RES(R8, 330)
- CAP(C55, CAP_U(5)) // Guessed
+ CAP(C55, CAP_U(5)) // Guessed
- //NET_C(RAY8910.1, SND)
- NET_C(RAY8910.1, clk)
+ //NET_C(RAY8910.1, SND)
+ NET_C(RAY8910.1, clk)
- //NET_C(C55.1, SOUND)
- NET_C(C55.1, V5)
- NET_C(C55.2, R24.1)
- NET_C(R24.2, R23.2)
- NET_C(R23.1, RAY8910.2)
- NET_C(R23.1, R20.1)
- NET_C(R20.2, GND)
+ //NET_C(C55.1, SOUND)
+ NET_C(C55.1, V5)
+ NET_C(C55.2, R24.1)
+ NET_C(R24.2, R23.2)
+ NET_C(R23.1, RAY8910.2)
+ NET_C(R23.1, R20.1)
+ NET_C(R20.2, GND)
- NET_C(R21.1, V5)
- NET_C(R21.2, R23.2)
+ NET_C(R21.1, V5)
+ NET_C(R21.2, R23.2)
- QBJT_EB(T2, "ss9014")
+ QBJT_EB(T2, "ss9014")
- NET_C(R9.1, V12)
- NET_C(R9.2, T2.C)
- NET_C(R21.2, T2.B)
- NET_C(R8.1, T2.E)
- NET_C(R8.2, GND)
+ NET_C(R9.1, V12)
+ NET_C(R9.2, T2.C)
+ NET_C(R21.2, T2.B)
+ NET_C(R8.1, T2.E)
+ NET_C(R8.2, GND)
- //LOG(logB, T2.B)
- LOG(logC, T2.C)
+ //LOG(logB, T2.B)
+ LOG(logC, T2.C)
NETLIST_END()
diff --git a/src/lib/netlist/examples/ne555_astable.c b/src/lib/netlist/examples/ne555_astable.c
index 0348d3ae4d3..f71076b4e96 100644
--- a/src/lib/netlist/examples/ne555_astable.c
+++ b/src/lib/netlist/examples/ne555_astable.c
@@ -11,43 +11,43 @@
NETLIST_START(ne555_astable)
- /*
- * Astable ne555
- *
- */
+ /*
+ * Astable ne555
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
+ SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5) // 5V
+ ANALOG_INPUT(V5, 5) // 5V
- /* Wiring up the ne555 */
+ /* Wiring up the ne555 */
- // astable NE555, 1.13 ms period
+ // astable NE555, 1.13 ms period
- RES(RA, 5000)
- RES(RB, 3000)
- CAP(C, 0.15e-6)
- NE555(555)
+ RES(RA, 5000)
+ RES(RB, 3000)
+ CAP(C, 0.15e-6)
+ NE555(555)
- NET_C(GND, 555.GND)
- NET_C(V5, 555.VCC)
- NET_C(V5, 555.RESET)
+ 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(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.1, 555.DISCH)
+ NET_C(RB.2, 555.TRIG)
- NET_C(RB.2, 555.THRESH)
+ NET_C(RB.2, 555.THRESH)
- NET_C(555.TRIG, C.1)
- NET_C(C.2, GND)
+ NET_C(555.TRIG, C.1)
+ NET_C(C.2, GND)
- LOG(log2, C.1)
- LOG(log3, 555.OUT)
+ LOG(log2, C.1)
+ LOG(log3, 555.OUT)
NETLIST_END()
//! [ne555_example]
diff --git a/src/lib/netlist/examples/nmos_fet.cpp b/src/lib/netlist/examples/nmos_fet.cpp
index 53c6b4a6fc9..5bec1a97411 100644
--- a/src/lib/netlist/examples/nmos_fet.cpp
+++ b/src/lib/netlist/examples/nmos_fet.cpp
@@ -10,37 +10,37 @@
#include "netlist/analog/nld_twoterm.h"
NETLIST_START(nmos)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 100) // 100 Hz
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-9)
+ CLOCK(clk, 100) // 100 Hz
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-9)
PARAM(Solver.NR_LOOPS, 50000)
PARAM(Solver.DYNAMIC_TS, 1)
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-9)
- ANALOG_INPUT(V5, 5)
- ANALOG_INPUT(V3, 3.5)
+ ANALOG_INPUT(V5, 5)
+ ANALOG_INPUT(V3, 3.5)
- /* NMOS - example */
+ /* NMOS - example */
NET_MODEL("MM NMOS(VTO=1.0 KP=2e-3 LAMBDA=2E-2)")
- MOSFET(M, "MM")
+ MOSFET(M, "MM")
- RES(RB, 1000)
- RES(RC, 10000)
+ RES(RB, 1000)
+ RES(RC, 10000)
- NET_C(RC.1, V5)
- NET_C(RC.2, M.D)
- NET_C(RB.1, clk)
- //NET_C(RB.1, V3)
- NET_C(RB.2, M.G)
- NET_C(M.S, GND)
+ NET_C(RC.1, V5)
+ NET_C(RC.2, M.D)
+ NET_C(RB.1, clk)
+ //NET_C(RB.1, V3)
+ NET_C(RB.2, M.G)
+ NET_C(M.S, GND)
- // put some load on M.D
+ // put some load on M.D
- RES(RCE, 150000)
- NET_C(RCE.1, M.D)
- NET_C(RCE.2, GND)
+ RES(RCE, 150000)
+ NET_C(RCE.1, M.D)
+ NET_C(RCE.2, GND)
// capacitance over G - S
@@ -48,7 +48,7 @@ NETLIST_START(nmos)
NET_C(M.D, C.1)
NET_C(M.S, C.2)
- LOG(log_G, M.G)
- LOG(log_D, M.D)
+ LOG(log_G, M.G)
+ LOG(log_D, M.D)
NETLIST_END()
diff --git a/src/lib/netlist/examples/norton_opamp.c b/src/lib/netlist/examples/norton_opamp.c
index 8e077a91df2..a6cf52ce152 100644
--- a/src/lib/netlist/examples/norton_opamp.c
+++ b/src/lib/netlist/examples/norton_opamp.c
@@ -8,119 +8,119 @@
NETLIST_START(main)
- /* Standard stuff */
-
- CLOCK(clk, 10000) // 1000 Hz
- SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5)
- PARAM(Solver.ACCURACY, 1e-6)
- PARAM(Solver.DYNAMIC_TS, 0)
- PARAM(Solver.SOR_FACTOR, 1.0)
- //PARAM(Solver.CONVERG, 1.0)
- PARAM(Solver.GS_LOOPS, 5)
-
- SUBMODEL(op1, opamp_fast)
- /* Wired as non - inverting amplifier like in LM3900 datasheet */
-
- RES(R1, 25000)
- RES(R2, 100000)
- RES(R3, 200000)
- CAP(C1, CAP_U(0.05))
-
- NET_C(clk, C1.1)
- NET_C(C1.2, R1.1)
-
- NET_C(op1.VM, GND)
- NET_C(op1.VP, V5 )
- NET_C(op1.PLUS, R1.2, R3.1)
- NET_C(R3.2, V5)
- //NET_C(R3.2, GND)
- NET_C(op1.MINUS, R2.2)
- NET_C(op1.OUT, R2.1)
-
- RES(RL, 10000)
- NET_C(RL.2, GND)
- NET_C(RL.1, op1.OUT)
-
- LOG(logX, op1.OUT)
- LOG(logY, clk)
+ /* Standard stuff */
+
+ CLOCK(clk, 10000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ ANALOG_INPUT(V5, 5)
+ PARAM(Solver.ACCURACY, 1e-6)
+ PARAM(Solver.DYNAMIC_TS, 0)
+ PARAM(Solver.SOR_FACTOR, 1.0)
+ //PARAM(Solver.CONVERG, 1.0)
+ PARAM(Solver.GS_LOOPS, 5)
+
+ SUBMODEL(op1, opamp_fast)
+ /* Wired as non - inverting amplifier like in LM3900 datasheet */
+
+ RES(R1, 25000)
+ RES(R2, 100000)
+ RES(R3, 200000)
+ CAP(C1, CAP_U(0.05))
+
+ NET_C(clk, C1.1)
+ NET_C(C1.2, R1.1)
+
+ NET_C(op1.VM, GND)
+ NET_C(op1.VP, V5 )
+ NET_C(op1.PLUS, R1.2, R3.1)
+ NET_C(R3.2, V5)
+ //NET_C(R3.2, GND)
+ NET_C(op1.MINUS, R2.2)
+ NET_C(op1.OUT, R2.1)
+
+ RES(RL, 10000)
+ NET_C(RL.2, GND)
+ NET_C(RL.1, op1.OUT)
+
+ LOG(logX, op1.OUT)
+ LOG(logY, clk)
NETLIST_END()
NETLIST_START(opamp)
- /* Opamp model from
- *
- * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
- *
- * Bandwidth 10Mhz
- *
- */
-
- /* Terminal definitions for calling netlists */
-
- ALIAS(PLUS, G1.IP) // Positive input
- ALIAS(MINUS, G2.IN) // Negative input
- ALIAS(OUT, EBUF.OP) // Opamp output ...
- ALIAS(VM, EBUF.ON) // V- terminal
- ALIAS(VP, DUMMY.I) // V+ terminal
-
- DUMMY_INPUT(DUMMY)
-
- /* The opamp model */
-
- CCCS(G1)
- CCCS(G2)
- //PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000
- PARAM(G1.G, 1000000) // typical OP-AMP amplification 100 * 1000 = 100000
- PARAM(G2.G, 1000000) // typical OP-AMP amplification 100 * 1000 = 100000
- RES(RP1, 1000)
- CAP(CP1, 1.59e-6) // <== change to 1.59e-3 for 10Khz bandwidth
- VCVS(EBUF)
- PARAM(EBUF.RO, 50)
- PARAM(EBUF.G, 1)
+ /* Opamp model from
+ *
+ * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
+ *
+ * Bandwidth 10Mhz
+ *
+ */
+
+ /* Terminal definitions for calling netlists */
+
+ ALIAS(PLUS, G1.IP) // Positive input
+ ALIAS(MINUS, G2.IN) // Negative input
+ ALIAS(OUT, EBUF.OP) // Opamp output ...
+ ALIAS(VM, EBUF.ON) // V- terminal
+ ALIAS(VP, DUMMY.I) // V+ terminal
+
+ DUMMY_INPUT(DUMMY)
+
+ /* The opamp model */
+
+ CCCS(G1)
+ CCCS(G2)
+ //PARAM(G1.G, 100) // typical OP-AMP amplification 100 * 1000 = 100000
+ PARAM(G1.G, 1000000) // typical OP-AMP amplification 100 * 1000 = 100000
+ PARAM(G2.G, 1000000) // typical OP-AMP amplification 100 * 1000 = 100000
+ RES(RP1, 1000)
+ CAP(CP1, 1.59e-6) // <== change to 1.59e-3 for 10Khz bandwidth
+ VCVS(EBUF)
+ PARAM(EBUF.RO, 50)
+ PARAM(EBUF.G, 1)
// NET_C(EBUF.ON, GND)
- NET_C(G1.ON, GND)
- NET_C(G2.ON, GND)
- NET_C(RP1.2, GND)
- NET_C(CP1.2, GND)
- NET_C(EBUF.IN, GND)
+ NET_C(G1.ON, GND)
+ NET_C(G2.ON, GND)
+ NET_C(RP1.2, GND)
+ NET_C(CP1.2, GND)
+ NET_C(EBUF.IN, GND)
- NET_C(G1.IN, G2.IP, GND)
+ NET_C(G1.IN, G2.IP, GND)
- NET_C(RP1.1, G1.OP)
- NET_C(RP1.1, G2.OP)
- NET_C(CP1.1, RP1.1)
- NET_C(EBUF.IP, RP1.1)
+ NET_C(RP1.1, G1.OP)
+ NET_C(RP1.1, G2.OP)
+ NET_C(CP1.1, RP1.1)
+ NET_C(EBUF.IP, RP1.1)
NETLIST_END()
NETLIST_START(opamp_fast)
- /*
- * Fast norton opamp model without bandwidth
- */
+ /*
+ * Fast norton opamp model without bandwidth
+ */
- /* Terminal definitions for calling netlists */
+ /* Terminal definitions for calling netlists */
- ALIAS(PLUS, R1.1) // Positive input
- ALIAS(MINUS, R2.1) // Negative input
- ALIAS(OUT, G1.OP) // Opamp output ...
- ALIAS(VM, G1.ON) // V- terminal
- ALIAS(VP, DUMMY.I) // V+ terminal
+ ALIAS(PLUS, R1.1) // Positive input
+ ALIAS(MINUS, R2.1) // Negative input
+ ALIAS(OUT, G1.OP) // Opamp output ...
+ ALIAS(VM, G1.ON) // V- terminal
+ ALIAS(VP, DUMMY.I) // V+ terminal
- DUMMY_INPUT(DUMMY)
+ DUMMY_INPUT(DUMMY)
- /* The opamp model */
+ /* The opamp model */
- RES(R1, 1)
- RES(R2, 1)
- NET_C(R1.1, G1.IP)
- NET_C(R2.1, G1.IN)
- NET_C(R1.2, R2.2, G1.ON)
- VCVS(G1)
- PARAM(G1.G, 1000000)
- PARAM(G1.RO, RES_K(8))
+ RES(R1, 1)
+ RES(R2, 1)
+ NET_C(R1.1, G1.IP)
+ NET_C(R2.1, G1.IN)
+ NET_C(R1.2, R2.2, G1.ON)
+ VCVS(G1)
+ PARAM(G1.G, 1000000)
+ PARAM(G1.RO, RES_K(8))
NETLIST_END()
diff --git a/src/lib/netlist/examples/opamp.c b/src/lib/netlist/examples/opamp.c
index b13d92dab67..b3730b29b51 100644
--- a/src/lib/netlist/examples/opamp.c
+++ b/src/lib/netlist/examples/opamp.c
@@ -10,91 +10,91 @@
NETLIST_START(main)
- /* Standard stuff */
+ /* Standard stuff */
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 480000)
- PARAM(Solver.ACCURACY, 1e-10)
- PARAM(Solver.NR_LOOPS, 30000 )
- //PARAM(Solver.CONVERG, 1.0)
- PARAM(Solver.GS_LOOPS, 30)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 480000)
+ PARAM(Solver.ACCURACY, 1e-10)
+ PARAM(Solver.NR_LOOPS, 30000 )
+ //PARAM(Solver.CONVERG, 1.0)
+ PARAM(Solver.GS_LOOPS, 30)
- // Tie up +5 to opamps thought it's not currently needed
- // Stay compatible
- ANALOG_INPUT(V5, 5)
- NET_C(op.VCC, V5)
- NET_C(op1.VCC, V5)
+ // Tie up +5 to opamps thought it's not currently needed
+ // Stay compatible
+ ANALOG_INPUT(V5, 5)
+ NET_C(op.VCC, V5)
+ NET_C(op1.VCC, V5)
- /* Opamp wired as impedance changer */
- SUBMODEL(opamp, op)
+ /* Opamp wired as impedance changer */
+ SUBMODEL(opamp, op)
- NET_C(op.GND, GND)
- NET_C(op.PLUS, clk)
- NET_C(op.MINUS, op.OUT)
+ NET_C(op.GND, GND)
+ NET_C(op.PLUS, clk)
+ NET_C(op.MINUS, op.OUT)
- SUBMODEL(opamp, op1)
- /* Wired as inverting amplifier connected to output of first opamp */
+ SUBMODEL(opamp, op1)
+ /* Wired as inverting amplifier connected to output of first opamp */
- RES(R1, 100000)
- RES(R2, 200000)
+ RES(R1, 100000)
+ RES(R2, 200000)
- NET_C(op1.GND, GND)
- NET_C(op1.PLUS, GND)
- NET_C(op1.MINUS, R2.2)
- NET_C(op1.MINUS, R1.2)
+ NET_C(op1.GND, GND)
+ NET_C(op1.PLUS, GND)
+ NET_C(op1.MINUS, R2.2)
+ NET_C(op1.MINUS, R1.2)
- NET_C(op.OUT, R1.1)
- NET_C(op1.OUT, R2.1)
+ NET_C(op.OUT, R1.1)
+ NET_C(op1.OUT, R2.1)
- RES(RL, 1000)
- NET_C(RL.2, GND)
- NET_C(RL.1, op1.OUT)
+ RES(RL, 1000)
+ NET_C(RL.2, GND)
+ NET_C(RL.1, op1.OUT)
- LOG(log_X, op1.OUT)
- LOG(log_Y, clk)
+ LOG(log_X, op1.OUT)
+ LOG(log_Y, clk)
NETLIST_END()
NETLIST_START(opamp)
- /* Opamp model from
- *
- * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
- *
- * Bandwidth 10Mhz
- *
- */
+ /* Opamp model from
+ *
+ * http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel1.htm
+ *
+ * Bandwidth 10Mhz
+ *
+ */
- /* Terminal definitions for calling netlists */
+ /* Terminal definitions for calling netlists */
- ALIAS(PLUS, G1.IP) // Positive input
- ALIAS(MINUS, G1.IN) // Negative input
- ALIAS(OUT, EBUF.OP) // Opamp output ...
+ ALIAS(PLUS, G1.IP) // Positive input
+ ALIAS(MINUS, G1.IN) // Negative input
+ ALIAS(OUT, EBUF.OP) // Opamp output ...
- ALIAS(GND, EBUF.ON) // GND terminal
- ALIAS(VCC, DUMMY.I) // VCC terminal
- DUMMY_INPUT(DUMMY)
+ ALIAS(GND, EBUF.ON) // GND terminal
+ ALIAS(VCC, DUMMY.I) // VCC terminal
+ DUMMY_INPUT(DUMMY)
- /* The opamp model */
+ /* The opamp model */
- LVCCS(G1)
- PARAM(G1.G, 0.0021)
+ LVCCS(G1)
+ PARAM(G1.G, 0.0021)
PARAM(G1.CURLIM, 0.002)
- RES(RP1, 1e7)
- CAP(CP1, 0.00333e-6)
- VCVS(EBUF)
- PARAM(EBUF.RO, 50)
- PARAM(EBUF.G, 1)
+ RES(RP1, 1e7)
+ CAP(CP1, 0.00333e-6)
+ VCVS(EBUF)
+ PARAM(EBUF.RO, 50)
+ PARAM(EBUF.G, 1)
// 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(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)
+ NET_C(RP1.1, G1.OP)
+ NET_C(CP1.1, RP1.1)
+ NET_C(EBUF.IP, RP1.1)
NETLIST_END()
@@ -110,12 +110,12 @@ NETLIST_START(opamp_mod)
*
* Simple Opamp Model Calculation
*
- * First Pole Frequency 5 Hz
- * Unity Gain Frequency 11,000 Hz
- * RP 100,000 Ohm
- * DC Gain / Aol 2200
- * CP 0.318 uF
- * KG 0.022
+ * First Pole Frequency 5 Hz
+ * Unity Gain Frequency 11,000 Hz
+ * RP 100,000 Ohm
+ * DC Gain / Aol 2200
+ * CP 0.318 uF
+ * KG 0.022
*
*/
diff --git a/src/lib/netlist/examples/opamp_amplification_curve.cpp b/src/lib/netlist/examples/opamp_amplification_curve.cpp
index e1665244b0e..ed5d1709985 100644
--- a/src/lib/netlist/examples/opamp_amplification_curve.cpp
+++ b/src/lib/netlist/examples/opamp_amplification_curve.cpp
@@ -22,14 +22,14 @@
NETLIST_START(main)
- /* Standard stuff */
-
- //VARCLOCK(clk, "0.5 / pow(10, 1 + T * 4)")
- //CLOCK(clk, 1000)
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-7)
- PARAM(Solver.NR_LOOPS, 300)
- PARAM(Solver.DYNAMIC_TS, 1)
+ /* Standard stuff */
+
+ //VARCLOCK(clk, "0.5 / pow(10, 1 + T * 4)")
+ //CLOCK(clk, 1000)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-7)
+ PARAM(Solver.NR_LOOPS, 300)
+ PARAM(Solver.DYNAMIC_TS, 1)
PARAM(Solver.DYNAMIC_MIN_TIMESTEP, 1e-7)
VS(vs, 0)
@@ -59,36 +59,36 @@ NETLIST_START(main)
PARAM(vs.R, 0.001)
ALIAS(clk, vs.1)
NET_C(vs.2, GND)
- ANALOG_INPUT(V12, 12)
- ANALOG_INPUT(VM12, -12)
+ ANALOG_INPUT(V12, 12)
+ ANALOG_INPUT(VM12, -12)
- OPAMP(op, OPAMP_TEST)
+ OPAMP(op, OPAMP_TEST)
- NET_C(op.GND, VM12)
- NET_C(op.VCC, V12)
+ NET_C(op.GND, VM12)
+ NET_C(op.VCC, V12)
- /* Opamp B wired as inverting amplifier connected to output of first opamp */
+ /* Opamp B wired as inverting amplifier connected to output of first opamp */
- RES(R1, 100)
- RES(RP, 100)
- RES(R2, 10000000)
+ RES(R1, 100)
+ RES(RP, 100)
+ RES(R2, 10000000)
- NET_C(op.PLUS, RP.1)
+ NET_C(op.PLUS, RP.1)
NET_C(RP.2, GND)
- NET_C(op.MINUS, R2.2)
- NET_C(op.MINUS, R1.2)
+ NET_C(op.MINUS, R2.2)
+ NET_C(op.MINUS, R1.2)
- NET_C(clk, R1.1)
- NET_C(op.OUT, R2.1)
+ NET_C(clk, R1.1)
+ NET_C(op.OUT, R2.1)
- RES(RL, 2000)
- NET_C(RL.2, GND)
- NET_C(RL.1, op.OUT)
+ RES(RL, 2000)
+ NET_C(RL.2, GND)
+ NET_C(RL.1, op.OUT)
AFUNC(f, 1, "A0 * 1000")
NET_C(f.A0, op.OUT)
#if 1
- LOG(log_Y, R1.1)
- LOG(log_Z, f)
+ LOG(log_Y, R1.1)
+ LOG(log_Z, f)
#endif
NETLIST_END()
diff --git a/src/lib/netlist/examples/rc.c b/src/lib/netlist/examples/rc.c
index 1850da313da..140440011b9 100644
--- a/src/lib/netlist/examples/rc.c
+++ b/src/lib/netlist/examples/rc.c
@@ -7,25 +7,25 @@
NETLIST_START(rc)
- /*
- * delay circuit
- *
- */
+ /*
+ * delay circuit
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-6)
- CLOCK(clk, 20000)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+ CLOCK(clk, 20000)
- CAP(C1, 0.022e-6)
- RES(R1, 10000)
- RES(R2, 20000)
+ CAP(C1, 0.022e-6)
+ RES(R1, 10000)
+ RES(R2, 20000)
- NET_C(clk, R2.1)
- NET_C(R2.2, R1.1, C1.1)
- NET_C(C1.2, R1.2, GND)
+ NET_C(clk, R2.1)
+ NET_C(R2.2, R1.1, C1.1)
+ NET_C(C1.2, R1.2, GND)
- LOG(tt, C1.1)
+ LOG(tt, C1.1)
NETLIST_END()
diff --git a/src/lib/netlist/examples/rl.c b/src/lib/netlist/examples/rl.c
index 2848348c440..b9f4e4e64c0 100644
--- a/src/lib/netlist/examples/rl.c
+++ b/src/lib/netlist/examples/rl.c
@@ -7,26 +7,26 @@
NETLIST_START(lr)
- /*
- * delay circuit
- *
- */
+ /*
+ * delay circuit
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-6)
- CLOCK(clk, 50)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+ CLOCK(clk, 50)
PARAM(Solver.METHOD, "MAT_CR")
- IND(L1, 10)
- RES(R1, 10000)
-
- NET_C(clk, L1.1)
- NET_C(L1.2, R1.1)
- NET_C(R1.2, GND)
+ IND(L1, 10)
+ RES(R1, 10000)
- //LOG(log_1, R1.1)
- //LOG(log_2, clk)
+ NET_C(clk, L1.1)
+ NET_C(L1.2, R1.1)
+ NET_C(R1.2, GND)
+
+ //LOG(log_1, R1.1)
+ //LOG(log_2, clk)
NETLIST_END()
diff --git a/src/lib/netlist/examples/sn74ls629_osc.c b/src/lib/netlist/examples/sn74ls629_osc.c
index f40c464f55c..3f797d9474d 100644
--- a/src/lib/netlist/examples/sn74ls629_osc.c
+++ b/src/lib/netlist/examples/sn74ls629_osc.c
@@ -9,26 +9,26 @@
NETLIST_START(ls629)
- /*
- * Astable ne555
- *
- */
+ /*
+ * Astable ne555
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
+ SOLVER(Solver, 48000)
- ANALOG_INPUT(V5, 5) // 5V
- ANALOG_INPUT(VF, 2.5) // 5V
- ANALOG_INPUT(VR, 5) // 5V
+ ANALOG_INPUT(V5, 5) // 5V
+ ANALOG_INPUT(VF, 2.5) // 5V
+ ANALOG_INPUT(VR, 5) // 5V
- SN74LS629(OSC, 0.022e-6)
+ SN74LS629(OSC, 0.022e-6)
- NET_C(GND, OSC.GND)
- NET_C(VR, OSC.RNG)
- NET_C(VF, OSC.FC)
- NET_C(GND, OSC.ENQ)
+ NET_C(GND, OSC.GND)
+ NET_C(VR, OSC.RNG)
+ NET_C(VF, OSC.FC)
+ NET_C(GND, OSC.ENQ)
- LOG(log2, OSC.Y)
+ LOG(log2, OSC.Y)
NETLIST_END()
diff --git a/src/lib/netlist/examples/test.c b/src/lib/netlist/examples/test.c
index 9a75dd3ad91..bee32494710 100644
--- a/src/lib/netlist/examples/test.c
+++ b/src/lib/netlist/examples/test.c
@@ -10,78 +10,78 @@
#include "netlist/devices/net_lib.h"
NETLIST_START(bjt)
- /* Standard stuff */
-
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
-
- ANALOG_INPUT(V3, 3)
- ANALOG_INPUT(STOPG, 0)
- ALIAS(SRSTQ, RYf.2)
- ALIAS(SRST, RYc.2)
- NET_C(antenna, GND)
- ALIAS(runQ, Q1.C)
-
- TTL_7404_INVERT(e4d, STOPG)
-
- RES(RYf, 50) // output impedance
- RES(RYc, 50) // output impedance
-
- TTL_7404_INVERT(c9f, RYc.2)
- TTL_7404_INVERT(c9c, RYf.2)
- NET_C(c9f.Q, RYf.1)
- NET_C(c9c.Q, RYc.1)
-
- SWITCH2(coinsw, RYc.2, RYf.2)
-
- NET_C(coinsw.Q, GND)
-
- /* Antenna circuit */
- /* Also has a diode to clamp negative voltages - omitted here */
- NETDEV_QNPN(Q3, BC237B)
- ALIAS(antenna, Q3.B)
- NET_C(GND, Q3.E)
- RES(RX5, 100)
- CAP(CX1, 100)
- NET_C(RX5.1, CX1.1)
- NET_C(RX5.1, Q3.C)
- NET_C(RX5.2, GND)
- NET_C(CX1.2, GND)
- NETDEV_QNPN(Q1, BC237B)
- NET_C(Q1.B, RX5.1)
- NET_C(Q1.E, GND)
-
- DIODE(D3, 1N914)
- NET_C(D3.A, Q1.C)
- NET_C(D3.K, SRSTQ)
-
- DIODE(D2, 1N914)
- RES(RX4, 220)
- NET_C(D2.K, e4d.Q)
- NET_C(D2.A, RX4.1)
- NET_C(RX4.2, Q3.C)
-
- RES(RX1, 100)
- RES(RX2, 100)
- RES(RX3, 330)
- CAP(CX2, CAP_U(0.1))
-
- NET_C(RX3.2, D3.A)
- NET_C(RX3.1, RX1.2)
- NET_C(RX1.1, V3)
-
- NET_C(RX1.1, CX2.1)
- NET_C(RX1.2, CX2.2)
-
- NETDEV_QPNP(Q2, BC556B)
- NET_C(Q2.E, V3)
- NET_C(Q2.B, RX1.2)
- NET_C(Q2.C, RX2.2)
-
- NET_C(RX2.1, D2.A)
-
-
- //LOG(logB, Q1.B)
- //LOG(logC, Q1.C)
+ /* Standard stuff */
+
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
+
+ ANALOG_INPUT(V3, 3)
+ ANALOG_INPUT(STOPG, 0)
+ ALIAS(SRSTQ, RYf.2)
+ ALIAS(SRST, RYc.2)
+ NET_C(antenna, GND)
+ ALIAS(runQ, Q1.C)
+
+ TTL_7404_INVERT(e4d, STOPG)
+
+ RES(RYf, 50) // output impedance
+ RES(RYc, 50) // output impedance
+
+ TTL_7404_INVERT(c9f, RYc.2)
+ TTL_7404_INVERT(c9c, RYf.2)
+ NET_C(c9f.Q, RYf.1)
+ NET_C(c9c.Q, RYc.1)
+
+ SWITCH2(coinsw, RYc.2, RYf.2)
+
+ NET_C(coinsw.Q, GND)
+
+ /* Antenna circuit */
+ /* Also has a diode to clamp negative voltages - omitted here */
+ NETDEV_QNPN(Q3, BC237B)
+ ALIAS(antenna, Q3.B)
+ NET_C(GND, Q3.E)
+ RES(RX5, 100)
+ CAP(CX1, 100)
+ NET_C(RX5.1, CX1.1)
+ NET_C(RX5.1, Q3.C)
+ NET_C(RX5.2, GND)
+ NET_C(CX1.2, GND)
+ NETDEV_QNPN(Q1, BC237B)
+ NET_C(Q1.B, RX5.1)
+ NET_C(Q1.E, GND)
+
+ DIODE(D3, 1N914)
+ NET_C(D3.A, Q1.C)
+ NET_C(D3.K, SRSTQ)
+
+ DIODE(D2, 1N914)
+ RES(RX4, 220)
+ NET_C(D2.K, e4d.Q)
+ NET_C(D2.A, RX4.1)
+ NET_C(RX4.2, Q3.C)
+
+ RES(RX1, 100)
+ RES(RX2, 100)
+ RES(RX3, 330)
+ CAP(CX2, CAP_U(0.1))
+
+ NET_C(RX3.2, D3.A)
+ NET_C(RX3.1, RX1.2)
+ NET_C(RX1.1, V3)
+
+ NET_C(RX1.1, CX2.1)
+ NET_C(RX1.2, CX2.2)
+
+ NETDEV_QPNP(Q2, BC556B)
+ NET_C(Q2.E, V3)
+ NET_C(Q2.B, RX1.2)
+ NET_C(Q2.C, RX2.2)
+
+ NET_C(RX2.1, D2.A)
+
+
+ //LOG(logB, Q1.B)
+ //LOG(logC, Q1.C)
NETLIST_END()
diff --git a/src/lib/netlist/examples/todo.c b/src/lib/netlist/examples/todo.c
index 62c713e86fd..6e9257f5410 100644
--- a/src/lib/netlist/examples/todo.c
+++ b/src/lib/netlist/examples/todo.c
@@ -43,47 +43,47 @@ NETLIST_END()
#if 0
- RES(R1, 10)
- RES(R2, 10)
- RES(R3, 10)
- NET_C(V5,R1.1)
- NET_C(R1.2, R2.1)
- NET_C(R2.2, R3.1)
- NET_C(R3.2, GND)
+ RES(R1, 10)
+ RES(R2, 10)
+ RES(R3, 10)
+ NET_C(V5,R1.1)
+ NET_C(R1.2, R2.1)
+ NET_C(R2.2, R3.1)
+ NET_C(R3.2, GND)
#endif
#if 0
- RES(R4, 1000)
- CAP(C1, 1e-6)
- NET_C(V5,R4.1)
- NET_C(R4.2, C1.1)
- NET_C(C1.2, GND)
- //LOG(log1, C1.1)
+ RES(R4, 1000)
+ CAP(C1, 1e-6)
+ NET_C(V5,R4.1)
+ NET_C(R4.2, C1.1)
+ NET_C(C1.2, GND)
+ //LOG(log1, C1.1)
#endif
#if 0
- RES(R5, 1000)
- NETDEV_1N914(D1)
- NET_C(V5, R5.1)
- NET_C(R5.2, D1.A)
- NET_C(D1.K, GND)
- //LOG(log1, D1.A)
+ RES(R5, 1000)
+ NETDEV_1N914(D1)
+ NET_C(V5, R5.1)
+ NET_C(R5.2, D1.A)
+ NET_C(D1.K, GND)
+ //LOG(log1, D1.A)
#endif
#if 0
#endif
#if 0
- NETDEV_VCVS(VV)
- RES(R1, 1000)
- RES(R2, 10000)
-
- NET_C(V5, R1.1)
- NET_C(R1.2, VV.IN)
- NET_C(R2.1, VV.OP)
- NET_C(R2.2, VV.IN)
- NET_C(VV.ON, GND)
- NET_C(VV.IP, GND)
- LOG(logX, VV.OP)
+ NETDEV_VCVS(VV)
+ RES(R1, 1000)
+ RES(R2, 10000)
+
+ NET_C(V5, R1.1)
+ NET_C(R1.2, VV.IN)
+ NET_C(R2.1, VV.OP)
+ NET_C(R2.2, VV.IN)
+ NET_C(VV.ON, GND)
+ NET_C(VV.IP, GND)
+ LOG(logX, VV.OP)
#endif
@@ -91,50 +91,50 @@ NETLIST_END()
#endif
#if 0
- NETDEV_VCVS(VV)
- PARAM(VV.G, 100000) // typical OP-AMP amplification
- PARAM(VV.RO, 50) // typical OP-AMP amplification
- RES(R1, 1000)
- RES(R3, 10000) // ==> 10x amplification (inverting)
-
- NET_C(4V, R1.1)
- NET_C(R1.2, VV.IN)
- NET_C(R3.1, VV.IN)
- NET_C(R3.2, VV.OP)
- NET_C(VV.ON, GND)
- NET_C(VV.IP, GND)
- LOG(logX, VV.OP)
- LOG(logY, 4V)
+ NETDEV_VCVS(VV)
+ PARAM(VV.G, 100000) // typical OP-AMP amplification
+ PARAM(VV.RO, 50) // typical OP-AMP amplification
+ RES(R1, 1000)
+ RES(R3, 10000) // ==> 10x amplification (inverting)
+
+ NET_C(4V, R1.1)
+ NET_C(R1.2, VV.IN)
+ NET_C(R3.1, VV.IN)
+ NET_C(R3.2, VV.OP)
+ NET_C(VV.ON, GND)
+ NET_C(VV.IP, GND)
+ LOG(logX, VV.OP)
+ LOG(logY, 4V)
#endif
#if 0
- // Impedance converter with resistor
- NETDEV_VCVS(VV)
- PARAM(VV.G, 100000) // typical OP-AMP amplification
- PARAM(VV.RO, 50) // typical OP-AMP amplification
- RES(R3, 10000)
-
- NET_C(4V, VV.IP)
- NET_C(R3.1, VV.IN)
- NET_C(R3.2, VV.OP)
- NET_C(VV.ON, GND)
- LOG(logX, VV.OP)
- LOG(logY, 4V)
+ // Impedance converter with resistor
+ NETDEV_VCVS(VV)
+ PARAM(VV.G, 100000) // typical OP-AMP amplification
+ PARAM(VV.RO, 50) // typical OP-AMP amplification
+ RES(R3, 10000)
+
+ NET_C(4V, VV.IP)
+ NET_C(R3.1, VV.IN)
+ NET_C(R3.2, VV.OP)
+ NET_C(VV.ON, GND)
+ LOG(logX, VV.OP)
+ LOG(logY, 4V)
#endif
#if 0
- // Impedance converter without resistor
- NETDEV_VCVS(VV)
- PARAM(VV.G, 100000) // typical OP-AMP amplification
- PARAM(VV.RO, 50) // typical OP-AMP amplification
-
- NET_C(4V, VV.IP)
- NET_C(VV.IN, VV.OP)
- NET_C(VV.ON, GND)
- LOG(logX, VV.OP)
- LOG(logY, 4V)
+ // Impedance converter without resistor
+ NETDEV_VCVS(VV)
+ PARAM(VV.G, 100000) // typical OP-AMP amplification
+ PARAM(VV.RO, 50) // typical OP-AMP amplification
+
+ NET_C(4V, VV.IP)
+ NET_C(VV.IN, VV.OP)
+ NET_C(VV.ON, GND)
+ LOG(logX, VV.OP)
+ LOG(logY, 4V)
#endif
diff --git a/src/lib/netlist/examples/vccs.c b/src/lib/netlist/examples/vccs.c
index 27ebf5a64e0..0e76ba6b219 100644
--- a/src/lib/netlist/examples/vccs.c
+++ b/src/lib/netlist/examples/vccs.c
@@ -10,21 +10,21 @@
NETLIST_START(vccs)
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-12)
- PARAM(Solver.GS_LOOPS, 10000)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-12)
+ PARAM(Solver.GS_LOOPS, 10000)
- VCCS(VV)
- PARAM(VV.G, 100) // typical OP-AMP amplification
- RES(R2, 1)
+ VCCS(VV)
+ PARAM(VV.G, 100) // typical OP-AMP amplification
+ RES(R2, 1)
- NET_C(clk, VV.IN)
- NET_C(R2.1, VV.OP)
- NET_C(R2.2, GND)
- NET_C(VV.ON, GND)
- NET_C(VV.IP, GND)
- LOG(logX, VV.OP)
- LOG(logY, clk)
+ NET_C(clk, VV.IN)
+ NET_C(R2.1, VV.OP)
+ NET_C(R2.2, GND)
+ NET_C(VV.ON, GND)
+ NET_C(VV.IP, GND)
+ LOG(logX, VV.OP)
+ LOG(logY, clk)
NETLIST_END()
diff --git a/src/lib/netlist/examples/vccs1.c b/src/lib/netlist/examples/vccs1.c
index 7e6dd1ea48c..b3513b325b7 100644
--- a/src/lib/netlist/examples/vccs1.c
+++ b/src/lib/netlist/examples/vccs1.c
@@ -10,26 +10,26 @@
NETLIST_START(vccs)
- CLOCK(clk, 1000) // 1000 Hz
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-6)
-
-
- VCCS(VV)
- PARAM(VV.G, 100000) // typical OP-AMP amplification
- RES(R1, 10000)
- RES(R2, 1)
- RES(R3, 1000)
-
- NET_C(clk, R1.1)
- NET_C(R1.2, VV.IN)
- NET_C(R2.1, VV.OP)
- NET_C(R3.1, VV.IN)
- NET_C(R3.2, VV.OP)
- NET_C(R2.2, GND)
- NET_C(VV.ON, GND)
- NET_C(VV.IP, GND)
- LOG(logX, VV.OP)
- LOG(logY, clk)
+ CLOCK(clk, 1000) // 1000 Hz
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+
+
+ VCCS(VV)
+ PARAM(VV.G, 100000) // typical OP-AMP amplification
+ RES(R1, 10000)
+ RES(R2, 1)
+ RES(R3, 1000)
+
+ NET_C(clk, R1.1)
+ NET_C(R1.2, VV.IN)
+ NET_C(R2.1, VV.OP)
+ NET_C(R3.1, VV.IN)
+ NET_C(R3.2, VV.OP)
+ NET_C(R2.2, GND)
+ NET_C(VV.ON, GND)
+ NET_C(VV.IP, GND)
+ LOG(logX, VV.OP)
+ LOG(logY, clk)
NETLIST_END()
diff --git a/src/lib/netlist/examples/vs.c b/src/lib/netlist/examples/vs.c
index 7d72398e297..583b94d7c4f 100644
--- a/src/lib/netlist/examples/vs.c
+++ b/src/lib/netlist/examples/vs.c
@@ -11,10 +11,10 @@
NETLIST_START(vs)
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 480)
- PARAM(Solver.ACCURACY, 1e-6)
+ SOLVER(Solver, 480)
+ PARAM(Solver.ACCURACY, 1e-6)
PARAM(Solver.METHOD, "MAT_CR")
PARAM(Solver.DYNAMIC_TS, 1)
@@ -26,7 +26,7 @@ NETLIST_START(vs)
NET_C(R1.2, VS1.N)
NET_C(GND, VS1.N)
- //LOG(tt, VS1.P)
- //LOG(tt1, R1.1)
+ //LOG(tt, VS1.P)
+ //LOG(tt1, R1.1)
NETLIST_END()
diff --git a/src/lib/netlist/examples/vs_cs.c b/src/lib/netlist/examples/vs_cs.c
index 9b39106a540..252eb9cad3f 100644
--- a/src/lib/netlist/examples/vs_cs.c
+++ b/src/lib/netlist/examples/vs_cs.c
@@ -11,20 +11,20 @@
NETLIST_START(rc)
- /*
- * delay circuit
- *
- */
+ /*
+ * delay circuit
+ *
+ */
- /* Standard stuff */
+ /* Standard stuff */
- SOLVER(Solver, 48000)
- PARAM(Solver.ACCURACY, 1e-6)
- CLOCK(clk, 20000)
+ SOLVER(Solver, 48000)
+ PARAM(Solver.ACCURACY, 1e-6)
+ CLOCK(clk, 20000)
/* Voltage source. Inner resistance will make clock visible */
- RES(R1, 1000)
+ RES(R1, 1000)
VS(VS1, 1)
NET_C(R1.1, clk)
NET_C(R1.2, VS1.P)
@@ -34,8 +34,8 @@ NETLIST_START(rc)
* need negative current
*/
- RES(R2, 1000)
- RES(R3, 1000)
+ RES(R2, 1000)
+ RES(R3, 1000)
CS(CS1, -0.001)
NET_C(CS1.P, R2.1)
NET_C(R2.2, R3.1)
@@ -46,7 +46,7 @@ NETLIST_START(rc)
NET_C(C1.2, R3.2)
- LOG(tt, VS1.P)
- LOG(tx, R2.2)
+ LOG(tt, VS1.P)
+ LOG(tx, R2.2)
NETLIST_END()
diff --git a/src/lib/netlist/macro/nlm_base.cpp b/src/lib/netlist/macro/nlm_base.cpp
index 79a6a358fa7..e04d98e59ad 100644
--- a/src/lib/netlist/macro/nlm_base.cpp
+++ b/src/lib/netlist/macro/nlm_base.cpp
@@ -75,11 +75,11 @@ NETLIST_END()
* ---------------------------------------------------------------------------*/
static NETLIST_START(family_models)
- NET_MODEL("FAMILY _(TYPE=CUSTOM FV=5 IVL=0.16 IVH=0.4 OVL=0.1 OVH=1.0 ORL=1.0 ORH=130.0)")
+ NET_MODEL("FAMILY _(TYPE=CUSTOM IVL=0.16 IVH=0.4 OVL=0.1 OVH=1.0 ORL=1.0 ORH=130.0)")
NET_MODEL("OPAMP _()")
NET_MODEL("SCHMITT_TRIGGER _()")
- NET_MODEL("74XXOC FAMILY(FV=5 IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.05 ORL=10.0 ORH=1.0e8)")
+ NET_MODEL("74XXOC FAMILY(IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.05 ORL=10.0 ORH=1.0e8)")
NET_MODEL("74XX FAMILY(TYPE=TTL)")
NET_MODEL("CD4XXX FAMILY(TYPE=CD4XXX)")
NETLIST_END()
diff --git a/src/lib/netlist/macro/nlm_cd4xxx.cpp b/src/lib/netlist/macro/nlm_cd4xxx.cpp
index 8844b3f8154..595045f66da 100644
--- a/src/lib/netlist/macro/nlm_cd4xxx.cpp
+++ b/src/lib/netlist/macro/nlm_cd4xxx.cpp
@@ -152,6 +152,45 @@ static NETLIST_START(CD4016_DIP)
)
NETLIST_END()
+/*
+ * DM7486: Quad 2-Input Exclusive-OR Gates
+ *
+ * Y = A+B
+ * +---+---++---+
+ * | A | B || Y |
+ * +===+===++===+
+ * | 0 | 0 || 0 |
+ * | 0 | 1 || 1 |
+ * | 1 | 0 || 1 |
+ * | 1 | 1 || 0 |
+ * +---+---++---+
+ *
+ * Naming conventions follow National Semiconductor datasheet
+ *
+ */
+
+static NETLIST_START(CD4070_DIP)
+ CD4070_GATE(A)
+ CD4070_GATE(B)
+ CD4070_GATE(C)
+ CD4070_GATE(D)
+
+ NET_C(A.VCC, B.VCC, C.VCC, D.VCC)
+ NET_C(A.GND, B.GND, C.GND, D.GND)
+
+ DIPPINS( /* +--------------+ */
+ A.A, /* A1 |1 ++ 14| VCC */ A.VCC,
+ A.B, /* B1 |2 13| B4 */ D.B,
+ A.Q, /* Y1 |3 12| A4 */ D.A,
+ B.Q, /* Y2 |4 7486 11| Y4 */ D.Q,
+ B.A, /* A2 |5 10| Y3 */ C.Q,
+ B.B, /* B2 |6 9| B3 */ C.B,
+ A.GND,/* GND |7 8| A3 */ C.A
+ /* +--------------+ */
+ )
+NETLIST_END()
+
+
static NETLIST_START(CD4316_DIP)
CD4316_GATE(A)
CD4316_GATE(B)
@@ -191,7 +230,17 @@ NETLIST_START(CD4XXX_lib)
TT_FAMILY("CD4XXX")
TRUTHTABLE_END()
+ TRUTHTABLE_START(CD4070_GATE, 2, 1, "")
+ TT_HEAD("A,B|Q ")
+ TT_LINE("0,0|0|15")
+ TT_LINE("0,1|1|22")
+ TT_LINE("1,0|1|22")
+ TT_LINE("1,1|0|15")
+ TT_FAMILY("CD4XXX")
+ TRUTHTABLE_END()
+
LOCAL_LIB_ENTRY(CD4001_DIP)
+ LOCAL_LIB_ENTRY(CD4070_DIP)
/* DIP ONLY */
LOCAL_LIB_ENTRY(CD4020_DIP)
diff --git a/src/lib/netlist/macro/nlm_cd4xxx.h b/src/lib/netlist/macro/nlm_cd4xxx.h
index afb78706ea6..efa7f33d586 100644
--- a/src/lib/netlist/macro/nlm_cd4xxx.h
+++ b/src/lib/netlist/macro/nlm_cd4xxx.h
@@ -33,6 +33,12 @@
#define CD4001_DIP(name) \
NET_REGISTER_DEV(CD4001_DIP, name)
+#define CD4070_GATE(name) \
+ NET_REGISTER_DEV(CD4070_GATE, name)
+
+#define CD4070_DIP(name) \
+ NET_REGISTER_DEV(CD4070_DIP, name)
+
/* ----------------------------------------------------------------------------
* DIP only macros
* ---------------------------------------------------------------------------*/
diff --git a/src/lib/netlist/macro/nlm_opamp.cpp b/src/lib/netlist/macro/nlm_opamp.cpp
index 31a52f74a96..e06be8a5e00 100644
--- a/src/lib/netlist/macro/nlm_opamp.cpp
+++ b/src/lib/netlist/macro/nlm_opamp.cpp
@@ -69,21 +69,17 @@ NETLIST_END()
/*
* Generic layout with 1 opamp, VCC+ on pin 7, VCC- on pin 4 and compensation
+ * // FIXME: Offset inputs are not supported!
*/
static NETLIST_START(opamp_layout_1_7_4)
- DIPPINS( /* +--------------+ */
- OFFSET.N1, /* |1 ++ 8| */ NC,
- MINUS, /* |2 7| */ VCC.PLUS,
- PLUS, /* |3 6| */ OUT,
- VCC.MINUS, /* |4 5| */ OFFSET.N2
- /* +--------------+ */
+ DIPPINS( /* +--------------+ */
+ NC /* OFFSET */, /* |1 ++ 8| */ NC,
+ A.MINUS, /* |2 7| */ A.VCC,
+ A.PLUS, /* |3 6| */ A.OUT,
+ A.GND, /* |4 5| */ NC /* OFFSET */
+ /* +--------------+ */
)
- NET_C(A.GND, VCC.MINUS)
- NET_C(A.VCC, VCC.PLUS)
- NET_C(A.MINUS, MINUS)
- NET_C(A.PLUS, PLUS)
- NET_C(A.OUT, OUT)
NETLIST_END()
/*
@@ -138,6 +134,16 @@ static NETLIST_START(MB3614_DIP)
NETLIST_END()
+static NETLIST_START(TL084_DIP)
+ OPAMP(A, "TL084")
+ OPAMP(B, "TL084")
+ OPAMP(C, "TL084")
+ OPAMP(D, "TL084")
+
+ INCLUDE(opamp_layout_4_4_11)
+
+NETLIST_END()
+
static NETLIST_START(LM324_DIP)
OPAMP(A, "LM324")
OPAMP(B, "LM324")
@@ -219,9 +225,10 @@ static NETLIST_START(LM3900)
ALIAS(MINUS, R2.1) // Negative input
ALIAS(OUT, G1.OP) // Opamp output ...
ALIAS(GND, G1.ON) // V- terminal
- ALIAS(VCC, DUMMY.I) // V+ terminal
+ ALIAS(VCC, DUMMY.1) // V+ terminal
- DUMMY_INPUT(DUMMY)
+ RES(DUMMY, RES_K(1))
+ NET_C(DUMMY.2, GND)
/* The opamp model */
@@ -347,13 +354,18 @@ NETLIST_START(OPAMP_lib)
LOCAL_LIB_ENTRY(opamp_layout_1_8_5)
LOCAL_LIB_ENTRY(opamp_layout_1_11_6)
+ // FIXME: JFET Opamp may need better model
+ // VLL and VHH for +-6V RI=10^12 (for numerical stability 10^9 is used below
+ // RO from data sheet
+ NET_MODEL("TL084 OPAMP(TYPE=3 VLH=0.75 VLL=0.75 FPF=10 UGF=3000k SLEW=13M RI=1000M RO=192 DAB=0.0014)")
+
NET_MODEL("LM324 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=5 UGF=500k SLEW=0.3M RI=1000k RO=50 DAB=0.00075)")
NET_MODEL("LM358 OPAMP(TYPE=3 VLH=2.0 VLL=0.2 FPF=5 UGF=500k SLEW=0.3M RI=1000k RO=50 DAB=0.001)")
NET_MODEL("MB3614 OPAMP(TYPE=3 VLH=1.4 VLL=0.02 FPF=10 UGF=1000k SLEW=0.6M RI=1000k RO=50 DAB=0.002)")
NET_MODEL("UA741 OPAMP(TYPE=3 VLH=1.0 VLL=1.0 FPF=5 UGF=1000k SLEW=0.5M RI=2000k RO=75 DAB=0.0017)")
NET_MODEL("LM747 OPAMP(TYPE=3 VLH=1.0 VLL=1.0 FPF=5 UGF=1000k SLEW=0.5M RI=2000k RO=50 DAB=0.0017)")
NET_MODEL("LM747A OPAMP(TYPE=3 VLH=2.0 VLL=2.0 FPF=5 UGF=1000k SLEW=0.7M RI=6000k RO=50 DAB=0.0015)")
- // TI and Motorola Datasheets differ - below are Motorola values values SLEW is average of LH and HL
+ // TI and Motorola Datasheets differ - below are Motorola values, SLEW is average of LH and HL
NET_MODEL("LM3900 OPAMP(TYPE=3 VLH=1.0 VLL=0.03 FPF=2k UGF=4M SLEW=10M RI=10M RO=2k DAB=0.0015)")
#if USE_LM3900_MODEL == 1
@@ -361,6 +373,7 @@ NETLIST_START(OPAMP_lib)
NET_MODEL("LM3900_PNP1 PNP(IS=1E-14 BF=40 TF=1E-7 CJC=1E-12 CJE=1E-12 VAF=150 RB=100 RE=5)")
#endif
LOCAL_LIB_ENTRY(MB3614_DIP)
+ LOCAL_LIB_ENTRY(TL084_DIP)
LOCAL_LIB_ENTRY(LM324_DIP)
LOCAL_LIB_ENTRY(LM358_DIP)
LOCAL_LIB_ENTRY(LM2902_DIP)
diff --git a/src/lib/netlist/macro/nlm_opamp.h b/src/lib/netlist/macro/nlm_opamp.h
index a7a001a710d..c0a1486aa2f 100644
--- a/src/lib/netlist/macro/nlm_opamp.h
+++ b/src/lib/netlist/macro/nlm_opamp.h
@@ -24,6 +24,9 @@
#define LM324_DIP(name) \
NET_REGISTER_DEV(LM324_DIP, name)
+#define TL084_DIP(name) \
+ NET_REGISTER_DEV(TL084_DIP, name)
+
#define LM2902_DIP(name) \
NET_REGISTER_DEV(LM2902_DIP, name)
@@ -33,6 +36,21 @@
#define LM3900(name) \
NET_REGISTER_DEV(LM3900, name)
+#define UA741_DIP8(name) \
+ NET_REGISTER_DEV(UA741_DIP8, name)
+
+#define UA741_DIP10(name) \
+ NET_REGISTER_DEV(UA741_DIP10, name)
+
+#define UA741_DIP14(name) \
+ NET_REGISTER_DEV(UA741_DIP14, name)
+
+#define LM747_DIP(name) \
+ NET_REGISTER_DEV(LM747_DIP, name)
+
+#define LM747A_DIP(name) \
+ NET_REGISTER_DEV(LM747A_DIP, name)
+
#endif // NL_AUTO_DEVICES
/* ----------------------------------------------------------------------------
diff --git a/src/lib/netlist/macro/nlm_other.cpp b/src/lib/netlist/macro/nlm_other.cpp
index befbc99a364..873f3ad84c5 100644
--- a/src/lib/netlist/macro/nlm_other.cpp
+++ b/src/lib/netlist/macro/nlm_other.cpp
@@ -48,7 +48,7 @@ NETLIST_START(otheric_lib)
TT_LINE(" 0 | 1 |100")
TT_LINE(" 1 | 0 |100")
// 2.1V negative going and 2.7V positive going at 5V
- TT_FAMILY("FAMILY(FV=0 IVL=0.42 IVH=0.54 OVL=0.05 OVH=0.05 ORL=10.0 ORH=10.0)")
+ TT_FAMILY("FAMILY(IVL=0.42 IVH=0.54 OVL=0.05 OVH=0.05 ORL=10.0 ORH=10.0)")
TRUTHTABLE_END()
LOCAL_LIB_ENTRY(MC14584B_DIP)
diff --git a/src/lib/netlist/macro/nlm_ttl74xx.cpp b/src/lib/netlist/macro/nlm_ttl74xx.cpp
index 9e0fa15c582..e96c32f66cf 100644
--- a/src/lib/netlist/macro/nlm_ttl74xx.cpp
+++ b/src/lib/netlist/macro/nlm_ttl74xx.cpp
@@ -897,7 +897,7 @@ NETLIST_START(TTL74XX_lib)
NET_MODEL("DM7414 SCHMITT_TRIGGER(VTP=1.7 VTM=0.9 VI=4.35 RI=6.15k VOH=3.5 ROH=120 VOL=0.1 ROL=37.5 TPLH=15 TPHL=15)")
NET_MODEL("TTL_7414_GATE SCHMITT_TRIGGER(VTP=1.7 VTM=0.9 VI=4.35 RI=6.15k VOH=3.5 ROH=120 VOL=0.1 ROL=37.5 TPLH=15 TPHL=15)")
NET_MODEL("DM74LS14 SCHMITT_TRIGGER(VTP=1.6 VTM=0.8 VI=4.4 RI=19.3k VOH=3.45 ROH=130 VOL=0.1 ROL=31.2 TPLH=15 TPHL=15)")
- //NET_MODEL("DM7414 FAMILY(FV=5 IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.05 ORL=10.0 ORH=1.0e8)")
+ //NET_MODEL("DM7414 FAMILY(IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.05 ORL=10.0 ORH=1.0e8)")
TRUTHTABLE_START(TTL_7400_GATE, 2, 1, "")
diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp
index 84762b39901..336f6783e8f 100644
--- a/src/lib/netlist/nl_base.cpp
+++ b/src/lib/netlist/nl_base.cpp
@@ -5,6 +5,7 @@
#include "solver/nld_solver.h"
#include "plib/palloc.h"
+#include "plib/pfmtlog.h"
#include "plib/pmempool.h"
#include "plib/putil.h"
@@ -34,7 +35,6 @@ namespace netlist
public:
logic_family_ttl_t() : logic_family_desc_t()
{
- m_fixed_V = nlconst::magic(5.0);
m_low_thresh_PCNT = nlconst::magic(0.8 / 5.0);
m_high_thresh_PCNT = nlconst::magic(2.0 / 5.0);
// m_low_V - these depend on sinked/sourced current. Values should be suitable for typical applications.
@@ -61,7 +61,6 @@ namespace netlist
public:
logic_family_cd4xxx_t() : logic_family_desc_t()
{
- m_fixed_V = nlconst::magic(0.0);
m_low_thresh_PCNT = nlconst::magic(1.5 / 5.0);
m_high_thresh_PCNT = nlconst::magic(3.5 / 5.0);
// m_low_V - these depend on sinked/sourced current. Values should be suitable for typical applications.
@@ -101,7 +100,7 @@ namespace netlist
// ----------------------------------------------------------------------------------------
detail::queue_t::queue_t(netlist_t &nl)
- : timed_queue<plib::pqentry_t<net_t *, netlist_time>, false>(512)
+ : timed_queue<plib::pqentry_t<net_t *, netlist_time_ext>, false>(512)
, netlist_ref(nl)
, m_qsize(0)
, m_times(512)
@@ -128,7 +127,6 @@ namespace netlist
}
}
-
void detail::queue_t::on_post_load(plib::state_manager_t &manager)
{
plib::unused_var(manager);
@@ -136,7 +134,7 @@ namespace netlist
for (std::size_t i = 0; i < m_qsize; i++ )
{
detail::net_t *n = state().nets()[m_net_ids[i]].get();
- this->push<false>(queue_t::entry_t(netlist_time::from_raw(m_times[i]),n));
+ this->push<false>(queue_t::entry_t(netlist_time_ext::from_raw(m_times[i]),n));
}
}
@@ -161,18 +159,16 @@ namespace netlist
{
if (dynamic_cast<const terminal_t *>(this) != nullptr)
return terminal_type::TERMINAL;
- else if (dynamic_cast<const logic_input_t *>(this) != nullptr
+ if (dynamic_cast<const logic_input_t *>(this) != nullptr
|| dynamic_cast<const analog_input_t *>(this) != nullptr)
return terminal_type::INPUT;
- else if (dynamic_cast<const logic_output_t *>(this) != nullptr
+ if (dynamic_cast<const logic_output_t *>(this) != nullptr
|| dynamic_cast<const analog_output_t *>(this) != nullptr)
return terminal_type::OUTPUT;
- else
- {
- state().log().fatal(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
- plib::pthrow<nl_exception>(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
- //return terminal_type::TERMINAL; // please compiler
- }
+
+ state().log().fatal(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
+ throw nl_exception(MF_UNKNOWN_TYPE_FOR_OBJECT(name()));
+ //return terminal_type::TERMINAL; // please compiler
}
// ----------------------------------------------------------------------------------------
@@ -182,7 +178,7 @@ namespace netlist
netlist_t::netlist_t(netlist_state_t &state)
: m_state(state)
, m_solver(nullptr)
- , m_time(netlist_time::zero())
+ , m_time(netlist_time_ext::zero())
, m_mainclock(nullptr)
, m_queue(*this)
, m_use_stats(false)
@@ -198,10 +194,10 @@ namespace netlist
netlist_state_t::netlist_state_t(const pstring &aname,
plib::unique_ptr<callbacks_t> &&callbacks)
: m_name(aname)
- , m_state()
, m_callbacks(std::move(callbacks)) // Order is important here
, m_log(*m_callbacks)
, m_extended_validation(false)
+ , m_dummy_version(1)
{
pstring libpath = plib::util::environment("NL_BOOSTLIB", plib::util::buildpath({".", "nlboost.so"}));
m_lib = plib::make_unique<plib::dynlib>(libpath);
@@ -210,7 +206,26 @@ namespace netlist
// create the run interface
m_netlist = m_pool.make_unique<netlist_t>(*this);
+ // Make sure save states are invalidated when a new version is deployed
+
+ m_state.save_item(this, m_dummy_version, pstring("V") + version());
+
+ // Initialize factory
devices::initialize_factory(m_setup->factory());
+
+ // Add default include file
+ using a = plib::psource_str_t<plib::psource_t>;
+ const pstring content =
+ "#define RES_R(res) (res) \n"
+ "#define RES_K(res) ((res) * 1e3) \n"
+ "#define RES_M(res) ((res) * 1e6) \n"
+ "#define CAP_U(cap) ((cap) * 1e-6) \n"
+ "#define CAP_N(cap) ((cap) * 1e-9) \n"
+ "#define CAP_P(cap) ((cap) * 1e-12) \n"
+ "#define IND_U(ind) ((ind) * 1e-6) \n"
+ "#define IND_N(ind) ((ind) * 1e-9) \n"
+ "#define IND_P(ind) ((ind) * 1e-12) \n";
+ setup().add_include(plib::make_unique<a>("netlist/devices/net_lib.h", content));
NETLIST_NAME(base)(*m_setup);
}
@@ -241,19 +256,19 @@ namespace netlist
return std::numeric_limits<std::size_t>::max();
}
-
-
void netlist_state_t::rebuild_lists()
{
for (auto & net : m_nets)
net->rebuild_list();
}
-
void netlist_state_t::compile_defines(std::vector<std::pair<pstring, pstring>> &defs)
{
#define ENTRY(x) if (pstring(#x) != PSTRINGIFY(x)) defs.emplace_back(std::pair<pstring, pstring>(#x, PSTRINGIFY(x)));
- ENTRY(PHAS_RDTSCP)
+ ENTRY(NL_VERSION_MAJOR)
+ ENTRY(NL_VERSION_MINOR)
+ ENTRY(NL_VERSION_PATCHLEVEL)
+
ENTRY(PUSE_ACCURATE_STATS)
ENTRY(PHAS_INT128)
ENTRY(PUSE_ALIGNED_OPTIMIZATIONS)
@@ -300,6 +315,16 @@ namespace netlist
#undef ENTRY
}
+ pstring netlist_state_t::version()
+ {
+ return plib::pfmt("{1}.{2}")(NL_VERSION_MAJOR, NL_VERSION_MINOR);
+ }
+
+ pstring netlist_state_t::version_patchlevel()
+ {
+ return plib::pfmt("{1}.{2}.{3}")(NL_VERSION_MAJOR, NL_VERSION_MINOR, NL_VERSION_PATCHLEVEL);
+ }
+
void netlist_t::reset()
{
log().debug("Searching for mainclock\n");
@@ -308,10 +333,10 @@ namespace netlist
log().debug("Searching for solver\n");
m_solver = m_state.get_single_device<devices::NETLIB_NAME(solver)>("solver");
- m_time = netlist_time::zero();
+ m_time = netlist_time_ext::zero();
m_queue.clear();
if (m_mainclock != nullptr)
- m_mainclock->m_Q.net().set_next_scheduled_time(netlist_time::zero());
+ m_mainclock->m_Q.net().set_next_scheduled_time(netlist_time_ext::zero());
//if (m_solver != nullptr)
// m_solver->reset();
@@ -426,7 +451,7 @@ namespace netlist
for (auto & j : index)
{
auto entry = m_state.m_devices[j].second.get();
- auto stats = m_state.m_devices[j].second.get()->m_stats.get();
+ auto stats = entry->m_stats.get();
log().verbose("Device {1:20} : {2:12} {3:12} {4:15} {5:12}", entry->name(),
stats->m_stat_call_count(), stats->m_stat_total_time.count(),
stats->m_stat_total_time.total(), stats->m_stat_inc_active());
@@ -502,10 +527,9 @@ namespace netlist
if (ret != nullptr)
{
m_log.fatal(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
- plib::pthrow<nl_exception>(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
+ throw nl_exception(MF_MORE_THAN_ONE_1_DEVICE_FOUND(classname));
}
- else
- ret = d.second.get();
+ ret = d.second.get();
}
}
return ret;
@@ -518,7 +542,6 @@ namespace netlist
core_device_t::core_device_t(netlist_state_t &owner, const pstring &name)
: object_t(name)
- , logic_family_t()
, netlist_ref(owner.exec())
, m_hint_deactivate(false)
, m_active_outputs(*this, "m_active_outputs", 1)
@@ -531,7 +554,6 @@ namespace netlist
core_device_t::core_device_t(core_device_t &owner, const pstring &name)
: object_t(owner.name() + "." + name)
- , logic_family_t()
, netlist_ref(owner.state().exec())
, m_hint_deactivate(false)
, m_active_outputs(*this, "m_active_outputs", 1)
@@ -603,7 +625,7 @@ namespace netlist
if (!state().setup().connect(t1, t2))
{
log().fatal(MF_ERROR_CONNECTING_1_TO_2(t1.name(), t2.name()));
- plib::pthrow<nl_exception>(MF_ERROR_CONNECTING_1_TO_2(t1.name(), t2.name()));
+ throw nl_exception(MF_ERROR_CONNECTING_1_TO_2(t1.name(), t2.name()));
}
}
@@ -637,7 +659,7 @@ namespace netlist
, m_new_Q(*this, "m_new_Q", 0)
, m_cur_Q (*this, "m_cur_Q", 0)
, m_in_queue(*this, "m_in_queue", queue_status::DELIVERED)
- , m_next_scheduled_time(*this, "m_time", netlist_time::zero())
+ , m_next_scheduled_time(*this, "m_time", netlist_time_ext::zero())
, m_railterminal(railterminal)
{
}
@@ -658,7 +680,7 @@ namespace netlist
void detail::net_t::reset() noexcept
{
- m_next_scheduled_time = netlist_time::zero();
+ m_next_scheduled_time = netlist_time_ext::zero();
m_in_queue = queue_status::DELIVERED;
m_new_Q = 0;
@@ -687,7 +709,7 @@ namespace netlist
if (t == &terminal)
{
state().log().fatal(MF_NET_1_DUPLICATE_TERMINAL_2(name(), t->name()));
- plib::pthrow<nl_exception>(MF_NET_1_DUPLICATE_TERMINAL_2(name(), t->name()));
+ throw nl_exception(MF_NET_1_DUPLICATE_TERMINAL_2(name(), t->name()));
}
terminal.set_net(this);
@@ -705,7 +727,7 @@ namespace netlist
else
{
state().log().fatal(MF_REMOVE_TERMINAL_1_FROM_NET_2(terminal.name(), this->name()));
- plib::pthrow<nl_exception>(MF_REMOVE_TERMINAL_1_FROM_NET_2(terminal.name(), this->name()));
+ throw nl_exception(MF_REMOVE_TERMINAL_1_FROM_NET_2(terminal.name(), this->name()));
}
}
@@ -743,7 +765,6 @@ namespace netlist
detail::core_terminal_t::core_terminal_t(core_device_t &dev, const pstring &aname,
const state_e state, nldelegate delegate)
: device_object_t(dev, dev.name() + "." + aname)
- , plib::linkedlist_t<core_terminal_t>::element_t()
#if NL_USE_COPY_INSTEAD_OF_REFERENCE
, m_Q(*this, "m_Q", 0)
#endif
@@ -762,7 +783,6 @@ namespace netlist
logic_t::logic_t(core_device_t &dev, const pstring &aname, const state_e state,
nldelegate delegate)
: core_terminal_t(dev, aname, state, delegate)
- , logic_family_t()
{
}
@@ -775,9 +795,8 @@ namespace netlist
, m_Idr1(nullptr)
, m_go1(nullptr)
, m_gt1(nullptr)
- , m_connected_terminal(otherterm)
{
- state().setup().register_term(*this);
+ state().setup().register_term(*this, *otherterm);
}
void terminal_t::solve_now()
@@ -881,19 +900,17 @@ namespace netlist
{
if (dynamic_cast<const param_str_t *>(this) != nullptr)
return STRING;
- else if (dynamic_cast<const param_fp_t *>(this) != nullptr)
+ if (dynamic_cast<const param_fp_t *>(this) != nullptr)
return DOUBLE;
- else if (dynamic_cast<const param_int_t *>(this) != nullptr)
+ if (dynamic_cast<const param_int_t *>(this) != nullptr)
return INTEGER;
- else if (dynamic_cast<const param_logic_t *>(this) != nullptr)
+ if (dynamic_cast<const param_logic_t *>(this) != nullptr)
return LOGIC;
- else if (dynamic_cast<const param_ptr_t *>(this) != nullptr)
+ if (dynamic_cast<const param_ptr_t *>(this) != nullptr)
return POINTER;
- else
- {
- state().log().fatal(MF_UNKNOWN_PARAM_TYPE(name()));
- plib::pthrow<nl_exception>(MF_UNKNOWN_PARAM_TYPE(name()));
- }
+
+ state().log().fatal(MF_UNKNOWN_PARAM_TYPE(name()));
+ throw nl_exception(MF_UNKNOWN_PARAM_TYPE(name()));
}
diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h
index fc0416a3dbb..0f8feea9faf 100644
--- a/src/lib/netlist/nl_base.h
+++ b/src/lib/netlist/nl_base.h
@@ -62,11 +62,18 @@ class NETLIB_NAME(name) : public device_t
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
: NETLIB_NAME(pclass)(owner, name)
+// FIXME: Only used by diode
#define NETLIB_CONSTRUCTOR_DERIVED_EX(cname, pclass, ...) \
private: detail::family_setter_t m_famsetter; \
public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name, __VA_ARGS__) \
: NETLIB_NAME(pclass)(owner, name)
+#define NETLIB_CONSTRUCTOR_DERIVED_PASS(cname, pclass, ...) \
+ private: detail::family_setter_t m_famsetter; \
+ public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \
+ : NETLIB_NAME(pclass)(owner, name, __VA_ARGS__)
+
+
/// \brief Used to define the constructor of a netlist device.
/// Use this to define the constructor of a netlist device. Please refer to
/// #NETLIB_OBJECT for an example.
@@ -135,7 +142,7 @@ class NETLIB_NAME(name) : public device_t
/// Please see \ref NETLIB_IS_TIMESTEP for an example.
#define NETLIB_TIMESTEPI() \
- public: virtual void timestep(const nl_fptype step) noexcept override
+ public: virtual void timestep(nl_fptype step) noexcept override
/// \brief Used to implement the body of the time stepping code.
///
@@ -258,8 +265,6 @@ namespace netlist
virtual unique_pool_ptr<devices::nld_base_a_to_d_proxy> create_a_d_proxy(netlist_state_t &anetlist, const pstring &name,
logic_input_t *proxied) const = 0;
- // FIXME: remove fixed_V()
- nl_fptype fixed_V() const noexcept{return m_fixed_V; }
nl_fptype low_thresh_V(nl_fptype VN, nl_fptype VP) const noexcept{ return VN + (VP - VN) * m_low_thresh_PCNT; }
nl_fptype high_thresh_V(nl_fptype VN, nl_fptype VP) const noexcept{ return VN + (VP - VN) * m_high_thresh_PCNT; }
nl_fptype low_offset_V() const noexcept{ return m_low_VO; }
@@ -273,7 +278,6 @@ namespace netlist
bool is_below_low_thresh_V(nl_fptype V, nl_fptype VN, nl_fptype VP) const noexcept
{ return (V - VN) < low_thresh_V(VN, VP); }
- nl_fptype m_fixed_V; //!< For variable voltage families, specify 0. For TTL this would be 5.
nl_fptype m_low_thresh_PCNT; //!< low input threshhold offset. If the input voltage is below this value times supply voltage, a "0" input is signalled
nl_fptype m_high_thresh_PCNT; //!< high input threshhold offset. If the input voltage is above the value times supply voltage, a "0" input is signalled
nl_fptype m_low_VO; //!< low output voltage offset. This voltage is output if the ouput is "0"
@@ -350,6 +354,10 @@ namespace netlist
C14CONSTEXPR operator T & () noexcept { return m_value; }
//! Return const value of state variable.
constexpr operator const T & () const noexcept { return m_value; }
+ //! Return non-const value of state variable.
+ C14CONSTEXPR T & operator ()() noexcept { return m_value; }
+ //! Return const value of state variable.
+ constexpr const T & operator ()() const noexcept { return m_value; }
//! Return pointer to state variable.
C14CONSTEXPR T * ptr() noexcept { return &m_value; }
//! Return const pointer to state variable.
@@ -565,33 +573,39 @@ namespace netlist
public plib::linkedlist_t<core_terminal_t>::element_t
{
public:
+ /// \brief Number of signal bits
+ ///
+ /// Going forward setting this to 8 will allow 8-bit signal
+ /// busses to be used in netlist, e.g. for more complex memory
+ /// arrangements.
+ static constexpr const unsigned int INP_BITS = 1;
+ static constexpr const unsigned int INP_MASK = (1 << INP_BITS) - 1;
static constexpr const unsigned int INP_HL_SHIFT = 0;
- static constexpr const unsigned int INP_LH_SHIFT = 1;
+ static constexpr const unsigned int INP_LH_SHIFT = INP_BITS;
enum state_e {
STATE_INP_PASSIVE = 0,
- STATE_INP_HL = (1 << INP_HL_SHIFT),
- STATE_INP_LH = (1 << INP_LH_SHIFT),
+ STATE_INP_HL = (INP_MASK << INP_HL_SHIFT),
+ STATE_INP_LH = (INP_MASK << INP_LH_SHIFT),
STATE_INP_ACTIVE = STATE_INP_HL | STATE_INP_LH,
- STATE_OUT = 128,
- STATE_BIDIR = 256
+ STATE_OUT = (1 << (2*INP_BITS)),
+ STATE_BIDIR = (1 << (2*INP_BITS + 1))
};
core_terminal_t(core_device_t &dev, const pstring &aname,
- const state_e state, nldelegate delegate = nldelegate());
+ state_e state, nldelegate delegate = nldelegate());
virtual ~core_terminal_t() noexcept = default;
COPYASSIGNMOVE(core_terminal_t, delete)
/// \brief The object type.
/// \returns type of the object
-
terminal_type type() const noexcept(false);
+
/// \brief Checks if object is of specified type.
/// \param atype type to check object against.
/// \returns true if object is of specified type else false.
-
bool is_type(const terminal_type atype) const noexcept(false) { return (type() == atype); }
void set_net(net_t *anet) noexcept { m_net = anet; }
@@ -622,13 +636,13 @@ namespace netlist
state_var_sig m_Q;
#else
- void set_copied_input(netlist_sig_t val) const noexcept { plib::unused_var(val); }
+ void set_copied_input(netlist_sig_t val) noexcept { plib::unused_var(val); }
#endif
void set_delegate(const nldelegate &delegate) noexcept { m_delegate = delegate; }
nldelegate &delegate() noexcept { return m_delegate; }
const nldelegate &delegate() const noexcept { return m_delegate; }
- void run_delegate() noexcept { m_delegate(); }
+ inline void run_delegate() noexcept { m_delegate(); }
private:
nldelegate m_delegate;
net_t * m_net;
@@ -674,8 +688,8 @@ namespace netlist
template <bool KEEP_STATS>
void update_devs() noexcept;
- netlist_time next_scheduled_time() const noexcept { return m_next_scheduled_time; }
- void set_next_scheduled_time(netlist_time ntime) noexcept { m_next_scheduled_time = ntime; }
+ netlist_time_ext next_scheduled_time() const noexcept { return m_next_scheduled_time; }
+ void set_next_scheduled_time(netlist_time_ext ntime) noexcept { m_next_scheduled_time = ntime; }
bool isRailNet() const noexcept { return !(m_railterminal == nullptr); }
core_terminal_t & railterminal() const noexcept { return *m_railterminal; }
@@ -733,7 +747,7 @@ namespace netlist
}
// only used for logic nets
- void set_Q_time(netlist_sig_t newQ, netlist_time at) noexcept
+ void set_Q_time(netlist_sig_t newQ, netlist_time_ext at) noexcept
{
if (newQ != m_new_Q)
{
@@ -756,10 +770,10 @@ namespace netlist
netlist_sig_t *Q_state_ptr() noexcept { return m_cur_Q.ptr(); }
private:
- state_var<netlist_sig_t> m_new_Q;
- state_var<netlist_sig_t> m_cur_Q;
- state_var<queue_status> m_in_queue; // 0: not in queue, 1: in queue, 2: last was taken
- state_var<netlist_time> m_next_scheduled_time;
+ state_var<netlist_sig_t> m_new_Q;
+ state_var<netlist_sig_t> m_cur_Q;
+ state_var<queue_status> m_in_queue;
+ state_var<netlist_time_ext> m_next_scheduled_time;
core_terminal_t * m_railterminal;
plib::linkedlist_t<core_terminal_t> m_list_active;
@@ -778,7 +792,7 @@ namespace netlist
{
public:
- analog_t(core_device_t &dev, const pstring &aname, const state_e state,
+ analog_t(core_device_t &dev, const pstring &aname, state_e state,
nldelegate delegate = nldelegate());
const analog_net_t & net() const noexcept;
@@ -809,7 +823,7 @@ namespace netlist
void set_go_gt_I(nl_fptype GO, nl_fptype GT, nl_fptype I) const noexcept
{
- // FIXME: is this check still needed?
+ // Check for rail nets ...
if (m_go1 != nullptr)
{
*m_Idr1 = I;
@@ -822,16 +836,12 @@ namespace netlist
void schedule_solve_after(netlist_time after) noexcept;
void set_ptrs(nl_fptype *gt, nl_fptype *go, nl_fptype *Idr) noexcept(false);
-
- terminal_t *connected_terminal() const noexcept { return m_connected_terminal; }
private:
nl_fptype *m_Idr1; // drive current
nl_fptype *m_go1; // conductance for Voltage from other term
nl_fptype *m_gt1; // conductance for total conductance
- terminal_t *m_connected_terminal; // FIXME: only used during setup
-
};
@@ -843,7 +853,7 @@ namespace netlist
{
public:
logic_t(core_device_t &dev, const pstring &aname,
- const state_e state, nldelegate delegate = nldelegate());
+ state_e state, nldelegate delegate = nldelegate());
logic_net_t & net() noexcept;
const logic_net_t & net() const noexcept;
@@ -956,7 +966,7 @@ namespace netlist
m_my_net.set_Q_and_push(newQ, delay); // take the shortcut
}
- void set_Q_time(netlist_sig_t newQ, netlist_time at) noexcept
+ void set_Q_time(netlist_sig_t newQ, netlist_time_ext at) noexcept
{
m_my_net.set_Q_time(newQ, at); // take the shortcut
}
@@ -1081,7 +1091,7 @@ namespace netlist
void connect(const pstring &t1, const pstring &t2);
void connect(const detail::core_terminal_t &t1, const detail::core_terminal_t &t2);
- void connect_post_start(detail::core_terminal_t &t1, detail::core_terminal_t &t2);
+ void connect_post_start(detail::core_terminal_t &t1, detail::core_terminal_t &t2) noexcept(false);
protected:
NETLIB_UPDATEI() { }
@@ -1142,7 +1152,7 @@ namespace netlist
class param_num_t final: public param_t
{
public:
- param_num_t(device_t &device, const pstring &name, const T val);
+ param_num_t(device_t &device, const pstring &name, T val) noexcept(false);
T operator()() const noexcept { return m_param; }
operator T() const noexcept { return m_param; }
@@ -1156,7 +1166,7 @@ namespace netlist
class param_enum_t final: public param_t
{
public:
- param_enum_t(device_t &device, const pstring &name, const T val);
+ param_enum_t(device_t &device, const pstring &name, T val) noexcept(false);
T operator()() const noexcept { return T(m_param); }
operator T() const noexcept { return T(m_param); }
@@ -1245,7 +1255,7 @@ namespace netlist
protected:
void changed() noexcept override;
private:
-};
+ };
// -----------------------------------------------------------------------------
// data parameter
@@ -1304,11 +1314,9 @@ namespace netlist
using timed_queue = plib::timed_queue_linear<T, TS>;
// Use timed_queue_heap to use stdc++ heap functions instead of linear processing.
- /// This slows down processing by about 25% on a Kaby Lake.
-
-
- //template <class T, bool TS>
- //using timed_queue = timed_queue_heap<T, TS>;
+ // This slows down processing by about 25% on a Kaby Lake.
+ // template <class T, bool TS>
+ // using timed_queue = plib::timed_queue_heap<T, TS>;
// -----------------------------------------------------------------------------
// queue_t
@@ -1319,13 +1327,13 @@ namespace netlist
class queue_t :
//public timed_queue<pqentry_t<net_t *, netlist_time>, false, NL_KEEP_STATISTICS>,
- public timed_queue<plib::pqentry_t<net_t *, netlist_time>, false>,
+ public timed_queue<plib::pqentry_t<net_t *, netlist_time_ext>, false>,
public netlist_ref,
public plib::state_manager_t::callback_t
{
public:
- using base_queue = timed_queue<plib::pqentry_t<net_t *, netlist_time>, false>;
- using entry_t = plib::pqentry_t<net_t *, netlist_time>;
+ using entry_t = plib::pqentry_t<net_t *, netlist_time_ext>;
+ using base_queue = timed_queue<entry_t, false>;
explicit queue_t(netlist_t &nl);
~queue_t() noexcept override = default;
@@ -1342,7 +1350,7 @@ namespace netlist
private:
std::size_t m_qsize;
- std::vector<netlist_time::internal_type> m_times;
+ std::vector<netlist_time_ext::internal_type> m_times;
std::vector<std::size_t> m_net_ids;
};
@@ -1380,7 +1388,7 @@ namespace netlist
return dynamic_cast<C *>(p) != nullptr;
}
- core_device_t *get_single_device(const pstring &classname, bool (*cc)(core_device_t *)) const;
+ core_device_t *get_single_device(const pstring &classname, bool (*cc)(core_device_t *)) const noexcept(false);
/// \brief Get single device filtered by class and name
///
@@ -1477,7 +1485,7 @@ namespace netlist
{
dev.release();
log().fatal(MF_DUPLICATE_NAME_DEVICE_LIST(name));
- plib::pthrow<nl_exception>(MF_DUPLICATE_NAME_DEVICE_LIST(name));
+ throw nl_exception(MF_DUPLICATE_NAME_DEVICE_LIST(name));
}
//m_devices.push_back(std::move(dev));
m_devices.insert(m_devices.end(), { name, std::move(dev) });
@@ -1521,6 +1529,8 @@ namespace netlist
void rebuild_lists(); // must be called after post_load !
static void compile_defines(std::vector<std::pair<pstring, pstring>> &defs);
+ static pstring version();
+ static pstring version_patchlevel();
nets_collection_type & nets() noexcept { return m_nets; }
const nets_collection_type & nets() const noexcept { return m_nets; }
@@ -1575,6 +1585,9 @@ namespace netlist
// sole use is to manage lifetime of net objects
devices_collection_type m_devices;
bool m_extended_validation;
+
+ // dummy version
+ int m_dummy_version;
};
namespace devices
@@ -1594,7 +1607,7 @@ namespace netlist
NETLIB_RESETI()
{
- m_Q.net().set_next_scheduled_time(netlist_time::zero());
+ m_Q.net().set_next_scheduled_time(netlist_time_ext::zero());
}
NETLIB_UPDATE_PARAMI()
@@ -1615,6 +1628,7 @@ namespace netlist
param_fp_t m_freq;
};
} // namespace devices
+
// -----------------------------------------------------------------------------
// netlist_t
// -----------------------------------------------------------------------------
@@ -1631,9 +1645,9 @@ namespace netlist
// run functions
- netlist_time time() const noexcept { return m_time; }
+ netlist_time_ext time() const noexcept { return m_time; }
- void process_queue(netlist_time delta) noexcept;
+ void process_queue(netlist_time_ext delta) noexcept;
void abort_current_queue_slice() noexcept
{
if (!NL_USE_QUEUE_STATS || !m_use_stats)
@@ -1692,20 +1706,19 @@ namespace netlist
private:
template <bool KEEP_STATS>
- void process_queue_stats(netlist_time delta) noexcept;
+ void process_queue_stats(netlist_time_ext delta) noexcept;
netlist_state_t & m_state;
devices::NETLIB_NAME(solver) * m_solver;
// mostly rw
PALIGNAS_CACHELINE()
- netlist_time m_time;
+ netlist_time_ext m_time;
devices::NETLIB_NAME(mainclock) * m_mainclock;
PALIGNAS_CACHELINE()
detail::queue_t m_queue;
bool m_use_stats;
-
// performance
plib::pperftime_t<true> m_stat_mainloop;
plib::pperfcount_t<true> m_perf_out_processed;
@@ -1765,7 +1778,7 @@ namespace netlist
auto valx = func.evaluate();
if (std::is_integral<T>::value)
if (plib::abs(valx - plib::trunc(valx)) > nlconst::magic(1e-6))
- plib::pthrow<nl_exception>(MF_INVALID_NUMBER_CONVERSION_1_2(device.name() + "." + name, p));
+ throw nl_exception(MF_INVALID_NUMBER_CONVERSION_1_2(device.name() + "." + name, p));
m_param = static_cast<T>(valx);
}
else
@@ -1787,7 +1800,7 @@ namespace netlist
if (!ok)
{
device.state().log().fatal(MF_INVALID_ENUM_CONVERSION_1_2(name, p));
- plib::pthrow<nl_exception>(MF_INVALID_ENUM_CONVERSION_1_2(name, p));
+ throw nl_exception(MF_INVALID_ENUM_CONVERSION_1_2(name, p));
}
m_param = temp;
}
@@ -1851,7 +1864,7 @@ namespace netlist
{
m_next_scheduled_time = exec().time() + delay;
- if (is_queued())
+ if (!!is_queued())
exec().qremove(this);
if (!m_list_active.empty())
@@ -1921,14 +1934,12 @@ namespace netlist
if (!(gt && go && Idr) && (gt || go || Idr))
{
state().log().fatal("Inconsistent nullptrs for terminal {}", name());
- plib::pthrow<nl_exception>("Inconsistent nullptrs for terminal {}", name());
- }
- else
- {
- m_gt1 = gt;
- m_go1 = go;
- m_Idr1 = Idr;
+ throw nl_exception("Inconsistent nullptrs for terminal {}", name());
}
+
+ m_gt1 = gt;
+ m_go1 = go;
+ m_Idr1 = Idr;
}
inline logic_net_t & logic_t::net() noexcept
@@ -2021,7 +2032,7 @@ namespace netlist
// -----------------------------------------------------------------------------
template <bool KEEP_STATS, typename T>
- inline void detail::net_t::process(const T mask, netlist_sig_t sig) noexcept
+ inline void detail::net_t::process(T mask, netlist_sig_t sig) noexcept
{
m_cur_Q = sig;
@@ -2062,57 +2073,63 @@ namespace netlist
}
template <bool KEEP_STATS>
- inline void netlist_t::process_queue_stats(const netlist_time delta) noexcept
+ inline void netlist_t::process_queue_stats(const netlist_time_ext delta) noexcept
{
- netlist_time stop(m_time + delta);
+ netlist_time_ext stop(m_time + delta);
qpush(detail::queue_t::entry_t(stop, nullptr));
if (m_mainclock == nullptr)
{
- detail::queue_t::entry_t e(m_queue.pop());
- m_time = e.exec_time();
- while (e.object() != nullptr)
+ m_time = m_queue.top().exec_time();
+ detail::net_t *obj(m_queue.top().object());
+ m_queue.pop();
+
+ while (obj != nullptr)
{
- e.object()->template update_devs<KEEP_STATS>();
+ obj->template update_devs<KEEP_STATS>();
if (KEEP_STATS)
m_perf_out_processed.inc();
- e = m_queue.pop();
- m_time = e.exec_time();
+ const detail::queue_t::entry_t *top = &m_queue.top();
+ m_time = top->exec_time();
+ obj = top->object();
+ m_queue.pop();
}
}
else
{
logic_net_t &mc_net(m_mainclock->m_Q.net());
const netlist_time inc(m_mainclock->m_inc);
- netlist_time mc_time(mc_net.next_scheduled_time());
+ netlist_time_ext mc_time(mc_net.next_scheduled_time());
do
{
- while (m_queue.top().exec_time() > mc_time)
+ const detail::queue_t::entry_t *top = &m_queue.top();
+ while (top->exec_time() > mc_time)
{
m_time = mc_time;
mc_net.toggle_new_Q();
mc_net.update_devs<KEEP_STATS>();
+ top = &m_queue.top();
mc_time += inc;
}
- detail::queue_t::entry_t e(m_queue.pop());
- m_time = e.exec_time();
- if (e.object() != nullptr)
- {
- e.object()->template update_devs<KEEP_STATS>();
- if (KEEP_STATS)
- m_perf_out_processed.inc();
- }
+ m_time = top->exec_time();
+ const auto obj(top->object());
+ m_queue.pop();
+ if (obj != nullptr)
+ obj->template update_devs<KEEP_STATS>();
else
break;
- } while (true); //while (e.m_object != nullptr);
+ if (KEEP_STATS)
+ m_perf_out_processed.inc();
+ } while (true);
+
mc_net.set_next_scheduled_time(mc_time);
}
}
- inline void netlist_t::process_queue(netlist_time delta) noexcept
+ inline void netlist_t::process_queue(netlist_time_ext delta) noexcept
{
if (!m_use_stats)
process_queue_stats<false>(delta);
diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h
index ed6f5ec4d74..a6aa74381e4 100644
--- a/src/lib/netlist/nl_config.h
+++ b/src/lib/netlist/nl_config.h
@@ -10,6 +10,19 @@
#include "plib/pconfig.h"
#include "plib/pexception.h"
+///
+/// \brief Version - Major.
+///
+#define NL_VERSION_MAJOR 0
+///
+/// \brief Version - Minor.
+///
+#define NL_VERSION_MINOR 11
+/// \brief Version - Patch level.
+///
+#define NL_VERSION_PATCHLEVEL 0
+
+///
/// \addtogroup compiledefine
/// \{
@@ -47,7 +60,7 @@
/// This approach is stricter and should identify bugs in
/// the netlist core faster.
/// By default it is disabled since it is not as fast as
-/// the default approach. It is up to 10% slower.
+/// the default approach. It is up to 20% slower.
///
#ifndef NL_USE_COPY_INSTEAD_OF_REFERENCE
@@ -111,20 +124,40 @@
//#define NL_DEBUG (true)
#endif
+///
+/// \}
+///
+
//============================================================
// Time resolution
//============================================================
/// \brief Resolution as clocks per second for timing
///
-/// Uses nano-second resolution - Sufficient for now
+/// Uses 100 pico second resolution. This is aligned to MAME's
+/// attotime resolution.
+///
+/// The table below shows the maximum run times depending on
+/// time type size and resolution.
+///
+/// | Bits | Res | Seconds | Days | Years |
+/// | ====-| ===-| =======-| ====-| =====-|
+/// | 63 | 1,000,000,000 | 9,223,372,037 | 106,752| 292.3 |
+/// | 63 | 10,000,000,000 | 922,337,204 | 10,675| 29.2 |
+/// | 63 | 100,000,000,000 | 92,233,720 | 1,068| 2.9 |
+/// | 63 | 1,000,000,000,000 | 9,223,372 | 107| 0.3 |
+///
-static constexpr const auto NETLIST_INTERNAL_RES = 1000000000;
+static constexpr const auto NETLIST_INTERNAL_RES = 10'000'000'000LL;
-// FIXME: Belongs into MAME netlist.h
-static constexpr const auto NETLIST_CLOCK = NETLIST_INTERNAL_RES;
+/// \brief Recommended clock to be used
+///
+/// This is the recommended clock to be used in fixed clock applications limited
+/// to 32 bit clock resolution. The MAME code (netlist.cpp) contains code
+/// illustrating how to deal with remainders if \ref NETLIST_INTERNAL_RES is
+/// bigger than NETLIST_CLOCK.
-/// \}
+static constexpr const int NETLIST_CLOCK = 1'000'000'000;
/// \brief Floating point types used
///
@@ -185,11 +218,11 @@ namespace netlist
template <>
struct fp_constants<float>
{
- static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20f; }
- static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0f; }
+ static inline constexpr float DIODE_MAXDIFF() noexcept { return 1e20F; }
+ static inline constexpr float DIODE_MAXVOLT() noexcept { return 90.0F; }
- static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30f; }
- static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8f; }
+ static inline constexpr float TIMESTEP_MAXDIFF() noexcept { return 1e30F; }
+ static inline constexpr float TIMESTEP_MINDIV() noexcept { return 1e-8F; }
static inline constexpr const char * name() noexcept { return "float"; }
static inline constexpr const char * suffix() noexcept { return "f"; }
diff --git a/src/lib/netlist/nl_errstr.h b/src/lib/netlist/nl_errstr.h
index a6bf39374d7..f0cd3233856 100644
--- a/src/lib/netlist/nl_errstr.h
+++ b/src/lib/netlist/nl_errstr.h
@@ -13,9 +13,9 @@
namespace netlist
{
- static constexpr const char sHINT_NO_DEACTIVATE[] = ".HINT_NO_DEACTIVATE";
- static constexpr const char sPowerGND[] = "GND";
- static constexpr const char sPowerVCC[] = "VCC";
+ static constexpr const char sHINT_NO_DEACTIVATE[] = ".HINT_NO_DEACTIVATE"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+ static constexpr const char sPowerGND[] = "GND"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+ static constexpr const char sPowerVCC[] = "VCC"; // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
// nl_base.cpp
diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp
index 4e53903971d..7577a9e7dc8 100644
--- a/src/lib/netlist/nl_factory.cpp
+++ b/src/lib/netlist/nl_factory.cpp
@@ -55,7 +55,7 @@ namespace factory {
if (e->name() == factory->name())
{
m_log.fatal(MF_FACTORY_ALREADY_CONTAINS_1(factory->name()));
- plib::pthrow<nl_exception>(MF_FACTORY_ALREADY_CONTAINS_1(factory->name()));
+ throw nl_exception(MF_FACTORY_ALREADY_CONTAINS_1(factory->name()));
}
push_back(std::move(factory));
}
@@ -69,7 +69,7 @@ namespace factory {
}
m_log.fatal(MF_CLASS_1_NOT_FOUND(devname));
- plib::pthrow<nl_exception>(MF_CLASS_1_NOT_FOUND(devname));
+ throw nl_exception(MF_CLASS_1_NOT_FOUND(devname));
}
// -----------------------------------------------------------------------------
diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h
index b9d00b4bcd6..3abe7b49958 100644
--- a/src/lib/netlist/nl_factory.h
+++ b/src/lib/netlist/nl_factory.h
@@ -110,9 +110,9 @@ namespace factory {
register_device(plib::make_unique<device_element_t<device_class>>(name, classname, def_param));
}
- void register_device(plib::unique_ptr<element_t> &&factory);
+ void register_device(plib::unique_ptr<element_t> &&factory) noexcept(false);
- element_t * factory_by_name(const pstring &devname);
+ element_t * factory_by_name(const pstring &devname) noexcept(false);
template <class C>
bool is_class(element_t *f) noexcept
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp
index e4d68c20c40..04cfd43c635 100644
--- a/src/lib/netlist/nl_parser.cpp
+++ b/src/lib/netlist/nl_parser.cpp
@@ -15,7 +15,7 @@ namespace netlist
void parser_t::verror(const pstring &msg)
{
m_setup.log().fatal("{1}", msg);
- plib::pthrow<nl_exception>(plib::pfmt("{1}")(msg));
+ throw nl_exception(plib::pfmt("{1}")(msg));
}
bool parser_t::parse(const pstring &nlname)
@@ -86,8 +86,9 @@ bool parser_t::parse(const pstring &nlname)
{
parse_netlist(name.str());
return true;
- } else
- in_nl = true;
+ }
+
+ in_nl = true;
}
}
}
@@ -235,10 +236,12 @@ void parser_t::frontier()
// don't do much
pstring attachat = get_identifier();
require_token(m_tok_comma);
- nl_fptype r_IN = eval_param(get_token());
- require_token(m_tok_comma);
- nl_fptype r_OUT = eval_param(get_token());
- require_token(m_tok_paren_right);
+ auto tok = get_token();
+ auto r_IN = stringify_expression(tok);
+ require_token(tok, m_tok_comma);
+ tok = get_token();
+ auto r_OUT = stringify_expression(tok);
+ require_token(tok, m_tok_paren_right);
m_setup.register_frontier(attachat, r_IN, r_OUT);
}
@@ -334,14 +337,15 @@ void parser_t::netdev_param()
{
m_setup.log().debug("Parser: Param: {1} {2}\n", param, tok.str());
m_setup.register_param(param, tok.str());
+ require_token(m_tok_paren_right);
}
else
{
- nl_fptype val = eval_param(tok);
+ auto val = stringify_expression(tok);
m_setup.log().debug("Parser: Param: {1} {2}\n", param, val);
m_setup.register_param(param, val);
+ require_token(tok, m_tok_paren_right);
}
- require_token(m_tok_paren_right);
}
void parser_t::netdev_hint()
@@ -350,7 +354,7 @@ void parser_t::netdev_hint()
pstring dev(get_identifier());
require_token(m_tok_comma);
pstring hint(get_identifier());
- m_setup.register_param(dev + ".HINT_" + hint, 1);
+ m_setup.register_param_val(dev + ".HINT_" + hint, 1);
require_token(m_tok_paren_right);
}
@@ -369,18 +373,15 @@ void parser_t::device(const pstring &dev_type)
{
tok = get_token();
if (tok.is_type(token_type::IDENTIFIER) || tok.is_type(token_type::STRING))
+ {
params.push_back(tok.str());
+ tok = get_token();
+ }
else
{
- // FIXME: Do we really need this?
- nl_fptype value = eval_param(tok);
- if (plib::abs(value - plib::floor(value)) > nlconst::magic(1e-30)
- || plib::abs(value) > nlconst::magic(1e9))
- params.push_back(plib::pfmt("{1:.9}").e(value));
- else
- params.push_back(plib::pfmt("{1}")(static_cast<long>(value)));
+ auto value = stringify_expression(tok);
+ params.push_back(value);
}
- tok = get_token();
}
require_token(tok, m_tok_paren_right);
@@ -392,39 +393,24 @@ void parser_t::device(const pstring &dev_type)
// private
// ----------------------------------------------------------------------------------------
-nl_fptype parser_t::eval_param(const token_t &tok)
+pstring parser_t::stringify_expression(token_t &tok)
{
- static std::array<pstring, 7> macs = {"", "RES_R", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"};
- static std::array<nl_fptype, 7> facs = {
- nlconst::magic(1.0),
- nlconst::magic(1.0),
- nlconst::magic(1e3),
- nlconst::magic(1e6),
- nlconst::magic(1e-6),
- nlconst::magic(1e-9),
- nlconst::magic(1e-12)
- };
- std::size_t f=0;
- nl_fptype ret(0);
-
- for (std::size_t i=1; i<macs.size();i++)
- if (tok.str() == macs[i])
- f = i;
- if (f>0)
- {
- require_token(m_tok_paren_left);
- ret = static_cast<nl_fptype>(get_number_double());
- require_token(m_tok_paren_right);
- }
- else
+ int pc(0);
+ pstring ret;
+ while (!tok.is(m_tok_comma))
{
- bool err(false);
- ret = plib::pstonum_ne<nl_fptype>(tok.str(), err);
- if (err)
- error(MF_PARAM_NOT_FP_1(tok.str()));
+ if (tok.is(m_tok_paren_left))
+ pc++;
+ else if (tok.is(m_tok_paren_right))
+ {
+ if (pc<=0)
+ break;
+ pc--;
+ }
+ ret += tok.str();
+ tok = get_token();
}
- return ret * facs[f];
-
+ return ret;
}
} // namespace netlist
diff --git a/src/lib/netlist/nl_parser.h b/src/lib/netlist/nl_parser.h
index e747f2dac28..524f2cfeed8 100644
--- a/src/lib/netlist/nl_parser.h
+++ b/src/lib/netlist/nl_parser.h
@@ -43,9 +43,7 @@ namespace netlist
void verror(const pstring &msg) override;
private:
-
- nl_fptype eval_param(const token_t &tok);
-
+ pstring stringify_expression(token_t &tok);
token_id_t m_tok_paren_left;
token_id_t m_tok_paren_right;
token_id_t m_tok_comma;
diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp
index 21b2c0e8999..5cda3e03d64 100644
--- a/src/lib/netlist/nl_setup.cpp
+++ b/src/lib/netlist/nl_setup.cpp
@@ -36,10 +36,10 @@ namespace netlist
void nlparse_t::register_dip_alias_arr(const pstring &terms)
{
std::vector<pstring> list(plib::psplit(terms,", "));
- if (list.size() == 0 || (list.size() % 2) == 1)
+ if (list.empty() || (list.size() % 2) == 1)
{
log().fatal(MF_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1(build_fqn("")));
- plib::pthrow<nl_exception>(MF_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1(build_fqn("")));
+ throw nl_exception(MF_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1(build_fqn("")));
}
std::size_t n = list.size();
for (std::size_t i = 0; i < n / 2; i++)
@@ -80,7 +80,7 @@ namespace netlist
register_dev(classname, name);
- if (params_and_connections.size() > 0)
+ if (!params_and_connections.empty())
{
auto ptok(params_and_connections.begin());
auto ptok_end(params_and_connections.end());
@@ -94,7 +94,7 @@ namespace netlist
{
auto err(MF_PARAM_COUNT_MISMATCH_2(name, params_and_connections.size()));
log().fatal(err);
- plib::pthrow<nl_exception>(err);
+ throw nl_exception(err);
//break;
}
pstring output_name = *ptok;
@@ -116,16 +116,14 @@ namespace netlist
{
auto err(MF_PARAM_COUNT_MISMATCH_2(name, params_and_connections.size()));
log().fatal(err);
- plib::pthrow<nl_exception>(err);
+ throw nl_exception(err);
}
pstring paramfq = name + "." + tp;
log().debug("Defparam: {1}\n", paramfq);
- // remove quotes
- if (plib::startsWith(*ptok, "\"") && plib::endsWith(*ptok, "\""))
- register_param(paramfq, ptok->substr(1, ptok->length() - 2));
- else
- register_param(paramfq, *ptok);
+
+ register_param(paramfq, *ptok);
+
++ptok;
}
}
@@ -133,7 +131,7 @@ namespace netlist
{
auto err(MF_PARAM_COUNT_EXCEEDED_2(name, params_and_connections.size()));
log().fatal(err);
- plib::pthrow<nl_exception>(err);
+ throw nl_exception(err);
}
}
}
@@ -144,21 +142,19 @@ namespace netlist
if (f == nullptr)
{
log().fatal(MF_CLASS_1_NOT_FOUND(classname));
- plib::pthrow<nl_exception>(MF_CLASS_1_NOT_FOUND(classname));
+ throw nl_exception(MF_CLASS_1_NOT_FOUND(classname));
}
- else
+
+ // make sure we parse macro library entries
+ f->macro_actions(*this, name);
+ pstring key = build_fqn(name);
+ if (device_exists(key))
{
- // make sure we parse macro library entries
- f->macro_actions(*this, name);
- pstring key = build_fqn(name);
- if (device_exists(key))
- {
- log().fatal(MF_DEVICE_ALREADY_EXISTS_1(name));
- plib::pthrow<nl_exception>(MF_DEVICE_ALREADY_EXISTS_1(name));
- }
- else
- m_device_factory.insert(m_device_factory.end(), {key, f});
+ log().fatal(MF_DEVICE_ALREADY_EXISTS_1(name));
+ throw nl_exception(MF_DEVICE_ALREADY_EXISTS_1(name));
}
+
+ m_device_factory.insert(m_device_factory.end(), {key, f});
}
void nlparse_t::register_link(const pstring &sin, const pstring &sout)
@@ -172,7 +168,7 @@ namespace netlist
if (list.size() < 2)
{
log().fatal(MF_NET_C_NEEDS_AT_LEAST_2_TERMINAL());
- plib::pthrow<nl_exception>(MF_NET_C_NEEDS_AT_LEAST_2_TERMINAL());
+ throw nl_exception(MF_NET_C_NEEDS_AT_LEAST_2_TERMINAL());
}
for (std::size_t i = 1; i < list.size(); i++)
{
@@ -188,7 +184,7 @@ namespace netlist
}))
return;
log().fatal(MF_NOT_FOUND_IN_SOURCE_COLLECTION(netlist_name));
- plib::pthrow<nl_exception>(MF_NOT_FOUND_IN_SOURCE_COLLECTION(netlist_name));
+ throw nl_exception(MF_NOT_FOUND_IN_SOURCE_COLLECTION(netlist_name));
}
@@ -218,21 +214,26 @@ namespace netlist
void nlparse_t::register_param(const pstring &param, const pstring &value)
{
pstring fqn = build_fqn(param);
+ pstring val(value);
+
+ // strip " from stringified strings
+ if (plib::startsWith(value, "\"") && plib::endsWith(value, "\""))
+ val = value.substr(1, value.length() - 2);
auto idx = m_param_values.find(fqn);
if (idx == m_param_values.end())
{
- if (!m_param_values.insert({fqn, value}).second)
+ if (!m_param_values.insert({fqn, val}).second)
{
log().fatal(MF_ADDING_PARAMETER_1_TO_PARAMETER_LIST(param));
- plib::pthrow<nl_exception>(MF_ADDING_PARAMETER_1_TO_PARAMETER_LIST(param));
+ throw nl_exception(MF_ADDING_PARAMETER_1_TO_PARAMETER_LIST(param));
}
}
else
{
log().warning(MW_OVERWRITING_PARAM_1_OLD_2_NEW_3(fqn, idx->second,
- value));
- m_param_values[fqn] = value;
+ val));
+ m_param_values[fqn] = val;
}
}
@@ -241,7 +242,7 @@ namespace netlist
m_factory.register_device(plib::make_unique<factory::library_element_t>(name, name, "", sourcefile));
}
- void nlparse_t::register_frontier(const pstring &attach, const nl_fptype r_IN, const nl_fptype r_OUT)
+ void nlparse_t::register_frontier(const pstring &attach, const pstring &r_IN, const pstring &r_OUT)
{
pstring frontier_name = plib::pfmt("frontier_{1}")(m_frontier_cnt);
m_frontier_cnt++;
@@ -268,7 +269,7 @@ namespace netlist
if (!found)
{
log().fatal(MF_FOUND_NO_OCCURRENCE_OF_1(attach));
- plib::pthrow<nl_exception>(MF_FOUND_NO_OCCURRENCE_OF_1(attach));
+ throw nl_exception(MF_FOUND_NO_OCCURRENCE_OF_1(attach));
}
register_link(attach, frontier_name + ".Q");
}
@@ -281,11 +282,8 @@ namespace netlist
pstring nlparse_t::build_fqn(const pstring &obj_name) const
{
- if (m_namespace_stack.empty())
- //return netlist().name() + "." + obj_name;
- return obj_name;
- else
- return m_namespace_stack.top() + "." + obj_name;
+ return (m_namespace_stack.empty()) ? obj_name
+ : m_namespace_stack.top() + "." + obj_name;
}
void nlparse_t::register_alias_nofqn(const pstring &alias, const pstring &out)
@@ -293,7 +291,7 @@ namespace netlist
if (!m_alias.insert({alias, out}).second)
{
log().fatal(MF_ADDING_ALI1_TO_ALIAS_LIST(alias));
- plib::pthrow<nl_exception>(MF_ADDING_ALI1_TO_ALIAS_LIST(alias));
+ throw nl_exception(MF_ADDING_ALI1_TO_ALIAS_LIST(alias));
}
}
@@ -343,7 +341,7 @@ setup_t::setup_t(netlist_state_t &nlstate)
{
}
-pstring setup_t::termtype_as_str(detail::core_terminal_t &in) const
+pstring setup_t::termtype_as_str(detail::core_terminal_t &in)
{
switch (in.type())
{
@@ -362,10 +360,7 @@ pstring setup_t::termtype_as_str(detail::core_terminal_t &in) const
pstring setup_t::get_initial_param_val(const pstring &name, const pstring &def) const
{
auto i = m_param_values.find(name);
- if (i != m_param_values.end())
- return i->second;
- else
- return def;
+ return (i != m_param_values.end()) ? i->second : def;
}
void setup_t::register_term(detail::core_terminal_t &term)
@@ -374,10 +369,16 @@ void setup_t::register_term(detail::core_terminal_t &term)
if (!m_terminals.insert({term.name(), &term}).second)
{
log().fatal(MF_ADDING_1_2_TO_TERMINAL_LIST(termtype_as_str(term), term.name()));
- plib::pthrow<nl_exception>(MF_ADDING_1_2_TO_TERMINAL_LIST(termtype_as_str(term), term.name()));
+ throw nl_exception(MF_ADDING_1_2_TO_TERMINAL_LIST(termtype_as_str(term), term.name()));
}
}
+void setup_t::register_term(terminal_t &term, terminal_t &other_term)
+{
+ this->register_term(term);
+ m_connected_terminals.insert({&term, &other_term});
+}
+
void setup_t::remove_connections(const pstring &pin)
{
pstring pinfn = build_fqn(pin);
@@ -397,7 +398,7 @@ void setup_t::remove_connections(const pstring &pin)
if (!found)
{
log().fatal(MF_FOUND_NO_OCCURRENCE_OF_1(pin));
- plib::pthrow<nl_exception>(MF_FOUND_NO_OCCURRENCE_OF_1(pin));
+ throw nl_exception(MF_FOUND_NO_OCCURRENCE_OF_1(pin));
}
}
@@ -406,7 +407,7 @@ void setup_t::register_param_t(const pstring &name, param_t &param)
if (!m_params.insert({param.name(), param_ref_t(param.name(), param.device(), param)}).second)
{
log().fatal(MF_ADDING_PARAMETER_1_TO_PARAMETER_LIST(name));
- plib::pthrow<nl_exception>(MF_ADDING_PARAMETER_1_TO_PARAMETER_LIST(name));
+ throw nl_exception(MF_ADDING_PARAMETER_1_TO_PARAMETER_LIST(name));
}
}
@@ -502,7 +503,7 @@ detail::core_terminal_t *setup_t::find_terminal(const pstring &terminal_in, bool
if (term == nullptr && required)
{
log().fatal(MF_TERMINAL_1_2_NOT_FOUND(terminal_in, tname));
- plib::pthrow<nl_exception>(MF_TERMINAL_1_2_NOT_FOUND(terminal_in, tname));
+ throw nl_exception(MF_TERMINAL_1_2_NOT_FOUND(terminal_in, tname));
}
if (term != nullptr)
{
@@ -527,7 +528,7 @@ detail::core_terminal_t *setup_t::find_terminal(const pstring &terminal_in,
if (ret == m_terminals.end() && required)
{
log().fatal(MF_TERMINAL_1_2_NOT_FOUND(terminal_in, tname));
- plib::pthrow<nl_exception>(MF_TERMINAL_1_2_NOT_FOUND(terminal_in, tname));
+ throw nl_exception(MF_TERMINAL_1_2_NOT_FOUND(terminal_in, tname));
}
detail::core_terminal_t *term = (ret == m_terminals.end() ? nullptr : ret->second);
@@ -536,10 +537,10 @@ detail::core_terminal_t *setup_t::find_terminal(const pstring &terminal_in,
if (required)
{
log().fatal(MF_OBJECT_1_2_WRONG_TYPE(terminal_in, tname));
- plib::pthrow<nl_exception>(MF_OBJECT_1_2_WRONG_TYPE(terminal_in, tname));
+ throw nl_exception(MF_OBJECT_1_2_WRONG_TYPE(terminal_in, tname));
}
- else
- term = nullptr;
+
+ term = nullptr;
}
if (term != nullptr)
log().debug("Found input {1}\n", tname);
@@ -556,7 +557,7 @@ param_t *setup_t::find_param(const pstring &param_in, bool required) const
if (ret == m_params.end() && required)
{
log().fatal(MF_PARAMETER_1_2_NOT_FOUND(param_in_fqn, outname));
- plib::pthrow<nl_exception>(MF_PARAMETER_1_2_NOT_FOUND(param_in_fqn, outname));
+ throw nl_exception(MF_PARAMETER_1_2_NOT_FOUND(param_in_fqn, outname));
}
if (ret != m_params.end())
log().debug("Found parameter {1}\n", outname);
@@ -570,39 +571,38 @@ devices::nld_base_proxy *setup_t::get_d_a_proxy(detail::core_terminal_t &out)
auto &out_cast = static_cast<logic_output_t &>(out);
auto iter_proxy(m_proxies.find(&out));
- if (iter_proxy == m_proxies.end())
- {
- // create a new one ...
- pstring x = plib::pfmt("proxy_da_{1}_{2}")(out.name())(m_proxy_cnt);
- auto new_proxy =
- out_cast.logic_family()->create_d_a_proxy(m_nlstate, x, &out_cast);
- m_proxy_cnt++;
- // connect all existing terminals to new net
+ if (iter_proxy != m_proxies.end())
+ return iter_proxy->second;
- for (auto & p : out.net().core_terms())
+ // create a new one ...
+ pstring x = plib::pfmt("proxy_da_{1}_{2}")(out.name())(m_proxy_cnt);
+ auto new_proxy =
+ out_cast.logic_family()->create_d_a_proxy(m_nlstate, x, &out_cast);
+ m_proxy_cnt++;
+ // connect all existing terminals to new net
+
+ for (auto & p : out.net().core_terms())
+ {
+ p->clear_net(); // de-link from all nets ...
+ if (!connect(new_proxy->proxy_term(), *p))
{
- p->clear_net(); // de-link from all nets ...
- if (!connect(new_proxy->proxy_term(), *p))
- {
- log().fatal(MF_CONNECTING_1_TO_2(
- new_proxy->proxy_term().name(), (*p).name()));
- plib::pthrow<nl_exception>(MF_CONNECTING_1_TO_2(
- new_proxy->proxy_term().name(), (*p).name()));
- }
+ log().fatal(MF_CONNECTING_1_TO_2(
+ new_proxy->proxy_term().name(), (*p).name()));
+ throw nl_exception(MF_CONNECTING_1_TO_2(
+ new_proxy->proxy_term().name(), (*p).name()));
}
- out.net().core_terms().clear();
+ }
+ out.net().core_terms().clear();
- out.net().add_terminal(new_proxy->in());
+ out.net().add_terminal(new_proxy->in());
- auto proxy(new_proxy.get());
- if (!m_proxies.insert({&out, proxy}).second)
- plib::pthrow<nl_exception>(MF_DUPLICATE_PROXY_1(out.name()));
+ auto proxy(new_proxy.get());
+ if (!m_proxies.insert({&out, proxy}).second)
+ throw nl_exception(MF_DUPLICATE_PROXY_1(out.name()));
+
+ m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
+ return proxy;
- m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
- return proxy;
- }
- else
- return iter_proxy->second;
}
devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
@@ -615,42 +615,40 @@ devices::nld_base_proxy *setup_t::get_a_d_proxy(detail::core_terminal_t &inp)
if (iter_proxy != m_proxies.end())
return iter_proxy->second;
- else
- {
- log().debug("connect_terminal_input: connecting proxy\n");
- pstring x = plib::pfmt("proxy_ad_{1}_{2}")(inp.name())(m_proxy_cnt);
- auto new_proxy = incast.logic_family()->create_a_d_proxy(m_nlstate, x, &incast);
- //auto new_proxy = plib::owned_ptr<devices::nld_a_to_d_proxy>::Create(netlist(), x, &incast);
- auto ret(new_proxy.get());
+ log().debug("connect_terminal_input: connecting proxy\n");
+ pstring x = plib::pfmt("proxy_ad_{1}_{2}")(inp.name())(m_proxy_cnt);
+ auto new_proxy = incast.logic_family()->create_a_d_proxy(m_nlstate, x, &incast);
+ //auto new_proxy = plib::owned_ptr<devices::nld_a_to_d_proxy>::Create(netlist(), x, &incast);
- if (!m_proxies.insert({&inp, ret}).second)
- plib::pthrow<nl_exception>(MF_DUPLICATE_PROXY_1(inp.name()));
+ auto ret(new_proxy.get());
- m_proxy_cnt++;
+ if (!m_proxies.insert({&inp, ret}).second)
+ throw nl_exception(MF_DUPLICATE_PROXY_1(inp.name()));
- // connect all existing terminals to new net
+ m_proxy_cnt++;
- if (inp.has_net())
+ // connect all existing terminals to new net
+
+ if (inp.has_net())
+ {
+ for (auto & p : inp.net().core_terms())
{
- for (auto & p : inp.net().core_terms())
+ p->clear_net(); // de-link from all nets ...
+ if (!connect(ret->proxy_term(), *p))
{
- p->clear_net(); // de-link from all nets ...
- if (!connect(ret->proxy_term(), *p))
- {
- log().fatal(MF_CONNECTING_1_TO_2(
- ret->proxy_term().name(), (*p).name()));
- plib::pthrow<nl_exception>(MF_CONNECTING_1_TO_2(
- ret->proxy_term().name(), (*p).name()));
+ log().fatal(MF_CONNECTING_1_TO_2(
+ ret->proxy_term().name(), (*p).name()));
+ throw nl_exception(MF_CONNECTING_1_TO_2(
+ ret->proxy_term().name(), (*p).name()));
- }
}
- inp.net().core_terms().clear(); // clear the list
}
- ret->out().net().add_terminal(inp);
- m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
- return ret;
+ inp.net().core_terms().clear(); // clear the list
}
+ ret->out().net().add_terminal(inp);
+ m_nlstate.register_device(new_proxy->name(), std::move(new_proxy));
+ return ret;
}
detail::core_terminal_t &setup_t::resolve_proxy(detail::core_terminal_t &term)
@@ -677,7 +675,7 @@ void setup_t::merge_nets(detail::net_t &thisnet, detail::net_t &othernet)
if (thisnet.isRailNet() && othernet.isRailNet())
{
log().fatal(MF_MERGE_RAIL_NETS_1_AND_2(thisnet.name(), othernet.name()));
- plib::pthrow<nl_exception>(MF_MERGE_RAIL_NETS_1_AND_2(thisnet.name(), othernet.name()));
+ throw nl_exception(MF_MERGE_RAIL_NETS_1_AND_2(thisnet.name(), othernet.name()));
}
if (othernet.isRailNet())
@@ -737,7 +735,7 @@ void setup_t::connect_terminal_input(terminal_t &term, detail::core_terminal_t &
else
{
log().fatal(MF_OBJECT_INPUT_TYPE_1(inp.name()));
- plib::pthrow<nl_exception>(MF_OBJECT_INPUT_TYPE_1(inp.name()));
+ throw nl_exception(MF_OBJECT_INPUT_TYPE_1(inp.name()));
}
}
@@ -762,7 +760,7 @@ void setup_t::connect_terminal_output(terminal_t &in, detail::core_terminal_t &o
else
{
log().fatal(MF_OBJECT_OUTPUT_TYPE_1(out.name()));
- plib::pthrow<nl_exception>(MF_OBJECT_OUTPUT_TYPE_1(out.name()));
+ throw nl_exception(MF_OBJECT_OUTPUT_TYPE_1(out.name()));
}
}
@@ -844,7 +842,7 @@ bool setup_t::connect(detail::core_terminal_t &t1_in, detail::core_terminal_t &t
if (t2.has_net() && t2.net().isRailNet())
{
log().fatal(MF_INPUT_1_ALREADY_CONNECTED(t2.name()));
- plib::pthrow<nl_exception>(MF_INPUT_1_ALREADY_CONNECTED(t2.name()));
+ throw nl_exception(MF_INPUT_1_ALREADY_CONNECTED(t2.name()));
}
connect_input_output(t2, t1);
}
@@ -853,7 +851,7 @@ bool setup_t::connect(detail::core_terminal_t &t1_in, detail::core_terminal_t &t
if (t1.has_net() && t1.net().isRailNet())
{
log().fatal(MF_INPUT_1_ALREADY_CONNECTED(t1.name()));
- plib::pthrow<nl_exception>(MF_INPUT_1_ALREADY_CONNECTED(t1.name()));
+ throw nl_exception(MF_INPUT_1_ALREADY_CONNECTED(t1.name()));
}
connect_input_output(t1, t2);
}
@@ -895,7 +893,7 @@ void setup_t::resolve_inputs()
// after all other terminals were connected.
unsigned tries = m_netlist_params->m_max_link_loops();
- while (m_links.size() > 0 && tries > 0)
+ while (!m_links.empty() > 0 && tries > 0)
{
for (auto li = m_links.begin(); li != m_links.end(); )
@@ -919,7 +917,7 @@ void setup_t::resolve_inputs()
log().warning(MF_CONNECTING_1_TO_2(setup().de_alias(link.first), setup().de_alias(link.second)));
log().fatal(MF_LINK_TRIES_EXCEEDED(m_netlist_params->m_max_link_loops()));
- plib::pthrow<nl_exception>(MF_LINK_TRIES_EXCEEDED(m_netlist_params->m_max_link_loops()));
+ throw nl_exception(MF_LINK_TRIES_EXCEEDED(m_netlist_params->m_max_link_loops()));
}
log().verbose("deleting empty nets ...");
@@ -964,7 +962,7 @@ void setup_t::resolve_inputs()
if (err)
{
log().fatal(MF_TERMINALS_WITHOUT_NET());
- plib::pthrow<nl_exception>(MF_TERMINALS_WITHOUT_NET());
+ throw nl_exception(MF_TERMINALS_WITHOUT_NET());
}
}
@@ -1006,11 +1004,11 @@ void models_t::register_model(const pstring &model_in)
{
auto pos = model_in.find(' ');
if (pos == pstring::npos)
- plib::pthrow<nl_exception>(MF_UNABLE_TO_PARSE_MODEL_1(model_in));
+ throw nl_exception(MF_UNABLE_TO_PARSE_MODEL_1(model_in));
pstring model = plib::ucase(plib::trim(plib::left(model_in, pos)));
pstring def = plib::trim(model_in.substr(pos + 1));
if (!m_models.insert({model, def}).second)
- plib::pthrow<nl_exception>(MF_MODEL_ALREADY_EXISTS_1(model_in));
+ throw nl_exception(MF_MODEL_ALREADY_EXISTS_1(model_in));
}
void models_t::model_parse(const pstring &model_in, model_map_t &map)
@@ -1027,7 +1025,7 @@ void models_t::model_parse(const pstring &model_in, model_map_t &map)
key = plib::ucase(model);
auto i = m_models.find(key);
if (i == m_models.end())
- plib::pthrow<nl_exception>(MF_MODEL_NOT_FOUND(model));
+ throw nl_exception(MF_MODEL_NOT_FOUND(model));
model = i->second;
}
pstring xmodel = plib::left(model, pos);
@@ -1040,12 +1038,12 @@ void models_t::model_parse(const pstring &model_in, model_map_t &map)
if (i != m_models.end())
model_parse(xmodel, map);
else
- plib::pthrow<nl_exception>(MF_MODEL_NOT_FOUND(model_in));
+ throw nl_exception(MF_MODEL_NOT_FOUND(model_in));
}
pstring remainder = plib::trim(model.substr(pos + 1));
if (!plib::endsWith(remainder, ")"))
- plib::pthrow<nl_exception>(MF_MODEL_ERROR_1(model));
+ throw nl_exception(MF_MODEL_ERROR_1(model));
// FIMXE: Not optimal
remainder = plib::left(remainder, remainder.size() - 1);
@@ -1054,7 +1052,7 @@ void models_t::model_parse(const pstring &model_in, model_map_t &map)
{
auto pose = pe.find('=');
if (pose == pstring::npos)
- plib::pthrow<nl_exception>(MF_MODEL_ERROR_ON_PAIR_1(model));
+ throw nl_exception(MF_MODEL_ERROR_ON_PAIR_1(model));
map[plib::ucase(plib::left(pe, pose))] = pe.substr(pose + 1);
}
}
@@ -1073,26 +1071,22 @@ pstring models_t::value_str(const pstring &model, const pstring &entity)
{
model_map_t &map = m_cache[model];
- if (map.size() == 0)
+ if (map.empty())
model_parse(model , map);
- pstring ret;
-
if (entity != plib::ucase(entity))
- plib::pthrow<nl_exception>(MF_MODEL_PARAMETERS_NOT_UPPERCASE_1_2(entity, model_string(map)));
+ throw nl_exception(MF_MODEL_PARAMETERS_NOT_UPPERCASE_1_2(entity, model_string(map)));
if (map.find(entity) == map.end())
- plib::pthrow<nl_exception>(MF_ENTITY_1_NOT_FOUND_IN_MODEL_2(entity, model_string(map)));
- else
- ret = map[entity];
+ throw nl_exception(MF_ENTITY_1_NOT_FOUND_IN_MODEL_2(entity, model_string(map)));
- return ret;
+ return map[entity];
}
nl_fptype models_t::value(const pstring &model, const pstring &entity)
{
model_map_t &map = m_cache[model];
- if (map.size() == 0)
+ if (map.empty())
model_parse(model , map);
pstring tmp = value_str(model, entity);
@@ -1112,7 +1106,7 @@ nl_fptype models_t::value(const pstring &model, const pstring &entity)
case 'a': factor = nlconst::magic(1e-18); break;
default:
if (*p < '0' || *p > '9')
- plib::pthrow<nl_exception>(MF_UNKNOWN_NUMBER_FACTOR_IN_1(entity));
+ throw nl_exception(MF_UNKNOWN_NUMBER_FACTOR_IN_1(entity));
}
if (factor != nlconst::one())
tmp = plib::left(tmp, tmp.size() - 1);
@@ -1121,7 +1115,7 @@ nl_fptype models_t::value(const pstring &model, const pstring &entity)
bool err(false);
auto val = plib::pstonum_ne<nl_fptype>(tmp, err);
if (err)
- plib::pthrow<nl_exception>(MF_MODEL_NUMBER_CONVERSION_ERROR(entity, tmp, "double", model));
+ throw nl_exception(MF_MODEL_NUMBER_CONVERSION_ERROR(entity, tmp, "double", model));
return val * factor;
}
@@ -1159,7 +1153,6 @@ const logic_family_desc_t *setup_t::family_from_model(const pstring &model)
auto ret = plib::make_unique<logic_family_std_proxy_t>();
- ret->m_fixed_V = m_models.value(model, "FV");
ret->m_low_thresh_PCNT = m_models.value(model, "IVL");
ret->m_high_thresh_PCNT = m_models.value(model, "IVH");
ret->m_low_VO = m_models.value(model, "OVL");
@@ -1204,8 +1197,7 @@ void setup_t::delete_empty_nets()
x->state().run_state_manager().remove_save_items(x.get());
return true;
}
- else
- return false;
+ return false;
}), m_nlstate.nets().end());
}
@@ -1269,7 +1261,7 @@ void setup_t::prepare_to_run()
}
}
- bool use_deactivate = m_netlist_params->m_use_deactivate() ? true : false;
+ const bool use_deactivate = m_netlist_params->m_use_deactivate();
for (auto &d : m_nlstate.devices())
{
@@ -1284,7 +1276,7 @@ void setup_t::prepare_to_run()
if (err || plib::abs(v - plib::floor(v)) > nlconst::magic(1e-6) )
{
log().fatal(MF_HND_VAL_NOT_SUPPORTED(p->second));
- plib::pthrow<nl_exception>(MF_HND_VAL_NOT_SUPPORTED(p->second));
+ throw nl_exception(MF_HND_VAL_NOT_SUPPORTED(p->second));
}
// FIXME comparison with zero
d.second->set_hint_deactivate(v == nlconst::zero());
@@ -1318,7 +1310,7 @@ void setup_t::prepare_to_run()
if (p->is_analog())
{
log().fatal(MF_NO_SOLVER());
- plib::pthrow<nl_exception>(MF_NO_SOLVER());
+ throw nl_exception(MF_NO_SOLVER());
}
}
else
@@ -1340,10 +1332,7 @@ void setup_t::prepare_to_run()
bool source_netlist_t::parse(nlparse_t &setup, const pstring &name)
{
auto strm(stream(name));
- if (strm)
- return setup.parse_stream(std::move(strm), name);
- else
- return false;
+ return (strm) ? setup.parse_stream(std::move(strm), name) : false;
}
source_string_t::stream_ptr source_string_t::stream(const pstring &name)
@@ -1366,10 +1355,7 @@ source_file_t::stream_ptr source_file_t::stream(const pstring &name)
{
plib::unused_var(name);
auto ret(plib::make_unique<std::ifstream>(plib::filesystem::u8path(m_filename)));
- if (ret->is_open())
- return std::move(ret);
- else
- return stream_ptr(nullptr);
+ return (ret->is_open()) ? std::move(ret) : stream_ptr(nullptr);
}
bool source_proc_t::parse(nlparse_t &setup, const pstring &name)
@@ -1379,8 +1365,8 @@ bool source_proc_t::parse(nlparse_t &setup, const pstring &name)
m_setup_func(setup);
return true;
}
- else
- return false;
+
+ return false;
}
source_proc_t::stream_ptr source_proc_t::stream(const pstring &name)
diff --git a/src/lib/netlist/nl_setup.h b/src/lib/netlist/nl_setup.h
index c8f1b4b2250..42a517e20a2 100644
--- a/src/lib/netlist/nl_setup.h
+++ b/src/lib/netlist/nl_setup.h
@@ -53,10 +53,10 @@
setup.register_link_arr( # term1 ", " # __VA_ARGS__);
#define PARAM(name, val) \
- setup.register_param(# name, val);
+ setup.register_param(# name, # val);
#define HINT(name, val) \
- setup.register_param(# name ".HINT_" # val, 1);
+ setup.register_param(# name ".HINT_" # val, "1");
#define NETDEV_PARAMI(name, param, val) \
setup.register_param(# name "." # param, val);
@@ -88,7 +88,7 @@ void NETLIST_NAME(name)(netlist::nlparse_t &setup) \
setup.namespace_pop();
#define OPTIMIZE_FRONTIER(attach, r_in, r_out) \
- setup.register_frontier(# attach, r_in, r_out);
+ setup.register_frontier(# attach, PSTRINGIFY_VA(r_in), PSTRINGIFY_VA(r_out));
// -----------------------------------------------------------------------------
// truthtable defines
@@ -184,9 +184,7 @@ namespace netlist
friend class setup_t;
- source_netlist_t()
- : plib::psource_t()
- {}
+ source_netlist_t() = default;
COPYASSIGNMOVE(source_netlist_t, delete)
~source_netlist_t() noexcept override = default;
@@ -200,9 +198,7 @@ namespace netlist
friend class setup_t;
- source_data_t()
- : plib::psource_t()
- {}
+ source_data_t() = default;
COPYASSIGNMOVE(source_data_t, delete)
~source_data_t() noexcept override = default;
@@ -243,7 +239,7 @@ namespace netlist
public:
using link_t = std::pair<pstring, pstring>;
- nlparse_t(setup_t &netlist, log_type &log);
+ nlparse_t(setup_t &setup, log_type &log);
void register_model(const pstring &model_in) { m_models.register_model(model_in); }
void register_alias(const pstring &alias, const pstring &out);
@@ -261,11 +257,11 @@ namespace netlist
void register_param(const pstring &param, const pstring &value);
// FIXME: quick hack
- void register_param_x(const pstring &param, const nl_fptype value);
+ void register_param_x(const pstring &param, nl_fptype value);
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value || std::is_integral<T>::value>::type
- register_param(const pstring &param, T value)
+ register_param_val(const pstring &param, T value)
{
register_param_x(param, static_cast<nl_fptype>(value));
}
@@ -278,7 +274,7 @@ namespace netlist
#endif
void register_lib_entry(const pstring &name, const pstring &sourcefile);
- void register_frontier(const pstring &attach, const nl_fptype r_IN, const nl_fptype r_OUT);
+ void register_frontier(const pstring &attach, const pstring &r_IN, const pstring &r_OUT);
// register a source
void register_source(plib::unique_ptr<plib::psource_t> &&src)
@@ -385,6 +381,13 @@ namespace netlist
pstring get_initial_param_val(const pstring &name, const pstring &def) const;
void register_term(detail::core_terminal_t &term);
+ void register_term(terminal_t &term, terminal_t &other_term);
+
+ terminal_t *get_connected_terminal(const terminal_t &term) const noexcept
+ {
+ auto ret(m_connected_terminals.find(&term));
+ return (ret != m_connected_terminals.end()) ? ret->second : nullptr;
+ }
void remove_connections(const pstring &pin);
@@ -414,7 +417,7 @@ namespace netlist
const log_type &log() const;
// needed by proxy
- detail::core_terminal_t *find_terminal(const pstring &outname_in, const detail::terminal_type atype, bool required = true) const;
+ detail::core_terminal_t *find_terminal(const pstring &terminal_in, detail::terminal_type atype, bool required = true) const;
detail::core_terminal_t *find_terminal(const pstring &terminal_in, bool required = true) const;
// core net handling
@@ -436,13 +439,14 @@ namespace netlist
bool connect_input_input(detail::core_terminal_t &t1, detail::core_terminal_t &t2);
// helpers
- pstring termtype_as_str(detail::core_terminal_t &in) const;
+ static pstring termtype_as_str(detail::core_terminal_t &in);
devices::nld_base_proxy *get_d_a_proxy(detail::core_terminal_t &out);
devices::nld_base_proxy *get_a_d_proxy(detail::core_terminal_t &inp);
detail::core_terminal_t &resolve_proxy(detail::core_terminal_t &term);
std::unordered_map<pstring, detail::core_terminal_t *> m_terminals;
+ std::unordered_map<const terminal_t *, terminal_t *> m_connected_terminals;
netlist_state_t &m_nlstate;
devices::nld_netlistparams *m_netlist_params;
@@ -462,7 +466,7 @@ namespace netlist
public:
explicit source_string_t(const pstring &source)
- : source_netlist_t(), m_str(source)
+ : m_str(source)
{
}
@@ -478,7 +482,7 @@ namespace netlist
public:
explicit source_file_t(const pstring &filename)
- : source_netlist_t(), m_filename(filename)
+ : m_filename(filename)
{
}
@@ -493,7 +497,7 @@ namespace netlist
{
public:
explicit source_mem_t(const char *mem)
- : source_netlist_t(), m_str(mem)
+ : m_str(mem)
{
}
@@ -508,9 +512,8 @@ namespace netlist
{
public:
source_proc_t(const pstring &name, void (*setup_func)(nlparse_t &))
- : source_netlist_t(),
- m_setup_func(setup_func),
- m_setup_func_name(name)
+ : m_setup_func(setup_func)
+ , m_setup_func_name(name)
{
}
diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h
index af3ccd5828b..3794c160a57 100644
--- a/src/lib/netlist/nltypes.h
+++ b/src/lib/netlist/nltypes.h
@@ -100,19 +100,22 @@ namespace netlist
} // namespace detail
#if (PHAS_INT128)
- using netlist_time = ptime<INT128, NETLIST_INTERNAL_RES>;
+ //using netlist_time = plib::ptime<INT128, NETLIST_INTERNAL_RES>;
+ using netlist_time = plib::ptime<std::int64_t, NETLIST_INTERNAL_RES>;
+ using netlist_time_ext = plib::ptime<INT128, NETLIST_INTERNAL_RES>;
#else
using netlist_time = plib::ptime<std::int64_t, NETLIST_INTERNAL_RES>;
- static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr");
+ using netlist_time_ext = netlist_time;
#endif
+ static_assert(noexcept(netlist_time::from_nsec(1)), "Not evaluated as constexpr");
//============================================================
// MACROS
//============================================================
- template <typename T> inline constexpr const netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); }
- template <typename T> inline constexpr const netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); }
- template <typename T> inline constexpr const netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); }
+ template <typename T> inline constexpr netlist_time NLTIME_FROM_NS(T &&t) noexcept { return netlist_time::from_nsec(t); }
+ template <typename T> inline constexpr netlist_time NLTIME_FROM_US(T &&t) noexcept { return netlist_time::from_usec(t); }
+ template <typename T> inline constexpr netlist_time NLTIME_FROM_MS(T &&t) noexcept { return netlist_time::from_msec(t); }
} // namespace netlist
diff --git a/src/lib/netlist/plib/gmres.h b/src/lib/netlist/plib/gmres.h
index c1c03ea7bd9..d8d8bc63bbb 100644
--- a/src/lib/netlist/plib/gmres.h
+++ b/src/lib/netlist/plib/gmres.h
@@ -296,8 +296,7 @@ namespace plib
vec_add_mult_scalar(n, x, m_v[i], m_y[i]);
return true;
}
- else
- return false;
+ return false;
}
template <int k, typename OPS, typename VT>
diff --git a/src/lib/netlist/plib/mat_cr.h b/src/lib/netlist/plib/mat_cr.h
index 3208ceeed3f..e97da4e33d1 100644
--- a/src/lib/netlist/plib/mat_cr.h
+++ b/src/lib/netlist/plib/mat_cr.h
@@ -110,11 +110,11 @@ namespace plib
template <typename M>
void build_from_fill_mat(const M &f, std::size_t max_fill = FILL_INFINITY - 1,
- std::size_t band_width = FILL_INFINITY)
+ std::size_t band_width = FILL_INFINITY) noexcept(false)
{
C nz = 0;
if (nz_num != 0)
- pthrow<pexception>("build_from_mat only allowed on empty CR matrix");
+ throw pexception("build_from_mat only allowed on empty CR matrix");
for (std::size_t k=0; k < size(); k++)
{
row_idx[k] = nz;
@@ -177,7 +177,7 @@ namespace plib
// throws error if P(source)>P(destination)
template <typename LUMAT>
- void slim_copy_from(LUMAT & src)
+ void slim_copy_from(LUMAT & src) noexcept(false)
{
for (std::size_t r=0; r<src.size(); r++)
{
@@ -188,7 +188,7 @@ namespace plib
while (col_idx[dp] < src.col_idx[sp])
A[dp++] = 0;
if (row_idx[r+1] <= dp || col_idx[dp] != src.col_idx[sp])
- pthrow<pexception>("slim_copy_from error");
+ throw pexception("slim_copy_from error");
A[dp++] = src.A[sp];
}
// fill remaining elements in row
@@ -337,8 +337,8 @@ namespace plib
void gaussian_elimination_parallel(V & RHS)
{
//printf("omp: %ld %d %d\n", m_ge_par.size(), nz_num, (int)m_ge_par[m_ge_par.size()-2].size());
- for (auto l = 0ul; l < m_ge_par.size(); l++)
- plib::omp::for_static(base::nz_num, 0ul, m_ge_par[l].size(), [this, &RHS, &l] (unsigned ll)
+ for (auto l = 0UL; l < m_ge_par.size(); l++)
+ plib::omp::for_static(base::nz_num, 0UL, m_ge_par[l].size(), [this, &RHS, &l] (unsigned ll)
{
auto &i = m_ge_par[l][ll];
{
diff --git a/src/lib/netlist/plib/palloc.h b/src/lib/netlist/plib/palloc.h
index 5262d0c569d..035fbdb749d 100644
--- a/src/lib/netlist/plib/palloc.h
+++ b/src/lib/netlist/plib/palloc.h
@@ -9,6 +9,7 @@
///
#include "pconfig.h"
+#include "pmath.h"
#include "pstring.h"
#include "ptypes.h"
@@ -281,6 +282,9 @@ namespace plib {
static inline void *allocate( size_t alignment, size_t size )
{
+ m_stat_cur_alloc() += size;
+ m_stat_max_alloc() = std::max(m_stat_max_alloc(), m_stat_cur_alloc());
+
#if (PUSE_ALIGNED_ALLOCATION)
#if defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)
return _aligned_malloc(size, alignment);
@@ -301,7 +305,8 @@ namespace plib {
static inline void deallocate( void *ptr, size_t size ) noexcept
{
- unused_var(size);
+ //unused_var(size);
+ m_stat_cur_alloc() -= size;
#if (PUSE_ALIGNED_ALLOCATION)
// NOLINTNEXTLINE(cppcoreguidelines-no-malloc)
free(ptr);
@@ -342,12 +347,32 @@ namespace plib {
}
}
+ template<typename T, typename... Args>
+ static T *alloc(Args&&... args)
+ {
+ auto *p = allocate(alignof(T), sizeof(T));
+ return new(p) T(std::forward<Args>(args)...);
+ }
+
+ template<typename T>
+ static void free(T *ptr) noexcept
+ {
+ ptr->~T();
+ aligned_arena::deallocate(ptr, sizeof(T));
+ }
+
bool operator ==(const aligned_arena &rhs) const noexcept
{
plib::unused_var(rhs);
return true;
}
+ size_type cur_alloc() const noexcept { return m_stat_cur_alloc(); } // NOLINT(readability-convert-member-functions-to-static)
+ size_type max_alloc() const noexcept { return m_stat_max_alloc(); } // NOLINT(readability-convert-member-functions-to-static)
+ private:
+ static size_t &m_stat_cur_alloc() noexcept { static size_t val = 0; return val; }
+ static size_t &m_stat_max_alloc() noexcept { static size_t val = 0; return val; }
+
};
template <typename T, std::size_t ALIGN>
@@ -377,29 +402,13 @@ namespace plib {
#endif
}
- // FIXME: remove
- template<typename T, typename... Args>
- inline T *pnew(Args&&... args)
- {
- auto *p = aligned_arena::allocate(alignof(T), sizeof(T));
- return new(p) T(std::forward<Args>(args)...);
- }
-
- template<typename T>
- inline void pdelete(T *ptr) noexcept
- {
- ptr->~T();
- aligned_arena::deallocate(ptr, sizeof(T));
- }
-
-
template <typename T>
- using unique_ptr = std::unique_ptr<T, arena_deleter<aligned_arena, T>>;
+ using unique_ptr = aligned_arena::unique_pool_ptr<T>;
template<typename T, typename... Args>
plib::unique_ptr<T> make_unique(Args&&... args)
{
- return plib::unique_ptr<T>(pnew<T>(std::forward<Args>(args)...));
+ return aligned_arena::instance().make_unique<T>(std::forward<Args>(args)...);
}
template <class T, std::size_t ALIGN = alignof(T)>
diff --git a/src/lib/netlist/plib/parray.h b/src/lib/netlist/plib/parray.h
index c60698d10e1..05f3b0ce3f4 100644
--- a/src/lib/netlist/plib/parray.h
+++ b/src/lib/netlist/plib/parray.h
@@ -76,21 +76,21 @@ namespace plib {
}
template <int X = SIZE >
- parray(size_type size, typename std::enable_if<(X != 0), int>::type = 0)
+ parray(size_type size, typename std::enable_if<(X != 0), int>::type = 0) noexcept(false)
: m_size(size)
{
if ((SIZE < 0 && size > SIZEABS())
|| (SIZE > 0 && size != SIZEABS()))
- pthrow<pexception>("parray: size error " + plib::to_string(size) + ">" + plib::to_string(SIZE));
+ throw pexception("parray: size error " + plib::to_string(size) + ">" + plib::to_string(SIZE));
}
template <int X = SIZE >
- parray(size_type size, FT val, typename std::enable_if<(X != 0), int>::type = 0)
+ parray(size_type size, FT val, typename std::enable_if<(X != 0), int>::type = 0) noexcept(false)
: m_size(size)
{
if ((SIZE < 0 && size > SIZEABS())
|| (SIZE > 0 && size != SIZEABS()))
- pthrow<plib::pexception>("parray: size error " + plib::to_string(size) + ">" + plib::to_string(SIZE));
+ throw pexception("parray: size error " + plib::to_string(size) + ">" + plib::to_string(SIZE));
m_a.fill(val);
}
@@ -107,13 +107,13 @@ namespace plib {
parray(const parray &rhs) : m_a(rhs.m_a), m_size(rhs.m_size) {}
parray(parray &&rhs) noexcept : m_a(std::move(rhs.m_a)), m_size(std::move(rhs.m_size)) {}
- parray &operator=(const parray &rhs) noexcept
+ parray &operator=(const parray &rhs) noexcept // NOLINT(bugprone-unhandled-self-assignment, cert-oop54-cpp)
{
- if (this != &rhs)
- {
- m_a = rhs.m_a;
- m_size = rhs.m_size;
- }
+ if (this == &rhs)
+ return *this;
+
+ m_a = rhs.m_a;
+ m_size = rhs.m_size;
return *this;
}
diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h
index f08c9c025ea..115eafd2196 100644
--- a/src/lib/netlist/plib/pconfig.h
+++ b/src/lib/netlist/plib/pconfig.h
@@ -25,7 +25,7 @@
/// \brief System supports INT128
///
/// Set this to one if you want to use 128 bit int for ptime.
-/// This is about 5% slower on a kaby lake processor.
+/// This is about 10% slower on a skylake processor for pongf.
///
#ifndef PHAS_INT128
#define PHAS_INT128 (0)
diff --git a/src/lib/netlist/plib/pexception.h b/src/lib/netlist/plib/pexception.h
index 22b67925b7e..703e407eae7 100644
--- a/src/lib/netlist/plib/pexception.h
+++ b/src/lib/netlist/plib/pexception.h
@@ -30,19 +30,6 @@ namespace plib {
[[noreturn]] void passert_fail(const char *assertion,
const char *file, int lineno, const char *msg) noexcept;
- /// \brief throw an exception.
- ///
- /// throws an exception E. The purpose is to clearly identify exception
- /// throwing in the code
- ///
- /// \tparam E Type of exception to be thrown
- ///
- template<typename E, typename... Args>
- [[noreturn]] static inline void pthrow(Args&&... args) noexcept(false)
- {
- throw E(std::forward<Args>(args)...);
- }
-
//============================================================
// exception base
//============================================================
diff --git a/src/lib/netlist/plib/pfmtlog.h b/src/lib/netlist/plib/pfmtlog.h
index 86761096caf..f73e83c2ca2 100644
--- a/src/lib/netlist/plib/pfmtlog.h
+++ b/src/lib/netlist/plib/pfmtlog.h
@@ -412,7 +412,7 @@ namespace plib {
struct perrmsg
{
template<std::size_t N, typename... Args>
- explicit perrmsg(const char (&fmt)[N], Args&&... args)
+ explicit perrmsg(const char (&fmt)[N], Args&&... args) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
: m_msg(plib::pfmt(fmt)(std::forward<Args>(args)...))
{ }
operator pstring const & () const noexcept { return m_msg; }
diff --git a/src/lib/netlist/plib/pfunction.cpp b/src/lib/netlist/plib/pfunction.cpp
index dee38f86416..f05a92ad339 100644
--- a/src/lib/netlist/plib/pfunction.cpp
+++ b/src/lib/netlist/plib/pfunction.cpp
@@ -15,7 +15,7 @@
namespace plib {
template <typename NT>
- void pfunction<NT>::compile(const pstring &expr, const std::vector<pstring> &inputs)
+ void pfunction<NT>::compile(const pstring &expr, const std::vector<pstring> &inputs) noexcept(false)
{
if (plib::startsWith(expr, "rpn:"))
compile_postfix(expr.substr(4), inputs);
@@ -24,7 +24,7 @@ namespace plib {
}
template <typename NT>
- void pfunction<NT>::compile_postfix(const pstring &expr, const std::vector<pstring> &inputs)
+ void pfunction<NT>::compile_postfix(const pstring &expr, const std::vector<pstring> &inputs) noexcept(false)
{
std::vector<pstring> cmds(plib::psplit(expr, " "));
compile_postfix(inputs, cmds, expr);
@@ -32,7 +32,7 @@ namespace plib {
template <typename NT>
void pfunction<NT>::compile_postfix(const std::vector<pstring> &inputs,
- const std::vector<pstring> &cmds, const pstring &expr)
+ const std::vector<pstring> &cmds, const pstring &expr) noexcept(false)
{
m_precompiled.clear();
int stk = 0;
@@ -76,38 +76,38 @@ namespace plib {
bool err(false);
rc.m_param = plib::pstonum_ne<decltype(rc.m_param)>(cmd, err);
if (err)
- pthrow<pexception>(plib::pfmt("pfunction: unknown/misformatted token <{1}> in <{2}>")(cmd)(expr));
+ throw pexception(plib::pfmt("pfunction: unknown/misformatted token <{1}> in <{2}>")(cmd)(expr));
stk += 1;
}
}
if (stk < 1)
- pthrow<pexception>(plib::pfmt("pfunction: stack underflow on token <{1}> in <{2}>")(cmd)(expr));
+ throw pexception(plib::pfmt("pfunction: stack underflow on token <{1}> in <{2}>")(cmd)(expr));
m_precompiled.push_back(rc);
}
if (stk != 1)
- pthrow<pexception>(plib::pfmt("pfunction: stack count different to one on <{2}>")(expr));
+ throw pexception(plib::pfmt("pfunction: stack count different to one on <{2}>")(expr));
}
static int get_prio(const pstring &v)
{
if (v == "(" || v == ")")
return 1;
- else if (plib::left(v, 1) >= "a" && plib::left(v, 1) <= "z")
+ if (plib::left(v, 1) >= "a" && plib::left(v, 1) <= "z")
return 0;
- else if (v == "*" || v == "/")
+ if (v == "*" || v == "/")
return 20;
- else if (v == "+" || v == "-")
+ if (v == "+" || v == "-")
return 10;
- else if (v == "^")
+ if (v == "^")
return 30;
- else
- return -1;
+
+ return -1;
}
- static pstring pop_check(std::stack<pstring> &stk, const pstring &expr)
+ static pstring pop_check(std::stack<pstring> &stk, const pstring &expr) noexcept(false)
{
- if (stk.size() == 0)
- pthrow<pexception>(plib::pfmt("pfunction: stack underflow during infix parsing of: <{1}>")(expr));
+ if (stk.empty())
+ throw pexception(plib::pfmt("pfunction: stack underflow during infix parsing of: <{1}>")(expr));
pstring res = stk.top();
stk.pop();
return res;
@@ -183,7 +183,7 @@ namespace plib {
postfix.push_back(x);
x = pop_check(opstk, expr);
}
- if (opstk.size() > 0 && get_prio(opstk.top()) == 0)
+ if (!opstk.empty() && get_prio(opstk.top()) == 0)
postfix.push_back(pop_check(opstk, expr));
}
else if (s==",")
@@ -200,7 +200,7 @@ namespace plib {
int p = get_prio(s);
if (p>0)
{
- if (opstk.size() == 0)
+ if (opstk.empty())
opstk.push(s);
else
{
@@ -211,7 +211,7 @@ namespace plib {
}
else if (p == 0) // Function or variable
{
- if (sexpr[i+1] == "(")
+ if ((i+1<sexpr.size()) && sexpr[i+1] == "(")
opstk.push(s);
else
postfix.push_back(s);
@@ -220,7 +220,7 @@ namespace plib {
postfix.push_back(s);
}
}
- while (opstk.size() > 0)
+ while (!opstk.empty())
{
postfix.push_back(opstk.top());
opstk.pop();
@@ -238,8 +238,8 @@ namespace plib {
std::uint16_t lsb = lfsr & 1;
lfsr >>= 1;
if (lsb)
- lfsr ^= 0xB400u; // taps 15, 13, 12, 10
- return static_cast<NT>(lfsr) / static_cast<NT>(0xffffu);
+ lfsr ^= 0xB400U; // taps 15, 13, 12, 10
+ return static_cast<NT>(lfsr) / static_cast<NT>(0xffffU);
}
template <typename NT>
@@ -249,7 +249,7 @@ namespace plib {
std::uint16_t lsb = lfsr & 1;
lfsr >>= 1;
if (lsb)
- lfsr ^= 0xB400u; // taps 15, 13, 12, 10
+ lfsr ^= 0xB400U; // taps 15, 13, 12, 10
return static_cast<NT>(lfsr);
}
diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h
index c6e94614856..cab5a78a983 100644
--- a/src/lib/netlist/plib/pfunction.h
+++ b/src/lib/netlist/plib/pfunction.h
@@ -58,7 +58,7 @@ namespace plib {
///
///
pfunction(const pstring &name, const void *owner, state_manager_t &state_manager)
- : m_lfsr(0xACE1u)
+ : m_lfsr(0xace1U)
{
state_manager.save_item(owner, m_lfsr, name + ".lfsr");
}
@@ -66,7 +66,7 @@ namespace plib {
/// \brief Constructor without state saving support
///
pfunction()
- : m_lfsr(0xACE1u)
+ : m_lfsr(0xace1U)
{
}
@@ -76,21 +76,21 @@ namespace plib {
/// to be prefixed with rpn, e.g. "rpn:A B + 1.3 /"
/// \param inputs Vector of input variables, e.g. {"A","B"}
///
- void compile(const pstring &expr, const std::vector<pstring> &inputs);
+ void compile(const pstring &expr, const std::vector<pstring> &inputs) noexcept(false);
/// \brief Compile a rpn expression
///
/// \param expr Reverse polish notation expression, e.g. "A B + 1.3 /"
/// \param inputs Vector of input variables, e.g. {"A","B"}
///
- void compile_postfix(const pstring &expr, const std::vector<pstring> &inputs);
+ void compile_postfix(const pstring &expr, const std::vector<pstring> &inputs) noexcept(false);
/// \brief Compile an infix expression
///
/// \param expr Infix expression, e.g. "(A+B)/1.3"
/// \param inputs Vector of input variables, e.g. {"A","B"}
///
- void compile_infix(const pstring &expr, const std::vector<pstring> &inputs);
+ void compile_infix(const pstring &expr, const std::vector<pstring> &inputs) noexcept(false);
/// \brief Evaluate the expression
///
diff --git a/src/lib/netlist/plib/plists.h b/src/lib/netlist/plib/plists.h
index 5f2c7b6706d..a5340193b3c 100644
--- a/src/lib/netlist/plib/plists.h
+++ b/src/lib/netlist/plib/plists.h
@@ -133,10 +133,12 @@ namespace plib {
constexpr iter_t(iter_t &rhs) noexcept : p(rhs.p) { }
iter_t(iter_t &&rhs) noexcept { std::swap(*this, rhs); }
- iter_t& operator=(const iter_t &rhs) noexcept
+ iter_t& operator=(const iter_t &rhs) noexcept // NOLINT(bugprone-unhandled-self-assignment, cert-oop54-cpp)
{
- if (this != &rhs)
- p = rhs.p;
+ if (this == &rhs)
+ return *this;
+
+ p = rhs.p;
return *this;
}
@@ -156,7 +158,7 @@ namespace plib {
C14CONSTEXPR LC* operator->() const noexcept { return p; }
};
- constexpr linkedlist_t() : m_head(nullptr) {}
+ constexpr linkedlist_t() noexcept : m_head(nullptr) {}
constexpr iter_t begin() const noexcept { return iter_t(m_head); }
constexpr iter_t end() const noexcept { return iter_t(nullptr); }
@@ -326,7 +328,7 @@ namespace plib {
m_prof_call.inc();
}
- T pop() noexcept { return *(--m_end); }
+ void pop() noexcept { --m_end; }
const T &top() const noexcept { return *(m_end-1); }
template <bool KEEPSTAT, class R>
@@ -461,8 +463,7 @@ namespace plib {
if (*i == elem)
{
m_end--;
- for (;i < m_end; i++)
- *i = std::move(*(i+1));
+ *i = *m_end;
std::make_heap(&m_list[0], m_end, compare());
return;
}
diff --git a/src/lib/netlist/plib/pmain.cpp b/src/lib/netlist/plib/pmain.cpp
index d603baeb474..b002d4dcb5e 100644
--- a/src/lib/netlist/plib/pmain.cpp
+++ b/src/lib/netlist/plib/pmain.cpp
@@ -5,7 +5,7 @@
#ifdef _WIN32
#include <windows.h>
-#include <string.h>
+#include <cstring>
#include <tchar.h>
#endif
@@ -26,8 +26,7 @@ namespace plib {
#endif
app::app()
- : options()
- , pout(&std::cout)
+ : pout(&std::cout)
, perr(&std::cerr)
{
diff --git a/src/lib/netlist/plib/pmath.h b/src/lib/netlist/plib/pmath.h
index 9738994770d..e995c3a6c27 100644
--- a/src/lib/netlist/plib/pmath.h
+++ b/src/lib/netlist/plib/pmath.h
@@ -9,6 +9,7 @@
///
#include "pconfig.h"
+#include "ptypes.h"
#include <algorithm>
#include <cmath>
@@ -75,7 +76,7 @@ namespace plib
/// later.
///
template <typename V>
- static inline constexpr const T magic(V &&v) noexcept { return static_cast<T>(v); }
+ static inline constexpr T magic(V &&v) noexcept { return static_cast<T>(v); }
};
/// \brief typesafe reciprocal function
@@ -329,7 +330,92 @@ namespace plib
#endif
- static_assert(noexcept(constants<double>::one()) == true, "Not evaluated as constexpr");
+ /// \brief is argument a power of two?
+ ///
+ /// \tparam T type of the argument
+ /// \param v argument to be checked
+ /// \return true if argument is a power of two
+ ///
+ template <typename T>
+ constexpr bool is_pow2(T v) noexcept
+ {
+ static_assert(is_integral<T>::value, "is_pow2 needs integer arguments");
+ return !(v & (v-1));
+ }
+
+ /// \brief return absolute value of signed argument
+ ///
+ /// \tparam T type of the argument
+ /// \param v argument
+ /// \return absolute value of argument
+ ///
+ template<typename T>
+ constexpr
+ typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value, T>::type
+ abs(T v) noexcept
+ {
+ return v < 0 ? -v : v;
+ }
+
+ /// \brief return absolute value of unsigned argument
+ ///
+ /// \tparam T type of the argument
+ /// \param v argument
+ /// \return argument since it has no sign
+ ///
+ template<typename T>
+ constexpr
+ typename std::enable_if<std::is_integral<T>::value && std::is_unsigned<T>::value, T>::type
+ abs(T v) noexcept
+ {
+ return v;
+ }
+
+ /// \brief return greatest common denominator
+ ///
+ /// Function returns the greatest common denominator of m and n. For known
+ /// arguments, this function also works at compile time.
+ ///
+ /// \tparam M type of the first argument
+ /// \tparam N type of the second argument
+ /// \param m first argument
+ /// \param n first argument
+ /// \return greatest common denominator of m and n
+ ///
+ template<typename M, typename N>
+ constexpr typename std::common_type<M, N>::type
+ gcd(M m, N n) noexcept
+ {
+ static_assert(std::is_integral<M>::value, "gcd: M must be an integer");
+ static_assert(std::is_integral<N>::value, "gcd: N must be an integer");
+
+ return m == 0 ? plib::abs(n)
+ : n == 0 ? plib::abs(m)
+ : gcd(n, m % n);
+ }
+
+ /// \brief return least common multiple
+ ///
+ /// Function returns the least common multiple of m and n. For known
+ /// arguments, this function also works at compile time.
+ ///
+ /// \tparam M type of the first argument
+ /// \tparam N type of the second argument
+ /// \param m first argument
+ /// \param n first argument
+ /// \return least common multiple of m and n
+ ///
+ template<typename M, typename N>
+ constexpr typename std::common_type<M, N>::type
+ lcm(M m, N n) noexcept
+ {
+ static_assert(std::is_integral<M>::value, "lcm: M must be an integer");
+ static_assert(std::is_integral<N>::value, "lcm: N must be an integer");
+
+ return (m != 0 && n != 0) ? (plib::abs(m) / gcd(m, n)) * plib::abs(n) : 0;
+ }
+
+ static_assert(noexcept(constants<double>::one()), "Not evaluated as constexpr");
} // namespace plib
diff --git a/src/lib/netlist/plib/pmempool.h b/src/lib/netlist/plib/pmempool.h
index 1e197fdfc82..a06c67acd8e 100644
--- a/src/lib/netlist/plib/pmempool.h
+++ b/src/lib/netlist/plib/pmempool.h
@@ -59,7 +59,7 @@ namespace plib {
plib::perrlogger("Found {} info blocks\n", sinfo().size());
plib::perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc);
}
- plib::pdelete(b);
+ aligned_arena::free(b);
//::operator delete(b->m_data);
}
}
@@ -126,7 +126,7 @@ namespace plib {
plib::terminate("mempool::free - block not found");
mp.m_blocks.erase(itb);
- plib::pdelete(b);
+ aligned_arena::free(b);
}
sinfo().erase(it);
}
@@ -222,15 +222,13 @@ namespace plib {
size_type m_pos;
};
-
block * new_block(size_type min_bytes)
{
- auto *b = plib::pnew<block>(*this, min_bytes);
+ auto *b = aligned_arena::alloc<block>(*this, min_bytes);
m_blocks.push_back(b);
return b;
}
-
static std::unordered_map<void *, info> &sinfo()
{
static std::unordered_map<void *, info> spinfo;
diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp
index 6f6ace0599c..fd683d888d8 100644
--- a/src/lib/netlist/plib/poptions.cpp
+++ b/src/lib/netlist/plib/poptions.cpp
@@ -75,15 +75,13 @@ namespace plib {
{
if (m_other_args != nullptr)
{
- pthrow<pexception>("other args can only be specified once!");
- }
- else
- {
- m_other_args = ov;
+ throw pexception("other args can only be specified once!");
}
+
+ m_other_args = ov;
}
else
- pthrow<pexception>("found option with neither short or long tag!" );
+ throw pexception("found option with neither short or long tag!" );
}
}
}
@@ -105,7 +103,7 @@ namespace plib {
if (!seen_other_args && plib::startsWith(arg, "--"))
{
auto v = psplit(arg.substr(2),"=");
- if (v.size() && v[0] != "")
+ if (!v.empty() && v[0] != "")
{
opt = getopt_long(v[0]);
has_equal_arg = (v.size() > 1);
diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h
index 15f43e0330e..26edebb727e 100644
--- a/src/lib/netlist/plib/poptions.h
+++ b/src/lib/netlist/plib/poptions.h
@@ -139,8 +139,8 @@ namespace plib {
m_val = static_cast<T>(raw);
return 0;
}
- else
- return 1;
+
+ return 1;
}
private:
@@ -236,7 +236,7 @@ namespace plib {
static pstring split_paragraphs(const pstring &text, unsigned width, unsigned indent,
unsigned firstline_indent);
- void check_consistency();
+ void check_consistency() noexcept(false);
template <typename T>
T *getopt_type() const
diff --git a/src/lib/netlist/plib/ppmf.h b/src/lib/netlist/plib/ppmf.h
index bbbe95ded05..a9df2f6b4aa 100644
--- a/src/lib/netlist/plib/ppmf.h
+++ b/src/lib/netlist/plib/ppmf.h
@@ -273,7 +273,7 @@ namespace plib {
#endif
}
template<typename O>
- R call(O *obj, Targs... args) const noexcept(true)
+ R call(O *obj, Targs&&... args) const noexcept(true)
{
using function_ptr = MEMBER_ABI R (*)(O *obj, Targs... args);
return (reinterpret_cast<function_ptr>(m_func))(obj, std::forward<Targs>(args)...);
@@ -311,7 +311,7 @@ namespace plib {
m_obj = reinterpret_cast<generic_class *>(object);
}
- inline R operator()(Targs ... args) const noexcept(true)
+ inline R operator()(Targs... args) const noexcept(true)
{
return this->call(m_obj, std::forward<Targs>(args)...);
}
diff --git a/src/lib/netlist/plib/ppreprocessor.cpp b/src/lib/netlist/plib/ppreprocessor.cpp
index 377c37d9fca..74d32fcd477 100644
--- a/src/lib/netlist/plib/ppreprocessor.cpp
+++ b/src/lib/netlist/plib/ppreprocessor.cpp
@@ -56,14 +56,14 @@ namespace plib {
pstring e = plib::pfmt("{1}:{2}:0: error: {3}\n")
(m_stack.back().m_name, m_stack.back().m_lineno, err);
m_stack.pop_back();
- while (m_stack.size() > 0)
+ while (!m_stack.empty())
{
if (m_stack.size() == 1)
trail = trail_first;
s = trail + plib::pfmt("{1}:{2}:0\n")(m_stack.back().m_name, m_stack.back().m_lineno) + s;
m_stack.pop_back();
}
- pthrow<pexception>("\n" + s + e + " " + m_line + "\n");
+ throw pexception("\n" + s + e + " " + m_line + "\n");
}
template <typename PP, typename L = ppreprocessor::string_list>
@@ -226,7 +226,6 @@ namespace plib {
{
pstring s(STR);
pi++;
- // FIXME : \"
while (pi < tmp.size() && tmp[pi] != STR)
{
s += tmp[pi];
@@ -236,38 +235,51 @@ namespace plib {
tmpret.push_back(s);
}
else
- if (!remove_ws || (tmp[pi] != " " && tmp[pi] != "\t"))
- tmpret.push_back(tmp[pi]);
+ {
+ pstring tok=tmp[pi];
+ if (tok.size() >= 2 && pi < tmp.size() - 2 )
+ {
+ auto sc=tok.substr(0,1);
+ auto ec=tok.substr(tok.size()-1, 1);
+ if ((sc == "." || (sc>="0" && sc<="9")) && (ec=="e" || ec=="E"))
+ {
+ // looks like an incomplete float due splitting by - or +
+ tok = tok + tmp[pi+1] + tmp[pi+2];
+ pi += 2;
+ }
+ }
+ if (!remove_ws || (tok != " " && tok != "\t"))
+ tmpret.push_back(tok);
+ }
pi++;
}
+
if (!concat)
return tmpret;
- else
+
+ // FIXME: error if concat at beginning or end
+ string_list ret;
+ pi = 0;
+ while (pi<tmpret.size())
{
- // FIXME: error if concat at beginning or end
- string_list ret;
- pi = 0;
- while (pi<tmpret.size())
+ if (tmpret[pi] == "##")
{
- if (tmpret[pi] == "##")
- {
- while (ret.back() == " " || ret.back() == "\t")
- ret.pop_back();
- pstring cc = ret.back();
+ while (ret.back() == " " || ret.back() == "\t")
ret.pop_back();
- pi++;
- while (pi < tmpret.size() && (tmpret[pi] == " " || tmpret[pi] == "\t"))
- pi++;
- if (pi == tmpret.size())
- error("## found at end of sequence");
- ret.push_back(cc + tmpret[pi]);
- }
- else
- ret.push_back(tmpret[pi]);
+ pstring cc = ret.back();
+ ret.pop_back();
pi++;
+ while (pi < tmpret.size() && (tmpret[pi] == " " || tmpret[pi] == "\t"))
+ pi++;
+ if (pi == tmpret.size())
+ error("## found at end of sequence");
+ ret.push_back(cc + tmpret[pi]);
}
- return ret;
+ else
+ ret.push_back(tmpret[pi]);
+ pi++;
}
+ return ret;
}
bool ppreprocessor::is_valid_token(const pstring &str)
@@ -441,7 +453,6 @@ namespace plib {
line = process_comments(m_line);
pstring lt = plib::trim(plib::replace_all(line, "\t", " "));
- // FIXME ... revise and extend macro handling
if (plib::startsWith(lt, "#"))
{
string_list lti(psplit(lt, " ", true));
@@ -449,7 +460,6 @@ namespace plib {
{
m_if_level++;
lt = replace_macros(lt);
- //std::vector<pstring> t(psplit(replace_all(lt.substr(3), " ", ""), m_expr_sep));
auto t(simple_iter<ppreprocessor>(this, tokenize(lt.substr(3), m_expr_sep, true, true)));
auto val = static_cast<int>(prepro_expr(t, 255));
t.skip_ws();
diff --git a/src/lib/netlist/plib/ppreprocessor.h b/src/lib/netlist/plib/ppreprocessor.h
index 892015b7f5a..fe498fc1148 100644
--- a/src/lib/netlist/plib/ppreprocessor.h
+++ b/src/lib/netlist/plib/ppreprocessor.h
@@ -77,7 +77,7 @@ namespace plib {
return *this;
}
- [[noreturn]] void error(const pstring &err);
+ [[noreturn]] void error(const pstring &err) noexcept(false);
protected:
diff --git a/src/lib/netlist/plib/pstate.h b/src/lib/netlist/plib/pstate.h
index 71db3b97bb6..d4156d09b02 100644
--- a/src/lib/netlist/plib/pstate.h
+++ b/src/lib/netlist/plib/pstate.h
@@ -162,7 +162,7 @@ public:
}
}
- const std::vector<const entry_t *> save_list() const
+ std::vector<const entry_t *> save_list() const
{
std::vector<const entry_t *> ret;
for (auto &i : m_save)
diff --git a/src/lib/netlist/plib/pstonum.h b/src/lib/netlist/plib/pstonum.h
index eed69e85883..737dca9f471 100644
--- a/src/lib/netlist/plib/pstonum.h
+++ b/src/lib/netlist/plib/pstonum.h
@@ -95,7 +95,7 @@ namespace plib
#endif
template<typename T, typename S>
- T pstonum(const S &arg, const std::locale &loc = std::locale::classic())
+ T pstonum(const S &arg, const std::locale &loc = std::locale::classic()) noexcept(false)
{
decltype(arg.c_str()) cstr = arg.c_str();
std::size_t idx(0);
@@ -106,11 +106,11 @@ namespace plib
//&& (ret == T(0) || plib::abs(ret) >= std::numeric_limits<T>::min() ))
{
if (cstr[idx] != 0)
- pthrow<pexception>(pstring("Continuation after numeric value ends: ") + pstring(cstr));
+ throw pexception(pstring("Continuation after numeric value ends: ") + pstring(cstr));
}
else
{
- pthrow<pexception>(pstring("Out of range: ") + pstring(cstr));
+ throw pexception(pstring("Out of range: ") + pstring(cstr));
}
return static_cast<T>(ret);
}
diff --git a/src/lib/netlist/plib/pstream.h b/src/lib/netlist/plib/pstream.h
index 4425842882c..ea19d673931 100644
--- a/src/lib/netlist/plib/pstream.h
+++ b/src/lib/netlist/plib/pstream.h
@@ -69,7 +69,7 @@ public:
{
if (c == 10)
break;
- else if (c != 13) // ignore CR
+ if (c != 13) // ignore CR
m_linebuf += putf8string(1, c);
if (!this->readcode(c))
break;
@@ -83,9 +83,7 @@ public:
if (m_strm->eof())
return false;
m_strm->read(&b, 1);
- if (m_strm->eof())
- return false;
- return true;
+ return (!m_strm->eof());
}
bool readcode(putf8string::traits_type::code_t &c)
@@ -170,8 +168,7 @@ class putf8_fmt_writer : public pfmt_writer_t<putf8_fmt_writer>, public putf8_wr
public:
explicit putf8_fmt_writer(std::ostream *strm)
- : pfmt_writer_t()
- , putf8_writer(strm)
+ : putf8_writer(strm)
{
}
diff --git a/src/lib/netlist/plib/pstring.cpp b/src/lib/netlist/plib/pstring.cpp
index b6ec39c25ed..a7b18cd7e17 100644
--- a/src/lib/netlist/plib/pstring.cpp
+++ b/src/lib/netlist/plib/pstring.cpp
@@ -14,9 +14,9 @@ int pstring_t<F>::compare(const pstring_t &right) const noexcept
{
if (mem_t_size() == 0 && right.mem_t_size() == 0)
return 0;
- else if (right.mem_t_size() == 0)
+ if (right.mem_t_size() == 0)
return 1;
- else if (mem_t_size() == 0)
+ if (mem_t_size() == 0)
return -1;
auto si = this->begin();
@@ -29,9 +29,9 @@ int pstring_t<F>::compare(const pstring_t &right) const noexcept
if (si != this->end() && ri != right.end())
return static_cast<int>(*si) - static_cast<int>(*ri);
- else if (this->mem_t_size() > right.mem_t_size())
+ if (this->mem_t_size() > right.mem_t_size())
return 1;
- else if (this->mem_t_size() < right.mem_t_size())
+ if (this->mem_t_size() < right.mem_t_size())
return -1;
return 0;
}
diff --git a/src/lib/netlist/plib/pstring.h b/src/lib/netlist/plib/pstring.h
index 4a9d99300bb..86b041cadaf 100644
--- a/src/lib/netlist/plib/pstring.h
+++ b/src/lib/netlist/plib/pstring.h
@@ -111,7 +111,7 @@ public:
template<typename C, std::size_t N,
class = typename std::enable_if<std::is_same<C, const mem_t>::value>::type>
- pstring_t(C (&string)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
+ pstring_t(C (&string)[N]) noexcept(false) // NOLINT(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
{
static_assert(N > 0,"pstring from array of length 0");
// need std::exception since pexception depends on pstring
@@ -174,7 +174,7 @@ public:
size_type length() const noexcept { return traits_type::len(m_str); }
size_type size() const noexcept { return traits_type::len(m_str); }
- bool empty() const noexcept { return m_str.size() == 0; }
+ bool empty() const noexcept { return m_str.empty(); }
pstring_t substr(size_type start, size_type nlen = npos) const;
int compare(const pstring_t &right) const noexcept;
@@ -186,8 +186,8 @@ public:
pstring_t& operator+=(const pstring_t &string) { m_str.append(string.m_str); return *this; }
pstring_t& operator+=(const code_t c) { traits_type::encode(c, m_str); return *this; }
friend pstring_t operator+(const pstring_t &lhs, const pstring_t &rhs) { return pstring_t(lhs) += rhs; }
- friend pstring_t operator+(const pstring_t &lhs, const code_t rhs) { return pstring_t(lhs) += rhs; }
- friend pstring_t operator+(const code_t lhs, const pstring_t &rhs) { return pstring_t(1, lhs) += rhs; }
+ friend pstring_t operator+(const pstring_t &lhs, code_t rhs) { return pstring_t(lhs) += rhs; }
+ friend pstring_t operator+(code_t lhs, const pstring_t &rhs) { return pstring_t(1, lhs) += rhs; }
// comparison operators
bool operator==(const pstring_t &string) const noexcept { return (compare(string) == 0); }
@@ -317,7 +317,9 @@ struct putf8_traits
const mem_t *p1 = p;
std::size_t i = n;
while (i-- > 0)
+ {
p1 += codelen(p1);
+ }
return p1;
}
};
@@ -336,7 +338,9 @@ struct putf16_traits
// FIXME: check that size is equal
auto c = static_cast<uint16_t>(*i++);
if (!((c & 0xd800) == 0xd800))
+ {
ret++;
+ }
}
return ret;
}
@@ -347,10 +351,7 @@ struct putf16_traits
}
static std::size_t codelen(const code_t c) noexcept
{
- if (c < 0x10000)
- return 1;
- else // U+10000 U+1FFFFF
- return 2;
+ return (c < 0x10000) ? 1 : 2; // U+10000 U+1FFFFF
}
static code_t code(const mem_t *p) noexcept
{
@@ -381,7 +382,9 @@ struct putf16_traits
{
std::size_t i = n;
while (i-- > 0)
+ {
p += codelen(p);
+ }
return p;
}
};
diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h
index 214f121c2df..7168477f49f 100644
--- a/src/lib/netlist/plib/ptime.h
+++ b/src/lib/netlist/plib/ptime.h
@@ -8,6 +8,8 @@
/// \file ptime.h
///
+#include <type_traits>
+
#include "pconfig.h"
#include "pmath.h" // std::floor
#include "ptypes.h"
@@ -19,6 +21,19 @@
namespace plib
{
+ template <typename T, typename U>
+ struct ptime_le
+ {
+ const static bool value = sizeof(T) <= sizeof(U);
+ };
+
+#if 0
+ template<typename T, typename U>
+ struct ptime_res {
+ using type = typename std::conditional<sizeof(T) >= sizeof(U), T, U>::type;
+ };
+#endif
+
template <typename TYPE, TYPE RES>
struct ptime final
{
@@ -27,6 +42,9 @@ namespace plib
using internal_type = TYPE;
using mult_type = TYPE;
+ template <typename altTYPE, altTYPE altRES>
+ friend struct ptime;
+
constexpr ptime() noexcept : m_time(0) {}
~ptime() noexcept = default;
@@ -43,56 +61,88 @@ namespace plib
constexpr explicit ptime(const internal_type nom, const internal_type den) noexcept
: m_time(nom * (RES / den)) { }
- C14CONSTEXPR ptime &operator+=(const ptime &rhs) noexcept { m_time += rhs.m_time; return *this; }
- C14CONSTEXPR ptime &operator-=(const ptime &rhs) noexcept { m_time -= rhs.m_time; return *this; }
- C14CONSTEXPR ptime &operator*=(const mult_type factor) noexcept { m_time *= static_cast<internal_type>(factor); return *this; }
+ // FIXME: check for overflow
+ template <typename O>
+ constexpr explicit ptime(const ptime<O, RES> &rhs) noexcept
+ : m_time(rhs.m_time) { }
- friend constexpr const ptime operator-(ptime lhs, const ptime rhs) noexcept
+ template <typename O>
+ C14CONSTEXPR ptime &operator+=(const ptime<O, RES> &rhs) noexcept
+ {
+ static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
+ m_time += rhs.m_time;
+ return *this;
+ }
+ template <typename O>
+ C14CONSTEXPR ptime &operator-=(const ptime<O, RES> &rhs) noexcept
{
- return ptime(lhs.m_time - rhs.m_time);
+ static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
+ m_time -= rhs.m_time;
+ return *this;
}
- friend constexpr const ptime operator+(ptime lhs, const ptime rhs) noexcept
+ template <typename M>
+ C14CONSTEXPR ptime &operator*=(const M &factor) noexcept
{
- return ptime(lhs.m_time + rhs.m_time);
+ static_assert(plib::is_integral<M>::value, "Factor must be an integral type");
+ m_time *= factor;
+ return *this;
}
- friend constexpr const ptime operator*(ptime lhs, const mult_type factor) noexcept
+ template <typename O>
+ constexpr ptime operator-(const ptime<O, RES> &rhs) const noexcept
{
- return ptime(lhs.m_time * factor);
+ static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
+ return ptime(m_time - rhs.m_time);
}
- friend constexpr mult_type operator/(const ptime lhs, const ptime rhs) noexcept
+ template <typename O>
+ constexpr ptime operator+(const ptime<O, RES> &rhs) const noexcept
{
- return static_cast<mult_type>(lhs.m_time / rhs.m_time);
+ static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
+ return ptime(m_time + rhs.m_time);
}
- friend constexpr bool operator<(const ptime lhs, const ptime rhs) noexcept
+ template <typename M>
+ constexpr ptime operator*(const M &factor) const noexcept
+ {
+ static_assert(plib::is_integral<M>::value, "Factor must be an integral type");
+ return ptime(m_time * static_cast<mult_type>(factor));
+ }
+
+ template <typename O>
+ constexpr mult_type operator/(const ptime<O, RES> &rhs) const noexcept
+ {
+ static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type");
+ return static_cast<mult_type>(m_time / rhs.m_time);
+ }
+
+ friend constexpr bool operator<(const ptime &lhs, const ptime &rhs) noexcept
{
return (lhs.m_time < rhs.m_time);
}
- friend constexpr bool operator>(const ptime lhs, const ptime rhs) noexcept
+ friend constexpr bool operator>(const ptime &lhs, const ptime &rhs) noexcept
{
return (rhs < lhs);
}
- friend constexpr bool operator<=(const ptime lhs, const ptime rhs) noexcept
+ friend constexpr bool operator<=(const ptime &lhs, const ptime &rhs) noexcept
{
return !(lhs > rhs);
}
- friend constexpr bool operator>=(const ptime lhs, const ptime rhs) noexcept
+ friend constexpr bool operator>=(const ptime &lhs, const ptime &rhs) noexcept
{
return !(lhs < rhs);
}
- friend constexpr bool operator==(const ptime lhs, const ptime rhs) noexcept
+ friend constexpr bool operator==(const ptime &lhs, const ptime &rhs) noexcept
{
return lhs.m_time == rhs.m_time;
}
- friend constexpr bool operator!=(const ptime lhs, const ptime rhs) noexcept
+ friend constexpr bool operator!=(const ptime &lhs, const ptime &rhs) noexcept
{
return !(lhs == rhs);
}
@@ -118,37 +168,41 @@ namespace plib
constexpr double as_float() const noexcept { return as_fp<float>(); }
constexpr double as_long_double() const noexcept { return as_fp<long double>(); }
+
+ constexpr ptime shl(unsigned shift) const noexcept { return ptime(m_time << shift); }
+ constexpr ptime shr(unsigned shift) const noexcept { return ptime(m_time >> shift); }
+
// for save states ....
C14CONSTEXPR internal_type *get_internaltype_ptr() noexcept { return &m_time; }
- static constexpr const ptime from_nsec(const internal_type ns) noexcept { return ptime(ns, UINT64_C(1000000000)); }
- static constexpr const ptime from_usec(const internal_type us) noexcept { return ptime(us, UINT64_C( 1000000)); }
- static constexpr const ptime from_msec(const internal_type ms) noexcept { return ptime(ms, UINT64_C( 1000)); }
- static constexpr const ptime from_sec(const internal_type s) noexcept { return ptime(s, UINT64_C( 1)); }
- static constexpr const ptime from_hz(const internal_type hz) noexcept { return ptime(1 , hz); }
- static constexpr const ptime from_raw(const internal_type raw) noexcept { return ptime(raw); }
+ static constexpr ptime from_nsec(internal_type ns) noexcept { return ptime(ns, UINT64_C(1000000000)); }
+ static constexpr ptime from_usec(internal_type us) noexcept { return ptime(us, UINT64_C( 1000000)); }
+ static constexpr ptime from_msec(internal_type ms) noexcept { return ptime(ms, UINT64_C( 1000)); }
+ static constexpr ptime from_sec(internal_type s) noexcept { return ptime(s, UINT64_C( 1)); }
+ static constexpr ptime from_hz(internal_type hz) noexcept { return ptime(1 , hz); }
+ static constexpr ptime from_raw(internal_type raw) noexcept { return ptime(raw); }
template <typename FT>
- static constexpr const typename std::enable_if<std::is_floating_point<FT>::value
+ static constexpr typename std::enable_if<std::is_floating_point<FT>::value
#if PUSE_FLOAT128
|| std::is_same<FT, __float128>::value
#endif
, ptime>::type
- from_fp(const FT t) noexcept { return ptime(static_cast<internal_type>(plib::floor(t * static_cast<FT>(RES) + static_cast<FT>(0.5))), RES); }
+ from_fp(FT t) noexcept { return ptime(static_cast<internal_type>(plib::floor(t * static_cast<FT>(RES) + static_cast<FT>(0.5))), RES); }
- static constexpr const ptime from_double(const double t) noexcept
+ static constexpr ptime from_double(double t) noexcept
{ return from_fp<double>(t); }
- static constexpr const ptime from_float(const float t) noexcept
+ static constexpr ptime from_float(float t) noexcept
{ return from_fp<float>(t); }
- static constexpr const ptime from_long_double(const long double t) noexcept
+ static constexpr ptime from_long_double(long double t) noexcept
{ return from_fp<long double>(t); }
- static constexpr const ptime zero() noexcept { return ptime(0, RES); }
- static constexpr const ptime quantum() noexcept { return ptime(1, RES); }
- static constexpr const ptime never() noexcept { return ptime(plib::numeric_limits<internal_type>::max(), RES); }
- static constexpr const internal_type resolution() noexcept { return RES; }
+ static constexpr ptime zero() noexcept { return ptime(0, RES); }
+ static constexpr ptime quantum() noexcept { return ptime(1, RES); }
+ static constexpr ptime never() noexcept { return ptime(plib::numeric_limits<internal_type>::max(), RES); }
+ static constexpr internal_type resolution() noexcept { return RES; }
constexpr internal_type in_nsec() const noexcept { return m_time / (RES / UINT64_C(1000000000)); }
constexpr internal_type in_usec() const noexcept { return m_time / (RES / UINT64_C( 1000000)); }
@@ -161,7 +215,6 @@ namespace plib
internal_type m_time;
};
-
} // namespace plib
diff --git a/src/lib/netlist/plib/ptokenizer.cpp b/src/lib/netlist/plib/ptokenizer.cpp
index a29b3342333..7ccb0ff8ca2 100644
--- a/src/lib/netlist/plib/ptokenizer.cpp
+++ b/src/lib/netlist/plib/ptokenizer.cpp
@@ -292,7 +292,7 @@ namespace plib {
pstring e = plib::pfmt("{1}:{2}:0: error: {3}\n")
(m_source_location.back().file_name(), m_source_location.back().line(), errs());
m_source_location.pop_back();
- while (m_source_location.size() > 0)
+ while (!m_source_location.empty())
{
if (m_source_location.size() == 1)
trail = trail_first;
diff --git a/src/lib/netlist/plib/ptokenizer.h b/src/lib/netlist/plib/ptokenizer.h
index 773df365bed..42858aa76e4 100644
--- a/src/lib/netlist/plib/ptokenizer.h
+++ b/src/lib/netlist/plib/ptokenizer.h
@@ -66,11 +66,11 @@ namespace plib {
struct token_t
{
explicit token_t(token_type type)
- : m_type(type), m_id(), m_token("")
+ : m_type(type), m_token("")
{
}
token_t(token_type type, const pstring &str)
- : m_type(type), m_id(), m_token(str)
+ : m_type(type), m_token(str)
{
}
token_t(const token_id_t &id, const pstring &str)
diff --git a/src/lib/netlist/plib/ptypes.h b/src/lib/netlist/plib/ptypes.h
index 7619faa1348..32ec6e7f9bf 100644
--- a/src/lib/netlist/plib/ptypes.h
+++ b/src/lib/netlist/plib/ptypes.h
@@ -82,58 +82,6 @@ namespace plib
template<typename... Ts>
inline void unused_var(Ts&&...) noexcept {}
- //============================================================
- // is_pow2
- //============================================================
- template <typename T>
- constexpr bool is_pow2(T v) noexcept
- {
- static_assert(is_integral<T>::value, "is_pow2 needs integer arguments");
- return !(v & (v-1));
- }
-
- //============================================================
- // abs, lcd, gcm
- //============================================================
-
- template<typename T>
- constexpr
- typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value, T>::type
- abs(T v) noexcept
- {
- return v < 0 ? -v : v;
- }
-
- template<typename T>
- constexpr
- typename std::enable_if<std::is_integral<T>::value && std::is_unsigned<T>::value, T>::type
- abs(T v) noexcept
- {
- return v;
- }
-
- template<typename M, typename N>
- constexpr typename std::common_type<M, N>::type
- gcd(M m, N n) noexcept
- {
- static_assert(std::is_integral<M>::value, "gcd: M must be an integer");
- static_assert(std::is_integral<N>::value, "gcd: N must be an integer");
-
- return m == 0 ? plib::abs(n)
- : n == 0 ? plib::abs(m)
- : gcd(n, m % n);
- }
-
- template<typename M, typename N>
- constexpr typename std::common_type<M, N>::type
- lcm(M m, N n) noexcept
- {
- static_assert(std::is_integral<M>::value, "lcm: M must be an integer");
- static_assert(std::is_integral<N>::value, "lcm: N must be an integer");
-
- return (m != 0 && n != 0) ? (plib::abs(m) / gcd(m, n)) * plib::abs(n) : 0;
- }
-
} // namespace plib
//============================================================
diff --git a/src/lib/netlist/plib/putil.cpp b/src/lib/netlist/plib/putil.cpp
index 986f5eb75ec..3ab92b97162 100644
--- a/src/lib/netlist/plib/putil.cpp
+++ b/src/lib/netlist/plib/putil.cpp
@@ -23,10 +23,7 @@ namespace plib
pstring basename(const pstring &filename)
{
auto p=find_last_of(filename, pstring(1, PATH_SEP));
- if (p == pstring::npos)
- return filename;
- else
- return filename.substr(p+1);
+ return (p == pstring::npos) ? filename : filename.substr(p+1);
}
pstring path(const pstring &filename)
@@ -34,10 +31,10 @@ namespace plib
auto p=find_last_of(filename, pstring(1, PATH_SEP));
if (p == pstring::npos)
return "";
- else if (p == 0) // root case
+ if (p == 0) // root case
return filename.substr(0, 1);
- else
- return filename.substr(0, p);
+
+ return filename.substr(0, p);
}
pstring buildpath(std::initializer_list<pstring> list )
@@ -55,10 +52,8 @@ namespace plib
pstring environment(const pstring &var, const pstring &default_val)
{
- if (std::getenv(var.c_str()) == nullptr)
- return default_val;
- else
- return pstring(std::getenv(var.c_str()));
+ return (std::getenv(var.c_str()) == nullptr) ? default_val
+ : pstring(std::getenv(var.c_str()));
}
} // namespace util
@@ -94,7 +89,7 @@ namespace plib
std::vector<std::string> result;
std::size_t splits = 0;
- while(str.size())
+ while(!str.empty())
{
std::size_t index = str.rfind(token);
bool found = index!=std::string::npos;
@@ -104,7 +99,7 @@ namespace plib
{
result.push_back(str.substr(index+token.size()));
str = str.substr(0, index);
- if (str.size()==0)
+ if (str.empty())
result.push_back(str);
}
else
diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h
index 22abf637f87..b5fe06efb61 100644
--- a/src/lib/netlist/plib/putil.h
+++ b/src/lib/netlist/plib/putil.h
@@ -19,12 +19,31 @@
#define PSTRINGIFY_HELP(y) # y
#define PSTRINGIFY(x) PSTRINGIFY_HELP(x)
-#define PNARGS_(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N
-#define PNARGS(...) PNARGS_(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
+// Discussion and background of this MSVC bug: https://github.com/mamedev/mame/issues/6106
+///
+/// \brief Macro to work around a bug in MSVC treatment of __VA_ARGS__
+///
+#define PMSVC_VARARG_BUG(MACRO, ARGS) MACRO ARGS
-#define PCONCAT_(a, b) a ## b
+/// \brief Determine number of arguments in __VA_ARGS__
+///
+/// This macro works up to 16 arguments in __VA_ARGS__
+///
+/// \returns Number of arguments
+///
+#define PNARGS(...) PNARGS_1(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
+
+#define PNARGS_2(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N
+#define PNARGS_1(...) PMSVC_VARARG_BUG(PNARGS_2, (__VA_ARGS__))
+
+/// \brief Concatenate two arguments after expansion
+///
+/// \returns Concatenated expanded arguments
+///
#define PCONCAT(a, b) PCONCAT_(a, b)
+#define PCONCAT_(a, b) a ## b
+
#define PSTRINGIFY_1(x) #x
#define PSTRINGIFY_2(x, x2) #x, #x2
#define PSTRINGIFY_3(x, ...) #x, PSTRINGIFY_2(__VA_ARGS__)
@@ -42,7 +61,13 @@
#define PSTRINGIFY_15(x, ...) #x, PSTRINGIFY_14(__VA_ARGS__)
#define PSTRINGIFY_16(x, ...) #x, PSTRINGIFY_15(__VA_ARGS__)
-#define PSTRINGIFY_VA(...) PCONCAT(PSTRINGIFY_, PNARGS(__VA_ARGS__))(__VA_ARGS__)
+/// \brief Individually stringify up to 16 arguments
+///
+/// PSTRINGIFY_VA(a, b, c) will be expanded to "a", "b", "c"
+///
+/// \returns List of stringified individual arguments
+///
+#define PSTRINGIFY_VA(...) PMSVC_VARARG_BUG(PCONCAT, (PSTRINGIFY_, PNARGS(__VA_ARGS__)))(__VA_ARGS__)
// FIXME:: __FUNCTION__ may be not be supported by all compilers.
@@ -131,10 +156,8 @@ namespace plib
typename TS::stream_ptr stream(const pstring &name) override
{
- if (name == m_name)
- return plib::make_unique<std::stringstream>(m_str);
- else
- return typename TS::stream_ptr(nullptr);
+ return (name == m_name) ?
+ plib::make_unique<std::stringstream>(m_str) : typename TS::stream_ptr(nullptr);
}
private:
pstring m_name;
@@ -254,7 +277,7 @@ namespace plib
std::vector<pstring> psplit(const pstring &str, const std::vector<pstring> &onstrl);
std::vector<std::string> psplit_r(const std::string &stri,
const std::string &token,
- const std::size_t maxsplit);
+ std::size_t maxsplit);
//============================================================
// penum - strongly typed enumeration
@@ -276,7 +299,8 @@ namespace plib
template <typename T> explicit ename(T val) { m_v = static_cast<E>(val); } \
bool set_from_string (const pstring &s) { \
int f = from_string_int(strings(), s); \
- if (f>=0) { m_v = static_cast<E>(f); return true; } else { return false; } \
+ if (f>=0) { m_v = static_cast<E>(f); return true; } \
+ return false;\
} \
operator E() const noexcept {return m_v;} \
bool operator==(const ename &rhs) const noexcept {return m_v == rhs.m_v;} \
diff --git a/src/lib/netlist/plib/vector_ops.h b/src/lib/netlist/plib/vector_ops.h
index a34a9bf8a54..71cb540fcc9 100644
--- a/src/lib/netlist/plib/vector_ops.h
+++ b/src/lib/netlist/plib/vector_ops.h
@@ -76,15 +76,13 @@ namespace plib
return value;
}
- else
- {
- using b8 = std::array<T, 8>;
- PALIGNAS_VECTOROPT() b8 value = {0};
- for (std::size_t i = 0; i < n ; i++ )
- value[i & 7] += v[i];
- return ((value[0] + value[1]) + (value[2] + value[3])) + ((value[4] + value[5]) + (value[6] + value[7]));
- }
+ using b8 = std::array<T, 8>;
+ PALIGNAS_VECTOROPT() b8 value = {0};
+ for (std::size_t i = 0; i < n ; i++ )
+ value[i & 7] += v[i];
+
+ return ((value[0] + value[1]) + (value[2] + value[3])) + ((value[4] + value[5]) + (value[6] + value[7]));
}
template<typename VV, typename T, typename VR>
diff --git a/src/lib/netlist/prg/nltool.cpp b/src/lib/netlist/prg/nltool.cpp
index 440c958711d..0f9d1088076 100644
--- a/src/lib/netlist/prg/nltool.cpp
+++ b/src/lib/netlist/prg/nltool.cpp
@@ -23,8 +23,6 @@
#include <ios>
#include <iostream> // scanf
-#define NLTOOL_VERSION 20190420
-
class tool_app_t : public plib::app
{
public:
@@ -121,7 +119,7 @@ public:
{
pstring res = plib::pfmt(fmt)(std::forward<ARGS>(args)...);
auto lines(plib::psplit(res, "\n", false));
- if (lines.size() == 0)
+ if (lines.empty())
pout(prefix + "\n");
else
for (auto &l : lines)
@@ -136,7 +134,7 @@ private:
void convert();
void static_compile();
- void mac_out(const pstring &s, const bool cont = true);
+ void mac_out(const pstring &s, bool cont = true);
void header_entry(const netlist::factory::element_t *e);
void mac(const netlist::factory::element_t *e);
@@ -165,8 +163,7 @@ class netlist_data_folder_t : public netlist::source_data_t
{
public:
explicit netlist_data_folder_t(const pstring &folder)
- : netlist::source_data_t()
- , m_folder(folder)
+ : m_folder(folder)
{
}
@@ -176,11 +173,9 @@ public:
auto strm(plib::make_unique<std::ifstream>(plib::filesystem::u8path(name)));
if (strm->fail())
return stream_ptr(nullptr);
- else
- {
- strm->imbue(std::locale::classic());
- return std::move(strm);
- }
+
+ strm->imbue(std::locale::classic());
+ return std::move(strm);
}
private:
@@ -191,8 +186,7 @@ class netlist_tool_callbacks_t : public netlist::callbacks_t
{
public:
explicit netlist_tool_callbacks_t(tool_app_t &app)
- : netlist::callbacks_t()
- , m_app(app)
+ : m_app(app)
{ }
void vlog(const plib::plog_level &l, const pstring &ls) const noexcept override;
@@ -224,8 +218,24 @@ public:
for (auto & r : roms)
setup().register_source(plib::make_unique<netlist_data_folder_t>(r));
+#if 0
using a = plib::psource_str_t<plib::psource_t>;
+#if USE_EVAL
+ const pstring content =
+ "#define RES_R(res) (res) \n"
+ "#define RES_K(res) ((res) * 1e3) \n"
+ "#define RES_M(res) ((res) * 1e6) \n"
+ "#define CAP_U(cap) ((cap) * 1e-6) \n"
+ "#define CAP_N(cap) ((cap) * 1e-9) \n"
+ "#define CAP_P(cap) ((cap) * 1e-12) \n"
+ "#define IND_U(ind) ((ind) * 1e-6) \n"
+ "#define IND_N(ind) ((ind) * 1e-9) \n"
+ "#define IND_P(ind) ((ind) * 1e-12) \n";
+ setup().add_include(plib::make_unique<a>("netlist/devices/net_lib.h", content));
+#else
setup().add_include(plib::make_unique<a>("netlist/devices/net_lib.h",""));
+#endif
+#endif
for (auto & i : includes)
setup().add_include(plib::make_unique<netlist_data_folder_t>(i));
@@ -277,7 +287,7 @@ public:
size += s->dt().size() * s->count();
if (buf.size() != size)
- plib::pthrow<netlist::nl_exception>("Size different during load state.");
+ throw netlist::nl_exception("Size different during load state.");
char *p = buf.data();
@@ -323,9 +333,9 @@ struct input_t
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
int e = std::sscanf(line.c_str(), "%lf,%[^,],%lf", &t, buf.data(), &val);
if (e != 3)
- plib::pthrow<netlist::nl_exception>(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
+ throw netlist::nl_exception(plib::pfmt("error {1} scanning line {2}\n")(e)(line));
m_value = static_cast<nl_fptype>(val);
- m_time = netlist::netlist_time::from_fp(t);
+ m_time = netlist::netlist_time_ext::from_fp(t);
m_param = setup.find_param(pstring(buf.data()), true);
}
@@ -335,7 +345,7 @@ struct input_t
{
case netlist::param_t::STRING:
case netlist::param_t::POINTER:
- plib::pthrow<netlist::nl_exception>(plib::pfmt("param {1} is not numeric\n")(m_param->name()));
+ throw netlist::nl_exception(plib::pfmt("param {1} is not numeric\n")(m_param->name()));
case netlist::param_t::DOUBLE:
static_cast<netlist::param_fp_t*>(m_param)->setTo(m_value);
break;
@@ -348,7 +358,7 @@ struct input_t
}
}
- netlist::netlist_time m_time;
+ netlist::netlist_time_ext m_time;
netlist::param_t *m_param;
nl_fptype m_value;
};
@@ -360,7 +370,7 @@ static std::vector<input_t> read_input(const netlist::setup_t &setup, const pstr
{
plib::putf8_reader r = plib::putf8_reader(std::ifstream(plib::filesystem::u8path(fname)));
if (r.stream().fail())
- plib::pthrow<netlist::nl_exception>(netlist::MF_FILE_OPEN_ERROR(fname));
+ throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(fname));
r.stream().imbue(std::locale::classic());
pstring l;
while (r.readline(l))
@@ -379,7 +389,7 @@ void tool_app_t::run()
{
plib::chrono::timer<plib::chrono::system_ticks> t;
std::vector<input_t> inps;
- netlist::netlist_time ttr;
+ netlist::netlist_time_ext ttr;
netlist_tool_t nt(*this, "netlist");
{
@@ -400,7 +410,7 @@ void tool_app_t::run()
nt.exec().reset();
inps = read_input(nt.setup(), opt_inp());
- ttr = netlist::netlist_time::from_fp(opt_ttr());
+ ttr = netlist::netlist_time_ext::from_fp(opt_ttr());
}
@@ -408,7 +418,7 @@ void tool_app_t::run()
t.reset();
- netlist::netlist_time nlt = nt.exec().time();
+ netlist::netlist_time_ext nlt = nt.exec().time();
{
auto t_guard(t.guard());
@@ -417,7 +427,7 @@ void tool_app_t::run()
{
std::ifstream strm(plib::filesystem::u8path(opt_loadstate()));
if (strm.fail())
- plib::pthrow<netlist::nl_exception>(netlist::MF_FILE_OPEN_ERROR(opt_loadstate()));
+ throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(opt_loadstate()));
strm.imbue(std::locale::classic());
plib::pbinary_reader reader(strm);
std::vector<char> loadstate;
@@ -455,7 +465,7 @@ void tool_app_t::run()
auto savestate = nt.save_state();
std::ofstream strm(plib::filesystem::u8path(opt_savestate()), std::ios_base::binary);
if (strm.fail())
- plib::pthrow<plib::file_open_e>(opt_savestate());
+ throw plib::file_open_e(opt_savestate());
strm.imbue(std::locale::classic());
plib::pbinary_writer writer(strm);
@@ -503,14 +513,14 @@ void tool_app_t::validate()
//pout("Validation errors: {}\n", m_errors);
if (m_warnings + m_errors > 0)
- plib::pthrow<netlist::nl_exception>("validation: {1} errors {2} warnings", m_errors, m_warnings);
+ throw netlist::nl_exception("validation: {1} errors {2} warnings", m_errors, m_warnings);
}
void tool_app_t::static_compile()
{
if (!opt_dir.was_specified())
- plib::pthrow<netlist::nl_exception>("--dir option needs to be specified");
+ throw netlist::nl_exception("--dir option needs to be specified");
netlist_tool_t nt(*this, "netlist");
@@ -570,7 +580,7 @@ static doc_ext read_docsrc(const pstring &fname, const pstring &id)
//printf("file %s\n", fname.c_str());
plib::putf8_reader r = plib::putf8_reader(std::ifstream(plib::filesystem::u8path(fname)));
if (r.stream().fail())
- plib::pthrow<netlist::nl_exception>(netlist::MF_FILE_OPEN_ERROR(fname));
+ throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(fname));
r.stream().imbue(std::locale::classic());
doc_ext ret;
@@ -586,8 +596,8 @@ static doc_ext read_docsrc(const pstring &fname, const pstring &id)
if (l != "")
{
auto a(plib::psplit(l, ":", true));
- if ((a.size() < 1) || (a.size() > 2))
- plib::pthrow<netlist::nl_exception>(l+" size mismatch");
+ if (a.empty() || (a.size() > 2))
+ throw netlist::nl_exception(l+" size mismatch");
pstring n(plib::trim(a[0]));
pstring v(a.size() < 2 ? "" : plib::trim(a[1]));
if (n == "Identifier")
@@ -623,11 +633,11 @@ static doc_ext read_docsrc(const pstring &fname, const pstring &id)
else if (n == "Example")
{
ret.example = plib::psplit(plib::trim(v),",",true);
- if (ret.example.size() != 2 && ret.example.size() != 0)
- plib::pthrow<netlist::nl_exception>("Example requires 2 parameters, but found {1}", ret.example.size());
+ if (ret.example.size() != 2 && !ret.example.empty())
+ throw netlist::nl_exception("Example requires 2 parameters, but found {1}", ret.example.size());
}
else
- plib::pthrow<netlist::nl_exception>(n);
+ throw netlist::nl_exception(n);
}
}
}
@@ -677,16 +687,12 @@ void tool_app_t::header_entry(const netlist::factory::element_t *e)
for (const auto &s : v)
{
- pstring r(plib::replace_all(plib::replace_all(plib::replace_all(s, "+", ""), ".", "_"), "@",""));
- if (plib::startsWith(s, "+"))
- vs += ", p" + r;
- else if (plib::startsWith(s, "@"))
+ if (!plib::startsWith(s, "@"))
{
- // automatically connected
- //mac_out("\tNET_CONNECT(name, " + r + ", " + r + ")");
- }
- else
+ // @ gets automatically connected
+ const pstring r(plib::replace_all(plib::replace_all(plib::replace_all(s, "+", ""), ".", "_"), "@",""));
vs += ", p" + r;
+ }
}
mac_out("\tNET_REGISTER_DEVEXT(" + e->name() +", name" + vs + ")", false);
@@ -702,7 +708,7 @@ void tool_app_t::mac(const netlist::factory::element_t *e)
vs += ", " + plib::replace_all(plib::replace_all(s, "+", ""), ".", "_");
pout("{1}(name{2})\n", e->name(), vs);
- if (v.size() > 0)
+ if (!v.empty())
{
pout("/*\n");
for (const auto &s : v)
@@ -833,7 +839,7 @@ void tool_app_t::create_docheader()
poutprefix("///", " @section {}_2 Connection Diagram", d.id);
poutprefix("///", "");
- if (d.pinalias.size() > 0)
+ if (!d.pinalias.empty())
{
poutprefix("///", " <pre>");
if (d.package == "DIP")
@@ -863,7 +869,7 @@ void tool_app_t::create_docheader()
poutprefix("///", " @section {}_4 Limitations", d.id);
poutprefix("///", "");
poutprefix("///", " {}", d.limitations);
- if (d.example.size() > 0)
+ if (!d.example.empty())
{
poutprefix("///", "");
poutprefix("///", " @section {}_5 Example", d.id);
@@ -917,7 +923,7 @@ void tool_app_t::listdevices()
}
out += ")";
pout("{}\n", out);
- if (terms.size() > 0)
+ if (!terms.empty())
{
pstring t = "";
for (auto & j : terms)
@@ -945,7 +951,7 @@ void tool_app_t::convert()
{
std::ifstream strm(plib::filesystem::u8path(opt_file()));
if (strm.fail())
- plib::pthrow<netlist::nl_exception>(netlist::MF_FILE_OPEN_ERROR(opt_file()));
+ throw netlist::nl_exception(netlist::MF_FILE_OPEN_ERROR(opt_file()));
strm.imbue(std::locale::classic());
plib::copystream(ostrm, strm);
}
@@ -1008,12 +1014,12 @@ int tool_app_t::execute()
if (opt_version())
{
pout(
- "nltool (netlist) " PSTRINGIFY(NLTOOL_VERSION) "\n"
- "Copyright (C) 2019 Couriersud\n"
+ "nltool (netlist) {1}\n"
+ "Copyright (C) 2020 Couriersud\n"
"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n\n"
- "Written by Couriersud.\n");
+ "Written by Couriersud.\n", netlist::netlist_state_t::version());
if (opt_verb())
{
std::vector<std::pair<pstring, pstring>> defs;
@@ -1027,7 +1033,7 @@ int tool_app_t::execute()
}
m_defines = opt_defines();
- m_defines.emplace_back("NLTOOL_VERSION=" PSTRINGIFY(NLTOOL_VERSION));
+ m_defines.emplace_back("NLTOOL_VERSION=" + netlist::netlist_state_t::version());
if (opt_prepro())
m_defines.emplace_back("__PREPROCESSOR_DEBUG__=1");
diff --git a/src/lib/netlist/prg/nlwav.cpp b/src/lib/netlist/prg/nlwav.cpp
index 84e32bfc04a..93a6d6e24a5 100644
--- a/src/lib/netlist/prg/nlwav.cpp
+++ b/src/lib/netlist/prg/nlwav.cpp
@@ -63,7 +63,7 @@ public:
m_f.write(reinterpret_cast<const std::ostream::char_type *>(&val), sizeof(T));
}
- void write_sample(int *sample)
+ void write_sample(const int *sample)
{
m_data.len += m_fmt.block_align;
for (std::size_t i = 0; i < channels(); i++)
@@ -494,8 +494,6 @@ void nlwav_app::convert(std::ostream &ostrm)
int nlwav_app::execute()
{
- for (auto &i : opt_args())
- pout("Hello : " + i + "\n");
if (opt_help())
{
pout(usage());
@@ -506,7 +504,7 @@ int nlwav_app::execute()
{
pout(
"nlwav (netlist) 0.1\n"
- "Copyright (C) 2019 Couriersud\n"
+ "Copyright (C) 2020 Couriersud\n"
"License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n\n"
@@ -534,7 +532,7 @@ int nlwav_app::execute()
{
auto outstrm(std::ofstream(plib::filesystem::u8path(opt_out())));
if (outstrm.fail())
- plib::pthrow<plib::file_open_e>(opt_out());
+ throw plib::file_open_e(opt_out());
outstrm.imbue(std::locale::classic());
convert(outstrm);
}
diff --git a/src/lib/netlist/solver/nld_matrix_solver.cpp b/src/lib/netlist/solver/nld_matrix_solver.cpp
index 679632cfc15..f6d9c0c579b 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.cpp
+++ b/src/lib/netlist/solver/nld_matrix_solver.cpp
@@ -2,6 +2,7 @@
// copyright-holders:Couriersud
#include "nld_matrix_solver.h"
+#include "nl_setup.h"
#include "plib/putil.h"
namespace netlist
@@ -45,7 +46,7 @@ namespace solver
, m_stat_calculations(*this, "m_stat_calculations", 0)
, m_stat_newton_raphson(*this, "m_stat_newton_raphson", 0)
, m_stat_vsolver_calls(*this, "m_stat_vsolver_calls", 0)
- , m_last_step(*this, "m_last_step", netlist_time::zero())
+ , m_last_step(*this, "m_last_step", netlist_time_ext::zero())
, m_fb_sync(*this, "FB_sync")
, m_Q_sync(*this, "Q_sync")
, m_ops(0)
@@ -57,6 +58,11 @@ namespace solver
setup_matrix();
}
+ analog_net_t *matrix_solver_t::get_connected_net(terminal_t *term)
+ {
+ return &state().setup().get_connected_terminal(*term)->net();
+ }
+
void matrix_solver_t::setup_base(const analog_net_t::list_t &nets)
{
log().debug("New solver setup\n");
@@ -121,7 +127,7 @@ namespace solver
break;
case detail::terminal_type::OUTPUT:
log().fatal(MF_UNHANDLED_ELEMENT_1_FOUND(p->name()));
- plib::pthrow<nl_exception>(MF_UNHANDLED_ELEMENT_1_FOUND(p->name()));
+ throw nl_exception(MF_UNHANDLED_ELEMENT_1_FOUND(p->name()));
}
}
}
@@ -211,7 +217,7 @@ namespace solver
for (std::size_t i = 0; i < term.count(); i++)
//FIXME: this is weird
if (other[i] != -1)
- other[i] = get_net_idx(&term.terms()[i]->connected_terminal()->net());
+ other[i] = get_net_idx(get_connected_net(term.terms()[i]));
}
}
@@ -342,6 +348,36 @@ namespace solver
}
}
+ void matrix_solver_t::set_pointers()
+ {
+ const std::size_t iN = this->m_terms.size();
+
+ std::size_t max_count = 0;
+ std::size_t max_rail = 0;
+ for (std::size_t k = 0; k < iN; k++)
+ {
+ max_count = std::max(max_count, m_terms[k].count());
+ max_rail = std::max(max_rail, m_terms[k].railstart());
+ }
+
+ m_gtn.resize(iN, max_count);
+ m_gonn.resize(iN, max_count);
+ m_Idrn.resize(iN, max_count);
+ m_connected_net_Vn.resize(iN, max_count);
+
+ for (std::size_t k = 0; k < iN; k++)
+ {
+ auto count = m_terms[k].count();
+
+ for (std::size_t i = 0; i < count; i++)
+ {
+ m_terms[k].terms()[i]->set_ptrs(&m_gtn[k][i], &m_gonn[k][i], &m_Idrn[k][i]);
+ //m_connected_net_Vn[k][i] = m_terms[k].terms()[i]->connected_terminal()->net().Q_Analog_state_ptr();
+ m_connected_net_Vn[k][i] = get_connected_net(m_terms[k].terms()[i])->Q_Analog_state_ptr();
+ }
+ }
+ }
+
void matrix_solver_t::update_inputs()
{
// avoid recursive calls. Inputs are updated outside this call
@@ -358,7 +394,7 @@ namespace solver
void matrix_solver_t::reset()
{
- m_last_step = netlist_time::zero();
+ m_last_step = netlist_time_ext::zero();
}
void matrix_solver_t::update() noexcept
@@ -397,18 +433,18 @@ namespace solver
d->timestep(dd);
}
- const netlist_time matrix_solver_t::solve(netlist_time now)
+ netlist_time matrix_solver_t::solve(netlist_time_ext now)
{
- const netlist_time delta = now - m_last_step;
+ const netlist_time_ext delta = now - m_last_step();
// We are already up to date. Avoid oscillations.
// FIXME: Make this a parameter!
- if (delta < netlist_time::quantum())
+ if (delta < netlist_time_ext::quantum())
return netlist_time::zero();
// update all terminals for new time step
m_last_step = now;
- step(delta);
+ step(static_cast<netlist_time>(delta));
++m_stat_vsolver_calls;
if (has_dynamic_devices())
@@ -438,9 +474,7 @@ namespace solver
this->vsolve_non_dynamic(false);
}
- const netlist_time next_time_step = compute_next_timestep(delta.as_fp<nl_fptype>());
-
- return next_time_step;
+ return compute_next_timestep(delta.as_fp<nl_fptype>());
}
int matrix_solver_t::get_net_idx(const analog_net_t *net) const noexcept
@@ -468,7 +502,7 @@ namespace solver
for (std::size_t i = 0; i < term.count(); i++)
{
- auto col = get_net_idx(&term.terms()[i]->connected_terminal()->net());
+ auto col = get_net_idx(get_connected_net(term.terms()[i]));
if (col != -1)
{
if (col==row) col = diag;
@@ -496,7 +530,7 @@ namespace solver
auto &term = m_terms[row];
for (std::size_t i = 0; i < term.count(); i++)
{
- auto col = get_net_idx(&term.terms()[i]->connected_terminal()->net());
+ auto col = get_net_idx(get_connected_net(term.terms()[i]));
if (col >= 0)
{
auto colu = static_cast<std::size_t>(col);
@@ -510,29 +544,27 @@ namespace solver
}
}
}
- return weight; // / static_cast<nl_fptype>(term.railstart());
+ return weight;
}
}
void matrix_solver_t::add_term(std::size_t net_idx, terminal_t *term)
{
- if (term->connected_terminal()->net().isRailNet())
+ if (get_connected_net(term)->isRailNet())
{
m_rails_temp[net_idx].add_terminal(term, -1, false);
}
else
{
- int ot = get_net_idx(&term->connected_terminal()->net());
+ int ot = get_net_idx(get_connected_net(term));
if (ot>=0)
{
m_terms[net_idx].add_terminal(term, ot, true);
}
- // Should this be allowed ?
- else // if (ot<0)
+ else
{
- m_rails_temp[net_idx].add_terminal(term, ot, true);
log().fatal(MF_FOUND_TERM_WITH_MISSING_OTHERNET(term->name()));
- plib::pthrow<nl_exception>(MF_FOUND_TERM_WITH_MISSING_OTHERNET(term->name()));
+ throw nl_exception(MF_FOUND_TERM_WITH_MISSING_OTHERNET(term->name()));
}
}
}
diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h
index f1a4cf928ab..a6b3c6774fd 100644
--- a/src/lib/netlist/solver/nld_matrix_solver.h
+++ b/src/lib/netlist/solver/nld_matrix_solver.h
@@ -77,7 +77,6 @@ namespace solver
// special
, m_use_gabs(parent, "USE_GABS", true)
- , m_use_linear_prediction(parent, "USE_LINEAR_PREDICTION", false) // // savings are eaten up by effort
{
m_min_timestep = m_dynamic_min_ts();
@@ -112,7 +111,6 @@ namespace solver
param_enum_t<matrix_sort_type_e> m_sort_type;
param_logic_t m_use_gabs;
- param_logic_t m_use_linear_prediction;
nl_fptype m_min_timestep;
nl_fptype m_max_timestep;
@@ -179,11 +177,11 @@ namespace solver
// after every call to solve, update inputs must be called.
// this can be done as well as a batch to ease parallel processing.
- const netlist_time solve(netlist_time now);
+ netlist_time solve(netlist_time_ext now);
void update_inputs();
- bool has_dynamic_devices() const noexcept { return m_dynamic_devices.size() > 0; }
- bool has_timestep_devices() const noexcept { return m_step_devices.size() > 0; }
+ bool has_dynamic_devices() const noexcept { return !m_dynamic_devices.empty(); }
+ bool has_timestep_devices() const noexcept { return !m_step_devices.empty(); }
void update_forced();
void update_after(netlist_time after) noexcept
@@ -206,16 +204,15 @@ namespace solver
std::size_t ops() { return m_ops; }
protected:
+ template <typename T>
+ using aligned_alloc = plib::aligned_allocator<T, PALIGN_VECTOROPT>;
matrix_solver_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const solver_parameters_t *params);
- virtual unsigned vsolve_non_dynamic(const bool newton_raphson) = 0;
- virtual netlist_time compute_next_timestep(const nl_fptype cur_ts) = 0;
-
- template <typename T>
- using aligned_alloc = plib::aligned_allocator<T, PALIGN_VECTOROPT>;
+ virtual unsigned vsolve_non_dynamic(bool newton_raphson) = 0;
+ virtual netlist_time compute_next_timestep(nl_fptype cur_ts) = 0;
plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gonn;
plib::pmatrix2d<nl_fptype, aligned_alloc<nl_fptype>> m_gtn;
@@ -238,7 +235,7 @@ namespace solver
state_var<std::size_t> m_stat_newton_raphson;
state_var<std::size_t> m_stat_vsolver_calls;
- state_var<netlist_time> m_last_step;
+ state_var<netlist_time_ext> m_last_step;
std::vector<core_device_t *> m_step_devices;
std::vector<core_device_t *> m_dynamic_devices;
@@ -248,7 +245,7 @@ namespace solver
std::size_t m_ops;
// base setup - called from constructor
- void setup_base(const analog_net_t::list_t &nets);
+ void setup_base(const analog_net_t::list_t &nets) noexcept(false);
void sort_terms(matrix_sort_type_e sort);
@@ -259,39 +256,15 @@ namespace solver
std::pair<int, int> get_left_right_of_diag(std::size_t irow, std::size_t idiag);
nl_fptype get_weight_around_diag(std::size_t row, std::size_t diag);
- void add_term(std::size_t net_idx, terminal_t *term);
+ void add_term(std::size_t net_idx, terminal_t *term) noexcept(false);
// calculate matrix
void setup_matrix();
- void set_pointers()
- {
- const std::size_t iN = this->m_terms.size();
-
- std::size_t max_count = 0;
- std::size_t max_rail = 0;
- for (std::size_t k = 0; k < iN; k++)
- {
- max_count = std::max(max_count, m_terms[k].count());
- max_rail = std::max(max_rail, m_terms[k].railstart());
- }
-
- m_gtn.resize(iN, max_count);
- m_gonn.resize(iN, max_count);
- m_Idrn.resize(iN, max_count);
- m_connected_net_Vn.resize(iN, max_count);
-
- for (std::size_t k = 0; k < iN; k++)
- {
- auto count = m_terms[k].count();
+ void set_pointers();
- for (std::size_t i = 0; i < count; i++)
- {
- m_terms[k].terms()[i]->set_ptrs(&m_gtn[k][i], &m_gonn[k][i], &m_Idrn[k][i]);
- m_connected_net_Vn[k][i] = m_terms[k].terms()[i]->connected_terminal()->net().Q_Analog_state_ptr();
- }
- }
- }
+ private:
+ analog_net_t *get_connected_net(terminal_t *term);
};
@@ -451,12 +424,13 @@ namespace solver
{
for (std::size_t k = 0; k < size(); k++)
{
- auto &t = m_terms[k];
- //const nl_fptype DD_n = (n->Q_Analog() - t->m_last_V);
+ const auto &t = m_terms[k];
+ const auto v(t.template getV<nl_fptype>());
// avoid floating point exceptions
-
const nl_fptype DD_n = std::max(-fp_constants<nl_fptype>::TIMESTEP_MAXDIFF(),
- std::min(+fp_constants<nl_fptype>::TIMESTEP_MAXDIFF(),(t.template getV<nl_fptype>() - m_last_V[k])));
+ std::min(+fp_constants<nl_fptype>::TIMESTEP_MAXDIFF(),(v - m_last_V[k])));
+
+ m_last_V[k] = v;
const nl_fptype hn = cur_ts;
//printf("%g %g %g %g\n", DD_n, hn, t.m_DD_n_m_1, t.m_h_n_m_1);
@@ -470,25 +444,15 @@ namespace solver
else
new_net_timestep = m_params.m_max_timestep;
- if (new_net_timestep < new_solver_timestep)
- new_solver_timestep = new_net_timestep;
-
- m_last_V[k] = t.template getV<nl_fptype>();
- }
- if (new_solver_timestep < m_params.m_min_timestep)
- {
- new_solver_timestep = m_params.m_min_timestep;
+ new_solver_timestep = std::min(new_net_timestep, new_solver_timestep);
}
+ new_solver_timestep = std::max(new_solver_timestep, m_params.m_min_timestep);
}
- //if (new_solver_timestep > 10.0 * hn)
- // new_solver_timestep = 10.0 * hn;
- //
- // FIXME: Factor 2 below is important. Without, we get timing issues. This must be a bug elsewhere.
+ // FIXME: Factor 2 below is important. Without, we get timing issues. This must be a bug elsewhere.
return std::max(netlist_time::from_fp(new_solver_timestep), netlist_time::quantum() * 2);
}
-
template <typename M>
void build_mat_ptr(M &mat)
{
diff --git a/src/lib/netlist/solver/nld_ms_direct.h b/src/lib/netlist/solver/nld_ms_direct.h
index cd808c2ee3c..fbb8e4a8250 100644
--- a/src/lib/netlist/solver/nld_ms_direct.h
+++ b/src/lib/netlist/solver/nld_ms_direct.h
@@ -30,7 +30,7 @@ namespace solver
matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
- const solver_parameters_t *params, const std::size_t size);
+ const solver_parameters_t *params, std::size_t size);
void reset() override { matrix_solver_t::reset(); }
@@ -42,8 +42,8 @@ namespace solver
static constexpr const std::size_t SIZEABS = plib::parray<FT, SIZE>::SIZEABS();
static constexpr const std::size_t m_pitch_ABS = (((SIZEABS + 0) + 7) / 8) * 8;
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
- unsigned solve_non_dynamic(const bool newton_raphson);
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
+ unsigned solve_non_dynamic(bool newton_raphson);
void LE_solve();
@@ -158,7 +158,7 @@ namespace solver
}
template <typename FT, int SIZE>
- unsigned matrix_solver_direct_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_direct_t<FT, SIZE>::solve_non_dynamic(bool newton_raphson)
{
this->LE_solve();
this->LE_back_subst(this->m_new_V);
@@ -171,7 +171,7 @@ namespace solver
}
template <typename FT, int SIZE>
- unsigned matrix_solver_direct_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_direct_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
// populate matrix
this->clear_square_mat(m_A);
@@ -184,7 +184,7 @@ namespace solver
matrix_solver_direct_t<FT, SIZE>::matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name,
const analog_net_t::list_t &nets,
const solver_parameters_t *params,
- const std::size_t size)
+ std::size_t size)
: matrix_solver_ext_t<FT, SIZE>(anetlist, name, nets, params, size)
, m_pitch(m_pitch_ABS ? m_pitch_ABS : (((size + 0) + 7) / 8) * 8)
, m_A(size, m_pitch)
diff --git a/src/lib/netlist/solver/nld_ms_direct1.h b/src/lib/netlist/solver/nld_ms_direct1.h
index 3a4e3778208..c0e6d63719c 100644
--- a/src/lib/netlist/solver/nld_ms_direct1.h
+++ b/src/lib/netlist/solver/nld_ms_direct1.h
@@ -32,7 +32,7 @@ namespace solver
// ----------------------------------------------------------------------------------------
// matrix_solver - Direct1
// ----------------------------------------------------------------------------------------
- unsigned vsolve_non_dynamic(const bool newton_raphson) override
+ unsigned vsolve_non_dynamic(bool newton_raphson) override
{
this->clear_square_mat(this->m_A);
this->fill_matrix_and_rhs();
diff --git a/src/lib/netlist/solver/nld_ms_direct2.h b/src/lib/netlist/solver/nld_ms_direct2.h
index 3e2b9727776..aa2f8d17eb9 100644
--- a/src/lib/netlist/solver/nld_ms_direct2.h
+++ b/src/lib/netlist/solver/nld_ms_direct2.h
@@ -32,7 +32,7 @@ namespace solver
const solver_parameters_t *params)
: matrix_solver_direct_t<FT, 2>(anetlist, name, nets, params, 2)
{}
- unsigned vsolve_non_dynamic(const bool newton_raphson) override
+ unsigned vsolve_non_dynamic(bool newton_raphson) override
{
this->clear_square_mat(this->m_A);
this->fill_matrix_and_rhs();
diff --git a/src/lib/netlist/solver/nld_ms_direct_lu.h b/src/lib/netlist/solver/nld_ms_direct_lu.h
index 1e1f7f1f158..5a8cbffbda6 100644
--- a/src/lib/netlist/solver/nld_ms_direct_lu.h
+++ b/src/lib/netlist/solver/nld_ms_direct_lu.h
@@ -38,12 +38,12 @@ public:
unsigned N() const { if (m_N == 0) return m_dim; else return m_N; }
- int vsolve_non_dynamic(const bool newton_raphson);
+ int vsolve_non_dynamic(bool newton_raphson);
protected:
virtual void add_term(int net_idx, terminal_t *term) override;
- int solve_non_dynamic(const bool newton_raphson);
+ int solve_non_dynamic(bool newton_raphson);
void build_LE_A();
void build_LE_RHS(nl_double * RESTRICT rhs);
@@ -565,7 +565,7 @@ void matrix_solver_direct_t<m_N, storage_N>::store(
template <unsigned m_N, unsigned storage_N>
-unsigned matrix_solver_direct_t<m_N, storage_N>::solve_non_dynamic(const bool newton_raphson)
+unsigned matrix_solver_direct_t<m_N, storage_N>::solve_non_dynamic(bool newton_raphson)
{
nl_double new_V[storage_N]; // = { 0.0 };
@@ -587,7 +587,7 @@ unsigned matrix_solver_direct_t<m_N, storage_N>::solve_non_dynamic(const bool ne
}
template <unsigned m_N, unsigned storage_N>
-int matrix_solver_direct_t<m_N, storage_N>::vsolve_non_dynamic(const bool newton_raphson)
+int matrix_solver_direct_t<m_N, storage_N>::vsolve_non_dynamic(bool newton_raphson)
{
this->build_LE_A();
this->build_LE_RHS(m_RHS);
diff --git a/src/lib/netlist/solver/nld_ms_gcr.h b/src/lib/netlist/solver/nld_ms_gcr.h
index e72a645b33e..be3fd5fa524 100644
--- a/src/lib/netlist/solver/nld_ms_gcr.h
+++ b/src/lib/netlist/solver/nld_ms_gcr.h
@@ -110,7 +110,7 @@ namespace solver
}
}
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
std::pair<pstring, pstring> create_solver_code() override;
@@ -146,7 +146,7 @@ namespace solver
{
const auto &nzbd = this->m_terms[i].m_nzbd;
- if (nzbd.size() > 0)
+ if (!nzbd.empty())
{
std::size_t pi = mat.diag[i];
@@ -226,7 +226,7 @@ namespace solver
}
template <typename FT, int SIZE>
- unsigned matrix_solver_GCR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_GCR_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
// populate matrix
mat.set_scalar(plib::constants<FT>::zero());
diff --git a/src/lib/netlist/solver/nld_ms_gmres.h b/src/lib/netlist/solver/nld_ms_gmres.h
index 6900f7f8f28..586a0ef8c26 100644
--- a/src/lib/netlist/solver/nld_ms_gmres.h
+++ b/src/lib/netlist/solver/nld_ms_gmres.h
@@ -78,7 +78,7 @@ namespace solver
}
}
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
private:
@@ -95,7 +95,7 @@ namespace solver
// ----------------------------------------------------------------------------------------
template <typename FT, int SIZE>
- unsigned matrix_solver_GMRES_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_GMRES_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
const std::size_t iN = this->size();
diff --git a/src/lib/netlist/solver/nld_ms_sm.h b/src/lib/netlist/solver/nld_ms_sm.h
index c3aae29b798..bb7057c9687 100644
--- a/src/lib/netlist/solver/nld_ms_sm.h
+++ b/src/lib/netlist/solver/nld_ms_sm.h
@@ -67,8 +67,8 @@ namespace solver
void reset() override { matrix_solver_t::reset(); }
protected:
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
- unsigned solve_non_dynamic(const bool newton_raphson);
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
+ unsigned solve_non_dynamic(bool newton_raphson);
void LE_invert();
@@ -197,7 +197,7 @@ namespace solver
}
template <typename FT, int SIZE>
- unsigned matrix_solver_sm_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_sm_t<FT, SIZE>::solve_non_dynamic(bool newton_raphson)
{
static constexpr const bool incremental = true;
const std::size_t iN = this->size();
@@ -283,7 +283,7 @@ namespace solver
}
template <typename FT, int SIZE>
- unsigned matrix_solver_sm_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_sm_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
this->clear_square_mat(this->m_A);
diff --git a/src/lib/netlist/solver/nld_ms_sor.h b/src/lib/netlist/solver/nld_ms_sor.h
index a5ac1fc7fc2..666025db260 100644
--- a/src/lib/netlist/solver/nld_ms_sor.h
+++ b/src/lib/netlist/solver/nld_ms_sor.h
@@ -39,7 +39,7 @@ namespace solver
{
}
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
private:
state_var<float_type> m_lp_fact;
@@ -52,7 +52,7 @@ namespace solver
// ----------------------------------------------------------------------------------------
template <typename FT, int SIZE>
- unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_SOR_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
const std::size_t iN = this->size();
bool resched = false;
diff --git a/src/lib/netlist/solver/nld_ms_sor_mat.h b/src/lib/netlist/solver/nld_ms_sor_mat.h
index 68632b82be9..3772c78b689 100644
--- a/src/lib/netlist/solver/nld_ms_sor_mat.h
+++ b/src/lib/netlist/solver/nld_ms_sor_mat.h
@@ -36,78 +36,22 @@ namespace solver
const analog_net_t::list_t &nets,
const solver_parameters_t *params, std::size_t size)
: matrix_solver_direct_t<FT, SIZE>(anetlist, name, nets, params, size)
- , m_Vdelta(*this, "m_Vdelta", std::vector<float_type>(size))
, m_omega(*this, "m_omega", static_cast<float_type>(params->m_gs_sor))
- , m_lp_fact(*this, "m_lp_fact", 0)
{
}
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
private:
- //state_var<float_type[storage_N]> m_Vdelta;
- state_var<std::vector<float_type>> m_Vdelta;
-
state_var<float_type> m_omega;
- state_var<float_type> m_lp_fact;
-
};
// ----------------------------------------------------------------------------------------
// matrix_solver - Gauss - Seidel
// ----------------------------------------------------------------------------------------
- #if 0
- //FIXME: move to solve_base
- template <unsigned m_N, unsigned storage_N>
- float_type matrix_solver_SOR_mat_t<m_N, storage_N>::vsolve()
- {
- //
- // enable linear prediction on first newton pass
- //
-
- if (this->m_params->use_linear_prediction)
- for (unsigned k = 0; k < this->size(); k++)
- {
- this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
- this->m_nets[k]->m_cur_Analog = this->m_nets[k]->m_cur_Analog + this->m_Vdelta[k] * this->current_timestep() * m_lp_fact;
- }
- else
- for (unsigned k = 0; k < this->size(); k++)
- {
- this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
- }
-
- this->solve_base(this);
-
- if (this->m_params->use_linear_prediction)
- {
- float_type sq = 0;
- float_type sqo = 0;
- const float_type rez_cts = plib::reciprocal(this->current_timestep());
- for (unsigned k = 0; k < this->size(); k++)
- {
- const analog_net_t *n = this->m_nets[k];
- const float_type nv = (n->Q_Analog() - this->m_last_V[k]) * rez_cts ;
- sq += nv * nv;
- sqo += this->m_Vdelta[k] * this->m_Vdelta[k];
- this->m_Vdelta[k] = nv;
- }
-
- // FIXME: used to be 1e90, but this would not be compatible with float
- if (sqo > NL_FCONST(1e-20))
- m_lp_fact = std::min(std::sqrt(sq/sqo), (float_type) 2.0);
- else
- m_lp_fact = NL_FCONST(0.0);
- }
-
-
- return this->compute_next_timestep();
- }
- #endif
-
template <typename FT, int SIZE>
- unsigned matrix_solver_SOR_mat_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_SOR_mat_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
// The matrix based code looks a lot nicer but actually is 30% slower than
// the optimized code which works directly on the data structures.
diff --git a/src/lib/netlist/solver/nld_ms_w.h b/src/lib/netlist/solver/nld_ms_w.h
index 5a78b668e62..345b7a13d2a 100644
--- a/src/lib/netlist/solver/nld_ms_w.h
+++ b/src/lib/netlist/solver/nld_ms_w.h
@@ -75,8 +75,8 @@ namespace solver
void reset() override { matrix_solver_t::reset(); }
protected:
- unsigned vsolve_non_dynamic(const bool newton_raphson) override;
- unsigned solve_non_dynamic(const bool newton_raphson);
+ unsigned vsolve_non_dynamic(bool newton_raphson) override;
+ unsigned solve_non_dynamic(bool newton_raphson);
void LE_invert();
@@ -208,7 +208,7 @@ namespace solver
template <typename FT, int SIZE>
- unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(bool newton_raphson)
{
const auto iN = this->size();
@@ -351,7 +351,7 @@ namespace solver
}
template <typename FT, int SIZE>
- unsigned matrix_solver_w_t<FT, SIZE>::vsolve_non_dynamic(const bool newton_raphson)
+ unsigned matrix_solver_w_t<FT, SIZE>::vsolve_non_dynamic(bool newton_raphson)
{
this->clear_square_mat(this->m_A);
this->fill_matrix_and_rhs();
diff --git a/src/lib/netlist/solver/nld_solver.cpp b/src/lib/netlist/solver/nld_solver.cpp
index 4b24e003d52..977b6ae7b20 100644
--- a/src/lib/netlist/solver/nld_solver.cpp
+++ b/src/lib/netlist/solver/nld_solver.cpp
@@ -27,6 +27,7 @@
#endif
#include "netlist/nl_factory.h"
+#include "netlist/nl_setup.h" // FIXME: only needed for splitter code
#include "nld_matrix_solver.h"
#include "nld_ms_direct.h"
#include "nld_ms_direct1.h"
@@ -68,10 +69,10 @@ namespace devices
if (m_params.m_dynamic_ts)
return;
- netlist_time now(exec().time());
+ netlist_time_ext now(exec().time());
// force solving during start up if there are no time-step devices
// FIXME: Needs a more elegant solution
- bool force_solve = (now < netlist_time::from_fp<decltype(m_params.m_max_timestep)>(2 * m_params.m_max_timestep));
+ bool force_solve = (now < netlist_time_ext::from_fp<decltype(m_params.m_max_timestep)>(2 * m_params.m_max_timestep));
std::size_t nthreads = std::min(static_cast<std::size_t>(m_params.m_parallel()), plib::omp::get_max_threads());
@@ -252,36 +253,55 @@ namespace devices
struct net_splitter
{
- bool already_processed(const analog_net_t &n) const
+ bool already_processed(const analog_net_t &n)
{
// no need to process rail nets - these are known variables
if (n.isRailNet())
return true;
+ // First check if it is in a previous group.
+ // In this case we need to merge this group into the current group
+ if (groupspre.size() > 1)
+ {
+ for (std::size_t i = 0; i<groupspre.size() - 1; i++)
+ if (plib::container::contains(groupspre[i], &n))
+ {
+ // copy all nets
+ for (auto & cn : groupspre[i])
+ if (!plib::container::contains(groupspre.back(), cn))
+ groupspre.back().push_back(cn);
+ // clear
+ groupspre[i].clear();
+ return true;
+ }
+ }
// if it's already processed - no need to continue
- for (auto & grp : groups)
- if (plib::container::contains(grp, &n))
- return true;
+ if (!groupspre.empty() && plib::container::contains(groupspre.back(), &n))
+ return true;
return false;
}
- void process_net(analog_net_t &n)
+ void process_net(netlist_state_t &netlist, analog_net_t &n)
{
// ignore empty nets. FIXME: print a warning message
+ netlist.log().verbose("Net {}", n.name());
if (n.num_cons() == 0)
return;
// add the net
- groups.back().push_back(&n);
+ groupspre.back().push_back(&n);
// process all terminals connected to this net
for (auto &term : n.core_terms())
{
+ netlist.log().verbose("Term {} {}", term->name(), static_cast<int>(term->type()));
// only process analog terminals
if (term->is_type(detail::terminal_type::TERMINAL))
{
auto *pt = static_cast<terminal_t *>(term);
// check the connected terminal
- analog_net_t &connected_net = pt->connected_terminal()->net();
+ // analog_net_t &connected_net = pt->connected_terminal()->net();
+ analog_net_t &connected_net = netlist.setup().get_connected_terminal(*pt)->net();
+ netlist.log().verbose(" Connected net {}", connected_net.name());
if (!already_processed(connected_net))
- process_net(connected_net);
+ process_net(netlist, connected_net);
}
}
}
@@ -290,22 +310,29 @@ namespace devices
{
for (auto & net : netlist.nets())
{
- netlist.log().debug("processing {1}\n", net->name());
+ netlist.log().debug("processing {1}", net->name());
+ netlist.log().verbose("processing {1}", net->name());
if (!net->isRailNet() && net->num_cons() > 0)
{
- netlist.log().debug(" ==> not a rail net\n");
+ netlist.log().debug(" ==> not a rail net");
+ netlist.log().verbose(" ==> not a rail net");
// Must be an analog net
auto &n = *static_cast<analog_net_t *>(net.get());
if (!already_processed(n))
{
- groups.emplace_back(analog_net_t::list_t());
- process_net(n);
+ groupspre.emplace_back(analog_net_t::list_t());
+ process_net(netlist, n);
}
}
}
+ for (auto &g : groupspre)
+ if (!g.empty())
+ groups.push_back(g);
}
std::vector<analog_net_t::list_t> groups;
+ private:
+ std::vector<analog_net_t::list_t> groupspre;
};
void NETLIB_NAME(solver)::post_start()
diff --git a/src/lib/netlist/tools/nl_convert.cpp b/src/lib/netlist/tools/nl_convert.cpp
index 28cf290d97c..dfc98598a97 100644
--- a/src/lib/netlist/tools/nl_convert.cpp
+++ b/src/lib/netlist/tools/nl_convert.cpp
@@ -9,12 +9,15 @@
#include <algorithm>
#include <unordered_map>
+#include <vector>
// FIXME: temporarily defined here - should be in a file
// FIXME: family logic in netlist is convoluted, create
// define a model param on core device
// Format: external name,netlist device,model
+
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
static constexpr const char s_lib_map[] =
"SN74LS00D, TTL_7400_DIP, 74LSXX\n"
"SN74LS04D, TTL_7404_DIP, 74LSXX\n"
@@ -58,7 +61,7 @@ static lib_map_t read_lib_map(const pstring &lm)
nl_convert_base_t::nl_convert_base_t()
: out(&m_buf)
- , m_numberchars("0123456789-+e.")
+ , m_numberchars("0123456789-+Ee.")
{
m_buf.imbue(std::locale::classic());
m_units = {
@@ -81,6 +84,14 @@ nl_convert_base_t::nl_convert_base_t()
{"MIL", "{1}", 25.4e-6}
};
+ dev_map =
+ {
+ { "VCCS", {"OP", "ON", "IP", "IN"} },
+ { "VCVS", {"OP", "ON", "IP", "IN"} },
+ { "CCCS", {"OP", "ON", "IP", "IN"} },
+ { "CCVS", {"OP", "ON", "IP", "IN"} },
+ { "VS", {"1", "2"} },
+ };
}
nl_convert_base_t::~nl_convert_base_t()
@@ -147,8 +158,65 @@ void nl_convert_base_t::add_term(const pstring &netname, const pstring &termname
net->terminals().push_back(termname);
}
+void nl_convert_base_t::add_term(const pstring &netname, const pstring &devname, unsigned term)
+{
+ auto e = dev_map.find(get_device(devname)->type());
+ if (e == dev_map.end())
+ out("// ERROR: No terminals found for device {}\n", devname);
+ else
+ {
+ if (term >= e->second.size())
+ out("// ERROR: {} : Term {} exceeds number of terminals {}\n", netname, devname, term);
+ else
+ add_term(netname, devname + "." + e->second[term]);
+ }
+}
+
+void nl_convert_base_t::add_device_extra_s(const pstring &devname, const pstring &extra)
+{
+ auto dev = get_device(devname);
+ if (dev == nullptr)
+ out("// ERROR: Device {} not found\n", devname);
+ else
+ {
+ dev->add_extra(extra);
+ }
+}
+
+
+
void nl_convert_base_t::dump_nl()
{
+ // do replacements
+ for (auto &r : m_replace)
+ {
+ // Get the device entry
+ auto *d = get_device(r.m_ce);
+ if (d == nullptr)
+ {
+ out("ERROR: Can not find <{}>\n", r.m_ce);
+ continue;
+ }
+
+ auto e = dev_map.find(d->type());
+ if (e == dev_map.end())
+ {
+ out("ERROR: Can not find type {}\n", d->type());
+ continue;
+ }
+ pstring term1 = r.m_ce + "." + e->second[0];
+ // scan all nets
+ for (auto &n : m_nets)
+ {
+ for (auto &t : n.second->terminals())
+ {
+ if (t == term1)
+ t = r.m_repterm;
+ }
+ }
+ add_term(r.m_net, term1);
+ }
+
for (auto & alias : m_ext_alias)
{
net_t *net = m_nets[alias].get();
@@ -178,6 +246,9 @@ void nl_convert_base_t::dump_nl()
else
out("{}({})\n", m_devs[j]->type().c_str(),
m_devs[j]->name().c_str());
+ for (auto &e : m_devs[j]->extra())
+ out("{}\n", e);
+
}
// print nets
for (auto & i : m_nets)
@@ -193,13 +264,14 @@ void nl_convert_base_t::dump_nl()
out(")\n");
}
}
+ m_replace.clear();
m_devs.clear();
m_nets.clear();
m_pins.clear();
m_ext_alias.clear();
}
-const pstring nl_convert_base_t::get_nl_val(const double val)
+pstring nl_convert_base_t::get_nl_val(double val)
{
for (auto &e : m_units)
{
@@ -291,6 +363,22 @@ static pstring rem(const std::vector<pstring> &vps, std::size_t start)
return r;
}
+static int npoly(const pstring &s)
+{
+ // Brute force
+ if (s=="POLY(1)")
+ return 1;
+ if (s=="POLY(2)")
+ return 2;
+ if (s=="POLY(3)")
+ return 3;
+ if (s=="POLY(4)")
+ return 4;
+ if (s=="POLY(5)")
+ return 5;
+ return -1;
+}
+
void nl_convert_spice_t::process_line(const pstring &line)
{
if (line != "")
@@ -384,24 +472,105 @@ void nl_convert_spice_t::process_line(const pstring &line)
add_term(tt[2], tt[0] + ".N");
break;
case 'E':
- add_device("VCVS", tt[0]);
+ {
+ auto n=npoly(tt[3]);
+ if (n<0)
+ {
+ add_device("VCVS", tt[0]);
+ add_term(tt[1], tt[0], 0);
+ add_term(tt[2], tt[0], 1);
+ add_term(tt[3], tt[0], 2);
+ add_term(tt[4], tt[0], 3);
+ add_device_extra(tt[0], "PARAM({}, {})", tt[0] + ".G", tt[5]);
+ }
+ else
+ {
+ unsigned sce(4);
+ auto scoeff(static_cast<unsigned>(5 + n));
+ if ((tt.size() != 5 + 2 * static_cast<unsigned>(n)) || (tt[scoeff-1] != "0"))
+ {
+ out("// IGNORED {}: {}\n", tt[0].c_str(), line.c_str());
+ break;
+ }
+ pstring lastnet = tt[1];
+ for (std::size_t i=0; i < static_cast<std::size_t>(n); i++)
+ {
+ pstring devname = tt[0] + plib::pfmt("{}")(i);
+ pstring nextnet = (i<static_cast<std::size_t>(n)-1) ? tt[1] + "a" + plib::pfmt("{}")(i) : tt[2];
+ auto net2 = plib::psplit(plib::replace_all(plib::replace_all(tt[sce+i],")",""),"(",""),",");
+ add_device("VCVS", devname);
+ add_term(lastnet, devname, 0);
+ add_term(nextnet, devname, 1);
+ add_term(net2[0], devname, 2);
+ add_term(net2[1], devname, 3);
+ add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]);
+ lastnet = nextnet;
+ //printf("xxx %d %s %s\n", (int) net2.size(), net2[0].c_str(), net2[1].c_str());
+#if 0
+ pstring extranetname = devname + "net";
+ m_replace.push_back({, devname + ".IP", extranetname });
+ add_term(extranetname, devname + ".IN");
+ add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]);
+#endif
+ }
+ }
+ }
+ break;
+ case 'F':
+ {
+ auto n=npoly(tt[3]);
+ unsigned sce(4);
+ unsigned scoeff(5 + static_cast<unsigned>(n));
+ if (n<0)
+ {
+ sce = 3;
+ scoeff = 4;
+ n = 1;
+ }
+ else
+ {
+ if ((tt.size() != 5 + 2 * static_cast<unsigned>(n)) || (tt[scoeff-1] != "0"))
+ {
+ out("// IGNORED {}: {}\n", tt[0].c_str(), line.c_str());
+ break;
+ }
+ }
+ for (std::size_t i=0; i < static_cast<std::size_t>(n); i++)
+ {
+ pstring devname = tt[0] + plib::pfmt("{}")(i);
+ add_device("CCCS", devname);
+ add_term(tt[1], devname, 0);
+ add_term(tt[2], devname, 1);
+
+ pstring extranetname = devname + "net";
+ m_replace.push_back({tt[sce+i], devname + ".IP", extranetname });
+ add_term(extranetname, devname + ".IN");
+ add_device_extra(devname, "PARAM({}, {})", devname + ".G", tt[scoeff+i]);
+ }
+ }
+ break;
+ case 'H':
+ add_device("CCVS", tt[0]);
add_term(tt[1], tt[0] + ".OP");
add_term(tt[2], tt[0] + ".ON");
- add_term(tt[3], tt[0] + ".IP");
- add_term(tt[4], tt[0] + ".IN");
- out("PARAM({}, {})\n", tt[0] + ".G", tt[5]);
+ m_replace.push_back({tt[3], tt[0] + ".IP", tt[2] + "a" });
+ add_term(tt[2] + "a", tt[0] + ".IN");
+ add_device_extra(tt[0], "PARAM({}, {})", tt[0] + ".G", tt[4]);
+ break;
+ case 'G':
+ add_device("VCCS", tt[0]);
+ add_term(tt[1], tt[0], 0);
+ add_term(tt[2], tt[0], 1);
+ add_term(tt[3], tt[0], 2);
+ add_term(tt[4], tt[0], 3);
+ add_device_extra(tt[0], "PARAM({}, {})", tt[0] + ".G", tt[5]);
break;
case 'V':
- // just simple Voltage sources ....
- if (tt[2] == "0")
- {
- val = get_sp_val(tt[3]);
- add_device("ANALOG_INPUT", tt[0], val);
- add_term(tt[1], tt[0] + ".Q");
- //add_term(tt[2], tt[0] + ".2");
- }
- else
- plib::perrlogger("Voltage Source {} not connected to GND\n", tt[0]);
+ // only DC Voltage sources ....
+ val = get_sp_val(tt[3] == "DC" ? tt[4] : tt[3]);
+ add_device("VS", tt[0], val);
+ add_term(tt[1], tt[0] + ".1");
+ add_term(tt[2], tt[0] + ".2");
break;
#if 0
// This is wrong ... Need to use something else for inputs!
@@ -415,7 +584,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
#else
case 'I':
{
- val = get_sp_val(tt[3]);
+ val = get_sp_val(tt[3] == "DC" ? tt[4] : tt[3]);
add_device("CS", tt[0], val);
add_term(tt[1], tt[0] + ".1");
add_term(tt[2], tt[0] + ".2");
@@ -423,10 +592,11 @@ void nl_convert_spice_t::process_line(const pstring &line)
break;
#endif
case 'D':
- add_device("DIODE", tt[0], tt[3]);
- // FIXME ==> does Kicad use different notation from LTSPICE
- add_term(tt[1], tt[0] + ".K");
- add_term(tt[2], tt[0] + ".A");
+ add_device("DIODE", tt[0], m_subckt + tt[3]);
+ // Spice D Anode Kathode model
+ // FIXME ==> does Kicad use different notation from LTSPICE ?
+ add_term(tt[1], tt[0] + ".A");
+ add_term(tt[2], tt[0] + ".K");
break;
case 'U':
case 'X':
@@ -499,7 +669,8 @@ void nl_convert_eagle_t::convert(const pstring &contents)
out("NETLIST_END()\n");
return;
}
- else if (token.is(tok.m_tok_SEMICOLON))
+
+ if (token.is(tok.m_tok_SEMICOLON))
{
// ignore empty statements
token = tok.get_token();
@@ -646,7 +817,8 @@ void nl_convert_rinf_t::convert(const pstring &contents)
out("NETLIST_END()\n");
return;
}
- else if (token.is(tok.m_tok_HEA))
+
+ if (token.is(tok.m_tok_HEA))
{
// seems to be start token - ignore
token = tok.get_token();
diff --git a/src/lib/netlist/tools/nl_convert.h b/src/lib/netlist/tools/nl_convert.h
index ac1597bf628..4d32eb7e2a6 100644
--- a/src/lib/netlist/tools/nl_convert.h
+++ b/src/lib/netlist/tools/nl_convert.h
@@ -22,6 +22,7 @@
class nl_convert_base_t
{
public:
+ using str_list = std::vector<pstring>;
COPYASSIGNMOVE(nl_convert_base_t, delete)
@@ -42,16 +43,34 @@ protected:
void add_device(const pstring &atype, const pstring &aname, double aval);
void add_device(const pstring &atype, const pstring &aname);
+ void add_device_extra_s(const pstring &devname, const pstring &extra);
+
+ template<typename... Args>
+ void add_device_extra(const pstring &devname, const pstring &fmt, Args&&... args)
+ {
+ add_device_extra_s(devname, plib::pfmt(fmt)(std::forward<Args>(args)...));
+ }
+
void add_term(const pstring &netname, const pstring &termname);
+ void add_term(const pstring &netname, const pstring &devname, unsigned term);
void dump_nl();
- const pstring get_nl_val(const double val);
+ pstring get_nl_val(double val);
double get_sp_unit(const pstring &unit);
double get_sp_val(const pstring &sin);
plib::putf8_fmt_writer out;
+
+ struct replace_t
+ {
+ pstring m_ce; // controlling element - must be twoterm
+ pstring m_repterm; // replace with terminal
+ pstring m_net; // connect to net
+ };
+ std::vector<replace_t> m_replace;
+
private:
struct net_t
@@ -102,16 +121,19 @@ private:
const pstring &type() const { return m_type;}
const pstring &model() const { return m_model;}
double value() const { return m_val;}
+ const str_list &extra() const { return m_extra;}
bool has_model() const { return m_model != ""; }
bool has_value() const { return m_has_val; }
+ void add_extra(const pstring &s) { m_extra.push_back(s); }
private:
pstring m_type;
pstring m_name;
pstring m_model;
double m_val;
bool m_has_val;
+ str_list m_extra;
};
struct unit_t {
@@ -133,9 +155,17 @@ private:
pstring m_alias;
};
+
private:
void add_device(plib::unique_ptr<dev_t> dev);
+ dev_t *get_device(const pstring &name)
+ {
+ for (auto &e : m_devs)
+ if (e->name() == name)
+ return e.get();
+ return nullptr;
+ }
std::stringstream m_buf;
@@ -147,13 +177,15 @@ private:
std::vector<unit_t> m_units;
pstring m_numberchars;
+ std::unordered_map<pstring, str_list> dev_map;
+
};
class nl_convert_spice_t : public nl_convert_base_t
{
public:
- nl_convert_spice_t() : nl_convert_base_t() {}
+ nl_convert_spice_t() = default;
void convert(const pstring &contents) override;
@@ -169,7 +201,7 @@ class nl_convert_eagle_t : public nl_convert_base_t
{
public:
- nl_convert_eagle_t() : nl_convert_base_t() {}
+ nl_convert_eagle_t() = default;
class tokenizer : public plib::ptokenizer
{
@@ -202,7 +234,7 @@ class nl_convert_rinf_t : public nl_convert_base_t
{
public:
- nl_convert_rinf_t() : nl_convert_base_t() {}
+ nl_convert_rinf_t() = default;
class tokenizer : public plib::ptokenizer
{
diff --git a/src/lib/util/avhuff.cpp b/src/lib/util/avhuff.cpp
index 9975287f4c1..73a41df50d7 100644
--- a/src/lib/util/avhuff.cpp
+++ b/src/lib/util/avhuff.cpp
@@ -58,14 +58,14 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "avhuff.h"
#include "huffman.h"
#include "chd.h"
-#include <math.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdlib>
#include <new>
@@ -679,18 +679,6 @@ uint16_t *avhuff_encoder::deltarle_encoder::rle_and_histo_bitmap(const uint8_t *
//**************************************************************************
/**
- * @fn avhuff_decoder::avhuff_decoder()
- *
- * @brief -------------------------------------------------
- * avhuff_decoder - constructor
- * -------------------------------------------------.
- */
-
-avhuff_decoder::avhuff_decoder()
-{
-}
-
-/**
* @fn void avhuff_decoder::configure(const avhuff_decompress_config &config)
*
* @brief -------------------------------------------------
diff --git a/src/lib/util/avhuff.h b/src/lib/util/avhuff.h
index 90ef43e977f..d14046e1f62 100644
--- a/src/lib/util/avhuff.h
+++ b/src/lib/util/avhuff.h
@@ -144,7 +144,7 @@ class avhuff_decoder
{
public:
// construction/destruction
- avhuff_decoder();
+ avhuff_decoder() = default;
// configuration
void configure(const avhuff_decompress_config &config);
diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp
index c66f706b6e2..067f81fef27 100644
--- a/src/lib/util/aviio.cpp
+++ b/src/lib/util/aviio.cpp
@@ -298,7 +298,7 @@ public:
std::uint32_t width = info.video_width;
std::uint32_t height = info.video_height;
- std::uint32_t integal_multiple = std::uint32_t(AVI_INTEGRAL_MULTIPLE);
+ auto integal_multiple = std::uint32_t(AVI_INTEGRAL_MULTIPLE);
if (integal_multiple > 1)
{
width = width - (width % integal_multiple);
@@ -720,8 +720,8 @@ inline void put_64bits(std::uint8_t *data, std::uint64_t value)
inline void u64toa(std::uint64_t val, char *output)
{
- std::uint32_t lo = std::uint32_t(val & 0xffffffff);
- std::uint32_t hi = std::uint32_t(val >> 32);
+ auto lo = std::uint32_t(val & 0xffffffff);
+ auto hi = std::uint32_t(val >> 32);
if (hi != 0)
sprintf(output, "%X%08X", hi, lo);
else
@@ -1055,7 +1055,7 @@ avi_file::error avi_stream::rgb32_compress_to_rgb(const bitmap_rgb32 &bitmap, st
avi_file::error avi_stream::yuv_decompress_to_yuy16(const std::uint8_t *data, std::uint32_t numbytes, bitmap_yuy16 &bitmap) const
{
- std::uint16_t const *const dataend = reinterpret_cast<const std::uint16_t *>(data + numbytes);
+ auto const *const dataend = reinterpret_cast<const std::uint16_t *>(data + numbytes);
int x, y;
/* compressed video */
@@ -1107,7 +1107,7 @@ avi_file::error avi_stream::yuv_decompress_to_yuy16(const std::uint8_t *data, st
avi_file::error avi_stream::yuy16_compress_to_yuy(const bitmap_yuy16 &bitmap, std::uint8_t *data, std::uint32_t numbytes) const
{
- std::uint16_t *const dataend = reinterpret_cast<std::uint16_t *>(data + numbytes);
+ auto *const dataend = reinterpret_cast<std::uint16_t *>(data + numbytes);
int x, y;
/* compressed video */
@@ -1871,7 +1871,7 @@ avi_file::error avi_file_impl::read_sound_samples(int channel, std::uint32_t fir
/* extract 16-bit samples from the chunk */
if (stream->samplebits() == 16)
{
- const std::int16_t *base = reinterpret_cast<const std::int16_t *>(&m_tempbuffer[8]);
+ const auto *base = reinterpret_cast<const std::int16_t *>(&m_tempbuffer[8]);
base += stream->channels() * (firstsample - chunkbase) + offset;
for (sampnum = 0; sampnum < samples_this_chunk; sampnum++)
{
@@ -3803,13 +3803,3 @@ const char *avi_file::error_string(error err)
default: return "undocumented error";
}
}
-
-
-avi_file::avi_file()
-{
-}
-
-
-avi_file::~avi_file()
-{
-}
diff --git a/src/lib/util/aviio.h b/src/lib/util/aviio.h
index c951f71b22f..8aa36d80b8b 100644
--- a/src/lib/util/aviio.h
+++ b/src/lib/util/aviio.h
@@ -111,7 +111,7 @@ public:
static error open(std::string const &filename, ptr &file);
static error create(std::string const &filename, movie_info const &info, ptr &file);
- virtual ~avi_file();
+ virtual ~avi_file() = default;
virtual void printf_chunks() = 0;
static const char *error_string(error err);
@@ -128,7 +128,7 @@ public:
virtual error append_sound_samples(int channel, std::int16_t const *samples, std::uint32_t numsamples, std::uint32_t sampleskip) = 0;
protected:
- avi_file();
+ avi_file() = default;
};
#endif // MAME_LIB_UTIL_AVIIO_H
diff --git a/src/lib/util/bitmap.cpp b/src/lib/util/bitmap.cpp
index 87cf8a27b76..ed814aae218 100644
--- a/src/lib/util/bitmap.cpp
+++ b/src/lib/util/bitmap.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "bitmap.h"
diff --git a/src/lib/util/cdrom.cpp b/src/lib/util/cdrom.cpp
index c2cded9f9aa..94efa870d8d 100644
--- a/src/lib/util/cdrom.cpp
+++ b/src/lib/util/cdrom.cpp
@@ -16,11 +16,11 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "cdrom.h"
-#include <stdlib.h>
+#include <cstdlib>
#include "chdcd.h"
@@ -558,7 +558,7 @@ uint32_t cdrom_read_data(cdrom_file *file, uint32_t lbasector, void *buffer, uin
/* return 2352 byte mode 1 raw sector from 2048 bytes of mode 1 data */
if ((datatype == CD_TRACK_MODE1_RAW) && (tracktype == CD_TRACK_MODE1))
{
- uint8_t *bufptr = (uint8_t *)buffer;
+ auto *bufptr = (uint8_t *)buffer;
uint32_t msf = lba_to_msf(lbasector);
static const uint8_t syncbytes[12] = {0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
@@ -1247,7 +1247,7 @@ chd_error cdrom_parse_metadata(chd_file *chd, cdrom_toc *toc)
return err;
/* reconstruct the TOC from it */
- uint32_t *mrp = reinterpret_cast<uint32_t *>(&oldmetadata[0]);
+ auto *mrp = reinterpret_cast<uint32_t *>(&oldmetadata[0]);
toc->numtrks = *mrp++;
for (i = 0; i < CD_MAX_TRACKS; i++)
diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp
index 3b61d044cd3..daad423147a 100644
--- a/src/lib/util/chd.cpp
+++ b/src/lib/util/chd.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "chd.h"
#include "avhuff.h"
@@ -17,9 +17,9 @@
#include "cdrom.h"
#include "coretmpl.h"
#include <zlib.h>
-#include <time.h>
-#include <stddef.h>
-#include <stdlib.h>
+#include <ctime>
+#include <cstddef>
+#include <cstdlib>
#include <new>
#include "eminline.h"
@@ -888,7 +888,7 @@ chd_error chd_file::read_hunk(uint32_t hunknum, void *buffer)
uint32_t blocklen;
util::crc32_t blockcrc;
uint8_t *rawmap;
- uint8_t *dest = reinterpret_cast<uint8_t *>(buffer);
+ auto *dest = reinterpret_cast<uint8_t *>(buffer);
switch (m_version)
{
// v3/v4 map entries
@@ -1045,7 +1045,7 @@ chd_error chd_file::write_hunk(uint32_t hunknum, const void *buffer)
{
// first make sure we need to allocate it
bool all_zeros = true;
- const uint32_t *scan = reinterpret_cast<const uint32_t *>(buffer);
+ const auto *scan = reinterpret_cast<const uint32_t *>(buffer);
for (uint32_t index = 0; index < m_hunkbytes / 4; index++)
if (scan[index] != 0)
{
@@ -1140,7 +1140,7 @@ chd_error chd_file::read_bytes(uint64_t offset, void *buffer, uint32_t bytes)
// iterate over hunks
uint32_t first_hunk = offset / m_hunkbytes;
uint32_t last_hunk = (offset + bytes - 1) / m_hunkbytes;
- uint8_t *dest = reinterpret_cast<uint8_t *>(buffer);
+ auto *dest = reinterpret_cast<uint8_t *>(buffer);
for (uint32_t curhunk = first_hunk; curhunk <= last_hunk; curhunk++)
{
// determine start/end boundaries
@@ -1193,7 +1193,7 @@ chd_error chd_file::write_bytes(uint64_t offset, const void *buffer, uint32_t by
// iterate over hunks
uint32_t first_hunk = offset / m_hunkbytes;
uint32_t last_hunk = (offset + bytes - 1) / m_hunkbytes;
- const uint8_t *source = reinterpret_cast<const uint8_t *>(buffer);
+ const auto *source = reinterpret_cast<const uint8_t *>(buffer);
for (uint32_t curhunk = first_hunk; curhunk <= last_hunk; curhunk++)
{
// determine start/end boundaries
@@ -2947,7 +2947,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
hunk_write_compressed(item.m_hunknum, item.m_compression, item.m_compressed, item.m_complen, item.m_hash[0].m_crc16);
m_total_out += item.m_complen;
m_current_map.add(item.m_hunknum, item.m_hash[0].m_crc16, item.m_hash[0].m_sha1);
- } while (0);
+ } while (false);
// reset the item and advance
item.m_status = WS_READY;
@@ -3010,7 +3010,7 @@ chd_error chd_file_compressor::compress_continue(double &progress, double &ratio
void *chd_file_compressor::async_walk_parent_static(void *param, int threadid)
{
- work_item *item = reinterpret_cast<work_item *>(param);
+ auto *item = reinterpret_cast<work_item *>(param);
item->m_compressor->async_walk_parent(*item);
return nullptr;
}
@@ -3052,7 +3052,7 @@ void chd_file_compressor::async_walk_parent(work_item &item)
void *chd_file_compressor::async_compress_hunk_static(void *param, int threadid)
{
- work_item *item = reinterpret_cast<work_item *>(param);
+ auto *item = reinterpret_cast<work_item *>(param);
item->m_compressor->async_compress_hunk(*item, threadid);
return nullptr;
}
diff --git a/src/lib/util/chdcd.cpp b/src/lib/util/chdcd.cpp
index 85bd7cdad27..b2b0e141499 100644
--- a/src/lib/util/chdcd.cpp
+++ b/src/lib/util/chdcd.cpp
@@ -7,9 +7,9 @@
***************************************************************************/
-#include <ctype.h>
-#include <stdlib.h>
-#include <assert.h>
+#include <cctype>
+#include <cstdlib>
+#include <cassert>
#include "osdcore.h"
#include "chd.h"
#include "chdcd.h"
@@ -262,7 +262,7 @@ static uint32_t parse_wav_sample(const char *filename, uint32_t *dataoffs)
}
/* seek until we find a format tag */
- while (1)
+ while (true)
{
file->read(buf, offset, 4, actual);
offset += actual;
@@ -329,7 +329,7 @@ static uint32_t parse_wav_sample(const char *filename, uint32_t *dataoffs)
offset += length - 16;
/* seek until we find a data tag */
- while (1)
+ while (true)
{
file->read(buf, offset, 4, actual);
offset += actual;
diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp
index 71763163a87..3f76af302bd 100644
--- a/src/lib/util/chdcodec.cpp
+++ b/src/lib/util/chdcodec.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "chd.h"
#include "hashing.h"
@@ -124,7 +124,7 @@ class chd_lzma_compressor : public chd_compressor
public:
// construction/destruction
chd_lzma_compressor(chd_file &chd, uint32_t hunkbytes, bool lossy);
- ~chd_lzma_compressor();
+ ~chd_lzma_compressor() = default;
// core functionality
virtual uint32_t compress(const uint8_t *src, uint32_t srclen, uint8_t *dest) override;
@@ -497,15 +497,6 @@ chd_codec::chd_codec(chd_file &chd, uint32_t hunkbytes, bool lossy)
//-------------------------------------------------
-// ~chd_codec - destructor
-//-------------------------------------------------
-
-chd_codec::~chd_codec()
-{
-}
-
-
-//-------------------------------------------------
// configure - configuration
//-------------------------------------------------
@@ -760,7 +751,7 @@ void chd_zlib_allocator::install(z_stream &stream)
voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size)
{
- chd_zlib_allocator *codec = reinterpret_cast<chd_zlib_allocator *>(opaque);
+ auto *codec = reinterpret_cast<chd_zlib_allocator *>(opaque);
// compute the size, rounding to the nearest 1k
size = (size * items + 0x3ff) & ~0x3ff;
@@ -778,7 +769,7 @@ voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size)
}
// alloc a new one and put it into the list
- uint32_t *ptr = reinterpret_cast<uint32_t *>(new uint8_t[size + sizeof(uint32_t)]);
+ auto *ptr = reinterpret_cast<uint32_t *>(new uint8_t[size + sizeof(uint32_t)]);
for (int scan = 0; scan < MAX_ZLIB_ALLOCS; scan++)
if (codec->m_allocptr[scan] == nullptr)
{
@@ -799,7 +790,7 @@ voidpf chd_zlib_allocator::fast_alloc(voidpf opaque, uInt items, uInt size)
void chd_zlib_allocator::fast_free(voidpf opaque, voidpf address)
{
- chd_zlib_allocator *codec = reinterpret_cast<chd_zlib_allocator *>(opaque);
+ auto *codec = reinterpret_cast<chd_zlib_allocator *>(opaque);
// find the hunk
uint32_t *ptr = reinterpret_cast<uint32_t *>(address) - 1;
@@ -980,7 +971,7 @@ chd_lzma_allocator::~chd_lzma_allocator()
void *chd_lzma_allocator::fast_alloc(void *p, size_t size)
{
- chd_lzma_allocator *codec = reinterpret_cast<chd_lzma_allocator *>(p);
+ auto *codec = reinterpret_cast<chd_lzma_allocator *>(p);
// compute the size, rounding to the nearest 1k
size = (size + 0x3ff) & ~0x3ff;
@@ -998,7 +989,7 @@ void *chd_lzma_allocator::fast_alloc(void *p, size_t size)
}
// alloc a new one and put it into the list
- uint32_t *ptr = reinterpret_cast<uint32_t *>(new uint8_t[size + sizeof(uint32_t)]);
+ auto *ptr = reinterpret_cast<uint32_t *>(new uint8_t[size + sizeof(uint32_t)]);
for (int scan = 0; scan < MAX_LZMA_ALLOCS; scan++)
if (codec->m_allocptr[scan] == nullptr)
{
@@ -1022,7 +1013,7 @@ void chd_lzma_allocator::fast_free(void *p, void *address)
if (address == nullptr)
return;
- chd_lzma_allocator *codec = reinterpret_cast<chd_lzma_allocator *>(p);
+ auto *codec = reinterpret_cast<chd_lzma_allocator *>(p);
// find the hunk
uint32_t *ptr = reinterpret_cast<uint32_t *>(address) - 1;
@@ -1054,15 +1045,6 @@ chd_lzma_compressor::chd_lzma_compressor(chd_file &chd, uint32_t hunkbytes, bool
//-------------------------------------------------
-// ~chd_lzma_compressor - destructor
-//-------------------------------------------------
-
-chd_lzma_compressor::~chd_lzma_compressor()
-{
-}
-
-
-//-------------------------------------------------
// compress - compress data using the LZMA codec
//-------------------------------------------------
diff --git a/src/lib/util/chdcodec.h b/src/lib/util/chdcodec.h
index e688b41a108..8be99b2e710 100644
--- a/src/lib/util/chdcodec.h
+++ b/src/lib/util/chdcodec.h
@@ -50,7 +50,7 @@ protected:
public:
// allow public deletion
- virtual ~chd_codec();
+ virtual ~chd_codec() = default;
// accessors
chd_file &chd() const { return m_chd; }
diff --git a/src/lib/util/corealloc.h b/src/lib/util/corealloc.h
index 222b1428307..5d1f055e19b 100644
--- a/src/lib/util/corealloc.h
+++ b/src/lib/util/corealloc.h
@@ -15,7 +15,7 @@
#include "osdcore.h"
-#include <stdlib.h>
+#include <cstdlib>
#include <cstddef>
#include <cstring>
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp
index 78a484c5511..d241dac6ed1 100644
--- a/src/lib/util/corefile.cpp
+++ b/src/lib/util/corefile.cpp
@@ -20,7 +20,7 @@
#include <cstring>
#include <iterator>
-#include <ctype.h>
+#include <cctype>
namespace util {
@@ -143,7 +143,7 @@ class core_proxy_file : public core_file
{
public:
core_proxy_file(core_file &file) : m_file(file) { }
- virtual ~core_proxy_file() override { }
+ virtual ~core_proxy_file() override = default;
virtual osd_file::error compress(int level) override { return m_file.compress(level); }
virtual int seek(std::int64_t offset, int whence) override { return m_file.seek(offset, whence); }
@@ -395,7 +395,7 @@ int core_text_file::getc()
// fetch the next character
char16_t utf16_buffer[UTF16_CHAR_MAX];
- char32_t uchar = char32_t(~0);
+ auto uchar = char32_t(~0);
switch (m_text_type)
{
default:
@@ -647,7 +647,7 @@ bool core_in_memory_file::eof() const
{
// check for buffered chars
if (has_putback())
- return 0;
+ return false;
// if the offset == length, we're at EOF
return (m_offset >= m_length);
@@ -1233,15 +1233,6 @@ osd_file::error core_file::load(std::string const &filename, std::vector<uint8_t
return osd_file::error::NONE;
}
-
-/*-------------------------------------------------
- protected constructor
--------------------------------------------------*/
-
-core_file::core_file()
-{
-}
-
} // namespace util
diff --git a/src/lib/util/corefile.h b/src/lib/util/corefile.h
index d286cb866ac..99496b964e8 100644
--- a/src/lib/util/corefile.h
+++ b/src/lib/util/corefile.h
@@ -128,7 +128,7 @@ public:
protected:
- core_file();
+ core_file() = default;
};
diff --git a/src/lib/util/corestr.cpp b/src/lib/util/corestr.cpp
index d0d5b576890..d4fc15b1bce 100644
--- a/src/lib/util/corestr.cpp
+++ b/src/lib/util/corestr.cpp
@@ -14,8 +14,8 @@
#include <algorithm>
#include <memory>
-#include <ctype.h>
-#include <stdlib.h>
+#include <cctype>
+#include <cstdlib>
/*-------------------------------------------------
diff --git a/src/lib/util/corestr.h b/src/lib/util/corestr.h
index 1791ae6d226..ee319d69deb 100644
--- a/src/lib/util/corestr.h
+++ b/src/lib/util/corestr.h
@@ -18,7 +18,7 @@
#include <string>
-#include <string.h>
+#include <cstring>
/***************************************************************************
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h
index 6c8ac39b45c..8b6bafa30fb 100644
--- a/src/lib/util/coretmpl.h
+++ b/src/lib/util/coretmpl.h
@@ -45,7 +45,7 @@ template<typename T> constexpr T make_bitmask(unsigned int N)
// a simple_list is a singly-linked list whose 'next' pointer is owned
// by the object
-template<class _ElementType>
+template<class ElementType>
class simple_list final
{
public:
@@ -53,36 +53,31 @@ public:
{
public:
typedef int difference_type;
- typedef _ElementType value_type;
- typedef _ElementType *pointer;
- typedef _ElementType &reference;
+ typedef ElementType value_type;
+ typedef ElementType *pointer;
+ typedef ElementType &reference;
typedef std::forward_iterator_tag iterator_category;
// construction/destruction
auto_iterator() noexcept : m_current(nullptr) { }
- auto_iterator(_ElementType *ptr) noexcept : m_current(ptr) { }
+ auto_iterator(ElementType *ptr) noexcept : m_current(ptr) { }
// required operator overloads
bool operator==(const auto_iterator &iter) const noexcept { return m_current == iter.m_current; }
bool operator!=(const auto_iterator &iter) const noexcept { return m_current != iter.m_current; }
- _ElementType &operator*() const noexcept { return *m_current; }
- _ElementType *operator->() const noexcept { return m_current; }
- // note that _ElementType::next() must not return a const ptr
+ ElementType &operator*() const noexcept { return *m_current; }
+ ElementType *operator->() const noexcept { return m_current; }
+ // note that ElementType::next() must not return a const ptr
auto_iterator &operator++() noexcept { m_current = m_current->next(); return *this; }
auto_iterator operator++(int) noexcept { auto_iterator result(*this); m_current = m_current->next(); return result; }
private:
// private state
- _ElementType *m_current;
+ ElementType *m_current;
};
// construction/destruction
- simple_list() noexcept
- : m_head(nullptr)
- , m_tail(nullptr)
- , m_count(0)
- {
- }
+ simple_list() noexcept { }
~simple_list() noexcept { reset(); }
// we don't support deep copying
@@ -90,18 +85,19 @@ public:
simple_list &operator=(const simple_list &) = delete;
// but we do support cheap swap/move
- simple_list(simple_list &&list) : simple_list() { operator=(std::move(list)); }
+ simple_list(simple_list &&list) noexcept { operator=(std::move(list)); }
simple_list &operator=(simple_list &&list)
{
using std::swap;
swap(m_head, list.m_head);
swap(m_tail, list.m_tail);
swap(m_count, list.m_count);
+ return *this;
}
// simple getters
- _ElementType *first() const noexcept { return m_head; }
- _ElementType *last() const noexcept { return m_tail; }
+ ElementType *first() const noexcept { return m_head; }
+ ElementType *last() const noexcept { return m_tail; }
int count() const noexcept { return m_count; }
bool empty() const noexcept { return m_count == 0; }
@@ -117,7 +113,7 @@ public:
}
// add the given object to the head of the list
- _ElementType &prepend(_ElementType &object) noexcept
+ ElementType &prepend(ElementType &object) noexcept
{
object.m_next = m_head;
m_head = &object;
@@ -128,13 +124,13 @@ public:
}
// add the given list to the head of the list
- void prepend_list(simple_list<_ElementType> &list) noexcept
+ void prepend_list(simple_list<ElementType> &list) noexcept
{
int count = list.count();
if (count == 0)
return;
- _ElementType *tail = list.last();
- _ElementType *head = list.detach_all();
+ ElementType *tail = list.last();
+ ElementType *head = list.detach_all();
tail->m_next = m_head;
m_head = head;
if (m_tail == nullptr)
@@ -143,7 +139,7 @@ public:
}
// add the given object to the tail of the list
- _ElementType &append(_ElementType &object) noexcept
+ ElementType &append(ElementType &object) noexcept
{
object.m_next = nullptr;
if (m_tail != nullptr)
@@ -155,13 +151,13 @@ public:
}
// add the given list to the tail of the list
- void append_list(simple_list<_ElementType> &list) noexcept
+ void append_list(simple_list<ElementType> &list) noexcept
{
int count = list.count();
if (count == 0)
return;
- _ElementType *tail = list.last();
- _ElementType *head = list.detach_all();
+ ElementType *tail = list.last();
+ ElementType *head = list.detach_all();
if (m_tail != nullptr)
m_tail->m_next = head;
else
@@ -171,7 +167,7 @@ public:
}
// insert the given object after a particular object (nullptr means prepend)
- _ElementType &insert_after(_ElementType &object, _ElementType *insert_after) noexcept
+ ElementType &insert_after(ElementType &object, ElementType *insert_after) noexcept
{
if (insert_after == nullptr)
return prepend(object);
@@ -184,11 +180,11 @@ public:
}
// insert the given object before a particular object (nullptr means append)
- _ElementType &insert_before(_ElementType &object, _ElementType *insert_before) noexcept
+ ElementType &insert_before(ElementType &object, ElementType *insert_before) noexcept
{
if (insert_before == nullptr)
return append(object);
- for (_ElementType **curptr = &m_head; *curptr != nullptr; curptr = &(*curptr)->m_next)
+ for (ElementType **curptr = &m_head; *curptr != nullptr; curptr = &(*curptr)->m_next)
if (*curptr == insert_before)
{
object.m_next = insert_before;
@@ -202,10 +198,10 @@ public:
}
// replace an item in the list at the same location, and remove it
- _ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace) noexcept
+ ElementType &replace_and_remove(ElementType &object, ElementType &toreplace) noexcept
{
- _ElementType *prev = nullptr;
- for (_ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next)
+ ElementType *prev = nullptr;
+ for (ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next)
if (cur == &toreplace)
{
if (prev != nullptr)
@@ -222,9 +218,9 @@ public:
}
// detach the head item from the list, but don't free its memory
- _ElementType *detach_head() noexcept
+ ElementType *detach_head() noexcept
{
- _ElementType *result = m_head;
+ ElementType *result = m_head;
if (result != nullptr)
{
m_head = result->m_next;
@@ -236,10 +232,10 @@ public:
}
// detach the given item from the list, but don't free its memory
- _ElementType &detach(_ElementType &object) noexcept
+ ElementType &detach(ElementType &object) noexcept
{
- _ElementType *prev = nullptr;
- for (_ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next)
+ ElementType *prev = nullptr;
+ for (ElementType *cur = m_head; cur != nullptr; prev = cur, cur = cur->m_next)
if (cur == &object)
{
if (prev != nullptr)
@@ -255,34 +251,34 @@ public:
}
// detach the entire list, returning the head, but don't free memory
- _ElementType *detach_all() noexcept
+ ElementType *detach_all() noexcept
{
- _ElementType *result = m_head;
+ ElementType *result = m_head;
m_head = m_tail = nullptr;
m_count = 0;
return result;
}
// remove the given object and free its memory
- void remove(_ElementType &object) noexcept
+ void remove(ElementType &object) noexcept
{
global_free(&detach(object));
}
// find an object by index in the list
- _ElementType *find(int index) const noexcept
+ ElementType *find(int index) const noexcept
{
- for (_ElementType *cur = m_head; cur != nullptr; cur = cur->m_next)
+ for (ElementType *cur = m_head; cur != nullptr; cur = cur->m_next)
if (index-- == 0)
return cur;
return nullptr;
}
// return the index of the given object in the list
- int indexof(const _ElementType &object) const noexcept
+ int indexof(const ElementType &object) const noexcept
{
int index = 0;
- for (_ElementType *cur = m_head; cur != nullptr; cur = cur->m_next)
+ for (ElementType *cur = m_head; cur != nullptr; cur = cur->m_next)
{
if (cur == &object)
return index;
@@ -293,49 +289,16 @@ public:
private:
// internal state
- _ElementType * m_head; // head of the singly-linked list
- _ElementType * m_tail; // tail of the singly-linked list
- int m_count; // number of objects in the list
-};
-
-
-// ======================> simple_list_wrapper
-
-// a simple_list_wrapper wraps an existing object with a next pointer so it
-// can live in a simple_list without requiring the object to have a next
-// pointer
-template<class _ObjectType>
-class simple_list_wrapper
-{
-public:
- template<class U> friend class simple_list;
-
- // construction/destruction
- simple_list_wrapper(_ObjectType *object)
- : m_next(nullptr),
- m_object(object) { }
-
- // operators
- operator _ObjectType *() { return m_object; }
- operator _ObjectType *() const { return m_object; }
- _ObjectType *operator *() { return m_object; }
- _ObjectType *operator *() const { return m_object; }
-
- // getters
- simple_list_wrapper *next() const { return m_next; }
- _ObjectType *object() const { return m_object; }
-
-private:
- // internal state
- simple_list_wrapper * m_next;
- _ObjectType * m_object;
+ ElementType * m_head = nullptr; // head of the singly-linked list
+ ElementType * m_tail = nullptr; // tail of the singly-linked list
+ int m_count = 0; // number of objects in the list
};
// ======================> fixed_allocator
// a fixed_allocator is a simple class that maintains a free pool of objects
-template<class _ItemType>
+template<class ItemType>
class fixed_allocator
{
// we don't support deep copying
@@ -347,24 +310,24 @@ public:
fixed_allocator() { }
// allocate a new item, either by recycling an old one, or by allocating a new one
- _ItemType *alloc()
+ ItemType *alloc()
{
- _ItemType *result = m_freelist.detach_head();
+ ItemType *result = m_freelist.detach_head();
if (result == nullptr)
- result = global_alloc(_ItemType);
+ result = global_alloc(ItemType);
return result;
}
// reclaim an item by adding it to the free list
- void reclaim(_ItemType *item) { if (item != nullptr) m_freelist.append(*item); }
- void reclaim(_ItemType &item) { m_freelist.append(item); }
+ void reclaim(ItemType *item) { if (item != nullptr) m_freelist.append(*item); }
+ void reclaim(ItemType &item) { m_freelist.append(item); }
// reclaim all items from a list
- void reclaim_all(simple_list<_ItemType> &_list) { m_freelist.append_list(_list); }
+ void reclaim_all(simple_list<ItemType> &_list) { m_freelist.append_list(_list); }
private:
// internal state
- simple_list<_ItemType> m_freelist; // list of free objects
+ simple_list<ItemType> m_freelist; // list of free objects
};
@@ -798,6 +761,7 @@ public:
m_mapping.insert(it);
assert(m_elements.size() == m_size);
assert(m_mapping.size() == m_size);
+ return *this;
}
private:
diff --git a/src/lib/util/coreutil.cpp b/src/lib/util/coreutil.cpp
index d973080e354..94ec6dec273 100644
--- a/src/lib/util/coreutil.cpp
+++ b/src/lib/util/coreutil.cpp
@@ -9,7 +9,7 @@
***************************************************************************/
#include "coreutil.h"
-#include <assert.h>
+#include <cassert>
#include <zlib.h>
diff --git a/src/lib/util/delegate.cpp b/src/lib/util/delegate.cpp
index 7b4ee8df76e..1ba81916030 100644
--- a/src/lib/util/delegate.cpp
+++ b/src/lib/util/delegate.cpp
@@ -8,9 +8,9 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include <cstdint>
-#include <stdio.h>
+#include <cstdio>
#include "delegate.h"
diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp
index 54a589ee2a2..9030249a7d0 100644
--- a/src/lib/util/flac.cpp
+++ b/src/lib/util/flac.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "flac.h"
#include <new>
@@ -559,7 +559,7 @@ void flac_decoder::metadata_callback_static(const FLAC__StreamDecoder *decoder,
return;
// parse out the data we care about
- flac_decoder *fldecoder = reinterpret_cast<flac_decoder *>(client_data);
+ auto *fldecoder = reinterpret_cast<flac_decoder *>(client_data);
fldecoder->m_sample_rate = metadata->data.stream_info.sample_rate;
fldecoder->m_bits_per_sample = metadata->data.stream_info.bits_per_sample;
fldecoder->m_channels = metadata->data.stream_info.channels;
diff --git a/src/lib/util/harddisk.cpp b/src/lib/util/harddisk.cpp
index 5db97e3417b..e91759c44f2 100644
--- a/src/lib/util/harddisk.cpp
+++ b/src/lib/util/harddisk.cpp
@@ -8,10 +8,10 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "harddisk.h"
#include "osdcore.h"
-#include <stdlib.h>
+#include <cstdlib>
/***************************************************************************
TYPE DEFINITIONS
diff --git a/src/lib/util/hash.cpp b/src/lib/util/hash.cpp
index ddb6f52ac5c..5808163b6b9 100644
--- a/src/lib/util/hash.cpp
+++ b/src/lib/util/hash.cpp
@@ -12,7 +12,7 @@
#include "hash.h"
#include "hashing.h"
-#include <ctype.h>
+#include <cctype>
namespace util {
diff --git a/src/lib/util/hashing.cpp b/src/lib/util/hashing.cpp
index 448cdc5d6ec..a5946f1ace8 100644
--- a/src/lib/util/hashing.cpp
+++ b/src/lib/util/hashing.cpp
@@ -284,7 +284,7 @@ void crc16_creator::append(const void *data, uint32_t length)
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
};
- const uint8_t *src = reinterpret_cast<const uint8_t *>(data);
+ const auto *src = reinterpret_cast<const uint8_t *>(data);
// fetch the current value into a local and rip through the source data
uint16_t crc = m_accum.m_raw;
diff --git a/src/lib/util/huffman.cpp b/src/lib/util/huffman.cpp
index d3a73315ea9..d8900b45e17 100644
--- a/src/lib/util/huffman.cpp
+++ b/src/lib/util/huffman.cpp
@@ -96,8 +96,8 @@
***************************************************************************/
-#include <stdlib.h>
-#include <assert.h>
+#include <cstdlib>
+#include <cassert>
#include "coretmpl.h"
#include "huffman.h"
@@ -431,7 +431,7 @@ huffman_error huffman_context_base::compute_tree_from_histo()
// binary search to achieve the optimum encoding
uint32_t lowerweight = 0;
uint32_t upperweight = sdatacount * 2;
- while (1)
+ while (true)
{
// build a tree using the current weight
uint32_t curweight = (upperweight + lowerweight) / 2;
@@ -678,14 +678,6 @@ void huffman_context_base::build_lookup_table()
// 8-BIT ENCODER
//**************************************************************************
-//-------------------------------------------------
-// huffman_8bit_encoder - constructor
-//-------------------------------------------------
-
-huffman_8bit_encoder::huffman_8bit_encoder()
-{
-}
-
//-------------------------------------------------
// encode - encode a full buffer
@@ -722,14 +714,6 @@ huffman_error huffman_8bit_encoder::encode(const uint8_t *source, uint32_t sleng
// 8-BIT DECODER
//**************************************************************************
-//-------------------------------------------------
-// huffman_8bit_decoder - constructor
-//-------------------------------------------------
-
-huffman_8bit_decoder::huffman_8bit_decoder()
-{
-}
-
/**
* @fn huffman_error huffman_8bit_decoder::decode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t dlength)
*
diff --git a/src/lib/util/huffman.h b/src/lib/util/huffman.h
index 0eac393f380..233146e8e20 100644
--- a/src/lib/util/huffman.h
+++ b/src/lib/util/huffman.h
@@ -149,7 +149,7 @@ class huffman_8bit_encoder : public huffman_encoder<>
{
public:
// construction/destruction
- huffman_8bit_encoder();
+ huffman_8bit_encoder() = default;
// operations
huffman_error encode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t destlength, uint32_t &complength);
@@ -163,7 +163,7 @@ class huffman_8bit_decoder : public huffman_decoder<>
{
public:
// construction/destruction
- huffman_8bit_decoder();
+ huffman_8bit_decoder() = default;
// operations
huffman_error decode(const uint8_t *source, uint32_t slength, uint8_t *dest, uint32_t destlength);
diff --git a/src/lib/util/jedparse.cpp b/src/lib/util/jedparse.cpp
index f7b252861a2..14cc503f18f 100644
--- a/src/lib/util/jedparse.cpp
+++ b/src/lib/util/jedparse.cpp
@@ -16,10 +16,10 @@
***************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cctype>
#include "jedparse.h"
@@ -189,7 +189,7 @@ static void process_field(jed_data *data, const uint8_t *cursrc, const uint8_t *
int jed_parse(const void *data, size_t length, jed_data *result)
{
- const uint8_t *cursrc = (const uint8_t *)data;
+ const auto *cursrc = (const uint8_t *)data;
const uint8_t *srcend = cursrc + length;
const uint8_t *scan;
jed_parse_info pinfo;
@@ -283,7 +283,7 @@ int jed_parse(const void *data, size_t length, jed_data *result)
size_t jed_output(const jed_data *data, void *result, size_t length)
{
- uint8_t *curdst = (uint8_t *)result;
+ auto *curdst = (uint8_t *)result;
uint8_t *dstend = curdst + length;
int i, zeros, ones;
char tempbuf[256];
@@ -379,7 +379,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length)
int jedbin_parse(const void *data, size_t length, jed_data *result)
{
- const uint8_t *cursrc = (const uint8_t *)data;
+ const auto *cursrc = (const uint8_t *)data;
/* initialize the output */
memset(result, 0, sizeof(*result));
@@ -439,7 +439,7 @@ int jedbin_parse(const void *data, size_t length, jed_data *result)
size_t jedbin_output(const jed_data *data, void *result, size_t length)
{
- uint8_t *curdst = (uint8_t *)result;
+ auto *curdst = (uint8_t *)result;
/* ensure we have enough room */
if (length >= 4 + (data->numfuses + 7) / 8)
diff --git a/src/lib/util/md5.cpp b/src/lib/util/md5.cpp
index 712bd4a23f3..3e26d0c5b07 100644
--- a/src/lib/util/md5.cpp
+++ b/src/lib/util/md5.cpp
@@ -22,7 +22,7 @@
* Still in the public domain.
*/
-#include <string.h> /* for memcpy() */
+#include <cstring> /* for memcpy() */
#include "md5.h"
diff --git a/src/lib/util/opresolv.cpp b/src/lib/util/opresolv.cpp
index 05b8a5e8898..210dde4f224 100644
--- a/src/lib/util/opresolv.cpp
+++ b/src/lib/util/opresolv.cpp
@@ -8,10 +8,10 @@
****************************************************************************/
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
+#include <cctype>
+#include <cstdlib>
+#include <cstring>
+#include <cassert>
#include "pool.h"
#include "corestr.h"
@@ -63,15 +63,6 @@ option_resolution::option_resolution(const option_guide &guide)
// -------------------------------------------------
-// dtor
-// -------------------------------------------------
-
-option_resolution::~option_resolution()
-{
-}
-
-
-// -------------------------------------------------
// lookup_in_specification
// -------------------------------------------------
diff --git a/src/lib/util/opresolv.h b/src/lib/util/opresolv.h
index 52030dc4336..a102dcd8c83 100644
--- a/src/lib/util/opresolv.h
+++ b/src/lib/util/opresolv.h
@@ -43,7 +43,7 @@
#pragma once
-#include <stdlib.h>
+#include <cstdlib>
#include <vector>
#include <string>
@@ -243,7 +243,7 @@ public:
// ctor/dtor
option_resolution(const option_guide &guide);
- ~option_resolution();
+ ~option_resolution() = default;
// sets a specification
void set_specification(const std::string &specification);
diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp
index 65aac4a8883..fd0783ccaae 100644
--- a/src/lib/util/options.cpp
+++ b/src/lib/util/options.cpp
@@ -15,10 +15,10 @@
#include <locale>
#include <string>
-#include <assert.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdlib.h>
+#include <cassert>
+#include <cctype>
+#include <cstdarg>
+#include <cstdlib>
const int core_options::MAX_UNADORNED_OPTIONS;
@@ -423,15 +423,6 @@ const char *core_options::simple_entry::maximum() const noexcept
//**************************************************************************
//-------------------------------------------------
-// core_options - constructor
-//-------------------------------------------------
-
-core_options::core_options()
-{
-}
-
-
-//-------------------------------------------------
// ~core_options - destructor
//-------------------------------------------------
@@ -520,7 +511,7 @@ void core_options::add_entry(const options_entry &opt, bool override_existing)
{
for (const std::string &name : names)
{
- existing_entry = get_entry(name.c_str());
+ existing_entry = get_entry(name);
if (existing_entry)
break;
}
@@ -657,7 +648,7 @@ void core_options::parse_command_line(const std::vector<std::string> &args, int
// special case - collect unadorned arguments after commands into a special place
if (is_unadorned && !m_command.empty())
{
- m_command_arguments.push_back(std::move(args[arg]));
+ m_command_arguments.push_back(args[arg]);
command_argument_processed();
continue;
}
diff --git a/src/lib/util/options.h b/src/lib/util/options.h
index 457ec08dd1d..a28720a0373 100644
--- a/src/lib/util/options.h
+++ b/src/lib/util/options.h
@@ -147,7 +147,7 @@ public:
};
// construction/destruction
- core_options();
+ core_options() = default;
core_options(const core_options &) = delete;
core_options(core_options &&) = default;
core_options& operator=(const core_options &) = delete;
@@ -213,7 +213,7 @@ private:
simple_entry(simple_entry &&) = delete;
simple_entry& operator=(const simple_entry &) = delete;
simple_entry& operator=(simple_entry &&) = delete;
- ~simple_entry();
+ virtual ~simple_entry();
// getters
virtual const char *value() const noexcept override;
diff --git a/src/lib/util/palette.cpp b/src/lib/util/palette.cpp
index 488f7f8a2d2..47fa06c05bd 100644
--- a/src/lib/util/palette.cpp
+++ b/src/lib/util/palette.cpp
@@ -8,11 +8,11 @@
******************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "palette.h"
-#include <stdlib.h>
-#include <math.h>
+#include <cstdlib>
+#include <cmath>
#include <algorithm>
@@ -256,15 +256,6 @@ palette_t::palette_t(uint32_t numcolors, uint32_t numgroups)
// palette_t - destructor
//-------------------------------------------------
-palette_t::~palette_t()
-{
-}
-
-
-//-------------------------------------------------
-// palette_t - destructor
-//-------------------------------------------------
-
void palette_t::deref()
{
if (--m_refcount == 0)
diff --git a/src/lib/util/palette.h b/src/lib/util/palette.h
index ff2c7bb80c9..0407a87c29b 100644
--- a/src/lib/util/palette.h
+++ b/src/lib/util/palette.h
@@ -191,7 +191,7 @@ public:
private:
// construction/destruction
palette_t(uint32_t numcolors, uint32_t numgroups = 1);
- ~palette_t();
+ ~palette_t() = default;
// internal helpers
rgb_t adjust_palette_entry(rgb_t entry, float brightness, float contrast, const uint8_t *gamma_map);
diff --git a/src/lib/util/plaparse.cpp b/src/lib/util/plaparse.cpp
index d1e7c679f97..756d29f46da 100644
--- a/src/lib/util/plaparse.cpp
+++ b/src/lib/util/plaparse.cpp
@@ -10,10 +10,10 @@
***************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cctype>
#include "jedparse.h"
#include "plaparse.h"
@@ -308,7 +308,7 @@ static bool process_field(jed_data *data, const uint8_t **src, const uint8_t *sr
int pla_parse(const void *data, size_t length, jed_data *result)
{
- const uint8_t *src = (const uint8_t *)data;
+ const auto *src = (const uint8_t *)data;
const uint8_t *srcend = src + length;
parse_info pinfo;
diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp
index 6b13f4f9593..6eb5293da53 100644
--- a/src/lib/util/png.cpp
+++ b/src/lib/util/png.cpp
@@ -21,8 +21,8 @@
#include <cmath>
#include <new>
-#include <math.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdlib>
@@ -201,7 +201,7 @@ private:
stream.next_out = pnginfo.image.get();
stream.avail_out = expected;
stream.avail_in = 0;
- std::list<image_data_chunk>::const_iterator it = idata.begin();
+ auto it = idata.begin();
while ((idata.end() != it) && ((Z_OK == zerr) || (Z_BUF_ERROR == zerr)) && !stream.avail_in)
{
stream.avail_in = it->length;
@@ -1042,7 +1042,7 @@ static png_error convert_bitmap_to_image_palette(png_info &pnginfo, const bitmap
/* copy in the pixels, specifying a nullptr filter */
for (y = 0; y < pnginfo.height; y++)
{
- uint16_t *src = reinterpret_cast<uint16_t *>(bitmap.raw_pixptr(y));
+ auto *src = reinterpret_cast<uint16_t *>(bitmap.raw_pixptr(y));
uint8_t *dst = &pnginfo.image[y * (rowbytes + 1)];
/* store the filter byte, then copy the data */
@@ -1088,7 +1088,7 @@ static png_error convert_bitmap_to_image_rgb(png_info &pnginfo, const bitmap_t &
/* 16bpp palettized format */
if (bitmap.format() == BITMAP_FORMAT_IND16)
{
- uint16_t *src16 = reinterpret_cast<uint16_t *>(bitmap.raw_pixptr(y));
+ auto *src16 = reinterpret_cast<uint16_t *>(bitmap.raw_pixptr(y));
for (x = 0; x < pnginfo.width; x++)
{
rgb_t color = palette[*src16++];
@@ -1101,7 +1101,7 @@ static png_error convert_bitmap_to_image_rgb(png_info &pnginfo, const bitmap_t &
/* 32-bit RGB direct */
else if (bitmap.format() == BITMAP_FORMAT_RGB32)
{
- uint32_t *src32 = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(y));
+ auto *src32 = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(y));
for (x = 0; x < pnginfo.width; x++)
{
rgb_t raw = *src32++;
@@ -1114,7 +1114,7 @@ static png_error convert_bitmap_to_image_rgb(png_info &pnginfo, const bitmap_t &
/* 32-bit ARGB direct */
else if (bitmap.format() == BITMAP_FORMAT_ARGB32)
{
- uint32_t *src32 = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(y));
+ auto *src32 = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(y));
for (x = 0; x < pnginfo.width; x++)
{
rgb_t raw = *src32++;
diff --git a/src/lib/util/pool.cpp b/src/lib/util/pool.cpp
index 606a7aea4b6..6bf049db03d 100644
--- a/src/lib/util/pool.cpp
+++ b/src/lib/util/pool.cpp
@@ -8,9 +8,9 @@
***************************************************************************/
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdlib.h>
+#include <cstdarg>
+#include <cstddef>
+#include <cstdlib>
#include "pool.h"
#include "coreutil.h"
@@ -578,7 +578,7 @@ static void memory_error(const char *message)
* @return An int.
*/
-bool test_memory_pools(void)
+bool test_memory_pools()
{
object_pool *pool;
void *ptrs[16];
diff --git a/src/lib/util/sha1.cpp b/src/lib/util/sha1.cpp
index fcda6ff9995..abc073cb6e8 100644
--- a/src/lib/util/sha1.cpp
+++ b/src/lib/util/sha1.cpp
@@ -27,9 +27,9 @@
#include "sha1.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
static unsigned int READ_UINT32(const uint8_t* data)
{
diff --git a/src/lib/util/unicode.h b/src/lib/util/unicode.h
index 46e1aec3496..9c727041db8 100644
--- a/src/lib/util/unicode.h
+++ b/src/lib/util/unicode.h
@@ -23,7 +23,7 @@
#include <string>
-#include <stdlib.h>
+#include <cstdlib>
diff --git a/src/lib/util/unzip.cpp b/src/lib/util/unzip.cpp
index 836d67f1113..a659445e1cc 100644
--- a/src/lib/util/unzip.cpp
+++ b/src/lib/util/unzip.cpp
@@ -1159,7 +1159,7 @@ archive_file::error zip_file_impl::decompress_data_type_8(std::uint64_t offset,
}
// loop until we're done
- while (1)
+ while (true)
{
// read in the next chunk of data
std::uint32_t read_length(0);
diff --git a/src/lib/util/vbiparse.cpp b/src/lib/util/vbiparse.cpp
index bfd145dd99f..6b790ec7180 100644
--- a/src/lib/util/vbiparse.cpp
+++ b/src/lib/util/vbiparse.cpp
@@ -10,7 +10,7 @@
#include "osdcore.h"
#include "vbiparse.h"
-#include <math.h>
+#include <cmath>
#include <algorithm>
diff --git a/src/lib/util/wavwrite.cpp b/src/lib/util/wavwrite.cpp
index 93b4b0a6ca7..56a7cd4e43b 100644
--- a/src/lib/util/wavwrite.cpp
+++ b/src/lib/util/wavwrite.cpp
@@ -23,7 +23,7 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels)
std::uint16_t temp16;
// allocate memory for the wav struct
- wav_file *const wav = new (std::nothrow) wav_file;
+ auto *const wav = new (std::nothrow) wav_file;
if (!wav)
return nullptr;
diff --git a/src/lib/util/xmlfile.cpp b/src/lib/util/xmlfile.cpp
index 1014a7b245c..8ba2cec92c3 100644
--- a/src/lib/util/xmlfile.cpp
+++ b/src/lib/util/xmlfile.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
-#include <assert.h>
+#include <cassert>
#include "xmlfile.h"
@@ -68,9 +68,6 @@ static void expat_element_end(void *data, const XML_Char *name);
XML FILE OBJECTS
***************************************************************************/
-file::file() { }
-file::~file() { }
-
/*-------------------------------------------------
create - create a new, empty XML file
@@ -757,7 +754,7 @@ const char *normalize_string(const char *string)
static void *expat_malloc(size_t size)
{
- uint32_t *result = (uint32_t *)malloc(size + 4 * sizeof(uint32_t));
+ auto *result = (uint32_t *)malloc(size + 4 * sizeof(uint32_t));
*result = size;
return &result[4];
}
@@ -840,7 +837,7 @@ static bool expat_setup_parser(parse_info &info, parse_options const *opts)
static void expat_element_start(void *data, const XML_Char *name, const XML_Char **attributes)
{
- parse_info *info = (parse_info *) data;
+ auto *info = (parse_info *) data;
data_node **curnode = &info->curnode;
data_node *newnode;
int attr;
@@ -869,7 +866,7 @@ static void expat_element_start(void *data, const XML_Char *name, const XML_Char
static void expat_data(void *data, const XML_Char *s, int len)
{
- parse_info *info = (parse_info *) data;
+ auto *info = (parse_info *) data;
data_node **curnode = &info->curnode;
(*curnode)->append_value(s, len);
}
@@ -882,7 +879,7 @@ static void expat_data(void *data, const XML_Char *s, int len)
static void expat_element_end(void *data, const XML_Char *name)
{
- parse_info *info = (parse_info *) data;
+ auto *info = (parse_info *) data;
data_node **curnode = &info->curnode;
/* strip leading/trailing spaces from the value data */
diff --git a/src/lib/util/xmlfile.h b/src/lib/util/xmlfile.h
index 8d09b2b7e1e..659ad59ae31 100644
--- a/src/lib/util/xmlfile.h
+++ b/src/lib/util/xmlfile.h
@@ -215,7 +215,7 @@ public:
using ptr = std::unique_ptr<file>;
- ~file();
+ ~file() = default;
// create a new, empty XML file
static ptr create();
@@ -231,7 +231,7 @@ public:
private:
- file();
+ file() = default;
};
diff --git a/src/lib/util/zippath.cpp b/src/lib/util/zippath.cpp
index d8e90de11ff..760c64fd066 100644
--- a/src/lib/util/zippath.cpp
+++ b/src/lib/util/zippath.cpp
@@ -13,7 +13,7 @@
#include "corestr.h"
#include "osdcore.h"
-#include <stdlib.h>
+#include <cstdlib>
#include <cassert>
#include <cctype>
@@ -264,7 +264,7 @@ osd_file::error zippath_resolve(const char *path, osd::directory::entry::entry_t
apath = zippath_parent(apath);
}
}
- while ((current_entry_type == osd::directory::entry::entry_type::NONE) && !is_root(apath.c_str()));
+ while ((current_entry_type == osd::directory::entry::entry_type::NONE) && !is_root(apath));
// if we did not find anything, then error out
if (current_entry_type == osd::directory::entry::entry_type::NONE)