Previous 199869 Revisions Next

r26467 Sunday 1st December, 2013 at 15:45:12 UTC by Couriersud
Netlist: implemented something more complex: A generic NE555 model. Period accuracy for astable operation is within 2% of the TI datasheet for astable operation.
Fixed an issue in the object model as well and made the code distinguish between a core terminal and analog terminals.

   NETDEV_R(RA, 5000)
   NETDEV_R(RB, 3000)
   NETDEV_C(C, 0.15e-6)
   NETDEV_NE555(555)

   NET_C(V0, 555.GND)
   NET_C(V5, 555.VCC)

   NET_C(RA.1, 555.VCC)
   NET_C(RA.2, 555.DISCH)

   NET_C(RB.1, 555.DISCH)
   NET_C(RB.2, 555.TRIG)

   NET_C(RB.2, 555.THRESH)

   NET_C(555.TRIG, C.1)
   NET_C(C.2, V0)
   
[src/emu/netlist]netlist.mak nl_base.c nl_base.h nl_config.h nl_parser.c nl_setup.c nl_setup.h
[src/emu/netlist/devices]net_lib.c net_lib.h nld_7430.h nld_7474.c nld_7474.h nld_7486.c nld_7486.h nld_NE555.c* nld_NE555.h* nld_system.c nld_system.h nld_twoterm.h
[src/mame/drivers]pong.c

