Commit Graph

72 Commits

Author SHA1 Message Date
Vas Crabb
5e8fefbb12 Turn psring iterator into a real forward iterator that works with standard algorithms.
There are a few changes to achieve this:
* Rename to const_iterator since it's immutable
* Typedef iterator to const_iterator for now as there's no mutable iterator
* Add default constrcutor and operator-> required by concept, const-qualify operators
* Remove operator+ and operator+= since it's not a random-access iterator (use std::next and std::advance instead)
* Return reference/pointer to a proxy rather than a code_t value from opertator*/operator->

The final change is required to meet the requirement that operator* for
two equivalent forward iterators return an equivalent reference.  The
pstring doesn't actually contain a sequence of code_t, so there's no way
to return a reference to code_t directly.  Instead, a reference to a
proxy object aliased on the string storage is returned.  The proxy is
implicitly convertible to code_t.  The most noticeable side effect is
that auto c = *s.begin() or for (auto c : s) won't work.  You need to do
for (auto &c : s) or for (code_t c : s) instead.
2017-03-30 15:51:14 +11:00
Couriersud
3c49610274 More cppcheck fixes. (nw) 2017-03-05 16:19:59 +01:00
couriersud
a82ca2d244 Improve readability. Add more c++11 noexcept and swap semantics.
Also fixed clang-5 warnings. (nw)
2017-02-22 02:04:02 +01:00
couriersud
e02d8cad2b Fixed a number of issues:
- Fixed crashes on terminals without nets (i.e. connected to a rail)
- Reviewed "FIXMEs" and corrected some minor ones.
- Made m_cur_analog protected. 
- Fixed pmf delegates to work with msvc.
- More optimizations to the solver code.
- Started work on a better signal pipeline in nlwav
- Only generate documentation for entities which are documented.
[Couriersud]
2017-01-31 22:37:25 +01:00
couriersud
c713f9ed1d Separate include file usage for netlist.
Device implementations (all cpp files in netlist/devices) now should
only include nl_base.h. 
Netlist implementation sources should only include "net_lib.h". 
Refactored netlist.h and netlist.cpp to avoid namespace congestion in
netlist.h.
Fixed VC2015 build. (nw)
2017-01-29 15:47:12 +01:00
couriersud
bd20222866 Fix bug which caused hazl1500 to crash. (nw) 2017-01-28 03:52:42 +01:00
couriersud
6d2354264a Do not derive other classes from std::vector. More cleanup. (nw) 2017-01-27 15:22:18 +01:00
couriersud
5c88873a87 Cleanup of includes. (nw) 2017-01-27 15:22:17 +01:00
couriersud
ba03118b09 More netlist refactoring:
- Remove virtual from some destructors and make them protected. 
- Various cleanups.
- Small performance improvement. 
- Fixed some inconsistencies. 
- More c++ refactoring. (nw)
2017-01-25 22:17:48 +01:00
couriersud
4d15501a30 Netlist: code refactoring
Make streams provide binary access only. Use putf8_reader and
putf8_writer to actually access streams. Replace some char * parameters
with pstring where appropriate. Minor code refactoring and move
functionality were it belongs. (nw)
2017-01-20 22:29:23 +01:00
couriersud
1ae3e29ea3 Assume string literals are UTF8 in netlist code.
At the same time, any char pointer has to be explicitly converted to
pstring by specifying an encoding. Not yet optimal, but certainly better
than what was there before. 
Removed unneeded methods from pstring. (nw)
2017-01-20 22:20:36 +01:00
couriersud
d0b6742563 Default argument on plib::environment now optional. (nw) 2017-01-20 22:20:35 +01:00
couriersud
167d8405ec Converted warnings and fatal log messages to constants.
Also refactored some code to ease the exercise. (nw)
2017-01-20 22:20:35 +01:00
couriersud
969e6ed6a0 Keep track were registry elements are created. (nw) 2017-01-16 19:49:44 +01:00
couriersud
10a4ab4af1 Preparation work for automatically generated include file for devices.
nltool now is able to create all defines from the factory definitions.
This will reduce the number of places needed to touch when adding
devices and always ensure that the parser and statically compiled
netlist code use the same syntax. This will enable us to delete most
device include files, e.g. nld_74107.h. 

Netlist usage to create this header file:
./nltool -c header > src/lib/netlist/devices/nld_devinc.h

This is not yet used in production. It will be enabled after additional
tests.

