Previous 199869 Revisions Next

r26079 Saturday 9th November, 2013 at 21:42:46 UTC by Couriersud
Netlist: checkpoint check-in. Outputs now drive nets and inputs access nets. Moved more stuff to net_terminal.
[src/emu/netlist]netlist.mak nl_base.c nl_base.h nl_setup.c
[src/emu/netlist/devices]net_lib.c nld_system.c* nld_system.h

trunk/src/emu/netlist/netlist.mak
r26078r26079
2121   $(NETLISTOBJ)/nl_setup.o \
2222   $(NETLISTOBJ)/nl_base.o \
2323   $(NETLISTOBJ)/nl_parser.o \
24   $(NETLISTOBJ)/devices/nld_system.o \
2425   $(NETLISTOBJ)/devices/net_lib.o \
2526
trunk/src/emu/netlist/nl_base.h
r26078r26079
8484// forward definitions
8585// ----------------------------------------------------------------------------------------
8686
87class net_net_t;
8788class net_output_t;
8889class net_param_t;
8990class netlist_setup_t;
r26078r26079
111112      SIGNAL_MASK =    0x10,
112113   };
113114
114   net_object_t(int atype)
115   net_object_t(const int atype)
115116      : m_objtype(atype) {}
116117
117118   virtual ~net_object_t() {}
118119
120    ATTR_COLD void init_object(netlist_base_t &nl)
121    {
122        m_netlist = &nl;
123    }
124
119125   ATTR_HOT inline int object_type() const { return m_objtype; }
120126   ATTR_HOT inline int object_type(const UINT32 mask) const { return m_objtype & mask; }
121127
128    ATTR_HOT inline netlist_base_t * RESTRICT netlist() { return m_netlist; }
129    ATTR_HOT inline const netlist_base_t * RESTRICT netlist() const { return m_netlist; }
130
122131private:
123   int m_objtype;
132   const int m_objtype;
133    netlist_base_t * RESTRICT m_netlist;
124134};
125135
126136// ----------------------------------------------------------------------------------------
r26078r26079
134144   net_terminal_t(const int atype)
135145   : net_object_t(atype)
136146   , m_netdev(NULL)
137   , m_netlist(NULL)
147    , m_net(NULL)
138148   {}
139149
140   ATTR_COLD void init_terminal(netlist_core_device_t *dev);
141   ATTR_HOT inline netlist_core_device_t * RESTRICT netdev() const { return m_netdev; }
142   ATTR_HOT inline netlist_base_t * RESTRICT netlist() const { return m_netlist; }
150   ATTR_COLD virtual void init_terminal(netlist_core_device_t &dev);
143151
152    ATTR_COLD void set_net(net_net_t &anet)   { m_net = &anet; }
153
154    ATTR_HOT inline const net_net_t & RESTRICT net() const { return *m_net;}
155    ATTR_HOT inline net_net_t & RESTRICT net() { return *m_net;}
156
157    ATTR_HOT inline netlist_core_device_t * RESTRICT netdev() const { return m_netdev; }
158
144159private:
145160   netlist_core_device_t * RESTRICT m_netdev;
146   netlist_base_t * RESTRICT m_netlist;
161    net_net_t * RESTRICT m_net;
147162};
148163
149164
r26078r26079
170185       , m_next(NULL)
171186#endif
172187      , m_state(INP_STATE_ACTIVE)
173      , m_output(NULL)
174188   {}
175189
176   ATTR_COLD void init_input(netlist_core_device_t *dev, net_input_state astate = INP_STATE_ACTIVE);
190   ATTR_COLD void init_input(netlist_core_device_t &dev, net_input_state astate = INP_STATE_ACTIVE);
177191
178   ATTR_HOT inline net_output_t * RESTRICT output() const { return m_output; }
179192   ATTR_HOT inline const bool is_state(const net_input_state astate) const { return (m_state == astate); }
180193   ATTR_HOT inline const net_input_state state() const { return m_state; }
181194
182   ATTR_COLD void set_output(net_output_t &aout)   { m_output = &aout; }
183195   ATTR_HOT inline void inactivate();
184196   ATTR_HOT inline void activate();
185197   ATTR_HOT inline void activate_hl();
r26078r26079
194206
195207private:
196208   net_input_state m_state;
197   net_output_t * RESTRICT m_output;
198209};
199210
200211// ----------------------------------------------------------------------------------------
r26078r26079
246257//#define INPVAL(_x) (_x).Q()
247258
248259// ----------------------------------------------------------------------------------------
249// net_output_t
260// net_net_t
250261// ----------------------------------------------------------------------------------------
251262
252class NETLIB_NAME(netdev_mainclock);
253
254class net_output_t : public net_terminal_t
263class net_net_t : public net_object_t
255264{
256265public:
257266
267    friend class NETLIB_NAME(netdev_mainclock);
268    friend class net_output_t;
269    friend class net_input_t;
270    friend class logic_output_t;
271    friend class analog_output_t;
272    friend class logic_input_t;
273    friend class analog_input_t;
274
258275    // FIXME: union does not work
259276    typedef struct
260277    {
r26078r26079
262279        double        Analog;
263280    } hybrid_t;
264281
265   net_output_t(int atype);
282    ATTR_COLD net_net_t(const int atype);
266283
267   friend const netlist_sig_t logic_input_t::Q() const;
268   friend const double analog_input_t::Q_Analog() const;
269   friend const bool analog_input_t::is_highz() const;
270   friend class NETLIB_NAME(netdev_mainclock);
284    ATTR_COLD void register_con(net_input_t &inp);
285    ATTR_COLD void register_raildev(netlist_core_device_t &mr)
286    {
287        assert(m_raildev == NULL);
288        m_raildev = &mr;
289    }
271290
272   ATTR_HOT inline const netlist_sig_t last_Q() const  { return m_last.Q;  }
273   ATTR_HOT inline const netlist_sig_t new_Q() const   { return m_new.Q;   }
291    ATTR_HOT inline bool isRailNet() { return m_raildev == NULL; }
274292
275   ATTR_COLD void register_con(net_input_t &inp);
293    /* inline not always works out */
294    ATTR_HOT /*inline*/ void update_devs();
276295
277   /* inline not always works out */
278   ATTR_HOT /*inline*/ void update_devs();
296    /* Everything below is used by the logic subsystem */
279297
280   ATTR_HOT inline void inc_active();
281   ATTR_HOT inline void dec_active();
298    ATTR_HOT inline void inc_active();
299    ATTR_HOT inline void dec_active();
282300
283   ATTR_HOT inline const int active_count() const { return m_active; }
284   ATTR_HOT inline const netlist_time time() const { return m_time; }
285   ATTR_HOT inline void set_time(const netlist_time ntime) { m_time = ntime; }
301    ATTR_HOT inline const int active_count() const { return m_active; }
302    ATTR_HOT inline const netlist_time time() const { return m_time; }
303    ATTR_HOT inline void set_time(const netlist_time ntime) { m_time = ntime; }
286304
287   double m_low_V;
288   double m_high_V;
305    ATTR_HOT inline const netlist_sig_t last_Q() const  { return m_last.Q;  }
306    ATTR_HOT inline const netlist_sig_t new_Q() const   { return m_new.Q;   }
289307
308    ATTR_HOT inline const netlist_core_device_t * RESTRICT  raildev() const { return m_raildev; }
309    ATTR_HOT inline netlist_core_device_t * RESTRICT raildev() { return m_raildev; }
310
290311protected:
291312
292   /* prohibit use in device functions
293    * current (pending) state can be inquired using new_Q()
294    */
295   ATTR_HOT inline const netlist_sig_t Q() const
296   {
297      assert(object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
298      return m_cur.Q;
299   }
300   ATTR_HOT inline const double Q_Analog() const
301   {
302      assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
313    /* prohibit use in device functions
314     * current (pending) state can be inquired using new_Q()
315     */
316    ATTR_HOT inline const netlist_sig_t Q() const
317    {
318        assert(object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
319        return m_cur.Q;
320    }
321    ATTR_HOT inline const double Q_Analog() const
322    {
323        assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
303324        return m_cur.Analog;
304   }
325    }
305326
306   ATTR_HOT inline void push_to_queue(const netlist_time &delay);
307327
308   hybrid_t m_last;
309   hybrid_t m_cur;
310   hybrid_t m_new;
328    ATTR_HOT inline void push_to_queue(const netlist_time &delay);
311329
330    hybrid_t m_last;
331    hybrid_t m_cur;
332    hybrid_t m_new;
333
312334#if USE_LINKED_LIST
313   net_input_t *m_head;
335    net_input_t *m_head;
314336#endif
315   UINT32 m_num_cons;
337    UINT32 m_num_cons;
316338
317339private:
318   ATTR_HOT void update_dev(const net_input_t *inp, const UINT32 mask);
340    ATTR_HOT void update_dev(const net_input_t *inp, const UINT32 mask);
319341
320   netlist_time m_time;
342    netlist_time m_time;
343    INT32        m_active;
344    UINT32       m_in_queue;    /* 0: not in queue, 1: in queue, 2: last was taken */
321345
322   INT32 m_active;
323
324   UINT32 m_in_queue;    /* 0: not in queue, 1: in queue, 2: last was taken */
325
326346#if !USE_LINKED_LIST
327   net_input_t *  RESTRICT m_cons[OUTPUT_MAX_CONNECTIONS];
347    net_input_t *  RESTRICT m_cons[OUTPUT_MAX_CONNECTIONS];
328348#endif
349    netlist_core_device_t * RESTRICT m_raildev;
329350};
330351
331352
353// ----------------------------------------------------------------------------------------
354// net_output_t
355// ----------------------------------------------------------------------------------------
356
357class NETLIB_NAME(netdev_mainclock);
358
359class net_output_t : public net_terminal_t
360{
361public:
362
363   net_output_t(int atype);
364
365    ATTR_COLD virtual void init_terminal(netlist_core_device_t &dev);
366
367   double m_low_V;
368   double m_high_V;
369
370protected:
371
372private:
373   net_net_t m_my_net;
374};
375
376
332377class logic_output_t : public net_output_t
333378{
334379public:
335380
336   logic_output_t()
337      : net_output_t(OUTPUT | SIGNAL_DIGITAL)
338   {
339      // Default to TTL
340      m_low_V = 0.1;  // these depend on sinked/sourced current. Values should be suitable for typical applications.
341      m_high_V = 4.8;
342   }
381   ATTR_COLD logic_output_t();
343382
344   ATTR_COLD void initial(const netlist_sig_t val) { m_cur.Q = val; m_new.Q = val; m_last.Q = !val; }
383   ATTR_COLD void initial(const netlist_sig_t val);
384    ATTR_COLD void set_levels(const double low, const double high);
345385
346386   ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time &delay)
347387   {
348      if (EXPECTED(newQ != m_new.Q))
388       net_net_t &anet = net();
389
390      if (EXPECTED(newQ != anet.m_new.Q))
349391      {
350           m_new.Q = newQ;
351         if (m_num_cons)
352            push_to_queue(delay);
392          anet.m_new.Q = newQ;
393         if (anet.m_num_cons)
394             anet.push_to_queue(delay);
353395      }
354396   }
355
356   ATTR_COLD inline void set_levels(const double low, const double high)
357   {
358      m_low_V = low;
359      m_high_V = high;
360   }
361397};
362398
363399class ttl_output_t : public logic_output_t
r26078r26079
376412{
377413public:
378414
379   analog_output_t()
415   ATTR_COLD analog_output_t()
380416      : net_output_t(OUTPUT | SIGNAL_ANALOG)
381417    {
382        m_cur.Analog = 0.0;
383        m_new.Analog = 0.0;
418       net().m_cur.Analog = 0.0;
419       net().m_new.Analog = 0.0;
384420    }
385421
386422    ATTR_COLD void initial(const double val)
387423    {
388        m_cur.Analog = val;
389        m_new.Analog = val;
424        net().m_cur.Analog = val;
425        net().m_new.Analog = val;
390426    }
391427
392428   ATTR_HOT inline void set_Q(const double newQ, const netlist_time &delay)
393429   {
394      if (newQ != m_new.Analog)
430      if (newQ != net().m_new.Analog)
395431      {
396            m_new.Analog = newQ;
397         push_to_queue(delay);
432          net().m_new.Analog = newQ;
433          net().push_to_queue(delay);
398434      }
399435   }
400436
r26078r26079
418454
419455   ATTR_HOT virtual void update_param() {}
420456
421   ATTR_HOT const netlist_sig_t INPLOGIC_PASSIVE(logic_input_t &inp);
422
423457   ATTR_HOT inline void update_dev()
424458   {
425459#if USE_DELEGATES
r26078r26079
433467#endif
434468   }
435469
470    ATTR_HOT const netlist_sig_t INPLOGIC_PASSIVE(logic_input_t &inp);
471
436472   ATTR_HOT inline const netlist_sig_t INPLOGIC(const logic_input_t &inp) const
437473   {
438474      assert(inp.state() != net_input_t::INP_STATE_PASSIVE);
r26078r26079
461497      out.set_Q(val, delay);
462498   }
463499
464   ATTR_HOT inline netlist_base_t *netlist() const { return m_netlist; }
465
466500   ATTR_HOT virtual void inc_active() {  }
467501
468502   ATTR_HOT virtual void dec_active() { /*printf("DeActivate %s\n", m_name);*/ }
r26078r26079
480514   ATTR_HOT virtual void update() { }
481515   ATTR_HOT virtual void start() { }
482516
483   netlist_base_t *  RESTRICT m_netlist;
484
485517private:
486
487518   astring m_name;
488519};
489520
r26078r26079
492523{
493524public:
494525
495   net_device_t();
526   ATTR_COLD net_device_t();
496527
497528   virtual ~net_device_t();
498529
r26078r26079
518549protected:
519550
520551   virtual void update() { }
521   ATTR_HOT virtual void start() { }
552   virtual void start() { }
522553
523554   ATTR_COLD void register_param(const astring &sname, net_param_t &param, const double initialVal = 0.0);
524555   ATTR_COLD void register_param(netlist_core_device_t &dev, const astring &sname, net_param_t &param, const double initialVal = 0.0);
r26078r26079
537568   , m_netdev(NULL)
538569   {  }
539570
540   inline void setTo(const double param) { m_param = param; m_netdev->update_param(); }
541   inline void setTo(const int param) { m_param = param; m_netdev->update_param(); }
571   ATTR_HOT inline void setTo(const double param) { m_param = param; m_netdev->update_param(); }
572   ATTR_HOT inline void setTo(const int param) { m_param = param; m_netdev->update_param(); }
542573   inline void initial(const double val) { m_param = val; }
543574   inline void initial(const int val) { m_param = val; }
544575
545   ATTR_HOT inline double Value() const        { return m_param;   }
546   ATTR_HOT inline int    ValueInt() const     { return (int) m_param;     }
576   ATTR_HOT inline const double Value() const        { return m_param;   }
577   ATTR_HOT inline const int    ValueInt() const     { return (int) m_param;     }
547578
548579   ATTR_HOT inline netlist_core_device_t &netdev() const { return *m_netdev; }
549   void set_netdev(netlist_core_device_t &dev) { m_netdev = &dev; }
580   ATTR_COLD void set_netdev(netlist_core_device_t &dev) { m_netdev = &dev; }
550581
551582private:
552583
r26078r26079
566597{
567598public:
568599
569   typedef netlist_timed_queue1<net_output_t, netlist_time, 512> queue_t;
600   typedef netlist_timed_queue1<net_net_t, netlist_time, 512> queue_t;
570601
571602   netlist_base_t();
572603   virtual ~netlist_base_t();
573604
574605   void set_clock_freq(UINT64 clockfreq);
575606
576   ATTR_HOT inline void push_to_queue(net_output_t &out, const netlist_time &attime)
607   ATTR_HOT inline void push_to_queue(net_net_t &out, const netlist_time &attime)
577608   {
578609      m_queue.push(queue_t::entry_t(attime, out));
579610   }
r26078r26079
629660protected:
630661   void start()
631662   {
632      m_I.init_input(this);
663      m_I.init_input(*this);
633664
634      m_Q.init_terminal(this);
665      m_Q.init_terminal(*this);
635666      m_Q.initial(1);
636667   }
637668
r26078r26079
668699protected:
669700   void start()
670701   {
671      m_I.init_input(this);
672      m_Q.init_terminal(this);
702      m_I.init_input(*this);
703      m_Q.init_terminal(*this);
673704      m_Q.initial(0);
674705   }
675706
r26078r26079
693724   if (m_state != INP_STATE_PASSIVE)
694725   {
695726      m_state = INP_STATE_PASSIVE;
696      m_output->dec_active();
727      net().dec_active();
697728   }
698729}
699730
r26078r26079
701732{
702733   if (m_state == INP_STATE_PASSIVE)
703734   {
704      m_output->inc_active();
735      net().inc_active();
705736      m_state = INP_STATE_ACTIVE;
706737   }
707738}
r26078r26079
710741{
711742   if (m_state == INP_STATE_PASSIVE)
712743   {
713      m_output->inc_active();
744      net().inc_active();
714745      m_state = INP_STATE_HL;
715746   }
716747}
r26078r26079
719750{
720751   if (m_state == INP_STATE_PASSIVE)
721752   {
722      m_output->inc_active();
753      net().inc_active();
723754      m_state = INP_STATE_LH;
724755   }
725756}
726757
727758
728ATTR_HOT inline void net_output_t::push_to_queue(const netlist_time &delay)
759ATTR_HOT inline void net_net_t::push_to_queue(const netlist_time &delay)
729760{
730761   // if (m_in_queue == 1) return; FIXME: check this at some time
731762   m_time = netlist()->time() + delay;
r26078r26079
737768   }
738769}
739770
740ATTR_HOT inline void net_output_t::inc_active()
771ATTR_HOT inline void net_net_t::inc_active()
741772{
742773   m_active++;
743774
r26078r26079
745776   if (m_active == 1 && m_in_queue > 0)
746777   {
747778      m_last = m_cur;
748      netdev()->inc_active();
779      raildev()->inc_active();
749780      m_cur = m_new;
750781   }
751782#endif
r26078r26079
765796   }
766797}
767798
768ATTR_HOT inline void net_output_t::dec_active()
799ATTR_HOT inline void net_net_t::dec_active()
769800{
770801   m_active--;
771802#if (USE_DEACTIVE_DEVICE)
772803   if (m_active == 0)
773      netdev()->dec_active();
804       raildev()->dec_active();
774805#endif
775806}
776807
777808ATTR_HOT inline const netlist_sig_t logic_input_t::Q() const
778809{
779   return output()->Q();
810   return net().Q();
780811}
781812
782813ATTR_HOT inline const netlist_sig_t logic_input_t::last_Q() const
783814{
784   return output()->last_Q();
815   return net().last_Q();
785816}
786817
787818ATTR_HOT inline const double analog_input_t::Q_Analog() const
788819{
789   return output()->Q_Analog();
820   return net().Q_Analog();
790821}
791822
792823ATTR_HOT inline const bool analog_input_t::is_highz() const
793824{
794   return (output()->Q_Analog() == NETLIST_HIGHIMP_V);
825   return (net().Q_Analog() == NETLIST_HIGHIMP_V);
795826}
796827
797828// ----------------------------------------------------------------------------------------
trunk/src/emu/netlist/nl_setup.c
r26078r26079
105105   astring temp = dev.name();
106106   temp.cat(".");
107107   temp.cat(name);
108   out.init_terminal(&upd_dev);
108   out.init_terminal(upd_dev);
109109   if (!(m_terminals.add(temp, &out, false)==TMERR_NONE))
110110      fatalerror("Error adding output %s to output list\n", name.cstr());
111111}
r26078r26079
116116   astring temp = dev.name();
117117   temp.cat(".");
118118   temp.cat(name);
119   inp.init_input(&upd_dev, type);
119   inp.init_input(upd_dev, type);
120120   dev.m_inputs.add(temp);
121121   if (!(m_terminals.add(temp, &inp, false) == TMERR_NONE))
122122      fatalerror("Error adding input %s to input list\n", name.cstr());
r26078r26079
211211         proxy->init(*this, x.cstr());
212212         register_dev(proxy);
213213
214         in->set_output(proxy->m_Q);
215         proxy->m_Q.register_con(*in);
216         proxy->m_I.set_output(out);
217         out.register_con(proxy->m_I);
214         proxy->m_Q.net().register_con(*in);
215         out.net().register_con(proxy->m_I);
218216
219217      }
220218      else if (out.object_type(net_output_t::SIGNAL_MASK) == net_output_t::SIGNAL_DIGITAL
r26078r26079
227225         proxy->init(*this, x.cstr());
228226         register_dev(proxy);
229227
230         in->set_output(proxy->m_Q);
231         proxy->m_Q.register_con(*in);
232         proxy->m_I.set_output(out);
233         out.register_con(proxy->m_I);
234         //printf("here 2\n");
228            proxy->m_Q.net().register_con(*in);
229            out.net().register_con(proxy->m_I);
235230      }
236231      else
237232      {
238         in->set_output(out);
239         out.register_con(*in);
233          out.net().register_con(*in);
240234      }
241235   }
242236
r26078r26079
250244      }
251245   }
252246
253#if 1
254
255#else
256   /* make sure all outputs are triggered once */
257   for (tagmap_output_t::entry_t *entry = m_outputs.first(); entry != NULL; entry = m_outputs.next(entry))
258   {
259      net_output_t *out = entry->object();
260      //if (dynamic_cast<const netdev_clock *>(out->netdev()) == NULL )
261      {
262         out->update_devs_force();
263         INT32 time = 10000;
264         m_netlist.process_list(time);
265      }
266   }
267   //m_netlist.m_queue.clear();
268#endif
269
270247   /* print all outputs */
271248   for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry))
272249   {
trunk/src/emu/netlist/devices/net_lib.c
r26078r26079
9898NETLIB_UPDATE(netdev_clock)
9999{
100100   //m_Q.setToNoCheck(!m_Q.new_Q(), m_inc  );
101   OUTLOGIC(m_Q, !m_Q.new_Q(), m_inc  );
101   OUTLOGIC(m_Q, !m_Q.net().new_Q(), m_inc  );
102102}
103103
104104NETLIB_START(nicMultiSwitch)
r26078r26079
112112   for (i=0; i<8; i++)
113113   {
114114      register_input(sIN[i], m_I[i]);
115      //register_link_internal(m_I[i], m_low);
116      m_I[i].set_output(m_low);
115      m_low.net().register_con(m_I[i]);
116      //m_I[i].set_net(m_low.m_net);
117117   }
118118   register_param("POS", m_POS);
119119   register_output("Q", m_Q);
r26078r26079
144144   for (i=0; i<8; i++)
145145   {
146146      register_input(sI[i], m_I[i]);
147      m_I[i].set_output(m_low);
147      m_low.net().register_con(m_I[i]);
148      //m_I[i].set_output(m_low);
148149      register_param(sR[i], m_R[i], 1e12);
149150   }
150151   register_output("Q", m_Q);
r26078r26079
215216   register_param("VS", m_VS, 5.0);
216217   register_param("VL", m_VL, 0.0 *5.0);
217218
218   m_THRESHOLD_OUT.init_terminal(this);
219   m_THRESHOLD_OUT.init_terminal(*this);
219220   register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, net_input_t::INP_STATE_ACTIVE);
220221
221222   m_Q.initial(5.0 * 0.4);
r26078r26079
632633NETLIB_UPDATE(nic7493ff)
633634{
634635   if (m_reset == 0)
635      OUTLOGIC(m_Q, !m_Q.new_Q(), NLTIME_FROM_NS(18));
636      OUTLOGIC(m_Q, !m_Q.net().new_Q(), NLTIME_FROM_NS(18));
636637}
637638
638639NETLIB_UPDATE(nic7493)
r26078r26079
773774NETLIB_UPDATE(nic74107Asub)
774775{
775776   {
776      netlist_sig_t t = m_Q.new_Q();
777      const netlist_sig_t t = m_Q.net().new_Q();
777778      newstate((!t & m_Q1) | (t & m_Q2) | m_F);
778779      if (!m_Q1)
779780         m_clk.inactivate();
trunk/src/emu/netlist/devices/nld_system.c
r0r26079
1/*
2 * nld_system.c
3 *
4 */
5
6#include "nld_system.h"
7
8// ----------------------------------------------------------------------------------------
9// netdev_const
10// ----------------------------------------------------------------------------------------
11
12NETLIB_START(netdev_ttl_const)
13{
14    register_output("Q", m_Q);
15    register_param("CONST", m_const, 0.0);
16}
17
18NETLIB_UPDATE(netdev_ttl_const)
19{
20}
21
22NETLIB_UPDATE_PARAM(netdev_ttl_const)
23{
24    OUTLOGIC(m_Q, m_const.ValueInt(), NLTIME_IMMEDIATE);
25}
26
27NETLIB_START(netdev_analog_const)
28{
29    register_output("Q", m_Q);
30    register_param("CONST", m_const, 0.0);
31}
32
33NETLIB_UPDATE(netdev_analog_const)
34{
35}
36
37NETLIB_UPDATE_PARAM(netdev_analog_const)
38{
39    m_Q.initial(m_const.Value());
40}
41
42NETLIB_UPDATE(netdev_analog_callback)
43{
44    // FIXME: Remove after device cleanup
45    if (!m_callback.isnull())
46        m_callback(INPANALOG(m_in));
47}
48
Property changes on: trunk/src/emu/netlist/devices/nld_system.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/emu/netlist/devices/nld_system.h
r26078r26079
4848   net_param_t m_freq;
4949   netlist_time m_inc;
5050
51   ATTR_HOT inline static void mc_update(net_output_t &Q, const netlist_time curtime);
51   ATTR_HOT inline static void mc_update(net_net_t &net, const netlist_time curtime);
5252);
5353
5454// ----------------------------------------------------------------------------------------
trunk/src/emu/netlist/nl_base.c
r26078r26079
3434      m_rem = 0;
3535      m_queue.clear();
3636      if (m_mainclock != NULL)
37         m_mainclock->m_Q.set_time(netlist_time::zero);
37         m_mainclock->m_Q.net().set_time(netlist_time::zero);
3838}
3939
4040
r26078r26079
7373         const queue_t::entry_t e = m_queue.pop();
7474         update_time(e.time(), atime);
7575
76         if (FATAL_ERROR_AFTER_NS)
77            printf("%s\n", e.object().netdev()->name().cstr());
76         //if (FATAL_ERROR_AFTER_NS)
77         //   printf("%s\n", e.object().netdev()->name().cstr());
7878
7979         e.object().update_devs();
8080
r26078r26079
9191         atime = 0;
9292      }
9393   } else {
94      net_output_t &mcQ = m_mainclock->m_Q;
94      net_net_t &mcQ = m_mainclock->m_Q.net();
9595      const netlist_time inc = m_mainclock->m_inc;
9696
9797      while (atime > 0)
r26078r26079
148148
149149ATTR_COLD void netlist_core_device_t::init(netlist_setup_t &setup, const astring &name)
150150{
151   m_netlist = &setup.netlist();
151    init_object(setup.netlist());
152152   m_name = name;
153153
154154#if USE_DELEGATES
r26078r26079
163163
164164}
165165
166ATTR_COLD void net_device_t::init(netlist_setup_t &setup, const astring &name)
167{
168   netlist_core_device_t::init(setup, name);
169   m_setup = &setup;
170   start();
171}
172
173
174166netlist_core_device_t::~netlist_core_device_t()
175167{
176168}
r26078r26079
206198   //printf("~net_device_t\n");
207199}
208200
201ATTR_COLD void net_device_t::init(netlist_setup_t &setup, const astring &name)
202{
203   netlist_core_device_t::init(setup, name);
204   m_setup = &setup;
205   start();
206}
207
208
209209ATTR_COLD void net_device_t::register_sub(netlist_core_device_t &dev, const astring &name)
210210{
211211   dev.init(*m_setup, name);
r26078r26079
233233
234234void net_device_t::register_link_internal(netlist_core_device_t &dev, net_input_t &in, net_output_t &out, net_input_t::net_input_state aState)
235235{
236   in.set_output(out);
237   in.init_input(&dev, aState);
236    in.init_input(dev, aState);
237    out.init_terminal(dev);
238238   //if (in.state() != net_input_t::INP_STATE_PASSIVE)
239      out.register_con(in);
239      out.net().register_con(in);
240240}
241241
242242void net_device_t::register_link_internal(net_input_t &in, net_output_t &out, net_input_t::net_input_state aState)
r26078r26079
257257}
258258
259259// ----------------------------------------------------------------------------------------
260// net_terminal_t
260// net_net_t
261261// ----------------------------------------------------------------------------------------
262262
263ATTR_COLD void net_terminal_t::init_terminal(netlist_core_device_t *dev)
263ATTR_COLD net_net_t::net_net_t(const int atype)
264    : net_object_t(atype)
265    #if USE_LINKED_LIST
266    ,  m_head(NULL)
267    #endif
268    , m_num_cons(0)
269    , m_time(netlist_time::zero)
270    , m_active(0)
271    , m_in_queue(2)
272    , m_raildev(NULL)
264273{
265   m_netdev = dev;
266   m_netlist = dev->netlist();
267}
274    m_cur.Q = 0;
275    m_new.Q = 0;
276    m_last.Q = 0;
277};
268278
269// ----------------------------------------------------------------------------------------
270// net_input_t
271// ----------------------------------------------------------------------------------------
272
273ATTR_COLD void net_input_t::init_input(netlist_core_device_t *dev, net_input_state astate)
279ATTR_COLD void net_net_t::register_con(net_input_t &input)
274280{
275   init_terminal(dev);
276   m_state = astate;
277}
281    input.set_net(*this);
282#if USE_LINKED_LIST
283    if (m_head == NULL)
284        m_head = &input;
285    else
286    {
287        input.m_next = m_head;
288        m_head = &input;
289    }
290#else
291   if (m_num_cons >= OUTPUT_MAX_CONNECTIONS)
292      fatalerror("Connections exceeded for %s\n", netdev()->name().cstr());
278293
279// ----------------------------------------------------------------------------------------
280// net_output_t
281// ----------------------------------------------------------------------------------------
294#if 0
295    int i;
296   /* keep similar devices together */
297   for (i = 0; i < m_num_cons; i++)
298      if (m_cons[i]->netdev() == input.netdev())
299         break;
282300
283net_output_t::net_output_t(int atype)
284   : net_terminal_t(atype)
285   , m_low_V(0.0)
286   , m_high_V(0.0)
287   //, m_last_Q(0)
288   //, m_Q(0)
289   //, m_new_Q(0)
290   //, m_Q_analog(0.0)
291   //, m_new_Q_analog(0.0)
292#if USE_LINKED_LIST
293    , m_head(NULL)
301   for (int j = m_num_cons; j > i; j--)
302      m_cons[j] = m_cons[j - 1];
303
304   m_cons[i] = &input;
305#else
306    m_cons[m_num_cons] = &input;
294307#endif
295    , m_num_cons(0)
296   , m_time(netlist_time::zero)
297   , m_active(0)
298   , m_in_queue(2)
299{
300    m_cur.Q = 0;
301    m_new.Q = 0;
302    m_last.Q = 0;
303   //m_cons = global_alloc_array(net_input_t *, OUTPUT_MAX_CONNECTIONS);
308#endif
309    m_num_cons++;
310    if (input.state() != net_input_t::INP_STATE_PASSIVE)
311        m_active++;
304312}
305313
306ATTR_HOT inline void net_output_t::update_dev(const net_input_t *inp, const UINT32 mask)
314ATTR_HOT inline void net_net_t::update_dev(const net_input_t *inp, const UINT32 mask)
307315{
308316   if ((inp->state() & mask) != 0)
309317   {
r26078r26079
315323   }
316324}
317325
318ATTR_HOT inline void net_output_t::update_devs()
326ATTR_HOT inline void net_net_t::update_devs()
319327{
320328   assert(m_num_cons != 0);
321329
r26078r26079
363371   m_last = m_cur;
364372}
365373
366ATTR_COLD void net_output_t::register_con(net_input_t &input)
367{
368#if USE_LINKED_LIST
369    if (m_head == NULL)
370        m_head = &input;
371    else
372    {
373        input.m_next = m_head;
374        m_head = &input;
375    }
376#else
377   if (m_num_cons >= OUTPUT_MAX_CONNECTIONS)
378      fatalerror("Connections exceeded for %s\n", netdev()->name().cstr());
374// ----------------------------------------------------------------------------------------
375// net_terminal_t
376// ----------------------------------------------------------------------------------------
379377
380#if 0
381    int i;
382   /* keep similar devices together */
383   for (i = 0; i < m_num_cons; i++)
384      if (m_cons[i]->netdev() == input.netdev())
385         break;
386
387   for (int j = m_num_cons; j > i; j--)
388      m_cons[j] = m_cons[j - 1];
389
390   m_cons[i] = &input;
391#else
392    m_cons[m_num_cons] = &input;
393#endif
394#endif
395    m_num_cons++;
396    if (input.state() != net_input_t::INP_STATE_PASSIVE)
397        m_active++;
378ATTR_COLD void net_terminal_t::init_terminal(netlist_core_device_t &dev)
379{
380   m_netdev = &dev;
381   init_object(*dev.netlist());
398382}
399383
400384// ----------------------------------------------------------------------------------------
401// netdev_const
385// net_input_t
402386// ----------------------------------------------------------------------------------------
403387
404NETLIB_START(netdev_ttl_const)
388ATTR_COLD void net_input_t::init_input(netlist_core_device_t &dev, net_input_state astate)
405389{
406   register_output("Q", m_Q);
407   register_param("CONST", m_const, 0.0);
390   init_terminal(dev);
391   m_state = astate;
408392}
409393
410NETLIB_UPDATE(netdev_ttl_const)
411{
412}
394// ----------------------------------------------------------------------------------------
395// net_output_t
396// ----------------------------------------------------------------------------------------
413397
414NETLIB_UPDATE_PARAM(netdev_ttl_const)
398net_output_t::net_output_t(int atype)
399   : net_terminal_t(atype)
400   , m_low_V(0.0)
401   , m_high_V(0.0)
402    , m_my_net(NET_DIGITAL)
415403{
416   OUTLOGIC(m_Q, m_const.ValueInt(), NLTIME_IMMEDIATE);
404    //m_net = new net_net_t(NET_DIGITAL);
405    this->set_net(m_my_net);
417406}
418407
419NETLIB_START(netdev_analog_const)
408ATTR_COLD void net_output_t::init_terminal(netlist_core_device_t &dev)
420409{
421   register_output("Q", m_Q);
422   register_param("CONST", m_const, 0.0);
410    net_terminal_t::init_terminal(dev);
411    net().init_object(*dev.netlist());
412    net().register_raildev(dev);
423413}
424414
425NETLIB_UPDATE(netdev_analog_const)
415ATTR_COLD void logic_output_t::initial(const netlist_sig_t val)
426416{
417    net().m_cur.Q = val;
418    net().m_new.Q = val;
419    net().m_last.Q = !val;
427420}
428421
429NETLIB_UPDATE_PARAM(netdev_analog_const)
422ATTR_COLD logic_output_t::logic_output_t()
423    : net_output_t(OUTPUT | SIGNAL_DIGITAL)
430424{
431   m_Q.initial(m_const.Value());
425    // Default to TTL
426    m_low_V = 0.1;  // these depend on sinked/sourced current. Values should be suitable for typical applications.
427    m_high_V = 4.8;
432428}
433429
434NETLIB_UPDATE(netdev_analog_callback)
430ATTR_COLD void logic_output_t::set_levels(const double low, const double high)
435431{
436   // FIXME: Remove after device cleanup
437   if (!m_callback.isnull())
438      m_callback(INPANALOG(m_in));
432    m_low_V = low;
433    m_high_V = high;
439434}
440435
436
441437// ----------------------------------------------------------------------------------------
442438// netdev_mainclock
443439// ----------------------------------------------------------------------------------------
444440
445ATTR_HOT inline void NETLIB_NAME(netdev_mainclock)::mc_update(net_output_t &Q, const netlist_time curtime)
441ATTR_HOT inline void NETLIB_NAME(netdev_mainclock)::mc_update(net_net_t &net, const netlist_time curtime)
446442{
447   Q.m_new.Q = !Q.m_new.Q;
448   Q.set_time(curtime);
449   Q.update_devs();
443   net.m_new.Q = !net.m_new.Q;
444   net.set_time(curtime);
445   net.update_devs();
450446}
451447
452448ATTR_COLD NETLIB_START(netdev_mainclock)
r26078r26079
465461
466462ATTR_HOT NETLIB_UPDATE(netdev_mainclock)
467463{
464    net_net_t &net = m_Q.net();
468465   // this is only called during setup ...
469   m_Q.m_new.Q = !m_Q.m_new.Q;
470   m_Q.set_time(m_netlist->time() + m_inc);
466   net.m_new.Q = !net.m_new.Q;
467   net.set_time(netlist()->time() + m_inc);
471468}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team