trunk/src/emu/netlist/devices/nld_7430.h
| r0 | r26404 | |
| 1 | // license:GPL-2.0+ |
| 2 | // copyright-holders:Couriersud |
| 3 | /* |
| 4 | * nld_7430.h |
| 5 | * |
| 6 | * DM7430: 8-Input NAND Gate |
| 7 | * |
| 8 | * +--------------+ |
| 9 | * A |1 ++ 14| VCC |
| 10 | * B |2 13| NC |
| 11 | * C |3 12| H |
| 12 | * D |4 7430 11| G |
| 13 | * E |5 10| NC |
| 14 | * F |6 9| NC |
| 15 | * GND |7 8| Y |
| 16 | * +--------------+ |
| 17 | * ________ |
| 18 | * Y = ABCDEFGH |
| 19 | * +---+---+---+---+---+---+---+---++---+ |
| 20 | * | A | B | C | D | E | F | G | H || Y | |
| 21 | * +===+===+===+===+===+===+===+===++===+ |
| 22 | * | X | X | X | X | X | X | X | 0 || 1 | |
| 23 | * | X | X | X | X | X | X | 0 | X || 1 | |
| 24 | * | X | X | X | X | X | 0 | X | X || 1 | |
| 25 | * | X | X | X | X | 0 | X | X | X || 1 | |
| 26 | * | X | X | X | 0 | X | X | X | X || 1 | |
| 27 | * | X | X | 0 | X | X | X | X | X || 1 | |
| 28 | * | X | 0 | X | X | X | X | X | X || 1 | |
| 29 | * | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 || 0 | |
| 30 | * +---+---+---+---+---+---+---+---++---+ |
| 31 | * |
| 32 | * Naming conventions follow National Semiconductor datasheet |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | |
| 37 | #ifndef NLD_7430_H_ |
| 38 | #define NLD_7430_H_ |
| 39 | |
| 40 | #include "nld_signal.h" |
| 41 | |
| 42 | #define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \ |
| 43 | NET_REGISTER_DEV(nic7430, _name) \ |
| 44 | NET_CONNECT(_name, A, _I1) \ |
| 45 | NET_CONNECT(_name, B, _I2) \ |
| 46 | NET_CONNECT(_name, C, _I3) \ |
| 47 | NET_CONNECT(_name, D, _I4) \ |
| 48 | NET_CONNECT(_name, E, _I5) \ |
| 49 | NET_CONNECT(_name, F, _I6) \ |
| 50 | NET_CONNECT(_name, G, _I7) \ |
| 51 | NET_CONNECT(_name, H, _I8) |
| 52 | |
| 53 | |
| 54 | NETLIB_SIGNAL(nic7430, 8, 0, 0); |
| 55 | |
| 56 | #endif /* NLD_7430_H_ */ |
trunk/src/emu/netlist/devices/net_lib.h
| r26403 | r26404 | |
| 60 | 60 | #include "nld_7420.h" |
| 61 | 61 | #include "nld_7425.h" |
| 62 | 62 | #include "nld_7427.h" |
| 63 | #include "nld_7430.h" |
| 64 | #include "nld_7486.h" |
| 63 | 65 | |
| 64 | 66 | // this is a bad hack |
| 65 | 67 | #define USE_OLD7493 (0) |
| r26403 | r26404 | |
| 97 | 99 | // TTL Logic chips |
| 98 | 100 | // ---------------------------------------------------------------------------------------- |
| 99 | 101 | |
| 100 | | |
| 101 | | |
| 102 | 102 | #define TTL_7404_INVERT(_name, _I1) \ |
| 103 | 103 | NET_REGISTER_DEV(nic7404, _name) \ |
| 104 | 104 | NET_CONNECT(_name, I1, _I1) |
| 105 | 105 | |
| 106 | | |
| 107 | | |
| 108 | | #define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \ |
| 109 | | NET_REGISTER_DEV(nic7430, _name) \ |
| 110 | | NET_CONNECT(_name, A, _I1) \ |
| 111 | | NET_CONNECT(_name, B, _I2) \ |
| 112 | | NET_CONNECT(_name, C, _I3) \ |
| 113 | | NET_CONNECT(_name, D, _I4) \ |
| 114 | | NET_CONNECT(_name, E, _I5) \ |
| 115 | | NET_CONNECT(_name, F, _I6) \ |
| 116 | | NET_CONNECT(_name, G, _I7) \ |
| 117 | | NET_CONNECT(_name, H, _I8) |
| 118 | | |
| 119 | 106 | #define TTL_7450_ANDORINVERT(_name, _I1, _I2, _I3, _I4) \ |
| 120 | 107 | NET_REGISTER_DEV(nic7450, _name) \ |
| 121 | 108 | NET_CONNECT(_name, I1, _I1) \ |
| r26403 | r26404 | |
| 123 | 110 | NET_CONNECT(_name, I3, _I3) \ |
| 124 | 111 | NET_CONNECT(_name, I4, _I4) |
| 125 | 112 | |
| 126 | | #define TTL_7486_XOR(_name, _I1, _I2) \ |
| 127 | | NET_REGISTER_DEV(nic7486, _name) \ |
| 128 | | NET_CONNECT(_name, I1, _I1) \ |
| 129 | | NET_CONNECT(_name, I2, _I2) |
| 130 | | |
| 131 | 113 | #define TTL_7448(_name, _A0, _A1, _A2, _A3, _LTQ, _BIQ, _RBIQ) \ |
| 132 | 114 | NET_REGISTER_DEV(nic7448, _name) \ |
| 133 | 115 | NET_CONNECT(_name, A0, _A0) \ |
| r26403 | r26404 | |
| 297 | 279 | |
| 298 | 280 | ); |
| 299 | 281 | |
| 300 | | NETLIB_SIGNAL(nic7430, 8, 0, 0); |
| 301 | 282 | |
| 283 | |
| 302 | 284 | NETLIB_DEVICE(nic7404, |
| 303 | 285 | netlist_ttl_input_t m_I; |
| 304 | 286 | netlist_ttl_output_t m_Q; |
| r26403 | r26404 | |
| 330 | 312 | netlist_ttl_input_t m_preQ; |
| 331 | 313 | ); |
| 332 | 314 | |
| 333 | | NETLIB_DEVICE(nic7486, |
| 334 | | netlist_ttl_input_t m_I0; |
| 335 | | netlist_ttl_input_t m_I1; |
| 336 | | netlist_ttl_output_t m_Q; |
| 337 | | ); |
| 338 | | |
| 339 | 315 | /* 74107 does latch data during high ! |
| 340 | 316 | * For modelling purposes, we assume 74107 and 74107A are the same |
| 341 | 317 | */ |
trunk/src/emu/netlist/pstring.c
| r26403 | r26404 | |
| 107 | 107 | |
| 108 | 108 | char *pstring::alloc_str(int n) |
| 109 | 109 | { |
| 110 | | #if (IMMEDIATE_MODE) |
| 111 | | return (char *) malloc(n); |
| 112 | | #else |
| 113 | | #if (DEBUG_MODE) |
| 114 | | int min_alloc = MAX(0, n+sizeof(memblock)); |
| 115 | | #else |
| 116 | | int min_alloc = MAX(8192, n+sizeof(memblock)); |
| 117 | | #endif |
| 118 | | char *ret = NULL; |
| 119 | | |
| 120 | | //std::printf("m_first %p\n", m_first); |
| 121 | | for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next) |
| 110 | if (IMMEDIATE_MODE) |
| 111 | return (char *) malloc(n); |
| 112 | else |
| 122 | 113 | { |
| 123 | | if (p->remaining > n) |
| 114 | int min_alloc = MAX((DEBUG_MODE) ? 0 : 8192, n+sizeof(memblock)); |
| 115 | char *ret = NULL; |
| 116 | |
| 117 | //std::printf("m_first %p\n", m_first); |
| 118 | for (memblock *p = m_first; p != NULL && ret == NULL; p = p->next) |
| 124 | 119 | { |
| 120 | if (p->remaining > n) |
| 121 | { |
| 122 | ret = p->cur; |
| 123 | p->cur += n; |
| 124 | p->allocated += 1; |
| 125 | p->remaining -= n; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | if (ret == NULL) |
| 130 | { |
| 131 | // need to allocate a new block |
| 132 | memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc]; |
| 133 | p->allocated = 0; |
| 134 | p->cur = &p->data[0]; |
| 135 | p->size = p->remaining = min_alloc - sizeof(memblock); |
| 136 | p->next = m_first; |
| 137 | //std::printf("allocated block size %d\n", p->size); |
| 138 | |
| 125 | 139 | ret = p->cur; |
| 126 | 140 | p->cur += n; |
| 127 | 141 | p->allocated += 1; |
| 128 | 142 | p->remaining -= n; |
| 143 | |
| 144 | m_first = p; |
| 129 | 145 | } |
| 130 | | } |
| 131 | 146 | |
| 132 | | if (ret == NULL) |
| 133 | | { |
| 134 | | // need to allocate a new block |
| 135 | | memblock *p = (memblock *) malloc(min_alloc); //new char[min_alloc]; |
| 136 | | p->allocated = 0; |
| 137 | | p->cur = &p->data[0]; |
| 138 | | p->size = p->remaining = min_alloc - sizeof(memblock); |
| 139 | | p->next = m_first; |
| 140 | | //std::printf("allocated block size %d\n", p->size); |
| 141 | | |
| 142 | | ret = p->cur; |
| 143 | | p->cur += n; |
| 144 | | p->allocated += 1; |
| 145 | | p->remaining -= n; |
| 146 | | |
| 147 | | m_first = p; |
| 147 | return ret; |
| 148 | 148 | } |
| 149 | | |
| 150 | | return ret; |
| 151 | | #endif |
| 152 | 149 | } |
| 153 | 150 | |
| 154 | 151 | void pstring::dealloc_str(void *ptr) |
| 155 | 152 | { |
| 156 | | #if (IMMEDIATE_MODE) |
| 157 | | free(ptr); |
| 158 | | #else |
| 159 | | for (memblock *p = m_first; p != NULL; p = p->next) |
| 153 | if (IMMEDIATE_MODE) |
| 154 | free(ptr); |
| 155 | else |
| 160 | 156 | { |
| 161 | | if (ptr >= &p->data[0] && ptr < &p->data[p->size]) |
| 157 | for (memblock *p = m_first; p != NULL; p = p->next) |
| 162 | 158 | { |
| 163 | | p->allocated -= 1; |
| 164 | | if (p->allocated < 0) |
| 165 | | fatalerror("nstring: memory corruption\n"); |
| 166 | | if (p->allocated == 0) |
| 159 | if (ptr >= &p->data[0] && ptr < &p->data[p->size]) |
| 167 | 160 | { |
| 168 | | //std::printf("Block entirely freed\n"); |
| 169 | | p->remaining = p->size; |
| 170 | | p->cur = &p->data[0]; |
| 161 | p->allocated -= 1; |
| 162 | if (p->allocated < 0) |
| 163 | fatalerror("nstring: memory corruption\n"); |
| 164 | if (p->allocated == 0) |
| 165 | { |
| 166 | //std::printf("Block entirely freed\n"); |
| 167 | p->remaining = p->size; |
| 168 | p->cur = &p->data[0]; |
| 169 | } |
| 170 | // shutting down ? |
| 171 | if (m_zero == NULL) |
| 172 | resetmem(); // try to free blocks |
| 173 | return; |
| 171 | 174 | } |
| 172 | | // shutting down ? |
| 173 | | if (m_zero == NULL) |
| 174 | | resetmem(); // try to free blocks |
| 175 | | return; |
| 176 | 175 | } |
| 176 | fatalerror("nstring: string <%p> not found\n", ptr); |
| 177 | 177 | } |
| 178 | | fatalerror("nstring: string <%p> not found\n", ptr); |
| 179 | | #endif |
| 180 | 178 | } |
| 181 | 179 | |
| 182 | 180 | void pstring::resetmem() |
| 183 | 181 | { |
| 184 | | #if (IMMEDIATE_MODE) |
| 185 | | #else |
| 186 | | memblock **p = &m_first; |
| 187 | | int totalblocks = 0; |
| 188 | | int freedblocks = 0; |
| 182 | if (!IMMEDIATE_MODE) |
| 183 | { |
| 184 | memblock **p = &m_first; |
| 185 | int totalblocks = 0; |
| 186 | int freedblocks = 0; |
| 189 | 187 | |
| 190 | | // Release the 0 string |
| 191 | | if (m_zero != NULL) sfree(m_zero); |
| 192 | | m_zero = NULL; |
| 188 | // Release the 0 string |
| 189 | if (m_zero != NULL) sfree(m_zero); |
| 190 | m_zero = NULL; |
| 193 | 191 | |
| 194 | | while (*p != NULL) |
| 195 | | { |
| 196 | | totalblocks++; |
| 197 | | memblock **next = &((*p)->next); |
| 198 | | if ((*p)->allocated == 0) |
| 192 | while (*p != NULL) |
| 199 | 193 | { |
| 200 | | //std::printf("freeing block %p\n", *p); |
| 201 | | memblock *freeme = *p; |
| 202 | | *p = *next; |
| 203 | | free(freeme); //delete[] *p; |
| 204 | | freedblocks++; |
| 194 | totalblocks++; |
| 195 | memblock **next = &((*p)->next); |
| 196 | if ((*p)->allocated == 0) |
| 197 | { |
| 198 | //std::printf("freeing block %p\n", *p); |
| 199 | memblock *freeme = *p; |
| 200 | *p = *next; |
| 201 | free(freeme); //delete[] *p; |
| 202 | freedblocks++; |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | if (DEBUG_MODE) |
| 207 | std::printf("Allocated: <%s>\n", ((str_t *)(&(*p)->data[0]))->str()); |
| 208 | |
| 209 | p = next; |
| 210 | } |
| 205 | 211 | } |
| 206 | | else |
| 207 | | { |
| 208 | | #if (DEBUG_MODE) |
| 209 | | std::printf("Allocated: <%s>\n", ((str_t *)(&(*p)->data[0]))->str()); |
| 210 | | #endif |
| 211 | | p = next; |
| 212 | | } |
| 212 | if (DEBUG_MODE) |
| 213 | std::printf("Freed %d out of total %d blocks\n", freedblocks, totalblocks); |
| 213 | 214 | } |
| 214 | | #if (DEBUG_MODE) |
| 215 | | std::printf("Freed %d out of total %d blocks\n", freedblocks, totalblocks); |
| 216 | | #endif |
| 217 | | #endif |
| 218 | 215 | } |