Previous 199869 Revisions Next

r26026 Wednesday 6th November, 2013 at 18:50:36 UTC by Couriersud
Netlist: Moved 7420 into its own header file, optimzed some memory ops
[src/emu/netlist]nl_base.c nl_base.h
[src/emu/netlist/devices]net_lib.h nld_7410.h nld_7420.h*

trunk/src/emu/netlist/nl_base.c
r26025r26026
284284   : net_terminal_t(atype)
285285   , m_low_V(0.0)
286286   , m_high_V(0.0)
287   , m_last_Q(0)
288   , m_Q(0)
289   , m_new_Q(0)
290   , m_Q_analog(0.0)
291   , m_new_Q_analog(0.0)
287   //, m_last_Q(0)
288   //, m_Q(0)
289   //, m_new_Q(0)
290   //, m_Q_analog(0.0)
291   //, m_new_Q_analog(0.0)
292292   , m_num_cons(0)
293293   , m_time(netlist_time::zero)
294294   , m_active(0)
295295   , m_in_queue(2)
296296{
297    m_cur.Q = 0;
298    m_new.Q = 0;
299    m_last.Q = 0;
297300   //m_cons = global_alloc_array(net_input_t *, OUTPUT_MAX_CONNECTIONS);
298301}
299302
r26025r26026
314317   assert(m_num_cons != 0);
315318
316319   const UINT32 masks[4] = { 1, 5, 3, 1 };
317   m_Q = m_new_Q;
318   m_Q_analog = m_new_Q_analog;
320   m_cur = m_new;
319321   m_in_queue = 2; /* mark as taken ... */
320322
321   const UINT32 mask = masks[ (m_last_Q  << 1) | m_Q ];
323   const UINT32 mask = masks[ (m_last.Q  << 1) | m_cur.Q ];
322324
323325   switch (m_num_cons)
324326   {
r26025r26026
335337      break;
336338   }
337339
338   m_last_Q = m_Q;
340   m_last = m_cur;
339341}
340342
341343ATTR_COLD void net_output_t::register_con(net_input_t &input)
r26025r26026
399401      m_callback(INPANALOG(m_in));
400402}
401403
402// license:GPL-2.0+
403// copyright-holders:Couriersud
404404// ----------------------------------------------------------------------------------------
405405// netdev_mainclock
406406// ----------------------------------------------------------------------------------------
407407
408408ATTR_HOT inline void NETLIB_NAME(netdev_mainclock)::mc_update(net_output_t &Q, const netlist_time curtime)
409409{
410   Q.m_new_Q = !Q.m_new_Q;
410   Q.m_new.Q = !Q.m_new.Q;
411411   Q.set_time(curtime);
412412   Q.update_devs();
413413}
r26025r26026
429429ATTR_HOT NETLIB_UPDATE(netdev_mainclock)
430430{
431431   // this is only called during setup ...
432   m_Q.m_new_Q = !m_Q.m_new_Q;
432   m_Q.m_new.Q = !m_Q.m_new.Q;
433433   m_Q.set_time(m_netlist->time() + m_inc);
434434}
trunk/src/emu/netlist/nl_base.h
r26025r26026
248248{
249249public:
250250
251    typedef struct {
252        double        Analog;
253        netlist_sig_t Q;
254    } hybrid_t;
255
251256   net_output_t(int atype);
252257
253258   friend const netlist_sig_t logic_input_t::Q() const;
r26025r26026
255260   friend const bool analog_input_t::is_highz() const;
256261   friend class NETLIB_NAME(netdev_mainclock);
257262
258   ATTR_HOT inline const netlist_sig_t last_Q() const  { return m_last_Q;  }
259   ATTR_HOT inline const netlist_sig_t new_Q() const   { return m_new_Q;   }
263   ATTR_HOT inline const netlist_sig_t last_Q() const  { return m_last.Q;  }
264   ATTR_HOT inline const netlist_sig_t new_Q() const   { return m_new.Q;   }
260265
261266   ATTR_COLD void register_con(net_input_t &inp);
262267
263   ATTR_HOT inline void update_devs();
268   /* inline not always works out */
269   ATTR_HOT /*inline*/ void update_devs();
264270
265271   ATTR_HOT inline void inc_active();
266272   ATTR_HOT inline void dec_active();
r26025r26026
280286   ATTR_HOT inline const netlist_sig_t Q() const
281287   {
282288      assert(object_type(SIGNAL_MASK) == SIGNAL_DIGITAL);
283      return m_Q;
289      return m_cur.Q;
284290   }
285291   ATTR_HOT inline const double Q_Analog() const
286292   {
287293      assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG);
288      return m_Q_analog;
294        return m_cur.Analog;
289295   }
290296
291297   ATTR_HOT inline void push_to_queue(const netlist_time &delay);
292298
293   netlist_sig_t m_last_Q;
294   netlist_sig_t m_Q;
295   netlist_sig_t m_new_Q;
299   hybrid_t m_last;
300   hybrid_t m_cur;
301   hybrid_t m_new;
296302
297   double m_Q_analog;
298   double m_new_Q_analog;
303   UINT32 m_num_cons;
299304
300   UINT32 m_num_cons;
301305private:
302306   ATTR_HOT void update_dev(const net_input_t *inp, const UINT32 mask);
303307
r26025r26026
323327      m_high_V = 4.8;
324328   }
325329
326   ATTR_COLD void initial(const netlist_sig_t val) { m_Q = val; m_new_Q = val; m_last_Q = !val; }
330   ATTR_COLD void initial(const netlist_sig_t val) { m_cur.Q = val; m_new.Q = val; m_last.Q = !val; }
327331
328332   ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time &delay)
329333   {
330      if (EXPECTED(newQ != m_new_Q))
334      if (EXPECTED(newQ != m_new.Q))
331335      {
332         m_new_Q = newQ;
336         m_new.Q = newQ;
333337         if (m_num_cons)
334338            push_to_queue(delay);
335339      }
r26025r26026
359363   analog_output_t()
360364      : net_output_t(OUTPUT | SIGNAL_ANALOG) { }
361365
362   ATTR_COLD void initial(const double val) { m_Q_analog = val; m_new_Q_analog = val; }
366    ATTR_COLD void initial(const double val) { m_cur.Analog = val; m_new.Analog = val; }
363367
364368   ATTR_HOT inline void set_Q(const double newQ, const netlist_time &delay)
365369   {
366      if (newQ != m_new_Q_analog)
370      if (newQ != m_new.Analog)
367371      {
368         m_new_Q_analog = newQ;
372            m_new.Analog = newQ;
369373         push_to_queue(delay);
370374      }
371375   }
r26025r26026
716720#if USE_DEACTIVE_DEVICE
717721   if (m_active == 1 && m_in_queue > 0)
718722   {
719      m_last_Q = m_Q;
723      m_last = m_cur;
720724      netdev()->inc_active();
721      m_Q = m_new_Q;
725      m_cur = m_new;
722726   }
723727#endif
724728
r26025r26026
731735      }
732736      else
733737      {
734         m_Q = m_last_Q = m_new_Q;
735         m_Q_analog = m_new_Q_analog;
738         m_cur = m_last = m_new;
736739         m_in_queue = 2;
737740      }
738741   }
trunk/src/emu/netlist/devices/nld_7410.h
r26025r26026
1717 *                  ___
1818 *              Y = ABC
1919 *          +---+---+---++---+
20 *          | A | B | B || Y |
20 *          | A | B | C || Y |
2121 *          +===+===+===++===+
2222 *          | X | X | 0 || 1 |
2323 *          | X | 0 | X || 1 |
trunk/src/emu/netlist/devices/nld_7420.h
r0r26026
1// license:GPL-2.0+
2// copyright-holders:Couriersud
3/*
4 * nld_7420.h
5 *
6 *  DM7420: Dual 4-Input NAND Gates
7 *
8 *          +--------------+
9 *       A1 |1     ++    14| VCC
10 *       B1 |2           13| D2
11 *       NC |3           12| C2
12 *       C1 |4    7420   11| NC
13 *       D1 |5           10| B2
14 *       Y! |6            9| A2
15 *      GND |7            8| Y2
16 *          +--------------+
17 *                  ____
18 *              Y = ABCD
19 *          +---+---+---+---++---+
20 *          | A | B | C | D || Y |
21 *          +===+===+===+===++===+
22 *          | X | X | X | 0 || 1 |
23 *          | X | X | 0 | X || 1 |
24 *          | X | 0 | X | X || 1 |
25 *          | 0 | X | X | X || 1 |
26 *          | 1 | 1 | 1 | 1 || 0 |
27 *          +---+---+---+---++---+
28 *
29 *  Naming conventions follow National Semiconductor datasheet
30 *
31 */
32
33
34#include "nld_signal.h"
35
36#ifndef NLD_7420_H_
37#define NLD_7420_H_
38
39#define TTL_7420_NAND(_name, _I1, _I2, _I3, _I4)                                    \
40        NET_REGISTER_DEV(nic7420, _name)                                            \
41        NET_CONNECT(_name, A, _I1)                                                  \
42        NET_CONNECT(_name, B, _I2)                                                  \
43        NET_CONNECT(_name, C, _I3)                                                  \
44        NET_CONNECT(_name, D, _I4)
45
46
47NETLIB_SIGNAL(nic7420, 4, 0, 0);
48
49#endif /* NLD_7420_H_ */
Property changes on: trunk/src/emu/netlist/devices/nld_7420.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native
trunk/src/emu/netlist/devices/net_lib.h
r26025r26026
5757#include "nld_7400.h"
5858#include "nld_7402.h"
5959#include "nld_7410.h"
60#include "nld_7420.h"
6061
6162// this is a bad hack
6263#define USE_OLD7493 (0)
r26025r26026
104105      NET_REGISTER_DEV(nic7404, _name)                                            \
105106      NET_CONNECT(_name, I1, _I1)
106107
107#define TTL_7420_NAND(_name, _I1, _I2, _I3, _I4)                                    \
108      NET_REGISTER_DEV(nic7420, _name)                                            \
109      NET_CONNECT(_name, A, _I1)                                                  \
110      NET_CONNECT(_name, B, _I2)                                                  \
111      NET_CONNECT(_name, C, _I3)                                                  \
112      NET_CONNECT(_name, D, _I4)
113
114108#define TTL_7425_NOR(_name, _I1, _I2, _I3, _I4)                                     \
115109      NET_REGISTER_DEV(nic7425, _name)                                            \
116110      NET_CONNECT(_name, A, _I1)                                                  \
r26025r26026
318312   net_param_t m_VL;
319313);
320314
321NETLIB_SIGNAL(nic7420, 4, 0, 0);
322315NETLIB_SIGNAL(nic7425, 4, 1, 0);
323316NETLIB_SIGNAL(nic7427, 3, 1, 0);
324317NETLIB_SIGNAL(nic7430, 8, 0, 0);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team