[Couriersud]
2017-01-16 19:49:43 +01:00
couriersud
c612391f8e Move analog devices into "netlist::analog" namespace. Added
documentation to opamp model. (nw)
2017-01-15 17:56:47 +01:00
couriersud
bce5c521a2 Add code to remove devices connected only to rail terminals. 2017-01-14 16:35:56 +01:00
couriersud
ef8b7ccb6b Core refactoring
- connect_late ==> connect
- register nets where they are created
2017-01-14 16:35:55 +01:00
couriersud
b1c3586789 Improve readability and remove some trampolines. (nw) 2017-01-12 23:20:23 +01:00
couriersud
5b4026d13f - setup_t is owned by netlist_t. Stop being complicated.
- Remove gnd() method. 
- Further simplification.
- Fix potential reset and initialization issues. (nw)
2017-01-12 23:20:21 +01:00
couriersud
9d3d07b771 Move netlists into macro folder. (nw) 2017-01-09 00:28:31 +01:00
couriersud
2c0b627f13 More cleanups. (nw) 2017-01-06 01:31:33 +01:00
couriersud
02c3f45bff Fix clang "-Wno-weak-vtables" warnings in netlist source. Refactored
code along the way. (nw)
2017-01-05 01:43:31 +01:00
couriersud
424e2d4097 Fix parsing of macro devices. (nw) 2017-01-04 18:01:17 +01:00
couriersud
db7cdcb957 Refactored factory. Use namespace "factory" instead of prefix factory_
all over the place. (nw)
2017-01-02 17:33:21 +01:00
couriersud
9a7b32f29d Simplify code. Introduce consistent approach to loading macro devices.
Changed  nltool "listdevices" command accordingly. Fix some bugs which
surfaced by this exercise. (nw)
2017-01-02 17:33:20 +01:00
couriersud
0eefe5f02d cstr() ==> c_str() (nw) 2016-12-30 23:42:24 +01:00
couriersud
f1a6e2b47e Align noexcept usage. Rename register_con to add_terminal for clearity.
Fix bug introduced with last commit. (nw)
2016-12-30 23:42:23 +01:00
couriersud
b1516cc7a3 Analog to digital proxy rework. (nw)
Properly handle connected inputs when creating a-d proxy. Aligned a-d
proxy to d-a proxy class structure.
2016-12-30 20:31:14 +01:00
couriersud
1983580e26 Some preparation for future changes on proxies and chip families. (nw) 2016-12-28 13:48:49 +01:00
couriersud
63f4e52dae Moved proxy code into separate file. (nw) 2016-12-28 13:48:48 +01:00
couriersud
016535b3d0 Simplify. (nw) 2016-12-27 15:19:18 +01:00
couriersud
54cbd67a42 Fix loading roms in two devices. (nl) 2016-12-27 04:33:18 +01:00
couriersud
f43e45a5cf Netlist: Roms now specify an identifier in the netlist.
The identifier is used to load data from a source_t implementation. This
allos a consistent approach in netlists independent of netlist
implementation. Both sources code and parameter code needed quite some
rewrite to support this. [Couriersud]
2016-12-27 02:44:45 +01:00
MooglyGuy
4f3b59ef31 Well, it sorta looks like Stunt Cycle, at least. (nw) 2016-12-26 20:34:03 +01:00
therealmogminer@gmail.com
66abfa8e6d -netlist: Added shared RAM pointer, for use by netlist RAM devices which need updating by non-netlist driver code. [Ryan Holtz]
-netlist: Added new devices: [Ryan Holtz]
 * Intel 2102A 1Kbit (1024 x 1) Static RAM
 * 74365 Hex Bus Driver with 3-State Outputs
 * Generic 2- and 3-terminal Tristate device
 * Note: Tristate device and 74365 do not actually tristate, they are simply a way of combining multiple outputs + chip enables.
2016-12-21 20:32:49 +01:00
therealmogminer@gmail.com
3fcf6e6a3c -netlist: Add simple ROM hookup capability. [Ryan Holtz] 2016-12-21 20:32:45 +01:00
couriersud
5b1d15383d Use noexcept in netlist code where appropriate.
Use macro NL_NOEXCEPT if debug builds would throw an exception (e.g. by
using nl_assert). This is not entirely safe. Going forward, nl_assert
should call log first and than throw. (nw)
2016-08-07 01:44:55 +02:00
couriersud
20a584b348 Various netlist fixes:
- minor include cleanup
- fix a memory hole (caused by assign operators)
- more C++.
2016-08-06 19:22:28 +02:00
couriersud
1e40d95e8b Netlist updates:
- Removed trampolines (OUTLOGIC, INPLOGIC and friends). 
- Started using doxygen comment and documentation style. Added doxygen
files to documentation folder. 
- Refactored code triggered by doxygen output. 
- Moved internal and support classes into namespace detail. 
- Use an anordered map in parser. 
- -Wconversion fixes - All done now. 
- Fixed -Wold-style-cast warnings in netlist code. 
- Added iterators to pstring. 
- Moved two macros, added more RAII and improved exceptions. Fixed some
bugs in parser code. 
- Fixed a number of bugs in parser code and exception handling. 
[Couriersud]
2016-07-21 11:05:55 +02:00
couriersud
011dbbe713 Moved two macros, added more RAII and improved exceptions. Fixed some
bugs in parser code. (nw)
2016-07-09 00:13:18 +02:00
couriersud
caafc0f782 Netlist improvements:
- nltool now accepts -Ddefine=value to pass on to netlists
- improved option handling and added "dummy" options to add grouping and
  examples in help output.
- improved --cmd=listdevices output
- Fix dynamic timestepping. This will work with breakout using real
  capacitor modelling instead of delay devices. Really slow, but very
  useful to calibrate timings.
