diff --git a/.gitattributes b/.gitattributes index dd2cb945d36..0d0420409fb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2131,6 +2131,9 @@ src/emu/netlist/devices/nld_7410.h svneol=native#text/plain src/emu/netlist/devices/nld_7420.h svneol=native#text/plain src/emu/netlist/devices/nld_7425.h svneol=native#text/plain src/emu/netlist/devices/nld_7427.h svneol=native#text/plain +src/emu/netlist/devices/nld_7430.h svneol=native#text/plain +src/emu/netlist/devices/nld_7486.c svneol=native#text/plain +src/emu/netlist/devices/nld_7486.h svneol=native#text/plain src/emu/netlist/devices/nld_signal.h svneol=native#text/plain src/emu/netlist/devices/nld_system.c svneol=native#text/plain src/emu/netlist/devices/nld_system.h svneol=native#text/plain diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index 86feecff40b..a28680d3cad 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -280,20 +280,6 @@ NETLIB_UPDATE(nic7404) OUTLOGIC(m_Q, t, delay[t]); } -NETLIB_START(nic7486) -{ - register_input("I1", m_I0); - register_input("I2", m_I1); - register_output("Q", m_Q); -} - -NETLIB_UPDATE(nic7486) -{ - static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; - UINT8 t = INPLOGIC(m_I0) ^ INPLOGIC(m_I1); - OUTLOGIC(m_Q, t, delay[t]); -} - NETLIB_START(nic7448) { register_sub(sub, "sub"); diff --git a/src/emu/netlist/devices/net_lib.h b/src/emu/netlist/devices/net_lib.h index 34338aaa3aa..d96cccc4a47 100644 --- a/src/emu/netlist/devices/net_lib.h +++ b/src/emu/netlist/devices/net_lib.h @@ -60,6 +60,8 @@ #include "nld_7420.h" #include "nld_7425.h" #include "nld_7427.h" +#include "nld_7430.h" +#include "nld_7486.h" // this is a bad hack #define USE_OLD7493 (0) @@ -97,25 +99,10 @@ // TTL Logic chips // ---------------------------------------------------------------------------------------- - - #define TTL_7404_INVERT(_name, _I1) \ NET_REGISTER_DEV(nic7404, _name) \ NET_CONNECT(_name, I1, _I1) - - -#define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \ - NET_REGISTER_DEV(nic7430, _name) \ - NET_CONNECT(_name, A, _I1) \ - NET_CONNECT(_name, B, _I2) \ - NET_CONNECT(_name, C, _I3) \ - NET_CONNECT(_name, D, _I4) \ - NET_CONNECT(_name, E, _I5) \ - NET_CONNECT(_name, F, _I6) \ - NET_CONNECT(_name, G, _I7) \ - NET_CONNECT(_name, H, _I8) - #define TTL_7450_ANDORINVERT(_name, _I1, _I2, _I3, _I4) \ NET_REGISTER_DEV(nic7450, _name) \ NET_CONNECT(_name, I1, _I1) \ @@ -123,11 +110,6 @@ NET_CONNECT(_name, I3, _I3) \ NET_CONNECT(_name, I4, _I4) -#define TTL_7486_XOR(_name, _I1, _I2) \ - NET_REGISTER_DEV(nic7486, _name) \ - NET_CONNECT(_name, I1, _I1) \ - NET_CONNECT(_name, I2, _I2) - #define TTL_7448(_name, _A0, _A1, _A2, _A3, _LTQ, _BIQ, _RBIQ) \ NET_REGISTER_DEV(nic7448, _name) \ NET_CONNECT(_name, A0, _A0) \ @@ -297,7 +279,7 @@ NETLIB_DEVICE_WITH_PARAMS(nicNE555N_MSTABLE, ); -NETLIB_SIGNAL(nic7430, 8, 0, 0); + NETLIB_DEVICE(nic7404, netlist_ttl_input_t m_I; @@ -330,12 +312,6 @@ NETLIB_DEVICE(nic7474, netlist_ttl_input_t m_preQ; ); -NETLIB_DEVICE(nic7486, - netlist_ttl_input_t m_I0; - netlist_ttl_input_t m_I1; - netlist_ttl_output_t m_Q; -); - /* 74107 does latch data during high ! * For modelling purposes, we assume 74107 and 74107A are the same */ diff --git a/src/emu/netlist/devices/nld_7400.h b/src/emu/netlist/devices/nld_7400.h index 82f121597ed..f7a533b8916 100644 --- a/src/emu/netlist/devices/nld_7400.h +++ b/src/emu/netlist/devices/nld_7400.h @@ -29,11 +29,11 @@ * */ -#include "nld_signal.h" - #ifndef NLD_7400_H_ #define NLD_7400_H_ +#include "nld_signal.h" + #define TTL_7400_NAND(_name, _A, _B) \ NET_REGISTER_DEV(7400, _name) \ NET_CONNECT(_name, A, _A) \ diff --git a/src/emu/netlist/devices/nld_7402.h b/src/emu/netlist/devices/nld_7402.h index 4020d940edf..0d5990478c0 100644 --- a/src/emu/netlist/devices/nld_7402.h +++ b/src/emu/netlist/devices/nld_7402.h @@ -29,12 +29,11 @@ * */ - -#include "nld_signal.h" - #ifndef NLD_7402_H_ #define NLD_7402_H_ +#include "nld_signal.h" + #define TTL_7402_NOR(_name, _I1, _I2) \ NET_REGISTER_DEV(7402, _name) \ NET_CONNECT(_name, A, _I1) \ diff --git a/src/emu/netlist/devices/nld_7410.h b/src/emu/netlist/devices/nld_7410.h index 17f0272b7d7..860d5fcab21 100644 --- a/src/emu/netlist/devices/nld_7410.h +++ b/src/emu/netlist/devices/nld_7410.h @@ -29,12 +29,11 @@ * */ - -#include "nld_signal.h" - #ifndef NLD_7410_H_ #define NLD_7410_H_ +#include "nld_signal.h" + #define TTL_7410_NAND(_name, _I1, _I2, _I3) \ NET_REGISTER_DEV(7410, _name) \ NET_CONNECT(_name, A, _I1) \ diff --git a/src/emu/netlist/devices/nld_7420.h b/src/emu/netlist/devices/nld_7420.h index 8e21d1cdd1b..5ff5bd12ac5 100644 --- a/src/emu/netlist/devices/nld_7420.h +++ b/src/emu/netlist/devices/nld_7420.h @@ -30,12 +30,11 @@ * */ - -#include "nld_signal.h" - #ifndef NLD_7420_H_ #define NLD_7420_H_ +#include "nld_signal.h" + #define TTL_7420_NAND(_name, _I1, _I2, _I3, _I4) \ NET_REGISTER_DEV(7420, _name) \ NET_CONNECT(_name, A, _I1) \ diff --git a/src/emu/netlist/devices/nld_7425.h b/src/emu/netlist/devices/nld_7425.h index 16fc1cadbb6..5e2fff4f946 100644 --- a/src/emu/netlist/devices/nld_7425.h +++ b/src/emu/netlist/devices/nld_7425.h @@ -33,12 +33,11 @@ * */ - -#include "nld_signal.h" - #ifndef NLD_7425_H_ #define NLD_7425_H_ +#include "nld_signal.h" + #define TTL_7425_NOR(_name, _I1, _I2, _I3, _I4) \ NET_REGISTER_DEV(7425, _name) \ NET_CONNECT(_name, A, _I1) \ diff --git a/src/emu/netlist/devices/nld_7427.h b/src/emu/netlist/devices/nld_7427.h index 00a8c0eec1c..c5a8ede870a 100644 --- a/src/emu/netlist/devices/nld_7427.h +++ b/src/emu/netlist/devices/nld_7427.h @@ -29,12 +29,11 @@ * */ - -#include "nld_signal.h" - #ifndef NLD_7427_H_ #define NLD_7427_H_ +#include "nld_signal.h" + #define TTL_7427_NOR(_name, _I1, _I2, _I3) \ NET_REGISTER_DEV(7427, _name) \ NET_CONNECT(_name, A, _I1) \ diff --git a/src/emu/netlist/devices/nld_7430.h b/src/emu/netlist/devices/nld_7430.h new file mode 100644 index 00000000000..55d7b3e406c --- /dev/null +++ b/src/emu/netlist/devices/nld_7430.h @@ -0,0 +1,56 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * nld_7430.h + * + * DM7430: 8-Input NAND Gate + * + * +--------------+ + * A |1 ++ 14| VCC + * B |2 13| NC + * C |3 12| H + * D |4 7430 11| G + * E |5 10| NC + * F |6 9| NC + * GND |7 8| Y + * +--------------+ + * ________ + * Y = ABCDEFGH + * +---+---+---+---+---+---+---+---++---+ + * | A | B | C | D | E | F | G | H || Y | + * +===+===+===+===+===+===+===+===++===+ + * | X | X | X | X | X | X | X | 0 || 1 | + * | X | X | X | X | X | X | 0 | X || 1 | + * | X | X | X | X | X | 0 | X | X || 1 | + * | X | X | X | X | 0 | X | X | X || 1 | + * | X | X | X | 0 | X | X | X | X || 1 | + * | X | X | 0 | X | X | X | X | X || 1 | + * | X | 0 | X | X | X | X | X | X || 1 | + * | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 || 0 | + * +---+---+---+---+---+---+---+---++---+ + * + * Naming conventions follow National Semiconductor datasheet + * + */ + + +#ifndef NLD_7430_H_ +#define NLD_7430_H_ + +#include "nld_signal.h" + +#define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \ + NET_REGISTER_DEV(nic7430, _name) \ + NET_CONNECT(_name, A, _I1) \ + NET_CONNECT(_name, B, _I2) \ + NET_CONNECT(_name, C, _I3) \ + NET_CONNECT(_name, D, _I4) \ + NET_CONNECT(_name, E, _I5) \ + NET_CONNECT(_name, F, _I6) \ + NET_CONNECT(_name, G, _I7) \ + NET_CONNECT(_name, H, _I8) + + +NETLIB_SIGNAL(nic7430, 8, 0, 0); + +#endif /* NLD_7430_H_ */ diff --git a/src/emu/netlist/devices/nld_7486.c b/src/emu/netlist/devices/nld_7486.c new file mode 100644 index 00000000000..c7c4ad03f70 --- /dev/null +++ b/src/emu/netlist/devices/nld_7486.c @@ -0,0 +1,21 @@ +/* + * nld_7486.c + * + */ + +#include "nld_7486.h" + +NETLIB_START(nic7486) +{ + register_input("A", m_A); + register_input("B", m_B); + register_output("Q", m_Q); +} + +NETLIB_UPDATE(nic7486) +{ + static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; + UINT8 t = INPLOGIC(m_A) ^ INPLOGIC(m_B); + OUTLOGIC(m_Q, t, delay[t]); +} + diff --git a/src/emu/netlist/devices/nld_7486.h b/src/emu/netlist/devices/nld_7486.h new file mode 100644 index 00000000000..c434fc1cf73 --- /dev/null +++ b/src/emu/netlist/devices/nld_7486.h @@ -0,0 +1,47 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * nld_7486.h + * + * DM7486: Quad 2-Input NAND Gates + * + * +--------------+ + * A1 |1 ++ 14| VCC + * B1 |2 13| B4 + * Y1 |3 12| A4 + * A2 |4 7486 11| Y4 + * B2 |5 10| B3 + * Y2 |6 9| A3 + * GND |7 8| Y3 + * +--------------+ + * + * Y = A+B + * +---+---++---+ + * | A | B || Y | + * +===+===++===+ + * | 0 | 0 || 0 | + * | 0 | 1 || 1 | + * | 1 | 0 || 1 | + * | 1 | 1 || 0 | + * +---+---++---+ + * + * Naming conventions follow National Semiconductor datasheet + * + */ + +#ifndef NLD_7486_H_ +#define NLD_7486_H_ + +#include "nld_signal.h" + +#define TTL_7486_XOR(_name, _A, _B) \ + NET_REGISTER_DEV(nic7486, _name) \ + NET_CONNECT(_name, A, _A) \ + NET_CONNECT(_name, B, _B) + +NETLIB_DEVICE(nic7486, + netlist_ttl_input_t m_A; + netlist_ttl_input_t m_B; + netlist_ttl_output_t m_Q; +); +#endif /* NLD_7486_H_ */ diff --git a/src/emu/netlist/netlist.mak b/src/emu/netlist/netlist.mak index c0d215d2e5c..7a26a5edd09 100644 --- a/src/emu/netlist/netlist.mak +++ b/src/emu/netlist/netlist.mak @@ -24,4 +24,5 @@ NETLISTOBJS+= \ $(NETLISTOBJ)/nl_parser.o \ $(NETLISTOBJ)/devices/nld_system.o \ $(NETLISTOBJ)/devices/net_lib.o \ + $(NETLISTOBJ)/devices/nld_7486.o \ diff --git a/src/emu/netlist/pstring.c b/src/emu/netlist/pstring.c index e23718a16a9..1620889cef5 100644 --- a/src/emu/netlist/pstring.c +++ b/src/emu/netlist/pstring.c @@ -107,112 +107,109 @@ pstring pstring::sprintf(const char *format, ...) char *pstring::alloc_str(int n) { -#if (IMMEDIATE_MODE) - return (char *) malloc(n); -#else -#if (DEBUG_MODE) - int min_alloc = MAX(0, n+sizeof(memblock)); -#else - int min_alloc = MAX(8192, n+sizeof(memblock)); -#endif - char *ret = NULL; - - //std::printf("m_first %p\n", m_first); - for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next) + if (IMMEDIATE_MODE) + return (char *) malloc(n); + else { - if (p->remaining > n) + int min_alloc = MAX((DEBUG_MODE) ? 0 : 8192, n+sizeof(memblock)); + char *ret = NULL; + + //std::printf("m_first %p\n", m_first); + for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next) { + if (p->remaining > n) + { + ret = p->cur; + p->cur += n; + p->allocated += 1; + p->remaining -= n; + } + } + + if (ret == NULL) + { + // need to allocate a new block + memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc]; + p->allocated = 0; + p->cur = &p->data[0]; + p->size = p->remaining = min_alloc - sizeof(memblock); + p->next = m_first; + //std::printf("allocated block size %d\n", p->size); + ret = p->cur; p->cur += n; p->allocated += 1; p->remaining -= n; + + m_first = p; } + + return ret; } - - if (ret == NULL) - { - // need to allocate a new block - memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc]; - p->allocated = 0; - p->cur = &p->data[0]; - p->size = p->remaining = min_alloc - sizeof(memblock); - p->next = m_first; - //std::printf("allocated block size %d\n", p->size); - - ret = p->cur; - p->cur += n; - p->allocated += 1; - p->remaining -= n; - - m_first = p; - } - - return ret; -#endif } void pstring::dealloc_str(void *ptr) { -#if (IMMEDIATE_MODE) - free(ptr); -#else - for (memblock *p = m_first; p != NULL; p = p->next) + if (IMMEDIATE_MODE) + free(ptr); + else { - if (ptr >= &p->data[0] && ptr < &p->data[p->size]) + for (memblock *p = m_first; p != NULL; p = p->next) { - p->allocated -= 1; - if (p->allocated < 0) - fatalerror("nstring: memory corruption\n"); - if (p->allocated == 0) + if (ptr >= &p->data[0] && ptr < &p->data[p->size]) { - //std::printf("Block entirely freed\n"); - p->remaining = p->size; - p->cur = &p->data[0]; + p->allocated -= 1; + if (p->allocated < 0) + fatalerror("nstring: memory corruption\n"); + if (p->allocated == 0) + { + //std::printf("Block entirely freed\n"); + p->remaining = p->size; + p->cur = &p->data[0]; + } + // shutting down ? + if (m_zero == NULL) + resetmem(); // try to free blocks + return; } - // shutting down ? - if (m_zero == NULL) - resetmem(); // try to free blocks - return; } + fatalerror("nstring: string <%p> not found\n", ptr); } - fatalerror("nstring: string <%p> not found\n", ptr); -#endif } void pstring::resetmem() { -#if (IMMEDIATE_MODE) -#else - memblock **p = &m_first; - int totalblocks = 0; - int freedblocks = 0; - - // Release the 0 string - if (m_zero != NULL) sfree(m_zero); - m_zero = NULL; - - while (*p != NULL) + if (!IMMEDIATE_MODE) { - totalblocks++; - memblock **next = &((*p)->next); - if ((*p)->allocated == 0) + memblock **p = &m_first; + int totalblocks = 0; + int freedblocks = 0; + + // Release the 0 string + if (m_zero != NULL) sfree(m_zero); + m_zero = NULL; + + while (*p != NULL) { - //std::printf("freeing block %p\n", *p); - memblock *freeme = *p; - *p = *next; - free(freeme); //delete[] *p; - freedblocks++; - } - else - { -#if (DEBUG_MODE) - std::printf("Allocated: <%s>\n", ((str_t *)(&(*p)->data[0]))->str()); -#endif - p = next; + totalblocks++; + memblock **next = &((*p)->next); + if ((*p)->allocated == 0) + { + //std::printf("freeing block %p\n", *p); + memblock *freeme = *p; + *p = *next; + free(freeme); //delete[] *p; + freedblocks++; + } + else + { + if (DEBUG_MODE) + std::printf("Allocated: <%s>\n", ((str_t *)(&(*p)->data[0]))->str()); + + p = next; + } } + if (DEBUG_MODE) + std::printf("Freed %d out of total %d blocks\n", freedblocks, totalblocks); } -#if (DEBUG_MODE) - std::printf("Freed %d out of total %d blocks\n", freedblocks, totalblocks); -#endif -#endif }