Found some cycles. (nw)

This commit is contained in:
couriersud 2015-05-28 22:39:54 +02:00
parent db3feb6c5e
commit e1d1a6b1f2
8 changed files with 71 additions and 45 deletions

View File

@ -1088,12 +1088,3 @@ NETLIB_UPDATE(mainclock)
net.set_time(netlist().time() + m_inc);
}
ATTR_HOT void netlist_base_t::push_to_queue(netlist_net_t &out, const netlist_time &attime)
{
m_queue.push(netlist_queue_t::entry_t(attime, &out));
}
ATTR_HOT void netlist_base_t::remove_from_queue(netlist_net_t &out)
{
m_queue.remove(&out);
}

View File

@ -1419,4 +1419,14 @@ ATTR_HOT inline void netlist_analog_output_t::set_Q(const nl_double newQ)
}
}
ATTR_HOT inline void netlist_base_t::push_to_queue(netlist_net_t &out, const netlist_time &attime)
{
m_queue.push(netlist_queue_t::entry_t(attime, &out));
}
ATTR_HOT inline void netlist_base_t::remove_from_queue(netlist_net_t &out)
{
m_queue.remove(&out);
}
#endif /* NLBASE_H_ */

View File

@ -125,6 +125,7 @@
//============================================================
#if NL_KEEP_STATISTICS
#include "eminline.h"
#define add_to_stat(v,x) do { v += (x); } while (0)
#define inc_stat(v) add_to_stat(v, 1)
#define begin_timing(v) do { v -= get_profile_ticks(); } while (0)

View File

@ -27,20 +27,20 @@ public:
{
public:
ATTR_HOT /* inline */ entry_t()
: m_object(), m_exec_time() {}
ATTR_HOT /* inline */ entry_t(const _Time &atime, const _Element &elem) : m_object(elem), m_exec_time(atime) {}
ATTR_HOT /* inline */ const _Time exec_time() const { return m_exec_time; }
ATTR_HOT /* inline */ const _Element object() const { return m_object; }
: m_exec_time(), m_object() {}
ATTR_HOT /* inline */ entry_t(const _Time &atime, const _Element &elem) : m_exec_time(atime), m_object(elem) {}
ATTR_HOT /* inline */ const _Time &exec_time() const { return m_exec_time; }
ATTR_HOT /* inline */ const _Element &object() const { return m_object; }
ATTR_HOT /* inline */ entry_t &operator=(const entry_t &right) {
m_object = right.m_object;
m_exec_time = right.m_exec_time;
m_object = right.m_object;
return *this;
}
private:
_Element m_object;
_Time m_exec_time;
_Element m_object;
};
netlist_timed_queue()
@ -49,20 +49,21 @@ public:
}
ATTR_HOT /* inline */ int capacity() const { return _Size; }
ATTR_HOT /* inline */ bool is_empty() const { return (m_end == &m_list[0]); }
ATTR_HOT /* inline */ bool is_not_empty() const { return (m_end > &m_list[0]); }
ATTR_HOT /* inline */ bool is_empty() const { return (m_end == &m_list[1]); }
ATTR_HOT /* inline */ bool is_not_empty() const { return (m_end > &m_list[1]); }
ATTR_HOT void push(const entry_t &e)
{
const _Time t = e.exec_time();
entry_t * i = m_end++;
while ((i > &m_list[0]) && (e.exec_time() > (i - 1)->exec_time()) )
while (t > (i - 1)->exec_time())
{
*(i) = *(i-1);
i--;
inc_stat(m_prof_sortmove);
}
*i = e;
inc_stat(m_prof_sort);
inc_stat(m_prof_call);
//nl_assert(m_end - m_list < _Size);
}
@ -98,6 +99,12 @@ public:
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
@ -108,10 +115,8 @@ public:
#if (NL_KEEP_STATISTICS)
// profiling
INT32 m_prof_start;
INT32 m_prof_end;
INT32 m_prof_sortmove;
INT32 m_prof_sort;
INT32 m_prof_call;
#endif
private:

View File

@ -787,15 +787,13 @@ void netlist_setup_t::print_stats() const
{
#if (NL_KEEP_STATISTICS)
{
for (netlist_core_device_t * const *entry = netlist().m_started_devices.first(); entry != NULL; entry = netlist().m_started_devices.next(entry))
for (std::size_t i = 0; i < netlist().m_started_devices.size(); i++)
{
//entry->object()->s
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));
netlist_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 Start %15d\n", m_netlist.queue().m_prof_start);
printf("Queue End %15d\n", m_netlist.queue().m_prof_end);
printf("Queue Sort %15d\n", m_netlist.queue().m_prof_sort);
printf("Queue Move %15d\n", m_netlist.queue().m_prof_sortmove);
printf("Queue Pushes %15d\n", m_netlist.queue().m_prof_call);
printf("Queue Moves %15d\n", m_netlist.queue().m_prof_sortmove);
}
#endif
}

View File

@ -70,6 +70,7 @@ protected:
ATTR_HOT inline netlist_time(const INTERNALTYPE val) : m_time(val) {}
private:
INTERNALTYPE m_time;
};

View File

