Previous 199869 Revisions Next

r26875 Wednesday 1st January, 2014 at 18:56:14 UTC by Couriersud
Minor modifications to the netlist code. No wn
[src/emu/machine]netlist.c netlist.h
[src/emu/netlist]nl_base.c nl_base.h nl_config.h nl_lists.h nl_parser.c nl_setup.c
[src/emu/netlist/devices]net_lib.c nld_signal.h nld_solver.c
[src/mame/drivers]pong.c

trunk/src/mame/drivers/pong.c
r26874r26875
461461   TTL_7402_NOR(ic_d2c, ic_e3c.Q, ic_e3b.Q)
462462   TTL_7404_INVERT(ic_g1a, 32V)
463463   TTL_7425_NOR(ic_f2a, ic_g1a.Q, 64V, 128V, ic_d2c.Q)
464   NET_ALIAS(c5-en, ic_f2a.Q)
464   NET_ALIAS(c5_en, ic_f2a.Q)
465465
466466   // ----------------------------------------------------------------------------------------
467467   // Score logic ...
r26874r26875
507507   TTL_74153(ic_c6a, high, score1_1, high, score2_1, 32H, 64H, low)
508508   TTL_74153(ic_c6b, score1_10Q, score1_2, score2_10Q, score2_2, 32H, 64H, low)
509509
510   TTL_7448(ic_c5, ic_c6a.AY, ic_c6b.AY, ic_d6a.AY, ic_d6b.AY, high, c5-en, high)
510   TTL_7448(ic_c5, ic_c6a.AY, ic_c6b.AY, ic_d6a.AY, ic_d6b.AY, high, c5_en, high)
511511
512512   TTL_7404_INVERT(ic_e4b, 16H)
513513   TTL_7427_NOR(ic_e5c, ic_e4b.Q, 8H, 4H)
r26874r26875
592592   required_device<netlist_mame_logic_input_t> m_sw1a;
593593   required_device<netlist_mame_logic_input_t> m_sw1b;
594594
595   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
595   //UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
596596
597597   DECLARE_INPUT_CHANGED_MEMBER(input_changed);
598598
r26874r26875
677677   PORT_ADJUSTER( 50, "VR1 - 50k, Paddle 1 adjustment" )   NETLIST_ANALOG_PORT_CHANGED("maincpu", "vr0")
678678   PORT_START("VR2")
679679   PORT_ADJUSTER( 50, "VR2 - 50k, Paddle 2 adjustment" )   NETLIST_ANALOG_PORT_CHANGED("maincpu", "vr1")
680   //PORT_START("GATESPEED")
681   //PORT_ADJUSTER( 100, "Logic Gate Delay" ) PORT_MINMAX(10, 200) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_GATEDELAY)
682680
683681INPUT_PORTS_END
684682
trunk/src/emu/machine/netlist.c
r26874r26875
302302         case DT_CUSTOM:
303303         case NOT_SUPPORTED:
304304         default:
305            netlist().xfatalerror("found unsupported save element %s\n", s->m_name.cstr());
305            netlist().error("found unsupported save element %s\n", s->m_name.cstr());
306306            break;
307307      }
308308   }
r26874r26875
373373   {
374374      //            sprintf(buffer, "%04x %02d %s", pc, relpc, netlist().queue()[netlist().queue().count() - relpc - 1].object().name().cstr());
375375      int dpc = netlist().queue().count() - relpc - 1;
376      sprintf(buffer, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].object().name().cstr(),
376      sprintf(buffer, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', netlist().queue()[dpc].object()->name().cstr(),
377377            netlist().queue()[dpc].time().as_double());
378378   }
379379   else
trunk/src/emu/machine/netlist.h
r26874r26875
365365{
366366public:
367367   NETLIB_NAME(analog_callback)()
368      : netlist_device_t() { }
368      : netlist_device_t(), m_cpu_device(NULL) { }
369369
370370   ATTR_COLD void start()
371371   {
r26874r26875
414414      netlist_time current = netlist().time();
415415      int pos = (current - m_last_buffer) / m_sample;
416416      if (pos >= BUFSIZE)
417         netlist().xfatalerror("sound %s: exceeded BUFSIZE\n", name().cstr());
417         netlist().error("sound %s: exceeded BUFSIZE\n", name().cstr());
418418      while (m_last_pos < pos )
419419      {
420420         m_buffer[m_last_pos++] = m_cur;
trunk/src/emu/netlist/nl_parser.c
r26874r26875
2929        buf[bufp++] = *p++;
3030    buf[bufp] = 0;
3131
32    m_setup.netlist().xfatalerror("line %d: error: %s\n\t\t%s\n", m_line, errmsg1.cstr(), buf);
32    m_setup.netlist().error("line %d: error: %s\n\t\t%s\n", m_line, errmsg1.cstr(), buf);
3333
3434    //throw error;
3535}
r26874r26875
317317double netlist_parser::eval_param()
318318{
319319   static const char *macs[6] = {"", "RES_K(", "RES_M(", "CAP_U(", "CAP_N(", "CAP_P("};
320   static const char *allowed = "RESKMUNPAC_0123456789E+-.";
320   static const char *allowed = "RESKMUNPAC_0123456789E(+-.";
321321   static double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12};
322322   int i;
323323   int f=0;
trunk/src/emu/netlist/nl_setup.c
r26874r26875
6060netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const pstring &name)
6161{
6262   if (!(netlist().m_devices.add(name, dev, false)==TMERR_NONE))
63      netlist().xfatalerror("Error adding %s to device list\n", name.cstr());
63      netlist().error("Error adding %s to device list\n", name.cstr());
6464   return dev;
6565}
6666
r26874r26875
8686   netlist_device_t *dev = netlist().m_devices.find(name);
8787   pstring temp = name + ".";
8888   if (dev == NULL)
89      netlist().xfatalerror("Device %s does not exist\n", name.cstr());
89      netlist().error("Device %s does not exist\n", name.cstr());
9090
9191   //remove_start_with<tagmap_input_t>(m_inputs, temp);
9292   remove_start_with<tagmap_terminal_t>(m_terminals, temp);
r26874r26875
112112{
113113   //if (!(m_alias.add(alias, new nstring(out), false)==TMERR_NONE))
114114   if (!(m_alias.add(alias, out, false)==TMERR_NONE))
115      netlist().xfatalerror("Error adding alias %s to alias list\n", alias.cstr());
115      netlist().error("Error adding alias %s to alias list\n", alias.cstr());
116116}
117117
118118pstring netlist_setup_t::objtype_as_astr(netlist_object_t &in)
r26874r26875
142142         break;
143143   }
144144   // FIXME: noreturn
145   netlist().xfatalerror("Unknown object type %d\n", in.type());
145   netlist().error("Unknown object type %d\n", in.type());
146146   return "Error";
147147}
148148
r26874r26875
161161               term.init_object(upd_dev, dev.name() + "." + name, state);
162162
163163            if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE))
164               netlist().xfatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr());
164               netlist().error("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr());
165165            NL_VERBOSE_OUT(("%s %s\n", objtype_as_astr(term).cstr(), name.cstr()));
166166         }
167167         break;
r26874r26875
180180                     NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()));
181181                     double vald = 0;
182182                     if (sscanf(val.cstr(), "%lf", &vald) != 1)
183                        netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
183                        netlist().error("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
184184                     dynamic_cast<netlist_param_double_t &>(param).initial(vald);
185185                  }
186186                  break;
r26874r26875
190190                     NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", name.cstr(), val->cstr()));
191191                     int vald = 0;
192192                     if (sscanf(val.cstr(), "%d", &vald) != 1)
193                        netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
193                        netlist().error("Invalid number conversion %s : %s\n", name.cstr(), val.cstr());
194194                     dynamic_cast<netlist_param_int_t &>(param).initial(vald);
195195                  }
196196                  break;
r26874r26875
215215                        }
216216                     }
217217                     if (!found)
218                        netlist().xfatalerror("Model %s not found\n", val.cstr());
218                        netlist().error("Model %s not found\n", val.cstr());
219219                  }
220220                  break;
221221                  default:
222                     netlist().xfatalerror("Parameter is not supported %s : %s\n", name.cstr(), val.cstr());
222                     netlist().error("Parameter is not supported %s : %s\n", name.cstr(), val.cstr());
223223               }
224224            }
225225            if (!(m_params.add(name, &param, false)==TMERR_NONE))
226               netlist().xfatalerror("Error adding parameter %s to parameter list\n", name.cstr());
226               netlist().error("Error adding parameter %s to parameter list\n", name.cstr());
227227         }
228228         break;
229229      case netlist_terminal_t::DEVICE:
230         netlist().xfatalerror("Device registration not yet supported - \n", name.cstr());
230         netlist().error("Device registration not yet supported - \n", name.cstr());
231231         break;
232232      case netlist_terminal_t::NETLIST:
233         netlist().xfatalerror("Netlist registration not yet supported - \n", name.cstr());
233         netlist().error("Netlist registration not yet supported - \n", name.cstr());
234234         break;
235235   }
236236}
r26874r26875
254254{
255255   //if (!(m_params_temp.add(param, new nstring(value), false)==TMERR_NONE))
256256   if (!(m_params_temp.add(param, value, false)==TMERR_NONE))
257      netlist().xfatalerror("Error adding parameter %s to parameter list\n", param.cstr());
257      netlist().error("Error adding parameter %s to parameter list\n", param.cstr());
258258}
259259
260260const pstring netlist_setup_t::resolve_alias(const pstring &name) const
r26874r26875
274274      pstring dname = ret;
275275      netlist_device_t *dev = netlist().m_devices.find(dname.substr(0,p));
276276      if (dev == NULL)
277         netlist().xfatalerror("Device for %s not found\n", name.cstr());
277         netlist().error("Device for %s not found\n", name.cstr());
278278      int c = atoi(ret.substr(p+2,ret.len()-p-3));
279279      temp = dev->name() + "." + dev->m_terminals[c];
280280      // reresolve ....
r26874r26875
302302      ret = m_terminals.find(s);
303303   }
304304   if (ret == NULL && required)
305      netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
305      netlist().error("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
306306   if (ret != NULL)
307307      NL_VERBOSE_OUT(("Found input %s\n", tname.cstr()));
308308   return ret;
r26874r26875
322322      ret = m_terminals.find(s);
323323   }
324324   if (ret == NULL && required)
325      netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
325      netlist().error("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
326326   if (ret != NULL && ret->type() != atype)
327327   {
328328      if (required)
329         netlist().xfatalerror("object %s(%s) found but wrong type\n", terminal_in.cstr(), tname.cstr());
329         netlist().error("object %s(%s) found but wrong type\n", terminal_in.cstr(), tname.cstr());
330330      else
331331         ret = NULL;
332332   }
r26874r26875
342342
343343   ret = m_params.find(outname);
344344   if (ret == NULL && required)
345      netlist().xfatalerror("parameter %s(%s) not found!\n", param_in.cstr(), outname.cstr());
345      netlist().error("parameter %s(%s) not found!\n", param_in.cstr(), outname.cstr());
346346   if (ret != NULL)
347347      NL_VERBOSE_OUT(("Found parameter %s\n", outname.cstr()));
348348   return ret;
r26874r26875
408408   }
409409   else
410410   {
411      netlist().xfatalerror("Netlist: Severe Error");
411      netlist().error("Netlist: Severe Error");
412412   }
413413}
414414
r26874r26875
443443   }
444444   else
445445   {
446      netlist().xfatalerror("Netlist: Severe Error");
446      netlist().error("Netlist: Severe Error");
447447   }
448448}
449449
r26874r26875
518518      connect_terminals(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_terminal_t &>(t2));
519519   }
520520   else
521      netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr());
521      netlist().error("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr());
522522}
523523
524524void netlist_setup_t::resolve_inputs()
r26874r26875
570570    for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry))
571571    {
572572        if (!entry->object()->has_net())
573            netlist().xfatalerror("Found terminal %s without a net\n",
573            netlist().error("Found terminal %s without a net\n",
574574                    entry->object()->name().cstr());
575575    }
576576
r26874r26875
583583        {
584584            has_twoterms = true;
585585            if (t->m_N.net().isRailNet() && t->m_P.net().isRailNet())
586                netlist().xfatalerror("Found device %s connected only to railterminals %s/%s\n",
586                netlist().error("Found device %s connected only to railterminals %s/%s\n",
587587                        t->name().cstr(), t->m_N.net().name().cstr(), t->m_P.net().name().cstr());
588588        }
589589    }
r26874r26875
593593   if (m_netlist.solver() == NULL)
594594   {
595595       if (!has_twoterms)
596           netlist().xfatalerror("No solver found for this net although analog elements are present\n");
596           netlist().error("No solver found for this net although analog elements are present\n");
597597   }
598598   else
599599      m_netlist.solver()->post_start();
r26874r26875
629629      if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL)
630630      {
631631          if (has_mainclock)
632              m_netlist.xfatalerror("Found more than one mainclock");
632              m_netlist.error("Found more than one mainclock");
633633         m_netlist.set_mainclock_dev(dynamic_cast<NETLIB_NAME(mainclock)*>(dev));
634634         has_mainclock = true;
635635      }
636636      if (dynamic_cast<NETLIB_NAME(solver)*>(dev) != NULL)
637637      {
638638          if (has_solver)
639                m_netlist.xfatalerror("Found more than one solver");
639                m_netlist.error("Found more than one solver");
640640         m_netlist.set_solver_dev(dynamic_cast<NETLIB_NAME(solver)*>(dev));
641641         has_solver = true;
642642      }
trunk/src/emu/netlist/nl_lists.h
r26874r26875
3737
3838   ATTR_COLD netlist_list_t(const netlist_list_t &rhs)
3939   {
40       m_num_elements = rhs.capacity();
4041      m_list = new entry_t[m_num_elements];
4142      m_ptr = m_list;
4243      m_ptr--;
r26874r26875
6061   {
6162      delete[] m_list;
6263   }
64
6365   ATTR_HOT inline void add(const _ListClass elem)
6466   {
6567      if (m_ptr-m_list >= m_num_elements - 1)
r26874r26875
6769
6870      (++m_ptr)->m_obj = elem;
6971   }
72
7073   ATTR_HOT inline void resize(const int new_size)
7174   {
7275      int cnt = count();
r26874r26875
8083      m_ptr = m_list + cnt - 1;
8184      m_num_elements = new_size;
8285   }
86
8387   ATTR_HOT inline void remove(const _ListClass elem)
8488   {
8589      for (entry_t *i = m_list; i <= m_ptr; i++)
r26874r26875
96100         }
97101      }
98102   }
103
99104   ATTR_HOT inline bool contains(const _ListClass elem) const
100105   {
101106      for (entry_t *i = m_list; i <= m_ptr; i++)
r26874r26875
105110      }
106111      return false;
107112   }
113
108114   ATTR_HOT inline entry_t *first() const { return (m_ptr >= m_list ? &m_list[0] : NULL ); }
109115   ATTR_HOT inline entry_t *next(entry_t *lc) const { return (lc < last() ? lc + 1 : NULL ); }
110116   ATTR_HOT inline entry_t *last() const { return m_ptr; }
111117   ATTR_HOT inline int count() const { return m_ptr - m_list + 1; }
112118   ATTR_HOT inline bool empty() const { return (m_ptr < m_list); }
113119   ATTR_HOT inline void reset() { m_ptr = m_list - 1; }
120    ATTR_HOT inline int capacity() const { return m_num_elements; }
114121
115122   ATTR_COLD void reset_and_free()
116123   {
r26874r26875
121128      reset();
122129   }
123130
124   //ATTR_HOT inline entry_t *item(int i) const { return &m_list[i]; }
125131   ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index].m_obj; }
126132   ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index].m_obj; }
127133
r26874r26875
145151   struct entry_t
146152   {
147153   public:
148      inline entry_t()
149      : m_time(), m_object(NULL) {}
150      inline entry_t(const _Time atime, _Element &elem) : m_time(atime), m_object(&elem) {}
151      ATTR_HOT inline const _Time &time() const { return m_time; }
152      ATTR_HOT inline _Element & object() const { return *m_object; }
154      ATTR_HOT inline entry_t()
155      : m_time(), m_object() {}
156      ATTR_HOT inline entry_t(const _Time atime, _Element elem) : m_time(atime), m_object(elem) {}
157      ATTR_HOT inline _Time time() const { return m_time; }
158      ATTR_HOT inline _Element object() const { return m_object; }
153159
154      ATTR_HOT inline const _Time *time_ptr() const { return &m_time; }
155      ATTR_HOT inline _Element *object_ptr() const { return m_object; }
156160   private:
157161      _Time m_time;
158      _Element *m_object;
162      _Element m_object;
159163   };
160164
161165   netlist_timed_queue()
r26874r26875
168172   ATTR_HOT inline bool is_empty() const { return (m_end == &m_list[0]); }
169173   ATTR_HOT inline bool is_not_empty() const { return (m_end > &m_list[0]); }
170174
171   ATTR_HOT ATTR_ALIGN inline void push(const entry_t &e)
175   ATTR_HOT ATTR_ALIGN void push(const entry_t &e)
172176   {
173      if (is_empty() || (e.time() <= (m_end - 1)->time()))
177#if 0
178       // less is more
179       if (is_empty() || (e.time() <= (m_end - 1)->time()))
174180      {
175181         *m_end++ = e;
176182         inc_stat(m_prof_end);
177183      }
178184      else
185#endif
179186      {
180187         entry_t * RESTRICT i = m_end++;
181         while ((i>&m_list[0]) && (e.time() > (i-1)->time()) )
188         while ((i > &m_list[0]) && (e.time() > (i - 1)->time()) )
182189         {
183            i--;
190             i--;
184191            *(i+1) = *i;
185192            inc_stat(m_prof_sortmove);
186193         }
r26874r26875
190197      assert(m_end - m_list < _Size);
191198   }
192199
193   ATTR_HOT inline const entry_t &pop()
200   ATTR_HOT inline entry_t pop()
194201   {
195202      return *--m_end;
196203   }
r26874r26875
207214
208215   // save state support & mame disasm
209216
210   ATTR_COLD entry_t *listptr() { return &m_list[0]; }
211   ATTR_COLD int count() const { return m_end - m_list; }
212   ATTR_HOT inline entry_t & operator[](const int & index) { return m_list[index]; }
217   ATTR_COLD inline const entry_t *listptr() const { return &m_list[0]; }
218   ATTR_HOT inline int count() const { return m_end - m_list; }
219   ATTR_HOT inline const entry_t & operator[](const int & index) const { return m_list[index]; }
213220
214221#if (NL_KEEP_STATISTICS)
215222   // profiling
trunk/src/emu/netlist/devices/nld_solver.c
r26874r26875
5252               NL_VERBOSE_OUT(("Added input\n"));
5353               break;
5454            default:
55               owner().netlist().xfatalerror("unhandled element found\n");
55               owner().netlist().error("unhandled element found\n");
5656               break;
5757         }
5858      }
trunk/src/emu/netlist/devices/net_lib.c
r26874r26875
291291      }
292292      p++;
293293   }
294   setup.netlist().xfatalerror("Class %s not found!\n", classname.cstr());
294   setup.netlist().error("Class %s not found!\n", classname.cstr());
295295   return NULL; // appease code analysis
296296}
297297
r26874r26875
307307      }
308308      p++;
309309   }
310   setup.netlist().xfatalerror("Class %s not found!\n", name.cstr());
310   setup.netlist().error("Class %s not found!\n", name.cstr());
311311   return NULL; // appease code analysis
312312}
trunk/src/emu/netlist/devices/nld_signal.h
r26874r26875
4949#if (USE_DEACTIVE_DEVICE)
5050   ATTR_HOT void inc_active()
5151   {
52      if (m_active == 0)
52      if (++m_active == 1)
5353      {
5454         update();
5555      }
56      m_active++;
5756   }
5857
5958   ATTR_HOT void dec_active()
6059   {
61      m_active--;
62      if (m_active == 0)
60      if (--m_active == 0)
6361      {
6462         for (int i = 0; i< _numdev; i++)
6563            m_i[i].inactivate();
r26874r26875
9997   #if (USE_DEACTIVE_DEVICE)
10098      ATTR_HOT void inc_active()
10199      {
102         if (m_active == 0)
100         if (++m_active == 1)
103101         {
104102            update();
105103         }
106         m_active++;
107104      }
108105
109106      ATTR_HOT void dec_active()
110107      {
111         m_active--;
112         if (m_active == 0)
108         if (--m_active == 0)
113109         {
114110            for (int i = 0; i< _numdev; i++)
115111               m_i[i].inactivate();
r26874r26875
173169   #if (USE_DEACTIVE_DEVICE)
174170      ATTR_HOT void inc_active()
175171      {
176         if (m_active == 0)
172         if (++m_active == 1)
177173         {
178174            update();
179175         }
180         m_active++;
181176      }
182177
183178      ATTR_HOT void dec_active()
184179      {
185         m_active--;
186         if (m_active == 0)
180         if (--m_active == 0)
187181         {
188182            m_i[0].inactivate();
189183            m_i[1].inactivate();
trunk/src/emu/netlist/nl_config.h
r26874r26875
1616//  SETUP
1717//============================================================
1818
19#define USE_DELEGATES           (0)
2019/*
2120 * The next options needs -Wno-pmf-conversions to compile and gcc
2221 * This is intended for non-mame usage.
r26874r26875
2423 */
2524#define USE_PMFDELEGATES        (0)
2625
27// Next if enabled adds 20% performance ... but is not guaranteed to be absolutely timing correct.
26// This used to add 20% performance ... but is not guaranteed to be absolutely timing correct.
27// Update 01.01.2014: Currently, enabling this has no observable impact on performance.
28
2829#define USE_DEACTIVE_DEVICE     (0)
2930
3031// Use nano-second resolution - Sufficient for now
trunk/src/emu/netlist/nl_base.c
r26874r26875
1515// ----------------------------------------------------------------------------------------
1616
1717netlist_queue_t::netlist_queue_t(netlist_base_t &nl)
18   : netlist_timed_queue<netlist_net_t, netlist_time, 512>(), pstate_callback_t(),
18   : netlist_timed_queue<netlist_net_t *, netlist_time, 512>(), pstate_callback_t(),
1919      m_netlist(nl),
2020      m_qsize(0)
2121{  }
r26874r26875
3636   for (int i = 0; i < m_qsize; i++ )
3737   {
3838      m_times[i] =  this->listptr()[i].time().as_raw();
39      const char *p = this->listptr()[i].object().name().cstr();
39      const char *p = this->listptr()[i].object()->name().cstr();
4040      int n = MIN(63, strlen(p));
4141      strncpy(&(m_name[i][0]), p, n);
4242      m_name[i][n] = 0;
r26874r26875
5353      netlist_net_t *n = m_netlist.find_net(&(m_name[i][0]));
5454      NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n));
5555      NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double()));
56      this->push(netlist_queue_t::entry_t(netlist_time::from_raw(m_times[i]), *n));
56      this->push(netlist_queue_t::entry_t(netlist_time::from_raw(m_times[i]), n));
5757   }
5858}
5959
r26874r26875
8282ATTR_COLD const pstring &netlist_object_t::name() const
8383{
8484   if (m_name == "")
85      netlist().xfatalerror("object not initialized");
85      netlist().error("object not initialized");
8686   return m_name;
8787}
8888
r26874r26875
197197        {
198198            const netlist_queue_t::entry_t &e = m_queue.pop();
199199            m_time_ps = e.time();
200            e.object().update_devs();
200            e.object()->update_devs();
201201
202202            add_to_stat(m_perf_out_processed, 1);
203203            if (FATAL_ERROR_AFTER_NS)
204204                if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
205                    xfatalerror("Stopped");
205                    error("Stopped");
206206        }
207207        if (m_queue.is_empty())
208208            m_time_ps = m_stop;
r26874r26875
223223
224224                const netlist_queue_t::entry_t &e = m_queue.pop();
225225                m_time_ps = e.time();
226                e.object().update_devs();
226                e.object()->update_devs();
227227
228228            } else {
229229                m_time_ps = mcQ.time();
r26874r26875
231231            }
232232            if (FATAL_ERROR_AFTER_NS)
233233                if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS))
234                    xfatalerror("Stopped");
234                    error("Stopped");
235235
236236            add_to_stat(m_perf_out_processed, 1);
237237        }
238238    }
239239}
240240
241ATTR_COLD void netlist_base_t::xfatalerror(const char *format, ...) const
241ATTR_COLD void netlist_base_t::error(const char *format, ...) const
242242{
243243   va_list ap;
244244   va_start(ap, format);
r26874r26875
273273{
274274   init_object(anetlist, name);
275275
276#if USE_DELEGATES
277276#if USE_PMFDELEGATES
278277   void (netlist_core_device_t::* pFunc)() = &netlist_core_device_t::update;
279278   static_update = reinterpret_cast<net_update_delegate>((this->*pFunc));
280#else
281   static_update = net_update_delegate(&netlist_core_device_t::update, "update", this);
282   // get the pointer to the member function
283279#endif
284#endif
285280
286281}
287282
r26874r26875
383378            dynamic_cast<netlist_terminal_t &>(term).init_object(dev, dev.name() + ".INTTERM", aState);
384379            break;
385380         default:
386            dev.netlist().xfatalerror("Unknown terminal type");
381            dev.netlist().error("Unknown terminal type");
387382            break;
388383      }
389384   }
r26874r26875
455450      return; // Nothing to do
456451
457452   if (this->isRailNet() && othernet->isRailNet())
458      netlist().xfatalerror("Trying to merge to rail nets\n");
453      netlist().error("Trying to merge to rail nets\n");
459454
460455   if (othernet->isRailNet())
461456   {
r26874r26875
505500   assert(m_num_cons != 0);
506501
507502   assert(this->isRailNet());
508   {
509      const UINT32 masks[4] = { 1, 5, 3, 1 };
510      m_cur = m_new;
511      m_in_queue = 2; /* mark as taken ... */
512503
513      const UINT32 mask = masks[ (m_last.Q  << 1) | m_cur.Q ];
504   const UINT32 masks[4] = { 1, 5, 3, 1 };
505    m_cur = m_new;
506    m_in_queue = 2; /* mark as taken ... */
514507
515      netlist_core_terminal_t *p = m_head;
516      switch (m_num_cons)
517      {
518      case 2:
519         update_dev(p, mask);
520         p = p->m_update_list_next;
521      case 1:
522         update_dev(p, mask);
523         break;
524      default:
525         do
526         {
527            update_dev(p, mask);
528            p = p->m_update_list_next;
529         } while (p != NULL);
530         break;
531      }
532      m_last = m_cur;
533   }
508    const UINT32 mask = masks[ (m_last.Q  << 1) | m_cur.Q ];
509
510    netlist_core_terminal_t *p = m_head;
511    switch (m_num_cons)
512    {
513    case 2:
514        update_dev(p, mask);
515        p = p->m_update_list_next;
516    case 1:
517        update_dev(p, mask);
518        break;
519    default:
520        do
521        {
522            update_dev(p, mask);
523            p = p->m_update_list_next;
524        } while (p != NULL);
525        break;
526    }
527    m_last = m_cur;
534528}
535529
536530// ----------------------------------------------------------------------------------------
r26874r26875
688682      tmp = tmp.substr(p, pblank - p);
689683      int pequal = tmp.find("=", 0);
690684      if (pequal < 0)
691         netlist().xfatalerror("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr());
685         netlist().error("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr());
692686      tmp = tmp.substr(pequal+1);
693687      double factor = 1.0;
694688      switch (*(tmp.right(1).cstr()))
r26874r26875
716710
717711ATTR_HOT inline void NETLIB_NAME(mainclock)::mc_update(netlist_net_t &net, const netlist_time curtime)
718712{
719   net.m_new.Q = !net.m_new.Q;
713   net.m_new.Q ^= 1;
720714   net.set_time(curtime);
721715   net.update_devs();
722716}
trunk/src/emu/netlist/nl_base.h
r26874r26875
163163
164164class netlist_core_device_t;
165165
166#if USE_DELEGATES
167166#if USE_PMFDELEGATES
168167typedef void (*net_update_delegate)(netlist_core_device_t *);
169#else
170typedef delegate<void ()> net_update_delegate;
171168#endif
172#endif
173169
174170//============================================================
175171//  MACROS / netlist devices
r26874r26875
578574      return m_cur.Analog;
579575   }
580576
581   ATTR_HOT inline void push_to_queue(const netlist_time &delay);
577   ATTR_HOT inline void push_to_queue(const netlist_time delay);
582578   ATTR_HOT bool is_queued() { return m_in_queue == 1; }
583579
584580   /* internal state support
r26874r26875
681677   ATTR_COLD void initial(const netlist_sig_t val);
682678   ATTR_COLD void set_levels(const double low, const double high);
683679
684   ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time &delay)
680   ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time delay)
685681   {
686      netlist_net_t &anet = net();
682      assert(net().m_num_cons != 1);
687683
688      if (EXPECTED(newQ != anet.m_new.Q))
684      if (EXPECTED(newQ != net().m_new.Q))
689685      {
690         anet.m_new.Q = newQ;
691         if (anet.m_num_cons)
692            anet.push_to_queue(delay);
686          net().m_new.Q = newQ;
687          net().push_to_queue(delay);
693688      }
694689   }
695690};
r26874r26875
711706
712707   ATTR_COLD void initial(const double val);
713708
714   ATTR_HOT inline void set_Q(const double newQ, const netlist_time &delay)
709   ATTR_HOT inline void set_Q(const double newQ, const netlist_time delay)
715710   {
716711      if (newQ != net().m_new.Analog)
717712      {
r26874r26875
852847
853848   ATTR_HOT inline void update_dev()
854849   {
855#if USE_DELEGATES
856850#if USE_PMFDELEGATES
857851      static_update(this);
858852#else
859      static_update();
860#endif
861#else
862853      update();
863854#endif
864855   }
r26874r26875
871862      return inp.Q();
872863   }
873864
874   ATTR_HOT inline void OUTLOGIC(netlist_logic_output_t &out, const netlist_sig_t val, const netlist_time &delay)
865   ATTR_HOT inline void OUTLOGIC(netlist_logic_output_t &out, const netlist_sig_t val, const netlist_time delay)
875866   {
876867      out.set_Q(val, delay);
877868   }
r26874r26875
890881
891882   ATTR_HOT inline const double TERMANALOG(const netlist_terminal_t &term) const { return term.net().Q_Analog(); }
892883
893   ATTR_HOT inline void OUTANALOG(netlist_analog_output_t &out, const double val, const netlist_time &delay)
884   ATTR_HOT inline void OUTANALOG(netlist_analog_output_t &out, const double val, const netlist_time delay)
894885   {
895886      out.set_Q(val, delay);
896887   }
r26874r26875
908899   INT32 stat_count;
909900#endif
910901
911#if USE_DELEGATES
902#if USE_PMFDELEGATES
912903   net_update_delegate static_update;
913904#endif
914905
r26874r26875
973964// netlist_queue_t
974965// ----------------------------------------------------------------------------------------
975966
976class netlist_queue_t : public netlist_timed_queue<netlist_net_t, netlist_time, 512>,
967class netlist_queue_t : public netlist_timed_queue<netlist_net_t *, netlist_time, 512>,
977968                  public pstate_callback_t
978969{
979970public:
r26874r26875
10111002   ATTR_HOT inline const netlist_queue_t &queue() const { return m_queue; }
10121003   ATTR_HOT inline netlist_queue_t &queue() { return m_queue; }
10131004
1014   ATTR_HOT inline void push_to_queue(netlist_net_t &out, const netlist_time &attime)
1005   ATTR_HOT inline void push_to_queue(netlist_net_t *out, const netlist_time attime)
10151006   {
10161007      m_queue.push(netlist_queue_t::entry_t(attime, out));
10171008   }
r26874r26875
10211012   ATTR_HOT void process_queue(const netlist_time delta);
10221013   ATTR_HOT inline void abort_current_queue_slice() { m_stop = netlist_time::zero; }
10231014
1024   ATTR_HOT inline const netlist_time &time() const { return m_time_ps; }
1015   ATTR_HOT inline const netlist_time time() const { return m_time_ps; }
10251016
10261017   ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev);
10271018   ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev);
r26874r26875
10321023   ATTR_COLD netlist_setup_t &setup() { return *m_setup; }
10331024   ATTR_COLD void reset();
10341025
1035   ATTR_COLD void xfatalerror(const char *format, ...) const;
1026   ATTR_COLD void error(const char *format, ...) const;
10361027
10371028   tagmap_devices_t m_devices;
10381029   netlist_net_t::list_t m_nets;
r26874r26875
10421033   // any derived netlist must override this ...
10431034   virtual void vfatalerror(const char *format, va_list ap) const = 0;
10441035
1045protected:
10461036   ATTR_COLD virtual void save_register()
10471037   {
10481038      save(NAME(m_queue.callback()));
r26874r26875
10791069   ATTR_COLD nld_a_to_d_proxy(netlist_input_t &in_proxied)
10801070         : netlist_device_t()
10811071   {
1082      //assert(in_proxied.object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
10831072      assert(in_proxied.family() == LOGIC);
10841073      m_I.m_high_thresh_V = in_proxied.m_high_thresh_V;
10851074      m_I.m_low_thresh_V = in_proxied.m_low_thresh_V;
r26874r26875
11201109   ATTR_COLD nld_d_to_a_proxy(netlist_output_t &out_proxied)
11211110         : netlist_device_t()
11221111   {
1123      //assert(out_proxied.object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
11241112      assert(out_proxied.family() == LOGIC);
11251113      m_low_V = out_proxied.m_low_V;
11261114      m_high_V = out_proxied.m_high_V;
r26874r26875
12111199}
12121200
12131201
1214ATTR_HOT inline void netlist_net_t::push_to_queue(const netlist_time &delay)
1202ATTR_HOT inline void netlist_net_t::push_to_queue(const netlist_time delay)
12151203{
12161204   // if (m_in_queue == 1) return; FIXME: check this at some time
12171205   m_time = netlist().time() + delay;
r26874r26875
12191207   if (m_in_queue)
12201208   {
12211209      //m_in_queue = 1;     /* pending */
1222      netlist().push_to_queue(*this, m_time);
1210      netlist().push_to_queue(this, m_time);
12231211   }
12241212}
12251213
r26874r26875
12271215{
12281216   m_active++;
12291217
1230   if (USE_DEACTIVE_DEVICE)
1231      if (m_active == 1 && m_in_queue > 0)
1232      {
1233         m_last = m_cur;
1234         railterminal().netdev().inc_active();
1235         m_cur = m_new;
1236      }
1218   if (USE_DEACTIVE_DEVICE && m_active == 1 && m_in_queue > 0)
1219    {
1220        m_last = m_cur;
1221        railterminal().netdev().inc_active();
1222        m_cur = m_new;
1223    }
12371224
1238   if (EXPECTED(m_active == 1 && m_in_queue == 0))
1225   if (m_active == 1 && m_in_queue == 0)
12391226   {
1240      if (EXPECTED(m_time > netlist().time()))
1227      if (m_time > netlist().time())
12411228      {
12421229         m_in_queue = 1;     /* pending */
1243         netlist().push_to_queue(*this, m_time);
1230         netlist().push_to_queue(this, m_time);
12441231      }
12451232      else
12461233      {
r26874r26875
12531240ATTR_HOT inline void netlist_net_t::dec_active()
12541241{
12551242   m_active--;
1256   if (USE_DEACTIVE_DEVICE)
1257      if (m_active == 0)
1258         railterminal().netdev().dec_active();
1243   if (USE_DEACTIVE_DEVICE && (m_active == 0))
1244        railterminal().netdev().dec_active();
12591245
12601246}
12611247

Previous 199869 Revisions Next


© 1997-2024 The MAME Team