- Fix an awful bug in timing for delay devices.
- Switched to clang 3.8 and made code compile with
  -Weverything -Werror -Wno-old-style-cast -Wno-padded -Wno-weak-vtables
  -Wno-missing-variable-declarations -Wno-conversion -Wno-c++98-compat
  -Wno-float-equal -Wno-cast-align -Wno-global-constructors
  -Wno-c++98-compat-pedantic -Wno-exit-time-destructors
  -Wno-format-nonliteral -Wno-weak-template-vtables
  This was a helpful exercise since it brought forward some 
  serious issues with implicit constructors. 
[Couriersud]
2016-07-01 02:09:14 +02:00
couriersud
d1cd307f83 Remove shared_ptr usage and replace with plib:owned_ptr. Clean up nltool
a bit. (nw)
2016-06-24 17:45:17 +02:00
couriersud
c6e6911aed Netlist changes
- Replaced shared_ptr by unique_ptr. 
- Better seperation of setup_t and netlist_t. 
- Fixed bugs in rdtsc code. Refactored timer code. 
- Simplify conditional activation/deactivation. 
- Introduced HINT(device, hint) to clarify that hints are inheritent 
  and not specific to devices. 
- Added improved profiling support to netlist. Statistics output now
  proposes devices for which whole device activation/deactivation be
  disabled. No significant improvement for pong, but breakout
  experiences a 10% improvement. 
- Moved options code from include to cpp file.
- Minor modifications to 7493 and 9316
- Introduced perftime_t and perfcount_t for gathering statistics. These
  templates do not create any code if statistics are not kept.
- Make help2man ./nltool produce usuable output. 
- More truthtable refactoring. Removed half-finished code for internal
  state support. As implemented, this would have had no support for
  timing delays. 
[Couriersud]
2016-06-23 02:04:51 +02:00
couriersud
404e589cff Merge netlist_dev branch, all code_refactoring: (nw)
Object model optimisation. 
    Merge remote-tracking branch 'origin/master' into netlist_dev
    Fix a merge issue. 
    #if ==> #elif. Ouch. 
    Default PHAS_PMF_INTERNAL=0 for 32bit windows mingw. 
    Change UINT8 to uint_[fast|least|8_t. 
    Move state_var so it can be used by base devices as well. 
    Remove last traces of ATTR_ALIGN. 
    Refactored netlist_time into a template.
    Removed implicit double assignment to netlist. Doomed to produce
bugs.
    Instead, use netlist_time::from_double.
    Switch to using proper (i.e. bool type) param_logic_t. 
    Formally differentiate between logic inputs (e.g. switches) and int
    inputs (e.g. resistor ladders or selection switches). 
    Added parameter USE_DEACTIVATE to truthtable devices.
    Added more constexpr to netlist_time.
    Fixed some ifdef code paths.
    - More c++.
    - Simplify main processing loop. As a nice side-effect that squeezed
out some cycles.
    - More cycle squeezing.
    - Removed pvector_t.
    - Use std::sort.
    - Refactored netlist state manager.
    - Introduction of state_var object template to be used on device
state
    members.
    - Changed remaining save occurrences to state_var.
    - Rewrote nltool's listdevices command. This allowed removal of one
    member from devices which served solely for listdevices.
    - Remove hashmap_t. Fix kidniki regression.
2016-06-16 00:01:47 +02:00
couriersud
81880659d2 - More code cleanup.
- Dead code removal and minor refactoring.
- Simplify. Align naming with stl. Fix somed pedantic warnings.
- More STL compatability.
- Remove ATTR_HOT and ATTR_COLD. Refactored netlist_time. 
- Fix long standing workaround which would ignore policy of change-only"
propagation.
- Rewrote for loops to use auto : semantics.
- Truthtable cleanup. (nw)
- Get rid of nl_math. Remove nl_util.h and moved contents to
plib/putil.h.
- Fix standalone build. Refactor ptypes.h. 
[Couriersud]
2016-06-07 21:44:15 +02:00
couriersud
3d3f5761f0 - Added constructors to prepare to move terminal setup into constructor.
- Reworked twoterm setup. Fixed some timebombs along the way.
- Fix r2r dac. Remove dead code.
- analog_outputs now created in constructor.
- moved analog_input creation into constructor. 
- moved logic output creation to constructor.
- moved all logic inputs into constructor.
- Completely removed init_object. Finally. 
[Couriersud]
2016-06-07 21:41:54 +02:00
balr0g
b277908905 - Minor cosmetic refactoring. Added a "uninitialised array" template to
allow in-place creation (for increased locality) of netlist classes.
Main use is in truthtable class.
- Remove PLIB_NAMESPACE macros.
- Remove namespace macros. Use explicit namespace declarations.
- Moved device definitions into cpp files.
- Moved more device definitions into cpp files.
- New prefix "nlid" for include files flags purely internal include
files not to be leaked into userland. 
- Fix factory code.
2016-06-07 21:40:30 +02:00
couriersud
02e3213897 Leading underscore massacre. (nw) 2016-05-27 01:20:09 +02:00
couriersud
fd62273a87 Moved more code into plib namespace. (nw) 2016-05-27 01:19:59 +02:00