@ -158,8 +158,8 @@ CIRCUIT_LAYOUT( breakout )
* ^--- Pattern Start
* <--------> 3 Clocks Offset
*/
EXTCLOCK(Y1, 14318000.0, "4,4,4,4,4,8")
EXTCLOCK(Y2, 14318000.0, "2,6,2,6,2,2,2,6")
EXTCLOCK(Y1, 14318000.0, "4,4,4,4,4,8")
PARAM(Y2.OFFSET, 3.0 / 14318000.0 + 20.0e-9 )
#define CKBH "Y1", Q
#define DICECLOCK "Y2", Q

View File

@ -361,6 +361,8 @@ public:
// Add gnd net
// FIXME: Parameter
out("NETLIST_START(dummy)\n");
nets.add(palloc(sp_net_t, "0"), false);
nets[0]->terminals().add("GND");
@ -380,6 +382,9 @@ public:
}
process_line(line);
dump_nl();
// FIXME: Parameter
out("NETLIST_END()\n");
printf("%s", m_buf.cstr());
}
protected:
@ -494,7 +499,7 @@ protected:
{
sp_net_t *net = nets.find(alias[i]);
// use the first terminal ...
printf("ALIAS(%s, %s)\n", alias[i].cstr(), net->terminals()[0].cstr());
out("ALIAS(%s, %s)\n", alias[i].cstr(), net->terminals()[0].cstr());
// if the aliased net only has this one terminal connected ==> don't dump
if (net->terminals().size() == 1)
net->set_no_export();
@ -502,13 +507,13 @@ protected:
for (int i=0; i<devs.size(); i++)
{
if (devs[i]->has_value())
printf("%s(%s, %s)\n", devs[i]->type().cstr(),
out("%s(%s, %s)\n", devs[i]->type().cstr(),
devs[i]->name().cstr(), get_nl_val(devs[i]->value()).cstr());
else if (devs[i]->has_model())
printf("%s(%s, \"%s\")\n", devs[i]->type().cstr(),
out("%s(%s, \"%s\")\n", devs[i]->type().cstr(),
devs[i]->name().cstr(), devs[i]->model().cstr());
else
printf("%s(%s)\n", devs[i]->type().cstr(),
out("%s(%s)\n", devs[i]->type().cstr(),
devs[i]->name().cstr());
}
// print nets
@ -518,12 +523,12 @@ protected:
if (!net->is_no_export())
{
//printf("Net %s\n", net->name().cstr());
printf("NET_C(%s", net->terminals()[0].cstr() );
out("NET_C(%s", net->terminals()[0].cstr() );
for (int j=1; j<net->terminals().size(); j++)
{
printf(", %s", net->terminals()[j].cstr() );
out(", %s", net->terminals()[j].cstr() );
}
printf(")\n");
out(")\n");
}
}
devs.clear_and_free();
@ -540,25 +545,25 @@ protected:
switch (tt[0].cstr()[0])
{
case ';':
printf("// %s\n", line.substr(1).cstr());
out("// %s\n", line.substr(1).cstr());
break;
case '*':
printf("// %s\n", line.substr(1).cstr());
out("// %s\n", line.substr(1).cstr());
break;
case '.':
if (tt[0].equals(".SUBCKT"))
{
printf("NETLIST_START(%s)\n", tt[1].cstr());
out("NETLIST_START(%s)\n", tt[1].cstr());
for (int i=2; i<tt.size(); i++)
alias.add(tt[i]);
}
else if (tt[0].equals(".ENDS"))
{
dump_nl();
printf("NETLIST_END()\n");
out("NETLIST_END()\n");
}
else
printf("// %s\n", line.cstr());
out("// %s\n", line.cstr());
break;
case 'Q':
{
@ -607,32 +612,47 @@ protected:
add_term(tt[1], tt[0] + ".A");
add_term(tt[2], tt[0] + ".K");
break;
case 'U':
case 'X':
{
// FIXME: specific code for KICAD exports
// last element is component type
// FIXME: Parameter
pstring xname = tt[0].replace(".", "_");
pstring tname = "TTL_" + tt[tt.size()-1] + "_DIP";
devs.add(palloc(sp_dev_t, tname, tt[0]), false);
devs.add(palloc(sp_dev_t, tname, xname), false);
for (int i=1; i < tt.size() - 1; i++)
{
pstring term = pstring::sprintf("%s.%d", tt[0].cstr(), i);
pstring term = pstring::sprintf("%s.%d", xname.cstr(), i);
add_term(tt[i], term);
}
break;
}
default:
printf("// IGNORED %s: %s\n", tt[0].cstr(), line.cstr());
pstring::sprintf("// IGNORED %s: %s\n", tt[0].cstr(), line.cstr());
}
}
}
void out(const char *format, ...) ATTR_PRINTF(2,3)
{
va_list ap;
va_start(ap, format);
m_buf += pstring(format).vprintf(ap);
va_end(ap);
}
private:
pnamedlist_t<sp_net_t *> nets;
pnamedlist_t<sp_dev_t *> devs;
plist_t<pstring> alias;
pstringbuffer m_buf;
static sp_unit m_sp_units[];
};
convert_t::sp_unit convert_t::m_sp_units[] = {