mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
netlist: maintenance. (nw)
- Fix automatic header generation - clang lint fixes. - srcclean - remove dead code
This commit is contained in:
parent
82e9ccb3a9
commit
63561e2c2c
@ -273,7 +273,7 @@ namespace analog
|
||||
if (Cox > nlconst::zero() && m_model.m_NSUB > nlconst::zero())
|
||||
m_gamma = plib::sqrt (nlconst::two()
|
||||
* constants::Q_e() * constants::eps_Si() * constants::eps_0()
|
||||
* m_model.m_NSUB * nlconst::magic(1e6)) / Cox;
|
||||
* m_model.m_NSUB * nlconst::magic(1e6)) / Cox;
|
||||
else
|
||||
m_gamma = nlconst::zero();
|
||||
}
|
||||
|
@ -235,10 +235,10 @@ native:
|
||||
$(MAKE) CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra "
|
||||
|
||||
gcc9:
|
||||
$(MAKE) CC=g++-9 LD=g++-9 CEXTRAFLAGS="-march=native -msse4.2 -Wall -Wpedantic -Wsign-compare -Wextra" EXTRALIBS="-lquadmath"
|
||||
$(MAKE) CC=g++-9 LD=g++-9 CEXTRAFLAGS="-march=native -msse4.2 -Wall -pedantic -Wpedantic -Wsign-compare -Wextra" EXTRALIBS="-lquadmath"
|
||||
|
||||
clang:
|
||||
$(MAKE) CC=clang++-10 LD=clang++-10 CEXTRAFLAGS="-march=native -msse4.2 -Weverything -Werror -Wno-padded -Wno-weak-vtables -Wno-unused-template -Wno-missing-variable-declarations -Wno-float-equal -Wconversion -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-exit-time-destructors"
|
||||
$(MAKE) CC=clang++-10 LD=clang++-10 CEXTRAFLAGS="-march=native -msse4.2 -Weverything -Wall -pedantic -Wpedantic -Werror -Wno-padded -Wno-weak-vtables -Wno-unused-template -Wno-missing-variable-declarations -Wno-float-equal -Wconversion -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-exit-time-destructors"
|
||||
|
||||
clang-5:
|
||||
$(MAKE) CC=clang++-5.0 LD=clang++-5.0 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-inconsistent-missing-destructor-override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors"
|
||||
|
@ -34,9 +34,9 @@
|
||||
#endif
|
||||
|
||||
#include "netlist/macro/nlm_cd4xxx.h"
|
||||
#include "netlist/macro/nlm_ttl74xx.h"
|
||||
#include "netlist/macro/nlm_opamp.h"
|
||||
#include "netlist/macro/nlm_other.h"
|
||||
#include "netlist/macro/nlm_ttl74xx.h"
|
||||
|
||||
#include "nld_7448.h"
|
||||
|
||||
|
@ -149,13 +149,6 @@ namespace netlist
|
||||
NETLIB_RESET(7448)
|
||||
{
|
||||
m_state = 0;
|
||||
#if 0
|
||||
m_A.set_state(logic_t::STATE_INP_PASSIVE);
|
||||
m_B.set_state(logic_t::STATE_INP_PASSIVE);
|
||||
m_C.set_state(logic_t::STATE_INP_PASSIVE);
|
||||
m_D.set_state(logic_t::STATE_INP_PASSIVE);
|
||||
m_RBIQ.set_state(logic_t::STATE_INP_PASSIVE);
|
||||
#endif
|
||||
}
|
||||
|
||||
NETLIB_DEVICE_IMPL(7448, "TTL_7448", "+A,+B,+C,+D,+LTQ,+BIQ,+RBIQ,@VCC,@GND")
|
||||
|
@ -14,7 +14,7 @@ namespace netlist
|
||||
namespace devices
|
||||
{
|
||||
|
||||
static constexpr const std::array<netlist_time, 4> delay =
|
||||
static C14CONSTEXPR const std::array<netlist_time, 4> delay =
|
||||
{
|
||||
NLTIME_FROM_NS(18),
|
||||
NLTIME_FROM_NS(36) - NLTIME_FROM_NS(18),
|
||||
|
@ -30,20 +30,10 @@
|
||||
|
||||
#include "netlist/nl_setup.h"
|
||||
|
||||
#if 0
|
||||
#define SN74LS629(name, p_cap) \
|
||||
NET_REGISTER_DEV(SN74LS629, name) \
|
||||
NETDEV_PARAMI(name, CAP, p_cap)
|
||||
|
||||
#define SN74LS629_DIP(name, p_cap1, p_cap2) \
|
||||
NET_REGISTER_DEV(SN74LS629_DIP, name) \
|
||||
NETDEV_PARAMI(name, 1.CAP, p_cap1) \
|
||||
NETDEV_PARAMI(name, 2.CAP, p_cap2)
|
||||
#else
|
||||
#define SN74LS629(name, p_cap) \
|
||||
NET_REGISTER_DEVEXT(SN74LS629, name, p_cap)
|
||||
|
||||
#define SN74LS629_DIP(name, p_cap1, p_cap2) \
|
||||
NET_REGISTER_DEVEXT(SN74LS629_DIP, name, p_cap1, p_cap2)
|
||||
#endif
|
||||
|
||||
#endif /* NLD_74LS629_H_ */
|
||||
|
@ -28,14 +28,8 @@
|
||||
NET_REGISTER_DEV(ANALOG_INPUT, name) \
|
||||
PARAM(name.IN, v)
|
||||
|
||||
#if 0
|
||||
#define MAINCLOCK(name, freq) \
|
||||
NET_REGISTER_DEV(MAINCLOCK, name) \
|
||||
PARAM(name.FREQ, freq)
|
||||
#else
|
||||
#define MAINCLOCK(name, freq) \
|
||||
NET_REGISTER_DEVEXT(MAINCLOCK, name, freq)
|
||||
#endif
|
||||
|
||||
#define CLOCK(name, freq) \
|
||||
NET_REGISTER_DEV(CLOCK, name) \
|
||||
|
@ -85,7 +85,7 @@ namespace netlist
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned d = 0x00;
|
||||
unsigned d = 0x00;
|
||||
for (std::size_t i=0; i<4; i++)
|
||||
{
|
||||
if (m_OE1())
|
||||
|
@ -40,45 +40,6 @@ namespace devices
|
||||
param_num_t<unsigned> m_max_link_loops;
|
||||
};
|
||||
|
||||
#if 0
|
||||
// -----------------------------------------------------------------------------
|
||||
// mainclock
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NETLIB_OBJECT(mainclock)
|
||||
{
|
||||
NETLIB_CONSTRUCTOR(mainclock)
|
||||
, m_Q(*this, "Q")
|
||||
, m_freq(*this, "FREQ", nlconst::magic(7159000.0 * 5))
|
||||
{
|
||||
m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two()));
|
||||
}
|
||||
|
||||
NETLIB_RESETI()
|
||||
{
|
||||
m_Q.net().set_next_scheduled_time(netlist_time::zero());
|
||||
}
|
||||
|
||||
NETLIB_UPDATE_PARAMI()
|
||||
{
|
||||
m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two()));
|
||||
}
|
||||
|
||||
NETLIB_UPDATEI()
|
||||
{
|
||||
logic_net_t &net = m_Q.net();
|
||||
// this is only called during setup ...
|
||||
net.toggle_new_Q();
|
||||
net.set_next_scheduled_time(exec().time() + m_inc);
|
||||
}
|
||||
|
||||
public:
|
||||
logic_output_t m_Q;
|
||||
netlist_time m_inc;
|
||||
private:
|
||||
param_fp_t m_freq;
|
||||
};
|
||||
#endif
|
||||
// -----------------------------------------------------------------------------
|
||||
// clock
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "plib/plists.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
|
@ -17,15 +17,15 @@
|
||||
|
||||
The following example shows a typical connection between several devices:
|
||||
|
||||
+---+ +---+ +---+ +---+ +---+
|
||||
| | | | | | | | | |
|
||||
| D | | D | | D | | D | | D |
|
||||
| | | | | | | | | |
|
||||
+-O-+ +-I-+ +-I-+ +-T-+ +-T-+
|
||||
| | | | |
|
||||
+-+---------+---------+---------+---------+-+
|
||||
| rail net |
|
||||
+-------------------------------------------+
|
||||
+---+ +---+ +---+ +---+ +---+
|
||||
| | | | | | | | | |
|
||||
| D | | D | | D | | D | | D |
|
||||
| | | | | | | | | |
|
||||
+-O-+ +-I-+ +-I-+ +-T-+ +-T-+
|
||||
| | | | |
|
||||
+-+---------+---------+---------+---------+-+
|
||||
| rail net |
|
||||
+-------------------------------------------+
|
||||
|
||||
A rail net is a net which is driven by exactly one output with an
|
||||
(idealized) internal resistance of zero.
|
||||
@ -39,29 +39,29 @@ The system differentiates between analog and logic input and outputs and
|
||||
analog terminals. Analog and logic devices can not be connected to the
|
||||
same net. Instead, proxy devices are inserted automatically:
|
||||
|
||||
+---+ +---+
|
||||
| | | |
|
||||
| D1| | D2|
|
||||
| A | | L |
|
||||
+-O-+ +-I-+
|
||||
| |
|
||||
+-+---------+---+
|
||||
| rail net |
|
||||
+---------------+
|
||||
+---+ +---+
|
||||
| | | |
|
||||
| D1| | D2|
|
||||
| A | | L |
|
||||
+-O-+ +-I-+
|
||||
| |
|
||||
+-+---------+---+
|
||||
| rail net |
|
||||
+---------------+
|
||||
|
||||
is converted into
|
||||
|
||||
+----------+
|
||||
| |
|
||||
+---+ +-+-+ | +---+
|
||||
| | | L | A-L | | |
|
||||
| D1| | D | Proxy | | D2|
|
||||
| A | | A | | | |
|
||||
+-O-+ +-I-+ | +-I-+
|
||||
| | | |
|
||||
+-+---------+--+ +-+-----+-------+
|
||||
| rail net (A) | | rail net (L) |
|
||||
+--------------| +---------------+
|
||||
+----------+
|
||||
| |
|
||||
+---+ +-+-+ | +---+
|
||||
| | | L | A-L | | |
|
||||
| D1| | D | Proxy | | D2|
|
||||
| A | | A | | | |
|
||||
+-O-+ +-I-+ | +-I-+
|
||||
| | | |
|
||||
+-+---------+--+ +-+-----+-------+
|
||||
| rail net (A) | | rail net (L) |
|
||||
+--------------| +---------------+
|
||||
|
||||
This works both analog to logic as well as logic to analog.
|
||||
|
||||
@ -74,61 +74,61 @@ and transistors again.
|
||||
Instead, the following approach in case of a pure terminal/input network
|
||||
is taken:
|
||||
|
||||
+---+ +---+ +---+ +---+ +---+
|
||||
| | | | | | | | | |
|
||||
| D | | D | | D | | D | | D |
|
||||
| | | | | | | | | |
|
||||
+-T-+ +-I-+ +-I-+ +-T-+ +-T-+
|
||||
| | | | |
|
||||
'+' | | '-' '-'
|
||||
+-+---------+---------+---------+---------+-+
|
||||
| Calculated net |
|
||||
+-------------------------------------------+
|
||||
+---+ +---+ +---+ +---+ +---+
|
||||
| | | | | | | | | |
|
||||
| D | | D | | D | | D | | D |
|
||||
| | | | | | | | | |
|
||||
+-T-+ +-I-+ +-I-+ +-T-+ +-T-+
|
||||
| | | | |
|
||||
'+' | | '-' '-'
|
||||
+-+---------+---------+---------+---------+-+
|
||||
| Calculated net |
|
||||
+-------------------------------------------+
|
||||
|
||||
Netlist uses the following basic two terminal device:
|
||||
|
||||
(k)
|
||||
+-----T-----+
|
||||
| | |
|
||||
| +--+--+ |
|
||||
| | | |
|
||||
| R | |
|
||||
| R | |
|
||||
| R I |
|
||||
| | I | Device n
|
||||
| V+ I |
|
||||
| V | |
|
||||
| V- | |
|
||||
| | | |
|
||||
| +--+--+ |
|
||||
| | |
|
||||
+-----T-----+
|
||||
(l)
|
||||
(k)
|
||||
+-----T-----+
|
||||
| | |
|
||||
| +--+--+ |
|
||||
| | | |
|
||||
| R | |
|
||||
| R | |
|
||||
| R I |
|
||||
| | I | Device n
|
||||
| V+ I |
|
||||
| V | |
|
||||
| V- | |
|
||||
| | | |
|
||||
| +--+--+ |
|
||||
| | |
|
||||
+-----T-----+
|
||||
(l)
|
||||
|
||||
This is a resistance in series to a voltage source and paralleled by a
|
||||
current source. This is suitable to model voltage sources, current sources,
|
||||
resistors, capacitors, inductances and diodes.
|
||||
|
||||
\f[
|
||||
I_{n,l} = - I_{n,k} = ( V_k - V^N - V_l ) \frac{1}{R^n} + I^n
|
||||
I_{n,l} = - I_{n,k} = ( V_k - V^N - V_l ) \frac{1}{R^n} + I^n
|
||||
\f]
|
||||
|
||||
Now, the sum of all currents for a given net must be 0:
|
||||
|
||||
\f[
|
||||
\sum_n I_{n,l} = 0 = \sum_{n,k} (V_k - V^n - V_l ) \frac{1}{R^n} + I^n
|
||||
\sum_n I_{n,l} = 0 = \sum_{n,k} (V_k - V^n - V_l ) \frac{1}{R^n} + I^n
|
||||
\f]
|
||||
|
||||
With \f$ G^n = \frac{1}{R^n} \f$ and \f$ \sum_n G^n = G^{tot} \f$ and \f$k=k(n)\f$
|
||||
|
||||
\f[
|
||||
0 = - V_l G^{tot} + \sum_n (V_{k(n)} - V^n) G^n + I^n)
|
||||
0 = - V_l G^{tot} + \sum_n (V_{k(n)} - V^n) G^n + I^n)
|
||||
\f]
|
||||
|
||||
and with \f$ l=l(n)\f$ and fixed \f$ k\f$
|
||||
|
||||
\f[
|
||||
0 = -V_k G^{tot} + sum_n( V_{l(n)} + V^n ) G^n - I^n)
|
||||
0 = -V_k G^{tot} + sum_n( V_{l(n)} + V^n ) G^n - I^n)
|
||||
\f]
|
||||
|
||||
These equations represent a linear Matrix equation (with more math).
|
||||
@ -136,7 +136,7 @@ These equations represent a linear Matrix equation (with more math).
|
||||
In the end the solution of the analog subsystem boils down to
|
||||
|
||||
\f[
|
||||
\mathbf{\it{(G - D) v = i}}
|
||||
\mathbf{\it{(G - D) v = i}}
|
||||
\f]
|
||||
|
||||
with G being the conductance matrix, D a diagonal matrix with the total
|
||||
|
@ -562,17 +562,6 @@ namespace netlist
|
||||
: core_device_t(owner, name)
|
||||
{
|
||||
}
|
||||
#if 0
|
||||
setup_t &device_t::setup() noexcept
|
||||
{
|
||||
return state().setup();
|
||||
}
|
||||
|
||||
const setup_t &device_t::setup() const noexcept
|
||||
{
|
||||
return state().setup();
|
||||
}
|
||||
#endif
|
||||
|
||||
void device_t::register_subalias(const pstring &name, detail::core_terminal_t &term)
|
||||
{
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "plib/palloc.h" // owned_ptr
|
||||
#include "plib/pdynlib.h"
|
||||
#include "plib/pfmtlog.h"
|
||||
#include "plib/pfunction.h"
|
||||
#include "plib/plists.h"
|
||||
#include "plib/pmempool.h"
|
||||
#include "plib/ppmf.h"
|
||||
@ -22,7 +23,6 @@
|
||||
#include "plib/pstonum.h"
|
||||
#include "plib/pstream.h"
|
||||
#include "plib/ptime.h"
|
||||
#include "plib/pfunction.h"
|
||||
|
||||
#include "nl_errstr.h"
|
||||
#include "nltypes.h"
|
||||
@ -144,7 +144,7 @@ class NETLIB_NAME(name) : public device_t
|
||||
///
|
||||
/// \param cname Name of object as given to \ref NETLIB_OBJECT
|
||||
///
|
||||
#define NETLIB_TIMESTEP(cname) \
|
||||
#define NETLIB_TIMESTEP(cname) \
|
||||
void NETLIB_NAME(cname) :: timestep(nl_fptype step) noexcept
|
||||
|
||||
#define NETLIB_FAMILY(family) , m_famsetter(*this, family)
|
||||
@ -587,7 +587,7 @@ namespace netlist
|
||||
/// \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 { return (type() == atype); }
|
||||
bool is_type(const terminal_type atype) const noexcept(false) { return (type() == atype); }
|
||||
|
||||
void set_net(net_t *anet) noexcept { m_net = anet; }
|
||||
void clear_net() noexcept { m_net = nullptr; }
|
||||
@ -1336,7 +1336,7 @@ namespace netlist
|
||||
using base_queue = timed_queue<plib::pqentry_t<net_t *, netlist_time>, false>;
|
||||
using entry_t = plib::pqentry_t<net_t *, netlist_time>;
|
||||
explicit queue_t(netlist_state_t &nl);
|
||||
virtual ~queue_t() noexcept override = default;
|
||||
~queue_t() noexcept override = default;
|
||||
|
||||
queue_t(const queue_t &) = delete;
|
||||
queue_t(queue_t &&) = delete;
|
||||
|
@ -68,8 +68,8 @@ namespace netlist
|
||||
PERRMSGV(MF_DEVICE_ALREADY_EXISTS_1, 1, "Device already exists: {1}")
|
||||
PERRMSGV(MF_ADDING_ALI1_TO_ALIAS_LIST, 1, "Error adding alias {1} to alias list")
|
||||
PERRMSGV(MF_DIP_PINS_MUST_BE_AN_EQUAL_NUMBER_OF_PINS_1, 1,"You must pass an equal number of pins to DIPPINS {1}")
|
||||
PERRMSGV(MF_PARAM_COUNT_MISMATCH_2, 2, "Parameter count mismatch for {1} - only found {2}")
|
||||
PERRMSGV(MF_PARAM_COUNT_EXCEEDED_2, 2, "Parameter count exceed for {1} - found {2}")
|
||||
PERRMSGV(MF_PARAM_COUNT_MISMATCH_2, 2, "Parameter count mismatch for {1} - only found {2}")
|
||||
PERRMSGV(MF_PARAM_COUNT_EXCEEDED_2, 2, "Parameter count exceed for {1} - found {2}")
|
||||
PERRMSGV(MF_UNKNOWN_OBJECT_TYPE_1, 1, "Unknown object type {1}")
|
||||
PERRMSGV(MF_INVALID_NUMBER_CONVERSION_1_2, 2, "Invalid number conversion {1} : {2}")
|
||||
PERRMSGV(MF_INVALID_ENUM_CONVERSION_1_2, 2, "Invalid element found {1} : {2}")
|
||||
|
@ -354,7 +354,6 @@ void parser_t::netdev_hint()
|
||||
|
||||
void parser_t::device(const pstring &dev_type)
|
||||
{
|
||||
#if 1
|
||||
std::vector<pstring> params;
|
||||
|
||||
pstring devname = get_identifier();
|
||||
@ -368,12 +367,8 @@ void parser_t::device(const pstring &dev_type)
|
||||
{
|
||||
tok = get_token();
|
||||
//printf("%d %s\n", tok.type(), tok.str().c_str());
|
||||
if (tok.is_type(IDENTIFIER))
|
||||
if (tok.is_type(IDENTIFIER) || tok.is_type(STRING))
|
||||
params.push_back(tok.str());
|
||||
else if (tok.is_type(STRING))
|
||||
{
|
||||
params.push_back(tok.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Do we really need this?
|
||||
@ -389,92 +384,6 @@ void parser_t::device(const pstring &dev_type)
|
||||
|
||||
require_token(tok, m_tok_param_right);
|
||||
m_setup.register_dev(dev_type, devname, params);
|
||||
|
||||
#else
|
||||
factory::element_t *f = m_setup.factory().factory_by_name(dev_type);
|
||||
auto paramlist = plib::psplit(f->param_desc(), ",");
|
||||
std::vector<pstring> params;
|
||||
|
||||
pstring devname = get_identifier();
|
||||
|
||||
m_setup.register_dev(dev_type, devname);
|
||||
m_setup.log().debug("Parser: IC: {1}\n", devname);
|
||||
|
||||
auto tok(get_token());
|
||||
|
||||
//printf("enter\n");
|
||||
while (tok.is(m_tok_comma))
|
||||
{
|
||||
tok = get_token();
|
||||
//printf("%d %s\n", tok.type(), tok.str().c_str());
|
||||
if (tok.is_type(IDENTIFIER))
|
||||
params.push_back(tok.str());
|
||||
else if (tok.is_type(STRING))
|
||||
{
|
||||
params.push_back(tok.str());
|
||||
}
|
||||
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)));
|
||||
}
|
||||
tok = get_token();
|
||||
}
|
||||
|
||||
require_token(tok, m_tok_param_right);
|
||||
|
||||
if (params.size() > 0)
|
||||
{
|
||||
auto ptok(params.begin());
|
||||
|
||||
for (const pstring &tp : paramlist)
|
||||
{
|
||||
//printf("x %s %s\n", tp.c_str(), ptok->c_str());
|
||||
if (plib::startsWith(tp, "+"))
|
||||
{
|
||||
if (ptok == params.end())
|
||||
{
|
||||
error(plib::pfmt("Input count mismatch for {1} - only found {2}")(devname)(params.size()));
|
||||
break;
|
||||
}
|
||||
pstring output_name = *ptok;
|
||||
m_setup.log().debug("Link: {1} {2}\n", tp, output_name);
|
||||
|
||||
m_setup.register_link(devname + "." + tp.substr(1), output_name);
|
||||
++ptok;
|
||||
}
|
||||
else if (plib::startsWith(tp, "@"))
|
||||
{
|
||||
pstring term = tp.substr(1);
|
||||
m_setup.log().debug("Link: {1} {2}\n", tp, term);
|
||||
|
||||
m_setup.register_link(devname + "." + term, term);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptok == params.end())
|
||||
{
|
||||
error(plib::pfmt("Input count mismatch for {1} - only found {2}")(devname)(params.size()));
|
||||
break;
|
||||
}
|
||||
pstring paramfq = devname + "." + tp;
|
||||
|
||||
m_setup.log().debug("Defparam: {1}\n", paramfq);
|
||||
m_setup.register_param(paramfq, *ptok);
|
||||
++ptok;
|
||||
}
|
||||
}
|
||||
if (ptok != params.end())
|
||||
{
|
||||
error(plib::pfmt("Input count exceed for {1} - found {2}")(devname)(params.size()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -482,7 +391,6 @@ void parser_t::device(const pstring &dev_type)
|
||||
// private
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
nl_fptype parser_t::eval_param(const token_t &tok)
|
||||
{
|
||||
static std::array<pstring, 7> macs = {"", "RES_R", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"};
|
||||
|
@ -58,12 +58,17 @@ namespace netlist
|
||||
register_dev(classname, name, params);
|
||||
}
|
||||
|
||||
void nlparse_t::register_dev(const pstring &classname, const pstring &name,
|
||||
void nlparse_t::register_devx(const pstring &classname,
|
||||
std::initializer_list<const char *> params_and_connections)
|
||||
{
|
||||
std::vector<pstring> params;
|
||||
for (auto &i : params_and_connections)
|
||||
params.push_back(pstring(i));
|
||||
auto i(params_and_connections.begin());
|
||||
pstring name(*i);
|
||||
++i;
|
||||
for (; i != params_and_connections.end(); ++i)
|
||||
{
|
||||
params.emplace_back(*i);
|
||||
}
|
||||
register_dev(classname, name, params);
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
#include "nl_factory.h"
|
||||
#include "nltypes.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <initializer_list>
|
||||
|
||||
//============================================================
|
||||
// MACROS / inline netlist definitions
|
||||
@ -42,8 +42,9 @@
|
||||
#define NET_REGISTER_DEV(type, name) \
|
||||
setup.register_dev(# type, # name);
|
||||
|
||||
#define NET_REGISTER_DEVEXT(type, name, ...) \
|
||||
setup.register_dev(# type, # name, # __VA_ARGS__);
|
||||
// name is first element so that __VA_ARGS__ always has one element
|
||||
#define NET_REGISTER_DEVEXT(type, ...) \
|
||||
setup.register_devx(# type, { PSTRINGIFY_VA(__VA_ARGS__) });
|
||||
|
||||
#define NET_CONNECT(name, input, output) \
|
||||
setup.register_link(# name "." # input, # output);
|
||||
@ -247,8 +248,7 @@ namespace netlist
|
||||
void register_dev(const pstring &classname, const pstring &name,
|
||||
const std::vector<pstring> ¶ms_and_connections);
|
||||
|
||||
void register_dev(const pstring &classname, const pstring &name,
|
||||
std::initializer_list<const char *> params_and_connections);
|
||||
void register_devx(const pstring &classname, std::initializer_list<const char *> params_and_connections);
|
||||
void register_dev(const pstring &classname, const pstring &name,
|
||||
const char *params_and_connections);
|
||||
|
||||
|
@ -505,14 +505,7 @@ namespace plib
|
||||
{
|
||||
auto f = std::min(fill[i][j], 1 + fill[i][k] + fill[k][j]);
|
||||
if (f <= ilup)
|
||||
{
|
||||
#if 0
|
||||
if (f > fill_max)
|
||||
fill_max = f;
|
||||
ops += 2;
|
||||
#endif
|
||||
fill[i][j] = f;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
|
@ -400,15 +400,6 @@ namespace plib {
|
||||
return plib::unique_ptr<T>(pnew<T>(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#if 0
|
||||
template<typename T, typename... Args>
|
||||
static owned_ptr<T> make_owned(Args&&... args)
|
||||
{
|
||||
return owned_ptr<T>(pnew<T>(std::forward<Args>(args)...), true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template <class T, std::size_t ALIGN = alignof(T)>
|
||||
using aligned_allocator = aligned_arena::allocator_type<T, ALIGN>;
|
||||
|
||||
|
@ -90,8 +90,8 @@ pfmt::rtype pfmt::setfmt(std::stringstream &strm, char32_t cfmt_spec)
|
||||
if (r.p != pstring::npos)
|
||||
{
|
||||
// a.b format here ...
|
||||
char32_t pend(0);
|
||||
int width(0);
|
||||
char32_t pend(0);
|
||||
int width(0);
|
||||
if (fmt != "" && pstring("duxofge").find(static_cast<pstring::value_type>(cfmt_spec)) != pstring::npos)
|
||||
{
|
||||
pend = static_cast<char32_t>(fmt.at(fmt.size() - 1));
|
||||
|
@ -227,7 +227,7 @@ namespace plib {
|
||||
}
|
||||
//printf("e : %s\n", expr.c_str());
|
||||
//for (auto &s : postfix)
|
||||
// printf("x : %s\n", s.c_str());
|
||||
// printf("x : %s\n", s.c_str());
|
||||
compile_postfix(inputs, postfix, expr);
|
||||
}
|
||||
|
||||
|
@ -250,19 +250,7 @@ namespace plib {
|
||||
{
|
||||
constexpr pqentry_t() noexcept : m_exec_time(), m_object(nullptr) { }
|
||||
constexpr pqentry_t(const Time t, const Element o) noexcept : m_exec_time(t), m_object(o) { }
|
||||
#if 0
|
||||
~pqentry_t() = default;
|
||||
constexpr pqentry_t(const pqentry_t &e) noexcept = default;
|
||||
constexpr pqentry_t(pqentry_t &&e) noexcept = default;
|
||||
pqentry_t& operator=(pqentry_t && other) noexcept = default;
|
||||
pqentry_t& operator=(const pqentry_t &other) noexcept = default;
|
||||
|
||||
void swap(pqentry_t &other) noexcept
|
||||
{
|
||||
std::swap(m_exec_time, other.m_exec_time);
|
||||
std::swap(m_object, other.m_object);
|
||||
}
|
||||
#endif
|
||||
inline bool operator ==(const pqentry_t &rhs) const noexcept
|
||||
{
|
||||
return m_object == rhs.m_object;
|
||||
|
@ -54,7 +54,7 @@ namespace plib {
|
||||
, m_expr_sep(std::move(s.m_expr_sep))
|
||||
, m_if_flag(s.m_if_flag)
|
||||
, m_if_level(s.m_if_level)
|
||||
, m_stack(std::move(s.m_stack))
|
||||
, m_stack(std::move(s.m_stack))
|
||||
, m_outbuf(std::move(s.m_outbuf))
|
||||
, m_pos(s.m_pos)
|
||||
, m_state(s.m_state)
|
||||
@ -84,7 +84,7 @@ namespace plib {
|
||||
class readbuffer : public std::streambuf
|
||||
{
|
||||
public:
|
||||
explicit readbuffer(ppreprocessor *strm) : m_strm(strm), m_buf()
|
||||
explicit readbuffer(ppreprocessor *strm) : m_strm(strm), m_buf()
|
||||
{ setg(nullptr, nullptr, nullptr); }
|
||||
readbuffer(readbuffer &&rhs) noexcept : m_strm(rhs.m_strm), m_buf() {}
|
||||
COPYASSIGN(readbuffer, delete)
|
||||
|
@ -13,12 +13,37 @@
|
||||
#include "pstring.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <initializer_list>
|
||||
#include <vector>
|
||||
|
||||
#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)
|
||||
|
||||
#define PCONCAT_(a, b) a ## b
|
||||
#define PCONCAT(a, b) PCONCAT_(a, b)
|
||||
|
||||
#define PSTRINGIFY_1(x) #x
|
||||
#define PSTRINGIFY_2(x, x2) #x, #x2
|
||||
#define PSTRINGIFY_3(x, ...) #x, PSTRINGIFY_2(__VA_ARGS__)
|
||||
#define PSTRINGIFY_4(x, ...) #x, PSTRINGIFY_3(__VA_ARGS__)
|
||||
#define PSTRINGIFY_5(x, ...) #x, PSTRINGIFY_4(__VA_ARGS__)
|
||||
#define PSTRINGIFY_6(x, ...) #x, PSTRINGIFY_5(__VA_ARGS__)
|
||||
#define PSTRINGIFY_7(x, ...) #x, PSTRINGIFY_6(__VA_ARGS__)
|
||||
#define PSTRINGIFY_8(x, ...) #x, PSTRINGIFY_7(__VA_ARGS__)
|
||||
#define PSTRINGIFY_9(x, ...) #x, PSTRINGIFY_8(__VA_ARGS__)
|
||||
#define PSTRINGIFY_10(x, ...) #x, PSTRINGIFY_9(__VA_ARGS__)
|
||||
#define PSTRINGIFY_11(x, ...) #x, PSTRINGIFY_10(__VA_ARGS__)
|
||||
#define PSTRINGIFY_12(x, ...) #x, PSTRINGIFY_11(__VA_ARGS__)
|
||||
#define PSTRINGIFY_13(x, ...) #x, PSTRINGIFY_12(__VA_ARGS__)
|
||||
#define PSTRINGIFY_14(x, ...) #x, PSTRINGIFY_13(__VA_ARGS__)
|
||||
#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__)
|
||||
|
||||
// FIXME:: __FUNCTION__ may be not be supported by all compilers.
|
||||
|
||||
#define PSOURCELOC() plib::source_location(__FILE__, __LINE__)
|
||||
@ -43,7 +68,7 @@ namespace plib
|
||||
{ }
|
||||
|
||||
source_location(pstring file, pstring func, unsigned line) noexcept
|
||||
: m_file(std::move(file)), m_func(func), m_line(line), m_col(0)
|
||||
: m_file(std::move(file)), m_func(std::move(func)), m_line(line), m_col(0)
|
||||
{ }
|
||||
|
||||
unsigned line() const noexcept { return m_line; }
|
||||
|
@ -10,11 +10,11 @@
|
||||
// ***************************************************************************
|
||||
|
||||
#include "netlist/plib/pmain.h"
|
||||
#include "netlist/plib/pstrutil.h"
|
||||
#include "netlist/devices/net_lib.h"
|
||||
#include "netlist/nl_errstr.h"
|
||||
#include "netlist/nl_parser.h"
|
||||
#include "netlist/nl_setup.h"
|
||||
#include "netlist/plib/pstrutil.h"
|
||||
#include "netlist/solver/nld_solver.h"
|
||||
#include "netlist/tools/nl_convert.h"
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
pstring usage() override;
|
||||
|
||||
template<typename... ARGS>
|
||||
void poutprefix(pstring prefix, pstring fmt, ARGS&&... args)
|
||||
void poutprefix(const pstring &prefix, const pstring &fmt, ARGS&&... args)
|
||||
{
|
||||
pstring res = plib::pfmt(fmt)(std::forward<ARGS>(args)...);
|
||||
auto lines(plib::psplit(res, "\n", false));
|
||||
|
@ -54,9 +54,9 @@ namespace solver
|
||||
, m_gs_sor(parent, "SOR_FACTOR", nlconst::magic(1.059))
|
||||
, m_method(parent, "METHOD", matrix_type_e::MAT_CR)
|
||||
, m_fp_type(parent, "FPTYPE", matrix_fp_type_e::DOUBLE)
|
||||
, m_reltol(parent, "RELTOL", nlconst::magic(1e-3)) ///< SPICE RELTOL parameter
|
||||
, m_vntol(parent, "VNTOL", nlconst::magic(1e-7)) ///< SPICE VNTOL parameter
|
||||
, m_accuracy(parent, "ACCURACY", nlconst::magic(1e-7)) ///< Iterative solver accuracy
|
||||
, m_reltol(parent, "RELTOL", nlconst::magic(1e-3)) ///< SPICE RELTOL parameter
|
||||
, m_vntol(parent, "VNTOL", nlconst::magic(1e-7)) ///< SPICE VNTOL parameter
|
||||
, m_accuracy(parent, "ACCURACY", nlconst::magic(1e-7)) ///< Iterative solver accuracy
|
||||
, m_nr_loops(parent, "NR_LOOPS", 250) ///< Maximum number of Newton-Raphson loops
|
||||
, m_gs_loops(parent, "GS_LOOPS", 9) ///< Maximum number of Gauss-Seidel loops
|
||||
|
||||
@ -68,7 +68,7 @@ namespace solver
|
||||
, m_parallel(parent, "PARALLEL", 0)
|
||||
|
||||
// automatic time step
|
||||
, m_dynamic_ts(parent, "DYNAMIC_TS", false) ///< Use dynamic time stepping
|
||||
, m_dynamic_ts(parent, "DYNAMIC_TS", false) ///< Use dynamic time stepping
|
||||
, m_dynamic_lte(parent, "DYNAMIC_LTE", nlconst::magic(1e-5)) ///< dynamic time stepping slope
|
||||
, m_dynamic_min_ts(parent, "DYNAMIC_MIN_TIMESTEP", nlconst::magic(1e-6)) ///< smallest time step allowed
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace devices
|
||||
case 2:
|
||||
return plib::make_unique<solver::matrix_solver_direct2_t<FT>>(state(), sname, nets, &m_params);
|
||||
break;
|
||||
#if 0
|
||||
#if 1
|
||||
case 3:
|
||||
return create_solver<FT, 3>(3, sname, nets);
|
||||
break;
|
||||
@ -206,8 +206,6 @@ namespace devices
|
||||
case 49:
|
||||
return create_solver<FT, 49>(49, sname);
|
||||
break;
|
||||
#endif
|
||||
#if 1
|
||||
case 87:
|
||||
return create_solver<FT,86>(86, sname, nets);
|
||||
break;
|
||||
|
@ -8,9 +8,9 @@
|
||||
/// \file nld_solver.h
|
||||
///
|
||||
|
||||
#include "../plib/pstream.h"
|
||||
#include "netlist/nl_base.h"
|
||||
#include "nld_matrix_solver.h"
|
||||
#include "../plib/pstream.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
Loading…
Reference in New Issue
Block a user