Previous 199869 Revisions Next

r26376 Saturday 23rd November, 2013 at 13:50:00 UTC by Couriersud
Netlist: Reworked object model a bit.

There is a slight performance drop (7%). Memory allocation order seems to be an issue here.
[src/emu/machine]netlist.c netlist.h
[src/emu/netlist]nl_base.c nl_base.h nl_lists.h nl_parser.c nl_setup.c nl_setup.h
[src/emu/netlist/devices]net_lib.c nld_system.c

trunk/src/emu/machine/netlist.c
r26375r26376
8888
8989   m_setup_func(*m_setup);
9090
91   m_setup->start_devices();
92
9193   bool allok = true;
9294   for (on_device_start **ods = m_device_start_list.first(); ods <= m_device_start_list.last(); ods++)
9395      allok &= (*ods)->OnDeviceStart();
trunk/src/emu/machine/netlist.h
r26375r26376
243243   virtual bool OnDeviceStart()
244244   {
245245      this->m_target = &m_netlist->setup().find_param(m_output);
246      return this->report_missing(this->m_target != NULL, "output", true);
246      return this->report_missing(this->m_target != NULL, "parameter", true);
247247   }
248248};
249249
trunk/src/emu/netlist/nl_parser.c
r26375r26376
5353   skipws();
5454   val = eval_param();
5555   NL_VERBOSE_OUT(("Parser: Param: %s %f\n", param.cstr(), val));
56   m_setup.find_param(param).initial(val);
56   m_setup.register_param(param, val);
57   //m_setup.find_param(param).initial(val);
5758   check_char(')');
5859}
5960
r26375r26376
6667
6768   skipws();
6869   name = getname(',');
69   dev = net_create_device_by_name(dev_name, m_setup, name);
70   m_setup.register_dev(dev);
70   dev = net_create_device_by_name(dev_name, m_setup);
71   m_setup.register_dev(dev, name);
7172   skipws();
7273   val = eval_param();
7374   check_char(')');
7475   paramfq = name;
7576   paramfq.cat(".CONST");
7677   NL_VERBOSE_OUT(("Parser: Const: %s %f\n", name.cstr(), val));
77   m_setup.find_param(paramfq).initial(val);
78   //m_setup.find_param(paramfq).initial(val);
79   m_setup.register_param(paramfq, val);
7880}
7981
8082void netlist_parser::netdev_device(const astring &dev_type)
r26375r26376
8587
8688   skipws();
8789   devname = getname2(',', ')');
88   dev = net_create_device_by_name(dev_type, m_setup, devname);
89   m_setup.register_dev(dev);
90   dev = net_create_device_by_name(dev_type, m_setup);
91   m_setup.register_dev(dev, devname);
9092   skipws();
9193   NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr()));
9294   cnt = 0;
r26375r26376
9698      skipws();
9799      astring output_name = getname2(',', ')');
98100      NL_VERBOSE_OUT(("Parser: ID: %s %s\n", output_name.cstr(), dev->m_terminals.item(cnt)->cstr()));
99      m_setup.register_link(devname + "." + *dev->m_terminals.item(cnt), output_name);
101      astring temp;
102      temp.printf("%s.[%d]", devname.cstr(), cnt);
103      m_setup.register_link(temp, output_name);
100104      skipws();
101105      cnt++;
102106   }
103   if (cnt != dev->m_terminals.count() && !dev->variable_input_count())
107/*
108    if (cnt != dev->m_terminals.count() && !dev->variable_input_count())
104109      fatalerror("netlist: input count mismatch for %s - expected %d found %d\n", devname.cstr(), dev->m_terminals.count(), cnt);
105110   if (dev->variable_input_count())
106111   {
107112      NL_VERBOSE_OUT(("variable inputs %s: %d\n", dev->name().cstr(), cnt));
108113   }
114   */
109115   check_char(')');
110116}
111117
trunk/src/emu/netlist/nl_base.h
r26375r26376
223223
224224
225225// ----------------------------------------------------------------------------------------
226// net_object_t
226// netlist_object_t
227227// ----------------------------------------------------------------------------------------
228228
229229class netlist_object_t
r26375r26376
244244        ALL      = 4   // <== devices usually fall into this category
245245    };
246246
247   ATTR_COLD netlist_object_t(const type_t atype, const family_t afamily)
248       : m_name(NULL)
249      , m_objtype(atype)
250        , m_family(afamily)
251        , m_netlist(NULL)
252        {}
247   ATTR_COLD netlist_object_t(const type_t atype, const family_t afamily);
253248
254   virtual ~netlist_object_t()
255   {
256       delete m_name;
257   }
249   virtual ~netlist_object_t();
258250
259    ATTR_COLD void init_object(netlist_base_t &nl, const astring &aname)
260    {
261        m_netlist = &nl;
262        m_name = new astring(aname);
263    }
251   ATTR_COLD void init_object(netlist_base_t &nl, const astring &aname);
264252
265    ATTR_COLD const astring &name() const { if (m_name == NULL) fatalerror("object not initialized"); return *m_name; }
253    ATTR_COLD const astring &name() const;
266254
267255   ATTR_HOT inline const type_t type() const { return m_objtype; }
268256    ATTR_HOT inline const family_t family() const { return m_family; }
r26375r26376
274262    ATTR_HOT inline const netlist_base_t & RESTRICT netlist() const { return *m_netlist; }
275263
276264private:
277    astring *m_name;
278265   const type_t m_objtype;
279266    const family_t m_family;
280267    netlist_base_t * RESTRICT m_netlist;
268    astring *m_name;
281269};
282270
283271// ----------------------------------------------------------------------------------------
272// netlist_owned_object_t
273// ----------------------------------------------------------------------------------------
274
275class netlist_owned_object_t : public netlist_object_t
276{
277public:
278    ATTR_COLD netlist_owned_object_t(const type_t atype, const family_t afamily);
279
280    ATTR_COLD void init_object(netlist_core_device_t &dev, const astring &aname);
281
282    ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; }
283private:
284    netlist_core_device_t * RESTRICT m_netdev;
285};
286
287// ----------------------------------------------------------------------------------------
284288// net_terminal_t
285289// ----------------------------------------------------------------------------------------
286290
287class netlist_terminal_t : public netlist_object_t
291class netlist_terminal_t : public netlist_owned_object_t
288292{
289293public:
290294
r26375r26376
299303        STATE_NONEX = 256
300304    };
301305
302   ATTR_COLD netlist_terminal_t(const type_t atype, const family_t afamily)
303   : netlist_object_t(atype, afamily)
304   , m_Idr(0.0)
305   , m_g(NETLIST_GMIN)
306    , m_update_list_next(NULL)
307   , m_netdev(NULL)
308    , m_net(NULL)
309    , m_state(STATE_NONEX)
310   {}
306   ATTR_COLD netlist_terminal_t(const type_t atype, const family_t afamily);
307    ATTR_COLD netlist_terminal_t();
311308
312    ATTR_COLD netlist_terminal_t()
313    : netlist_object_t(TERMINAL, ANALOG)
314    , m_Idr(0.0)
315    , m_update_list_next(NULL)
316    , m_netdev(NULL)
317    , m_net(NULL)
318    , m_state(STATE_NONEX)
319    {}
309   ATTR_COLD void init_object(netlist_core_device_t &dev, const astring &aname, const state_e astate);
320310
321   ATTR_COLD void init_terminal(netlist_core_device_t &dev, const astring &aname, const state_e astate);
322
323    ATTR_COLD void set_net(netlist_net_t &anet)   { m_net = &anet; }
324    ATTR_COLD bool has_net() { return (m_net != NULL); }
325
311    ATTR_COLD void set_net(netlist_net_t &anet);
312    ATTR_COLD inline bool has_net() { return (m_net != NULL); }
326313    ATTR_HOT inline const netlist_net_t & RESTRICT net() const { return *m_net;}
327314    ATTR_HOT inline netlist_net_t & RESTRICT net() { return *m_net;}
328315
r26375r26376
334321        m_state = astate;
335322    }
336323
337    ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; }
338
339324    double m_Idr; // drive current
340325    double m_g; // conductance
341326
342327    netlist_terminal_t *m_update_list_next;
343328
344329private:
345   netlist_core_device_t * RESTRICT m_netdev;
346330    netlist_net_t * RESTRICT m_net;
347331    state_e m_state;
348332};
r26375r26376
456440
457441    ATTR_COLD void register_con(netlist_terminal_t &terminal);
458442    ATTR_COLD void merge_net(netlist_net_t *othernet);
459    ATTR_COLD void register_railterminal(netlist_terminal_t &mr)
460    {
461        assert(m_railterminal == NULL);
462        m_railterminal = &mr;
463    }
443    ATTR_COLD void register_railterminal(netlist_terminal_t &mr);
464444
465445    /* inline not always works out */
466446    ATTR_HOT inline void update_devs();
r26375r26376
470450
471451    ATTR_HOT inline bool isRailNet() { return !(m_railterminal == NULL); }
472452    ATTR_HOT inline const netlist_terminal_t & RESTRICT  railterminal() const { return *m_railterminal; }
473    ATTR_HOT inline netlist_terminal_t & RESTRICT railterminal() { return *m_railterminal; }
453    ATTR_HOT inline const netlist_terminal_t & RESTRICT railterminal() { return *m_railterminal; }
474454
475455    /* Everything below is used by the logic subsystem */
476456
r26375r26376
533513{
534514public:
535515
536   netlist_output_t(const type_t atype, const family_t afamily);
516   ATTR_COLD netlist_output_t(const type_t atype, const family_t afamily);
537517
538    ATTR_COLD void init_terminal(netlist_core_device_t &dev, const astring &aname);
518    ATTR_COLD void init_object(netlist_core_device_t &dev, const astring &aname);
539519
540520   double m_low_V;
541521   double m_high_V;
r26375r26376
617597{
618598public:
619599
620   netlist_core_device_t();
600    ATTR_COLD netlist_core_device_t();
621601
622   virtual ~netlist_core_device_t();
602    ATTR_COLD virtual ~netlist_core_device_t();
623603
624604   ATTR_COLD virtual void init(netlist_setup_t &setup, const astring &name);
625605
r26375r26376
699679
700680   ATTR_COLD netlist_device_t();
701681
702   virtual ~netlist_device_t();
682   ATTR_COLD virtual ~netlist_device_t();
703683
704684   ATTR_COLD virtual void init(netlist_setup_t &setup, const astring &name);
705685
r26375r26376
750730
751731   ATTR_HOT inline void setTo(const double param) { m_param = param; m_netdev->update_param(); }
752732   ATTR_HOT inline void setTo(const int param) { m_param = param; m_netdev->update_param(); }
753   inline void initial(const double val) { m_param = val; }
754   inline void initial(const int val) { m_param = val; }
733   ATTR_COLD inline void initial(const double val) { m_param = val; }
734   ATTR_COLD inline void initial(const int val) { m_param = val; }
755735
756736   ATTR_HOT inline const double Value() const        { return m_param;   }
757737   ATTR_HOT inline const int    ValueInt() const     { return (int) m_param;     }
r26375r26376
774754{
775755public:
776756
777   typedef netlist_timed_queue1<netlist_net_t, netlist_time, 512> queue_t;
757   typedef netlist_timed_queue<netlist_net_t, netlist_time, 512> queue_t;
778758
779759   netlist_base_t();
780760   virtual ~netlist_base_t();
781761
782   void set_clock_freq(UINT64 clockfreq);
762   ATTR_COLD void set_clock_freq(UINT64 clockfreq);
783763
764    ATTR_HOT inline queue_t &queue() { return m_queue; }
765
784766   ATTR_HOT inline void push_to_queue(netlist_net_t &out, const netlist_time &attime)
785767   {
786768      m_queue.push(queue_t::entry_t(attime, out));
r26375r26376
797779
798780   ATTR_COLD void reset();
799781
800   // FIXME: should'nt be public
801   queue_t m_queue;
802
803782protected:
804783   // performance
805784   int m_perf_out_processed;
r26375r26376
807786   int m_perf_inp_active;
808787
809788private:
789    queue_t                     m_queue;
810790   NETLIB_NAME(mainclock) *    m_mainclock;
811791    NETLIB_NAME(solver) *       m_solver;
812792   netlist_time                m_time_ps;
r26375r26376
841821protected:
842822   void start()
843823   {
844      m_I.init_terminal(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
824      m_I.init_object(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
845825
846      m_Q.init_terminal(*this, "Q");
826      m_Q.init_object(*this, "Q");
847827      m_Q.initial(1);
848828   }
849829
r26375r26376
883863protected:
884864   void start()
885865   {
886      m_I.init_terminal(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
887      m_Q.init_terminal(*this, "Q");
866      m_I.init_object(*this, "I", netlist_terminal_t::STATE_INP_ACTIVE);
867      m_Q.init_object(*this, "Q");
888868      m_Q.initial(0);
889869   }
890870
r26375r26376
10441024   }
10451025};
10461026
1047netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup, const astring &icname);
1048netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup, const astring &icname);
1027netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup);
1028netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup);
10491029
10501030
10511031#endif /* NLBASE_H_ */
trunk/src/emu/netlist/nl_setup.c
r26375r26376
4747   m_terminals.reset();
4848}
4949
50netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev)
50netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const astring &name)
5151{
52   if (!(m_devices.add(dev->name(), dev, false)==TMERR_NONE))
53      fatalerror("Error adding %s to device list\n", dev->name().cstr());
52   if (!(m_devices.add(name, dev, false)==TMERR_NONE))
53      fatalerror("Error adding %s to device list\n", name.cstr());
5454   return dev;
5555}
5656
r26375r26376
144144            {
145145                netlist_terminal_t &term = dynamic_cast<netlist_terminal_t &>(obj);
146146                if (obj.isType(netlist_terminal_t::OUTPUT))
147                    dynamic_cast<netlist_output_t &>(term).init_terminal(upd_dev, dev.name() + "." + name);
147                    dynamic_cast<netlist_output_t &>(term).init_object(upd_dev, dev.name() + "." + name);
148148                else
149                    term.init_terminal(upd_dev, dev.name() + "." + name, state);
149                    term.init_object(upd_dev, dev.name() + "." + name, state);
150150
151151                if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE))
152152                    fatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr());
r26375r26376
161161                astring temp = param.netdev().name();
162162                temp.cat(".");
163163                temp.cat(name);
164                const astring *val = m_params_temp.find(temp);
165                if (val != NULL)
166                {
167                    //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr());
168                    double vald = 0;
169                    if (sscanf(val->cstr(), "%lf", &vald) != 1)
170                        fatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val->cstr());
171                    param.initial(vald);
172                }
164173                if (!(m_params.add(temp, &param, false)==TMERR_NONE))
165174                    fatalerror("Error adding parameter %s to parameter list\n", name.cstr());
166175            }
r26375r26376
178187      fatalerror("Error adding link %s<==%s to link list\n", sin.cstr(), sout.cstr());
179188}
180189
181const astring &netlist_setup_t::resolve_alias(const astring &name) const
190void netlist_setup_t::register_param(const astring &param, const double value)
182191{
183   const astring *ret = m_alias.find(name);
184   if (ret != NULL)
185      return *ret;
186   return name;
192    // FIXME: there should be a better way
193    astring temp;
194    temp.printf("%.9e", value);
195    register_param(param, temp);
187196}
188197
198void netlist_setup_t::register_param(const astring &param, const astring &value)
199{
200    if (!(m_params_temp.add(param, new astring(value), false)==TMERR_NONE))
201        fatalerror("Error adding parameter %s to parameter list\n", param.cstr());
202}
203
204const astring netlist_setup_t::resolve_alias(const astring &name) const
205{
206   const astring *temp = m_alias.find(name);
207   astring ret = name;
208   if (temp != NULL)
209      ret = *temp;
210   int p = ret.find(".[");
211   if (p > 0)
212   {
213       astring dname = ret;
214       netlist_device_t *dev = m_devices.find(dname.substr(0,p));
215       if (dev == NULL)
216           fatalerror("Device for %s not found\n", name.cstr());
217       ret.substr(p+2,ret.len()-p-3);
218       int c = atoi(ret);
219       ret = dev->name() + "." + *(dev->m_terminals.item(c));
220   }
221
222   return ret;
223}
224
189225netlist_terminal_t &netlist_setup_t::find_terminal(const astring &terminal_in)
190226{
191227    const astring &tname = resolve_alias(terminal_in);
r26375r26376
250286        x.printf("proxy_ad_%d", m_proxy_cnt++);
251287
252288        proxy->init(*this, x.cstr());
253        register_dev(proxy);
289        register_dev(proxy, x);
254290
255291        proxy->m_Q.net().register_con(in);
256292        out.net().register_con(proxy->m_I);
r26375r26376
263299        astring x = "";
264300        x.printf("proxy_da_%d", m_proxy_cnt++);
265301        proxy->init(*this, x.cstr());
266        register_dev(proxy);
302        register_dev(proxy, x);
267303
268304        proxy->m_Q.net().register_con(in);
269305        out.net().register_con(proxy->m_I);
r26375r26376
287323        astring x = "";
288324        x.printf("proxy_da_%d", m_proxy_cnt++);
289325        proxy->init(*this, x.cstr());
290        register_dev(proxy);
326        register_dev(proxy, x);
291327
292328        connect_terminals(term, proxy->m_I);
293329
r26375r26376
322358        astring x = "";
323359        x.printf("proxy_da_%d", m_proxy_cnt++);
324360        proxy->init(*this, x.cstr());
325        register_dev(proxy);
361        register_dev(proxy, x);
326362
327363        out.net().register_con(proxy->m_I);
328364
r26375r26376
449485
450486}
451487
488void netlist_setup_t::start_devices(void)
489{
490    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
491    {
492        netlist_device_t *dev = entry->object();
493        dev->init(*this, entry->tag());
494    }
495}
496
452497void netlist_setup_t::step_devices_once(void)
453498{
454499   /* make sure params are set now .. */
r26375r26376
480525         //entry->object()->s
481526         printf("Device %20s : %12d %15ld\n", entry->object()->name().cstr(), entry->object()->stat_count, (long int) entry->object()->total_time / (entry->object()->stat_count + 1));
482527      }
483      printf("Queue Start %15d\n", m_netlist.m_queue.m_prof_start);
484      printf("Queue End   %15d\n", m_netlist.m_queue.m_prof_end);
485      printf("Queue Sort  %15d\n", m_netlist.m_queue.m_prof_sort);
486      printf("Queue Move  %15d\n", m_netlist.m_queue.m_prof_sortmove);
528      printf("Queue Start %15d\n", m_netlist.queue().m_prof_start);
529      printf("Queue End   %15d\n", m_netlist.queue().m_prof_end);
530      printf("Queue Sort  %15d\n", m_netlist.queue().m_prof_sort);
531      printf("Queue Move  %15d\n", m_netlist.queue().m_prof_sortmove);
487532   }
488533}
trunk/src/emu/netlist/nl_lists.h
r26375r26376
8080// ----------------------------------------------------------------------------------------
8181
8282template <class _Element, class _Time, int _Size>
83class netlist_timed_queue1
83class netlist_timed_queue
8484{
8585public:
8686
r26375r26376
9797      _Element *m_object;
9898   };
9999
100   netlist_timed_queue1()
100   netlist_timed_queue()
101101   {
102102      //m_list = global_alloc_array(entry_t, SIZE);
103103      clear();
trunk/src/emu/netlist/nl_setup.h
r26375r26376
2020
2121#define NET_ALIAS(_alias, _name)                                                    \
2222   netlist.register_alias(# _alias, # _name);
23#define NET_NEW(_type , _name)  net_create_device_by_classname(NETLIB_NAME_STR(_type), netlist, # _name)
23#define NET_NEW(_type)  net_create_device_by_classname(NETLIB_NAME_STR(_type), netlist)
2424
2525#define NET_REGISTER_DEV(_type, _name)                                              \
26      netlist.register_dev(NET_NEW(_type, _name));
26      netlist.register_dev(NET_NEW(_type), # _name);
2727#define NET_REMOVE_DEV(_name)                                                       \
2828      netlist.remove_dev(# _name);
2929#define NET_REGISTER_SIGNAL(_type, _name)                                           \
r26375r26376
3232      netlist.register_link(# _name "." # _input, # _output);
3333#define NET_C(_input, _output)                                                      \
3434        netlist.register_link(NET_STR(_input) , NET_STR(_output));
35
3536#define NETDEV_PARAM(_name, _val)                                                   \
36      netlist.find_param(# _name).initial(_val);
37      netlist.register_param(# _name, _val);
38
3739#define NETDEV_PARAMI(_name, _param, _val)                                           \
38        netlist.find_param(# _name "." # _param).initial(_val);
40        netlist.register_param(# _name "." # _param, _val);
3941
40
4142#define NETLIST_NAME(_name) netlist ## _ ## _name
4243
4344#define NETLIST_START(_name) \
r26375r26376
8788
8889   netlist_base_t &netlist() { return m_netlist; }
8990
90   netlist_device_t *register_dev(netlist_device_t *dev);
91   netlist_device_t *register_dev(netlist_device_t *dev, const astring &name);
9192   void remove_dev(const astring &name);
9293
9394    void register_alias(const astring &alias, const astring &out);
94
9595    void register_link(const astring &sin, const astring &sout);
96    void register_param(const astring &param, const astring &value);
97    void register_param(const astring &param, const double value);
9698
9799    void register_object(netlist_device_t &dev, netlist_core_device_t &upd_dev, const astring &name, netlist_object_t &obj, netlist_input_t::state_e state);
98100
r26375r26376
105107
106108   void parse(char *buf);
107109
110    void start_devices(void);
108111   void resolve_inputs(void);
109112   void step_devices_once(void);
110113
r26375r26376
123126   tagmap_astring_t m_alias;
124127   tagmap_param_t  m_params;
125128   tagmap_link_t  m_links;
129    tagmap_astring_t m_params_temp;
126130
127131   int m_proxy_cnt;
128132
r26375r26376
134138    // helpers
135139    astring objtype_as_astr(netlist_object_t &in);
136140
137   const astring &resolve_alias(const astring &name) const;
141   const astring resolve_alias(const astring &name) const;
138142};
139143
140144#endif /* NLSETUP_H_ */
trunk/src/emu/netlist/devices/nld_system.c
r26375r26376
143143
144144    if (delta >= m_inc)
145145    {
146        NL_VERBOSE_OUT(("Step!\n"));
146147        /* update all terminals for new time step */
147148        m_last_step = now;
148149        for (netlist_terminal_t **p = m_terms.first(); p != NULL; p = m_terms.next(p))
trunk/src/emu/netlist/devices/net_lib.c
r26375r26376
194194   register_param("VS", m_VS, 5.0);
195195   register_param("VL", m_VL, 0.0 *5.0);
196196
197   m_THRESHOLD_OUT.init_terminal(*this, "THRESHOLD");
197   m_THRESHOLD_OUT.init_object(*this, "THRESHOLD");
198198   register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, netlist_input_t::STATE_INP_ACTIVE);
199199
200200   m_Q.initial(5.0 * 0.4);
r26375r26376
987987   NULL
988988};
989989
990netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup, const astring &icname)
990netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup)
991991{
992992   const net_device_t_base_factory **p = &netregistry[0];
993993   while (*p != NULL)
r26375r26376
995995      if (strcmp((*p)->classname(), classname) == 0)
996996      {
997997         netlist_device_t *ret = (*p)->Create();
998         ret->init(setup, icname);
999998         return ret;
1000999      }
10011000      p++;
10021001   }
1003   fatalerror("Class %s required for IC %s not found!\n", classname.cstr(), icname.cstr());
1002   fatalerror("Class %s not found!\n", classname.cstr());
10041003   return NULL; // appease code analysis
10051004}
10061005
1007netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup, const astring &icname)
1006netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup)
10081007{
10091008   const net_device_t_base_factory **p = &netregistry[0];
10101009   while (*p != NULL)
r26375r26376
10121011      if (strcmp((*p)->name(), name) == 0)
10131012      {
10141013         netlist_device_t *ret = (*p)->Create();
1015         ret->init(setup, icname);
1014         //ret->init(setup, icname);
10161015         return ret;
10171016      }
10181017      p++;
10191018   }
1020   fatalerror("Class %s required for IC %s not found!\n", name.cstr(), icname.cstr());
1019   fatalerror("Class %s not found!\n", name.cstr());
10211020   return NULL; // appease code analysis
10221021}
trunk/src/emu/netlist/nl_base.c
r26375r26376
66#include "nl_base.h"
77#include "devices/nld_system.h"
88
9// ----------------------------------------------------------------------------------------
10// netlist_object_t
11// ----------------------------------------------------------------------------------------
912
13ATTR_COLD netlist_object_t::netlist_object_t(const type_t atype, const family_t afamily)
14: m_objtype(atype)
15, m_family(afamily)
16, m_netlist(NULL)
17, m_name(NULL)
18{}
19
20ATTR_COLD netlist_object_t::~netlist_object_t()
21{
22    delete m_name;
23}
24
25ATTR_COLD void netlist_object_t::init_object(netlist_base_t &nl, const astring &aname)
26{
27    m_netlist = &nl;
28    m_name = new astring(aname);
29}
30
31ATTR_COLD const astring &netlist_object_t::name() const
32{
33    if (m_name == NULL)
34        fatalerror("object not initialized");
35    return *m_name;
36}
37
1038// ----------------------------------------------------------------------------------------
39// netlist_owned_object_t
40// ----------------------------------------------------------------------------------------
41
42ATTR_COLD netlist_owned_object_t::netlist_owned_object_t(const type_t atype,
43        const family_t afamily)
44: netlist_object_t(atype, afamily)
45, m_netdev(NULL)
46{
47}
48
49ATTR_COLD void netlist_owned_object_t::init_object(netlist_core_device_t &dev,
50        const astring &aname)
51{
52    netlist_object_t::init_object(dev.netlist(), aname);
53    m_netdev = &dev;
54}
55
56// ----------------------------------------------------------------------------------------
1157// netlist_base_t
1258// ----------------------------------------------------------------------------------------
1359
r26375r26376
244290// FIXME: Revise internal links ...
245291ATTR_COLD void netlist_device_t::register_link_internal(netlist_core_device_t &dev, netlist_input_t &in, netlist_output_t &out, netlist_input_t::state_e aState)
246292{
247    in.init_terminal(dev, "internal input", aState);
293    in.init_object(dev, "internal input", aState);
248294    // ensure we are not yet initialized ...
249295    if (!out.net().isRailNet())
250        out.init_terminal(dev, "internal output");
296        out.init_object(dev, "internal output");
251297   //if (in.state() != net_input_t::INP_STATE_PASSIVE)
252298      out.net().register_con(in);
253299}
r26375r26376
287333    m_last.Q = 0;
288334};
289335
336ATTR_COLD void netlist_net_t::register_railterminal(netlist_terminal_t &mr)
337{
338    assert(m_railterminal == NULL);
339    m_railterminal = &mr;
340}
341
290342ATTR_COLD void netlist_net_t::merge_net(netlist_net_t *othernet)
291343{
292344    NL_VERBOSE_OUT(("merging nets ...\n"));
r26375r26376
377429// netlist_terminal_t
378430// ----------------------------------------------------------------------------------------
379431
380ATTR_COLD void netlist_terminal_t::init_terminal(netlist_core_device_t &dev, const astring &aname, const state_e astate)
432ATTR_COLD netlist_terminal_t::netlist_terminal_t(const type_t atype, const family_t afamily)
433: netlist_owned_object_t(atype, afamily)
434, m_Idr(0.0)
435, m_g(NETLIST_GMIN)
436, m_update_list_next(NULL)
437, m_net(NULL)
438, m_state(STATE_NONEX)
381439{
382   m_netdev = &dev;
440
441}
442
443ATTR_COLD netlist_terminal_t::netlist_terminal_t()
444: netlist_owned_object_t(TERMINAL, ANALOG)
445, m_Idr(0.0)
446, m_g(NETLIST_GMIN)
447, m_update_list_next(NULL)
448, m_net(NULL)
449, m_state(STATE_NONEX)
450{
451
452}
453
454ATTR_COLD void netlist_terminal_t::init_object(netlist_core_device_t &dev, const astring &aname, const state_e astate)
455{
383456   set_state(astate);
384   init_object(dev.netlist(), aname);
457   netlist_owned_object_t::init_object(dev, aname);
385458}
386459
460ATTR_COLD void netlist_terminal_t::set_net(netlist_net_t &anet)
461{
462    m_net = &anet;
463}
464
387465// ----------------------------------------------------------------------------------------
388466// net_input_t
389467// ----------------------------------------------------------------------------------------
r26375r26376
402480    this->set_net(m_my_net);
403481}
404482
405ATTR_COLD void netlist_output_t::init_terminal(netlist_core_device_t &dev, const astring &aname)
483ATTR_COLD void netlist_output_t::init_object(netlist_core_device_t &dev, const astring &aname)
406484{
407    netlist_terminal_t::init_terminal(dev, aname, STATE_OUT);
485    netlist_terminal_t::init_object(dev, aname, STATE_OUT);
408486    net().init_object(dev.netlist(), aname);
409487    net().register_railterminal(*this);
410488}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team