Commit Graph

75 Commits

Author SHA1 Message Date
couriersud
324f9d44d5
netlist: More c++, less macros, added support for cspell (#9794)
- More c++, less macros
  * Significantly reduced the use of unused_var and replaced it with
    [[maybe_unused]]
  * use enum class in ppmf.h

- Changes to testing code in ptest.h
  * Catch exceptions in more places
  * The verbosity of the output can now be controlled
  * Display of test stats totals

- added support for cspell
- fixed various typos
- fixed SUBTARGET=nl build
- fixed more file permissions
- srcclean and add fix_permissions target to netlist makefile
2022-05-22 01:16:50 +10:00
Olivier Galibert
40acc597d4 netlist: Relicensing of the GPL code to BSD-3 with the blessing of the
copyright owners.  Much thanks for that Couriersud, the main creator
and contributor, but also to Jonathan Gevaryahu and Sergey Svishchev.

There are small remnants in machine/NL_*, specifially breakout, pong
doubles and rebound that are also copyrighted by the DICE team,
whoever that means.  They're not critical since they only concern
these drivers and not an important core subsystem.
2021-03-09 09:26:00 +01:00
couriersud
e62e2d759b netlist: optimize headers.
* where possible rely on forward declarations to optimiuze compile time.
2020-09-17 19:45:10 +02:00
couriersud
6726338362 netlist: Move selected NET_MODELS into the core 2020-09-12 23:52:20 +02:00
couriersud
ca31c844cd netlist: move to generated header and link support files files.
* Removed device and macro header files.
* All of those can be generated automatically so going forward there is
no need for these any longer.
* Introduced the modules concept. Modules are netlists for which
automatic lib entries are generated.
* Going forward you just store them in macro/modules and they will be
automatically registered as device elements.
* You need to do a "make generated" is src/lib/netlist/build
* Some_device.cpp still needs to be added to netlist.lua
* Added documentation on how to add devices to netlist.
* Please refer to adding_devices.md for more information.
2020-09-12 23:20:16 +02:00
Couriersud
f3eb632465 netlist: code maintenance and performance optimizations.
* rename some misleading type names
* remove callback_t and replace by better scalable approach
* hide implementations details
* move sources classes from putil.h to psources.h
* reduce code complexity
* improve parsing performance, parsing netlists now is twice as fast.
* fix issues around multi-byte string support
* moved psplit into pstrutil.h
2020-09-05 21:31:49 +02:00
couriersud
5d3342c837 netlist: Fix processing of TRUTHTABLES for generated files.
* also made nld_devinc.h srcclean friendly.
* nld_devinc.h and lib_entries.hxx are currently not used. You can try
the automated build by changing NL_AUTO_DEVICES in setup.h to 1.
2020-08-28 09:32:24 +02:00
couriersud
e00a6ccf41 netlist: Truth tables are now standalone objects.
* Added TRUTHTABLE_ENTRY to netlist language.
* Please see nlm_ttl74xx for reference implementation.
2020-08-26 22:12:57 +02:00
couriersud
b612367b33 netlist: clang tidy include order fixes. 2020-08-24 22:01:58 +02:00
couriersud
290ffa74fc netlist: Remove printf debugging.
* also raises error if during parsing a local source is not found.
2020-08-15 22:20:24 +02:00
couriersud
167da15753 netlist: improve parsing performance
* preparational work for easier device addition.
2020-08-12 20:17:10 +02:00
couriersud
9809a7b991 netlist: align naming of files within the macro folder.
* Use a consistent naming scheme. This is a preparational step towards
improved parsing performance.
2020-08-10 18:31:34 +02:00
couriersud
d524688df1 netlist: Refactored pokenizer.
* Separated tokenizing and reading of tokens.
* This enables caching of parsing results on the token level.
* Implemented caching of token stream.
* Overall this significantly improves parsing performance (~10x)
* Next step towards a bare-bone nltool which does not depend on macro
devices.
2020-08-06 09:44:59 +02:00
couriersud
c00cbad238 netlist: Add a missing directive to the file parser. 2020-07-28 20:42:13 +02:00
couriersud
319be2dfd2 netlist: code maintenance and bug fixes.
* palloc.h/pmatrix2d.h: Fix static_assert warnings at the origin.
* Rework hints to broaden their use and fix NC hint.
* 74377: use NC hint
* plists.h: Fix debugging in MSVC
* Include cleanup: Move everything not needed by netlists from
nl_setup.h into core/setup.h
* Fix some clang tidy warnings
* srcclean
2020-07-01 20:59:04 +02:00
couriersud
1408aab30c netlist: add hints for outputs not connected. [Couriersud, Aaron Giles]
* Logic and analogue outputs can now be flagged as "NC" (not connected).
* Example: "HINT(IC13.4, NC)".
* This will suppress info messages to be logged.
* The HINT must apply to an existing terminal. HINTs for non-existing
terminals are treated as fatal errors.
* Terminals and logic inputs not connected are still treated as
warnings. These need though and a proper fix.
2020-06-28 16:55:34 +02:00
couriersud
e949e9c29d netlist: Performance improvement and refactoring. [Couriersud]
Kidniki now achieves up to 910% when run with static solvers and with
nltool. That is significant better than the 860% we have seen
previously.

This increase is driven by using a global memory pool in the solver
code.

In addition the following refactoring and code maintenance work is
included. Please excuse the large commit, some of this took interfered
with other work and the detail development steps were ugly.

- gsl support: This commit adds pgsl.h which implements a very limited
  number of the functionality of the gsl header described in the c++ core
  guidelines.
- clang-tidy fixes
- A significant refactoring of palloc.h. Aligned hints were removed,
  they added complexity without a significant performance gain. Vector
  operations should better be done on special spans/views.

The code has been tested on linux with g++-7, g++-9, clang-11.
On Windows mingw-10 and VS2019, OSX clang-11.
2020-06-13 15:49:35 +02:00
couriersud
40628bc269 netlist: simplify factory call structure. (nw)
This change will make it a lot easier to add enhanced functionality to
the factory infrastructure.
Using integral constants also improves linking stability.
2020-05-20 07:58:57 +02:00
couriersud
a94de94c73 netlist: improve typesafety for source locations. (nw)
During object creation netlist tracks the source files which provide
object creation. This is later used e.g. by nltool to create
documentation from source.
2020-05-17 19:52:24 +02:00
couriersud
faac9a2d2c netlist: Extended functionality and code cleanup. [Couriersud]
- working macro level parameters
- simplified code significantly
- fixed a number of hidden issue
- dead code removal

It is now possible to define netlist level parameters using:

static NETLIST_START(chip)
DEFPARAM(parameter, 123)
RES(R1, $(@.parameter))
....
NETLIST_END()

NETLIST_START(main)

chip(X1)
PARAM(X1.parameter, 1000)
...
NETLIST_END()

This will pass on 1000 to R1 as a parameter.

"@." will resolve to the current namespace. In this case it is X1, thus
"X1.parameter. This is during parsing. During evalution, i.e. device
creation, $(X1.parameter) is evaluated to 1000.

This also means, that global parameters are possible and accessible ...

DEFPARAM(P, 234)
...
RES(R1, $(P))

or going forward

RES(R1, 1000)
CAP(C1, 1.0 / $(R1.R))

This opens up the path to more possibilities ...

static NETLIST_START(DM9456_DIP)
DEFPARAM(MODEL, "74XX")
DM9456_GATE(X1)
DM9456_GATE(X2)
PARAM(X1.MODEL, $(@.MODEL))
PARAM(X2.MODEL, $(@.MODEL))
...
NETLIST_END()

NETLIST_START(main)

DM9456_DIP(X1)
PARAM(X1.MODEL, "LS74XX")
...
NETLIST_END()

The code also has been prepared to allow something along the lines of

LIBENTRY_MODEL(DM74LS00_DIP, DM7400_DIP, "LS74XX")

to define a LS version on top of an DM7400_DIP bare TTL implementation.
This however will need more efforts to existing devices to honour some
timing adjustment in the model definition. It will already honour
different output specifications between LS series and bare TTL if
connected to analog components.
2020-05-12 18:52:44 +02:00
couriersud
fceee50c8b netlist: Parameters evaluated when netlist is created. [Couriersud]
Parameters are now passed to the netlist core as strings. During netlist
creation they are evaluated as functions. This opens the path to
parameters on subdevice level.

Examples:

PARAM(device.XY, (1+2*0.005))
RES(R1, 2.05*RES_K(1)+1)

In addition the commit contains dead code removal.
2020-01-29 19:00:10 +01:00
couriersud
f7d8a10da5 netlist: Code maintenance. (nw)
- Fixed some clang lint warnings
- Removed dead code
- Experimental parser code to allow calculations in parameter value.
  This already works for compiled netlists. These changes are
  currently disabled. Updated pong netlist (and CRC/SHA) to work
  with this new code.
2020-01-27 21:47:41 +01:00
couriersud
6874b1f7ac netlist: clang lint readability fixes. (nw) 2020-01-25 21:13:21 +01:00
couriersud
9e272e4b55 netlist: code maintenance. (nw)
- remove pthrow trampline as proposed by Vas.
- identify throwing code by adding noexcept(false)
- move "connected term" information to setup code.
- srcclean
2020-01-20 21:15:22 +01:00
couriersud
67dc264e22 netlist: more code maintenance. (nw)
- refactor error messages.
- Fix some drivers to cope with outputted added my the mame driver
  for video and sound.
- Fix validation.
2019-11-16 16:09:04 +01:00
couriersud
63561e2c2c netlist: maintenance. (nw)
- Fix automatic header generation
- clang lint fixes.
- srcclean
- remove dead code
2019-11-11 15:04:21 +01:00
couriersud
b8c43342d5 netlist: first steps on the way to calculated parameters. [Couriersud]
This commit is a first step towards using formulas in parameters, i.e.

MAINCLOCK(clock, 20 * 30)

The intention is to improve readability and scalability.
Since device registration already provides all necessary information
about parameters, the code to create an include file for all
devices has been improved. Long term, this will remove the need for
device specific header files.

In addition going forward devices will accept either no connections or
all specified connections, i.e.

TTL_7400_NAND(name, chip1.2, chip2.3)

or

TTL_7400_NAND(name)
NET_C(...)
NET_C(...)

This will allow to remove all duplicate definitions which are currently
necessary, i.e. TTL_7400_NAND/TTL_7400_GATE
2019-11-10 19:54:26 +01:00
couriersud
88f702b416 netlist: code maintenance and bug fixes. (nw)
- comment style migration continues.
- Fixed a two bugs in the truthtable ignore inputs code
- refactored the truthtable code a bit for better readability.
- updated netlist specific gitignore.
2019-11-08 23:52:14 +01:00
couriersud
bbbd1c0e8e netlist: maintenance. (nw)
- switch to VS 2019 community and fix standalone build.
- more migration to C++ comment style.
- add some more doxygen markup.
2019-11-08 12:56:05 +01:00
couriersud
22e07506cc netlist: more consistent exception handling. (nw)
Still not optimal, but better than what we had previously. No exception
logging comes closer.
2019-11-05 00:08:52 +01:00
couriersud
2cf61b2e4c netlist: code maintenance. (nw)
- more const
- explicitly raise exceptions instead of leaving this to log.fatal()
- correct a number of cppcheck findings.
- dead code removal
- clang lint corrections, e.g. include order
2019-11-04 22:04:11 +01:00
couriersud
db0dbeaea5 netlist: improve readability. (nw)
Renamed cast member of the constants struct to magic to clearly identify
magic numbers.

Introduced nlconst struct inheriting from plib::constants<nl_fptype> to
make code better understandable.
2019-11-02 23:39:24 +01:00
couriersud
77ea61bac7 netlist: add RELTOL/VNTOL solver parameters. Type safety. [Couriersud]
The newly added RELTOL and VNTOL parameters implement Newton convergence
checks comparable following other SPICE implementations.
The ACCURACY solver parameter now is only used for convergence checks in
iterative solvers.

In addition, type safety was significantly improved and a lot of "magic"
numbers are identifiable now.
2019-11-02 22:25:11 +01:00
couriersud
6c075e602c netlist: maintenance and simplifcation. (nw)
- solver: align matrix population along the various solvers
- solver: delete dead code
- renamed nl_double to nl_fptype and use nl_fptype where previously
  double has been used.
- renamed param_double_t to param_fp_t
2019-10-31 18:39:09 +01:00
couriersud
cac86fb1b4 netlist: code maintenance. (nw)
- Removed code no longer used
- Add noexcept where appropriate
- split pparser.[c|h] into ppreprocessor and ptokenizer
- smaller optimizations, e.g. use of std::size_t
- fix lint warnings
2019-10-29 19:55:53 +01:00
couriersud
97129cece5 netlist: Preprocessor enhancements. [Couriersud]
The builtin preprocessor now behaves closer to cpp:

- supports macro parameters, i.e. define x(a) a
- supports stringification, i.e. define x(a) #a
- supports concatenation, i.e. define x(a) a ## _ext

In addition, error reporting now provides a source context including the
include history.
2019-10-28 13:44:26 +01:00
couriersud
a89b7d194d netlist: mame netlist reorganization. [Couriersud]
- moved netlists out of driver code into audio/ or machine/ as
nl_xxx.cpp files.
- identified and documented extended validation
- updated arcade, mess and nl targets
2019-10-13 16:45:30 +02:00
couriersud
8f83e4392f netlist: code maintenance (nw)
- clang lint and pedantic fixes
- mat_cr.h: separate solving linear systems from underlying matrix
2019-10-12 19:36:50 +02:00
couriersud
545f8069ef netlist: maintenance and lint fixes. (nw) 2019-10-06 23:50:13 +02:00
couriersud
545ebe832d netlist: more lint corrections. (nw)
- fixed lint corrections
- added NOLINT where needed
2019-09-28 21:45:59 +02:00
couriersud
56f9e77b84 netlist: Fix MT06827.
All pstonum calls now need to specify if they want local locale
or the "classic" "C" locale.
2019-04-22 21:08:49 +02:00
couriersud
6b96f7ba60 netlist: Add power terminals to most logic devices.
This fixes an over simplification. Logic devices implicitly assumed that
GND/VDD actually is connected to GND(i.e. 0V). There is no immediate
benefit from this change. It is a preparation for the future
scalability. Now all power terminals (typically 7/14, 8/16) have to be
explicitly connected to the supply rails.

Also added a validation mode to the netlist core. This is not
intended for running, but solely to better indentify pins which
are not properly connected.
2019-04-21 12:05:44 +02:00
couriersud
6392b345e6 netlist: scalable error messages.
This approach uses functors for logging messages.
2019-04-18 01:18:01 +02:00
Vas Crabb
97b6717027 (nw) Clean up the mess on master
This effectively reverts b380514764 and
c24473ddff, restoring the state at
598cd52272.

Before pushing, please check that what you're about to push is sane.
Check your local commit log and ensure there isn't anything out-of-place
before pushing to mainline.  When things like this happen, it wastes
everyone's time.  I really don't need this in a week when real work™ is
busting my balls and I'm behind where I want to be with preparing for
MAME release.
2019-03-26 11:13:37 +11:00
andreasnaive
b380514764 Revert "conflict resolution (nw)"
This reverts commit c24473ddff, reversing
changes made to 009cba4fb8.
2019-03-25 23:13:40 +01:00
couriersud
f4c0f8c74b netlist: more cpp core guidelines work. (nw) 2019-02-08 23:18:47 +01:00
couriersud
3b899b86e6 netlist: Refactoring after adding clang-tidy support to netlist makefile
- convert macros to c++ code.
- order of device creation should not depend on std lib.
- some state saving cleanup.
- added support for clang-tidy to makefile.
- modifications triggered by clang-tidy-9.
2019-02-07 21:54:11 +01:00
couriersud
17d32e0bd5 netlist: pstream and ppreprocessor (now a pistream) refactoring. (nw) 2019-01-19 18:17:35 +01:00
couriersud
f12f735f54 Fix clang-8 warnings. (nw) 2019-01-11 21:50:43 +01:00
couriersud
4213a396d8 Improve type safety on string->numeric conversions. (nw)
Also fixed an issue with 7497.

./nltool -t 5 -f src/mame/machine/nl_tp1983.cpp -v

now runs again.
2019-01-10 00:30:51 +01:00