trunk/src/mame/drivers/pong.c
r26466r26467
531531#endif
532532
533533#if 0
534
535534    // astable NAND Multivibrator
536535    NETDEV_R(R1, 1000)
537536    NETDEV_C(C1, 1e-6)
r26466r26467
544543    //NETDEV_LOG(log2, n1.Q)
545544    //NETDEV_LOG(log3, n2.Q)
546545#endif
546
547#if 0
548    // astable NE555, 1.13 ms period
549    NETDEV_R(RA, 5000)
550    NETDEV_R(RB, 3000)
551    NETDEV_C(C, 0.15e-6)
552    NETDEV_NE555(555)
553
554    NET_C(V0, 555.GND)
555    NET_C(V5, 555.VCC)
556
557    NET_C(RA.1, 555.VCC)
558    NET_C(RA.2, 555.DISCH)
559
560    NET_C(RB.1, 555.DISCH)
561    NET_C(RB.2, 555.TRIG)
562
563    NET_C(RB.2, 555.THRESH)
564
565    NET_C(555.TRIG, C.1)
566    NET_C(C.2, V0)
567    //NETDEV_LOG(log2, C.1)
568#endif
569
570
547571NETLIST_END
548572
549573static NETLIST_START(pong)
trunk/src/emu/netlist/nl_parser.c
r26466r26467
9696      m_p++;
9797      skipws();
9898      pstring output_name = getname2(',', ')');
99      NL_VERBOSE_OUT(("Parser: ID: %s %s\n", output_name.cstr(), dev->m_terminals.item(cnt)->cstr()));
100      m_setup.register_link(pstring::sprintf("%s.[%d]", devname.cstr(), cnt), output_name);
99      pstring alias = pstring::sprintf("%s.[%d]", devname.cstr(), cnt);
100      NL_VERBOSE_OUT(("Parser: ID: %s %s\n", output_name.cstr(), alias.cstr()));
101      m_setup.register_link(alias, output_name);
101102      skipws();
102103      cnt++;
103104   }
trunk/src/emu/netlist/nl_base.h
r26466r26467
291291};
292292
293293// ----------------------------------------------------------------------------------------
294// net_terminal_t
294// netlist_core_terminal_t
295295// ----------------------------------------------------------------------------------------
296296
297class netlist_terminal_t : public netlist_owned_object_t
297class netlist_core_terminal_t : public netlist_owned_object_t
298298{
299299public:
300300
r26466r26467
309309        STATE_NONEX = 256
310310    };
311311
312   ATTR_COLD netlist_terminal_t(const type_t atype, const family_t afamily);
313    ATTR_COLD netlist_terminal_t();
312   ATTR_COLD netlist_core_terminal_t(const type_t atype, const family_t afamily);
314313
315314   ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate);
316315
r26466r26467
327326        m_state = astate;
328327    }
329328
330    double m_Idr; // drive current
331    double m_g; // conductance
329    netlist_core_terminal_t *m_update_list_next;
332330
333    netlist_terminal_t *m_update_list_next;
334
335331private:
336332    netlist_net_t * RESTRICT m_net;
337333    state_e m_state;
338334};
339335
336class netlist_terminal_t : public netlist_core_terminal_t
337{
338public:
339    ATTR_COLD netlist_terminal_t();
340340
341    double m_Idr; // drive current
342    double m_g; // conductance
343
344};
345
346
341347// ----------------------------------------------------------------------------------------
342348// netlist_input_t
343349// ----------------------------------------------------------------------------------------
344350
345class netlist_input_t : public netlist_terminal_t
351class netlist_input_t : public netlist_core_terminal_t
346352{
347353public:
348354
349355
350356   ATTR_COLD netlist_input_t(const type_t atype, const family_t afamily)
351      : netlist_terminal_t(atype, afamily)
357      : netlist_core_terminal_t(atype, afamily)
352358        , m_low_thresh_V(0)
353359        , m_high_thresh_V(0)
354360   {
r26466r26467
444450
445451    ATTR_COLD netlist_net_t(const type_t atype, const family_t afamily);
446452
447    ATTR_COLD void register_con(netlist_terminal_t &terminal);
453    ATTR_COLD void register_con(netlist_core_terminal_t &terminal);
448454    ATTR_COLD void merge_net(netlist_net_t *othernet);
449    ATTR_COLD void register_railterminal(netlist_terminal_t &mr);
455    ATTR_COLD void register_railterminal(netlist_output_t &mr);
450456
451457    /* inline not always works out */
452458    ATTR_HOT inline void update_devs();
r26466r26467
455461    ATTR_HOT inline void set_time(const netlist_time ntime) { m_time = ntime; }
456462
457463    ATTR_HOT inline bool isRailNet() { return !(m_railterminal == NULL); }
458    ATTR_HOT inline const netlist_terminal_t & RESTRICT  railterminal() const { return *m_railterminal; }
459    ATTR_HOT inline const netlist_terminal_t & RESTRICT railterminal() { return *m_railterminal; }
464    ATTR_HOT inline const netlist_core_terminal_t & RESTRICT  railterminal() const { return *m_railterminal; }
465    ATTR_HOT inline const netlist_core_terminal_t & RESTRICT railterminal() { return *m_railterminal; }
460466
461467    /* Everything below is used by the logic subsystem */
462468
r26466r26467
494500    hybrid_t m_cur;
495501    hybrid_t m_new;
496502
497    netlist_terminal_t *m_head;
503    netlist_core_terminal_t *m_head;
498504    UINT32 m_num_cons;
499505
500506private:
501    ATTR_HOT void update_dev(const netlist_terminal_t *inp, const UINT32 mask);
507    ATTR_HOT void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask);
502508
503509    netlist_time m_time;
504510    INT32        m_active;
505511    UINT32       m_in_queue;    /* 0: not in queue, 1: in queue, 2: last was taken */
506512
507    netlist_terminal_t * RESTRICT m_railterminal;
513    netlist_core_terminal_t * RESTRICT m_railterminal;
508514};
509515
510516
r26466r26467
515521class NETLIB_NAME(mainclock);
516522class NETLIB_NAME(solver);
517523
518class netlist_output_t : public netlist_terminal_t
524class netlist_output_t : public netlist_core_terminal_t
519525{
520526public:
521527
r26466r26467
748754
749755   ATTR_HOT inline const double INPANALOG(const netlist_analog_input_t &inp) const { return inp.Q_Analog(); }
750756
757   ATTR_HOT inline const double TERMANALOG(const netlist_terminal_t &term) const { return term.net().Q_Analog(); }
758
751759   ATTR_HOT inline void OUTANALOG(netlist_analog_output_t &out, const double val, const netlist_time &delay)
752760   {
753761      out.set_Q(val, delay);
r26466r26467
794802   ATTR_COLD bool variable_input_count() { return m_variable_input_count; }
795803
796804   ATTR_COLD void register_sub(netlist_device_t &dev, const pstring &name);
797    ATTR_COLD void register_subalias(const pstring &name, netlist_terminal_t &term);
805    ATTR_COLD void register_subalias(const pstring &name, netlist_core_terminal_t &term);
798806
799807    ATTR_COLD void register_terminal(const pstring &name, netlist_terminal_t &port);
800808
trunk/src/emu/netlist/netlist.mak
r26466r26467
2828   $(NETLISTOBJ)/devices/nld_7404.o \
2929   $(NETLISTOBJ)/devices/nld_7474.o \
3030   $(NETLISTOBJ)/devices/nld_7486.o \
31   $(NETLISTOBJ)/devices/nld_NE555.o \
3132
trunk/src/emu/netlist/nl_setup.c
r26466r26467
146146        case netlist_terminal_t::INPUT:
147147        case netlist_terminal_t::OUTPUT:
148148            {
149                netlist_terminal_t &term = dynamic_cast<netlist_terminal_t &>(obj);
149                netlist_core_terminal_t &term = dynamic_cast<netlist_core_terminal_t &>(obj);
150150                if (obj.isType(netlist_terminal_t::OUTPUT))
151151                    dynamic_cast<netlist_output_t &>(term).init_object(upd_dev, dev.name() + "." + name);
152152                else
r26466r26467
259259   return ret;
260260}
261261
262netlist_terminal_t &netlist_setup_t::find_terminal(const pstring &terminal_in)
262netlist_core_terminal_t &netlist_setup_t::find_terminal(const pstring &terminal_in)
263263{
264264    const pstring &tname = resolve_alias(terminal_in);
265    netlist_terminal_t *ret;
265    netlist_core_terminal_t *ret;
266266
267    ret = dynamic_cast<netlist_terminal_t *>(m_terminals.find(tname));
267    ret = m_terminals.find(tname);
268268    /* look for default */
269269    if (ret == NULL)
270270    {
271271        /* look for ".Q" std output */
272272        pstring s = tname + ".Q";
273        ret = dynamic_cast<netlist_terminal_t *>(m_terminals.find(s));
273        ret = m_terminals.find(s);
274274    }
275275    if (ret == NULL)
276276        fatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
r26466r26467
278278    return *ret;
279279}
280280
281netlist_terminal_t &netlist_setup_t::find_terminal(const pstring &terminal_in, netlist_object_t::type_t atype)
281netlist_core_terminal_t &netlist_setup_t::find_terminal(const pstring &terminal_in, netlist_object_t::type_t atype)
282282{
283283   const pstring &tname = resolve_alias(terminal_in);
284   netlist_terminal_t *ret;
284   netlist_core_terminal_t *ret;
285285
286   ret = dynamic_cast<netlist_terminal_t *>(m_terminals.find(tname));
286   ret = m_terminals.find(tname);
287287   /* look for default */
288288   if (ret == NULL && atype == netlist_object_t::OUTPUT)
289289   {
290290      /* look for ".Q" std output */
291291      pstring s = tname + ".Q";
292      ret = dynamic_cast<netlist_terminal_t *>(m_terminals.find(s));
292      ret = m_terminals.find(s);
293293   }
294294   if (ret == NULL)
295295      fatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr());
r26466r26467
411411    }
412412}
413413
414void netlist_setup_t::connect_terminals(netlist_terminal_t &t1, netlist_terminal_t &t2)
414void netlist_setup_t::connect_terminals(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2)
415415{
416416    //assert(in.isType(netlist_terminal_t::TERMINAL));
417417    //assert(out.isType(netlist_terminal_t::TERMINAL));
r26466r26467
444444    }
445445}
446446
447void netlist_setup_t::connect(netlist_terminal_t &t1, netlist_terminal_t &t2)
447void netlist_setup_t::connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2)
448448{
449    NL_VERBOSE_OUT(("Connecting %s to %s\n", t1.name().cstr(), t2s.name().cstr()));
450
449    NL_VERBOSE_OUT(("Connecting %s to %s\n", t1.name().cstr(), t2.name().cstr()));
451450    // FIXME: amend device design so that warnings can be turned into errors
452451    //        Only variable inputs have this issue
453    if (t1.isType(netlist_terminal_t::OUTPUT) && t2.isType(netlist_terminal_t::INPUT))
452    if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT))
454453    {
455454        if (t2.has_net())
456455            mame_printf_warning("Input %s already connected\n", t2.name().cstr());
457456        connect_input_output(dynamic_cast<netlist_input_t &>(t2), dynamic_cast<netlist_output_t &>(t1));
458457    }
459    else if (t1.isType(netlist_terminal_t::INPUT) && t2.isType(netlist_terminal_t::OUTPUT))
458    else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::OUTPUT))
460459    {
461460        if (t1.has_net())
462461            mame_printf_warning("Input %s already connected\n", t1.name().cstr());
463462        connect_input_output(dynamic_cast<netlist_input_t &>(t1), dynamic_cast<netlist_output_t &>(t2));
464463    }
465    else if (t1.isType(netlist_terminal_t::OUTPUT) && t2.isType(netlist_terminal_t::TERMINAL))
464    else if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::TERMINAL))
466465    {
467466        connect_terminal_output(dynamic_cast<netlist_terminal_t &>(t2), dynamic_cast<netlist_output_t &>(t1));
468467    }
469    else if (t1.isType(netlist_terminal_t::TERMINAL) && t2.isType(netlist_terminal_t::OUTPUT))
468    else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::OUTPUT))
470469    {
471470        connect_terminal_output(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_output_t &>(t2));
472471    }
473    else if (t1.isType(netlist_terminal_t::INPUT) && t2.isType(netlist_terminal_t::TERMINAL))
472    else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::TERMINAL))
474473    {
475474        connect_terminal_input(dynamic_cast<netlist_terminal_t &>(t2), dynamic_cast<netlist_input_t &>(t1));
476475    }
477    else if (t1.isType(netlist_terminal_t::TERMINAL) && t2.isType(netlist_terminal_t::INPUT))
476    else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::INPUT))
478477    {
479478        connect_terminal_input(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_input_t &>(t2));
480479    }
481    else if (t1.isType(netlist_terminal_t::TERMINAL) && t2.isType(netlist_terminal_t::TERMINAL))
480    else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::TERMINAL))
482481    {
483482        connect_terminals(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_terminal_t &>(t2));
484483    }
r26466r26467
488487
489488void netlist_setup_t::resolve_inputs(void)
490489{
491    NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n"));
492    /* find the main clock ... */
493    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
494    {
495        netlist_device_t *dev = entry->object();
496        if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL)
497        {
498            m_netlist.set_mainclock_dev(dynamic_cast<NETLIB_NAME(mainclock)*>(dev));
499        }
500        if (dynamic_cast<NETLIB_NAME(solver)*>(dev) != NULL)
501        {
502            m_netlist.set_solver_dev(dynamic_cast<NETLIB_NAME(solver)*>(dev));
503        }
504    }
505490
506491    NL_VERBOSE_OUT(("Resolving ...\n"));
507492    for (tagmap_link_t::entry_t *entry = m_links.first(); entry != NULL; entry = m_links.next(entry))
508493    {
509494        const pstring t1s = entry->object().e1;
510495        const pstring t2s = entry->object().e2;
511        netlist_terminal_t &t1 = find_terminal(t1s);
512        netlist_terminal_t &t2 = find_terminal(t2s);
496        netlist_core_terminal_t &t1 = find_terminal(t1s);
497        netlist_core_terminal_t &t2 = find_terminal(t2s);
513498
514499        connect(t1, t2);
515500    }
r26466r26467
530515
531516void netlist_setup_t::start_devices(void)
532517{
518
519    NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n"));
520    /* find the main clock ... */
533521    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
534522    {
535523        netlist_device_t *dev = entry->object();
524        if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL)
525        {
526            m_netlist.set_mainclock_dev(dynamic_cast<NETLIB_NAME(mainclock)*>(dev));
527        }
528        if (dynamic_cast<NETLIB_NAME(solver)*>(dev) != NULL)
529        {
530            m_netlist.set_solver_dev(dynamic_cast<NETLIB_NAME(solver)*>(dev));
531        }
532    }
533
534    NL_VERBOSE_OUT(("Initializing devices ...\n"));
535    for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
536    {
537        netlist_device_t *dev = entry->object();
536538        dev->init(*this, entry->tag().cstr());
537539    }
538540}
trunk/src/emu/netlist/nl_setup.h
r26466r26467
9191   typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t;
9292   typedef tagmap_t<pstring, 393> tagmap_nstring_t;
9393   typedef tagmap_t<netlist_param_t *, 393> tagmap_param_t;
94   typedef tagmap_t<netlist_terminal_t *, 393> tagmap_terminal_t;
94   typedef tagmap_t<netlist_core_terminal_t *, 393> tagmap_terminal_t;
9595   typedef netlist_list_t<link_t> tagmap_link_t;
9696
9797   netlist_setup_t(netlist_base_t &netlist);
r26466r26467
108108    void register_param(const pstring &param, const double value);
109109
110110    void register_object(netlist_device_t &dev, netlist_core_device_t &upd_dev, const pstring &name, netlist_object_t &obj, netlist_input_t::state_e state);
111    void connect(netlist_terminal_t &t1, netlist_terminal_t &t2);
111    void connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2);
112112
113    netlist_terminal_t &find_terminal(const pstring &outname_in);
114    netlist_terminal_t &find_terminal(const pstring &outname_in, netlist_object_t::type_t atype);
113    netlist_core_terminal_t &find_terminal(const pstring &outname_in);
114    netlist_core_terminal_t &find_terminal(const pstring &outname_in, netlist_object_t::type_t atype);
115115
116116    netlist_param_t &find_param(const pstring &param_in);
117117
r26466r26467
142142
143143   int m_proxy_cnt;
144144
145   void connect_terminals(netlist_terminal_t &in, netlist_terminal_t &out);
145   void connect_terminals(netlist_core_terminal_t &in, netlist_core_terminal_t &out);
146146   void connect_input_output(netlist_input_t &in, netlist_output_t &out);
147147    void connect_terminal_output(netlist_terminal_t &in, netlist_output_t &out);
148148    void connect_terminal_input(netlist_terminal_t &term, netlist_input_t &inp);
trunk/src/emu/netlist/devices/nld_7474.c
r26466r26467
55
66#include "nld_7474.h"
77
8ATTR_HOT inline void NETLIB_NAME(nic7474sub)::newstate(const UINT8 state)
8ATTR_HOT inline void NETLIB_NAME(7474sub)::newstate(const UINT8 state)
99{
1010    static const netlist_time delay[2] = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(40) };
1111    //printf("%s %d %d %d\n", "7474", state, Q.Q(), QQ.Q());
r26466r26467
1313    OUTLOGIC(m_QQ, !state, delay[!state]);
1414}
1515
16NETLIB_UPDATE(nic7474sub)
16NETLIB_UPDATE(7474sub)
1717{
1818    //if (!INP_LAST(m_clk) & INP(m_clk))
1919    {
r26466r26467
2222    }
2323}
2424
25NETLIB_UPDATE(nic7474)
25NETLIB_UPDATE(7474)
2626{
2727    if (!INPLOGIC(m_preQ))
2828    {
r26466r26467
4444    }
4545}
4646
47NETLIB_START(nic7474)
47NETLIB_START(7474)
4848{
4949    register_sub(sub, "sub");
5050
r26466r26467
5858
5959}
6060
61NETLIB_START(nic7474sub)
61NETLIB_START(7474sub)
6262{
6363    register_input("CLK",  m_clk, netlist_input_t::STATE_INP_LH);
6464
trunk/src/emu/netlist/devices/nld_twoterm.h
r26466r26467
9999
100100    NETLIB_UPDATE_TERMINALS() { NETLIB_NAME(twoterm)::update_terminals(); }
101101
102public:
103    inline void set_R(double R) { m_g = 1.0 / R; }
104
102105);
103106
104107// ----------------------------------------------------------------------------------------
trunk/src/emu/netlist/devices/nld_NE555.h
r0r26467
1// license:GPL-2.0+
2// copyright-holders:Couriersud
3/*
4 * nld_NE555.h
5 *
6 *  NE555: PRECISION TIMERS
7 *
8 *          +--------+
9 *      GND |1  ++  8| VCC
10 *     TRIG |2      7| DISCH
11 *      OUT |3      6| THRES
12 *    RESET |4      5| CONT
13 *          +--------+
14 *
15 *  Naming conventions follow Texas Instruments datasheet
16 *
17 */
18
19#ifndef NLD_NE555_H_
20#define NLD_NE555_H_
21
22#include "../nl_base.h"
23#include "nld_twoterm.h"
24
25#define NETDEV_NE555(_name)                                                        \
26      NET_REGISTER_DEV(NE555, _name)                                             \
27
28NETLIB_DEVICE(NE555,
29    NETLIB_NAME(R) m_R1;
30    NETLIB_NAME(R) m_R2;
31    NETLIB_NAME(R) m_R3;
32    NETLIB_NAME(R) m_RDIS;
33
34    netlist_logic_input_t m_RESET;
35    netlist_analog_input_t m_THRES;
36    netlist_analog_input_t m_TRIG;
37    netlist_analog_output_t m_OUT;
38
39    bool m_last_out;
40
41    double clamp(const double v, const double a, const double b);
42
43);
44
45
46
47#endif /* NLD_NE555_H_ */
Property changes on: trunk/src/emu/netlist/devices/nld_NE555.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/emu/netlist/devices/nld_7486.c
r26466r26467
55
66#include "nld_7486.h"
77
8NETLIB_START(nic7486)
8NETLIB_START(7486)
99{
1010    register_input("A", m_A);
1111    register_input("B", m_B);
1212    register_output("Q", m_Q);
1313}
1414
15NETLIB_UPDATE(nic7486)
15NETLIB_UPDATE(7486)
1616{
1717    static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) };
1818    UINT8 t = INPLOGIC(m_A) ^ INPLOGIC(m_B);
trunk/src/emu/netlist/devices/nld_7474.h
r26466r26467
4545#include "nld_signal.h"
4646
4747#define TTL_7474(_name, _CLK, _D, _CLRQ, _PREQ)                                     \
48        NET_REGISTER_DEV(nic7474, _name)                                            \
48        NET_REGISTER_DEV(7474, _name)                                               \
4949        NET_CONNECT(_name, CLK, _CLK)                                               \
5050        NET_CONNECT(_name, D,  _D)                                                  \
5151        NET_CONNECT(_name, CLRQ,  _CLRQ)                                            \
5252        NET_CONNECT(_name, PREQ,  _PREQ)
5353
54NETLIB_SUBDEVICE(nic7474sub,
54NETLIB_SUBDEVICE(7474sub,
5555    netlist_ttl_input_t m_clk;
5656
5757    UINT8 m_nextD;
r26466r26467
6161    ATTR_HOT inline void newstate(const UINT8 state);
6262);
6363
64NETLIB_DEVICE(nic7474,
65    NETLIB_NAME(nic7474sub) sub;
64NETLIB_DEVICE(7474,
65    NETLIB_NAME(7474sub) sub;
6666
6767    netlist_ttl_input_t m_D;
6868    netlist_ttl_input_t m_clrQ;
r26466r26467
7070);
7171
7272
73
74NETLIB_SIGNAL(7474, 4, 0, 0);
75
7673#endif /* NLD_7474_H_ */
trunk/src/emu/netlist/devices/nld_7486.h
r26466r26467
3535#include "nld_signal.h"
3636
3737#define TTL_7486_XOR(_name, _A, _B)                                                 \
38        NET_REGISTER_DEV(nic7486, _name)                                            \
38        NET_REGISTER_DEV(7486, _name)                                               \
3939        NET_CONNECT(_name, A, _A)                                                   \
4040        NET_CONNECT(_name, B, _B)
4141
42NETLIB_DEVICE(nic7486,
42NETLIB_DEVICE(7486,
4343        netlist_ttl_input_t m_A;
4444        netlist_ttl_input_t m_B;
4545        netlist_ttl_output_t m_Q;
trunk/src/emu/netlist/devices/net_lib.c
r26466r26467
939939   ENTRY(7420,                 TTL_7420_NAND)
940940   ENTRY(7425,                 TTL_7425_NOR)
941941   ENTRY(7427,                 TTL_7427_NOR)
942   ENTRY(nic7430,              TTL_7430_NAND)
942   ENTRY(7430,                 TTL_7430_NAND)
943943   ENTRY(nic7450,              TTL_7450_ANDORINVERT)
944   ENTRY(nic7486,              TTL_7486_XOR)
944   ENTRY(7486,                 TTL_7486_XOR)
945945   ENTRY(nic7448,              TTL_7448)
946   ENTRY(nic7474,              TTL_7474)
946   ENTRY(7474,                 TTL_7474)
947947   ENTRY(nic7483,              TTL_7483)
948948   ENTRY(nic7490,              TTL_7490)
949949   ENTRY(nic7493,              TTL_7493)
r26466r26467
951951   ENTRY(nic74107A,            TTL_74107A)
952952   ENTRY(nic74153,             TTL_74153)
953953   ENTRY(nic9316,              TTL_9316)
954   ENTRY(nicNE555N_MSTABLE,    NE555N_MSTABLE)
954   ENTRY(NE555,                NETDEV_NE555)
955    ENTRY(nicNE555N_MSTABLE,    NE555N_MSTABLE)
955956   NULL
956957};
957958
trunk/src/emu/netlist/devices/net_lib.h
r26466r26467
6666#include "nld_7474.h"
6767#include "nld_7486.h"
6868
69#include "nld_NE555.h"
70
6971// this is a bad hack
7072#define USE_OLD7493 (0)
7173
trunk/src/emu/netlist/devices/nld_system.c
r26466r26467
120120    for (net_list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
121121    {
122122        NL_VERBOSE_OUT(("setting up net\n"));
123        for (netlist_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next)
123        for (netlist_core_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next)
124124        {
125125            switch (p->type())
126126            {
r26466r26467
170170        double gtot = 0;
171171        double iIdr = 0;
172172
173        for (netlist_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next)
173        for (netlist_core_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next)
174174        {
175            if (p->isType(netlist_terminal_t::TERMINAL))
175            if (p->isType(netlist_core_terminal_t::TERMINAL))
176176            {
177                p->netdev().update_terminals();
178                gtot += p->m_g;
179                iIdr += p->m_Idr;
177                netlist_terminal_t *pt = static_cast<netlist_terminal_t *>(p);
178                pt->netdev().update_terminals();
179                gtot += pt->m_g;
180                iIdr += pt->m_Idr;
180181            }
181182        }
182183
r26466r26467
185186            resched = true;
186187        pn->object()->m_cur.Analog = pn->object()->m_new.Analog = new_val;
187188
188        NL_VERBOSE_OUT(("Info: %d\n", (*pn)->m_num_cons));
189        NL_VERBOSE_OUT(("Info: %d\n", pn->object()->m_num_cons));
189190        NL_VERBOSE_OUT(("New: %lld %f %f\n", netlist().time().as_raw(), netlist().time().as_double(), new_val));
190191    }
191192    if (resched)
trunk/src/emu/netlist/devices/nld_system.h
r26466r26467
8080// ----------------------------------------------------------------------------------------
8181
8282NETLIB_DEVICE_WITH_PARAMS(solver,
83        typedef netlist_list_t<netlist_terminal_t *> terminal_list_t;
83        typedef netlist_list_t<netlist_core_terminal_t *> terminal_list_t;
8484        typedef netlist_list_t<netlist_net_t *>      net_list_t;
8585
8686        netlist_ttl_input_t m_fb_sync;
trunk/src/emu/netlist/devices/nld_NE555.c
r0r26467
1/*
2 * nld_NE555.c
3 *
4 */
5
6#include "nld_NE555.h"
7#include "../nl_setup.h"
8
9#define R_OFF (1E20)
10#define R_ON (1)
11
12inline double NETLIB_NAME(NE555)::clamp(const double v, const double a, const double b)
13{
14    double ret = v;
15    double vcc = TERMANALOG(m_R1.m_P);
16
17    if (ret >  vcc - a)
18        ret = vcc - a;
19    if (ret < b)
20        ret = b;
21    return ret;
22}
23
24NETLIB_START(NE555)
25{
26
27    register_sub(m_R1, "R1");
28    register_sub(m_R2, "R2");
29    register_sub(m_R3, "R3");
30    register_sub(m_RDIS, "RDIS");
31
32    register_subalias("GND",  m_R3.m_N);    // Pin 1
33    register_input("TRIG",    m_TRIG);      // Pin 2
34    register_output("OUT",    m_OUT);       // Pin 3
35    register_input("RESET",   m_RESET);     // Pin 4
36    register_subalias("CONT", m_R1.m_N);    // Pin 5
37    register_input("THRESH",  m_THRES);     // Pin 6
38    register_subalias("DISCH", m_RDIS.m_P); // Pin 7
39    register_subalias("VCC",  m_R1.m_P);    // Pin 8
40
41    m_R1.set_R(5000);
42    m_R2.set_R(5000);
43    m_R3.set_R(5000);
44    m_RDIS.set_R(R_OFF);
45
46    m_setup->connect(m_R1.m_N, m_R2.m_P);
47    m_setup->connect(m_R2.m_N, m_R3.m_P);
48    m_setup->connect(m_RDIS.m_N, m_R3.m_N);
49
50    m_last_out = false;
51}
52
53NETLIB_UPDATE(NE555)
54{
55    // FIXME: assumes GND is connected to 0V.
56
57    double vt = clamp(TERMANALOG(m_R2.m_P), 0.7, 1.4);
58    bool bthresh = (INPANALOG(m_THRES) > vt);
59    bool btrig = (INPANALOG(m_TRIG) > clamp(TERMANALOG(m_R2.m_N), 0.7, 1.4));
60    bool out = m_last_out;
61
62    if (!btrig)
63    {
64        out = true;
65    }
66    else if (bthresh)
67    {
68        out = false;
69    }
70
71    if (!m_last_out && out)
72    {
73        OUTANALOG(m_OUT, TERMANALOG(m_R1.m_P), NLTIME_FROM_NS(100));
74        m_RDIS.set_R(R_OFF);
75    }
76    else if (m_last_out && !out)
77    {
78        OUTANALOG(m_OUT, TERMANALOG(m_R3.m_N), NLTIME_FROM_NS(100));
79        m_RDIS.set_R(R_ON);
80    }
81    m_last_out = out;
82}
Property changes on: trunk/src/emu/netlist/devices/nld_NE555.c
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/emu/netlist/devices/nld_7430.h
r26466r26467
4040#include "nld_signal.h"
4141
4242#define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8)                \
43        NET_REGISTER_DEV(nic7430, _name)                                            \
43        NET_REGISTER_DEV(7430, _name)                                               \
4444        NET_CONNECT(_name, A, _I1)                                                  \
4545        NET_CONNECT(_name, B, _I2)                                                  \
4646        NET_CONNECT(_name, C, _I3)                                                  \
r26466r26467
5151        NET_CONNECT(_name, H, _I8)
5252
5353
54NETLIB_SIGNAL(nic7430, 8, 0, 0);
54NETLIB_SIGNAL(7430, 8, 0, 0);
5555
5656#endif /* NLD_7430_H_ */
trunk/src/emu/netlist/nl_base.c
r26466r26467
266266   dev.init(*m_setup, this->name() + "." + name);
267267}
268268
269ATTR_COLD void netlist_device_t::register_subalias(const pstring &name, netlist_terminal_t &term)
269ATTR_COLD void netlist_device_t::register_subalias(const pstring &name, netlist_core_terminal_t &term)
270270{
271271    pstring alias = this->name() + "." + name;
272272
r26466r26467
294294    m_setup->register_object(*this, *this, name, inp, type);
295295}
296296
297static void init_term(netlist_core_device_t &dev, netlist_terminal_t &term, netlist_input_t::state_e aState)
297static void init_term(netlist_core_device_t &dev, netlist_core_terminal_t &term, netlist_input_t::state_e aState)
298298{
299299    if (!term.isInitalized())
300300    {
r26466r26467
362362    m_last.Q = 0;
363363};
364364
365ATTR_COLD void netlist_net_t::register_railterminal(netlist_terminal_t &mr)
365ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr)
366366{
367367    assert(m_railterminal == NULL);
368368    m_railterminal = &mr;
r26466r26467
384384    }
385385    else
386386    {
387        netlist_terminal_t *p = othernet->m_head;
387        netlist_core_terminal_t *p = othernet->m_head;
388388        while (p != NULL)
389389        {
390            netlist_terminal_t *pn = p->m_update_list_next;
390            netlist_core_terminal_t *pn = p->m_update_list_next;
391391            register_con(*p);
392392            p = pn;
393393        }
r26466r26467
396396    }
397397}
398398
399ATTR_COLD void netlist_net_t::register_con(netlist_terminal_t &terminal)
399ATTR_COLD void netlist_net_t::register_con(netlist_core_terminal_t &terminal)
400400{
401401    terminal.set_net(*this);
402402
r26466r26467
408408        m_active++;
409409}
410410
411ATTR_HOT inline void netlist_net_t::update_dev(const netlist_terminal_t *inp, const UINT32 mask)
411ATTR_HOT inline void netlist_net_t::update_dev(const netlist_core_terminal_t *inp, const UINT32 mask)
412412{
413413   if ((inp->state() & mask) != 0)
414414   {
r26466r26467
433433
434434       const UINT32 mask = masks[ (m_last.Q  << 1) | m_cur.Q ];
435435
436       netlist_terminal_t *p = m_head;
436       netlist_core_terminal_t *p = m_head;
437437       switch (m_num_cons)
438438       {
439439       case 2:
r26466r26467
458458// netlist_terminal_t
459459// ----------------------------------------------------------------------------------------
460460
461ATTR_COLD netlist_terminal_t::netlist_terminal_t(const type_t atype, const family_t afamily)
461ATTR_COLD netlist_core_terminal_t::netlist_core_terminal_t(const type_t atype, const family_t afamily)
462462: netlist_owned_object_t(atype, afamily)
463, m_Idr(0.0)
464, m_g(NETLIST_GMIN)
465463, m_update_list_next(NULL)
466464, m_net(NULL)
467465, m_state(STATE_NONEX)
r26466r26467
470468}
471469
472470ATTR_COLD netlist_terminal_t::netlist_terminal_t()
473: netlist_owned_object_t(TERMINAL, ANALOG)
471: netlist_core_terminal_t(TERMINAL, ANALOG)
474472, m_Idr(0.0)
475473, m_g(NETLIST_GMIN)
476, m_update_list_next(NULL)
477, m_net(NULL)
478, m_state(STATE_NONEX)
479474{
480475
481476}
482477
483ATTR_COLD void netlist_terminal_t::init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate)
478ATTR_COLD void netlist_core_terminal_t::init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate)
484479{
485480   set_state(astate);
486481   netlist_owned_object_t::init_object(dev, aname);
487482}
488483
489ATTR_COLD void netlist_terminal_t::set_net(netlist_net_t &anet)
484ATTR_COLD void netlist_core_terminal_t::set_net(netlist_net_t &anet)
490485{
491486    m_net = &anet;
492487}
r26466r26467
500495// ----------------------------------------------------------------------------------------
501496
502497netlist_output_t::netlist_output_t(const type_t atype, const family_t afamily)
503   : netlist_terminal_t(atype, afamily)
498   : netlist_core_terminal_t(atype, afamily)
504499   , m_low_V(0.0)
505500   , m_high_V(0.0)
506501    , m_my_net(NET, afamily)
r26466r26467
511506
512507ATTR_COLD void netlist_output_t::init_object(netlist_core_device_t &dev, const pstring &aname)
513508{
514    netlist_terminal_t::init_object(dev, aname, STATE_OUT);
509    netlist_core_terminal_t::init_object(dev, aname, STATE_OUT);
515510    net().init_object(dev.netlist(), aname);
516511    net().register_railterminal(*this);
517512}
trunk/src/emu/netlist/nl_config.h
r26466r26467
5454//  DEBUGGING
5555//============================================================
5656
57#define NL_VERBOSE                 (0)
58#define NL_KEEP_STATISTICS         (0)
59#define FATAL_ERROR_AFTER_NS     (0) //(1000)
57#define NL_VERBOSE                  (0)
58#define NL_KEEP_STATISTICS          (0)
59#define FATAL_ERROR_AFTER_NS        (0) //(1000)
6060
6161#if (NL_VERBOSE)
62   #define NL_VERBOSE_OUT(x)      printf x
62   #define NL_VERBOSE_OUT(x)      printf x
6363#else
6464   #define NL_VERBOSE_OUT(x)
6565#endif

Previous 199869 Revisions Next


© 1997-2024 The MAME Team