mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
Some more moves to the netlist namespace. (nw)
This commit is contained in:
parent
5283c4a803
commit
06e3aa2324
@ -63,8 +63,8 @@ void netlist_mame_analog_input_t::static_set_name(device_t &device, const char *
|
||||
void netlist_mame_analog_input_t::device_start()
|
||||
{
|
||||
LOG_DEV_CALLS(("start %s\n", tag()));
|
||||
netlist::netlist_param_t *p = this->nl_owner().setup().find_param(m_param_name);
|
||||
m_param = dynamic_cast<netlist::netlist_param_double_t *>(p);
|
||||
netlist::param_t *p = this->nl_owner().setup().find_param(m_param_name);
|
||||
m_param = dynamic_cast<netlist::param_double_t *>(p);
|
||||
if (m_param == NULL)
|
||||
{
|
||||
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
|
||||
@ -95,7 +95,7 @@ void netlist_mame_analog_output_t::static_set_params(device_t &device, const cha
|
||||
netlist.m_delegate = adelegate;
|
||||
}
|
||||
|
||||
void netlist_mame_analog_output_t::custom_netlist_additions(netlist::netlist_setup_t &setup)
|
||||
void netlist_mame_analog_output_t::custom_netlist_additions(netlist::setup_t &setup)
|
||||
{
|
||||
pstring dname = "OUT_" + m_in;
|
||||
m_delegate.bind_relative_to(owner()->machine().root_device());
|
||||
@ -137,8 +137,8 @@ void netlist_mame_logic_input_t::static_set_params(device_t &device, const char
|
||||
void netlist_mame_logic_input_t::device_start()
|
||||
{
|
||||
LOG_DEV_CALLS(("start %s\n", tag()));
|
||||
netlist::netlist_param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
|
||||
m_param = dynamic_cast<netlist::netlist_param_int_t *>(p);
|
||||
netlist::param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
|
||||
m_param = dynamic_cast<netlist::param_int_t *>(p);
|
||||
if (m_param == NULL)
|
||||
{
|
||||
fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
|
||||
@ -169,7 +169,7 @@ void netlist_mame_stream_input_t::device_start()
|
||||
LOG_DEV_CALLS(("start %s\n", tag()));
|
||||
}
|
||||
|
||||
void netlist_mame_stream_input_t::custom_netlist_additions(netlist::netlist_setup_t &setup)
|
||||
void netlist_mame_stream_input_t::custom_netlist_additions(netlist::setup_t &setup)
|
||||
{
|
||||
NETLIB_NAME(sound_in) *snd_in = setup.netlist().get_first_device<NETLIB_NAME(sound_in)>();
|
||||
if (snd_in == NULL)
|
||||
@ -207,7 +207,7 @@ void netlist_mame_stream_output_t::device_start()
|
||||
LOG_DEV_CALLS(("start %s\n", tag()));
|
||||
}
|
||||
|
||||
void netlist_mame_stream_output_t::custom_netlist_additions(netlist::netlist_setup_t &setup)
|
||||
void netlist_mame_stream_output_t::custom_netlist_additions(netlist::setup_t &setup)
|
||||
{
|
||||
//NETLIB_NAME(sound_out) *snd_out;
|
||||
pstring sname = pstring::sprintf("STREAM_OUT_%d", m_channel);
|
||||
@ -257,7 +257,7 @@ netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, cons
|
||||
m_icount(0),
|
||||
m_div(0),
|
||||
m_rem(0),
|
||||
m_old(netlist_time::zero),
|
||||
m_old(netlist::netlist_time::zero),
|
||||
m_netlist(NULL),
|
||||
m_setup(NULL),
|
||||
m_setup_func(NULL)
|
||||
@ -269,14 +269,14 @@ netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, devi
|
||||
m_icount(0),
|
||||
m_div(0),
|
||||
m_rem(0),
|
||||
m_old(netlist_time::zero),
|
||||
m_old(netlist::netlist_time::zero),
|
||||
m_netlist(NULL),
|
||||
m_setup(NULL),
|
||||
m_setup_func(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void netlist_mame_device_t::static_set_constructor(device_t &device, void (*setup_func)(netlist::netlist_setup_t &))
|
||||
void netlist_mame_device_t::static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &))
|
||||
{
|
||||
LOG_DEV_CALLS(("static_set_constructor\n"));
|
||||
netlist_mame_device_t &netlist = downcast<netlist_mame_device_t &>(device);
|
||||
@ -295,7 +295,7 @@ void netlist_mame_device_t::device_start()
|
||||
//printf("clock is %d\n", clock());
|
||||
|
||||
m_netlist = global_alloc_clear(netlist_mame_t(*this));
|
||||
m_setup = global_alloc_clear(netlist::netlist_setup_t(m_netlist));
|
||||
m_setup = global_alloc_clear(netlist::setup_t(m_netlist));
|
||||
netlist().init_object(*m_netlist, "netlist");
|
||||
m_setup->init();
|
||||
|
||||
@ -325,7 +325,7 @@ void netlist_mame_device_t::device_start()
|
||||
|
||||
save_state();
|
||||
|
||||
m_old = netlist_time::zero;
|
||||
m_old = netlist::netlist_time::zero;
|
||||
m_rem = 0;
|
||||
|
||||
}
|
||||
@ -333,7 +333,7 @@ void netlist_mame_device_t::device_start()
|
||||
void netlist_mame_device_t::device_clock_changed()
|
||||
{
|
||||
//printf("device_clock_changed\n");
|
||||
m_div = netlist_time::from_hz(clock()).as_raw();
|
||||
m_div = netlist::netlist_time::from_hz(clock()).as_raw();
|
||||
//m_rem = 0;
|
||||
//NL_VERBOSE_OUT(("Setting clock %" I64FMT "d and divisor %d\n", clock(), m_div));
|
||||
NL_VERBOSE_OUT(("Setting clock %d and divisor %d\n", clock(), m_div));
|
||||
@ -344,7 +344,7 @@ void netlist_mame_device_t::device_clock_changed()
|
||||
void netlist_mame_device_t::device_reset()
|
||||
{
|
||||
LOG_DEV_CALLS(("device_reset\n"));
|
||||
m_old = netlist_time::zero;
|
||||
m_old = netlist::netlist_time::zero;
|
||||
m_rem = 0;
|
||||
netlist().do_reset();
|
||||
}
|
||||
@ -383,7 +383,7 @@ void netlist_mame_device_t::device_timer(emu_timer &timer, device_timer_id id, i
|
||||
|
||||
ATTR_HOT ATTR_ALIGN void netlist_mame_device_t::update_time_x()
|
||||
{
|
||||
const netlist_time delta = netlist().time() - m_old + netlist_time::from_raw(m_rem);
|
||||
const netlist::netlist_time delta = netlist().time() - m_old + netlist::netlist_time::from_raw(m_rem);
|
||||
m_old = netlist().time();
|
||||
m_icount -= divu_64x32_rem(delta.as_raw(), m_div, &m_rem);
|
||||
}
|
||||
@ -529,13 +529,13 @@ ATTR_HOT void netlist_mame_cpu_device_t::execute_run()
|
||||
m_genPC++;
|
||||
m_genPC &= 255;
|
||||
debugger_instruction_hook(this, m_genPC);
|
||||
netlist().process_queue(netlist_time::from_raw(m_div));
|
||||
netlist().process_queue(netlist::netlist_time::from_raw(m_div));
|
||||
update_time_x();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
netlist().process_queue(netlist_time::from_raw(m_div) * m_icount);
|
||||
netlist().process_queue(netlist::netlist_time::from_raw(m_div) * m_icount);
|
||||
update_time_x();
|
||||
}
|
||||
}
|
||||
@ -576,7 +576,7 @@ void netlist_mame_sound_device_t::device_start()
|
||||
if (chan < 0 || chan >= MAX_OUT || chan >= outdevs.size())
|
||||
fatalerror("illegal channel number");
|
||||
m_out[chan] = outdevs[i];
|
||||
m_out[chan]->m_sample = netlist_time::from_hz(clock());
|
||||
m_out[chan]->m_sample = netlist::netlist_time::from_hz(clock());
|
||||
m_out[chan]->m_buffer = NULL;
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ void netlist_mame_sound_device_t::device_start()
|
||||
{
|
||||
m_in = indevs[0];
|
||||
m_num_inputs = m_in->resolve();
|
||||
m_in->m_inc = netlist_time::from_hz(clock());
|
||||
m_in->m_inc = netlist::netlist_time::from_hz(clock());
|
||||
}
|
||||
|
||||
/* initialize the stream(s) */
|
||||
@ -622,11 +622,11 @@ void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stre
|
||||
m_in->m_buffer[i] = inputs[i];
|
||||
}
|
||||
|
||||
netlist_time cur = netlist().time();
|
||||
netlist::netlist_time cur = netlist().time();
|
||||
|
||||
netlist().process_queue(netlist_time::from_raw(m_div) * samples);
|
||||
netlist().process_queue(netlist::netlist_time::from_raw(m_div) * samples);
|
||||
|
||||
cur += (netlist_time::from_raw(m_div) * samples);
|
||||
cur += (netlist::netlist_time::from_raw(m_div) * samples);
|
||||
|
||||
for (int i=0; i < m_num_outputs; i++)
|
||||
{
|
||||
@ -639,9 +639,9 @@ void netlist_mame_sound_device_t::sound_stream_update(sound_stream &stream, stre
|
||||
// memregion source support
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
bool netlist_source_memregion_t::parse(netlist::netlist_setup_t *setup, const pstring name)
|
||||
bool netlist_source_memregion_t::parse(netlist::setup_t *setup, const pstring name)
|
||||
{
|
||||
const char *mem = (const char *)downcast<netlist_mame_t &>(setup->netlist()).machine().root_device().memregion(m_name.cstr())->base();
|
||||
netlist::netlist_parser p(*setup);
|
||||
netlist::parser_t p(*setup);
|
||||
return p.parse(mem, name);
|
||||
}
|
||||
|
@ -60,15 +60,15 @@
|
||||
// Extensions to interface netlist with MAME code ....
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_source_memregion_t : public netlist::netlist_setup_t::source_t
|
||||
class netlist_source_memregion_t : public netlist::setup_t::source_t
|
||||
{
|
||||
public:
|
||||
netlist_source_memregion_t(pstring name)
|
||||
: netlist::netlist_setup_t::source_t(), m_name(name)
|
||||
: netlist::setup_t::source_t(), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
bool parse(netlist::netlist_setup_t *setup, const pstring name);
|
||||
bool parse(netlist::setup_t *setup, const pstring name);
|
||||
private:
|
||||
pstring m_name;
|
||||
};
|
||||
@ -116,12 +116,12 @@ public:
|
||||
netlist_mame_device_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *file);
|
||||
virtual ~netlist_mame_device_t() {}
|
||||
|
||||
static void static_set_constructor(device_t &device, void (*setup_func)(netlist::netlist_setup_t &));
|
||||
static void static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &));
|
||||
|
||||
ATTR_HOT inline netlist::netlist_setup_t &setup() { return *m_setup; }
|
||||
ATTR_HOT inline netlist::setup_t &setup() { return *m_setup; }
|
||||
ATTR_HOT inline netlist_mame_t &netlist() { return *m_netlist; }
|
||||
|
||||
ATTR_HOT inline netlist_time last_time_update() { return m_old; }
|
||||
ATTR_HOT inline netlist::netlist_time last_time_update() { return m_old; }
|
||||
ATTR_HOT void update_time_x();
|
||||
ATTR_HOT void check_mame_abort_slice();
|
||||
|
||||
@ -150,12 +150,12 @@ private:
|
||||
|
||||
/* timing support here - so sound can hijack it ... */
|
||||
UINT32 m_rem;
|
||||
netlist_time m_old;
|
||||
netlist::netlist_time m_old;
|
||||
|
||||
netlist_mame_t * m_netlist;
|
||||
netlist::netlist_setup_t * m_setup;
|
||||
netlist::setup_t * m_setup;
|
||||
|
||||
void (*m_setup_func)(netlist::netlist_setup_t &);
|
||||
void (*m_setup_func)(netlist::setup_t &);
|
||||
};
|
||||
|
||||
inline running_machine &netlist_mame_t::machine()
|
||||
@ -179,7 +179,7 @@ public:
|
||||
netlist_mame_cpu_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~netlist_mame_cpu_device_t() {}
|
||||
|
||||
static void static_set_constructor(device_t &device, void (*setup_func)(netlist::netlist_setup_t &));
|
||||
static void static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &));
|
||||
|
||||
protected:
|
||||
// netlist_mame_device_t
|
||||
@ -256,7 +256,7 @@ public:
|
||||
netlist_mame_sound_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~netlist_mame_sound_device_t() {}
|
||||
|
||||
static void static_set_constructor(device_t &device, void (*setup_func)(netlist::netlist_setup_t &));
|
||||
static void static_set_constructor(device_t &device, void (*setup_func)(netlist::setup_t &));
|
||||
|
||||
inline sound_stream *get_stream() { return m_stream; }
|
||||
|
||||
@ -306,7 +306,7 @@ public:
|
||||
}
|
||||
virtual ~netlist_mame_sub_interface() { }
|
||||
|
||||
virtual void custom_netlist_additions(netlist::netlist_setup_t &setup) { }
|
||||
virtual void custom_netlist_additions(netlist::setup_t &setup) { }
|
||||
|
||||
inline netlist_mame_device_t &nl_owner() const { return *m_owner; }
|
||||
|
||||
@ -375,7 +375,7 @@ protected:
|
||||
virtual void device_start();
|
||||
|
||||
private:
|
||||
netlist::netlist_param_double_t *m_param;
|
||||
netlist::param_double_t *m_param;
|
||||
bool m_auto_port;
|
||||
pstring m_param_name;
|
||||
};
|
||||
@ -400,7 +400,7 @@ public:
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void custom_netlist_additions(netlist::netlist_setup_t &setup);
|
||||
virtual void custom_netlist_additions(netlist::setup_t &setup);
|
||||
|
||||
private:
|
||||
pstring m_in;
|
||||
@ -449,7 +449,7 @@ protected:
|
||||
virtual void device_start();
|
||||
|
||||
private:
|
||||
netlist::netlist_param_int_t *m_param;
|
||||
netlist::param_int_t *m_param;
|
||||
UINT32 m_mask;
|
||||
UINT32 m_shift;
|
||||
pstring m_param_name;
|
||||
@ -473,7 +473,7 @@ public:
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void custom_netlist_additions(netlist::netlist_setup_t &setup);
|
||||
virtual void custom_netlist_additions(netlist::setup_t &setup);
|
||||
private:
|
||||
UINT32 m_channel;
|
||||
pstring m_param_name;
|
||||
@ -497,7 +497,7 @@ public:
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual void custom_netlist_additions(netlist::netlist_setup_t &setup);
|
||||
virtual void custom_netlist_additions(netlist::setup_t &setup);
|
||||
private:
|
||||
UINT32 m_channel;
|
||||
pstring m_out_name;
|
||||
@ -569,7 +569,7 @@ public:
|
||||
register_param("CHAN", m_channel, 0);
|
||||
register_param("MULT", m_mult, 1000.0);
|
||||
register_param("OFFSET", m_offset, 0.0);
|
||||
m_sample = netlist_time::from_hz(1); //sufficiently big enough
|
||||
m_sample = netlist::netlist_time::from_hz(1); //sufficiently big enough
|
||||
save(NAME(m_last_buffer));
|
||||
}
|
||||
|
||||
@ -577,10 +577,10 @@ public:
|
||||
{
|
||||
m_cur = 0;
|
||||
m_last_pos = 0;
|
||||
m_last_buffer = netlist_time::zero;
|
||||
m_last_buffer = netlist::netlist_time::zero;
|
||||
}
|
||||
|
||||
ATTR_HOT void sound_update(const netlist_time upto)
|
||||
ATTR_HOT void sound_update(const netlist::netlist_time upto)
|
||||
{
|
||||
int pos = (upto - m_last_buffer) / m_sample;
|
||||
if (pos >= BUFSIZE)
|
||||
@ -598,23 +598,23 @@ public:
|
||||
m_cur = (stream_sample_t) (val * m_mult.Value() + m_offset.Value());
|
||||
}
|
||||
|
||||
ATTR_HOT void buffer_reset(netlist_time upto)
|
||||
ATTR_HOT void buffer_reset(netlist::netlist_time upto)
|
||||
{
|
||||
m_last_pos = 0;
|
||||
m_last_buffer = upto;
|
||||
}
|
||||
|
||||
netlist::netlist_param_int_t m_channel;
|
||||
netlist::netlist_param_double_t m_mult;
|
||||
netlist::netlist_param_double_t m_offset;
|
||||
netlist::param_int_t m_channel;
|
||||
netlist::param_double_t m_mult;
|
||||
netlist::param_double_t m_offset;
|
||||
stream_sample_t *m_buffer;
|
||||
netlist_time m_sample;
|
||||
netlist::netlist_time m_sample;
|
||||
|
||||
private:
|
||||
netlist::analog_input_t m_in;
|
||||
stream_sample_t m_cur;
|
||||
int m_last_pos;
|
||||
netlist_time m_last_buffer;
|
||||
netlist::netlist_time m_last_buffer;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -636,7 +636,7 @@ public:
|
||||
register_input("FB", m_feedback);
|
||||
|
||||
connect(m_feedback, m_Q);
|
||||
m_inc = netlist_time::from_nsec(1);
|
||||
m_inc = netlist::netlist_time::from_nsec(1);
|
||||
|
||||
|
||||
for (int i = 0; i < MAX_INPUT_CHANNELS; i++)
|
||||
@ -665,7 +665,7 @@ public:
|
||||
if (i != m_num_channel)
|
||||
netlist().error("sound input numbering has to be sequential!");
|
||||
m_num_channel++;
|
||||
m_param[i] = dynamic_cast<netlist::netlist_param_double_t *>(setup().find_param(m_param_name[i].Value(), true));
|
||||
m_param[i] = dynamic_cast<netlist::param_double_t *>(setup().find_param(m_param_name[i].Value(), true));
|
||||
}
|
||||
}
|
||||
return m_num_channel;
|
||||
@ -689,12 +689,12 @@ public:
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
netlist::netlist_param_str_t m_param_name[MAX_INPUT_CHANNELS];
|
||||
netlist::netlist_param_double_t *m_param[MAX_INPUT_CHANNELS];
|
||||
netlist::param_str_t m_param_name[MAX_INPUT_CHANNELS];
|
||||
netlist::param_double_t *m_param[MAX_INPUT_CHANNELS];
|
||||
stream_sample_t *m_buffer[MAX_INPUT_CHANNELS];
|
||||
netlist::netlist_param_double_t m_param_mult[MAX_INPUT_CHANNELS];
|
||||
netlist::netlist_param_double_t m_param_offset[MAX_INPUT_CHANNELS];
|
||||
netlist_time m_inc;
|
||||
netlist::param_double_t m_param_mult[MAX_INPUT_CHANNELS];
|
||||
netlist::param_double_t m_param_offset[MAX_INPUT_CHANNELS];
|
||||
netlist::netlist_time m_inc;
|
||||
|
||||
private:
|
||||
netlist::logic_input_t m_feedback;
|
||||
|
@ -180,7 +180,7 @@ void gmres_t::diagonal_pointer_cr (const int nz_num, const int ia[], const int j
|
||||
}
|
||||
//****************************************************************************80
|
||||
|
||||
void gmres_t::ilu_cr (const int nz_num, const int ia[], const int ja[], const double a[])
|
||||
void gmres_t::ilu_cr (const int nz_num, const int * RESTRICT ia, const int * RESTRICT ja, const double * RESTRICT a)
|
||||
|
||||
//****************************************************************************80
|
||||
//
|
||||
@ -502,8 +502,8 @@ gmres_t::~gmres_t()
|
||||
delete [] m_y;
|
||||
}
|
||||
|
||||
int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
double x[], const double rhs[], const int itr_max, const int mr, const double tol_abs,
|
||||
int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double * RESTRICT a,
|
||||
double * RESTRICT x, const double * RESTRICT rhs, const int itr_max, const int mr, const double tol_abs,
|
||||
const double tol_rel )
|
||||
|
||||
//****************************************************************************80
|
||||
@ -602,7 +602,7 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
//
|
||||
{
|
||||
double av;
|
||||
double delta = 1.0e-03;
|
||||
const double delta = 1.0e-03;
|
||||
double htmp;
|
||||
int itr;
|
||||
int itr_used = 0;
|
||||
@ -640,7 +640,7 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
if (pre_ilu)
|
||||
lus_cr(ia, ja, m_r);
|
||||
|
||||
rho = sqrt(r8vec_dot2(m_r));
|
||||
rho = std::sqrt(r8vec_dot2(m_r));
|
||||
|
||||
if (verbose)
|
||||
cout << " ITR = " << itr << " Residual = " << rho << "\n";
|
||||
@ -648,7 +648,7 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
if (itr == 0)
|
||||
rho_tol = rho * tol_rel;
|
||||
|
||||
double rhoq = 1.0 / rho;
|
||||
const double rhoq = 1.0 / rho;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
m_v[0][i] = m_r[i] * rhoq;
|
||||
@ -665,45 +665,45 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
for (int k = 0; k < mr; k++)
|
||||
{
|
||||
k_copy = k;
|
||||
const int k1 = k + 1;
|
||||
|
||||
ax_cr(ia, ja, a, m_v[k], m_v[k + 1]);
|
||||
ax_cr(ia, ja, a, m_v[k], m_v[k1]);
|
||||
|
||||
if (pre_ilu)
|
||||
lus_cr(ia, ja, m_v[k + 1]);
|
||||
lus_cr(ia, ja, m_v[k1]);
|
||||
|
||||
av = sqrt(r8vec_dot2(m_v[k + 1]));
|
||||
av = std::sqrt(r8vec_dot2(m_v[k1]));
|
||||
|
||||
for (int j = 0; j <= k; j++)
|
||||
{
|
||||
m_h[j][k] = r8vec_dot(m_v[k + 1], m_v[j]);
|
||||
m_h[j][k] = r8vec_dot(m_v[k1], m_v[j]);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
m_v[k + 1][i] = m_v[k + 1][i]
|
||||
- m_h[j][k] * m_v[j][i];
|
||||
m_v[k1][i] -= m_h[j][k] * m_v[j][i];
|
||||
}
|
||||
}
|
||||
m_h[k + 1][k] = sqrt(r8vec_dot2(m_v[k + 1]));
|
||||
m_h[k1][k] = std::sqrt(r8vec_dot2(m_v[k1]));
|
||||
|
||||
if ((av + delta * m_h[k + 1][k]) == av)
|
||||
if ((av + delta * m_h[k1][k]) == av)
|
||||
{
|
||||
for (int j = 0; j < k + 1; j++)
|
||||
for (int j = 0; j < k1; j++)
|
||||
{
|
||||
htmp = r8vec_dot(m_v[k + 1], m_v[j]);
|
||||
htmp = r8vec_dot(m_v[k1], m_v[j]);
|
||||
m_h[j][k] = m_h[j][k] + htmp;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
m_v[k + 1][i] = m_v[k + 1][i] - htmp * m_v[j][i];
|
||||
m_v[k1][i] -= htmp * m_v[j][i];
|
||||
}
|
||||
}
|
||||
m_h[k + 1][k] = sqrt(r8vec_dot2(m_v[k + 1]));
|
||||
m_h[k1][k] = sqrt(r8vec_dot2(m_v[k1]));
|
||||
}
|
||||
|
||||
if (m_h[k + 1][k] != 0.0)
|
||||
if (m_h[k1][k] != 0.0)
|
||||
{
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
m_v[k + 1][i] = m_v[k + 1][i]
|
||||
/ m_h[k + 1][k];
|
||||
m_v[k1][i] = m_v[k1][i]
|
||||
/ m_h[k1][k];
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,17 +722,17 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
m_h[i][k] = m_y[i];
|
||||
}
|
||||
}
|
||||
mu = sqrt(
|
||||
mu = std::sqrt(
|
||||
m_h[k][k] * m_h[k][k]
|
||||
+ m_h[k + 1][k] * m_h[k + 1][k]);
|
||||
+ m_h[k1][k] * m_h[k1][k]);
|
||||
m_c[k] = m_h[k][k] / mu;
|
||||
m_s[k] = -m_h[k + 1][k] / mu;
|
||||
m_s[k] = -m_h[k1][k] / mu;
|
||||
m_h[k][k] = m_c[k] * m_h[k][k]
|
||||
- m_s[k] * m_h[k + 1][k];
|
||||
m_h[k + 1][k] = 0.0;
|
||||
- m_s[k] * m_h[k1][k];
|
||||
m_h[k1][k] = 0.0;
|
||||
mult_givens(m_c[k], m_s[k], k, m_g);
|
||||
|
||||
rho = std::abs(m_g[k + 1]);
|
||||
rho = std::abs(m_g[k1]);
|
||||
|
||||
itr_used = itr_used + 1;
|
||||
|
||||
@ -757,7 +757,7 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
}
|
||||
m_y[i] = tmp / m_h[i][i];
|
||||
}
|
||||
double cerr = 0;
|
||||
//double cerr = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
double tmp = 0.0;
|
||||
@ -765,7 +765,7 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
{
|
||||
tmp += m_v[j][i] * m_y[j];
|
||||
}
|
||||
cerr = std::max(std::abs(tmp), cerr);
|
||||
//cerr = std::max(std::abs(tmp), cerr);
|
||||
x[i] += tmp;
|
||||
}
|
||||
#if 0
|
||||
@ -795,7 +795,7 @@ int gmres_t::pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
}
|
||||
//****************************************************************************80
|
||||
|
||||
double gmres_t::r8vec_dot (const double a1[], const double a2[] )
|
||||
double gmres_t::r8vec_dot (const double * RESTRICT a1, const double * RESTRICT a2 )
|
||||
{
|
||||
const int n = m_n;
|
||||
double value = 0.0;
|
||||
|
@ -8,15 +8,15 @@ public:
|
||||
gmres_t(const int n);
|
||||
~gmres_t();
|
||||
|
||||
int pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double a[],
|
||||
double x[], const double rhs[], const int itr_max, const int mr, const double tol_abs,
|
||||
int pmgmres_ilu_cr (const int nz_num, int ia[], int ja[], double * RESTRICT a,
|
||||
double * RESTRICT x, const double * RESTRICT rhs, const int itr_max, const int mr, const double tol_abs,
|
||||
const double tol_rel );
|
||||
|
||||
private:
|
||||
|
||||
void diagonal_pointer_cr(const int nz_num, const int ia[], const int ja[]);
|
||||
void rearrange_cr (const int nz_num, int ia[], int ja[], double a[] );
|
||||
inline double r8vec_dot (const double a1[], const double a2[] );
|
||||
inline double r8vec_dot (const double * RESTRICT a1, const double * RESTRICT a2 );
|
||||
inline double r8vec_dot2 (const double a1[]);
|
||||
|
||||
void ax_cr(const int * RESTRICT ia, const int * RESTRICT ja, const double * RESTRICT a,
|
||||
@ -24,7 +24,7 @@ private:
|
||||
|
||||
void lus_cr (const int * RESTRICT ia, const int * RESTRICT ja, double * RESTRICT r);
|
||||
|
||||
void ilu_cr (const int nz_num, const int ia[], const int ja[], const double a[]);
|
||||
void ilu_cr (const int nz_num, const int * RESTRICT ia, const int * RESTRICT ja, const double * RESTRICT a);
|
||||
|
||||
const int m_n;
|
||||
|
||||
|
@ -51,7 +51,7 @@ protected:
|
||||
virtual void reset();
|
||||
ATTR_HOT void update();
|
||||
|
||||
netlist_param_model_t m_model;
|
||||
param_model_t m_model;
|
||||
private:
|
||||
q_type m_qtype;
|
||||
};
|
||||
@ -151,8 +151,8 @@ protected:
|
||||
ATTR_HOT void virtual update();
|
||||
NETLIB_UPDATE_TERMINALSI();
|
||||
|
||||
netlist_generic_diode m_gD_BC;
|
||||
netlist_generic_diode m_gD_BE;
|
||||
generic_diode m_gD_BC;
|
||||
generic_diode m_gD_BE;
|
||||
|
||||
nld_twoterm m_D_CB; // gcc, gce - gcc, gec - gcc, gcc - gce | Ic
|
||||
nld_twoterm m_D_EB; // gee, gec - gee, gce - gee, gee - gec | Ie
|
||||
|
@ -74,8 +74,8 @@ protected:
|
||||
terminal_t m_OP1;
|
||||
terminal_t m_ON1;
|
||||
|
||||
netlist_param_double_t m_G;
|
||||
netlist_param_double_t m_RI;
|
||||
param_double_t m_G;
|
||||
param_double_t m_RI;
|
||||
|
||||
nl_double m_gfac;
|
||||
};
|
||||
@ -110,8 +110,6 @@ class NETLIB_NAME(CCCS) : public NETLIB_NAME(VCCS)
|
||||
public:
|
||||
ATTR_COLD NETLIB_NAME(CCCS)()
|
||||
: NETLIB_NAME(VCCS)(CCCS), m_gfac(1.0) { }
|
||||
//ATTR_COLD NETLIB_NAME(CCCS)(const family_t afamily)
|
||||
//: netlist_device_t(afamily), m_gfac(1.0) { }
|
||||
|
||||
protected:
|
||||
virtual void start();
|
||||
@ -166,7 +164,7 @@ protected:
|
||||
terminal_t m_OP2;
|
||||
terminal_t m_ON2;
|
||||
|
||||
netlist_param_double_t m_RO;
|
||||
param_double_t m_RO;
|
||||
};
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_END()
|
||||
|
@ -15,17 +15,17 @@
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_direct_t: public netlist_matrix_solver_t
|
||||
class matrix_solver_direct_t: public matrix_solver_t
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_matrix_solver_direct_t(const netlist_solver_parameters_t *params, const int size);
|
||||
netlist_matrix_solver_direct_t(const eSolverType type, const netlist_solver_parameters_t *params, const int size);
|
||||
matrix_solver_direct_t(const solver_parameters_t *params, const int size);
|
||||
matrix_solver_direct_t(const eSolverType type, const solver_parameters_t *params, const int size);
|
||||
|
||||
virtual ~netlist_matrix_solver_direct_t();
|
||||
virtual ~matrix_solver_direct_t();
|
||||
|
||||
virtual void vsetup(analog_net_t::list_t &nets);
|
||||
virtual void reset() { netlist_matrix_solver_t::reset(); }
|
||||
virtual void reset() { matrix_solver_t::reset(); }
|
||||
|
||||
ATTR_HOT inline unsigned N() const { if (m_N == 0) return m_dim; else return m_N; }
|
||||
|
||||
@ -65,11 +65,11 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver_direct
|
||||
// matrix_solver_direct
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t()
|
||||
matrix_solver_direct_t<m_N, _storage_N>::~matrix_solver_direct_t()
|
||||
{
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
@ -80,7 +80,7 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::~netlist_matrix_solver_direct_t
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep()
|
||||
ATTR_HOT nl_double matrix_solver_direct_t<m_N, _storage_N>::compute_next_timestep()
|
||||
{
|
||||
nl_double new_solver_timestep = m_params.m_max_timestep;
|
||||
|
||||
@ -119,24 +119,24 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::compute_next
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, terminal_t *term)
|
||||
ATTR_COLD void matrix_solver_direct_t<m_N, _storage_N>::add_term(int k, terminal_t *term)
|
||||
{
|
||||
if (term->m_otherterm->net().isRailNet())
|
||||
{
|
||||
m_rails_temp[k].add(term, -1);
|
||||
m_rails_temp[k].add(term, -1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
int ot = get_net_idx(&term->m_otherterm->net());
|
||||
if (ot>=0)
|
||||
{
|
||||
m_terms[k]->add(term, ot);
|
||||
m_terms[k]->add(term, ot, true);
|
||||
SOLVER_VERBOSE_OUT(("Net %d Term %s %f %f\n", k, terms[i]->name().cstr(), terms[i]->m_gt, terms[i]->m_go));
|
||||
}
|
||||
/* Should this be allowed ? */
|
||||
else // if (ot<0)
|
||||
{
|
||||
m_rails_temp[k].add(term, ot);
|
||||
m_rails_temp[k].add(term, ot, true);
|
||||
netlist().error("found term with missing othernet %s\n", term->name().cstr());
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::add_term(int k,
|
||||
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
ATTR_COLD void matrix_solver_direct_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
{
|
||||
if (m_dim < nets.size())
|
||||
netlist().error("Dimension %d less than %" SIZETFMT, m_dim, nets.size());
|
||||
@ -155,13 +155,13 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(analog_ne
|
||||
m_rails_temp[k].clear();
|
||||
}
|
||||
|
||||
netlist_matrix_solver_t::setup(nets);
|
||||
matrix_solver_t::setup(nets);
|
||||
|
||||
for (unsigned k = 0; k < N(); k++)
|
||||
{
|
||||
m_terms[k]->m_railstart = m_terms[k]->count();
|
||||
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]);
|
||||
this->m_terms[k]->add(m_rails_temp[k].terms()[i], m_rails_temp[k].net_other()[i], false);
|
||||
|
||||
m_rails_temp[k].clear(); // no longer needed
|
||||
m_terms[k]->set_pointers();
|
||||
@ -283,7 +283,7 @@ ATTR_COLD void netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(analog_ne
|
||||
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_A()
|
||||
ATTR_HOT void matrix_solver_direct_t<m_N, _storage_N>::build_LE_A()
|
||||
{
|
||||
const unsigned iN = N();
|
||||
for (unsigned k = 0; k < iN; k++)
|
||||
@ -309,7 +309,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_A()
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS(nl_double * RESTRICT rhs)
|
||||
ATTR_HOT void matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS(nl_double * RESTRICT rhs)
|
||||
{
|
||||
const unsigned iN = N();
|
||||
for (unsigned k = 0; k < iN; k++)
|
||||
@ -334,7 +334,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::build_LE_RHS(nl_d
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
ATTR_HOT void matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
{
|
||||
#if 0
|
||||
for (int i = 0; i < N(); i++)
|
||||
@ -411,7 +411,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_solve()
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
ATTR_HOT void matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
nl_double * RESTRICT x)
|
||||
{
|
||||
const unsigned kN = N();
|
||||
@ -459,7 +459,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::LE_back_subst(
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
ATTR_HOT nl_double matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
const nl_double * RESTRICT V)
|
||||
{
|
||||
/* FIXME: Ideally we should also include currents (RHS) here. This would
|
||||
@ -475,7 +475,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::delta(
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store(
|
||||
ATTR_HOT void matrix_solver_direct_t<m_N, _storage_N>::store(
|
||||
const nl_double * RESTRICT V)
|
||||
{
|
||||
for (unsigned i = 0, iN=N(); i < iN; i++)
|
||||
@ -485,7 +485,7 @@ ATTR_HOT void netlist_matrix_solver_direct_t<m_N, _storage_N>::store(
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
ATTR_HOT nl_double matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
this->solve_base(this);
|
||||
return this->compute_next_timestep();
|
||||
@ -493,7 +493,7 @@ ATTR_HOT nl_double netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve()
|
||||
|
||||
|
||||
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)
|
||||
ATTR_HOT int 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 };
|
||||
|
||||
@ -515,7 +515,7 @@ ATTR_HOT int netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(
|
||||
}
|
||||
|
||||
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)
|
||||
ATTR_HOT inline int matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
this->build_LE_A();
|
||||
this->build_LE_RHS(m_last_RHS);
|
||||
@ -529,8 +529,8 @@ ATTR_HOT inline int netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_
|
||||
}
|
||||
|
||||
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 *params, const int size)
|
||||
: netlist_matrix_solver_t(GAUSSIAN_ELIMINATION, params)
|
||||
matrix_solver_direct_t<m_N, _storage_N>::matrix_solver_direct_t(const solver_parameters_t *params, const int size)
|
||||
: matrix_solver_t(GAUSSIAN_ELIMINATION, params)
|
||||
, m_dim(size)
|
||||
, m_lp_fact(0)
|
||||
{
|
||||
@ -546,8 +546,8 @@ netlist_matrix_solver_direct_t<m_N, _storage_N>::netlist_matrix_solver_direct_t(
|
||||
}
|
||||
|
||||
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 *params, const int size)
|
||||
: netlist_matrix_solver_t(type, params)
|
||||
matrix_solver_direct_t<m_N, _storage_N>::matrix_solver_direct_t(const eSolverType type, const solver_parameters_t *params, const int size)
|
||||
: matrix_solver_t(type, params)
|
||||
, m_dim(size)
|
||||
, m_lp_fact(0)
|
||||
{
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
class netlist_matrix_solver_direct1_t: public netlist_matrix_solver_direct_t<1,1>
|
||||
class matrix_solver_direct1_t: public matrix_solver_direct_t<1,1>
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_matrix_solver_direct1_t(const netlist_solver_parameters_t *params)
|
||||
: netlist_matrix_solver_direct_t<1, 1>(params, 1)
|
||||
matrix_solver_direct1_t(const solver_parameters_t *params)
|
||||
: matrix_solver_direct_t<1, 1>(params, 1)
|
||||
{}
|
||||
ATTR_HOT inline int vsolve_non_dynamic(const bool newton_raphson);
|
||||
protected:
|
||||
@ -27,16 +27,16 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver - Direct1
|
||||
// matrix_solver - Direct1
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct1_t::vsolve()
|
||||
ATTR_HOT nl_double matrix_solver_direct1_t::vsolve()
|
||||
{
|
||||
solve_base<netlist_matrix_solver_direct1_t>(this);
|
||||
solve_base<matrix_solver_direct1_t>(this);
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
ATTR_HOT inline int netlist_matrix_solver_direct1_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
|
||||
ATTR_HOT inline int matrix_solver_direct1_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
|
||||
{
|
||||
analog_net_t *net = m_nets[0];
|
||||
this->build_LE_A();
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
class netlist_matrix_solver_direct2_t: public netlist_matrix_solver_direct_t<2,2>
|
||||
class matrix_solver_direct2_t: public matrix_solver_direct_t<2,2>
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_matrix_solver_direct2_t(const netlist_solver_parameters_t *params)
|
||||
: netlist_matrix_solver_direct_t<2, 2>(params, 2)
|
||||
matrix_solver_direct2_t(const solver_parameters_t *params)
|
||||
: matrix_solver_direct_t<2, 2>(params, 2)
|
||||
{}
|
||||
ATTR_HOT inline int vsolve_non_dynamic(const bool newton_raphson);
|
||||
protected:
|
||||
@ -27,16 +27,16 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver - Direct2
|
||||
// matrix_solver - Direct2
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_HOT nl_double netlist_matrix_solver_direct2_t::vsolve()
|
||||
ATTR_HOT nl_double matrix_solver_direct2_t::vsolve()
|
||||
{
|
||||
solve_base<netlist_matrix_solver_direct2_t>(this);
|
||||
solve_base<matrix_solver_direct2_t>(this);
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
ATTR_HOT inline int netlist_matrix_solver_direct2_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
|
||||
ATTR_HOT inline int matrix_solver_direct2_t::vsolve_non_dynamic(ATTR_UNUSED const bool newton_raphson)
|
||||
{
|
||||
build_LE_A();
|
||||
build_LE_RHS(m_RHS);
|
||||
|
@ -22,19 +22,19 @@
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_GMRES_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
class matrix_solver_GMRES_t: public matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_matrix_solver_GMRES_t(const netlist_solver_parameters_t *params, int size)
|
||||
: netlist_matrix_solver_direct_t<m_N, _storage_N>(netlist_matrix_solver_t::GAUSS_SEIDEL, params, size)
|
||||
matrix_solver_GMRES_t(const solver_parameters_t *params, int size)
|
||||
: matrix_solver_direct_t<m_N, _storage_N>(matrix_solver_t::GAUSS_SEIDEL, params, size)
|
||||
, m_gmres(m_N ? m_N : size)
|
||||
, m_gs_fail(0)
|
||||
, m_gs_total(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~netlist_matrix_solver_GMRES_t() {}
|
||||
virtual ~matrix_solver_GMRES_t() {}
|
||||
|
||||
virtual void log_stats();
|
||||
|
||||
@ -50,11 +50,11 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_GMRES_t<m_N, _storage_N>::log_stats()
|
||||
void matrix_solver_GMRES_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && this->m_params.m_log_stats)
|
||||
{
|
||||
@ -74,22 +74,22 @@ void netlist_matrix_solver_GMRES_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_GMRES_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
void matrix_solver_GMRES_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
{
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(nets);
|
||||
matrix_solver_direct_t<m_N, _storage_N>::vsetup(nets);
|
||||
this->save(NLNAME(m_gs_fail));
|
||||
this->save(NLNAME(m_gs_total));
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_GMRES_t<m_N, _storage_N>::vsolve()
|
||||
ATTR_HOT nl_double matrix_solver_GMRES_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
this->solve_base(this);
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT inline int netlist_matrix_solver_GMRES_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
ATTR_HOT inline int matrix_solver_GMRES_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
const int iN = this->N();
|
||||
|
||||
@ -164,18 +164,18 @@ ATTR_HOT inline int netlist_matrix_solver_GMRES_t<m_N, _storage_N>::vsolve_non_d
|
||||
|
||||
const nl_double accuracy = this->m_params.m_accuracy;
|
||||
|
||||
int gsl = m_gmres.pmgmres_ilu_cr(nz_num, ia, ja, a, new_V, RHS, 1, std::min(iN-1,20), accuracy * (double) (iN), 1e6);
|
||||
int gsl = m_gmres.pmgmres_ilu_cr(nz_num, ia, ja, a, new_V, RHS, 12, std::min(iN-1,10), accuracy * (double) (iN), 1e6);
|
||||
|
||||
m_gs_total += gsl;
|
||||
this->m_stat_calculations++;
|
||||
|
||||
if (gsl>=19)
|
||||
if (gsl>119)
|
||||
{
|
||||
for (int k = 0; k < iN; k++)
|
||||
this->m_nets[k]->m_cur_Analog = new_V[k];
|
||||
// Fallback to direct solver ...
|
||||
this->m_gs_fail++;
|
||||
return netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(newton_raphson);
|
||||
return matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(newton_raphson);
|
||||
}
|
||||
|
||||
if (newton_raphson)
|
||||
|
@ -20,19 +20,19 @@
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_SOR_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
class matrix_solver_SOR_t: public matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_matrix_solver_SOR_t(const netlist_solver_parameters_t *params, int size)
|
||||
: netlist_matrix_solver_direct_t<m_N, _storage_N>(netlist_matrix_solver_t::GAUSS_SEIDEL, params, size)
|
||||
matrix_solver_SOR_t(const solver_parameters_t *params, int size)
|
||||
: matrix_solver_direct_t<m_N, _storage_N>(matrix_solver_t::GAUSS_SEIDEL, params, size)
|
||||
, m_lp_fact(0)
|
||||
, m_gs_fail(0)
|
||||
, m_gs_total(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~netlist_matrix_solver_SOR_t() {}
|
||||
virtual ~matrix_solver_SOR_t() {}
|
||||
|
||||
virtual void log_stats();
|
||||
|
||||
@ -48,11 +48,11 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
void matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && this->m_params.m_log_stats)
|
||||
{
|
||||
@ -72,23 +72,23 @@ void netlist_matrix_solver_SOR_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
void matrix_solver_SOR_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
{
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(nets);
|
||||
matrix_solver_direct_t<m_N, _storage_N>::vsetup(nets);
|
||||
this->save(NLNAME(m_lp_fact));
|
||||
this->save(NLNAME(m_gs_fail));
|
||||
this->save(NLNAME(m_gs_total));
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve()
|
||||
ATTR_HOT nl_double matrix_solver_SOR_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
this->solve_base(this);
|
||||
return this->compute_next_timestep();
|
||||
}
|
||||
|
||||
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)
|
||||
ATTR_HOT inline int matrix_solver_SOR_t<m_N, _storage_N>::vsolve_non_dynamic(const bool newton_raphson)
|
||||
{
|
||||
const int iN = this->N();
|
||||
bool resched = false;
|
||||
@ -201,7 +201,7 @@ ATTR_HOT inline int netlist_matrix_solver_SOR_t<m_N, _storage_N>::vsolve_non_dyn
|
||||
{
|
||||
// Fallback to direct solver ...
|
||||
this->m_gs_fail++;
|
||||
return netlist_matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(newton_raphson);
|
||||
return matrix_solver_direct_t<m_N, _storage_N>::vsolve_non_dynamic(newton_raphson);
|
||||
}
|
||||
|
||||
if (interleaved_dynamic_updates)
|
||||
|
@ -20,12 +20,12 @@
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
class netlist_matrix_solver_SOR_mat_t: public netlist_matrix_solver_direct_t<m_N, _storage_N>
|
||||
class matrix_solver_SOR_mat_t: public matrix_solver_direct_t<m_N, _storage_N>
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_matrix_solver_SOR_mat_t(const netlist_solver_parameters_t *params, int size)
|
||||
: netlist_matrix_solver_direct_t<m_N, _storage_N>(netlist_matrix_solver_t::GAUSS_SEIDEL, params, size)
|
||||
matrix_solver_SOR_mat_t(const solver_parameters_t *params, int size)
|
||||
: matrix_solver_direct_t<m_N, _storage_N>(matrix_solver_t::GAUSS_SEIDEL, params, size)
|
||||
, m_omega(params->m_sor)
|
||||
, m_lp_fact(0)
|
||||
, m_gs_fail(0)
|
||||
@ -33,7 +33,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~netlist_matrix_solver_SOR_mat_t() {}
|
||||
virtual ~matrix_solver_SOR_mat_t() {}
|
||||
|
||||
virtual void log_stats();
|
||||
virtual void vsetup(analog_net_t::list_t &nets);
|
||||
@ -52,11 +52,11 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver - Gauss - Seidel
|
||||
// matrix_solver - Gauss - Seidel
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
void matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
{
|
||||
if (this->m_stat_calculations != 0 && this->m_params.m_log_stats)
|
||||
{
|
||||
@ -76,9 +76,9 @@ void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::log_stats()
|
||||
}
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
void matrix_solver_SOR_mat_t<m_N, _storage_N>::vsetup(analog_net_t::list_t &nets)
|
||||
{
|
||||
netlist_matrix_solver_direct_t<m_N, _storage_N>::vsetup(nets);
|
||||
matrix_solver_direct_t<m_N, _storage_N>::vsetup(nets);
|
||||
this->save(NLNAME(m_omega));
|
||||
this->save(NLNAME(m_lp_fact));
|
||||
this->save(NLNAME(m_gs_fail));
|
||||
@ -88,7 +88,7 @@ void netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsetup(analog_net_t::list
|
||||
|
||||
|
||||
template <unsigned m_N, unsigned _storage_N>
|
||||
ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
ATTR_HOT nl_double matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
{
|
||||
/*
|
||||
* enable linear prediction on first newton pass
|
||||
@ -134,7 +134,7 @@ ATTR_HOT nl_double netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve()
|
||||
}
|
||||
|
||||
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)
|
||||
ATTR_HOT inline int 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
|
||||
* the optimized code which works directly on the data structures.
|
||||
@ -227,7 +227,7 @@ ATTR_HOT inline int netlist_matrix_solver_SOR_mat_t<m_N, _storage_N>::vsolve_non
|
||||
this->m_gs_fail++;
|
||||
|
||||
this->LE_solve();
|
||||
return netlist_matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(newton_raphson);
|
||||
return matrix_solver_direct_t<m_N, _storage_N>::solve_non_dynamic(newton_raphson);
|
||||
}
|
||||
else {
|
||||
this->store(new_v);
|
||||
|
@ -43,8 +43,22 @@
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
ATTR_COLD void terms_t::add(terminal_t *term, int net_other)
|
||||
ATTR_COLD void terms_t::add(terminal_t *term, int net_other, bool sorted)
|
||||
{
|
||||
if (sorted)
|
||||
for (unsigned i=0; i < m_net_other.size(); i++)
|
||||
{
|
||||
if (m_net_other[i] > net_other)
|
||||
{
|
||||
m_term.insert_at(term, i);
|
||||
m_net_other.insert_at(net_other, i);
|
||||
m_gt.insert_at(0.0, i);
|
||||
m_go.insert_at(0.0, i);
|
||||
m_Idr.insert_at(0.0, i);
|
||||
m_other_curanalog.insert_at(NULL, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_term.add(term);
|
||||
m_net_other.add(net_other);
|
||||
m_gt.add(0.0);
|
||||
@ -65,10 +79,10 @@ ATTR_COLD void terms_t::set_pointers()
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver
|
||||
// matrix_solver
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD netlist_matrix_solver_t::netlist_matrix_solver_t(const eSolverType type, const netlist_solver_parameters_t *params)
|
||||
ATTR_COLD matrix_solver_t::matrix_solver_t(const eSolverType type, const solver_parameters_t *params)
|
||||
: m_stat_calculations(0),
|
||||
m_stat_newton_raphson(0),
|
||||
m_stat_vsolver_calls(0),
|
||||
@ -78,12 +92,12 @@ ATTR_COLD netlist_matrix_solver_t::netlist_matrix_solver_t(const eSolverType typ
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_matrix_solver_t::~netlist_matrix_solver_t()
|
||||
ATTR_COLD matrix_solver_t::~matrix_solver_t()
|
||||
{
|
||||
m_inps.clear_and_free();
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_matrix_solver_t::setup(analog_net_t::list_t &nets)
|
||||
ATTR_COLD void matrix_solver_t::setup(analog_net_t::list_t &nets)
|
||||
{
|
||||
NL_VERBOSE_OUT(("New solver setup\n"));
|
||||
|
||||
@ -117,7 +131,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(analog_net_t::list_t &nets)
|
||||
break;
|
||||
case device_t::BJT_EB:
|
||||
case device_t::DIODE:
|
||||
//case netlist_device_t::VCVS:
|
||||
//case device_t::VCVS:
|
||||
case device_t::BJT_SWITCH:
|
||||
NL_VERBOSE_OUT(("found BJT/Diode\n"));
|
||||
if (!m_dynamic_devices.contains(&p->netdev()))
|
||||
@ -134,7 +148,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(analog_net_t::list_t &nets)
|
||||
break;
|
||||
case terminal_t::INPUT:
|
||||
{
|
||||
netlist_analog_output_t *net_proxy_output = NULL;
|
||||
analog_output_t *net_proxy_output = NULL;
|
||||
for (std::size_t i = 0; i < m_inps.size(); i++)
|
||||
if (m_inps[i]->m_proxied_net == &p->net().as_analog())
|
||||
{
|
||||
@ -144,7 +158,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(analog_net_t::list_t &nets)
|
||||
|
||||
if (net_proxy_output == NULL)
|
||||
{
|
||||
net_proxy_output = palloc(netlist_analog_output_t);
|
||||
net_proxy_output = palloc(analog_output_t);
|
||||
net_proxy_output->init_object(*this, this->name() + "." + pstring::sprintf("m%" SIZETFMT, m_inps.size()));
|
||||
m_inps.add(net_proxy_output);
|
||||
net_proxy_output->m_proxied_net = &p->net().as_analog();
|
||||
@ -165,7 +179,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(analog_net_t::list_t &nets)
|
||||
}
|
||||
|
||||
|
||||
ATTR_HOT void netlist_matrix_solver_t::update_inputs()
|
||||
ATTR_HOT void matrix_solver_t::update_inputs()
|
||||
{
|
||||
// avoid recursive calls. Inputs are updated outside this call
|
||||
for (std::size_t i=0; i<m_inps.size(); i++)
|
||||
@ -173,14 +187,14 @@ ATTR_HOT void netlist_matrix_solver_t::update_inputs()
|
||||
|
||||
}
|
||||
|
||||
ATTR_HOT void netlist_matrix_solver_t::update_dynamic()
|
||||
ATTR_HOT void matrix_solver_t::update_dynamic()
|
||||
{
|
||||
/* update all non-linear devices */
|
||||
for (std::size_t i=0; i < m_dynamic_devices.size(); i++)
|
||||
m_dynamic_devices[i]->update_terminals();
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_matrix_solver_t::start()
|
||||
ATTR_COLD void matrix_solver_t::start()
|
||||
{
|
||||
register_output("Q_sync", m_Q_sync);
|
||||
register_input("FB_sync", m_fb_sync);
|
||||
@ -191,12 +205,12 @@ ATTR_COLD void netlist_matrix_solver_t::start()
|
||||
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_matrix_solver_t::reset()
|
||||
ATTR_COLD void matrix_solver_t::reset()
|
||||
{
|
||||
m_last_step = netlist_time::zero;
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_matrix_solver_t::update()
|
||||
ATTR_COLD void matrix_solver_t::update()
|
||||
{
|
||||
const nl_double new_timestep = solve();
|
||||
|
||||
@ -204,7 +218,7 @@ ATTR_COLD void netlist_matrix_solver_t::update()
|
||||
m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(new_timestep));
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_matrix_solver_t::update_forced()
|
||||
ATTR_COLD void matrix_solver_t::update_forced()
|
||||
{
|
||||
ATTR_UNUSED const nl_double new_timestep = solve();
|
||||
|
||||
@ -212,7 +226,7 @@ ATTR_COLD void netlist_matrix_solver_t::update_forced()
|
||||
m_Q_sync.net().reschedule_in_queue(netlist_time::from_double(m_params.m_min_timestep));
|
||||
}
|
||||
|
||||
ATTR_HOT void netlist_matrix_solver_t::step(const netlist_time delta)
|
||||
ATTR_HOT void matrix_solver_t::step(const netlist_time delta)
|
||||
{
|
||||
const nl_double dd = delta.as_double();
|
||||
for (std::size_t k=0; k < m_step_devices.size(); k++)
|
||||
@ -220,7 +234,7 @@ ATTR_HOT void netlist_matrix_solver_t::step(const netlist_time delta)
|
||||
}
|
||||
|
||||
template<class C >
|
||||
void netlist_matrix_solver_t::solve_base(C *p)
|
||||
void matrix_solver_t::solve_base(C *p)
|
||||
{
|
||||
m_stat_vsolver_calls++;
|
||||
if (is_dynamic())
|
||||
@ -249,7 +263,7 @@ void netlist_matrix_solver_t::solve_base(C *p)
|
||||
}
|
||||
}
|
||||
|
||||
ATTR_HOT nl_double netlist_matrix_solver_t::solve()
|
||||
ATTR_HOT nl_double matrix_solver_t::solve()
|
||||
{
|
||||
netlist_time now = netlist().time();
|
||||
netlist_time delta = now - m_last_step;
|
||||
@ -273,10 +287,10 @@ ATTR_HOT nl_double netlist_matrix_solver_t::solve()
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_matrix_solver - Direct base
|
||||
// matrix_solver - Direct base
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD int netlist_matrix_solver_t::get_net_idx(net_t *net)
|
||||
ATTR_COLD int matrix_solver_t::get_net_idx(net_t *net)
|
||||
{
|
||||
for (std::size_t k = 0; k < m_nets.size(); k++)
|
||||
if (m_nets[k] == net)
|
||||
@ -333,7 +347,7 @@ NETLIB_RESET(solver)
|
||||
|
||||
NETLIB_UPDATE_PARAM(solver)
|
||||
{
|
||||
//m_inc = netlist_time::from_hz(m_freq.Value());
|
||||
//m_inc = time::from_hz(m_freq.Value());
|
||||
}
|
||||
|
||||
NETLIB_STOP(solver)
|
||||
@ -396,31 +410,31 @@ NETLIB_UPDATE(solver)
|
||||
}
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
netlist_matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const int gs_threshold, const bool use_specific)
|
||||
matrix_solver_t * NETLIB_NAME(solver)::create_solver(int size, const int gs_threshold, const bool use_specific)
|
||||
{
|
||||
if (use_specific && m_N == 1)
|
||||
return palloc(netlist_matrix_solver_direct1_t, &m_params);
|
||||
return palloc(matrix_solver_direct1_t, &m_params);
|
||||
else if (use_specific && m_N == 2)
|
||||
return palloc(netlist_matrix_solver_direct2_t, &m_params);
|
||||
return palloc(matrix_solver_direct2_t, &m_params);
|
||||
else
|
||||
{
|
||||
if (size >= gs_threshold)
|
||||
{
|
||||
if (USE_MATRIX_GS)
|
||||
{
|
||||
typedef netlist_matrix_solver_SOR_mat_t<m_N,_storage_N> solver_mat;
|
||||
typedef matrix_solver_SOR_mat_t<m_N,_storage_N> solver_mat;
|
||||
return palloc(solver_mat, &m_params, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef netlist_matrix_solver_SOR_t<m_N,_storage_N> solver_GS;
|
||||
//typedef netlist_matrix_solver_GMRES_t<m_N,_storage_N> solver_GS;
|
||||
typedef matrix_solver_SOR_t<m_N,_storage_N> solver_GS;
|
||||
//typedef matrix_solver_GMRES_t<m_N,_storage_N> solver_GS;
|
||||
return palloc(solver_GS, &m_params, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef netlist_matrix_solver_direct_t<m_N,_storage_N> solver_D;
|
||||
typedef matrix_solver_direct_t<m_N,_storage_N> solver_D;
|
||||
return palloc(solver_D, &m_params, size);
|
||||
}
|
||||
}
|
||||
@ -481,7 +495,7 @@ ATTR_COLD void NETLIB_NAME(solver)::post_start()
|
||||
netlist().log("Found %d net groups in %" SIZETFMT " nets\n", cur_group + 1, netlist().m_nets.size());
|
||||
for (int i = 0; i <= cur_group; i++)
|
||||
{
|
||||
netlist_matrix_solver_t *ms;
|
||||
matrix_solver_t *ms;
|
||||
std::size_t net_count = groups[i].size();
|
||||
|
||||
switch (net_count)
|
||||
|
@ -35,7 +35,7 @@ class NETLIB_NAME(solver);
|
||||
|
||||
/* FIXME: these should become proper devices */
|
||||
|
||||
struct netlist_solver_parameters_t
|
||||
struct solver_parameters_t
|
||||
{
|
||||
nl_double m_accuracy;
|
||||
nl_double m_lte;
|
||||
@ -68,7 +68,7 @@ class terms_t
|
||||
m_other_curanalog.clear();
|
||||
}
|
||||
|
||||
ATTR_COLD void add(terminal_t *term, int net_other);
|
||||
ATTR_COLD void add(terminal_t *term, int net_other, bool sorted);
|
||||
|
||||
ATTR_HOT inline unsigned count() { return m_term.size(); }
|
||||
|
||||
@ -94,10 +94,10 @@ private:
|
||||
plist_t<nl_double *> m_other_curanalog;
|
||||
};
|
||||
|
||||
class netlist_matrix_solver_t : public device_t
|
||||
class matrix_solver_t : public device_t
|
||||
{
|
||||
public:
|
||||
typedef plist_t<netlist_matrix_solver_t *> list_t;
|
||||
typedef plist_t<matrix_solver_t *> list_t;
|
||||
typedef core_device_t::list_t dev_list_t;
|
||||
|
||||
enum eSolverType
|
||||
@ -106,8 +106,8 @@ public:
|
||||
GAUSS_SEIDEL
|
||||
};
|
||||
|
||||
ATTR_COLD netlist_matrix_solver_t(const eSolverType type, const netlist_solver_parameters_t *params);
|
||||
virtual ~netlist_matrix_solver_t();
|
||||
ATTR_COLD matrix_solver_t(const eSolverType type, const solver_parameters_t *params);
|
||||
virtual ~matrix_solver_t();
|
||||
|
||||
virtual void vsetup(analog_net_t::list_t &nets) = 0;
|
||||
|
||||
@ -146,13 +146,13 @@ protected:
|
||||
virtual void add_term(int net_idx, terminal_t *term) = 0;
|
||||
|
||||
plist_t<analog_net_t *> m_nets;
|
||||
plist_t<netlist_analog_output_t *> m_inps;
|
||||
plist_t<analog_output_t *> m_inps;
|
||||
|
||||
int m_stat_calculations;
|
||||
int m_stat_newton_raphson;
|
||||
int m_stat_vsolver_calls;
|
||||
|
||||
const netlist_solver_parameters_t &m_params;
|
||||
const solver_parameters_t &m_params;
|
||||
|
||||
ATTR_HOT inline nl_double current_timestep() { return m_cur_ts; }
|
||||
private:
|
||||
@ -196,29 +196,29 @@ protected:
|
||||
logic_input_t m_fb_step;
|
||||
logic_output_t m_Q_step;
|
||||
|
||||
netlist_param_double_t m_freq;
|
||||
netlist_param_double_t m_sync_delay;
|
||||
netlist_param_double_t m_accuracy;
|
||||
netlist_param_double_t m_gmin;
|
||||
netlist_param_double_t m_lte;
|
||||
netlist_param_double_t m_sor;
|
||||
netlist_param_logic_t m_dynamic;
|
||||
netlist_param_double_t m_min_timestep;
|
||||
param_double_t m_freq;
|
||||
param_double_t m_sync_delay;
|
||||
param_double_t m_accuracy;
|
||||
param_double_t m_gmin;
|
||||
param_double_t m_lte;
|
||||
param_double_t m_sor;
|
||||
param_logic_t m_dynamic;
|
||||
param_double_t m_min_timestep;
|
||||
|
||||
netlist_param_int_t m_nr_loops;
|
||||
netlist_param_int_t m_gs_loops;
|
||||
netlist_param_int_t m_gs_threshold;
|
||||
netlist_param_int_t m_parallel;
|
||||
param_int_t m_nr_loops;
|
||||
param_int_t m_gs_loops;
|
||||
param_int_t m_gs_threshold;
|
||||
param_int_t m_parallel;
|
||||
|
||||
netlist_param_logic_t m_log_stats;
|
||||
param_logic_t m_log_stats;
|
||||
|
||||
netlist_matrix_solver_t::list_t m_mat_solvers;
|
||||
matrix_solver_t::list_t m_mat_solvers;
|
||||
private:
|
||||
|
||||
netlist_solver_parameters_t m_params;
|
||||
solver_parameters_t m_params;
|
||||
|
||||
template <int m_N, int _storage_N>
|
||||
netlist_matrix_solver_t *create_solver(int size, int gs_threshold, bool use_specific);
|
||||
matrix_solver_t *create_solver(int size, int gs_threshold, bool use_specific);
|
||||
};
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_END()
|
||||
|
@ -32,13 +32,13 @@ NETLIB_NAMESPACE_DEVICES_START()
|
||||
NETLIB_DEVICE_WITH_PARAMS(switch1,
|
||||
NETLIB_NAME(R_base) m_R;
|
||||
|
||||
netlist_param_int_t m_POS;
|
||||
param_int_t m_POS;
|
||||
);
|
||||
|
||||
NETLIB_DEVICE_WITH_PARAMS(switch2,
|
||||
NETLIB_NAME(R_base) m_R[2];
|
||||
|
||||
netlist_param_int_t m_POS;
|
||||
param_int_t m_POS;
|
||||
);
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_END()
|
||||
|
@ -13,16 +13,16 @@
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_generic_diode
|
||||
// generic_diode
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD netlist_generic_diode::netlist_generic_diode()
|
||||
ATTR_COLD generic_diode::generic_diode()
|
||||
{
|
||||
m_Vd = 0.7;
|
||||
set_param(1e-15, 1, 1e-15);
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_generic_diode::set_param(const nl_double Is, const nl_double n, nl_double gmin)
|
||||
ATTR_COLD void generic_diode::set_param(const nl_double Is, const nl_double n, nl_double gmin)
|
||||
{
|
||||
static const double csqrt2 = nl_math::sqrt(2.0);
|
||||
m_Is = Is;
|
||||
@ -35,7 +35,7 @@ ATTR_COLD void netlist_generic_diode::set_param(const nl_double Is, const nl_dou
|
||||
m_VtInv = 1.0 / m_Vt;
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_generic_diode::save(pstring name, object_t &parent)
|
||||
ATTR_COLD void generic_diode::save(pstring name, object_t &parent)
|
||||
{
|
||||
parent.save(m_Vd, name + ".m_Vd");
|
||||
parent.save(m_Id, name + ".m_Id");
|
||||
|
@ -152,7 +152,7 @@ protected:
|
||||
};
|
||||
|
||||
NETLIB_DEVICE_WITH_PARAMS_DERIVED(R, R_base,
|
||||
netlist_param_double_t m_R;
|
||||
param_double_t m_R;
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -163,18 +163,18 @@ NETLIB_DEVICE_WITH_PARAMS(POT,
|
||||
NETLIB_NAME(R_base) m_R1;
|
||||
NETLIB_NAME(R_base) m_R2;
|
||||
|
||||
netlist_param_double_t m_R;
|
||||
netlist_param_double_t m_Dial;
|
||||
netlist_param_logic_t m_DialIsLog;
|
||||
param_double_t m_R;
|
||||
param_double_t m_Dial;
|
||||
param_logic_t m_DialIsLog;
|
||||
);
|
||||
|
||||
NETLIB_DEVICE_WITH_PARAMS(POT2,
|
||||
NETLIB_NAME(R_base) m_R1;
|
||||
|
||||
netlist_param_double_t m_R;
|
||||
netlist_param_double_t m_Dial;
|
||||
netlist_param_logic_t m_DialIsLog;
|
||||
netlist_param_logic_t m_Reverse;
|
||||
param_double_t m_R;
|
||||
param_double_t m_Dial;
|
||||
param_logic_t m_DialIsLog;
|
||||
param_logic_t m_Reverse;
|
||||
);
|
||||
|
||||
|
||||
@ -200,7 +200,7 @@ protected:
|
||||
virtual void update_param();
|
||||
ATTR_HOT void update();
|
||||
|
||||
netlist_param_double_t m_C;
|
||||
param_double_t m_C;
|
||||
|
||||
};
|
||||
|
||||
@ -209,10 +209,10 @@ protected:
|
||||
// A generic diode model to be used in other devices (Diode, BJT ...)
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_generic_diode
|
||||
class generic_diode
|
||||
{
|
||||
public:
|
||||
ATTR_COLD netlist_generic_diode();
|
||||
ATTR_COLD generic_diode();
|
||||
|
||||
ATTR_HOT inline void update_diode(const nl_double nVd)
|
||||
{
|
||||
@ -288,9 +288,9 @@ protected:
|
||||
virtual void update_param();
|
||||
ATTR_HOT void update();
|
||||
|
||||
netlist_param_model_t m_model;
|
||||
param_model_t m_model;
|
||||
|
||||
netlist_generic_diode m_D;
|
||||
generic_diode m_D;
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
UINT8 m_state;
|
||||
double m_KP;
|
||||
|
||||
netlist_param_double_t m_K;
|
||||
netlist_param_double_t m_RI;
|
||||
param_double_t m_K;
|
||||
param_double_t m_RI;
|
||||
|
||||
int m_dev_type;
|
||||
);
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
analog_input_t m_RNG;
|
||||
analog_input_t m_FC;
|
||||
|
||||
netlist_param_double_t m_CAP;
|
||||
param_double_t m_CAP;
|
||||
);
|
||||
|
||||
#define SN74LS629_DIP(_name, _cap1, _cap2) \
|
||||
|
@ -45,8 +45,8 @@ NETLIB_DEVICE_WITH_PARAMS(nicDelay,
|
||||
|
||||
logic_output_t m_Q;
|
||||
|
||||
netlist_param_int_t m_L_to_H;
|
||||
netlist_param_int_t m_H_to_L;
|
||||
param_int_t m_L_to_H;
|
||||
param_int_t m_H_to_L;
|
||||
|
||||
UINT8 m_last;
|
||||
);
|
||||
|
@ -36,7 +36,7 @@ NETLIB_DEVICE(NE555,
|
||||
logic_input_t m_RESET;
|
||||
analog_input_t m_THRES;
|
||||
analog_input_t m_TRIG;
|
||||
netlist_analog_output_t m_OUT;
|
||||
analog_output_t m_OUT;
|
||||
|
||||
bool m_last_out;
|
||||
bool m_ff;
|
||||
|
@ -58,10 +58,10 @@
|
||||
NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
NETLIB_DEVICE_WITH_PARAMS_DERIVED(r2r_dac, twoterm,
|
||||
netlist_param_double_t m_VIN;
|
||||
netlist_param_double_t m_R;
|
||||
netlist_param_int_t m_num;
|
||||
netlist_param_int_t m_val;
|
||||
param_double_t m_VIN;
|
||||
param_double_t m_R;
|
||||
param_int_t m_num;
|
||||
param_int_t m_val;
|
||||
);
|
||||
|
||||
NETLIB_NAMESPACE_DEVICES_END()
|
||||
|
@ -72,7 +72,7 @@ NETLIB_NAMESPACE_DEVICES_START()
|
||||
|
||||
NETLIB_DEVICE_WITH_PARAMS(netlistparams,
|
||||
public:
|
||||
netlist_param_logic_t m_use_deactivate;
|
||||
param_logic_t m_use_deactivate;
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -83,7 +83,7 @@ NETLIB_DEVICE_WITH_PARAMS(mainclock,
|
||||
public:
|
||||
logic_output_t m_Q;
|
||||
|
||||
netlist_param_double_t m_freq;
|
||||
param_double_t m_freq;
|
||||
netlist_time m_inc;
|
||||
|
||||
ATTR_HOT inline static void mc_update(logic_net_t &net);
|
||||
@ -97,7 +97,7 @@ NETLIB_DEVICE_WITH_PARAMS(clock,
|
||||
logic_input_t m_feedback;
|
||||
logic_output_t m_Q;
|
||||
|
||||
netlist_param_double_t m_freq;
|
||||
param_double_t m_freq;
|
||||
netlist_time m_inc;
|
||||
);
|
||||
|
||||
@ -109,9 +109,9 @@ NETLIB_DEVICE_WITH_PARAMS(extclock,
|
||||
logic_input_t m_feedback;
|
||||
logic_output_t m_Q;
|
||||
|
||||
netlist_param_double_t m_freq;
|
||||
netlist_param_str_t m_pattern;
|
||||
netlist_param_double_t m_offset;
|
||||
param_double_t m_freq;
|
||||
param_str_t m_pattern;
|
||||
param_double_t m_offset;
|
||||
|
||||
UINT8 m_cnt;
|
||||
UINT8 m_size;
|
||||
@ -126,13 +126,13 @@ NETLIB_DEVICE_WITH_PARAMS(extclock,
|
||||
NETLIB_DEVICE_WITH_PARAMS(ttl_input,
|
||||
logic_output_t m_Q;
|
||||
|
||||
netlist_param_logic_t m_IN;
|
||||
param_logic_t m_IN;
|
||||
);
|
||||
|
||||
NETLIB_DEVICE_WITH_PARAMS(analog_input,
|
||||
netlist_analog_output_t m_Q;
|
||||
analog_output_t m_Q;
|
||||
|
||||
netlist_param_double_t m_IN;
|
||||
param_double_t m_IN;
|
||||
);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -164,7 +164,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
netlist_analog_output_t m_Q;
|
||||
analog_output_t m_Q;
|
||||
|
||||
};
|
||||
|
||||
@ -245,10 +245,10 @@ private:
|
||||
NETLIB_NAME(twoterm) m_RIN;
|
||||
NETLIB_NAME(twoterm) m_ROUT;
|
||||
analog_input_t m_I;
|
||||
netlist_analog_output_t m_Q;
|
||||
analog_output_t m_Q;
|
||||
|
||||
netlist_param_double_t m_p_RIN;
|
||||
netlist_param_double_t m_p_ROUT;
|
||||
param_double_t m_p_RIN;
|
||||
param_double_t m_p_ROUT;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -263,8 +263,8 @@ public:
|
||||
|
||||
virtual ~NETLIB_NAME(res_sw)() {}
|
||||
|
||||
netlist_param_double_t m_RON;
|
||||
netlist_param_double_t m_ROFF;
|
||||
param_double_t m_RON;
|
||||
param_double_t m_ROFF;
|
||||
logic_input_t m_I;
|
||||
NETLIB_NAME(R) m_R;
|
||||
|
||||
@ -402,7 +402,7 @@ protected:
|
||||
ATTR_HOT void update();
|
||||
|
||||
private:
|
||||
netlist_analog_output_t m_Q;
|
||||
analog_output_t m_Q;
|
||||
nld_twoterm m_RV;
|
||||
int m_last_state;
|
||||
bool m_is_timestep;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "analog/nld_solver.h"
|
||||
#include "nl_util.h"
|
||||
|
||||
const netlist_time netlist_time::zero = netlist_time::from_raw(0);
|
||||
const netlist::netlist_time netlist::netlist_time::zero = netlist::netlist_time::from_raw(0);
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
@ -40,13 +40,13 @@ fatalerror_e::fatalerror_e(const char *format, va_list ap)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_logic_family_ttl_t
|
||||
// logic_family_ttl_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class netlist_logic_family_ttl_t : public logic_family_desc_t
|
||||
class logic_family_ttl_t : public logic_family_desc_t
|
||||
{
|
||||
public:
|
||||
netlist_logic_family_ttl_t()
|
||||
logic_family_ttl_t()
|
||||
{
|
||||
m_low_thresh_V = 0.8;
|
||||
m_high_thresh_V = 2.0;
|
||||
@ -63,10 +63,10 @@ public:
|
||||
};
|
||||
|
||||
//FIXME: set to proper values
|
||||
class netlist_logic_family_cd4000_t : public logic_family_desc_t
|
||||
class logic_family_cd4000_t : public logic_family_desc_t
|
||||
{
|
||||
public:
|
||||
netlist_logic_family_cd4000_t()
|
||||
logic_family_cd4000_t()
|
||||
{
|
||||
m_low_thresh_V = 0.8;
|
||||
m_high_thresh_V = 2.0;
|
||||
@ -82,15 +82,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
const logic_family_desc_t &netlist_family_TTL = netlist_logic_family_ttl_t();
|
||||
const logic_family_desc_t &netlist_family_CD4000 = netlist_logic_family_cd4000_t();
|
||||
const logic_family_desc_t &netlist_family_TTL = logic_family_ttl_t();
|
||||
const logic_family_desc_t &netlist_family_CD4000 = logic_family_cd4000_t();
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_queue_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
queue_t::queue_t(netlist_t &nl)
|
||||
: netlist_timed_queue<net_t *, netlist_time>(512)
|
||||
: timed_queue<net_t *, netlist_time>(512)
|
||||
, object_t(QUEUE, GENERIC)
|
||||
, pstate_callback_t()
|
||||
, m_qsize(0)
|
||||
@ -492,7 +492,7 @@ device_t::~device_t()
|
||||
//NL_VERBOSE_OUT(("~net_device_t\n");
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_setup_t &device_t::setup()
|
||||
ATTR_COLD setup_t &device_t::setup()
|
||||
{
|
||||
return netlist().setup();
|
||||
}
|
||||
@ -535,7 +535,7 @@ ATTR_COLD void device_t::register_output(const pstring &name, logic_output_t &po
|
||||
setup().register_object(*this, name, port);
|
||||
}
|
||||
|
||||
ATTR_COLD void device_t::register_output(const pstring &name, netlist_analog_output_t &port)
|
||||
ATTR_COLD void device_t::register_output(const pstring &name, analog_output_t &port)
|
||||
{
|
||||
//port.set_logic_family(this->logic_family());
|
||||
setup().register_object(*this, name, port);
|
||||
@ -572,13 +572,13 @@ ATTR_COLD void device_t::register_param(const pstring &sname, C ¶m, const T
|
||||
setup().register_object(*this, fullname, param);
|
||||
}
|
||||
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_double_t ¶m, const double initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_double_t ¶m, const float initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_int_t ¶m, const int initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_logic_t ¶m, const int initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_str_t ¶m, const char * const initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_str_t ¶m, const pstring &initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, netlist_param_model_t ¶m, const char * const initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_double_t ¶m, const double initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_double_t ¶m, const float initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_int_t ¶m, const int initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_logic_t ¶m, const int initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_str_t ¶m, const char * const initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_str_t ¶m, const pstring &initialVal);
|
||||
template ATTR_COLD void device_t::register_param(const pstring &sname, param_model_t ¶m, const char * const initialVal);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -981,7 +981,7 @@ ATTR_COLD void logic_output_t::initial(const netlist_sig_t val)
|
||||
// netlist_analog_output_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD netlist_analog_output_t::netlist_analog_output_t()
|
||||
ATTR_COLD analog_output_t::analog_output_t()
|
||||
: netlist_analog_t(OUTPUT), m_proxied_net(NULL)
|
||||
{
|
||||
this->set_net(m_my_net);
|
||||
@ -990,14 +990,14 @@ ATTR_COLD netlist_analog_output_t::netlist_analog_output_t()
|
||||
net().as_analog().m_cur_Analog = 0.98;
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_analog_output_t::init_object(core_device_t &dev, const pstring &aname)
|
||||
ATTR_COLD void analog_output_t::init_object(core_device_t &dev, const pstring &aname)
|
||||
{
|
||||
core_terminal_t::init_object(dev, aname);
|
||||
net().init_object(dev.netlist(), aname + ".net");
|
||||
net().register_railterminal(*this);
|
||||
}
|
||||
|
||||
ATTR_COLD void netlist_analog_output_t::initial(const nl_double val)
|
||||
ATTR_COLD void analog_output_t::initial(const nl_double val)
|
||||
{
|
||||
// FIXME: Really necessary?
|
||||
net().as_analog().m_cur_Analog = val * NL_FCONST(0.99);
|
||||
@ -1007,42 +1007,42 @@ ATTR_COLD void netlist_analog_output_t::initial(const nl_double val)
|
||||
// netlist_param_t & friends
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD netlist_param_t::netlist_param_t(const param_type_t atype)
|
||||
ATTR_COLD param_t::param_t(const param_type_t atype)
|
||||
: owned_object_t(PARAM, ANALOG)
|
||||
, m_param_type(atype)
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_param_double_t::netlist_param_double_t()
|
||||
: netlist_param_t(DOUBLE)
|
||||
ATTR_COLD param_double_t::param_double_t()
|
||||
: param_t(DOUBLE)
|
||||
, m_param(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_param_int_t::netlist_param_int_t()
|
||||
: netlist_param_t(INTEGER)
|
||||
ATTR_COLD param_int_t::param_int_t()
|
||||
: param_t(INTEGER)
|
||||
, m_param(0)
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_param_logic_t::netlist_param_logic_t()
|
||||
: netlist_param_int_t()
|
||||
ATTR_COLD param_logic_t::param_logic_t()
|
||||
: param_int_t()
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_param_str_t::netlist_param_str_t()
|
||||
: netlist_param_t(STRING)
|
||||
ATTR_COLD param_str_t::param_str_t()
|
||||
: param_t(STRING)
|
||||
, m_param("")
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD netlist_param_model_t::netlist_param_model_t()
|
||||
: netlist_param_t(MODEL)
|
||||
ATTR_COLD param_model_t::param_model_t()
|
||||
: param_t(MODEL)
|
||||
, m_param("")
|
||||
{
|
||||
}
|
||||
|
||||
ATTR_COLD const pstring netlist_param_model_t::model_type() const
|
||||
ATTR_COLD const pstring param_model_t::model_type() const
|
||||
{
|
||||
pstring tmp = this->Value();
|
||||
// .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)
|
||||
@ -1055,7 +1055,7 @@ ATTR_COLD const pstring netlist_param_model_t::model_type() const
|
||||
}
|
||||
|
||||
|
||||
ATTR_COLD nl_double netlist_param_model_t::model_value(const pstring &entity, const nl_double defval) const
|
||||
ATTR_COLD nl_double param_model_t::model_value(const pstring &entity, const nl_double defval) const
|
||||
{
|
||||
pstring tmp = this->Value();
|
||||
// .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)
|
||||
|
@ -164,9 +164,7 @@
|
||||
// Type definitions
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
//typedef UINT8 netlist_sig_t;
|
||||
|
||||
#define netlist_sig_t UINT8
|
||||
typedef UINT8 netlist_sig_t;
|
||||
|
||||
//============================================================
|
||||
// MACROS / netlist devices
|
||||
@ -274,7 +272,7 @@ namespace netlist
|
||||
{
|
||||
namespace devices
|
||||
{
|
||||
class netlist_matrix_solver_t;
|
||||
class matrix_solver_t;
|
||||
class NETLIB_NAME(gnd);
|
||||
class NETLIB_NAME(solver);
|
||||
class NETLIB_NAME(mainclock);
|
||||
@ -303,7 +301,7 @@ namespace netlist
|
||||
class analog_net_t;
|
||||
class logic_net_t;
|
||||
class net_t;
|
||||
class netlist_setup_t;
|
||||
class setup_t;
|
||||
class netlist_t;
|
||||
class core_device_t;
|
||||
|
||||
@ -810,7 +808,7 @@ namespace netlist
|
||||
return m_cur_Analog;
|
||||
}
|
||||
|
||||
ATTR_HOT devices::netlist_matrix_solver_t *solver() { return m_solver; }
|
||||
ATTR_HOT devices::matrix_solver_t *solver() { return m_solver; }
|
||||
|
||||
ATTR_COLD bool already_processed(list_t *groups, int cur_group);
|
||||
ATTR_COLD void process_net(list_t *groups, int &cur_group);
|
||||
@ -828,7 +826,7 @@ namespace netlist
|
||||
nl_double m_h_n_m_1;
|
||||
|
||||
//FIXME: needed by current solver code
|
||||
devices::netlist_matrix_solver_t *m_solver;
|
||||
devices::matrix_solver_t *m_solver;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -859,12 +857,12 @@ namespace netlist
|
||||
logic_net_t m_my_net;
|
||||
};
|
||||
|
||||
class netlist_analog_output_t : public netlist_analog_t
|
||||
class analog_output_t : public netlist_analog_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_analog_output_t)
|
||||
NETLIST_PREVENT_COPYING(analog_output_t)
|
||||
public:
|
||||
|
||||
ATTR_COLD netlist_analog_output_t();
|
||||
ATTR_COLD analog_output_t();
|
||||
|
||||
ATTR_COLD void init_object(core_device_t &dev, const pstring &aname);
|
||||
virtual void reset()
|
||||
@ -886,9 +884,9 @@ namespace netlist
|
||||
// net_param_t
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class netlist_param_t : public owned_object_t
|
||||
class param_t : public owned_object_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_param_t)
|
||||
NETLIST_PREVENT_COPYING(param_t)
|
||||
public:
|
||||
|
||||
enum param_type_t {
|
||||
@ -899,7 +897,7 @@ namespace netlist
|
||||
LOGIC
|
||||
};
|
||||
|
||||
ATTR_COLD netlist_param_t(const param_type_t atype);
|
||||
ATTR_COLD param_t(const param_type_t atype);
|
||||
|
||||
ATTR_HOT param_type_t param_type() const { return m_param_type; }
|
||||
|
||||
@ -911,11 +909,11 @@ namespace netlist
|
||||
const param_type_t m_param_type;
|
||||
};
|
||||
|
||||
class netlist_param_double_t : public netlist_param_t
|
||||
class param_double_t : public param_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_param_double_t)
|
||||
NETLIST_PREVENT_COPYING(param_double_t)
|
||||
public:
|
||||
ATTR_COLD netlist_param_double_t();
|
||||
ATTR_COLD param_double_t();
|
||||
|
||||
ATTR_HOT void setTo(const nl_double param);
|
||||
ATTR_COLD void initial(const nl_double val) { m_param = val; }
|
||||
@ -925,18 +923,18 @@ namespace netlist
|
||||
virtual void save_register()
|
||||
{
|
||||
save(NLNAME(m_param));
|
||||
netlist_param_t::save_register();
|
||||
param_t::save_register();
|
||||
}
|
||||
|
||||
private:
|
||||
nl_double m_param;
|
||||
};
|
||||
|
||||
class netlist_param_int_t : public netlist_param_t
|
||||
class param_int_t : public param_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_param_int_t)
|
||||
NETLIST_PREVENT_COPYING(param_int_t)
|
||||
public:
|
||||
ATTR_COLD netlist_param_int_t();
|
||||
ATTR_COLD param_int_t();
|
||||
|
||||
ATTR_HOT void setTo(const int param);
|
||||
ATTR_COLD void initial(const int val) { m_param = val; }
|
||||
@ -947,25 +945,25 @@ namespace netlist
|
||||
virtual void save_register()
|
||||
{
|
||||
save(NLNAME(m_param));
|
||||
netlist_param_t::save_register();
|
||||
param_t::save_register();
|
||||
}
|
||||
|
||||
private:
|
||||
int m_param;
|
||||
};
|
||||
|
||||
class netlist_param_logic_t : public netlist_param_int_t
|
||||
class param_logic_t : public param_int_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_param_logic_t)
|
||||
NETLIST_PREVENT_COPYING(param_logic_t)
|
||||
public:
|
||||
ATTR_COLD netlist_param_logic_t();
|
||||
ATTR_COLD param_logic_t();
|
||||
};
|
||||
|
||||
class netlist_param_str_t : public netlist_param_t
|
||||
class param_str_t : public param_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_param_str_t)
|
||||
NETLIST_PREVENT_COPYING(param_str_t)
|
||||
public:
|
||||
ATTR_COLD netlist_param_str_t();
|
||||
ATTR_COLD param_str_t();
|
||||
|
||||
ATTR_HOT void setTo(const pstring ¶m);
|
||||
ATTR_COLD void initial(const pstring &val) { m_param = val; }
|
||||
@ -976,11 +974,11 @@ namespace netlist
|
||||
pstring m_param;
|
||||
};
|
||||
|
||||
class netlist_param_model_t : public netlist_param_t
|
||||
class param_model_t : public param_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_param_model_t)
|
||||
NETLIST_PREVENT_COPYING(param_model_t)
|
||||
public:
|
||||
ATTR_COLD netlist_param_model_t();
|
||||
ATTR_COLD param_model_t();
|
||||
|
||||
ATTR_COLD void initial(const pstring &val) { m_param = val; }
|
||||
|
||||
@ -1047,7 +1045,7 @@ namespace netlist
|
||||
|
||||
ATTR_HOT nl_double TERMANALOG(const terminal_t &term) const { return term.net().as_analog().Q_Analog(); }
|
||||
|
||||
ATTR_HOT void OUTANALOG(netlist_analog_output_t &out, const nl_double val)
|
||||
ATTR_HOT void OUTANALOG(analog_output_t &out, const nl_double val)
|
||||
{
|
||||
out.set_Q(val);
|
||||
}
|
||||
@ -1102,12 +1100,12 @@ namespace netlist
|
||||
|
||||
virtual void init(netlist_t &anetlist, const pstring &name);
|
||||
|
||||
ATTR_COLD netlist_setup_t &setup();
|
||||
ATTR_COLD setup_t &setup();
|
||||
|
||||
ATTR_COLD void register_sub(const pstring &name, device_t &dev);
|
||||
ATTR_COLD void register_subalias(const pstring &name, core_terminal_t &term);
|
||||
ATTR_COLD void register_terminal(const pstring &name, terminal_t &port);
|
||||
ATTR_COLD void register_output(const pstring &name, netlist_analog_output_t &out);
|
||||
ATTR_COLD void register_output(const pstring &name, analog_output_t &out);
|
||||
ATTR_COLD void register_output(const pstring &name, logic_output_t &out);
|
||||
ATTR_COLD void register_input(const pstring &name, analog_input_t &in);
|
||||
ATTR_COLD void register_input(const pstring &name, logic_input_t &in);
|
||||
@ -1133,7 +1131,7 @@ namespace netlist
|
||||
// netlist_queue_t
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class queue_t : public netlist_timed_queue<net_t *, netlist_time>,
|
||||
class queue_t : public timed_queue<net_t *, netlist_time>,
|
||||
public object_t,
|
||||
public pstate_callback_t
|
||||
{
|
||||
@ -1187,8 +1185,8 @@ namespace netlist
|
||||
|
||||
ATTR_COLD void rebuild_lists(); /* must be called after post_load ! */
|
||||
|
||||
ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup; }
|
||||
ATTR_COLD netlist_setup_t &setup() { return *m_setup; }
|
||||
ATTR_COLD void set_setup(setup_t *asetup) { m_setup = asetup; }
|
||||
ATTR_COLD setup_t &setup() { return *m_setup; }
|
||||
|
||||
ATTR_COLD net_t *find_net(const pstring &name);
|
||||
|
||||
@ -1283,7 +1281,7 @@ namespace netlist
|
||||
|
||||
|
||||
devices::NETLIB_NAME(netlistparams) *m_params;
|
||||
netlist_setup_t *m_setup;
|
||||
setup_t *m_setup;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -1292,13 +1290,13 @@ namespace netlist
|
||||
|
||||
PSTATE_INTERFACE(object_t, m_netlist, name())
|
||||
|
||||
ATTR_HOT inline void netlist_param_str_t::setTo(const pstring ¶m)
|
||||
ATTR_HOT inline void param_str_t::setTo(const pstring ¶m)
|
||||
{
|
||||
m_param = param;
|
||||
netdev().update_param();
|
||||
}
|
||||
|
||||
ATTR_HOT inline void netlist_param_int_t::setTo(const int param)
|
||||
ATTR_HOT inline void param_int_t::setTo(const int param)
|
||||
{
|
||||
if (m_param != param)
|
||||
{
|
||||
@ -1307,7 +1305,7 @@ namespace netlist
|
||||
}
|
||||
}
|
||||
|
||||
ATTR_HOT inline void netlist_param_double_t::setTo(const nl_double param)
|
||||
ATTR_HOT inline void param_double_t::setTo(const nl_double param)
|
||||
{
|
||||
if (m_param != param)
|
||||
{
|
||||
@ -1416,7 +1414,7 @@ namespace netlist
|
||||
return net().as_analog().Q_Analog();
|
||||
}
|
||||
|
||||
ATTR_HOT inline void netlist_analog_output_t::set_Q(const nl_double newQ)
|
||||
ATTR_HOT inline void analog_output_t::set_Q(const nl_double newQ)
|
||||
{
|
||||
if (newQ != net().as_analog().m_cur_Analog)
|
||||
{
|
||||
|
@ -64,13 +64,13 @@ device_t *factory_list_t::new_device_by_classname(const pstring &classname) cons
|
||||
return NULL; // appease code analysis
|
||||
}
|
||||
|
||||
device_t *factory_list_t::new_device_by_name(const pstring &name, netlist_setup_t &setup) const
|
||||
device_t *factory_list_t::new_device_by_name(const pstring &name, setup_t &setup) const
|
||||
{
|
||||
base_factory_t *f = factory_by_name(name, setup);
|
||||
return f->Create();
|
||||
}
|
||||
|
||||
base_factory_t * factory_list_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const
|
||||
base_factory_t * factory_list_t::factory_by_name(const pstring &name, setup_t &setup) const
|
||||
{
|
||||
for (std::size_t i=0; i < m_list.size(); i++)
|
||||
{
|
||||
|
@ -84,8 +84,8 @@ namespace netlist
|
||||
}
|
||||
|
||||
ATTR_COLD device_t *new_device_by_classname(const pstring &classname) const;
|
||||
ATTR_COLD device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
ATTR_COLD base_factory_t * factory_by_name(const pstring &name, netlist_setup_t &setup) const;
|
||||
ATTR_COLD device_t *new_device_by_name(const pstring &name, setup_t &setup) const;
|
||||
ATTR_COLD base_factory_t * factory_by_name(const pstring &name, setup_t &setup) const;
|
||||
|
||||
const list_t &list() { return m_list; }
|
||||
|
||||
|
@ -17,138 +17,143 @@
|
||||
// timed queue
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
template <class _Element, class _Time>
|
||||
class netlist_timed_queue
|
||||
namespace netlist
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_timed_queue)
|
||||
public:
|
||||
|
||||
class entry_t
|
||||
template <class _Element, class _Time>
|
||||
class timed_queue
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(timed_queue)
|
||||
public:
|
||||
ATTR_HOT entry_t()
|
||||
: m_exec_time(), m_object() {}
|
||||
ATTR_HOT entry_t(const _Time &atime, const _Element &elem) : m_exec_time(atime), m_object(elem) {}
|
||||
ATTR_HOT const _Time &exec_time() const { return m_exec_time; }
|
||||
ATTR_HOT const _Element &object() const { return m_object; }
|
||||
|
||||
ATTR_HOT entry_t &operator=(const entry_t &right) {
|
||||
m_exec_time = right.m_exec_time;
|
||||
m_object = right.m_object;
|
||||
return *this;
|
||||
class entry_t
|
||||
{
|
||||
public:
|
||||
ATTR_HOT entry_t()
|
||||
: m_exec_time(), m_object() {}
|
||||
ATTR_HOT entry_t(const _Time &atime, const _Element &elem) : m_exec_time(atime), m_object(elem) {}
|
||||
ATTR_HOT const _Time &exec_time() const { return m_exec_time; }
|
||||
ATTR_HOT const _Element &object() const { return m_object; }
|
||||
|
||||
ATTR_HOT entry_t &operator=(const entry_t &right) {
|
||||
m_exec_time = right.m_exec_time;
|
||||
m_object = right.m_object;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
_Time m_exec_time;
|
||||
_Element m_object;
|
||||
};
|
||||
|
||||
timed_queue(unsigned list_size)
|
||||
: m_list(list_size)
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
clear();
|
||||
}
|
||||
|
||||
ATTR_HOT std::size_t capacity() const { return m_list.size(); }
|
||||
ATTR_HOT bool is_empty() const { return (m_end == &m_list[1]); }
|
||||
ATTR_HOT bool is_not_empty() const { return (m_end > &m_list[1]); }
|
||||
|
||||
ATTR_HOT void push(const entry_t &e)
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
/* Lock */
|
||||
while (atomic_exchange32(&m_lock, 1)) { }
|
||||
#endif
|
||||
const _Time t = e.exec_time();
|
||||
entry_t * i = m_end++;
|
||||
while (t > (i - 1)->exec_time())
|
||||
{
|
||||
*(i) = *(i-1);
|
||||
i--;
|
||||
inc_stat(m_prof_sortmove);
|
||||
}
|
||||
*i = e;
|
||||
inc_stat(m_prof_call);
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
//nl_assert(m_end - m_list < _Size);
|
||||
}
|
||||
|
||||
ATTR_HOT const entry_t *pop()
|
||||
{
|
||||
return --m_end;
|
||||
}
|
||||
|
||||
ATTR_HOT const entry_t *peek() const
|
||||
{
|
||||
return (m_end-1);
|
||||
}
|
||||
|
||||
ATTR_HOT void remove(const _Element &elem)
|
||||
{
|
||||
/* Lock */
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
while (atomic_exchange32(&m_lock, 1)) { }
|
||||
#endif
|
||||
entry_t * i = m_end - 1;
|
||||
while (i > &m_list[0])
|
||||
{
|
||||
if (i->object() == elem)
|
||||
{
|
||||
m_end--;
|
||||
while (i < m_end)
|
||||
{
|
||||
*i = *(i+1);
|
||||
i++;
|
||||
}
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
ATTR_COLD void clear()
|
||||
{
|
||||
m_end = &m_list[0];
|
||||
/* put an empty element with maximum time into the queue.
|
||||
* the insert algo above will run into this element and doesn't
|
||||
* need a comparison with queue start.
|
||||
*/
|
||||
m_list[0] = entry_t(_Time::from_raw(~0), _Element(0));
|
||||
m_end++;
|
||||
}
|
||||
|
||||
// save state support & mame disasm
|
||||
|
||||
ATTR_COLD const entry_t *listptr() const { return &m_list[1]; }
|
||||
ATTR_HOT int count() const { return m_end - &m_list[1]; }
|
||||
ATTR_HOT const entry_t & operator[](const int & index) const { return m_list[1+index]; }
|
||||
|
||||
#if (NL_KEEP_STATISTICS)
|
||||
// profiling
|
||||
INT32 m_prof_sortmove;
|
||||
INT32 m_prof_call;
|
||||
#endif
|
||||
|
||||
private:
|
||||
_Time m_exec_time;
|
||||
_Element m_object;
|
||||
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
volatile INT32 m_lock;
|
||||
#endif
|
||||
entry_t * m_end;
|
||||
//entry_t m_list[_Size];
|
||||
parray_t<entry_t> m_list;
|
||||
|
||||
};
|
||||
|
||||
netlist_timed_queue(unsigned list_size)
|
||||
: m_list(list_size)
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
clear();
|
||||
}
|
||||
|
||||
ATTR_HOT std::size_t capacity() const { return m_list.size(); }
|
||||
ATTR_HOT bool is_empty() const { return (m_end == &m_list[1]); }
|
||||
ATTR_HOT bool is_not_empty() const { return (m_end > &m_list[1]); }
|
||||
|
||||
ATTR_HOT void push(const entry_t &e)
|
||||
{
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
/* Lock */
|
||||
while (atomic_exchange32(&m_lock, 1)) { }
|
||||
#endif
|
||||
const _Time t = e.exec_time();
|
||||
entry_t * i = m_end++;
|
||||
while (t > (i - 1)->exec_time())
|
||||
{
|
||||
*(i) = *(i-1);
|
||||
i--;
|
||||
inc_stat(m_prof_sortmove);
|
||||
}
|
||||
*i = e;
|
||||
inc_stat(m_prof_call);
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
//nl_assert(m_end - m_list < _Size);
|
||||
}
|
||||
|
||||
ATTR_HOT const entry_t *pop()
|
||||
{
|
||||
return --m_end;
|
||||
}
|
||||
|
||||
ATTR_HOT const entry_t *peek() const
|
||||
{
|
||||
return (m_end-1);
|
||||
}
|
||||
|
||||
ATTR_HOT void remove(const _Element &elem)
|
||||
{
|
||||
/* Lock */
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
while (atomic_exchange32(&m_lock, 1)) { }
|
||||
#endif
|
||||
entry_t * i = m_end - 1;
|
||||
while (i > &m_list[0])
|
||||
{
|
||||
if (i->object() == elem)
|
||||
{
|
||||
m_end--;
|
||||
while (i < m_end)
|
||||
{
|
||||
*i = *(i+1);
|
||||
i++;
|
||||
}
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
m_lock = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
ATTR_COLD void clear()
|
||||
{
|
||||
m_end = &m_list[0];
|
||||
/* put an empty element with maximum time into the queue.
|
||||
* the insert algo above will run into this element and doesn't
|
||||
* need a comparison with queue start.
|
||||
*/
|
||||
m_list[0] = entry_t(_Time::from_raw(~0), _Element(0));
|
||||
m_end++;
|
||||
}
|
||||
|
||||
// save state support & mame disasm
|
||||
|
||||
ATTR_COLD const entry_t *listptr() const { return &m_list[1]; }
|
||||
ATTR_HOT int count() const { return m_end - &m_list[1]; }
|
||||
ATTR_HOT const entry_t & operator[](const int & index) const { return m_list[1+index]; }
|
||||
|
||||
#if (NL_KEEP_STATISTICS)
|
||||
// profiling
|
||||
INT32 m_prof_sortmove;
|
||||
INT32 m_prof_call;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
#if HAS_OPENMP && USE_OPENMP
|
||||
volatile INT32 m_lock;
|
||||
#endif
|
||||
entry_t * m_end;
|
||||
//entry_t m_list[_Size];
|
||||
parray_t<entry_t> m_list;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* NLLISTS_H_ */
|
||||
|
@ -18,7 +18,7 @@ namespace netlist
|
||||
// A netlist parser
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
ATTR_COLD void netlist_parser::verror(pstring msg, int line_num, pstring line)
|
||||
ATTR_COLD void parser_t::verror(pstring msg, int line_num, pstring line)
|
||||
{
|
||||
m_setup.netlist().error("line %d: error: %s\n\t\t%s\n", line_num,
|
||||
msg.cstr(), line.cstr());
|
||||
@ -27,7 +27,7 @@ ATTR_COLD void netlist_parser::verror(pstring msg, int line_num, pstring line)
|
||||
}
|
||||
|
||||
|
||||
bool netlist_parser::parse(const char *buf, const pstring nlname)
|
||||
bool parser_t::parse(const char *buf, const pstring nlname)
|
||||
{
|
||||
ppreprocessor prepro;
|
||||
|
||||
@ -104,7 +104,7 @@ bool netlist_parser::parse(const char *buf, const pstring nlname)
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_parser::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@ -144,7 +144,7 @@ void netlist_parser::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_parser::net_truthtable_start()
|
||||
void parser_t::net_truthtable_start()
|
||||
{
|
||||
pstring name = get_identifier();
|
||||
require_token(m_tok_comma);
|
||||
@ -188,20 +188,20 @@ void netlist_parser::net_truthtable_start()
|
||||
}
|
||||
|
||||
|
||||
void netlist_parser::netdev_netlist_start()
|
||||
void parser_t::netdev_netlist_start()
|
||||
{
|
||||
// don't do much
|
||||
token_t name = get_token();
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
|
||||
void netlist_parser::netdev_netlist_end()
|
||||
void parser_t::netdev_netlist_end()
|
||||
{
|
||||
// don't do much
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
|
||||
void netlist_parser::net_model()
|
||||
void parser_t::net_model()
|
||||
{
|
||||
// don't do much
|
||||
pstring model = get_string();
|
||||
@ -209,7 +209,7 @@ void netlist_parser::net_model()
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
|
||||
void netlist_parser::net_submodel()
|
||||
void parser_t::net_submodel()
|
||||
{
|
||||
// don't do much
|
||||
pstring model = get_identifier();
|
||||
@ -222,7 +222,7 @@ void netlist_parser::net_submodel()
|
||||
m_setup.namespace_pop();
|
||||
}
|
||||
|
||||
void netlist_parser::frontier()
|
||||
void parser_t::frontier()
|
||||
{
|
||||
// don't do much
|
||||
pstring attachat = get_identifier();
|
||||
@ -235,7 +235,7 @@ void netlist_parser::frontier()
|
||||
m_setup.register_frontier(attachat, r_IN, r_OUT);
|
||||
}
|
||||
|
||||
void netlist_parser::net_include()
|
||||
void parser_t::net_include()
|
||||
{
|
||||
// don't do much
|
||||
pstring name = get_identifier();
|
||||
@ -244,7 +244,7 @@ void netlist_parser::net_include()
|
||||
m_setup.include(name);
|
||||
}
|
||||
|
||||
void netlist_parser::net_local_source()
|
||||
void parser_t::net_local_source()
|
||||
{
|
||||
// This directive is only for hardcoded netlists. Ignore it here.
|
||||
pstring name = get_identifier();
|
||||
@ -252,7 +252,7 @@ void netlist_parser::net_local_source()
|
||||
|
||||
}
|
||||
|
||||
void netlist_parser::net_alias()
|
||||
void parser_t::net_alias()
|
||||
{
|
||||
pstring alias = get_identifier_or_number();
|
||||
|
||||
@ -266,7 +266,7 @@ void netlist_parser::net_alias()
|
||||
m_setup.register_alias(alias, out);
|
||||
}
|
||||
|
||||
void netlist_parser::net_c()
|
||||
void parser_t::net_c()
|
||||
{
|
||||
pstring first = get_identifier();
|
||||
require_token(m_tok_comma);
|
||||
@ -285,7 +285,7 @@ void netlist_parser::net_c()
|
||||
|
||||
}
|
||||
|
||||
void netlist_parser::netdev_param()
|
||||
void parser_t::netdev_param()
|
||||
{
|
||||
pstring param;
|
||||
nl_double val;
|
||||
@ -297,7 +297,7 @@ void netlist_parser::netdev_param()
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
|
||||
void netlist_parser::device(const pstring &dev_type)
|
||||
void parser_t::device(const pstring &dev_type)
|
||||
{
|
||||
pstring devname;
|
||||
base_factory_t *f = m_setup.factory().factory_by_name(dev_type, m_setup);
|
||||
@ -356,7 +356,7 @@ void netlist_parser::device(const pstring &dev_type)
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
nl_double netlist_parser::eval_param(const token_t tok)
|
||||
nl_double parser_t::eval_param(const token_t tok)
|
||||
{
|
||||
static const char *macs[6] = {"", "RES_K", "RES_M", "CAP_U", "CAP_N", "CAP_P"};
|
||||
static nl_double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12};
|
||||
|
@ -15,60 +15,60 @@
|
||||
namespace netlist
|
||||
{
|
||||
|
||||
class netlist_parser : public ptokenizer
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_parser)
|
||||
public:
|
||||
netlist_parser(netlist_setup_t &setup)
|
||||
: ptokenizer(), m_setup(setup), m_buf(NULL) {}
|
||||
class parser_t : public ptokenizer
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(parser_t)
|
||||
public:
|
||||
parser_t(setup_t &setup)
|
||||
: ptokenizer(), m_setup(setup), m_buf(NULL) {}
|
||||
|
||||
bool parse(const char *buf, const pstring nlname = "");
|
||||
bool parse(const char *buf, const pstring nlname = "");
|
||||
|
||||
void parse_netlist(const pstring &nlname);
|
||||
void net_alias();
|
||||
void netdev_param();
|
||||
void net_c();
|
||||
void frontier();
|
||||
void device(const pstring &dev_type);
|
||||
void netdev_netlist_start();
|
||||
void netdev_netlist_end();
|
||||
void net_model();
|
||||
void net_submodel();
|
||||
void net_include();
|
||||
void net_local_source();
|
||||
void net_truthtable_start();
|
||||
void parse_netlist(const pstring &nlname);
|
||||
void net_alias();
|
||||
void netdev_param();
|
||||
void net_c();
|
||||
void frontier();
|
||||
void device(const pstring &dev_type);
|
||||
void netdev_netlist_start();
|
||||
void netdev_netlist_end();
|
||||
void net_model();
|
||||
void net_submodel();
|
||||
void net_include();
|
||||
void net_local_source();
|
||||
void net_truthtable_start();
|
||||
|
||||
protected:
|
||||
/* for debugging messages */
|
||||
netlist_t &netlist() { return m_setup.netlist(); }
|
||||
protected:
|
||||
/* for debugging messages */
|
||||
netlist_t &netlist() { return m_setup.netlist(); }
|
||||
|
||||
virtual void verror(pstring msg, int line_num, pstring line);
|
||||
private:
|
||||
virtual void verror(pstring msg, int line_num, pstring line);
|
||||
private:
|
||||
|
||||
nl_double eval_param(const token_t tok);
|
||||
nl_double eval_param(const token_t tok);
|
||||
|
||||
token_id_t m_tok_param_left;
|
||||
token_id_t m_tok_param_right;
|
||||
token_id_t m_tok_comma;
|
||||
token_id_t m_tok_ALIAS;
|
||||
token_id_t m_tok_NET_C;
|
||||
token_id_t m_tok_FRONTIER;
|
||||
token_id_t m_tok_PARAM;
|
||||
token_id_t m_tok_NET_MODEL;
|
||||
token_id_t m_tok_NETLIST_START;
|
||||
token_id_t m_tok_NETLIST_END;
|
||||
token_id_t m_tok_SUBMODEL;
|
||||
token_id_t m_tok_INCLUDE;
|
||||
token_id_t m_tok_LOCAL_SOURCE;
|
||||
token_id_t m_tok_TRUTHTABLE_START;
|
||||
token_id_t m_tok_TRUTHTABLE_END;
|
||||
token_id_t m_tok_TT_HEAD;
|
||||
token_id_t m_tok_TT_LINE;
|
||||
token_id_t m_tok_param_left;
|
||||
token_id_t m_tok_param_right;
|
||||
token_id_t m_tok_comma;
|
||||
token_id_t m_tok_ALIAS;
|
||||
token_id_t m_tok_NET_C;
|
||||
token_id_t m_tok_FRONTIER;
|
||||
token_id_t m_tok_PARAM;
|
||||
token_id_t m_tok_NET_MODEL;
|
||||
token_id_t m_tok_NETLIST_START;
|
||||
token_id_t m_tok_NETLIST_END;
|
||||
token_id_t m_tok_SUBMODEL;
|
||||
token_id_t m_tok_INCLUDE;
|
||||
token_id_t m_tok_LOCAL_SOURCE;
|
||||
token_id_t m_tok_TRUTHTABLE_START;
|
||||
token_id_t m_tok_TRUTHTABLE_END;
|
||||
token_id_t m_tok_TT_HEAD;
|
||||
token_id_t m_tok_TT_LINE;
|
||||
|
||||
netlist_setup_t &m_setup;
|
||||
setup_t &m_setup;
|
||||
|
||||
const char *m_buf;
|
||||
};
|
||||
const char *m_buf;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,13 @@ NETLIST_END()
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// netlist_setup_t
|
||||
// setup_t
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
namespace netlist
|
||||
{
|
||||
|
||||
netlist_setup_t::netlist_setup_t(netlist_t *netlist)
|
||||
setup_t::setup_t(netlist_t *netlist)
|
||||
: m_netlist(netlist)
|
||||
, m_proxy_cnt(0)
|
||||
{
|
||||
@ -48,14 +48,14 @@ netlist_setup_t::netlist_setup_t(netlist_t *netlist)
|
||||
m_factory = palloc(factory_list_t);
|
||||
}
|
||||
|
||||
void netlist_setup_t::init()
|
||||
void setup_t::init()
|
||||
{
|
||||
initialize_factory(factory());
|
||||
NETLIST_NAME(base)(*this);
|
||||
}
|
||||
|
||||
|
||||
netlist_setup_t::~netlist_setup_t()
|
||||
setup_t::~setup_t()
|
||||
{
|
||||
m_links.clear();
|
||||
m_alias.clear();
|
||||
@ -70,7 +70,7 @@ netlist_setup_t::~netlist_setup_t()
|
||||
pstring::resetmem();
|
||||
}
|
||||
|
||||
ATTR_COLD pstring netlist_setup_t::build_fqn(const pstring &obj_name) const
|
||||
ATTR_COLD pstring setup_t::build_fqn(const pstring &obj_name) const
|
||||
{
|
||||
if (m_stack.empty())
|
||||
return netlist().name() + "." + obj_name;
|
||||
@ -78,7 +78,7 @@ ATTR_COLD pstring netlist_setup_t::build_fqn(const pstring &obj_name) const
|
||||
return m_stack.peek() + "." + obj_name;
|
||||
}
|
||||
|
||||
void netlist_setup_t::namespace_push(const pstring &aname)
|
||||
void setup_t::namespace_push(const pstring &aname)
|
||||
{
|
||||
if (m_stack.empty())
|
||||
m_stack.push(netlist().name() + "." + aname);
|
||||
@ -86,13 +86,13 @@ void netlist_setup_t::namespace_push(const pstring &aname)
|
||||
m_stack.push(m_stack.peek() + "." + aname);
|
||||
}
|
||||
|
||||
void netlist_setup_t::namespace_pop()
|
||||
void setup_t::namespace_pop()
|
||||
{
|
||||
m_stack.pop();
|
||||
}
|
||||
|
||||
|
||||
device_t *netlist_setup_t::register_dev(device_t *dev, const pstring &name)
|
||||
device_t *setup_t::register_dev(device_t *dev, const pstring &name)
|
||||
{
|
||||
pstring fqn = build_fqn(name);
|
||||
|
||||
@ -103,7 +103,7 @@ device_t *netlist_setup_t::register_dev(device_t *dev, const pstring &name)
|
||||
return dev;
|
||||
}
|
||||
|
||||
device_t *netlist_setup_t::register_dev(const pstring &classname, const pstring &name)
|
||||
device_t *setup_t::register_dev(const pstring &classname, const pstring &name)
|
||||
{
|
||||
device_t *dev = factory().new_device_by_classname(classname);
|
||||
if (dev == NULL)
|
||||
@ -111,7 +111,7 @@ device_t *netlist_setup_t::register_dev(const pstring &classname, const pstring
|
||||
return register_dev(dev, name);
|
||||
}
|
||||
|
||||
void netlist_setup_t::remove_dev(const pstring &name)
|
||||
void setup_t::remove_dev(const pstring &name)
|
||||
{
|
||||
device_t *dev = netlist().m_devices.find_by_name(name);
|
||||
pstring temp = name + ".";
|
||||
@ -132,25 +132,25 @@ void netlist_setup_t::remove_dev(const pstring &name)
|
||||
netlist().m_devices.remove_by_name(name);
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_model(const pstring &model)
|
||||
void setup_t::register_model(const pstring &model)
|
||||
{
|
||||
m_models.add(model);
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_alias_nofqn(const pstring &alias, const pstring &out)
|
||||
void setup_t::register_alias_nofqn(const pstring &alias, const pstring &out)
|
||||
{
|
||||
if (!(m_alias.add(link_t(alias, out), false)==true))
|
||||
netlist().error("Error adding alias %s to alias list\n", alias.cstr());
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_alias(const pstring &alias, const pstring &out)
|
||||
void setup_t::register_alias(const pstring &alias, const pstring &out)
|
||||
{
|
||||
pstring alias_fqn = build_fqn(alias);
|
||||
pstring out_fqn = build_fqn(out);
|
||||
register_alias_nofqn(alias_fqn, out_fqn);
|
||||
}
|
||||
|
||||
pstring netlist_setup_t::objtype_as_astr(object_t &in) const
|
||||
pstring setup_t::objtype_as_astr(object_t &in) const
|
||||
{
|
||||
switch (in.type())
|
||||
{
|
||||
@ -176,7 +176,7 @@ pstring netlist_setup_t::objtype_as_astr(object_t &in) const
|
||||
return "Error";
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_object(device_t &dev, const pstring &name, object_t &obj)
|
||||
void setup_t::register_object(device_t &dev, const pstring &name, object_t &obj)
|
||||
{
|
||||
switch (obj.type())
|
||||
{
|
||||
@ -190,7 +190,7 @@ void netlist_setup_t::register_object(device_t &dev, const pstring &name, object
|
||||
if (obj.isFamily(terminal_t::LOGIC))
|
||||
dynamic_cast<logic_output_t &>(term).init_object(dev, dev.name() + "." + name);
|
||||
else if (obj.isFamily(terminal_t::ANALOG))
|
||||
dynamic_cast<netlist_analog_output_t &>(term).init_object(dev, dev.name() + "." + name);
|
||||
dynamic_cast<analog_output_t &>(term).init_object(dev, dev.name() + "." + name);
|
||||
else
|
||||
netlist().error("Error adding %s %s to terminal list, neither LOGIC nor ANALOG\n", objtype_as_astr(term).cstr(), term.name().cstr());
|
||||
}
|
||||
@ -206,38 +206,38 @@ void netlist_setup_t::register_object(device_t &dev, const pstring &name, object
|
||||
break;
|
||||
case terminal_t::PARAM:
|
||||
{
|
||||
netlist_param_t ¶m = dynamic_cast<netlist_param_t &>(obj);
|
||||
param_t ¶m = dynamic_cast<param_t &>(obj);
|
||||
//printf("name: %s\n", name.cstr());
|
||||
const pstring val = m_params_temp.find_by_name(name).e2;
|
||||
if (val != "")
|
||||
{
|
||||
switch (param.param_type())
|
||||
{
|
||||
case netlist_param_t::DOUBLE:
|
||||
case param_t::DOUBLE:
|
||||
{
|
||||
NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", name.cstr(), val.cstr()));
|
||||
double vald = 0;
|
||||
if (std::sscanf(val.cstr(), "%lf", &vald) != 1)
|
||||
netlist().error("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
|
||||
dynamic_cast<netlist_param_double_t &>(param).initial(vald);
|
||||
dynamic_cast<param_double_t &>(param).initial(vald);
|
||||
}
|
||||
break;
|
||||
case netlist_param_t::INTEGER:
|
||||
case netlist_param_t::LOGIC:
|
||||
case param_t::INTEGER:
|
||||
case param_t::LOGIC:
|
||||
{
|
||||
NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", name.cstr(), val.cstr()));
|
||||
double vald = 0;
|
||||
if (std::sscanf(val.cstr(), "%lf", &vald) != 1)
|
||||
netlist().error("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
|
||||
dynamic_cast<netlist_param_int_t &>(param).initial((int) vald);
|
||||
dynamic_cast<param_int_t &>(param).initial((int) vald);
|
||||
}
|
||||
break;
|
||||
case netlist_param_t::STRING:
|
||||
case param_t::STRING:
|
||||
{
|
||||
dynamic_cast<netlist_param_str_t &>(param).initial(val);
|
||||
dynamic_cast<param_str_t &>(param).initial(val);
|
||||
}
|
||||
break;
|
||||
case netlist_param_t::MODEL:
|
||||
case param_t::MODEL:
|
||||
{
|
||||
pstring search = (".model " + val + " ").ucase();
|
||||
bool found = false;
|
||||
@ -248,7 +248,7 @@ void netlist_setup_t::register_object(device_t &dev, const pstring &name, object
|
||||
//int pl=m_models[i].find("(");
|
||||
//int pr=m_models[i].find(")");
|
||||
//dynamic_cast<netlist_param_model_t &>(param).initial(m_models[i].substr(pl+1,pr-pl-1));
|
||||
dynamic_cast<netlist_param_model_t &>(param).initial(m_models[i]);
|
||||
dynamic_cast<param_model_t &>(param).initial(m_models[i]);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@ -277,7 +277,7 @@ void netlist_setup_t::register_object(device_t &dev, const pstring &name, object
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_link_arr(const pstring &terms)
|
||||
void setup_t::register_link_arr(const pstring &terms)
|
||||
{
|
||||
pstring_list_t list(terms,", ");
|
||||
if (list.size() < 2)
|
||||
@ -289,7 +289,7 @@ void netlist_setup_t::register_link_arr(const pstring &terms)
|
||||
}
|
||||
|
||||
|
||||
void netlist_setup_t::register_link(const pstring &sin, const pstring &sout)
|
||||
void setup_t::register_link(const pstring &sin, const pstring &sout)
|
||||
{
|
||||
link_t temp = link_t(build_fqn(sin), build_fqn(sout));
|
||||
NL_VERBOSE_OUT(("link %s <== %s\n", sin.cstr(), sout.cstr()));
|
||||
@ -298,7 +298,7 @@ void netlist_setup_t::register_link(const pstring &sin, const pstring &sout)
|
||||
// fatalerror("Error adding link %s<==%s to link list\n", sin.cstr(), sout.cstr());
|
||||
}
|
||||
|
||||
void netlist_setup_t::remove_connections(const pstring pin)
|
||||
void setup_t::remove_connections(const pstring pin)
|
||||
{
|
||||
pstring pinfn = build_fqn(pin);
|
||||
bool found = false;
|
||||
@ -316,7 +316,7 @@ void netlist_setup_t::remove_connections(const pstring pin)
|
||||
}
|
||||
|
||||
|
||||
void netlist_setup_t::register_frontier(const pstring attach, const double r_IN, const double r_OUT)
|
||||
void setup_t::register_frontier(const pstring attach, const double r_IN, const double r_OUT)
|
||||
{
|
||||
static int frontier_cnt = 0;
|
||||
pstring frontier_name = pstring::sprintf("frontier_%d", frontier_cnt);
|
||||
@ -346,13 +346,13 @@ void netlist_setup_t::register_frontier(const pstring attach, const double r_IN,
|
||||
}
|
||||
|
||||
|
||||
void netlist_setup_t::register_param(const pstring ¶m, const double value)
|
||||
void setup_t::register_param(const pstring ¶m, const double value)
|
||||
{
|
||||
// FIXME: there should be a better way
|
||||
register_param(param, pstring::sprintf("%.9e", value));
|
||||
}
|
||||
|
||||
void netlist_setup_t::register_param(const pstring ¶m, const pstring &value)
|
||||
void setup_t::register_param(const pstring ¶m, const pstring &value)
|
||||
{
|
||||
pstring fqn = build_fqn(param);
|
||||
|
||||
@ -360,7 +360,7 @@ void netlist_setup_t::register_param(const pstring ¶m, const pstring &value)
|
||||
netlist().error("Error adding parameter %s to parameter list\n", param.cstr());
|
||||
}
|
||||
|
||||
const pstring netlist_setup_t::resolve_alias(const pstring &name) const
|
||||
const pstring setup_t::resolve_alias(const pstring &name) const
|
||||
{
|
||||
pstring temp = name;
|
||||
pstring ret;
|
||||
@ -375,7 +375,7 @@ const pstring netlist_setup_t::resolve_alias(const pstring &name) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_in, bool required)
|
||||
core_terminal_t *setup_t::find_terminal(const pstring &terminal_in, bool required)
|
||||
{
|
||||
const pstring &tname = resolve_alias(terminal_in);
|
||||
core_terminal_t *ret;
|
||||
@ -395,7 +395,7 @@ core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_in, bool
|
||||
return ret;
|
||||
}
|
||||
|
||||
core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_in, object_t::type_t atype, bool required)
|
||||
core_terminal_t *setup_t::find_terminal(const pstring &terminal_in, object_t::type_t atype, bool required)
|
||||
{
|
||||
const pstring &tname = resolve_alias(terminal_in);
|
||||
core_terminal_t *ret;
|
||||
@ -422,12 +422,12 @@ core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_in, obje
|
||||
return ret;
|
||||
}
|
||||
|
||||
netlist_param_t *netlist_setup_t::find_param(const pstring ¶m_in, bool required)
|
||||
param_t *setup_t::find_param(const pstring ¶m_in, bool required)
|
||||
{
|
||||
const pstring param_in_fqn = build_fqn(param_in);
|
||||
|
||||
const pstring &outname = resolve_alias(param_in_fqn);
|
||||
netlist_param_t *ret;
|
||||
param_t *ret;
|
||||
|
||||
ret = m_params.find_by_name(outname);
|
||||
if (ret == NULL && required)
|
||||
@ -438,7 +438,7 @@ netlist_param_t *netlist_setup_t::find_param(const pstring ¶m_in, bool requi
|
||||
}
|
||||
|
||||
// FIXME avoid dynamic cast here
|
||||
devices::nld_base_proxy *netlist_setup_t::get_d_a_proxy(core_terminal_t &out)
|
||||
devices::nld_base_proxy *setup_t::get_d_a_proxy(core_terminal_t &out)
|
||||
{
|
||||
nl_assert(out.isFamily(terminal_t::LOGIC));
|
||||
|
||||
@ -475,7 +475,7 @@ devices::nld_base_proxy *netlist_setup_t::get_d_a_proxy(core_terminal_t &out)
|
||||
return proxy;
|
||||
}
|
||||
|
||||
void netlist_setup_t::connect_input_output(core_terminal_t &in, core_terminal_t &out)
|
||||
void setup_t::connect_input_output(core_terminal_t &in, core_terminal_t &out)
|
||||
{
|
||||
if (out.isFamily(terminal_t::ANALOG) && in.isFamily(terminal_t::LOGIC))
|
||||
{
|
||||
@ -509,7 +509,7 @@ void netlist_setup_t::connect_input_output(core_terminal_t &in, core_terminal_t
|
||||
}
|
||||
|
||||
|
||||
void netlist_setup_t::connect_terminal_input(terminal_t &term, core_terminal_t &inp)
|
||||
void setup_t::connect_terminal_input(terminal_t &term, core_terminal_t &inp)
|
||||
{
|
||||
if (inp.isFamily(terminal_t::ANALOG))
|
||||
{
|
||||
@ -541,7 +541,7 @@ void netlist_setup_t::connect_terminal_input(terminal_t &term, core_terminal_t &
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_setup_t::connect_terminal_output(terminal_t &in, core_terminal_t &out)
|
||||
void setup_t::connect_terminal_output(terminal_t &in, core_terminal_t &out)
|
||||
{
|
||||
if (out.isFamily(terminal_t::ANALOG))
|
||||
{
|
||||
@ -565,7 +565,7 @@ void netlist_setup_t::connect_terminal_output(terminal_t &in, core_terminal_t &o
|
||||
}
|
||||
}
|
||||
|
||||
void netlist_setup_t::connect_terminals(core_terminal_t &t1, core_terminal_t &t2)
|
||||
void setup_t::connect_terminals(core_terminal_t &t1, core_terminal_t &t2)
|
||||
{
|
||||
//nl_assert(in.isType(netlist_terminal_t::TERMINAL));
|
||||
//nl_assert(out.isType(netlist_terminal_t::TERMINAL));
|
||||
@ -609,7 +609,7 @@ static core_terminal_t &resolve_proxy(core_terminal_t &term)
|
||||
return term;
|
||||
}
|
||||
|
||||
bool netlist_setup_t::connect_input_input(core_terminal_t &t1, core_terminal_t &t2)
|
||||
bool setup_t::connect_input_input(core_terminal_t &t1, core_terminal_t &t2)
|
||||
{
|
||||
bool ret = false;
|
||||
if (t1.has_net())
|
||||
@ -653,7 +653,7 @@ bool netlist_setup_t::connect_input_input(core_terminal_t &t1, core_terminal_t &
|
||||
|
||||
|
||||
|
||||
bool netlist_setup_t::connect(core_terminal_t &t1_in, core_terminal_t &t2_in)
|
||||
bool setup_t::connect(core_terminal_t &t1_in, core_terminal_t &t2_in)
|
||||
{
|
||||
NL_VERBOSE_OUT(("Connecting %s to %s\n", t1_in.name().cstr(), t2_in.name().cstr()));
|
||||
core_terminal_t &t1 = resolve_proxy(t1_in);
|
||||
@ -702,7 +702,7 @@ bool netlist_setup_t::connect(core_terminal_t &t1_in, core_terminal_t &t2_in)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void netlist_setup_t::resolve_inputs()
|
||||
void setup_t::resolve_inputs()
|
||||
{
|
||||
bool has_twoterms = false;
|
||||
|
||||
@ -810,7 +810,7 @@ void netlist_setup_t::resolve_inputs()
|
||||
|
||||
}
|
||||
|
||||
void netlist_setup_t::start_devices()
|
||||
void setup_t::start_devices()
|
||||
{
|
||||
pstring env = nl_util::environment("NL_LOGS");
|
||||
|
||||
@ -832,17 +832,17 @@ void netlist_setup_t::start_devices()
|
||||
netlist().start();
|
||||
}
|
||||
|
||||
void netlist_setup_t::print_stats() const
|
||||
void setup_t::print_stats() const
|
||||
{
|
||||
#if (NL_KEEP_STATISTICS)
|
||||
{
|
||||
for (std::size_t i = 0; i < netlist().m_started_devices.size(); i++)
|
||||
{
|
||||
netlist_core_device_t *entry = netlist().m_started_devices[i];
|
||||
core_device_t *entry = netlist().m_started_devices[i];
|
||||
printf("Device %20s : %12d %12d %15ld\n", entry->name().cstr(), entry->stat_call_count, entry->stat_update_count, (long int) entry->stat_total_time / (entry->stat_update_count + 1));
|
||||
}
|
||||
printf("Queue Pushes %15d\n", m_netlist.queue().m_prof_call);
|
||||
printf("Queue Moves %15d\n", m_netlist.queue().m_prof_sortmove);
|
||||
printf("Queue Pushes %15d\n", netlist().queue().m_prof_call);
|
||||
printf("Queue Moves %15d\n", netlist().queue().m_prof_sortmove);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -851,7 +851,7 @@ void netlist_setup_t::print_stats() const
|
||||
// Sources
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
void netlist_setup_t::include(const pstring &netlist_name)
|
||||
void setup_t::include(const pstring &netlist_name)
|
||||
{
|
||||
for (std::size_t i=0; i < m_sources.size(); i++)
|
||||
{
|
||||
@ -865,15 +865,15 @@ void netlist_setup_t::include(const pstring &netlist_name)
|
||||
// base sources
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
bool netlist_source_string_t::parse(netlist_setup_t *setup, const pstring name)
|
||||
bool netlist_source_string_t::parse(setup_t *setup, const pstring name)
|
||||
{
|
||||
netlist_parser p(*setup);
|
||||
parser_t p(*setup);
|
||||
return p.parse(m_str, name);
|
||||
}
|
||||
|
||||
bool netlist_source_mem_t::parse(netlist_setup_t *setup, const pstring name)
|
||||
bool netlist_source_mem_t::parse(setup_t *setup, const pstring name)
|
||||
{
|
||||
netlist_parser p(*setup);
|
||||
parser_t p(*setup);
|
||||
return p.parse(m_str, name);
|
||||
}
|
||||
|
||||
|
@ -50,15 +50,15 @@
|
||||
#define NETLIST_NAME(_name) netlist ## _ ## _name
|
||||
|
||||
#define NETLIST_EXTERNAL(_name) \
|
||||
ATTR_COLD void NETLIST_NAME(_name)(netlist::netlist_setup_t &setup)
|
||||
ATTR_COLD void NETLIST_NAME(_name)(netlist::setup_t &setup)
|
||||
|
||||
#define NETLIST_START(_name) \
|
||||
ATTR_COLD void NETLIST_NAME(_name)(netlist::netlist_setup_t &setup) \
|
||||
ATTR_COLD void NETLIST_NAME(_name)(netlist::setup_t &setup) \
|
||||
{
|
||||
#define NETLIST_END() }
|
||||
|
||||
#define LOCAL_SOURCE(_name) \
|
||||
setup.register_source(palloc(netlist::netlist_source_proc_t, # _name, &NETLIST_NAME(_name)));
|
||||
setup.register_source(palloc(netlist::source_proc_t, # _name, &NETLIST_NAME(_name)));
|
||||
|
||||
#define INCLUDE(_name) \
|
||||
setup.include(# _name);
|
||||
@ -75,226 +75,226 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist::netlist_setup_t &setup)
|
||||
namespace netlist
|
||||
{
|
||||
|
||||
// Forward definition so we keep nl_factory.h out of the public
|
||||
class factory_list_t;
|
||||
// Forward definition so we keep nl_factory.h out of the public
|
||||
class factory_list_t;
|
||||
|
||||
|
||||
class netlist_setup_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(netlist_setup_t)
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// A Generic netlist sources implementation
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class source_t
|
||||
class setup_t
|
||||
{
|
||||
NETLIST_PREVENT_COPYING(setup_t)
|
||||
public:
|
||||
typedef plist_t<source_t *> list_t;
|
||||
|
||||
source_t()
|
||||
{}
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// A Generic netlist sources implementation
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
virtual ~source_t() { }
|
||||
|
||||
virtual bool parse(netlist_setup_t *setup, const pstring name) = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
struct link_t
|
||||
{
|
||||
link_t() { }
|
||||
link_t(void *) { }
|
||||
// Copy constructor
|
||||
link_t(const link_t &from)
|
||||
class source_t
|
||||
{
|
||||
e1 = from.e1;
|
||||
e2 = from.e2;
|
||||
}
|
||||
public:
|
||||
typedef plist_t<source_t *> list_t;
|
||||
|
||||
link_t(const pstring &ae1, const pstring &ae2)
|
||||
source_t()
|
||||
{}
|
||||
|
||||
virtual ~source_t() { }
|
||||
|
||||
virtual bool parse(setup_t *setup, const pstring name) = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
struct link_t
|
||||
{
|
||||
e1 = ae1;
|
||||
e2 = ae2;
|
||||
}
|
||||
pstring e1;
|
||||
pstring e2;
|
||||
|
||||
bool operator==(const link_t &rhs) const { return (e1 == rhs.e1) && (e2 == rhs.e2); }
|
||||
link_t &operator=(const link_t &rhs) { e1 = rhs.e1; e2 = rhs.e2; return *this; }
|
||||
|
||||
const pstring &name() const { return e1; }
|
||||
};
|
||||
|
||||
typedef pnamedlist_t<link_t> tagmap_nstring_t;
|
||||
typedef pnamedlist_t<netlist_param_t *> tagmap_param_t;
|
||||
typedef pnamedlist_t<core_terminal_t *> tagmap_terminal_t;
|
||||
typedef plist_t<link_t> tagmap_link_t;
|
||||
|
||||
netlist_setup_t(netlist_t *netlist);
|
||||
~netlist_setup_t();
|
||||
|
||||
void init();
|
||||
|
||||
netlist_t &netlist() { return *m_netlist; }
|
||||
const netlist_t &netlist() const { return *m_netlist; }
|
||||
|
||||
pstring build_fqn(const pstring &obj_name) const;
|
||||
|
||||
device_t *register_dev(device_t *dev, const pstring &name);
|
||||
device_t *register_dev(const pstring &classname, const pstring &name);
|
||||
void remove_dev(const pstring &name);
|
||||
|
||||
void register_model(const pstring &model);
|
||||
void register_alias(const pstring &alias, const pstring &out);
|
||||
void register_alias_nofqn(const pstring &alias, const pstring &out);
|
||||
void register_link_arr(const pstring &terms);
|
||||
void register_link(const pstring &sin, const pstring &sout);
|
||||
void register_param(const pstring ¶m, const pstring &value);
|
||||
void register_param(const pstring ¶m, const double value);
|
||||
|
||||
void register_frontier(const pstring attach, const double r_IN, const double r_OUT);
|
||||
void remove_connections(const pstring attach);
|
||||
|
||||
void register_object(device_t &dev, const pstring &name, object_t &obj);
|
||||
bool connect(core_terminal_t &t1, core_terminal_t &t2);
|
||||
|
||||
core_terminal_t *find_terminal(const pstring &outname_in, bool required = true);
|
||||
core_terminal_t *find_terminal(const pstring &outname_in, object_t::type_t atype, bool required = true);
|
||||
|
||||
netlist_param_t *find_param(const pstring ¶m_in, bool required = true);
|
||||
|
||||
void start_devices();
|
||||
void resolve_inputs();
|
||||
|
||||
/* handle namespace */
|
||||
|
||||
void namespace_push(const pstring &aname);
|
||||
void namespace_pop();
|
||||
|
||||
/* parse a source */
|
||||
|
||||
void include(const pstring &netlist_name);
|
||||
|
||||
/* register a source */
|
||||
|
||||
void register_source(source_t *src) { m_sources.add(src); }
|
||||
|
||||
factory_list_t &factory() { return *m_factory; }
|
||||
const factory_list_t &factory() const { return *m_factory; }
|
||||
|
||||
/* not ideal, but needed for save_state */
|
||||
tagmap_terminal_t m_terminals;
|
||||
|
||||
void print_stats() const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
netlist_t *m_netlist;
|
||||
|
||||
tagmap_nstring_t m_alias;
|
||||
tagmap_param_t m_params;
|
||||
tagmap_link_t m_links;
|
||||
tagmap_nstring_t m_params_temp;
|
||||
|
||||
factory_list_t *m_factory;
|
||||
|
||||
plist_t<pstring> m_models;
|
||||
|
||||
int m_proxy_cnt;
|
||||
|
||||
pstack_t<pstring> m_stack;
|
||||
source_t::list_t m_sources;
|
||||
|
||||
|
||||
void connect_terminals(core_terminal_t &in, core_terminal_t &out);
|
||||
void connect_input_output(core_terminal_t &in, core_terminal_t &out);
|
||||
void connect_terminal_output(terminal_t &in, core_terminal_t &out);
|
||||
void connect_terminal_input(terminal_t &term, core_terminal_t &inp);
|
||||
bool connect_input_input(core_terminal_t &t1, core_terminal_t &t2);
|
||||
|
||||
// helpers
|
||||
pstring objtype_as_astr(object_t &in) const;
|
||||
|
||||
const pstring resolve_alias(const pstring &name) const;
|
||||
devices::nld_base_proxy *get_d_a_proxy(core_terminal_t &out);
|
||||
|
||||
template <class T>
|
||||
void remove_start_with(T &hm, pstring &sw)
|
||||
{
|
||||
for (std::size_t i = hm.size() - 1; i >= 0; i--)
|
||||
{
|
||||
pstring x = hm[i]->name();
|
||||
if (sw.equals(x.substr(0, sw.len())))
|
||||
link_t() { }
|
||||
link_t(void *) { }
|
||||
// Copy constructor
|
||||
link_t(const link_t &from)
|
||||
{
|
||||
NL_VERBOSE_OUT(("removing %s\n", hm[i]->name().cstr()));
|
||||
hm.remove(hm[i]);
|
||||
e1 = from.e1;
|
||||
e2 = from.e2;
|
||||
}
|
||||
|
||||
link_t(const pstring &ae1, const pstring &ae2)
|
||||
{
|
||||
e1 = ae1;
|
||||
e2 = ae2;
|
||||
}
|
||||
pstring e1;
|
||||
pstring e2;
|
||||
|
||||
bool operator==(const link_t &rhs) const { return (e1 == rhs.e1) && (e2 == rhs.e2); }
|
||||
link_t &operator=(const link_t &rhs) { e1 = rhs.e1; e2 = rhs.e2; return *this; }
|
||||
|
||||
const pstring &name() const { return e1; }
|
||||
};
|
||||
|
||||
typedef pnamedlist_t<link_t> tagmap_nstring_t;
|
||||
typedef pnamedlist_t<param_t *> tagmap_param_t;
|
||||
typedef pnamedlist_t<core_terminal_t *> tagmap_terminal_t;
|
||||
typedef plist_t<link_t> tagmap_link_t;
|
||||
|
||||
setup_t(netlist_t *netlist);
|
||||
~setup_t();
|
||||
|
||||
void init();
|
||||
|
||||
netlist_t &netlist() { return *m_netlist; }
|
||||
const netlist_t &netlist() const { return *m_netlist; }
|
||||
|
||||
pstring build_fqn(const pstring &obj_name) const;
|
||||
|
||||
device_t *register_dev(device_t *dev, const pstring &name);
|
||||
device_t *register_dev(const pstring &classname, const pstring &name);
|
||||
void remove_dev(const pstring &name);
|
||||
|
||||
void register_model(const pstring &model);
|
||||
void register_alias(const pstring &alias, const pstring &out);
|
||||
void register_alias_nofqn(const pstring &alias, const pstring &out);
|
||||
void register_link_arr(const pstring &terms);
|
||||
void register_link(const pstring &sin, const pstring &sout);
|
||||
void register_param(const pstring ¶m, const pstring &value);
|
||||
void register_param(const pstring ¶m, const double value);
|
||||
|
||||
void register_frontier(const pstring attach, const double r_IN, const double r_OUT);
|
||||
void remove_connections(const pstring attach);
|
||||
|
||||
void register_object(device_t &dev, const pstring &name, object_t &obj);
|
||||
bool connect(core_terminal_t &t1, core_terminal_t &t2);
|
||||
|
||||
core_terminal_t *find_terminal(const pstring &outname_in, bool required = true);
|
||||
core_terminal_t *find_terminal(const pstring &outname_in, object_t::type_t atype, bool required = true);
|
||||
|
||||
param_t *find_param(const pstring ¶m_in, bool required = true);
|
||||
|
||||
void start_devices();
|
||||
void resolve_inputs();
|
||||
|
||||
/* handle namespace */
|
||||
|
||||
void namespace_push(const pstring &aname);
|
||||
void namespace_pop();
|
||||
|
||||
/* parse a source */
|
||||
|
||||
void include(const pstring &netlist_name);
|
||||
|
||||
/* register a source */
|
||||
|
||||
void register_source(source_t *src) { m_sources.add(src); }
|
||||
|
||||
factory_list_t &factory() { return *m_factory; }
|
||||
const factory_list_t &factory() const { return *m_factory; }
|
||||
|
||||
/* not ideal, but needed for save_state */
|
||||
tagmap_terminal_t m_terminals;
|
||||
|
||||
void print_stats() const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
netlist_t *m_netlist;
|
||||
|
||||
tagmap_nstring_t m_alias;
|
||||
tagmap_param_t m_params;
|
||||
tagmap_link_t m_links;
|
||||
tagmap_nstring_t m_params_temp;
|
||||
|
||||
factory_list_t *m_factory;
|
||||
|
||||
plist_t<pstring> m_models;
|
||||
|
||||
int m_proxy_cnt;
|
||||
|
||||
pstack_t<pstring> m_stack;
|
||||
source_t::list_t m_sources;
|
||||
|
||||
|
||||
void connect_terminals(core_terminal_t &in, core_terminal_t &out);
|
||||
void connect_input_output(core_terminal_t &in, core_terminal_t &out);
|
||||
void connect_terminal_output(terminal_t &in, core_terminal_t &out);
|
||||
void connect_terminal_input(terminal_t &term, core_terminal_t &inp);
|
||||
bool connect_input_input(core_terminal_t &t1, core_terminal_t &t2);
|
||||
|
||||
// helpers
|
||||
pstring objtype_as_astr(object_t &in) const;
|
||||
|
||||
const pstring resolve_alias(const pstring &name) const;
|
||||
devices::nld_base_proxy *get_d_a_proxy(core_terminal_t &out);
|
||||
|
||||
template <class T>
|
||||
void remove_start_with(T &hm, pstring &sw)
|
||||
{
|
||||
for (std::size_t i = hm.size() - 1; i >= 0; i--)
|
||||
{
|
||||
pstring x = hm[i]->name();
|
||||
if (sw.equals(x.substr(0, sw.len())))
|
||||
{
|
||||
NL_VERBOSE_OUT(("removing %s\n", hm[i]->name().cstr()));
|
||||
hm.remove(hm[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// base sources
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// base sources
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class netlist_source_string_t : public netlist_setup_t::source_t
|
||||
{
|
||||
public:
|
||||
|
||||
netlist_source_string_t(pstring source)
|
||||
: netlist_setup_t::source_t(), m_str(source)
|
||||
class netlist_source_string_t : public setup_t::source_t
|
||||
{
|
||||
}
|
||||
public:
|
||||
|
||||
bool parse(netlist_setup_t *setup, const pstring name);
|
||||
|
||||
private:
|
||||
pstring m_str;
|
||||
};
|
||||
|
||||
|
||||
class netlist_source_mem_t : public netlist_setup_t::source_t
|
||||
{
|
||||
public:
|
||||
netlist_source_mem_t(const char *mem)
|
||||
: netlist_setup_t::source_t(), m_str(mem)
|
||||
{
|
||||
}
|
||||
|
||||
bool parse(netlist_setup_t *setup, const pstring name);
|
||||
private:
|
||||
pstring m_str;
|
||||
};
|
||||
|
||||
class netlist_source_proc_t : public netlist_setup_t::source_t
|
||||
{
|
||||
public:
|
||||
netlist_source_proc_t(pstring name, void (*setup_func)(netlist_setup_t &))
|
||||
: netlist_setup_t::source_t(),
|
||||
m_setup_func(setup_func),
|
||||
m_setup_func_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
bool parse(netlist_setup_t *setup, const pstring name)
|
||||
{
|
||||
if (name == m_setup_func_name)
|
||||
netlist_source_string_t(pstring source)
|
||||
: setup_t::source_t(), m_str(source)
|
||||
{
|
||||
m_setup_func(*setup);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
void (*m_setup_func)(netlist_setup_t &);
|
||||
pstring m_setup_func_name;
|
||||
};
|
||||
|
||||
bool parse(setup_t *setup, const pstring name);
|
||||
|
||||
private:
|
||||
pstring m_str;
|
||||
};
|
||||
|
||||
|
||||
class netlist_source_mem_t : public setup_t::source_t
|
||||
{
|
||||
public:
|
||||
netlist_source_mem_t(const char *mem)
|
||||
: setup_t::source_t(), m_str(mem)
|
||||
{
|
||||
}
|
||||
|
||||
bool parse(setup_t *setup, const pstring name);
|
||||
private:
|
||||
pstring m_str;
|
||||
};
|
||||
|
||||
class source_proc_t : public setup_t::source_t
|
||||
{
|
||||
public:
|
||||
source_proc_t(pstring name, void (*setup_func)(setup_t &))
|
||||
: setup_t::source_t(),
|
||||
m_setup_func(setup_func),
|
||||
m_setup_func_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
bool parse(setup_t *setup, const pstring name)
|
||||
{
|
||||
if (name == m_setup_func_name)
|
||||
{
|
||||
m_setup_func(*setup);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
void (*m_setup_func)(setup_t &);
|
||||
pstring m_setup_func_name;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,105 +25,111 @@
|
||||
|
||||
#define RESOLUTION NETLIST_INTERNAL_RES
|
||||
|
||||
struct netlist_time
|
||||
namespace netlist
|
||||
{
|
||||
public:
|
||||
|
||||
typedef UINT64 INTERNALTYPE;
|
||||
struct netlist_time
|
||||
{
|
||||
public:
|
||||
|
||||
ATTR_HOT /* inline */ netlist_time() : m_time(0) {}
|
||||
typedef UINT64 INTERNALTYPE;
|
||||
|
||||
ATTR_HOT friend /* inline */ const netlist_time operator-(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ const netlist_time operator+(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ const netlist_time operator*(const netlist_time &left, const UINT32 factor);
|
||||
ATTR_HOT friend /* inline */ UINT32 operator/(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator>(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator<(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator>=(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator<=(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator!=(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT /* inline */ netlist_time() : m_time(0) {}
|
||||
|
||||
ATTR_HOT /* inline */ const netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; }
|
||||
ATTR_HOT /* inline */ const netlist_time &operator=(const double &right) { m_time = (INTERNALTYPE) ( right * (double) RESOLUTION); return *this; }
|
||||
ATTR_HOT friend /* inline */ const netlist_time operator-(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ const netlist_time operator+(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ const netlist_time operator*(const netlist_time &left, const UINT32 factor);
|
||||
ATTR_HOT friend /* inline */ UINT32 operator/(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator>(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator<(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator>=(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator<=(const netlist_time &left, const netlist_time &right);
|
||||
ATTR_HOT friend /* inline */ bool operator!=(const netlist_time &left, const netlist_time &right);
|
||||
|
||||
// issues with ISO C++ standard
|
||||
//ATTR_HOT /* inline */ operator double() const { return as_double(); }
|
||||
ATTR_HOT /* inline */ const netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; }
|
||||
ATTR_HOT /* inline */ const netlist_time &operator=(const double &right) { m_time = (INTERNALTYPE) ( right * (double) RESOLUTION); return *this; }
|
||||
|
||||
ATTR_HOT /* inline */ const netlist_time &operator+=(const netlist_time &right) { m_time += right.m_time; return *this; }
|
||||
// issues with ISO C++ standard
|
||||
//ATTR_HOT /* inline */ operator double() const { return as_double(); }
|
||||
|
||||
ATTR_HOT /* inline */ INTERNALTYPE as_raw() const { return m_time; }
|
||||
ATTR_HOT /* inline */ double as_double() const { return (double) m_time / (double) RESOLUTION; }
|
||||
ATTR_HOT /* inline */ const netlist_time &operator+=(const netlist_time &right) { m_time += right.m_time; return *this; }
|
||||
|
||||
// for save states ....
|
||||
ATTR_HOT /* inline */ INTERNALTYPE *get_internaltype_ptr() { return &m_time; }
|
||||
ATTR_HOT /* inline */ INTERNALTYPE as_raw() const { return m_time; }
|
||||
ATTR_HOT /* inline */ double as_double() const { return (double) m_time / (double) RESOLUTION; }
|
||||
|
||||
ATTR_HOT static /* inline */ const netlist_time from_nsec(const int ns) { return netlist_time((UINT64) ns * (RESOLUTION / U64(1000000000))); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_usec(const int us) { return netlist_time((UINT64) us * (RESOLUTION / U64(1000000))); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_msec(const int ms) { return netlist_time((UINT64) ms * (RESOLUTION / U64(1000))); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_hz(const UINT64 hz) { return netlist_time(RESOLUTION / hz); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_double(const double t) { return netlist_time((INTERNALTYPE) ( t * (double) RESOLUTION)); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_raw(const INTERNALTYPE raw) { return netlist_time(raw); }
|
||||
// for save states ....
|
||||
ATTR_HOT /* inline */ INTERNALTYPE *get_internaltype_ptr() { return &m_time; }
|
||||
|
||||
static const netlist_time zero;
|
||||
ATTR_HOT static /* inline */ const netlist_time from_nsec(const int ns) { return netlist_time((UINT64) ns * (RESOLUTION / U64(1000000000))); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_usec(const int us) { return netlist_time((UINT64) us * (RESOLUTION / U64(1000000))); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_msec(const int ms) { return netlist_time((UINT64) ms * (RESOLUTION / U64(1000))); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_hz(const UINT64 hz) { return netlist_time(RESOLUTION / hz); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_double(const double t) { return netlist_time((INTERNALTYPE) ( t * (double) RESOLUTION)); }
|
||||
ATTR_HOT static /* inline */ const netlist_time from_raw(const INTERNALTYPE raw) { return netlist_time(raw); }
|
||||
|
||||
protected:
|
||||
static const netlist_time zero;
|
||||
|
||||
ATTR_HOT /* inline */ netlist_time(const INTERNALTYPE val) : m_time(val) {}
|
||||
protected:
|
||||
|
||||
private:
|
||||
INTERNALTYPE m_time;
|
||||
};
|
||||
ATTR_HOT /* inline */ netlist_time(const INTERNALTYPE val) : m_time(val) {}
|
||||
|
||||
#undef RESOLUTION
|
||||
private:
|
||||
INTERNALTYPE m_time;
|
||||
};
|
||||
|
||||
#undef RESOLUTION
|
||||
|
||||
ATTR_HOT inline const netlist_time operator-(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return netlist_time::from_raw(left.m_time - right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline const netlist_time operator*(const netlist_time &left, const UINT32 factor)
|
||||
{
|
||||
return netlist_time::from_raw(left.m_time * factor);
|
||||
}
|
||||
|
||||
ATTR_HOT inline UINT32 operator/(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return left.m_time / right.m_time;
|
||||
}
|
||||
|
||||
ATTR_HOT inline const netlist_time operator+(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return netlist_time::from_raw(left.m_time + right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator<(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time < right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator>(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time > right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator<=(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time <= right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator>=(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time >= right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator!=(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time != right.m_time);
|
||||
}
|
||||
|
||||
template<> ATTR_COLD inline void pstate_manager_t::save_item(netlist_time &nlt, const void *owner, const pstring &stname)
|
||||
{
|
||||
save_state_ptr(stname, DT_INT64, owner, sizeof(netlist_time::INTERNALTYPE), 1, nlt.get_internaltype_ptr(), false);
|
||||
}
|
||||
|
||||
ATTR_HOT inline const netlist_time operator-(const netlist_time &left, const netlist_time &right)
|
||||
template<> ATTR_COLD inline void pstate_manager_t::save_item(netlist::netlist_time &nlt, const void *owner, const pstring &stname)
|
||||
{
|
||||
return netlist_time::from_raw(left.m_time - right.m_time);
|
||||
save_state_ptr(stname, DT_INT64, owner, sizeof(netlist::netlist_time::INTERNALTYPE), 1, nlt.get_internaltype_ptr(), false);
|
||||
}
|
||||
|
||||
ATTR_HOT inline const netlist_time operator*(const netlist_time &left, const UINT32 factor)
|
||||
{
|
||||
return netlist_time::from_raw(left.m_time * factor);
|
||||
}
|
||||
|
||||
ATTR_HOT inline UINT32 operator/(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return left.m_time / right.m_time;
|
||||
}
|
||||
|
||||
ATTR_HOT inline const netlist_time operator+(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return netlist_time::from_raw(left.m_time + right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator<(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time < right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator>(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time > right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator<=(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time <= right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator>=(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time >= right.m_time);
|
||||
}
|
||||
|
||||
ATTR_HOT inline bool operator!=(const netlist_time &left, const netlist_time &right)
|
||||
{
|
||||
return (left.m_time != right.m_time);
|
||||
}
|
||||
|
||||
#endif /* NLTIME_H_ */
|
||||
|
@ -218,6 +218,20 @@ public:
|
||||
m_list[m_count++] = elem;
|
||||
}
|
||||
|
||||
ATTR_HOT void insert_at(const _ListClass &elem, const std::size_t index)
|
||||
{
|
||||
if (m_count >= m_capacity){
|
||||
std::size_t new_size = m_capacity * 2;
|
||||
if (new_size < 32)
|
||||
new_size = 32;
|
||||
set_capacity(new_size);
|
||||
}
|
||||
for (std::size_t i = m_count; i>index; i--)
|
||||
m_list[i] = m_list[i-1];
|
||||
m_list[index] = elem;
|
||||
m_count++;
|
||||
}
|
||||
|
||||
ATTR_HOT void remove(const _ListClass &elem)
|
||||
{
|
||||
for (std::size_t i = 0; i < m_count; i++)
|
||||
|
@ -70,7 +70,6 @@ NETLIST_SAVE_TYPE(UINT32, DT_INT);
|
||||
NETLIST_SAVE_TYPE(INT32, DT_INT);
|
||||
NETLIST_SAVE_TYPE(UINT16, DT_INT16);
|
||||
NETLIST_SAVE_TYPE(INT16, DT_INT16);
|
||||
//NETLIST_SAVE_TYPE(netlist_time::INTERNALTYPE, DT_INT64);
|
||||
//NETLIST_SAVE_TYPE(std::size_t, DT_INT64);
|
||||
|
||||
class pstate_manager_t;
|
||||
|
@ -183,7 +183,7 @@ public:
|
||||
|
||||
void init()
|
||||
{
|
||||
m_setup = palloc(netlist::netlist_setup_t, this);
|
||||
m_setup = palloc(netlist::setup_t, this);
|
||||
this->init_object(*this, "netlist");
|
||||
m_setup->init();
|
||||
}
|
||||
@ -244,7 +244,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
netlist::netlist_setup_t *m_setup;
|
||||
netlist::setup_t *m_setup;
|
||||
};
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ static void run(tool_options_t &opts)
|
||||
printf("runnning ...\n");
|
||||
t = osd_ticks();
|
||||
|
||||
nt.process_queue(netlist_time::from_double(ttr));
|
||||
nt.process_queue(netlist::netlist_time::from_double(ttr));
|
||||
nt.stop();
|
||||
|
||||
double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
|
||||
@ -292,7 +292,7 @@ static void listdevices()
|
||||
nt.init();
|
||||
const netlist::factory_list_t::list_t &list = nt.setup().factory().list();
|
||||
|
||||
nt.setup().register_source(palloc(netlist::netlist_source_proc_t, "dummy", &netlist_dummy));
|
||||
nt.setup().register_source(palloc(netlist::source_proc_t, "dummy", &netlist_dummy));
|
||||
nt.setup().include("dummy");
|
||||
|
||||
nt.setup().start_devices();
|
||||
|
Loading…
Reference in New Issue
Block a user