Previous 199869 Revisions Next

r26488 Monday 2nd December, 2013 at 23:20:39 UTC by Couriersud
Netlist: Class factory is now initialized dynamically.

Note: Please delete all netlist related object files prior to compiling,  e.g.:

rm -rf  obj/windowsd/mame/drivers/pong.o obj/windowsd/emu/machine/net* obj/windowsd/emu/netlist/
[src/emu/netlist]nl_base.h nl_config.h nl_lists.h nl_parser.c nl_setup.c nl_setup.h pstring.c
[src/emu/netlist/devices]net_lib.c nld_7400.h nld_log.c nld_log.h nld_system.c

trunk/src/emu/netlist/nl_config.h
r26487r26488
1616//  SETUP
1717//============================================================
1818
19//#define astring breakme()
20
2119#define USE_DELEGATES           (0)
2220/*
2321 * The next options needs -Wno-pmf-conversions to compile and gcc
trunk/src/emu/netlist/nl_parser.c
r26487r26488
6767
6868   skipws();
6969   name = getname(',');
70   dev = net_create_device_by_name(dev_name, m_setup);
70   dev = m_setup.factory().new_device_by_name(dev_name, m_setup);
7171   m_setup.register_dev(dev, name);
7272   skipws();
7373   val = eval_param();
r26487r26488
8686
8787   skipws();
8888   devname = getname2(',', ')');
89   dev = net_create_device_by_name(dev_type, m_setup);
89   dev = m_setup.factory().new_device_by_name(dev_type, m_setup);
9090   m_setup.register_dev(dev, devname);
9191   skipws();
9292   NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr()));
trunk/src/emu/netlist/pstring.c
r26487r26488
77#include <cstdio>
88
99
10// The following will work on linux, however not on Windows ....
11
1012//pblockpool *pstring::m_pool = new pblockpool;
1113//pstring::str_t *pstring::m_zero = new(pstring::m_pool, 0) pstring::str_t(0);
1214
trunk/src/emu/netlist/nl_base.h
r26487r26488
11391139   }
11401140};
11411141
1142netlist_device_t *net_create_device_by_classname(const pstring &classname, netlist_setup_t &setup);
1143netlist_device_t *net_create_device_by_name(const pstring &name, netlist_setup_t &setup);
1142class netlist_factory
1143{
1144public:
11441145
1146    void initialize();
11451147
1148    netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
1149    netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
1150
1151private:
1152    typedef netlist_list_t<net_device_t_base_factory *> list_t;
1153    list_t m_list;
1154
1155};
1156
1157
1158
11461159#endif /* NLBASE_H_ */
trunk/src/emu/netlist/nl_setup.c
r26487r26488
2525   : m_netlist(netlist)
2626    , m_proxy_cnt(0)
2727{
28    m_factory.initialize();
2829   NETLIST_NAME(base)(*this);
2930}
3031
trunk/src/emu/netlist/nl_lists.h
r26487r26488
7575            }
7676        }
7777    }
78   ATTR_HOT inline entry_t *first() { return (m_ptr >= m_list ? &m_list[0] : NULL ); }
79    ATTR_HOT inline entry_t *next(entry_t *lc) { return (lc < last() ? lc + 1 : NULL ); }
80   ATTR_HOT inline entry_t *last()  { return m_ptr; }
81   ATTR_HOT inline entry_t *item(int i) { return &m_list[i]; }
78   ATTR_HOT inline entry_t *first() const { return (m_ptr >= m_list ? &m_list[0] : NULL ); }
79    ATTR_HOT inline entry_t *next(entry_t *lc) const { return (lc < last() ? lc + 1 : NULL ); }
80   ATTR_HOT inline entry_t *last() const { return m_ptr; }
81   ATTR_HOT inline entry_t *item(int i) const { return &m_list[i]; }
8282   ATTR_HOT inline int count() const { return m_ptr - m_list + 1; }
83   ATTR_HOT inline bool empty() { return (m_ptr < m_list); }
83   ATTR_HOT inline bool empty() const { return (m_ptr < m_list); }
8484   ATTR_HOT inline void reset() { m_ptr = m_list - 1; }
8585private:
8686   entry_t * m_ptr;
trunk/src/emu/netlist/nl_setup.h
r26487r26488
2020
2121#define NET_ALIAS(_alias, _name)                                                    \
2222   netlist.register_alias(# _alias, # _name);
23#define NET_NEW(_type)  net_create_device_by_classname(NETLIB_NAME_STR(_type), netlist)
23#define NET_NEW(_type)  netlist.factory().new_device_by_classname(NETLIB_NAME_STR(_type), netlist)
2424
2525#define NET_REGISTER_DEV(_type, _name)                                              \
2626      netlist.register_dev(NET_NEW(_type), # _name);
r26487r26488
9898   ~netlist_setup_t();
9999
100100   netlist_base_t &netlist() { return m_netlist; }
101   netlist_factory &factory() { return m_factory; }
101102
102103   netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name);
103104   void remove_dev(const pstring &name);
r26487r26488
140141   tagmap_link_t   m_links;
141142    tagmap_nstring_t m_params_temp;
142143
144    netlist_factory m_factory;
145
143146   int m_proxy_cnt;
144147
145148   void connect_terminals(netlist_core_terminal_t &in, netlist_core_terminal_t &out);
trunk/src/emu/netlist/devices/nld_7400.h
r26487r26488
4141
4242NETLIB_SIGNAL(7400, 2, 0, 0);
4343
44NETLIB_DEVICE(7400pin,
45
46    NETLIB_NAME(7400) m_1;
47    NETLIB_NAME(7400) m_2;
48    NETLIB_NAME(7400) m_3;
49    NETLIB_NAME(7400) m_4;
50);
51
52inline NETLIB_START(7400pin)
53{
54    register_sub(m_1, "1");
55    register_sub(m_2, "2");
56    register_sub(m_3, "3");
57    register_sub(m_4, "4");
58
59    register_subalias("1", m_1.m_i[0]);
60    register_subalias("2", m_1.m_i[1]);
61    register_subalias("3", m_1.m_Q);
62
63    register_subalias("4", m_2.m_i[0]);
64    register_subalias("5", m_2.m_i[1]);
65    register_subalias("6", m_2.m_Q);
66
67    register_subalias("9", m_3.m_i[0]);
68    register_subalias("10", m_3.m_i[1]);
69    register_subalias("8", m_3.m_Q);
70
71    register_subalias("12", m_4.m_i[0]);
72    register_subalias("13", m_4.m_i[1]);
73    register_subalias("11", m_4.m_Q);
74}
75
4476#endif /* NLD_7400_H_ */
trunk/src/emu/netlist/devices/net_lib.c
r26487r26488
901901}
902902
903903#define xstr(s) # s
904#define ENTRY1(_nic, _name) new net_device_t_factory< _nic >( # _name, xstr(_nic) ),
904#define ENTRY1(_nic, _name) m_list.add(new net_device_t_factory< _nic >( # _name, xstr(_nic) ));
905905#define ENTRY(_nic, _name) ENTRY1(NETLIB_NAME(_nic), _name)
906906
907static const net_device_t_base_factory *netregistry[] =
907void netlist_factory::initialize()
908908{
909909    ENTRY(R,                    NETDEV_R)
910910    ENTRY(C,                    NETDEV_C)
911911    ENTRY(D,                    NETDEV_D)
912   ENTRY(ttl_const,            NETDEV_TTL_CONST)
913   ENTRY(analog_const,         NETDEV_ANALOG_CONST)
914   ENTRY(logic_input,          NETDEV_LOGIC_INPUT)
915   ENTRY(analog_input,         NETDEV_ANALOG_INPUT)
916   ENTRY(log,                  NETDEV_LOG)
917   ENTRY(clock,                NETDEV_CLOCK)
918   ENTRY(mainclock,            NETDEV_MAINCLOCK)
912    ENTRY(ttl_const,            NETDEV_TTL_CONST)
913    ENTRY(analog_const,         NETDEV_ANALOG_CONST)
914    ENTRY(logic_input,          NETDEV_LOGIC_INPUT)
915    ENTRY(analog_input,         NETDEV_ANALOG_INPUT)
916    ENTRY(log,                  NETDEV_LOG)
917    ENTRY(clock,                NETDEV_CLOCK)
918    ENTRY(mainclock,            NETDEV_MAINCLOCK)
919919    ENTRY(solver,               NETDEV_SOLVER)
920   ENTRY(analog_callback,      NETDEV_CALLBACK)
921   ENTRY(nicMultiSwitch,       NETDEV_SWITCH2)
922   ENTRY(nicRSFF,              NETDEV_RSFF)
923   ENTRY(nicMixer8,            NETDEV_MIXER)
924   ENTRY(7400,                 TTL_7400_NAND)
925   ENTRY(7402,                 TTL_7402_NOR)
926   ENTRY(nic7404,              TTL_7404_INVERT)
927   ENTRY(7410,                 TTL_7410_NAND)
928   ENTRY(7420,                 TTL_7420_NAND)
929   ENTRY(7425,                 TTL_7425_NOR)
930   ENTRY(7427,                 TTL_7427_NOR)
931   ENTRY(7430,                 TTL_7430_NAND)
932   ENTRY(nic7450,              TTL_7450_ANDORINVERT)
933   ENTRY(7486,                 TTL_7486_XOR)
934   ENTRY(nic7448,              TTL_7448)
935   ENTRY(7474,                 TTL_7474)
936   ENTRY(nic7483,              TTL_7483)
937   ENTRY(nic7490,              TTL_7490)
938   ENTRY(nic7493,              TTL_7493)
939   ENTRY(nic74107,             TTL_74107)
940   ENTRY(nic74107A,            TTL_74107A)
941   ENTRY(nic74153,             TTL_74153)
942   ENTRY(nic9316,              TTL_9316)
943   ENTRY(NE555,                NETDEV_NE555)
920    ENTRY(analog_callback,      NETDEV_CALLBACK)
921    ENTRY(nicMultiSwitch,       NETDEV_SWITCH2)
922    ENTRY(nicRSFF,              NETDEV_RSFF)
923    ENTRY(nicMixer8,            NETDEV_MIXER)
924    ENTRY(7400,                 TTL_7400_NAND)
925    ENTRY(7402,                 TTL_7402_NOR)
926    ENTRY(nic7404,              TTL_7404_INVERT)
927    ENTRY(7410,                 TTL_7410_NAND)
928    ENTRY(7420,                 TTL_7420_NAND)
929    ENTRY(7425,                 TTL_7425_NOR)
930    ENTRY(7427,                 TTL_7427_NOR)
931    ENTRY(7430,                 TTL_7430_NAND)
932    ENTRY(nic7450,              TTL_7450_ANDORINVERT)
933    ENTRY(7486,                 TTL_7486_XOR)
934    ENTRY(nic7448,              TTL_7448)
935    ENTRY(7474,                 TTL_7474)
936    ENTRY(nic7483,              TTL_7483)
937    ENTRY(nic7490,              TTL_7490)
938    ENTRY(nic7493,              TTL_7493)
939    ENTRY(nic74107,             TTL_74107)
940    ENTRY(nic74107A,            TTL_74107A)
941    ENTRY(nic74153,             TTL_74153)
942    ENTRY(nic9316,              TTL_9316)
943    ENTRY(NE555,                NETDEV_NE555)
944944    ENTRY(nicNE555N_MSTABLE,    NE555N_MSTABLE)
945   NULL
946};
945}
947946
948netlist_device_t *net_create_device_by_classname(const pstring &classname, netlist_setup_t &setup)
947netlist_device_t *netlist_factory::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const
949948{
950   const net_device_t_base_factory **p = &netregistry[0];
951   while (*p != NULL)
952   {
953      if (strcmp((*p)->classname(), classname) == 0)
954      {
955         netlist_device_t *ret = (*p)->Create();
956         return ret;
957      }
958      p++;
959   }
960   fatalerror("Class %s not found!\n", classname.cstr());
961   return NULL; // appease code analysis
949    for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e))
950    {
951        net_device_t_base_factory *p = e->object();
952        if (strcmp(p->classname(), classname) == 0)
953        {
954            netlist_device_t *ret = p->Create();
955            return ret;
956        }
957        p++;
958    }
959    fatalerror("Class %s not found!\n", classname.cstr());
960    return NULL; // appease code analysis
962961}
963962
964netlist_device_t *net_create_device_by_name(const pstring &name, netlist_setup_t &setup)
963netlist_device_t *netlist_factory::new_device_by_name(const pstring &name, netlist_setup_t &setup) const
965964{
966   const net_device_t_base_factory **p = &netregistry[0];
967   while (*p != NULL)
968   {
969      if (strcmp((*p)->name(), name) == 0)
970      {
971         netlist_device_t *ret = (*p)->Create();
972         //ret->init(setup, icname);
973         return ret;
974      }
975      p++;
976   }
977   fatalerror("Class %s not found!\n", name.cstr());
978   return NULL; // appease code analysis
965    for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e))
966    {
967        net_device_t_base_factory *p = e->object();
968        if (strcmp(p->name(), name) == 0)
969        {
970            netlist_device_t *ret = p->Create();
971            return ret;
972        }
973        p++;
974    }
975    fatalerror("Class %s not found!\n", name.cstr());
976    return NULL; // appease code analysis
979977}
978
trunk/src/emu/netlist/devices/nld_log.c
r26487r26488
44 */
55
66#include "nld_log.h"
7#include "sound/wavwrite.h"
78
89NETLIB_START(log)
910{
r26487r26488
2223{
2324    fclose(m_file);
2425}
26
27// FIXME: Implement wav later, this must be clock triggered device where the input to be written
28//        is on a subdevice ...
29#if 0
30NETLIB_START(wav)
31{
32    register_input("I", m_I);
33
34    pstring filename = "netlist_" + name() + ".wav";
35    m_file = wav_open(filename, sample_rate(), active_inputs()/2)
36}
37
38NETLIB_UPDATE(wav)
39{
40    fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I));
41}
42
43NETLIB_NAME(log)::~NETLIB_NAME(wav)()
44{
45    fclose(m_file);
46}
47#endif
trunk/src/emu/netlist/devices/nld_system.c
r26487r26488
8989    register_param("SYNC_DELAY", m_sync_delay, NLTIME_FROM_NS(10).as_double());
9090    m_nt_sync_delay = m_sync_delay.Value();
9191
92    register_param("FREQ", m_freq, 50000.0);
92    register_param("FREQ", m_freq, 48000.0);
9393    m_inc = netlist_time::from_hz(m_freq.Value());
9494
9595    register_link_internal(m_fb_sync, m_Q_sync, netlist_input_t::STATE_INP_ACTIVE);
trunk/src/emu/netlist/devices/nld_log.h
r26487r26488
3131    FILE *m_file;
3232);
3333
34#if 0
35NETLIB_DEVICE(wav,
36    ~NETLIB_NAME(wav)();
37    netlist_analog_input_t m_I;
38private:
39    // FIXME: rewrite sound/wavwrite.h to be an object ...
40    void *m_file;
41);
42#endif
43
3444#endif /* NLD_LOG_H_ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team