Previous 199869 Revisions Next

r29621 Sunday 13th April, 2014 at 22:08:49 UTC by Couriersud
Netlist: All analysis is now based on an immutable list of terminals. The dynamic list now is only used in the "hot" core. This is the base for possible further optimizations using multiple lists; e.g. a high-low transition list and a low-high transition list. [Couriersud]
[src/emu/netlist]nl_base.c nl_base.h nl_lists.h nl_setup.c
[src/emu/netlist/analog]nld_solver.c

trunk/src/emu/netlist/nl_base.h
r29620r29621
625625
626626   ATTR_HOT void solve();
627627
628   netlist_list_t<netlist_core_terminal_t *> m_registered; // save post-start m_list ...
629   plinked_list<netlist_core_terminal_t> m_list;
628   netlist_list_t<netlist_core_terminal_t *> m_core_terms; // save post-start m_list ...
629   plinked_list<netlist_core_terminal_t> m_list_active;
630630
631631   ATTR_COLD void rebuild_list();     /* rebuild m_list after a load */
632632
trunk/src/emu/netlist/analog/nld_solver.c
r29620r29621
3232
3333      (*pn)->m_solver = this;
3434
35      for (netlist_core_terminal_t *p = (*pn)->m_list.first(); p != NULL; p = (*pn)->m_list.next(p))
35        for (int i = 0; i < (*pn)->m_core_terms.count(); i++)
3636      {
37          netlist_core_terminal_t *p = (*pn)->m_core_terms[i];
3738         NL_VERBOSE_OUT(("%s %s %d\n", p->name().cstr(), (*pn)->name().cstr(), (int) (*pn)->isRailNet()));
3839         switch (p->type())
3940         {
r29620r29621
8990   }
9091   for (netlist_core_terminal_t * const *p = m_inps.first(); p != NULL; p = m_inps.next(p))
9192   {
92      (*p)->net().m_last_Analog = (*p)->net().m_cur_Analog;
93        if ((*p)->net().m_last_Analog != (*p)->net().m_cur_Analog)
94            (*p)->net().m_last_Analog = (*p)->net().m_cur_Analog;
9395   }
9496
9597}
r29620r29621
625627
626628ATTR_COLD static void process_net(net_groups_t groups, int &cur_group, netlist_net_t *net)
627629{
628   if (net->m_list.is_empty())
630   if (net->m_core_terms.is_empty())
629631      return;
630632   /* add the net */
631633   SOLVER_VERBOSE_OUT(("add %d - %s\n", cur_group, net->name().cstr()));
632634   groups[cur_group].add(net);
633   for (netlist_core_terminal_t *p = net->m_list.first(); p != NULL; p = net->m_list.next(p))
635   for (int i = 0; i < net->m_core_terms.count(); i++)
634636   {
635      SOLVER_VERBOSE_OUT(("terminal %s\n", p->name().cstr()));
637       netlist_core_terminal_t *p = net->m_core_terms[i];
638       SOLVER_VERBOSE_OUT(("terminal %s\n", p->name().cstr()));
636639      if (p->isType(netlist_terminal_t::TERMINAL))
637640      {
638641         SOLVER_VERBOSE_OUT(("isterminal\n"));
r29620r29621
853856      {
854857         SOLVER_VERBOSE_OUT(("Net %d: %s\n", j, groups[i][j]->name().cstr()));
855858         netlist_net_t *n = groups[i][j];
856         for (netlist_core_terminal_t *p = n->m_list.first(); p != NULL; p = n->m_list.next(p))
859         for (int k = 0; k < n->m_core_terms.count(); k++)
857860         {
861             ATTR_UNUSED netlist_core_terminal_t *p = n->m_core_terms[k];
858862            SOLVER_VERBOSE_OUT(("   %s\n", p->name().cstr()));
859863         }
860864      }
trunk/src/emu/netlist/nl_setup.c
r29620r29621
402402#if 1
403403      /* connect all existing terminals to new net */
404404
405      netlist_core_terminal_t *p = out.net().m_list.first();
406      while (p != NULL)
405      for (int i = 0; i < out.net().m_core_terms.count(); i++)
407406      {
408         netlist_core_terminal_t *np = out.net().m_list.next(p);
407           netlist_core_terminal_t *p = out.net().m_core_terms[i];
409408         p->clear_net(); // de-link from all nets ...
410409         connect(proxy->out(), *p);
411         p = np;
412410      }
413      out.net().m_list.clear(); // clear the list
411      out.net().m_core_terms.clear(); // clear the list
414412      out.net().m_num_cons = 0;
415413#endif
416414      out.net().register_con(proxy->m_I);
r29620r29621
620618
621619   for (netlist_net_t *const *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
622620   {
623      if ((*pn)->m_list.is_empty())
621      if ((*pn)->m_core_terms.is_empty())
624622      {
625623         todelete.add(*pn);
626624      }
627625      else
628626      {
627#if 0
629628         for (netlist_core_terminal_t *p = (*pn)->m_list.first(); p != NULL; p = (*pn)->m_list.next(p))
630629            (*pn)->m_registered.add(p);
630#else
631         (*pn)->rebuild_list();
632#endif
631633      }
632634   }
633635
trunk/src/emu/netlist/nl_lists.h
r29620r29621
4242
4343   ATTR_COLD netlist_list_t &operator=(const netlist_list_t &rhs)
4444   {
45      this->reset();
45      this->clear();
4646      for (int i=0; i<rhs.count(); i++)
4747      {
4848         this->add(rhs[i]);
r29620r29621
129129   ATTR_HOT inline const _ListClass *next(const _ListClass *lc) const { return ((lc < last()) ? lc + 1 : NULL ); }
130130   ATTR_HOT inline const _ListClass *last() const { return &m_list[m_count -1]; }
131131   ATTR_HOT inline int count() const { return m_count; }
132   ATTR_HOT inline bool empty() const { return (m_count == 0); }
132   ATTR_HOT inline bool is_empty() const { return (m_count == 0); }
133133   ATTR_HOT inline void clear() { m_count = 0; }
134134   ATTR_HOT inline int capacity() const { return m_num_elements; }
135135
trunk/src/emu/netlist/nl_base.c
r29620r29621
496496
497497   if (USE_ADD_REMOVE_LIST)
498498   {
499      m_list.insert(term);
499      m_list_active.insert(term);
500500      //m_list.add(term);
501501   }
502502
r29620r29621
534534
535535   if (USE_ADD_REMOVE_LIST)
536536   {
537      m_list.remove(term);
537      m_list_active.remove(term);
538538   }
539539
540540   if (USE_DEACTIVE_DEVICE)
r29620r29621
548548{
549549   /* rebuild m_list */
550550
551   m_list.clear();
552   for (int i=0; i < m_registered.count(); i++)
553      if (m_registered[i]->state() != netlist_input_t::STATE_INP_PASSIVE)
554         m_list.add(*m_registered[i]);
551   m_list_active.clear();
552   for (int i=0; i < m_core_terms.count(); i++)
553      if (m_core_terms[i]->state() != netlist_input_t::STATE_INP_PASSIVE)
554         m_list_active.add(*m_core_terms[i]);
555555}
556556
557557ATTR_COLD void netlist_net_t::reset()
r29620r29621
568568
569569   /* rebuild m_list */
570570
571   m_list.clear();
572   for (int i=0; i < m_registered.count(); i++)
573      m_list.add(*m_registered[i]);
571   m_list_active.clear();
572   for (int i=0; i < m_core_terms.count(); i++)
573      m_list_active.add(*m_core_terms[i]);
574574
575   for (netlist_core_terminal_t *t = m_list.first(); t != NULL; t = m_list.next(t))
576   {
577      t->do_reset();
578   }
579   for (netlist_core_terminal_t *t = m_list.first(); t != NULL; t = m_list.next(t))
580   {
581      if (t->state() != netlist_input_t::STATE_INP_PASSIVE)
582         m_active++;
583   }
575    for (int i=0; i < m_core_terms.count(); i++)
576        m_core_terms[i]->do_reset();
577
578    for (int i=0; i < m_core_terms.count(); i++)
579        if (m_core_terms[i]->state() != netlist_input_t::STATE_INP_PASSIVE)
580            m_active++;
584581}
585582
586583ATTR_COLD void netlist_net_t::init_object(netlist_base_t &nl, const pstring &aname)
r29620r29621
625622   }
626623   else
627624   {
628      netlist_core_terminal_t *p = othernet->m_list.first();
629      while (p != NULL)
625       for (int i = 0; i < othernet->m_core_terms.count(); i++)
630626      {
631         netlist_core_terminal_t *pn = othernet->m_list.next(p);
627           netlist_core_terminal_t *p = othernet->m_core_terms[i];
632628         register_con(*p);
633         p = pn;
634629      }
635630
636      othernet->m_list.clear(); // FIXME: othernet needs to be free'd from memory
631      othernet->m_core_terms.clear(); // FIXME: othernet needs to be free'd from memory
637632   }
638633}
639634
r29620r29621
641636{
642637   terminal.set_net(*this);
643638
644   m_list.insert(terminal);
639   m_core_terms.add(&terminal);
645640   m_num_cons++;
646641
647642   if (terminal.state() != netlist_input_t::STATE_INP_PASSIVE)
r29620r29621
667662
668663   const UINT32 masks[4] = { 1, 5, 3, 1 };
669664   const UINT32 mask = masks[ (m_last_Q  << 1) | m_new_Q ];
670   netlist_core_terminal_t *p = m_list.first();
665   netlist_core_terminal_t *p = m_list_active.first();
671666
672667   m_in_queue = 2; /* mark as taken ... */
673668   m_cur_Q = m_new_Q;
r29620r29621
680675      {
681676      case 2:
682677         update_dev(p, mask);
683         p = m_list.next(p);
678         p = m_list_active.next(p);
684679         if (p == NULL) break;
685680      case 1:
686681         update_dev(p, mask);
r29620r29621
689684         while (p != NULL)
690685         {
691686            update_dev(p, mask);
692            p = m_list.next(p);
687            p = m_list_active.next(p);
693688         }
694689         break;
695690      }
r29620r29621
700695      {
701696      case 2:
702697         update_dev(p, mask);
703         p = m_list.next(p);
698         p = m_list_active.next(p);
704699      case 1:
705700         update_dev(p, mask);
706701         break;
r29620r29621
708703         do
709704         {
710705            update_dev(p, mask);
711            p = m_list.next(p);
706            p = m_list_active.next(p);
712707         } while (p != NULL);
713708         break;
714709      }

Previous 199869 Revisions Next


© 1997-2024 The MAME Team