trunk/src/emu/netlist/nl_parser.c
| r26375 | r26376 | |
| 53 | 53 | skipws(); |
| 54 | 54 | val = eval_param(); |
| 55 | 55 | 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); |
| 57 | 58 | check_char(')'); |
| 58 | 59 | } |
| 59 | 60 | |
| r26375 | r26376 | |
| 66 | 67 | |
| 67 | 68 | skipws(); |
| 68 | 69 | 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); |
| 71 | 72 | skipws(); |
| 72 | 73 | val = eval_param(); |
| 73 | 74 | check_char(')'); |
| 74 | 75 | paramfq = name; |
| 75 | 76 | paramfq.cat(".CONST"); |
| 76 | 77 | 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); |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | void netlist_parser::netdev_device(const astring &dev_type) |
| r26375 | r26376 | |
| 85 | 87 | |
| 86 | 88 | skipws(); |
| 87 | 89 | 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); |
| 90 | 92 | skipws(); |
| 91 | 93 | NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr())); |
| 92 | 94 | cnt = 0; |
| r26375 | r26376 | |
| 96 | 98 | skipws(); |
| 97 | 99 | astring output_name = getname2(',', ')'); |
| 98 | 100 | 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); |
| 100 | 104 | skipws(); |
| 101 | 105 | cnt++; |
| 102 | 106 | } |
| 103 | | if (cnt != dev->m_terminals.count() && !dev->variable_input_count()) |
| 107 | /* |
| 108 | if (cnt != dev->m_terminals.count() && !dev->variable_input_count()) |
| 104 | 109 | fatalerror("netlist: input count mismatch for %s - expected %d found %d\n", devname.cstr(), dev->m_terminals.count(), cnt); |
| 105 | 110 | if (dev->variable_input_count()) |
| 106 | 111 | { |
| 107 | 112 | NL_VERBOSE_OUT(("variable inputs %s: %d\n", dev->name().cstr(), cnt)); |
| 108 | 113 | } |
| 114 | */ |
| 109 | 115 | check_char(')'); |
| 110 | 116 | } |
| 111 | 117 | |
trunk/src/emu/netlist/nl_base.h
| r26375 | r26376 | |
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | // ---------------------------------------------------------------------------------------- |
| 226 | | // net_object_t |
| 226 | // netlist_object_t |
| 227 | 227 | // ---------------------------------------------------------------------------------------- |
| 228 | 228 | |
| 229 | 229 | class netlist_object_t |
| r26375 | r26376 | |
| 244 | 244 | ALL = 4 // <== devices usually fall into this category |
| 245 | 245 | }; |
| 246 | 246 | |
| 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); |
| 253 | 248 | |
| 254 | | virtual ~netlist_object_t() |
| 255 | | { |
| 256 | | delete m_name; |
| 257 | | } |
| 249 | virtual ~netlist_object_t(); |
| 258 | 250 | |
| 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); |
| 264 | 252 | |
| 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; |
| 266 | 254 | |
| 267 | 255 | ATTR_HOT inline const type_t type() const { return m_objtype; } |
| 268 | 256 | ATTR_HOT inline const family_t family() const { return m_family; } |
| r26375 | r26376 | |
| 274 | 262 | ATTR_HOT inline const netlist_base_t & RESTRICT netlist() const { return *m_netlist; } |
| 275 | 263 | |
| 276 | 264 | private: |
| 277 | | astring *m_name; |
| 278 | 265 | const type_t m_objtype; |
| 279 | 266 | const family_t m_family; |
| 280 | 267 | netlist_base_t * RESTRICT m_netlist; |
| 268 | astring *m_name; |
| 281 | 269 | }; |
| 282 | 270 | |
| 283 | 271 | // ---------------------------------------------------------------------------------------- |
| 272 | // netlist_owned_object_t |
| 273 | // ---------------------------------------------------------------------------------------- |
| 274 | |
| 275 | class netlist_owned_object_t : public netlist_object_t |
| 276 | { |
| 277 | public: |
| 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; } |
| 283 | private: |
| 284 | netlist_core_device_t * RESTRICT m_netdev; |
| 285 | }; |
| 286 | |
| 287 | // ---------------------------------------------------------------------------------------- |
| 284 | 288 | // net_terminal_t |
| 285 | 289 | // ---------------------------------------------------------------------------------------- |
| 286 | 290 | |
| 287 | | class netlist_terminal_t : public netlist_object_t |
| 291 | class netlist_terminal_t : public netlist_owned_object_t |
| 288 | 292 | { |
| 289 | 293 | public: |
| 290 | 294 | |
| r26375 | r26376 | |
| 299 | 303 | STATE_NONEX = 256 |
| 300 | 304 | }; |
| 301 | 305 | |
| 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(); |
| 311 | 308 | |
| 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); |
| 320 | 310 | |
| 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); } |
| 326 | 313 | ATTR_HOT inline const netlist_net_t & RESTRICT net() const { return *m_net;} |
| 327 | 314 | ATTR_HOT inline netlist_net_t & RESTRICT net() { return *m_net;} |
| 328 | 315 | |
| r26375 | r26376 | |
| 334 | 321 | m_state = astate; |
| 335 | 322 | } |
| 336 | 323 | |
| 337 | | ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; } |
| 338 | | |
| 339 | 324 | double m_Idr; // drive current |
| 340 | 325 | double m_g; // conductance |
| 341 | 326 | |
| 342 | 327 | netlist_terminal_t *m_update_list_next; |
| 343 | 328 | |
| 344 | 329 | private: |
| 345 | | netlist_core_device_t * RESTRICT m_netdev; |
| 346 | 330 | netlist_net_t * RESTRICT m_net; |
| 347 | 331 | state_e m_state; |
| 348 | 332 | }; |
| r26375 | r26376 | |
| 456 | 440 | |
| 457 | 441 | ATTR_COLD void register_con(netlist_terminal_t &terminal); |
| 458 | 442 | 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); |
| 464 | 444 | |
| 465 | 445 | /* inline not always works out */ |
| 466 | 446 | ATTR_HOT inline void update_devs(); |
| r26375 | r26376 | |
| 470 | 450 | |
| 471 | 451 | ATTR_HOT inline bool isRailNet() { return !(m_railterminal == NULL); } |
| 472 | 452 | 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; } |
| 474 | 454 | |
| 475 | 455 | /* Everything below is used by the logic subsystem */ |
| 476 | 456 | |
| r26375 | r26376 | |
| 533 | 513 | { |
| 534 | 514 | public: |
| 535 | 515 | |
| 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); |
| 537 | 517 | |
| 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); |
| 539 | 519 | |
| 540 | 520 | double m_low_V; |
| 541 | 521 | double m_high_V; |
| r26375 | r26376 | |
| 617 | 597 | { |
| 618 | 598 | public: |
| 619 | 599 | |
| 620 | | netlist_core_device_t(); |
| 600 | ATTR_COLD netlist_core_device_t(); |
| 621 | 601 | |
| 622 | | virtual ~netlist_core_device_t(); |
| 602 | ATTR_COLD virtual ~netlist_core_device_t(); |
| 623 | 603 | |
| 624 | 604 | ATTR_COLD virtual void init(netlist_setup_t &setup, const astring &name); |
| 625 | 605 | |
| r26375 | r26376 | |
| 699 | 679 | |
| 700 | 680 | ATTR_COLD netlist_device_t(); |
| 701 | 681 | |
| 702 | | virtual ~netlist_device_t(); |
| 682 | ATTR_COLD virtual ~netlist_device_t(); |
| 703 | 683 | |
| 704 | 684 | ATTR_COLD virtual void init(netlist_setup_t &setup, const astring &name); |
| 705 | 685 | |
| r26375 | r26376 | |
| 750 | 730 | |
| 751 | 731 | ATTR_HOT inline void setTo(const double param) { m_param = param; m_netdev->update_param(); } |
| 752 | 732 | 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; } |
| 755 | 735 | |
| 756 | 736 | ATTR_HOT inline const double Value() const { return m_param; } |
| 757 | 737 | ATTR_HOT inline const int ValueInt() const { return (int) m_param; } |
| r26375 | r26376 | |
| 774 | 754 | { |
| 775 | 755 | public: |
| 776 | 756 | |
| 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; |
| 778 | 758 | |
| 779 | 759 | netlist_base_t(); |
| 780 | 760 | virtual ~netlist_base_t(); |
| 781 | 761 | |
| 782 | | void set_clock_freq(UINT64 clockfreq); |
| 762 | ATTR_COLD void set_clock_freq(UINT64 clockfreq); |
| 783 | 763 | |
| 764 | ATTR_HOT inline queue_t &queue() { return m_queue; } |
| 765 | |
| 784 | 766 | ATTR_HOT inline void push_to_queue(netlist_net_t &out, const netlist_time &attime) |
| 785 | 767 | { |
| 786 | 768 | m_queue.push(queue_t::entry_t(attime, out)); |
| r26375 | r26376 | |
| 797 | 779 | |
| 798 | 780 | ATTR_COLD void reset(); |
| 799 | 781 | |
| 800 | | // FIXME: should'nt be public |
| 801 | | queue_t m_queue; |
| 802 | | |
| 803 | 782 | protected: |
| 804 | 783 | // performance |
| 805 | 784 | int m_perf_out_processed; |
| r26375 | r26376 | |
| 807 | 786 | int m_perf_inp_active; |
| 808 | 787 | |
| 809 | 788 | private: |
| 789 | queue_t m_queue; |
| 810 | 790 | NETLIB_NAME(mainclock) * m_mainclock; |
| 811 | 791 | NETLIB_NAME(solver) * m_solver; |
| 812 | 792 | netlist_time m_time_ps; |
| r26375 | r26376 | |
| 841 | 821 | protected: |
| 842 | 822 | void start() |
| 843 | 823 | { |
| 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); |
| 845 | 825 | |
| 846 | | m_Q.init_terminal(*this, "Q"); |
| 826 | m_Q.init_object(*this, "Q"); |
| 847 | 827 | m_Q.initial(1); |
| 848 | 828 | } |
| 849 | 829 | |
| r26375 | r26376 | |
| 883 | 863 | protected: |
| 884 | 864 | void start() |
| 885 | 865 | { |
| 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"); |
| 888 | 868 | m_Q.initial(0); |
| 889 | 869 | } |
| 890 | 870 | |
| r26375 | r26376 | |
| 1044 | 1024 | } |
| 1045 | 1025 | }; |
| 1046 | 1026 | |
| 1047 | | netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup, const astring &icname); |
| 1048 | | netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup, const astring &icname); |
| 1027 | netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup); |
| 1028 | netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup); |
| 1049 | 1029 | |
| 1050 | 1030 | |
| 1051 | 1031 | #endif /* NLBASE_H_ */ |
trunk/src/emu/netlist/nl_setup.c
| r26375 | r26376 | |
| 47 | 47 | m_terminals.reset(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | | netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev) |
| 50 | netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const astring &name) |
| 51 | 51 | { |
| 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()); |
| 54 | 54 | return dev; |
| 55 | 55 | } |
| 56 | 56 | |
| r26375 | r26376 | |
| 144 | 144 | { |
| 145 | 145 | netlist_terminal_t &term = dynamic_cast<netlist_terminal_t &>(obj); |
| 146 | 146 | 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); |
| 148 | 148 | else |
| 149 | | term.init_terminal(upd_dev, dev.name() + "." + name, state); |
| 149 | term.init_object(upd_dev, dev.name() + "." + name, state); |
| 150 | 150 | |
| 151 | 151 | if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE)) |
| 152 | 152 | fatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr()); |
| r26375 | r26376 | |
| 161 | 161 | astring temp = param.netdev().name(); |
| 162 | 162 | temp.cat("."); |
| 163 | 163 | 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 | } |
| 164 | 173 | if (!(m_params.add(temp, ¶m, false)==TMERR_NONE)) |
| 165 | 174 | fatalerror("Error adding parameter %s to parameter list\n", name.cstr()); |
| 166 | 175 | } |
| r26375 | r26376 | |
| 178 | 187 | fatalerror("Error adding link %s<==%s to link list\n", sin.cstr(), sout.cstr()); |
| 179 | 188 | } |
| 180 | 189 | |
| 181 | | const astring &netlist_setup_t::resolve_alias(const astring &name) const |
| 190 | void netlist_setup_t::register_param(const astring ¶m, const double value) |
| 182 | 191 | { |
| 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); |
| 187 | 196 | } |
| 188 | 197 | |
| 198 | void netlist_setup_t::register_param(const astring ¶m, 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 | |
| 204 | const 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 | |
| 189 | 225 | netlist_terminal_t &netlist_setup_t::find_terminal(const astring &terminal_in) |
| 190 | 226 | { |
| 191 | 227 | const astring &tname = resolve_alias(terminal_in); |
| r26375 | r26376 | |
| 250 | 286 | x.printf("proxy_ad_%d", m_proxy_cnt++); |
| 251 | 287 | |
| 252 | 288 | proxy->init(*this, x.cstr()); |
| 253 | | register_dev(proxy); |
| 289 | register_dev(proxy, x); |
| 254 | 290 | |
| 255 | 291 | proxy->m_Q.net().register_con(in); |
| 256 | 292 | out.net().register_con(proxy->m_I); |
| r26375 | r26376 | |
| 263 | 299 | astring x = ""; |
| 264 | 300 | x.printf("proxy_da_%d", m_proxy_cnt++); |
| 265 | 301 | proxy->init(*this, x.cstr()); |
| 266 | | register_dev(proxy); |
| 302 | register_dev(proxy, x); |
| 267 | 303 | |
| 268 | 304 | proxy->m_Q.net().register_con(in); |
| 269 | 305 | out.net().register_con(proxy->m_I); |
| r26375 | r26376 | |
| 287 | 323 | astring x = ""; |
| 288 | 324 | x.printf("proxy_da_%d", m_proxy_cnt++); |
| 289 | 325 | proxy->init(*this, x.cstr()); |
| 290 | | register_dev(proxy); |
| 326 | register_dev(proxy, x); |
| 291 | 327 | |
| 292 | 328 | connect_terminals(term, proxy->m_I); |
| 293 | 329 | |
| r26375 | r26376 | |
| 322 | 358 | astring x = ""; |
| 323 | 359 | x.printf("proxy_da_%d", m_proxy_cnt++); |
| 324 | 360 | proxy->init(*this, x.cstr()); |
| 325 | | register_dev(proxy); |
| 361 | register_dev(proxy, x); |
| 326 | 362 | |
| 327 | 363 | out.net().register_con(proxy->m_I); |
| 328 | 364 | |
| r26375 | r26376 | |
| 449 | 485 | |
| 450 | 486 | } |
| 451 | 487 | |
| 488 | void 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 | |
| 452 | 497 | void netlist_setup_t::step_devices_once(void) |
| 453 | 498 | { |
| 454 | 499 | /* make sure params are set now .. */ |
| r26375 | r26376 | |
| 480 | 525 | //entry->object()->s |
| 481 | 526 | 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)); |
| 482 | 527 | } |
| 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); |
| 487 | 532 | } |
| 488 | 533 | } |
trunk/src/emu/netlist/nl_setup.h
| r26375 | r26376 | |
| 20 | 20 | |
| 21 | 21 | #define NET_ALIAS(_alias, _name) \ |
| 22 | 22 | 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) |
| 24 | 24 | |
| 25 | 25 | #define NET_REGISTER_DEV(_type, _name) \ |
| 26 | | netlist.register_dev(NET_NEW(_type, _name)); |
| 26 | netlist.register_dev(NET_NEW(_type), # _name); |
| 27 | 27 | #define NET_REMOVE_DEV(_name) \ |
| 28 | 28 | netlist.remove_dev(# _name); |
| 29 | 29 | #define NET_REGISTER_SIGNAL(_type, _name) \ |
| r26375 | r26376 | |
| 32 | 32 | netlist.register_link(# _name "." # _input, # _output); |
| 33 | 33 | #define NET_C(_input, _output) \ |
| 34 | 34 | netlist.register_link(NET_STR(_input) , NET_STR(_output)); |
| 35 | |
| 35 | 36 | #define NETDEV_PARAM(_name, _val) \ |
| 36 | | netlist.find_param(# _name).initial(_val); |
| 37 | netlist.register_param(# _name, _val); |
| 38 | |
| 37 | 39 | #define NETDEV_PARAMI(_name, _param, _val) \ |
| 38 | | netlist.find_param(# _name "." # _param).initial(_val); |
| 40 | netlist.register_param(# _name "." # _param, _val); |
| 39 | 41 | |
| 40 | | |
| 41 | 42 | #define NETLIST_NAME(_name) netlist ## _ ## _name |
| 42 | 43 | |
| 43 | 44 | #define NETLIST_START(_name) \ |
| r26375 | r26376 | |
| 87 | 88 | |
| 88 | 89 | netlist_base_t &netlist() { return m_netlist; } |
| 89 | 90 | |
| 90 | | netlist_device_t *register_dev(netlist_device_t *dev); |
| 91 | netlist_device_t *register_dev(netlist_device_t *dev, const astring &name); |
| 91 | 92 | void remove_dev(const astring &name); |
| 92 | 93 | |
| 93 | 94 | void register_alias(const astring &alias, const astring &out); |
| 94 | | |
| 95 | 95 | void register_link(const astring &sin, const astring &sout); |
| 96 | void register_param(const astring ¶m, const astring &value); |
| 97 | void register_param(const astring ¶m, const double value); |
| 96 | 98 | |
| 97 | 99 | 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); |
| 98 | 100 | |
| r26375 | r26376 | |
| 105 | 107 | |
| 106 | 108 | void parse(char *buf); |
| 107 | 109 | |
| 110 | void start_devices(void); |
| 108 | 111 | void resolve_inputs(void); |
| 109 | 112 | void step_devices_once(void); |
| 110 | 113 | |
| r26375 | r26376 | |
| 123 | 126 | tagmap_astring_t m_alias; |
| 124 | 127 | tagmap_param_t m_params; |
| 125 | 128 | tagmap_link_t m_links; |
| 129 | tagmap_astring_t m_params_temp; |
| 126 | 130 | |
| 127 | 131 | int m_proxy_cnt; |
| 128 | 132 | |
| r26375 | r26376 | |
| 134 | 138 | // helpers |
| 135 | 139 | astring objtype_as_astr(netlist_object_t &in); |
| 136 | 140 | |
| 137 | | const astring &resolve_alias(const astring &name) const; |
| 141 | const astring resolve_alias(const astring &name) const; |
| 138 | 142 | }; |
| 139 | 143 | |
| 140 | 144 | #endif /* NLSETUP_H_ */ |
trunk/src/emu/netlist/devices/net_lib.c
| r26375 | r26376 | |
| 194 | 194 | register_param("VS", m_VS, 5.0); |
| 195 | 195 | register_param("VL", m_VL, 0.0 *5.0); |
| 196 | 196 | |
| 197 | | m_THRESHOLD_OUT.init_terminal(*this, "THRESHOLD"); |
| 197 | m_THRESHOLD_OUT.init_object(*this, "THRESHOLD"); |
| 198 | 198 | register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, netlist_input_t::STATE_INP_ACTIVE); |
| 199 | 199 | |
| 200 | 200 | m_Q.initial(5.0 * 0.4); |
| r26375 | r26376 | |
| 987 | 987 | NULL |
| 988 | 988 | }; |
| 989 | 989 | |
| 990 | | netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup, const astring &icname) |
| 990 | netlist_device_t *net_create_device_by_classname(const astring &classname, netlist_setup_t &setup) |
| 991 | 991 | { |
| 992 | 992 | const net_device_t_base_factory **p = &netregistry[0]; |
| 993 | 993 | while (*p != NULL) |
| r26375 | r26376 | |
| 995 | 995 | if (strcmp((*p)->classname(), classname) == 0) |
| 996 | 996 | { |
| 997 | 997 | netlist_device_t *ret = (*p)->Create(); |
| 998 | | ret->init(setup, icname); |
| 999 | 998 | return ret; |
| 1000 | 999 | } |
| 1001 | 1000 | p++; |
| 1002 | 1001 | } |
| 1003 | | fatalerror("Class %s required for IC %s not found!\n", classname.cstr(), icname.cstr()); |
| 1002 | fatalerror("Class %s not found!\n", classname.cstr()); |
| 1004 | 1003 | return NULL; // appease code analysis |
| 1005 | 1004 | } |
| 1006 | 1005 | |
| 1007 | | netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup, const astring &icname) |
| 1006 | netlist_device_t *net_create_device_by_name(const astring &name, netlist_setup_t &setup) |
| 1008 | 1007 | { |
| 1009 | 1008 | const net_device_t_base_factory **p = &netregistry[0]; |
| 1010 | 1009 | while (*p != NULL) |
| r26375 | r26376 | |
| 1012 | 1011 | if (strcmp((*p)->name(), name) == 0) |
| 1013 | 1012 | { |
| 1014 | 1013 | netlist_device_t *ret = (*p)->Create(); |
| 1015 | | ret->init(setup, icname); |
| 1014 | //ret->init(setup, icname); |
| 1016 | 1015 | return ret; |
| 1017 | 1016 | } |
| 1018 | 1017 | p++; |
| 1019 | 1018 | } |
| 1020 | | fatalerror("Class %s required for IC %s not found!\n", name.cstr(), icname.cstr()); |
| 1019 | fatalerror("Class %s not found!\n", name.cstr()); |
| 1021 | 1020 | return NULL; // appease code analysis |
| 1022 | 1021 | } |
trunk/src/emu/netlist/nl_base.c
| r26375 | r26376 | |
| 6 | 6 | #include "nl_base.h" |
| 7 | 7 | #include "devices/nld_system.h" |
| 8 | 8 | |
| 9 | // ---------------------------------------------------------------------------------------- |
| 10 | // netlist_object_t |
| 11 | // ---------------------------------------------------------------------------------------- |
| 9 | 12 | |
| 13 | ATTR_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 | |
| 20 | ATTR_COLD netlist_object_t::~netlist_object_t() |
| 21 | { |
| 22 | delete m_name; |
| 23 | } |
| 24 | |
| 25 | ATTR_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 | |
| 31 | ATTR_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 | |
| 10 | 38 | // ---------------------------------------------------------------------------------------- |
| 39 | // netlist_owned_object_t |
| 40 | // ---------------------------------------------------------------------------------------- |
| 41 | |
| 42 | ATTR_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 | |
| 49 | ATTR_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 | // ---------------------------------------------------------------------------------------- |
| 11 | 57 | // netlist_base_t |
| 12 | 58 | // ---------------------------------------------------------------------------------------- |
| 13 | 59 | |
| r26375 | r26376 | |
| 244 | 290 | // FIXME: Revise internal links ... |
| 245 | 291 | ATTR_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) |
| 246 | 292 | { |
| 247 | | in.init_terminal(dev, "internal input", aState); |
| 293 | in.init_object(dev, "internal input", aState); |
| 248 | 294 | // ensure we are not yet initialized ... |
| 249 | 295 | if (!out.net().isRailNet()) |
| 250 | | out.init_terminal(dev, "internal output"); |
| 296 | out.init_object(dev, "internal output"); |
| 251 | 297 | //if (in.state() != net_input_t::INP_STATE_PASSIVE) |
| 252 | 298 | out.net().register_con(in); |
| 253 | 299 | } |
| r26375 | r26376 | |
| 287 | 333 | m_last.Q = 0; |
| 288 | 334 | }; |
| 289 | 335 | |
| 336 | ATTR_COLD void netlist_net_t::register_railterminal(netlist_terminal_t &mr) |
| 337 | { |
| 338 | assert(m_railterminal == NULL); |
| 339 | m_railterminal = &mr; |
| 340 | } |
| 341 | |
| 290 | 342 | ATTR_COLD void netlist_net_t::merge_net(netlist_net_t *othernet) |
| 291 | 343 | { |
| 292 | 344 | NL_VERBOSE_OUT(("merging nets ...\n")); |
| r26375 | r26376 | |
| 377 | 429 | // netlist_terminal_t |
| 378 | 430 | // ---------------------------------------------------------------------------------------- |
| 379 | 431 | |
| 380 | | ATTR_COLD void netlist_terminal_t::init_terminal(netlist_core_device_t &dev, const astring &aname, const state_e astate) |
| 432 | ATTR_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) |
| 381 | 439 | { |
| 382 | | m_netdev = &dev; |
| 440 | |
| 441 | } |
| 442 | |
| 443 | ATTR_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 | |
| 454 | ATTR_COLD void netlist_terminal_t::init_object(netlist_core_device_t &dev, const astring &aname, const state_e astate) |
| 455 | { |
| 383 | 456 | set_state(astate); |
| 384 | | init_object(dev.netlist(), aname); |
| 457 | netlist_owned_object_t::init_object(dev, aname); |
| 385 | 458 | } |
| 386 | 459 | |
| 460 | ATTR_COLD void netlist_terminal_t::set_net(netlist_net_t &anet) |
| 461 | { |
| 462 | m_net = &anet; |
| 463 | } |
| 464 | |
| 387 | 465 | // ---------------------------------------------------------------------------------------- |
| 388 | 466 | // net_input_t |
| 389 | 467 | // ---------------------------------------------------------------------------------------- |
| r26375 | r26376 | |
| 402 | 480 | this->set_net(m_my_net); |
| 403 | 481 | } |
| 404 | 482 | |
| 405 | | ATTR_COLD void netlist_output_t::init_terminal(netlist_core_device_t &dev, const astring &aname) |
| 483 | ATTR_COLD void netlist_output_t::init_object(netlist_core_device_t &dev, const astring &aname) |
| 406 | 484 | { |
| 407 | | netlist_terminal_t::init_terminal(dev, aname, STATE_OUT); |
| 485 | netlist_terminal_t::init_object(dev, aname, STATE_OUT); |
| 408 | 486 | net().init_object(dev.netlist(), aname); |
| 409 | 487 | net().register_railterminal(*this); |
| 410 | 488 | } |