mirror of
https://github.com/holub/mame
synced 2025-07-08 19:31:59 +03:00
Moved all files in src/emu/netlist starting with p into plib folder.
This is a first step to ease synchronisation with a stand alone, e.g. outside mame, netlist implementation. More signed/unsigned cleanups and started work on generic truthtable devices. (nw)
This commit is contained in:
parent
e9fe1e74c4
commit
cef370aa13
@ -3,6 +3,60 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "netlist/devices/net_lib.h"
|
||||
|
||||
struct ttd
|
||||
{
|
||||
nl_util::pstring_list a;
|
||||
};
|
||||
|
||||
ttd * nl_register_tt(pstring name, int in, int out);
|
||||
|
||||
|
||||
#define NETLIST_TT(_name, _in, _out) \
|
||||
{ \
|
||||
ttd *a = setup.register_tt(# _name, _in, _out); \
|
||||
|
||||
#define TT_LINE(_x) \
|
||||
a->a.add(_x);
|
||||
|
||||
#define TT_END() }
|
||||
|
||||
NETLIST_START(7400_TTL)
|
||||
NET_REGISTER_DEV(7400, s1)
|
||||
NET_REGISTER_DEV(7400, s2)
|
||||
NET_REGISTER_DEV(7400, s3)
|
||||
NET_REGISTER_DEV(7400, s4)
|
||||
|
||||
ALIAS(1, s1.A);
|
||||
ALIAS(2, s1.B);
|
||||
ALIAS(3, s1.Q);
|
||||
|
||||
ALIAS(4, s2.A);
|
||||
ALIAS(5, s2.B);
|
||||
ALIAS(6, s2.Q);
|
||||
|
||||
ALIAS(9, s3.A);
|
||||
ALIAS(10, s3.B)
|
||||
ALIAS(8, s3.Q);
|
||||
|
||||
ALIAS(12, s4.A);
|
||||
ALIAS(13, s4.B);
|
||||
ALIAS(11, s4.Q);
|
||||
|
||||
NETLIST_END()
|
||||
|
||||
NETLIST_START(lib)
|
||||
NETLIST_TT(7400, 2, 1)
|
||||
TT_LINE("A,B | Q ")
|
||||
TT_LINE("0,X|1|22")
|
||||
TT_LINE("X,0|1|22")
|
||||
TT_LINE("1,1|0|15")
|
||||
TT_END()
|
||||
NETLIST_END()
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
RES(R1, 10)
|
||||
RES(R2, 10)
|
||||
@ -98,4 +152,4 @@
|
||||
LOG(logY, 4V)
|
||||
|
||||
#endif
|
||||
d
|
||||
|
||||
|
@ -15,16 +15,17 @@ files {
|
||||
MAME_DIR .. "src/emu/netlist/nl_setup.h",
|
||||
MAME_DIR .. "src/emu/netlist/nl_factory.c",
|
||||
MAME_DIR .. "src/emu/netlist/nl_factory.h",
|
||||
MAME_DIR .. "src/emu/netlist/pconfig.h",
|
||||
MAME_DIR .. "src/emu/netlist/palloc.c",
|
||||
MAME_DIR .. "src/emu/netlist/palloc.h",
|
||||
MAME_DIR .. "src/emu/netlist/plists.h",
|
||||
MAME_DIR .. "src/emu/netlist/pparser.c",
|
||||
MAME_DIR .. "src/emu/netlist/pparser.h",
|
||||
MAME_DIR .. "src/emu/netlist/pstate.c",
|
||||
MAME_DIR .. "src/emu/netlist/pstate.h",
|
||||
MAME_DIR .. "src/emu/netlist/pstring.c",
|
||||
MAME_DIR .. "src/emu/netlist/pstring.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pconfig.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/palloc.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/palloc.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/plists.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/poptions.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pparser.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pparser.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstate.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstate.h",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstring.c",
|
||||
MAME_DIR .. "src/emu/netlist/plib/pstring.h",
|
||||
MAME_DIR .. "src/emu/netlist/analog/nld_bjt.c",
|
||||
MAME_DIR .. "src/emu/netlist/analog/nld_bjt.h",
|
||||
MAME_DIR .. "src/emu/netlist/analog/nld_fourterm.c",
|
||||
|
@ -448,7 +448,7 @@ links {
|
||||
includedirs {
|
||||
MAME_DIR .. "src/osd",
|
||||
MAME_DIR .. "src/lib/util",
|
||||
MAME_DIR .. "src/emu",
|
||||
MAME_DIR .. "src/emu/netlist",
|
||||
}
|
||||
|
||||
files {
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "nld_solver.h"
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_direct_t: public netlist_matrix_solver_t
|
||||
{
|
||||
public:
|
||||
@ -23,7 +23,7 @@ public:
|
||||
/* ATTR_COLD */ virtual void vsetup(netlist_analog_net_t::list_t &nets);
|
||||
/* ATTR_COLD */ virtual void reset() { netlist_matrix_solver_t::reset(); }
|
||||
|
||||
ATTR_HOT inline int N() const { return (m_N == 0 ? m_dim : m_N); }
|
||||
ATTR_HOT inline unsigned N() const { if (m_N == 0) return m_dim; else return m_N; }
|
||||
|
||||
ATTR_HOT inline int vsolve_non_dynamic(const bool newton_raphson);
|
||||
|
||||
@ -56,7 +56,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
const int m_dim;
|
||||
const unsigned m_dim;
|
||||
nl_double m_lp_fact;
|
||||
};
|
||||
|
||||
@ -64,10 +64,10 @@ private:
|
||||
// netlist_matrix_solver_direct
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t()
|
||||
{
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
pfree(m_terms[k]);
|
||||
}
|
||||
@ -75,7 +75,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t
|
||||
pfree_array(m_rails_temp);
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep()
|
||||
{
|
||||
nl_double new_solver_timestep = m_params.m_max_timestep;
|
||||
@ -86,7 +86,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next
|
||||
* FIXME: We should extend the logic to use either all nets or
|
||||
* only output nets.
|
||||
*/
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
netlist_analog_net_t *n = m_nets[k];
|
||||
|
||||
@ -114,7 +114,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next
|
||||
return new_solver_timestep;
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, netlist_terminal_t *term)
|
||||
{
|
||||
if (term->m_otherterm->net().isRailNet())
|
||||
@ -139,13 +139,13 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k,
|
||||
}
|
||||
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_analog_net_t::list_t &nets)
|
||||
{
|
||||
if (m_dim < nets.size())
|
||||
netlist().error("Dimension %d less than %" SIZETFMT, m_dim, nets.size());
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k]->clear();
|
||||
m_rails_temp[k].clear();
|
||||
@ -153,10 +153,10 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
|
||||
netlist_matrix_solver_t::setup(nets);
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k]->m_railstart = m_terms[k]->count();
|
||||
for (int i = 0; i < m_rails_temp[k].count(); i++)
|
||||
for (unsigned i = 0; i < m_rails_temp[k].count(); i++)
|
||||
this->m_terms[k]->add(m_rails_temp[k].terms()[i], m_rails_temp[k].net_other()[i]);
|
||||
|
||||
m_rails_temp[k].clear(); // no longer needed
|
||||
@ -187,8 +187,8 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
|
||||
int sort_order = (type() == GAUSS_SEIDEL ? 1 : -1);
|
||||
|
||||
for (int k = 0; k < N() / 2; k++)
|
||||
for (int i = 0; i < N() - 1; i++)
|
||||
for (unsigned k = 0; k < N() / 2; k++)
|
||||
for (unsigned i = 0; i < N() - 1; i++)
|
||||
{
|
||||
if ((m_terms[i]->m_railstart - m_terms[i+1]->m_railstart) * sort_order < 0)
|
||||
{
|
||||
@ -197,10 +197,10 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
}
|
||||
}
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
int *other = m_terms[k]->net_other();
|
||||
for (int i = 0; i < m_terms[k]->count(); i++)
|
||||
for (unsigned i = 0; i < m_terms[k]->count(); i++)
|
||||
if (other[i] != -1)
|
||||
other[i] = get_net_idx(&m_terms[k]->terms()[i]->m_otherterm->net());
|
||||
}
|
||||
@ -209,35 +209,35 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(netlist_a
|
||||
}
|
||||
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_A()
|
||||
{
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
for (int i=0; i < N(); i++)
|
||||
for (unsigned i=0; i < N(); i++)
|
||||
m_A[k][i] = 0.0;
|
||||
|
||||
nl_double akk = 0.0;
|
||||
const int terms_count = m_terms[k]->count();
|
||||
const int railstart = m_terms[k]->m_railstart;
|
||||
const unsigned terms_count = m_terms[k]->count();
|
||||
const unsigned railstart = m_terms[k]->m_railstart;
|
||||
const nl_double * RESTRICT gt = m_terms[k]->gt();
|
||||
const nl_double * RESTRICT go = m_terms[k]->go();
|
||||
const int * RESTRICT net_other = m_terms[k]->net_other();
|
||||
|
||||
for (int i = 0; i < terms_count; i++)
|
||||
for (unsigned i = 0; i < terms_count; i++)
|
||||
akk = akk + gt[i];
|
||||
|
||||
m_A[k][k] += akk;
|
||||
|
||||
for (int i = 0; i < railstart; i++)
|
||||
for (unsigned i = 0; i < railstart; i++)
|
||||
m_A[k][net_other[i]] += -go[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS()
|
||||
{
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
nl_double rhsk_a = 0.0;
|
||||
nl_double rhsk_b = 0.0;
|
||||
@ -258,7 +258,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
{
|
||||
#if 0
|
||||
@ -271,15 +271,15 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
const int kN = N();
|
||||
const unsigned kN = N();
|
||||
|
||||
for (int i = 0; i < kN; i++) {
|
||||
for (unsigned i = 0; i < kN; i++) {
|
||||
// FIXME: use a parameter to enable pivoting?
|
||||
if (USE_PIVOT_SEARCH)
|
||||
{
|
||||
/* Find the row with the largest first value */
|
||||
int maxrow = i;
|
||||
for (int j = i + 1; j < kN; j++)
|
||||
unsigned maxrow = i;
|
||||
for (unsigned j = i + 1; j < kN; j++)
|
||||
{
|
||||
if (nl_math::abs(m_A[j][i]) > nl_math::abs(m_A[maxrow][i]))
|
||||
maxrow = j;
|
||||
@ -288,7 +288,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
if (maxrow != i)
|
||||
{
|
||||
/* Swap the maxrow and ith row */
|
||||
for (int k = i; k < kN; k++) {
|
||||
for (unsigned k = i; k < kN; k++) {
|
||||
std::swap(m_A[i][k], m_A[maxrow][k]);
|
||||
}
|
||||
std::swap(m_RHS[i], m_RHS[maxrow]);
|
||||
@ -300,12 +300,12 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
|
||||
/* Eliminate column i from row j */
|
||||
|
||||
for (int j = i + 1; j < kN; j++)
|
||||
for (unsigned j = i + 1; j < kN; j++)
|
||||
{
|
||||
const nl_double f1 = - m_A[j][i] * f;
|
||||
if (f1 != NL_FCONST(0.0))
|
||||
{
|
||||
for (int k = i + 1; k < kN; k++)
|
||||
for (unsigned k = i + 1; k < kN; k++)
|
||||
m_A[j][k] += m_A[i][k] * f1;
|
||||
m_RHS[j] += m_RHS[i] * f1;
|
||||
}
|
||||
@ -313,18 +313,18 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
nl_double * RESTRICT x)
|
||||
{
|
||||
const int kN = N();
|
||||
const unsigned kN = N();
|
||||
|
||||
/* back substitution */
|
||||
for (int j = kN - 1; j >= 0; j--)
|
||||
{
|
||||
nl_double tmp = 0;
|
||||
|
||||
for (int k = j + 1; k < kN; k++)
|
||||
for (unsigned k = j + 1; k < kN; k++)
|
||||
tmp += m_A[j][k] * x[k];
|
||||
|
||||
x[j] = (m_RHS[j] - tmp) / m_A[j][j];
|
||||
@ -342,13 +342,13 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
const nl_double * RESTRICT V)
|
||||
{
|
||||
nl_double cerr = 0;
|
||||
nl_double cerr2 = 0;
|
||||
for (int i = 0; i < this->N(); i++)
|
||||
for (unsigned i = 0; i < this->N(); i++)
|
||||
{
|
||||
const nl_double e = nl_math::abs(V[i] - this->m_nets[i]->m_cur_Analog);
|
||||
const nl_double e2 = nl_math::abs(m_RHS[i] - this->m_last_RHS[i]);
|
||||
@ -359,24 +359,24 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
return cerr + cerr2*NL_FCONST(100000.0);
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store(
|
||||
const nl_double * RESTRICT V, const bool store_RHS)
|
||||
{
|
||||
for (int i = 0; i < this->N(); i++)
|
||||
for (unsigned i = 0; i < this->N(); i++)
|
||||
{
|
||||
this->m_nets[i]->m_cur_Analog = V[i];
|
||||
}
|
||||
if (store_RHS)
|
||||
{
|
||||
for (int i = 0; i < this->N(); i++)
|
||||
for (unsigned i = 0; i < this->N(); i++)
|
||||
{
|
||||
this->m_last_RHS[i] = m_RHS[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
solve_base<netlist_matrix_solver_direct_t>(this);
|
||||
@ -384,7 +384,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
}
|
||||
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
|
||||
{
|
||||
nl_double new_v[_storage_N]; // = { 0.0 };
|
||||
@ -406,7 +406,7 @@ ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
this->build_LE_A();
|
||||
@ -416,7 +416,7 @@ ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_
|
||||
return this->solve_non_dynamic(newton_raphson);
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(const netlist_solver_parameters_t ¶ms, const int size)
|
||||
: netlist_matrix_solver_t(GAUSSIAN_ELIMINATION, params)
|
||||
, m_dim(size)
|
||||
@ -425,7 +425,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
m_terms = palloc_array(terms_t *, N());
|
||||
m_rails_temp = palloc_array(terms_t, N());
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k] = palloc(terms_t);
|
||||
m_last_RHS[k] = 0.0;
|
||||
@ -433,7 +433,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(const eSolverType type, const netlist_solver_parameters_t ¶ms, const int size)
|
||||
: netlist_matrix_solver_t(type, params)
|
||||
, m_dim(size)
|
||||
@ -442,7 +442,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
m_terms = palloc_array(terms_t *, N());
|
||||
m_rails_temp = palloc_array(terms_t, N());
|
||||
|
||||
for (int k = 0; k < N(); k++)
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k] = palloc(terms_t);
|
||||
m_last_RHS[k] = 0.0;
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "nld_solver.h"
|
||||
#include "nld_ms_direct.h"
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_SOR_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
@ -46,7 +46,7 @@ private:
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && this->m_params.m_log_stats)
|
||||
@ -66,14 +66,14 @@ void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
this->solve_base(this);
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
const int iN = this->N();
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "nld_solver.h"
|
||||
#include "nld_ms_direct.h"
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_SOR_mat_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
@ -57,7 +57,7 @@ private:
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && m_log_stats)
|
||||
@ -77,7 +77,7 @@ void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
/*
|
||||
@ -85,13 +85,13 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
*/
|
||||
|
||||
if (USE_LINEAR_PREDICTION)
|
||||
for (int k = 0; k < this->N(); k++)
|
||||
for (unsigned k = 0; k < this->N(); 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 (int k = 0; k < this->N(); k++)
|
||||
for (unsigned k = 0; k < this->N(); k++)
|
||||
{
|
||||
this->m_last_V[k] = this->m_nets[k]->m_cur_Analog;
|
||||
}
|
||||
@ -103,7 +103,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
nl_double sq = 0;
|
||||
nl_double sqo = 0;
|
||||
const nl_double rez_cts = 1.0 / this->current_timestep();
|
||||
for (int k = 0; k < this->N(); k++)
|
||||
for (unsigned k = 0; k < this->N(); k++)
|
||||
{
|
||||
const netlist_analog_net_t *n = this->m_nets[k];
|
||||
const nl_double nv = (n->m_cur_Analog - this->m_last_V[k]) * rez_cts ;
|
||||
@ -123,7 +123,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
/* The matrix based code looks a lot nicer but actually is 30% slower than
|
||||
|
@ -51,7 +51,7 @@ ATTR_COLD void terms_t::add(netlist_terminal_t *term, int net_other)
|
||||
|
||||
ATTR_COLD void terms_t::set_pointers()
|
||||
{
|
||||
for (int i = 0; i < count(); i++)
|
||||
for (unsigned i = 0; i < count(); i++)
|
||||
{
|
||||
m_term[i]->m_gt1 = &m_gt[i];
|
||||
m_term[i]->m_go1 = &m_go[i];
|
||||
|
@ -65,7 +65,7 @@ class terms_t
|
||||
|
||||
ATTR_COLD void add(netlist_terminal_t *term, int net_other);
|
||||
|
||||
ATTR_HOT inline int count() { return m_term.size(); }
|
||||
ATTR_HOT inline unsigned count() { return m_term.size(); }
|
||||
|
||||
ATTR_HOT inline netlist_terminal_t **terms() { return m_term.data(); }
|
||||
ATTR_HOT inline int *net_other() { return m_net_other.data(); }
|
||||
@ -76,7 +76,7 @@ class terms_t
|
||||
|
||||
ATTR_COLD void set_pointers();
|
||||
|
||||
int m_railstart;
|
||||
unsigned m_railstart;
|
||||
|
||||
private:
|
||||
plist_t<netlist_terminal_t *> m_term;
|
||||
|
@ -76,7 +76,7 @@ NETLIB_START(extclock)
|
||||
connect(m_feedback, m_Q);
|
||||
{
|
||||
netlist_time base = netlist_time::from_hz(m_freq.Value()*2);
|
||||
nl_util::pstring_list pat = nl_util::split(m_pattern.Value(),",");
|
||||
pstring_list_t pat(m_pattern.Value(),",");
|
||||
m_off = netlist_time::from_double(m_offset.Value());
|
||||
|
||||
int pati[256];
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "nld_truthtable.h"
|
||||
#include "../plists.h"
|
||||
#include "../plib/plists.h"
|
||||
|
||||
unsigned truthtable_desc_t::count_bits(UINT32 v)
|
||||
{
|
||||
@ -97,7 +97,7 @@ UINT32 truthtable_desc_t::get_ignored_extended(UINT32 i)
|
||||
// desc
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD void truthtable_desc_t::help(unsigned cur, nl_util::pstring_list list,
|
||||
ATTR_COLD void truthtable_desc_t::help(unsigned cur, pstring_list_t list,
|
||||
UINT64 state,UINT16 val, UINT8 *timing_index)
|
||||
{
|
||||
pstring elem = list[cur].trim();
|
||||
@ -142,15 +142,17 @@ ATTR_COLD void truthtable_desc_t::help(unsigned cur, nl_util::pstring_list list,
|
||||
}
|
||||
}
|
||||
|
||||
ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled_ignore)
|
||||
ATTR_COLD void truthtable_desc_t::setup(const pstring_list_t &truthtable, UINT32 disabled_ignore)
|
||||
{
|
||||
unsigned line = 0;
|
||||
|
||||
if (*m_initialized)
|
||||
return;
|
||||
|
||||
pstring ttline = pstring(truthtable[0]);
|
||||
truthtable++;
|
||||
ttline = pstring(truthtable[0]);
|
||||
truthtable++;
|
||||
pstring ttline = truthtable[line];
|
||||
line++;
|
||||
ttline = truthtable[line];
|
||||
line++;
|
||||
|
||||
for (unsigned j=0; j < m_size; j++)
|
||||
m_outs[j] = ~0L;
|
||||
@ -160,14 +162,14 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled
|
||||
|
||||
while (!ttline.equals(""))
|
||||
{
|
||||
nl_util::pstring_list io = nl_util::split(ttline,"|");
|
||||
pstring_list_t io(ttline,"|");
|
||||
// checks
|
||||
nl_assert_always(io.size() == 3, "io.count mismatch");
|
||||
nl_util::pstring_list inout = nl_util::split(io[0], ",");
|
||||
pstring_list_t inout(io[0], ",");
|
||||
nl_assert_always(inout.size() == m_num_bits, "number of bits not matching");
|
||||
nl_util::pstring_list out = nl_util::split(io[1], ",");
|
||||
pstring_list_t out(io[1], ",");
|
||||
nl_assert_always(out.size() == m_NO, "output count not matching");
|
||||
nl_util::pstring_list times = nl_util::split(io[2], ",");
|
||||
pstring_list_t times(io[2], ",");
|
||||
nl_assert_always(times.size() == m_NO, "timing count not matching");
|
||||
|
||||
UINT16 val = 0;
|
||||
@ -189,8 +191,8 @@ ATTR_COLD void truthtable_desc_t::setup(const char **truthtable, UINT32 disabled
|
||||
}
|
||||
|
||||
help(0, inout, 0 , val, tindex.data());
|
||||
ttline = pstring(truthtable[0]);
|
||||
truthtable++;
|
||||
ttline = truthtable[line];
|
||||
line++;
|
||||
}
|
||||
|
||||
// determine ignore
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define NLD_TRUTHTABLE_H_
|
||||
|
||||
#include "../nl_base.h"
|
||||
#include "../nl_factory.h"
|
||||
|
||||
#define NETLIB_TRUTHTABLE(_name, _nIN, _nOUT, _state) \
|
||||
class NETLIB_NAME(_name) : public nld_truthtable_t<_nIN, _nOUT, _state> \
|
||||
@ -44,10 +45,10 @@ struct truthtable_desc_t
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD void setup(const char **truthtable, UINT32 disabled_ignore);
|
||||
ATTR_COLD void setup(const pstring_list_t &desc, UINT32 disabled_ignore);
|
||||
|
||||
private:
|
||||
ATTR_COLD void help(unsigned cur, nl_util::pstring_list list,
|
||||
ATTR_COLD void help(unsigned cur, pstring_list_t list,
|
||||
UINT64 state,UINT16 val, UINT8 *timing_index);
|
||||
static unsigned count_bits(UINT32 v);
|
||||
static UINT32 set_bits(UINT32 v, UINT32 b);
|
||||
@ -89,28 +90,40 @@ public:
|
||||
};
|
||||
|
||||
nld_truthtable_t(truthtable_t *ttbl, const char *desc[])
|
||||
: netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl), m_desc(desc)
|
||||
: netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl)
|
||||
{
|
||||
while (*desc != NULL && **desc != 0 )
|
||||
{
|
||||
m_desc.add(*desc);
|
||||
desc++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nld_truthtable_t(truthtable_t *ttbl, const pstring_list_t &desc)
|
||||
: netlist_device_t(), m_last_state(0), m_ign(0), m_active(1), m_ttp(ttbl)
|
||||
{
|
||||
m_desc = desc;
|
||||
}
|
||||
|
||||
/* ATTR_COLD */ virtual void start()
|
||||
{
|
||||
pstring ttline = pstring(m_desc[0]);
|
||||
pstring header = m_desc[0];
|
||||
|
||||
nl_util::pstring_list io = nl_util::split(ttline,"|");
|
||||
pstring_list_t io(header,"|");
|
||||
// checks
|
||||
nl_assert_always(io.size() == 2, "too many '|'");
|
||||
nl_util::pstring_list inout = nl_util::split(io[0], ",");
|
||||
pstring_list_t inout(io[0], ",");
|
||||
nl_assert_always(inout.size() == m_num_bits, "bitcount wrong");
|
||||
nl_util::pstring_list out = nl_util::split(io[1], ",");
|
||||
pstring_list_t out(io[1], ",");
|
||||
nl_assert_always(out.size() == m_NO, "output count wrong");
|
||||
|
||||
for (int i=0; i < m_NI; i++)
|
||||
for (unsigned i=0; i < m_NI; i++)
|
||||
{
|
||||
inout[i] = inout[i].trim();
|
||||
register_input(inout[i], m_i[i]);
|
||||
}
|
||||
for (int i=0; i < m_NO; i++)
|
||||
for (unsigned i=0; i < m_NO; i++)
|
||||
{
|
||||
out[i] = out[i].trim();
|
||||
register_output(out[i], m_Q[i]);
|
||||
@ -118,7 +131,7 @@ public:
|
||||
// Connect output "Q" to input "_Q" if this exists
|
||||
// This enables timed state without having explicit state ....
|
||||
UINT32 disabled_ignore = 0;
|
||||
for (int i=0; i < m_NO; i++)
|
||||
for (unsigned i=0; i < m_NO; i++)
|
||||
{
|
||||
pstring tmp = "_" + out[i];
|
||||
const int idx = inout.indexof(tmp);
|
||||
@ -154,7 +167,7 @@ public:
|
||||
ATTR_COLD void reset()
|
||||
{
|
||||
m_active = 0;
|
||||
for (int i=0; i<m_NO;i++)
|
||||
for (unsigned i=0; i<m_NO;i++)
|
||||
if (this->m_Q[i].net().num_cons()>0)
|
||||
m_active++;
|
||||
m_last_state = 0;
|
||||
@ -193,14 +206,14 @@ public:
|
||||
const UINT32 timebase = nstate * m_NO;
|
||||
if (doOUT)
|
||||
{
|
||||
for (int i = 0; i < m_NO; i++)
|
||||
for (unsigned i = 0; i < m_NO; i++)
|
||||
OUTLOGIC(m_Q[i], (out >> i) & 1, m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]);
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < m_NO; i++)
|
||||
for (unsigned i = 0; i < m_NO; i++)
|
||||
m_Q[i].net().set_Q_time((out >> i) & 1, mt + m_ttp->m_timing_nt[m_ttp->m_timing[timebase + i]]);
|
||||
|
||||
for (int i = 0; i < m_NI; i++)
|
||||
for (unsigned i = 0; i < m_NI; i++)
|
||||
if (m_ign & (1 << i))
|
||||
m_i[i].inactivate();
|
||||
|
||||
@ -227,7 +240,7 @@ public:
|
||||
if (has_state == 0)
|
||||
if (--m_active == 0)
|
||||
{
|
||||
for (int i = 0; i< m_NI; i++)
|
||||
for (unsigned i = 0; i< m_NI; i++)
|
||||
m_i[i].inactivate();
|
||||
}
|
||||
}
|
||||
@ -242,10 +255,41 @@ private:
|
||||
INT32 m_active;
|
||||
|
||||
truthtable_t *m_ttp;
|
||||
const char **m_desc;
|
||||
pstring_list_t m_desc;
|
||||
};
|
||||
|
||||
class net_device_t_base_factory_tt : public net_device_t_base_factory
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(net_device_t_base_factory_tt)
|
||||
public:
|
||||
ATTR_COLD net_device_t_base_factory_tt(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: net_device_t_base_factory(name, classname, def_param)
|
||||
{}
|
||||
pstring_list_t m_desc;
|
||||
};
|
||||
|
||||
|
||||
template<unsigned m_NI, unsigned m_NO, int has_state>
|
||||
class net_device_t_factory_tt : public net_device_t_base_factory_tt
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(net_device_t_factory_tt)
|
||||
public:
|
||||
ATTR_COLD net_device_t_factory_tt(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: net_device_t_base_factory(name, classname, def_param) { }
|
||||
|
||||
ATTR_COLD netlist_device_t *Create() const
|
||||
{
|
||||
typedef nld_truthtable_t<m_NI, m_NO, has_state> tt_type;
|
||||
netlist_device_t *r = palloc(tt_type, &m_ttbl, m_desc);
|
||||
//r->init(setup, name);
|
||||
return r;
|
||||
}
|
||||
private:
|
||||
typename nld_truthtable_t<m_NI, m_NO, has_state>::truthtable_t m_ttbl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* NLD_TRUTHTABLE_H_ */
|
||||
|
@ -7,12 +7,11 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "palloc.h"
|
||||
#include "plib/palloc.h"
|
||||
|
||||
#include "nl_base.h"
|
||||
#include "devices/nld_system.h"
|
||||
#include "analog/nld_solver.h"
|
||||
#include "pstring.h"
|
||||
#include "nl_util.h"
|
||||
|
||||
const netlist_time netlist_time::zero = netlist_time::from_raw(0);
|
||||
|
@ -158,8 +158,7 @@
|
||||
#include "nl_lists.h"
|
||||
#include "nl_time.h"
|
||||
#include "nl_util.h"
|
||||
#include "pstring.h"
|
||||
#include "pstate.h"
|
||||
#include "plib/pstate.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
@ -1197,7 +1196,7 @@ public:
|
||||
plist_t<_C *> get_device_list()
|
||||
{
|
||||
plist_t<_C *> tmp;
|
||||
for (int i = 0; i < m_devices.size(); i++)
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
{
|
||||
_C *dev = dynamic_cast<_C *>(m_devices[i]);
|
||||
if (dev != NULL)
|
||||
@ -1209,7 +1208,7 @@ public:
|
||||
template<class _C>
|
||||
_C *get_first_device()
|
||||
{
|
||||
for (int i = 0; i < m_devices.size(); i++)
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
{
|
||||
_C *dev = dynamic_cast<_C *>(m_devices[i]);
|
||||
if (dev != NULL)
|
||||
@ -1222,7 +1221,7 @@ public:
|
||||
_C *get_single_device(const char *classname)
|
||||
{
|
||||
_C *ret = NULL;
|
||||
for (int i = 0; i < m_devices.size(); i++)
|
||||
for (std::size_t i = 0; i < m_devices.size(); i++)
|
||||
{
|
||||
_C *dev = dynamic_cast<_C *>(m_devices[i]);
|
||||
if (dev != NULL)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef NLCONFIG_H_
|
||||
#define NLCONFIG_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "plib/pconfig.h"
|
||||
|
||||
//============================================================
|
||||
// SETUP
|
||||
|
@ -15,20 +15,20 @@
|
||||
// net_device_t_base_factory
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::term_param_list()
|
||||
ATTR_COLD const pstring_list_t net_device_t_base_factory::term_param_list()
|
||||
{
|
||||
if (m_def_param.startsWith("+"))
|
||||
return nl_util::split(m_def_param.substr(1), ",");
|
||||
return pstring_list_t(m_def_param.substr(1), ",");
|
||||
else
|
||||
return nl_util::pstring_list();
|
||||
return pstring_list_t();
|
||||
}
|
||||
|
||||
ATTR_COLD const nl_util::pstring_list net_device_t_base_factory::def_params()
|
||||
ATTR_COLD const pstring_list_t net_device_t_base_factory::def_params()
|
||||
{
|
||||
if (m_def_param.startsWith("+") || m_def_param.equals("-"))
|
||||
return nl_util::pstring_list();
|
||||
return pstring_list_t();
|
||||
else
|
||||
return nl_util::split(m_def_param, ",");
|
||||
return pstring_list_t(m_def_param, ",");
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,10 +10,9 @@
|
||||
#define NLFACTORY_H_
|
||||
|
||||
#include "nl_config.h"
|
||||
#include "palloc.h"
|
||||
#include "plists.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "plib/plists.h"
|
||||
#include "nl_base.h"
|
||||
#include "pstring.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// net_dev class factory
|
||||
@ -35,8 +34,8 @@ public:
|
||||
ATTR_COLD const pstring &name() const { return m_name; }
|
||||
ATTR_COLD const pstring &classname() const { return m_classname; }
|
||||
ATTR_COLD const pstring ¶m_desc() const { return m_def_param; }
|
||||
ATTR_COLD const nl_util::pstring_list term_param_list();
|
||||
ATTR_COLD const nl_util::pstring_list def_params();
|
||||
ATTR_COLD const pstring_list_t term_param_list();
|
||||
ATTR_COLD const pstring_list_t def_params();
|
||||
|
||||
protected:
|
||||
pstring m_name; /* device name */
|
||||
@ -76,6 +75,11 @@ public:
|
||||
m_list.add(palloc(net_device_t_factory< _C >, name, classname, def_param));
|
||||
}
|
||||
|
||||
ATTR_COLD void register_device(net_device_t_base_factory *factory)
|
||||
{
|
||||
m_list.add(factory);
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname) const;
|
||||
ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
ATTR_COLD net_device_t_base_factory * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
|
@ -225,8 +225,8 @@ void netlist_parser::device(const pstring &dev_type)
|
||||
pstring devname;
|
||||
net_device_t_base_factory *f = m_setup.factory().factory_by_name(dev_type, m_setup);
|
||||
netlist_device_t *dev;
|
||||
nl_util::pstring_list termlist = f->term_param_list();
|
||||
nl_util::pstring_list def_params = f->def_params();
|
||||
pstring_list_t termlist = f->term_param_list();
|
||||
pstring_list_t def_params = f->def_params();
|
||||
|
||||
std::size_t cnt;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "nl_setup.h"
|
||||
#include "nl_util.h"
|
||||
#include "pparser.h"
|
||||
#include "plib/pparser.h"
|
||||
|
||||
class netlist_parser : public ptokenizer
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "palloc.h"
|
||||
#include "plib/palloc.h"
|
||||
#include "nl_base.h"
|
||||
#include "nl_setup.h"
|
||||
#include "nl_parser.h"
|
||||
@ -286,7 +286,7 @@ void netlist_setup_t::register_object(netlist_device_t &dev, const pstring &name
|
||||
|
||||
void netlist_setup_t::register_link_arr(const pstring &terms)
|
||||
{
|
||||
nl_util::pstring_list list = nl_util::split(terms,", ");
|
||||
pstring_list_t list(terms,", ");
|
||||
if (list.size() < 2)
|
||||
netlist().error("You must pass at least 2 terminals to NET_C");
|
||||
for (std::size_t i = 1; i < list.size(); i++)
|
||||
@ -776,7 +776,7 @@ void netlist_setup_t::start_devices()
|
||||
if (env != "")
|
||||
{
|
||||
NL_VERBOSE_OUT(("Creating dynamic logs ...\n"));
|
||||
nl_util::pstring_list ll = nl_util::split(env, ":");
|
||||
pstring_list_t ll(env, ":");
|
||||
for (std::size_t i=0; i < ll.size(); i++)
|
||||
{
|
||||
NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr()));
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define NLTIME_H_
|
||||
|
||||
#include "nl_config.h"
|
||||
#include "pstate.h"
|
||||
#include "plib/pstate.h"
|
||||
|
||||
//============================================================
|
||||
// MACROS
|
||||
|
@ -8,11 +8,12 @@
|
||||
#ifndef NL_UTIL_H_
|
||||
#define NL_UTIL_H_
|
||||
|
||||
#include "pstring.h"
|
||||
#include "plists.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/plists.h"
|
||||
|
||||
class nl_util
|
||||
{
|
||||
// this is purely static
|
||||
@ -20,68 +21,7 @@ private:
|
||||
nl_util() {};
|
||||
|
||||
public:
|
||||
typedef plist_t<pstring> pstring_list;
|
||||
|
||||
static pstring_list split(const pstring &str, const pstring &onstr, bool ignore_empty = false)
|
||||
{
|
||||
pstring_list temp;
|
||||
|
||||
int p = 0;
|
||||
int pn;
|
||||
|
||||
pn = str.find(onstr, p);
|
||||
while (pn>=0)
|
||||
{
|
||||
pstring t = str.substr(p, pn - p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
temp.add(t);
|
||||
p = pn + onstr.len();
|
||||
pn = str.find(onstr, p);
|
||||
}
|
||||
if (p<str.len())
|
||||
{
|
||||
pstring t = str.substr(p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
temp.add(t);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
static pstring_list splitexpr(const pstring &str, const pstring_list &onstrl)
|
||||
{
|
||||
pstring_list temp;
|
||||
pstring col = "";
|
||||
|
||||
int i = 0;
|
||||
while (i<str.len())
|
||||
{
|
||||
int p = -1;
|
||||
for (std::size_t j=0; j < onstrl.size(); j++)
|
||||
{
|
||||
if (std::strncmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].len())==0)
|
||||
{
|
||||
p = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p>=0)
|
||||
{
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
col = "";
|
||||
temp.add(onstrl[p]);
|
||||
i += onstrl[p].len();
|
||||
}
|
||||
else
|
||||
{
|
||||
col += str.cstr()[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
return temp;
|
||||
}
|
||||
|
||||
static const pstring environment(const pstring &var, const pstring &default_val = "")
|
||||
{
|
||||
|
@ -77,6 +77,23 @@ typedef int64_t INT64;
|
||||
#define S64(val) val
|
||||
#endif
|
||||
|
||||
/* MINGW has adopted the MSVC formatting for 64-bit ints as of gcc 4.4 */
|
||||
#if (defined(__MINGW32__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))) || defined(_MSC_VER)
|
||||
#define I64FMT "I64"
|
||||
#else
|
||||
#define I64FMT "ll"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#ifdef PTR64
|
||||
#define SIZETFMT "I64u"
|
||||
#else
|
||||
#define SIZETFMT "u"
|
||||
#endif
|
||||
#else
|
||||
#define SIZETFMT "zu"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* PCONFIG_H_ */
|
@ -10,6 +10,8 @@
|
||||
#ifndef PLISTS_H_
|
||||
#define PLISTS_H_
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "palloc.h"
|
||||
#include "pstring.h"
|
||||
|
||||
@ -236,7 +238,7 @@ public:
|
||||
{
|
||||
//nl_assert((pos>=0) && (pos<m_count));
|
||||
m_count--;
|
||||
for (int i = pos; i < m_count; i++)
|
||||
for (std::size_t i = pos; i < m_count; i++)
|
||||
{
|
||||
m_list[i] = m_list[i+1];
|
||||
}
|
||||
@ -339,7 +341,7 @@ class pnamedlist_t : public plist_t<_ListClass>
|
||||
public:
|
||||
_ListClass find(const pstring &name) const
|
||||
{
|
||||
for (int i=0; i < this->size(); i++)
|
||||
for (std::size_t i=0; i < this->size(); i++)
|
||||
if (get_name((*this)[i]) == name)
|
||||
return (*this)[i];
|
||||
return _ListClass(NULL);
|
||||
@ -510,4 +512,74 @@ private:
|
||||
_ListClass *m_head;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// string list
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class pstring_list_t : public plist_t<pstring>
|
||||
{
|
||||
public:
|
||||
pstring_list_t() : plist_t<pstring>() { }
|
||||
|
||||
pstring_list_t(const pstring &str, const pstring &onstr, bool ignore_empty = false)
|
||||
: plist_t<pstring>()
|
||||
{
|
||||
|
||||
int p = 0;
|
||||
int pn;
|
||||
|
||||
pn = str.find(onstr, p);
|
||||
while (pn>=0)
|
||||
{
|
||||
pstring t = str.substr(p, pn - p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
this->add(t);
|
||||
p = pn + onstr.len();
|
||||
pn = str.find(onstr, p);
|
||||
}
|
||||
if (p<str.len())
|
||||
{
|
||||
pstring t = str.substr(p);
|
||||
if (!ignore_empty || t.len() != 0)
|
||||
this->add(t);
|
||||
}
|
||||
}
|
||||
|
||||
static pstring_list_t splitexpr(const pstring &str, const pstring_list_t &onstrl)
|
||||
{
|
||||
pstring_list_t temp;
|
||||
pstring col = "";
|
||||
|
||||
int i = 0;
|
||||
while (i<str.len())
|
||||
{
|
||||
int p = -1;
|
||||
for (std::size_t j=0; j < onstrl.size(); j++)
|
||||
{
|
||||
if (std::strncmp(onstrl[j].cstr(), &(str.cstr()[i]), onstrl[j].len())==0)
|
||||
{
|
||||
p = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p>=0)
|
||||
{
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
col = "";
|
||||
temp.add(onstrl[p]);
|
||||
i += onstrl[p].len();
|
||||
}
|
||||
else
|
||||
{
|
||||
col += str.cstr()[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (col != "")
|
||||
temp.add(col);
|
||||
return temp;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* PLISTS_H_ */
|
@ -227,7 +227,7 @@ void ppreprocessor::error(const pstring &err)
|
||||
|
||||
|
||||
|
||||
double ppreprocessor::expr(const nl_util::pstring_list &sexpr, std::size_t &start, int prio)
|
||||
double ppreprocessor::expr(const pstring_list_t &sexpr, std::size_t &start, int prio)
|
||||
{
|
||||
double val;
|
||||
pstring tok=sexpr[start];
|
||||
@ -300,7 +300,7 @@ ppreprocessor::define_t *ppreprocessor::get_define(const pstring &name)
|
||||
|
||||
pstring ppreprocessor::replace_macros(const pstring &line)
|
||||
{
|
||||
nl_util::pstring_list elems = nl_util::splitexpr(line, m_expr_sep);
|
||||
pstring_list_t elems = pstring_list_t::splitexpr(line, m_expr_sep);
|
||||
pstringbuffer ret = "";
|
||||
for (std::size_t i=0; i<elems.size(); i++)
|
||||
{
|
||||
@ -313,7 +313,7 @@ pstring ppreprocessor::replace_macros(const pstring &line)
|
||||
return pstring(ret.cstr());
|
||||
}
|
||||
|
||||
static pstring catremainder(const nl_util::pstring_list &elems, std::size_t start, pstring sep)
|
||||
static pstring catremainder(const pstring_list_t &elems, std::size_t start, pstring sep)
|
||||
{
|
||||
pstringbuffer ret = "";
|
||||
for (std::size_t i=start; i<elems.size(); i++)
|
||||
@ -327,7 +327,7 @@ static pstring catremainder(const nl_util::pstring_list &elems, std::size_t star
|
||||
pstring ppreprocessor::process(const pstring &contents)
|
||||
{
|
||||
pstringbuffer ret = "";
|
||||
nl_util::pstring_list lines = nl_util::split(contents,"\n", false);
|
||||
pstring_list_t lines(contents,"\n", false);
|
||||
UINT32 ifflag = 0; // 31 if levels
|
||||
int level = 0;
|
||||
|
||||
@ -339,12 +339,12 @@ pstring ppreprocessor::process(const pstring &contents)
|
||||
lt = replace_macros(lt);
|
||||
if (lt.startsWith("#"))
|
||||
{
|
||||
nl_util::pstring_list lti = nl_util::split(lt, " ", true);
|
||||
pstring_list_t lti(lt, " ", true);
|
||||
if (lti[0].equals("#if"))
|
||||
{
|
||||
level++;
|
||||
std::size_t start = 0;
|
||||
nl_util::pstring_list t = nl_util::splitexpr(lt.substr(3).replace(" ",""), m_expr_sep);
|
||||
pstring_list_t t = pstring_list_t::splitexpr(lt.substr(3).replace(" ",""), m_expr_sep);
|
||||
int val = expr(t, start, 0);
|
||||
if (val == 0)
|
||||
ifflag |= (1 << level);
|
@ -9,8 +9,8 @@
|
||||
#define PPARSER_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "nl_config.h" // FIXME
|
||||
#include "nl_util.h"
|
||||
#include "../nl_config.h" // FIXME
|
||||
#include "../nl_util.h"
|
||||
|
||||
class ptokenizer
|
||||
{
|
||||
@ -161,7 +161,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
double expr(const nl_util::pstring_list &sexpr, std::size_t &start, int prio);
|
||||
double expr(const pstring_list_t &sexpr, std::size_t &start, int prio);
|
||||
|
||||
define_t *get_define(const pstring &name);
|
||||
|
||||
@ -172,7 +172,7 @@ protected:
|
||||
private:
|
||||
|
||||
plist_t<define_t> m_defines;
|
||||
nl_util::pstring_list m_expr_sep;
|
||||
pstring_list_t m_expr_sep;
|
||||
};
|
||||
|
||||
#endif /* PPARSER_H_ */
|
@ -11,23 +11,24 @@
|
||||
#include <cstdio>
|
||||
|
||||
#ifdef PSTANDALONE
|
||||
#if (PSTANDALONE)
|
||||
#if (PSTANDALONE)
|
||||
#define PSTANDALONE_PROVIDED
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PSTANDALONE_PROVIDED
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "poptions.h"
|
||||
#include "pstring.h"
|
||||
#include "plists.h"
|
||||
#include "plib/poptions.h"
|
||||
#include "plib/pstring.h"
|
||||
#include "plib/plists.h"
|
||||
#include "nl_setup.h"
|
||||
#include "nl_factory.h"
|
||||
#include "nl_parser.h"
|
||||
#include "devices/net_lib.h"
|
||||
|
||||
|
||||
#ifdef PSTANDALONE_PROVIDED
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#define osd_ticks_t clock_t
|
||||
|
||||
inline osd_ticks_t osd_ticks_per_second() { return CLOCKS_PER_SEC; }
|
||||
@ -35,14 +36,8 @@ inline osd_ticks_t osd_ticks_per_second() { return CLOCKS_PER_SEC; }
|
||||
osd_ticks_t osd_ticks(void) { return clock(); }
|
||||
#else
|
||||
|
||||
#include "netlist/poptions.h"
|
||||
#include "netlist/pstring.h"
|
||||
#include "netlist/plists.h"
|
||||
#include "netlist/nl_setup.h"
|
||||
#include "netlist/nl_factory.h"
|
||||
#include "netlist/nl_parser.h"
|
||||
#include "netlist/devices/net_lib.h"
|
||||
#endif
|
||||
|
||||
/***************************************************************************
|
||||
* MAME COMPATIBILITY ...
|
||||
*
|
||||
@ -209,7 +204,7 @@ public:
|
||||
void log_setup()
|
||||
{
|
||||
NL_VERBOSE_OUT(("Creating dynamic logs ...\n"));
|
||||
nl_util::pstring_list ll = nl_util::split(m_logs, ":");
|
||||
pstring_list_t ll(m_logs, ":");
|
||||
for (int i=0; i < ll.size(); i++)
|
||||
{
|
||||
pstring name = "log_" + ll[i];
|
||||
@ -360,7 +355,7 @@ public:
|
||||
|
||||
void convert(const pstring &contents)
|
||||
{
|
||||
nl_util::pstring_list spnl = nl_util::split(contents, "\n");
|
||||
pstring_list_t spnl(contents, "\n");
|
||||
|
||||
// Add gnd net
|
||||
|
||||
@ -369,7 +364,7 @@ public:
|
||||
|
||||
pstring line = "";
|
||||
|
||||
for (int i=0; i < spnl.size(); i++)
|
||||
for (std::size_t i=0; i < spnl.size(); i++)
|
||||
{
|
||||
// Basic preprocessing
|
||||
pstring inl = spnl[i].trim().ucase();
|
||||
@ -393,14 +388,14 @@ protected:
|
||||
: m_name(aname), m_no_export(false) {}
|
||||
|
||||
const pstring &name() { return m_name;}
|
||||
nl_util::pstring_list &terminals() { return m_terminals; }
|
||||
pstring_list_t &terminals() { return m_terminals; }
|
||||
void set_no_export() { m_no_export = true; }
|
||||
bool is_no_export() { return m_no_export; }
|
||||
|
||||
private:
|
||||
pstring m_name;
|
||||
bool m_no_export;
|
||||
nl_util::pstring_list m_terminals;
|
||||
pstring_list_t m_terminals;
|
||||
};
|
||||
|
||||
struct sp_dev_t
|
||||
@ -538,7 +533,7 @@ protected:
|
||||
{
|
||||
if (line != "")
|
||||
{
|
||||
nl_util::pstring_list tt = nl_util::split(line, " ", true);
|
||||
pstring_list_t tt(line, " ", true);
|
||||
double val = 0.0;
|
||||
switch (tt[0].cstr()[0])
|
||||
{
|
||||
@ -646,7 +641,7 @@ convert_t::sp_unit convert_t::m_sp_units[] = {
|
||||
{"", "%g", 1.0e0 },
|
||||
{"M", "CAP_M(%g)", 1.0e-3 },
|
||||
{"U", "CAP_U(%g)", 1.0e-6 },
|
||||
{"??", "CAP_U(%g)", 1.0e-6 },
|
||||
{"µ", "CAP_U(%g)", 1.0e-6 },
|
||||
{"N", "CAP_N(%g)", 1.0e-9 },
|
||||
{"P", "CAP_P(%g)", 1.0e-12},
|
||||
{"F", "%ge-15", 1.0e-15},
|
||||
|
Loading…
Reference in New Issue
Block a user