diff options
| author | 2013-12-24 07:24:51 +0000 | |
|---|---|---|
| committer | 2013-12-24 07:24:51 +0000 | |
| commit | ca546caa6e2932e504d020fb80b6cc0e8665cea9 (patch) | |
| tree | aa9f12d46b8088c24d1ff5322d0808c0aacce42c /src/emu | |
| parent | efaac9818f3f4511f7ad5201fcfe3bbd22c007a4 (diff) | |
Cleanups and version bumpmame0152
Diffstat (limited to 'src/emu')
99 files changed, 3722 insertions, 3750 deletions
diff --git a/src/emu/bus/a2bus/a2alfam2.c b/src/emu/bus/a2bus/a2alfam2.c index 197d6cdb4de..e55b43f773b 100644 --- a/src/emu/bus/a2bus/a2alfam2.c +++ b/src/emu/bus/a2bus/a2alfam2.c @@ -177,7 +177,7 @@ void a2bus_sn76489_device::write_c0nx(address_space &space, UINT8 offset, UINT8 case 3: if (m_has4thsn) { - m_sn4->write(space, 0, data); + m_sn4->write(space, 0, data); m_latch3 = data; } break; diff --git a/src/emu/bus/abcbus/lux21046.c b/src/emu/bus/abcbus/lux21046.c index b0dc187e9d3..cbf092fbef7 100644 --- a/src/emu/bus/abcbus/lux21046.c +++ b/src/emu/bus/abcbus/lux21046.c @@ -498,7 +498,7 @@ INPUT_PORTS_START( abc830 ) PORT_START("SW3") PORT_DIPNAME( 0x7f, 0x2d, "Card Address" ) PORT_DIPLOCATION("SW3:1,2,3,4,5,6,7") PORT_DIPSETTING( 0x2d, "45" ) - + PORT_START("S1") // also S3,S5 PORT_DIPNAME( 0x01, 0x01, "Interface Type" ) PORT_DIPSETTING( 0x00, "ABC 1600" ) @@ -549,7 +549,7 @@ INPUT_PORTS_START( abc832 ) PORT_START("SW3") PORT_DIPNAME( 0x7f, 0x2c, "Card Address" ) PORT_DIPLOCATION("SW3:1,2,3,4,5,6,7") PORT_DIPSETTING( 0x2c, "44" ) - + PORT_START("S1") // also S3,S5 PORT_DIPNAME( 0x01, 0x01, "Interface Type" ) PORT_DIPSETTING( 0x00, "ABC 1600" ) @@ -629,7 +629,7 @@ INPUT_PORTS_START( abc838 ) PORT_START("SW1") PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW1:1,2,3,4") PORT_DIPSETTING( 0x00, DEF_STR( Unused ) ) - + PORT_START("SW2") PORT_DIPNAME( 0x0f, 0x0e, "Drive Type" ) PORT_DIPLOCATION("SW2:1,2,3,4") PORT_DIPSETTING( 0x0e, "BASF 6105" ) @@ -688,7 +688,7 @@ INPUT_PORTS_START( abc850 ) PORT_START("SW3") PORT_DIPNAME( 0x7f, 0x2c, "Card Address" ) PORT_DIPLOCATION("SW3:1,2,3,4,5,6,7") PORT_DIPSETTING( 0x2c, "44" ) - + PORT_START("S1") // also S3,S5 PORT_DIPNAME( 0x01, 0x01, "Interface Type" ) PORT_DIPSETTING( 0x00, "ABC 1600" ) @@ -1125,11 +1125,11 @@ WRITE8_MEMBER( luxor_55_21046_device::_8a_w ) if (BIT(data, 2)) { - m_fdc->set_unscaled_clock(XTAL_16MHz/16); + m_fdc->set_unscaled_clock(XTAL_16MHz/16); } else { - m_fdc->set_unscaled_clock(XTAL_16MHz/8); + m_fdc->set_unscaled_clock(XTAL_16MHz/8); } } diff --git a/src/emu/bus/abcbus/lux21056.c b/src/emu/bus/abcbus/lux21056.c index 7dc84668a36..279021a8750 100644 --- a/src/emu/bus/abcbus/lux21056.c +++ b/src/emu/bus/abcbus/lux21056.c @@ -30,12 +30,12 @@ $ mess abc800m -bus abc850 -flop1 ufd631 -hard ro202.chd $ mess abc800m -bus abc850 -bus:abc850:io2 xebec,bios=basf6186 -flop1 ufd631 -hard basf6186.chd - - or with the ABC 852 attached: + + or with the ABC 852 attached: $ mess abc800m -bus abc852 -flop1 ufd631 -hard basf6185.chd $ mess abc800m -bus abc852 -bus:abc852:io2 xebec,bios=nec5126 -flop1 ufd631 -hard nec5126.chd - + or with the ABC 856 attached: $ mess abc800m -bus abc856 -flop1 ufd631 -hard micr1325.chd @@ -59,12 +59,12 @@ Enter "DOSGEN,F HD0:" to start the formatting utility. Enter "J", and enter "J" to confirm the formatting. - If you have a 20MB image, format the second partition by entering "DOSGEN,F HD1:", "J", and "J". + If you have a 20MB image, format the second partition by entering "DOSGEN,F HD1:", "J", and "J". - If you have a 60MB image, format the third partition by entering "DOSGEN,F HD2:", "J", and "J", - and format the fourth partition by entering "DOSGEN,F HD3:", "J", and "J". + If you have a 60MB image, format the third partition by entering "DOSGEN,F HD2:", "J", and "J", + and format the fourth partition by entering "DOSGEN,F HD3:", "J", and "J". - You can now list your freshly created partitions by entering "LIB". + You can now list your freshly created partitions by entering "LIB". Or skip all of the above and use the preformatted images in the software list: diff --git a/src/emu/bus/adamnet/fdc.c b/src/emu/bus/adamnet/fdc.c index cb7b778e8aa..fe7bd49683b 100644 --- a/src/emu/bus/adamnet/fdc.c +++ b/src/emu/bus/adamnet/fdc.c @@ -10,12 +10,12 @@ **********************************************************************/ /* - - TODO: - - 320KB DSDD 5.25" - - 720KB DSDD 3.5" - - 1.44MB DSHD 3.5" + TODO: + + - 320KB DSDD 5.25" + - 720KB DSDD 3.5" + - 1.44MB DSHD 3.5" */ diff --git a/src/emu/bus/c64/pagefox.c b/src/emu/bus/c64/pagefox.c index 2edc58983c6..16c46f12742 100644 --- a/src/emu/bus/c64/pagefox.c +++ b/src/emu/bus/c64/pagefox.c @@ -67,7 +67,7 @@ void c64_pagefox_cartridge_device::device_start() { // allocate memory m_ram.allocate(0x8000); - + // state saving save_item(NAME(m_bank)); } diff --git a/src/emu/bus/pc_kbd/iskr1030.c b/src/emu/bus/pc_kbd/iskr1030.c index 021d76088ff..96dc8d2abe3 100644 --- a/src/emu/bus/pc_kbd/iskr1030.c +++ b/src/emu/bus/pc_kbd/iskr1030.c @@ -66,7 +66,7 @@ static ADDRESS_MAP_START( iskr_1030_keyboard_io, AS_IO, 8, iskr_1030_keyboard_de AM_RANGE(0x00, 0xFF) AM_RAM AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(p1_r, p1_w) AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(p2_w) -// AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(t0_r) +// AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(t0_r) AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(t1_r) ADDRESS_MAP_END @@ -358,7 +358,7 @@ WRITE_LINE_MEMBER( iskr_1030_keyboard_device::data_write ) READ8_MEMBER( iskr_1030_keyboard_device::t0_r ) { return 0; -// return clock_signal(); +// return clock_signal(); } diff --git a/src/emu/bus/plus4/std.h b/src/emu/bus/plus4/std.h index 127bf66aa2f..99d57227f42 100644 --- a/src/emu/bus/plus4/std.h +++ b/src/emu/bus/plus4/std.h @@ -40,7 +40,7 @@ protected: // device_plus4_expansion_card_interface overrides virtual UINT8 plus4_cd_r(address_space &space, offs_t offset, UINT8 data, int ba, int cs0, int c1l, int c2l, int cs1, int c1h, int c2h); - + }; diff --git a/src/emu/bus/vic10/std.h b/src/emu/bus/vic10/std.h index 2aa7e3574f7..ca5fc55f593 100644 --- a/src/emu/bus/vic10/std.h +++ b/src/emu/bus/vic10/std.h @@ -26,7 +26,7 @@ // ======================> vic10_standard_cartridge_device class vic10_standard_cartridge_device : public device_t, - public device_vic10_expansion_card_interface + public device_vic10_expansion_card_interface { public: // construction/destruction diff --git a/src/emu/cpu/8x300/8x300.c b/src/emu/cpu/8x300/8x300.c index 1d031be2d4a..dc43204beba 100644 --- a/src/emu/cpu/8x300/8x300.c +++ b/src/emu/cpu/8x300/8x300.c @@ -1,10 +1,10 @@ /* * 8x300.c * - * Implementation of the Scientific Micro Systems SMS300 / Signetics 8X300 CPU + * Implementation of the Scientific Micro Systems SMS300 / Signetics 8X300 CPU * Created on: 18/12/2013 * - * Written by Barry Rodewald + * Written by Barry Rodewald */ #include "debugger.h" @@ -56,7 +56,7 @@ void n8x300_cpu_device::set_reg(UINT8 reg, UINT8 val) case 0x05: m_R5 = val; break; case 0x06: m_R6 = val; break; case 0x07: m_IVL = val; break; -// OVF is read-only +// OVF is read-only case 0x09: m_R11 = val; break; case 0x0f: m_IVR = val; break; default: logerror("8X300: Invalid register %02x written to.\n",reg); break; @@ -74,10 +74,10 @@ UINT8 n8x300_cpu_device::get_reg(UINT8 reg) case 0x04: return m_R4; case 0x05: return m_R5; case 0x06: return m_R6; -// IVL is write-only +// IVL is write-only case 0x08: return m_OVF; case 0x09: return m_R11; -// IVR is write-only +// IVR is write-only default: logerror("8X300: Invalid register %02x read.\n",reg); return 0; } return 0; @@ -142,9 +142,9 @@ void n8x300_cpu_device::state_string_export(const device_state_entry &entry, ast { switch (entry.index()) { -// case STATE_GENFLAGS: -// string.printf("%c%c%c%c%c%c", -// break; +// case STATE_GENFLAGS: +// string.printf("%c%c%c%c%c%c", +// break; } } @@ -550,4 +550,3 @@ offs_t n8x300_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT extern CPU_DISASSEMBLE( n8x300 ); return CPU_DISASSEMBLE_NAME(n8x300)(this, buffer, pc, oprom, opram, options); } - diff --git a/src/emu/cpu/8x300/8x300.h b/src/emu/cpu/8x300/8x300.h index f05ec299551..fa0fbee4c51 100644 --- a/src/emu/cpu/8x300/8x300.h +++ b/src/emu/cpu/8x300/8x300.h @@ -1,7 +1,7 @@ /* * 8x300.h * - * Implementation of the Scientific Micro Systems SMS300 / Signetics 8X300 Microcontroller + * Implementation of the Scientific Micro Systems SMS300 / Signetics 8X300 Microcontroller * Created on: 18/12/2013 */ diff --git a/src/emu/cpu/8x300/8x300dasm.c b/src/emu/cpu/8x300/8x300dasm.c index 707b3ccdb6e..40533fccdd7 100644 --- a/src/emu/cpu/8x300/8x300dasm.c +++ b/src/emu/cpu/8x300/8x300dasm.c @@ -1,6 +1,6 @@ /* * 8x300dasm.c - * Implementation of the Scientific Micro Systems SMS300 / Signetics 8X300 Microcontroller + * Implementation of the Scientific Micro Systems SMS300 / Signetics 8X300 Microcontroller * * Created on: 18/12/2013 */ diff --git a/src/emu/cpu/cpu.mak b/src/emu/cpu/cpu.mak index d0d955c98c1..97bcf617ec8 100644 --- a/src/emu/cpu/cpu.mak +++ b/src/emu/cpu/cpu.mak @@ -77,7 +77,7 @@ CPUOBJS += $(CPUOBJ)/8x300/8x300.o DASMOBJS += $(CPUOBJ)/8x300/8x300dasm.o endif -$(CPUOBJ)/8x300/8x300.o: $(CPUSRC)/8x300/8x300.c \ +$(CPUOBJ)/8x300/8x300.o: $(CPUSRC)/8x300/8x300.c \ $(CPUSRC)/8x300/8x300.h #------------------------------------------------- diff --git a/src/emu/cpu/t11/t11.c b/src/emu/cpu/t11/t11.c index ab21aac98bf..6c859524803 100644 --- a/src/emu/cpu/t11/t11.c +++ b/src/emu/cpu/t11/t11.c @@ -41,7 +41,7 @@ const device_type T11 = &device_creator<t11_device>; t11_device::t11_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : cpu_device(mconfig, T11, "T11", tag, owner, clock, "t11", __FILE__) , m_program_config("program", ENDIANNESS_LITTLE, 16, 16, 0) - , c_initial_mode(0) + , c_initial_mode(0) { m_is_octal = true; } @@ -379,4 +379,3 @@ offs_t t11_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *opro extern CPU_DISASSEMBLE( t11 ); return CPU_DISASSEMBLE_NAME(t11)(this, buffer, pc, oprom, opram, options); } - diff --git a/src/emu/cpu/tms57002/tms57002.c b/src/emu/cpu/tms57002/tms57002.c index a9a7301003d..6dee543d118 100644 --- a/src/emu/cpu/tms57002/tms57002.c +++ b/src/emu/cpu/tms57002/tms57002.c @@ -682,7 +682,7 @@ int tms57002_device::decode_get_pc() for(;;) { short ipc; UINT32 opcode = program->read_dword(adr << 2); - + cs.inc = 0; if((opcode & 0xfc0000) == 0xfc0000) @@ -743,11 +743,11 @@ void tms57002_device::execute_run() case 1: ++ca; goto inst; - + case 2: ++id; goto inst; - + case 3: ++ca, ++id; goto inst; diff --git a/src/emu/cpu/z8/z8.c b/src/emu/cpu/z8/z8.c index 8bc4eb116dc..7a7602bb630 100644 --- a/src/emu/cpu/z8/z8.c +++ b/src/emu/cpu/z8/z8.c @@ -163,11 +163,11 @@ const device_type Z8611 = &device_creator<z8611_device>; ***************************************************************************/ static ADDRESS_MAP_START( program_2kb, AS_PROGRAM, 8, z8_device ) - AM_RANGE(0x0000, 0x07ff) AM_ROM + AM_RANGE(0x0000, 0x07ff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START( program_4kb, AS_PROGRAM, 8, z8_device ) - AM_RANGE(0x0000, 0x0fff) AM_ROM + AM_RANGE(0x0000, 0x0fff) AM_ROM ADDRESS_MAP_END @@ -846,4 +846,3 @@ void z8_device::execute_set_input(int inputnum, int state) } } - diff --git a/src/emu/diimage.c b/src/emu/diimage.c index ff1444d66b3..732d64b6023 100644 --- a/src/emu/diimage.c +++ b/src/emu/diimage.c @@ -442,7 +442,7 @@ const char *device_image_interface::get_feature(const char *feature_name) bool device_image_interface::load_software_region(const char *tag, optional_shared_ptr<UINT8> &ptr) { size_t size = get_software_region_length(tag); - + if (size) { ptr.allocate(size); diff --git a/src/emu/diserial.h b/src/emu/diserial.h index c31e2d8951e..52a9ad09317 100644 --- a/src/emu/diserial.h +++ b/src/emu/diserial.h @@ -37,7 +37,7 @@ public: { CTS = 0x0001, /* Clear to Send. (INPUT) Other end of connection is ready to accept data */ RTS = 0x0002, /* Request to Send. (OUTPUT) This end is ready to send data, and requests if the other */ - /* end is ready to accept it */ + /* end is ready to accept it */ DSR = 0x0004, /* Data Set ready. (INPUT) Other end of connection has data */ DTR = 0x0008, /* Data terminal Ready. (OUTPUT) TX contains new data. */ RX = 0x0010, /* Recieve data. (INPUT) */ @@ -159,7 +159,7 @@ private: class serial_source_device : public device_t, - public device_serial_interface + public device_serial_interface { public: // construction/destruction diff --git a/src/emu/machine/mc2661.c b/src/emu/machine/mc2661.c index 8bca28a21af..8232fc9fbe2 100644 --- a/src/emu/machine/mc2661.c +++ b/src/emu/machine/mc2661.c @@ -370,8 +370,8 @@ WRITE8_MEMBER( mc2661_device::write ) UINT32 tx_baud = baud_rates[data & 0x0f]; if(data & 0x10) // internal receiver clock { -// if((m_mr[0] & 0x03) != 0) -// rx_baud *= 16; +// if((m_mr[0] & 0x03) != 0) +// rx_baud *= 16; } else // external receiver clock { @@ -390,8 +390,8 @@ WRITE8_MEMBER( mc2661_device::write ) } if(data & 0x20) // internal transmitter clock { -// if((m_mr[0] & 0x03) != 0) -// tx_baud *= 16; +// if((m_mr[0] & 0x03) != 0) +// tx_baud *= 16; } else // external transmitter clock { diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c index e88e7b3e7df..0eb037f7324 100644 --- a/src/emu/machine/netlist.c +++ b/src/emu/machine/netlist.c @@ -63,7 +63,7 @@ const device_type NETLIST = &device_creator<netlist_mame_device>; netlist_mame_device::netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, NETLIST, "netlist", tag, owner, clock, "netlist_mame", __FILE__), device_execute_interface(mconfig, *this), - //device_state_interface(mconfig, *this), + //device_state_interface(mconfig, *this), m_device_start_list(100), m_netlist(NULL), m_setup(NULL), @@ -81,21 +81,21 @@ void netlist_mame_device::static_set_constructor(device_t &device, void (*setup_ void netlist_mame_device::device_config_complete() { - LOG_DEV_CALLS(("device_config_complete\n")); + LOG_DEV_CALLS(("device_config_complete\n")); } void netlist_mame_device::device_start() { - LOG_DEV_CALLS(("device_start\n")); + LOG_DEV_CALLS(("device_start\n")); m_netlist = global_alloc_clear(netlist_mame_t(*this)); m_setup = global_alloc_clear(netlist_setup_t(*m_netlist)); - m_netlist->init_object(*m_netlist, "netlist"); - m_setup->init(); + m_netlist->init_object(*m_netlist, "netlist"); + m_setup->init(); - m_netlist->set_clock_freq(this->clock()); + m_netlist->set_clock_freq(this->clock()); - // register additional devices + // register additional devices m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback"); @@ -104,12 +104,12 @@ void netlist_mame_device::device_start() m_setup->start_devices(); m_setup->resolve_inputs(); - bool allok = true; - for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods)) - allok &= ods->object()->OnDeviceStart(); + bool allok = true; + for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods)) + allok &= ods->object()->OnDeviceStart(); - if (!allok) - m_netlist->xfatalerror("required elements not found\n"); + if (!allok) + m_netlist->xfatalerror("required elements not found\n"); save_state(); @@ -119,13 +119,13 @@ void netlist_mame_device::device_start() void netlist_mame_device::device_reset() { - LOG_DEV_CALLS(("device_reset\n")); + LOG_DEV_CALLS(("device_reset\n")); m_netlist->reset(); } void netlist_mame_device::device_stop() { - LOG_DEV_CALLS(("device_stop\n")); + LOG_DEV_CALLS(("device_stop\n")); m_setup->print_stats(); global_free(m_setup); @@ -136,38 +136,38 @@ void netlist_mame_device::device_stop() ATTR_COLD void netlist_mame_device::device_post_load() { - LOG_DEV_CALLS(("device_post_load\n")); - m_netlist->queue().clear(); - NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize)); - for (int i = 0; i < qsize; i++ ) - { - netlist_net_t *n = m_netlist->find_net(qtemp[i].m_name); - NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n)); - NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double())); - m_netlist->queue().push(netlist_base_t::queue_t::entry_t(qtemp[i].m_time, *n)); - } + LOG_DEV_CALLS(("device_post_load\n")); + m_netlist->queue().clear(); + NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize)); + for (int i = 0; i < qsize; i++ ) + { + netlist_net_t *n = m_netlist->find_net(qtemp[i].m_name); + NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n)); + NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double())); + m_netlist->queue().push(netlist_base_t::queue_t::entry_t(qtemp[i].m_time, *n)); + } } ATTR_COLD void netlist_mame_device::device_pre_save() { - LOG_DEV_CALLS(("device_pre_save\n")); - - qsize = m_netlist->queue().count(); - NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize)); - for (int i = 0; i < qsize; i++ ) - { - qtemp[i].m_time = m_netlist->queue().listptr()[i].time(); - const char *p = m_netlist->queue().listptr()[i].object().name().cstr(); - int n = MIN(63, strlen(p)); - strncpy(qtemp[i].m_name, p, n); - qtemp[i].m_name[n] = 0; - } + LOG_DEV_CALLS(("device_pre_save\n")); + + qsize = m_netlist->queue().count(); + NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize)); + for (int i = 0; i < qsize; i++ ) + { + qtemp[i].m_time = m_netlist->queue().listptr()[i].time(); + const char *p = m_netlist->queue().listptr()[i].object().name().cstr(); + int n = MIN(63, strlen(p)); + strncpy(qtemp[i].m_name, p, n); + qtemp[i].m_name[n] = 0; + } #if 0 - netlist_time *nlt = (netlist_time *) ; - netlist_base_t::queue_t::entry_t *p = m_netlist->queue().listptr()[i]; - netlist_time *nlt = (netlist_time *) p->time_ptr(); - save_pointer(nlt->get_internaltype_ptr(), "queue", 1, i); + netlist_time *nlt = (netlist_time *) ; + netlist_base_t::queue_t::entry_t *p = m_netlist->queue().listptr()[i]; + netlist_time *nlt = (netlist_time *) p->time_ptr(); + save_pointer(nlt->get_internaltype_ptr(), "queue", 1, i); #endif } @@ -179,43 +179,43 @@ void netlist_mame_device::device_timer(emu_timer &timer, device_timer_id id, int ATTR_COLD void netlist_mame_device::save_state() { - for (pstate_entry_t::list_t::entry_t *p = m_netlist->save_list().first(); p != NULL; p = m_netlist->save_list().next(p)) - { - pstate_entry_t *s = p->object(); - NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr())); - switch (s->m_dt) - { - case DT_DOUBLE: - save_pointer((double *) s->m_ptr, s->m_name, s->m_count); - break; - case DT_INT64: - save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count); - break; - case DT_INT8: - save_pointer((INT8 *) s->m_ptr, s->m_name, s->m_count); - break; - case DT_INT: - save_pointer((int *) s->m_ptr, s->m_name, s->m_count); - break; - case DT_BOOLEAN: - save_pointer((bool *) s->m_ptr, s->m_name, s->m_count); - break; - case NOT_SUPPORTED: - default: - m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr()); - break; - } - } - - // handle the queue - - save_item(NAME(qsize)); - for (int i = 0; i < m_netlist->queue().capacity(); i++ ) - { - save_pointer(qtemp[i].m_time.get_internaltype_ptr(), "queue_time", 1, i); - save_pointer(qtemp[i].m_name, "queue_name", sizeof(qtemp[i].m_name), i); - - } + for (pstate_entry_t::list_t::entry_t *p = m_netlist->save_list().first(); p != NULL; p = m_netlist->save_list().next(p)) + { + pstate_entry_t *s = p->object(); + NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr())); + switch (s->m_dt) + { + case DT_DOUBLE: + save_pointer((double *) s->m_ptr, s->m_name, s->m_count); + break; + case DT_INT64: + save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count); + break; + case DT_INT8: + save_pointer((INT8 *) s->m_ptr, s->m_name, s->m_count); + break; + case DT_INT: + save_pointer((int *) s->m_ptr, s->m_name, s->m_count); + break; + case DT_BOOLEAN: + save_pointer((bool *) s->m_ptr, s->m_name, s->m_count); + break; + case NOT_SUPPORTED: + default: + m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr()); + break; + } + } + + // handle the queue + + save_item(NAME(qsize)); + for (int i = 0; i < m_netlist->queue().capacity(); i++ ) + { + save_pointer(qtemp[i].m_time.get_internaltype_ptr(), "queue_time", 1, i); + save_pointer(qtemp[i].m_name, "queue_name", sizeof(qtemp[i].m_name), i); + + } } ATTR_COLD UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const @@ -235,7 +235,7 @@ ATTR_HOT void netlist_mame_device::execute_run() // debugging //m_ppc = m_pc; // copy PC to previous PC if (check_debugger) - debugger_instruction_hook(this, 0); //m_pc); + debugger_instruction_hook(this, 0); //m_pc); m_netlist->process_queue(m_icount); } diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h index 1ad5588bb00..7ac6cb53b90 100644 --- a/src/emu/machine/netlist.h +++ b/src/emu/machine/netlist.h @@ -70,18 +70,18 @@ // ---------------------------------------------------------------------------------------- #define NETLIST_MEMREGION(_name) \ - netlist.parse((char *)downcast<netlist_mame_t &>(netlist.netlist()).machine().root_device().memregion(_name)->base()); + netlist.parse((char *)downcast<netlist_mame_t &>(netlist.netlist()).machine().root_device().memregion(_name)->base()); #define NETDEV_ANALOG_CALLBACK(_name, _IN, _class, _member, _tag) \ - { \ - NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>(netlist.register_dev(NET_NEW(analog_callback), # _name)); \ - netlist_analog_output_delegate d = netlist_analog_output_delegate(& _class :: _member, # _class "::" # _member, _tag, (_class *) 0); \ - dev->register_callback(d); \ - } \ - NET_CONNECT(_name, IN, _IN) + { \ + NETLIB_NAME(analog_callback) *dev = downcast<NETLIB_NAME(analog_callback) *>(netlist.register_dev(NET_NEW(analog_callback), # _name)); \ + netlist_analog_output_delegate d = netlist_analog_output_delegate(& _class :: _member, # _class "::" # _member, _tag, (_class *) 0); \ + dev->register_callback(d); \ + } \ + NET_CONNECT(_name, IN, _IN) #define NETDEV_ANALOG_CALLBACK_MEMBER(_name) \ - void _name(const double data, const attotime &time) + void _name(const double data, const attotime &time) class netlist_mame_device; @@ -89,26 +89,26 @@ class netlist_mame_t : public netlist_base_t { public: - netlist_mame_t(netlist_mame_device &parent) - : netlist_base_t(), - m_parent(parent) - {} - virtual ~netlist_mame_t() { }; + netlist_mame_t(netlist_mame_device &parent) + : netlist_base_t(), + m_parent(parent) + {} + virtual ~netlist_mame_t() { }; - inline running_machine &machine(); + inline running_machine &machine(); - netlist_mame_device &parent() { return m_parent; } + netlist_mame_device &parent() { return m_parent; } protected: - void vfatalerror(const char *format, va_list ap) const - { - emu_fatalerror error(format, ap); - throw error; - } + void vfatalerror(const char *format, va_list ap) const + { + emu_fatalerror error(format, ap); + throw error; + } private: - netlist_mame_device &m_parent; + netlist_mame_device &m_parent; }; // ---------------------------------------------------------------------------------------- @@ -121,21 +121,21 @@ private: // ======================> netlist_mame_device class netlist_mame_device : public device_t, - public device_execute_interface - //public device_state_interface - //, public device_memory_interface + public device_execute_interface + //public device_state_interface + //, public device_memory_interface { public: template<bool _Required, class _NETClass> class output_finder; - template<class C> + template<class C> class optional_output; template<class C> class required_output; - template<class C> + template<class C> class optional_param; - template<class C> + template<class C> class required_param; class on_device_start; @@ -159,7 +159,7 @@ protected: virtual void device_stop(); virtual void device_reset(); virtual void device_post_load(); - virtual void device_pre_save(); + virtual void device_pre_save(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); virtual UINT64 execute_clocks_to_cycles(UINT64 clocks) const; virtual UINT64 execute_cycles_to_clocks(UINT64 cycles) const; @@ -173,8 +173,8 @@ protected: // more save state ... needs to go somewhere else struct qentry { - netlist_time m_time; - char m_name[64]; + netlist_time m_time; + char m_name[64]; }; qentry qtemp[1024]; @@ -193,7 +193,7 @@ private: inline running_machine &netlist_mame_t::machine() { - return m_parent.machine(); + return m_parent.machine(); } // ---------------------------------------------------------------------------------------- @@ -205,75 +205,75 @@ typedef device_delegate<void (const double, const attotime &)> netlist_analog_ou class NETLIB_NAME(analog_callback) : public netlist_device_t { public: - NETLIB_NAME(analog_callback)() - : netlist_device_t() { } - - ATTR_COLD void start() - { - register_input("IN", m_in); - m_callback.bind_relative_to(downcast<netlist_mame_t &>(netlist()).machine().root_device()); - } - - ATTR_COLD void register_callback(netlist_analog_output_delegate callback) - { - m_callback = callback; - } - - ATTR_HOT void update() - { - // FIXME: Remove after device cleanup - if (!m_callback.isnull()) - m_callback(INPANALOG(m_in), downcast<netlist_mame_t &>(netlist()).parent().local_time()); - } + NETLIB_NAME(analog_callback)() + : netlist_device_t() { } + + ATTR_COLD void start() + { + register_input("IN", m_in); + m_callback.bind_relative_to(downcast<netlist_mame_t &>(netlist()).machine().root_device()); + } + + ATTR_COLD void register_callback(netlist_analog_output_delegate callback) + { + m_callback = callback; + } + + ATTR_HOT void update() + { + // FIXME: Remove after device cleanup + if (!m_callback.isnull()) + m_callback(INPANALOG(m_in), downcast<netlist_mame_t &>(netlist()).parent().local_time()); + } private: - netlist_analog_input_t m_in; - netlist_analog_output_delegate m_callback; + netlist_analog_input_t m_in; + netlist_analog_output_delegate m_callback; }; class NETLIB_NAME(sound) : public netlist_device_t { public: - NETLIB_NAME(sound)() - : netlist_device_t() { } - - static const int BUFSIZE = 2048; - - ATTR_COLD void start() - { - register_input("IN", m_in); - m_cur = 0; - m_last_pos = 0; - m_last_buffer = netlist_time::zero; - m_sample = netlist_time::zero; // FIXME: divide by zero - } - - ATTR_HOT void sound_update() - { - netlist_time current = netlist().time(); - int pos = (current - m_last_buffer) / m_sample; - if (pos >= BUFSIZE) - netlist().xfatalerror("sound %s: exceeded BUFSIZE\n", name().cstr()); - while (m_last_pos < pos ) - { - m_buffer[m_last_pos++] = m_cur; - } - } - - ATTR_HOT void update() - { - double val = INPANALOG(m_in); - sound_update(); - m_cur = val; - } + NETLIB_NAME(sound)() + : netlist_device_t() { } + + static const int BUFSIZE = 2048; + + ATTR_COLD void start() + { + register_input("IN", m_in); + m_cur = 0; + m_last_pos = 0; + m_last_buffer = netlist_time::zero; + m_sample = netlist_time::zero; // FIXME: divide by zero + } + + ATTR_HOT void sound_update() + { + netlist_time current = netlist().time(); + int pos = (current - m_last_buffer) / m_sample; + if (pos >= BUFSIZE) + netlist().xfatalerror("sound %s: exceeded BUFSIZE\n", name().cstr()); + while (m_last_pos < pos ) + { + m_buffer[m_last_pos++] = m_cur; + } + } + + ATTR_HOT void update() + { + double val = INPANALOG(m_in); + sound_update(); + m_cur = val; + } private: - netlist_analog_input_t m_in; - netlist_time m_sample; - double m_cur; - int m_last_pos; - netlist_time m_last_buffer; - stream_sample_t m_buffer[BUFSIZE]; + netlist_analog_input_t m_in; + netlist_time m_sample; + double m_cur; + int m_last_pos; + netlist_time m_last_buffer; + stream_sample_t m_buffer[BUFSIZE]; }; diff --git a/src/emu/machine/nscsi_cb.c b/src/emu/machine/nscsi_cb.c index 35d7e873d5f..bd828cac1e4 100644 --- a/src/emu/machine/nscsi_cb.c +++ b/src/emu/machine/nscsi_cb.c @@ -4,15 +4,15 @@ const device_type NSCSI_CB = &device_creator<nscsi_callback_device>; nscsi_callback_device::nscsi_callback_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : nscsi_device(mconfig, NSCSI_CB, "SCSI callback (new)", tag, owner, clock, "nscsi_cb", __FILE__), - m_write_rst(*this), - m_write_atn(*this), - m_write_ack(*this), - m_write_req(*this), - m_write_msg(*this), - m_write_io(*this), - m_write_cd(*this), - m_write_sel(*this), - m_write_bsy(*this) + m_write_rst(*this), + m_write_atn(*this), + m_write_ack(*this), + m_write_req(*this), + m_write_msg(*this), + m_write_io(*this), + m_write_cd(*this), + m_write_sel(*this), + m_write_bsy(*this) { } diff --git a/src/emu/machine/nscsi_s1410.c b/src/emu/machine/nscsi_s1410.c index e38fc7135ed..d3f3defd95e 100644 --- a/src/emu/machine/nscsi_s1410.c +++ b/src/emu/machine/nscsi_s1410.c @@ -10,7 +10,7 @@ nscsi_s1410_device::nscsi_s1410_device(const machine_config &mconfig, const char void nscsi_s1410_device::device_reset() { nscsi_harddisk_device::device_reset(); - + // initialize drive characteristics params[0] = 0; params[1] = 153; @@ -44,7 +44,7 @@ void nscsi_s1410_device::scsi_command() scsi_status_complete(SS_NOT_READY); return; } - + scsi_status_complete(SS_GOOD); break; @@ -56,7 +56,7 @@ void nscsi_s1410_device::scsi_command() lba = ((scsi_cmdbuf[1] & 0x1f)<<16) | (scsi_cmdbuf[2]<<8) | scsi_cmdbuf[3]; blocks = (bytes_per_sector == 256) ? 32 : 17; - + int track_length = blocks*bytes_per_sector; UINT8 *data = global_alloc_array(UINT8,track_length); memset(data, 0xc6, track_length); @@ -76,7 +76,7 @@ void nscsi_s1410_device::scsi_command() scsi_status_complete(SS_NOT_READY); return; } - + scsi_data_in(2, 3); scsi_status_complete(SS_GOOD); break; @@ -103,7 +103,7 @@ void nscsi_s1410_device::scsi_command() } scsi_status_complete(SS_GOOD); break; - + case SC_READ_ECC_BURST: case SC_RAM_DIAG: case SC_DRIVE_DIAG: @@ -135,7 +135,7 @@ void nscsi_s1410_device::scsi_put_data(int id, int pos, UINT8 data) switch(scsi_cmdbuf[0]) { case SC_FORMAT_ALT_TRACK: break; - + case SC_INIT_DRIVE_PARAMS: params[pos] = data; break; diff --git a/src/emu/machine/nscsi_s1410.h b/src/emu/machine/nscsi_s1410.h index 7409b6c6f0b..0af6963950d 100644 --- a/src/emu/machine/nscsi_s1410.h +++ b/src/emu/machine/nscsi_s1410.h @@ -12,42 +12,42 @@ public: protected: // SCSI status returns enum { - SS_GOOD = 0x00, - SS_NO_INDEX = 0x01, - SS_NO_SEEK_COMPLETE = 0x02, - SS_WRITE_FAULT = 0x03, - SS_NOT_READY = 0x04, - SS_TK00_NOT_FOUND = 0x06, - SS_SEEK_IN_PROGRESS = 0x08, - SS_ID_FIELD_ERROR = 0x10, - SS_DATA_ERROR = 0x11, - SS_SAM_NOT_FOUND = 0x12, - SS_SECTOR_NOT_FOUND = 0x14, - SS_SEEK_ERROR = 0x15, - SS_ECC = 0x18, - SS_BAD_TRACK = 0x19, - SS_FORMAT_ERROR = 0x1a, - SS_ALT_TRACK = 0x1c, - SS_ALT_TRACK_DEFECT = 0x1d, + SS_GOOD = 0x00, + SS_NO_INDEX = 0x01, + SS_NO_SEEK_COMPLETE = 0x02, + SS_WRITE_FAULT = 0x03, + SS_NOT_READY = 0x04, + SS_TK00_NOT_FOUND = 0x06, + SS_SEEK_IN_PROGRESS = 0x08, + SS_ID_FIELD_ERROR = 0x10, + SS_DATA_ERROR = 0x11, + SS_SAM_NOT_FOUND = 0x12, + SS_SECTOR_NOT_FOUND = 0x14, + SS_SEEK_ERROR = 0x15, + SS_ECC = 0x18, + SS_BAD_TRACK = 0x19, + SS_FORMAT_ERROR = 0x1a, + SS_ALT_TRACK = 0x1c, + SS_ALT_TRACK_DEFECT = 0x1d, SS_ALT_TRACK_NOT_FOUND = 0x1e, SS_ALT_TRACK_SAME = 0x1f, - SS_RAM_ERROR = 0x30, - SS_ROM_ERROR = 0x31, - SS_ECC_CHECK_FAILURE = 0x32 + SS_RAM_ERROR = 0x30, + SS_ROM_ERROR = 0x31, + SS_ECC_CHECK_FAILURE = 0x32 }; // SCSI commands enum { - SC_TEST_UNIT_READY = 0x00, - SC_REZERO = 0x01, - SC_REQUEST_SENSE = 0x03, - SC_FORMAT_UNIT = 0x04, - SC_CHECK_TRACK_FORMAT = 0x05, - SC_FORMAT_TRACK = 0x06, - SC_REASSIGN_BLOCKS = 0x07, - SC_READ = 0x08, - SC_WRITE = 0x0a, - SC_SEEK = 0x0b, + SC_TEST_UNIT_READY = 0x00, + SC_REZERO = 0x01, + SC_REQUEST_SENSE = 0x03, + SC_FORMAT_UNIT = 0x04, + SC_CHECK_TRACK_FORMAT = 0x05, + SC_FORMAT_TRACK = 0x06, + SC_REASSIGN_BLOCKS = 0x07, + SC_READ = 0x08, + SC_WRITE = 0x0a, + SC_SEEK = 0x0b, SC_INIT_DRIVE_PARAMS = 0x0c, SC_READ_ECC_BURST = 0x0d, SC_FORMAT_ALT_TRACK = 0x0e, diff --git a/src/emu/machine/t10mmc.c b/src/emu/machine/t10mmc.c index 84ff5f72667..aee65ffb5ce 100644 --- a/src/emu/machine/t10mmc.c +++ b/src/emu/machine/t10mmc.c @@ -550,10 +550,10 @@ void t10mmc::ReadData( UINT8 *data, int dataLength ) case T10MMC_CMD_READ_TOC_PMA_ATIP: /* - Track numbers are problematic here: 0 = lead-in, 0xaa = lead-out. - That makes sense in terms of how real-world CDs are referred to, but - our internal routines for tracks use "0" as track 1. That probably - should be fixed... + Track numbers are problematic here: 0 = lead-in, 0xaa = lead-out. + That makes sense in terms of how real-world CDs are referred to, but + our internal routines for tracks use "0" as track 1. That probably + should be fixed... */ { bool msf = (command[1] & 0x2) != 0; diff --git a/src/emu/machine/t10sbc.c b/src/emu/machine/t10sbc.c index 59e421ca16b..204046e39d6 100644 --- a/src/emu/machine/t10sbc.c +++ b/src/emu/machine/t10sbc.c @@ -42,9 +42,9 @@ void t10sbc::ExecCommand() case T10SBC_CMD_SEEK_6: m_lba = (command[1]&0x1f)<<16 | command[2]<<8 | command[3]; - + logerror("S1410: SEEK to LBA %x\n", m_lba); - + m_phase = SCSI_PHASE_STATUS; m_transfer_length = 0; break; diff --git a/src/emu/machine/tmp68301.c b/src/emu/machine/tmp68301.c index 1065c8b01bd..134578c2678 100644 --- a/src/emu/machine/tmp68301.c +++ b/src/emu/machine/tmp68301.c @@ -6,11 +6,11 @@ 3 timers, address decoder, wait generator, interrupt controller, all integrated in a single chip. - TODO: - - Interrupt generation: handle pending / in-service mechanisms - - Parallel port: handle timing latency - - Serial port: not done at all - - (and many other things) + TODO: + - Interrupt generation: handle pending / in-service mechanisms + - Parallel port: handle timing latency + - Serial port: not done at all + - (and many other things) ***************************************************************************/ @@ -20,7 +20,7 @@ const device_type TMP68301 = &device_creator<tmp68301_device>; static ADDRESS_MAP_START( tmp68301_regs, AS_0, 16, tmp68301_device ) -// AM_RANGE(0x000,0x3ff) AM_RAM +// AM_RANGE(0x000,0x3ff) AM_RAM AM_RANGE(0x094,0x095) AM_READWRITE(imr_r,imr_w) AM_RANGE(0x098,0x099) AM_READWRITE(iisr_r,iisr_w) @@ -63,9 +63,9 @@ READ16_MEMBER(tmp68301_device::scr_r) WRITE16_MEMBER(tmp68301_device::scr_w) { /* - *--- ---- CKSE - --*- ---- RES - ---- ---* INTM + *--- ---- CKSE + --*- ---- RES + ---- ---* INTM */ COMBINE_DATA(&m_scr); diff --git a/src/emu/machine/tmp68301.h b/src/emu/machine/tmp68301.h index 5ed7aab2d0d..31811342f42 100644 --- a/src/emu/machine/tmp68301.h +++ b/src/emu/machine/tmp68301.h @@ -29,7 +29,7 @@ struct tmp68301_interface { devcb_read16 m_in_parallel_cb; devcb_write16 m_out_parallel_cb; -// TODO: serial ports +// TODO: serial ports }; class tmp68301_device : public device_t, diff --git a/src/emu/machine/upd4992.c b/src/emu/machine/upd4992.c index 95a2db0e01c..7a56bb678a3 100644 --- a/src/emu/machine/upd4992.c +++ b/src/emu/machine/upd4992.c @@ -2,13 +2,13 @@ // copyright-holders: Angelo Salese /*************************************************************************** - uPD4992 parallel RTC + uPD4992 parallel RTC - TODO: - - Add timers - - Add leap year count - - Add 12 hours mode - - Add mode/control register + TODO: + - Add timers + - Add leap year count + - Add 12 hours mode + - Add mode/control register ***************************************************************************/ @@ -35,7 +35,7 @@ const device_type UPD4992 = &device_creator<upd4992_device>; upd4992_device::upd4992_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, UPD4992, "uPD4992", tag, owner, clock, "upd4992", __FILE__), - device_rtc_interface(mconfig, *this) + device_rtc_interface(mconfig, *this) { } diff --git a/src/emu/machine/upd4992.h b/src/emu/machine/upd4992.h index b94f0fee763..17feb7a942a 100644 --- a/src/emu/machine/upd4992.h +++ b/src/emu/machine/upd4992.h @@ -2,7 +2,7 @@ // copyright-holders: Angelo Salese /*************************************************************************** - uPD4992 RTC + uPD4992 RTC ***************************************************************************/ @@ -27,7 +27,7 @@ // ======================> upd4992_device class upd4992_device : public device_t, - public device_rtc_interface + public device_rtc_interface { public: // construction/destruction diff --git a/src/emu/machine/z80dart.c b/src/emu/machine/z80dart.c index f770e6b7c30..1e7da115a54 100644 --- a/src/emu/machine/z80dart.c +++ b/src/emu/machine/z80dart.c @@ -1227,7 +1227,7 @@ WRITE_LINE_MEMBER( z80dart_channel::rxc_w ) m_rx_clock++; if (m_rx_clock == clocks) m_rx_clock = 0; - + } } @@ -1249,7 +1249,7 @@ WRITE_LINE_MEMBER( z80dart_channel::txc_w ) m_tx_clock++; if (m_tx_clock == clocks) m_tx_clock = 0; - + } } @@ -1339,4 +1339,3 @@ WRITE_LINE_MEMBER(z80dart_channel::write_rx) input_callback(m_input_state & ~RX); } } - diff --git a/src/emu/machine/z80dma.c b/src/emu/machine/z80dma.c index df0803ad196..846ea1ce794 100644 --- a/src/emu/machine/z80dma.c +++ b/src/emu/machine/z80dma.c @@ -123,7 +123,7 @@ const int TM_SEARCH_TRANSFER = 0x03; #define EOB_F_CLEAR (m_status |= 0x20) #define READY_ACTIVE_HIGH ((WR5>>3) & 0x01) -#define AUTO_RESTART ((WR5>>5) & 0x01) +#define AUTO_RESTART ((WR5>>5) & 0x01) #define INTERRUPT_ENABLE (WR3 & 0x20) #define INT_ON_MATCH (INTERRUPT_CTRL & 0x01) diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index 81a375bfd27..fdb376d6340 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -53,164 +53,164 @@ NETLIB_START(nic7448) { - register_sub(sub, "sub"); - - register_subalias("A0", sub.m_A0); - register_subalias("A1", sub.m_A1); - register_subalias("A2", sub.m_A2); - register_subalias("A3", sub.m_A3); - register_input("LTQ", m_LTQ); - register_input("BIQ", m_BIQ); - register_subalias("RBIQ",sub.m_RBIQ); - - register_subalias("a", sub.m_a); - register_subalias("b", sub.m_b); - register_subalias("c", sub.m_c); - register_subalias("d", sub.m_d); - register_subalias("e", sub.m_e); - register_subalias("f", sub.m_f); - register_subalias("g", sub.m_g); + register_sub(sub, "sub"); + + register_subalias("A0", sub.m_A0); + register_subalias("A1", sub.m_A1); + register_subalias("A2", sub.m_A2); + register_subalias("A3", sub.m_A3); + register_input("LTQ", m_LTQ); + register_input("BIQ", m_BIQ); + register_subalias("RBIQ",sub.m_RBIQ); + + register_subalias("a", sub.m_a); + register_subalias("b", sub.m_b); + register_subalias("c", sub.m_c); + register_subalias("d", sub.m_d); + register_subalias("e", sub.m_e); + register_subalias("f", sub.m_f); + register_subalias("g", sub.m_g); } NETLIB_UPDATE(nic7448) { - if (INPLOGIC(m_BIQ) && !INPLOGIC(m_LTQ)) - { - sub.update_outputs(8); - } - else if (!INPLOGIC(m_BIQ)) - { - sub.update_outputs(15); - } - - if (!INPLOGIC(m_BIQ) || (INPLOGIC(m_BIQ) && !INPLOGIC(m_LTQ))) - { - sub.m_A0.inactivate(); - sub.m_A1.inactivate(); - sub.m_A2.inactivate(); - sub.m_A3.inactivate(); - sub.m_RBIQ.inactivate(); - } else { - sub.m_RBIQ.activate(); - sub.m_A3.activate(); - sub.m_A2.activate(); - sub.m_A1.activate(); - sub.m_A0.activate(); - sub.update(); - } + if (INPLOGIC(m_BIQ) && !INPLOGIC(m_LTQ)) + { + sub.update_outputs(8); + } + else if (!INPLOGIC(m_BIQ)) + { + sub.update_outputs(15); + } + + if (!INPLOGIC(m_BIQ) || (INPLOGIC(m_BIQ) && !INPLOGIC(m_LTQ))) + { + sub.m_A0.inactivate(); + sub.m_A1.inactivate(); + sub.m_A2.inactivate(); + sub.m_A3.inactivate(); + sub.m_RBIQ.inactivate(); + } else { + sub.m_RBIQ.activate(); + sub.m_A3.activate(); + sub.m_A2.activate(); + sub.m_A1.activate(); + sub.m_A0.activate(); + sub.update(); + } } NETLIB_START(nic7448_sub) { - m_state = 0; - - register_input("A0", m_A0); - register_input("A1", m_A1); - register_input("A2", m_A2); - register_input("A3", m_A3); - register_input("RBIQ", m_RBIQ); - - register_output("a", m_a); - register_output("b", m_b); - register_output("c", m_c); - register_output("d", m_d); - register_output("e", m_e); - register_output("f", m_f); - register_output("g", m_g); - - save(NAME(m_state)); + m_state = 0; + + register_input("A0", m_A0); + register_input("A1", m_A1); + register_input("A2", m_A2); + register_input("A3", m_A3); + register_input("RBIQ", m_RBIQ); + + register_output("a", m_a); + register_output("b", m_b); + register_output("c", m_c); + register_output("d", m_d); + register_output("e", m_e); + register_output("f", m_f); + register_output("g", m_g); + + save(NAME(m_state)); } NETLIB_UPDATE(nic7448_sub) { - UINT8 v; + UINT8 v; - v = (INPLOGIC(m_A0) << 0) | (INPLOGIC(m_A1) << 1) | (INPLOGIC(m_A2) << 2) | (INPLOGIC(m_A3) << 3); - if ((!INPLOGIC(m_RBIQ) && (v==0))) - v = 15; - update_outputs(v); + v = (INPLOGIC(m_A0) << 0) | (INPLOGIC(m_A1) << 1) | (INPLOGIC(m_A2) << 2) | (INPLOGIC(m_A3) << 3); + if ((!INPLOGIC(m_RBIQ) && (v==0))) + v = 15; + update_outputs(v); } NETLIB_FUNC_VOID(nic7448_sub, update_outputs, (UINT8 v)) { - assert(v<16); - if (v != m_state) - { - OUTLOGIC(m_a, tab7448[v][0], NLTIME_FROM_NS(100)); - OUTLOGIC(m_b, tab7448[v][1], NLTIME_FROM_NS(100)); - OUTLOGIC(m_c, tab7448[v][2], NLTIME_FROM_NS(100)); - OUTLOGIC(m_d, tab7448[v][3], NLTIME_FROM_NS(100)); - OUTLOGIC(m_e, tab7448[v][4], NLTIME_FROM_NS(100)); - OUTLOGIC(m_f, tab7448[v][5], NLTIME_FROM_NS(100)); - OUTLOGIC(m_g, tab7448[v][6], NLTIME_FROM_NS(100)); - m_state = v; - } + assert(v<16); + if (v != m_state) + { + OUTLOGIC(m_a, tab7448[v][0], NLTIME_FROM_NS(100)); + OUTLOGIC(m_b, tab7448[v][1], NLTIME_FROM_NS(100)); + OUTLOGIC(m_c, tab7448[v][2], NLTIME_FROM_NS(100)); + OUTLOGIC(m_d, tab7448[v][3], NLTIME_FROM_NS(100)); + OUTLOGIC(m_e, tab7448[v][4], NLTIME_FROM_NS(100)); + OUTLOGIC(m_f, tab7448[v][5], NLTIME_FROM_NS(100)); + OUTLOGIC(m_g, tab7448[v][6], NLTIME_FROM_NS(100)); + m_state = v; + } } const UINT8 NETLIB_NAME(nic7448_sub)::tab7448[16][7] = { - { 1, 1, 1, 1, 1, 1, 0 }, /* 00 - not blanked ! */ - { 0, 1, 1, 0, 0, 0, 0 }, /* 01 */ - { 1, 1, 0, 1, 1, 0, 1 }, /* 02 */ - { 1, 1, 1, 1, 0, 0, 1 }, /* 03 */ - { 0, 1, 1, 0, 0, 1, 1 }, /* 04 */ - { 1, 0, 1, 1, 0, 1, 1 }, /* 05 */ - { 0, 0, 1, 1, 1, 1, 1 }, /* 06 */ - { 1, 1, 1, 0, 0, 0, 0 }, /* 07 */ - { 1, 1, 1, 1, 1, 1, 1 }, /* 08 */ - { 1, 1, 1, 0, 0, 1, 1 }, /* 09 */ - { 0, 0, 0, 1, 1, 0, 1 }, /* 10 */ - { 0, 0, 1, 1, 0, 0, 1 }, /* 11 */ - { 0, 1, 0, 0, 0, 1, 1 }, /* 12 */ - { 1, 0, 0, 1, 0, 1, 1 }, /* 13 */ - { 0, 0, 0, 1, 1, 1, 1 }, /* 14 */ - { 0, 0, 0, 0, 0, 0, 0 }, /* 15 */ + { 1, 1, 1, 1, 1, 1, 0 }, /* 00 - not blanked ! */ + { 0, 1, 1, 0, 0, 0, 0 }, /* 01 */ + { 1, 1, 0, 1, 1, 0, 1 }, /* 02 */ + { 1, 1, 1, 1, 0, 0, 1 }, /* 03 */ + { 0, 1, 1, 0, 0, 1, 1 }, /* 04 */ + { 1, 0, 1, 1, 0, 1, 1 }, /* 05 */ + { 0, 0, 1, 1, 1, 1, 1 }, /* 06 */ + { 1, 1, 1, 0, 0, 0, 0 }, /* 07 */ + { 1, 1, 1, 1, 1, 1, 1 }, /* 08 */ + { 1, 1, 1, 0, 0, 1, 1 }, /* 09 */ + { 0, 0, 0, 1, 1, 0, 1 }, /* 10 */ + { 0, 0, 1, 1, 0, 0, 1 }, /* 11 */ + { 0, 1, 0, 0, 0, 1, 1 }, /* 12 */ + { 1, 0, 0, 1, 0, 1, 1 }, /* 13 */ + { 0, 0, 0, 1, 1, 1, 1 }, /* 14 */ + { 0, 0, 0, 0, 0, 0, 0 }, /* 15 */ }; NETLIB_START(nic7450) { - register_input("I1", m_I0); - register_input("I2", m_I1); - register_input("I3", m_I2); - register_input("I4", m_I3); - register_output("Q", m_Q); + register_input("I1", m_I0); + register_input("I2", m_I1); + register_input("I3", m_I2); + register_input("I4", m_I3); + register_output("Q", m_Q); } NETLIB_UPDATE(nic7450) { - m_I0.activate(); - m_I1.activate(); - m_I2.activate(); - m_I3.activate(); - UINT8 t1 = INPLOGIC(m_I0) & INPLOGIC(m_I1); - UINT8 t2 = INPLOGIC(m_I2) & INPLOGIC(m_I3); + m_I0.activate(); + m_I1.activate(); + m_I2.activate(); + m_I3.activate(); + UINT8 t1 = INPLOGIC(m_I0) & INPLOGIC(m_I1); + UINT8 t2 = INPLOGIC(m_I2) & INPLOGIC(m_I3); #if 0 - UINT8 t = (t1 | t2) ^ 1; - OUTLOGIC(m_Q, t, t ? NLTIME_FROM_NS(22) : NLTIME_FROM_NS(15)); + UINT8 t = (t1 | t2) ^ 1; + OUTLOGIC(m_Q, t, t ? NLTIME_FROM_NS(22) : NLTIME_FROM_NS(15)); #else - const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) }; - - UINT8 res = 0; - if (t1 ^ 1) - { - if (t2 ^ 1) - { - res = 1; - } - else - { - m_I0.inactivate(); - m_I1.inactivate(); - } - } else { - if (t2 ^ 1) - { - m_I2.inactivate(); - m_I3.inactivate(); - } - } - OUTLOGIC(m_Q, res, times[1 - res]);// ? 22000 : 15000); + const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) }; + + UINT8 res = 0; + if (t1 ^ 1) + { + if (t2 ^ 1) + { + res = 1; + } + else + { + m_I0.inactivate(); + m_I1.inactivate(); + } + } else { + if (t2 ^ 1) + { + m_I2.inactivate(); + m_I3.inactivate(); + } + } + OUTLOGIC(m_Q, res, times[1 - res]);// ? 22000 : 15000); #endif } @@ -221,122 +221,122 @@ NETLIB_UPDATE(nic7450) NETLIB_START(nic74107Asub) { - register_input("CLK", m_clk, netlist_input_t::STATE_INP_HL); - register_output("Q", m_Q); - register_output("QQ", m_QQ); + register_input("CLK", m_clk, netlist_input_t::STATE_INP_HL); + register_output("Q", m_Q); + register_output("QQ", m_QQ); - m_Q.initial(0); - m_QQ.initial(1); + m_Q.initial(0); + m_QQ.initial(1); - save(NAME(m_Q1)); - save(NAME(m_Q2)); - save(NAME(m_F)); + save(NAME(m_Q1)); + save(NAME(m_Q2)); + save(NAME(m_F)); } NETLIB_START(nic74107A) { - register_sub(sub, "sub"); + register_sub(sub, "sub"); - register_subalias("CLK", sub.m_clk); - register_input("J", m_J); - register_input("K", m_K); - register_input("CLRQ", m_clrQ); - register_subalias("Q", sub.m_Q); - register_subalias("QQ", sub.m_QQ); + register_subalias("CLK", sub.m_clk); + register_input("J", m_J); + register_input("K", m_K); + register_input("CLRQ", m_clrQ); + register_subalias("Q", sub.m_Q); + register_subalias("QQ", sub.m_QQ); - sub.m_Q.initial(0); - sub.m_QQ.initial(1); + sub.m_Q.initial(0); + sub.m_QQ.initial(1); } ATTR_HOT inline void NETLIB_NAME(nic74107Asub)::newstate(const netlist_sig_t state) { - const netlist_time delay[2] = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) }; + const netlist_time delay[2] = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) }; #if 1 - OUTLOGIC(m_Q, state, delay[state ^ 1]); - OUTLOGIC(m_QQ, state ^ 1, delay[state]); + OUTLOGIC(m_Q, state, delay[state ^ 1]); + OUTLOGIC(m_QQ, state ^ 1, delay[state]); #else - if (state != Q.new_Q()) - { - Q.setToNoCheck(state, delay[1-state]); - QQ.setToNoCheck(1-state, delay[state]); - } + if (state != Q.new_Q()) + { + Q.setToNoCheck(state, delay[1-state]); + QQ.setToNoCheck(1-state, delay[state]); + } #endif } NETLIB_UPDATE(nic74107Asub) { - { - const netlist_sig_t t = m_Q.net().new_Q(); - newstate((!t & m_Q1) | (t & m_Q2) | m_F); - if (!m_Q1) - m_clk.inactivate(); - } + { + const netlist_sig_t t = m_Q.net().new_Q(); + newstate((!t & m_Q1) | (t & m_Q2) | m_F); + if (!m_Q1) + m_clk.inactivate(); + } } NETLIB_UPDATE(nic74107A) { - if (INPLOGIC(m_J) & INPLOGIC(m_K)) - { - sub.m_Q1 = 1; - sub.m_Q2 = 0; - sub.m_F = 0; - } - else if (!INPLOGIC(m_J) & INPLOGIC(m_K)) - { - sub.m_Q1 = 0; - sub.m_Q2 = 0; - sub.m_F = 0; - } - else if (INPLOGIC(m_J) & !INPLOGIC(m_K)) - { - sub.m_Q1 = 0; - sub.m_Q2 = 0; - sub.m_F = 1; - } - else - { - sub.m_Q1 = 0; - sub.m_Q2 = 1; - sub.m_F = 0; - sub.m_clk.inactivate(); - } - if (!INPLOGIC(m_clrQ)) - { - sub.m_clk.inactivate(); - sub.newstate(0); - } - else if (!sub.m_Q2) - sub.m_clk.activate_hl(); - //if (!sub.m_Q2 & INPLOGIC(m_clrQ)) - // sub.m_clk.activate_hl(); + if (INPLOGIC(m_J) & INPLOGIC(m_K)) + { + sub.m_Q1 = 1; + sub.m_Q2 = 0; + sub.m_F = 0; + } + else if (!INPLOGIC(m_J) & INPLOGIC(m_K)) + { + sub.m_Q1 = 0; + sub.m_Q2 = 0; + sub.m_F = 0; + } + else if (INPLOGIC(m_J) & !INPLOGIC(m_K)) + { + sub.m_Q1 = 0; + sub.m_Q2 = 0; + sub.m_F = 1; + } + else + { + sub.m_Q1 = 0; + sub.m_Q2 = 1; + sub.m_F = 0; + sub.m_clk.inactivate(); + } + if (!INPLOGIC(m_clrQ)) + { + sub.m_clk.inactivate(); + sub.newstate(0); + } + else if (!sub.m_Q2) + sub.m_clk.activate_hl(); + //if (!sub.m_Q2 & INPLOGIC(m_clrQ)) + // sub.m_clk.activate_hl(); } NETLIB_START(nic74153) { - register_input("A1", m_I[0]); - register_input("A2", m_I[1]); - register_input("A3", m_I[2]); - register_input("A4", m_I[3]); - register_input("A", m_A); - register_input("B", m_B); - register_input("GA", m_GA); - - register_output("AY", m_AY); + register_input("A1", m_I[0]); + register_input("A2", m_I[1]); + register_input("A3", m_I[2]); + register_input("A4", m_I[3]); + register_input("A", m_A); + register_input("B", m_B); + register_input("GA", m_GA); + + register_output("AY", m_AY); } NETLIB_UPDATE(nic74153) { - const netlist_time delay[2] = { NLTIME_FROM_NS(23), NLTIME_FROM_NS(18) }; - if (!INPLOGIC(m_GA)) - { - UINT8 chan = (INPLOGIC(m_A) | (INPLOGIC(m_B)<<1)); - UINT8 t = INPLOGIC(m_I[chan]); - OUTLOGIC(m_AY, t, delay[t] ); /* data to y only, FIXME */ - } - else - { - OUTLOGIC(m_AY, 0, delay[0]); - } + const netlist_time delay[2] = { NLTIME_FROM_NS(23), NLTIME_FROM_NS(18) }; + if (!INPLOGIC(m_GA)) + { + UINT8 chan = (INPLOGIC(m_A) | (INPLOGIC(m_B)<<1)); + UINT8 t = INPLOGIC(m_I[chan]); + OUTLOGIC(m_AY, t, delay[t] ); /* data to y only, FIXME */ + } + else + { + OUTLOGIC(m_AY, 0, delay[0]); + } } @@ -346,93 +346,91 @@ NETLIB_UPDATE(nic74153) netlist_factory::netlist_factory() { - } netlist_factory::~netlist_factory() { - for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e)) - { - net_device_t_base_factory *p = e->object(); - delete p; - } - m_list.reset(); + for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e)) + { + net_device_t_base_factory *p = e->object(); + delete p; + } + m_list.reset(); } void netlist_factory::initialize() { - ENTRY(R, NETDEV_R) - ENTRY(POT, NETDEV_POT) - ENTRY(C, NETDEV_C) - ENTRY(D, NETDEV_D) - ENTRY(VCVS, NETDEV_VCVS) - ENTRY(VCCS, NETDEV_VCCS) - ENTRY(QPNP_switch, NETDEV_QPNP) - ENTRY(QNPN_switch, NETDEV_QNPN) - ENTRY(ttl_const, NETDEV_TTL_CONST) - ENTRY(analog_const, NETDEV_ANALOG_CONST) - ENTRY(logic_input, NETDEV_LOGIC_INPUT) - ENTRY(analog_input, NETDEV_ANALOG_INPUT) - ENTRY(log, NETDEV_LOG) - ENTRY(logD, NETDEV_LOGD) - ENTRY(clock, NETDEV_CLOCK) - ENTRY(mainclock, NETDEV_MAINCLOCK) - ENTRY(solver, NETDEV_SOLVER) - ENTRY(nicMultiSwitch, NETDEV_SWITCH2) - ENTRY(nicRSFF, NETDEV_RSFF) - ENTRY(nicMixer8, NETDEV_MIXER) - ENTRY(7400, TTL_7400_NAND) - ENTRY(7402, TTL_7402_NOR) - ENTRY(nic7404, TTL_7404_INVERT) - ENTRY(7410, TTL_7410_NAND) - ENTRY(7420, TTL_7420_NAND) - ENTRY(7425, TTL_7425_NOR) - ENTRY(7427, TTL_7427_NOR) - ENTRY(7430, TTL_7430_NAND) - ENTRY(nic7450, TTL_7450_ANDORINVERT) - ENTRY(7486, TTL_7486_XOR) - ENTRY(nic7448, TTL_7448) - ENTRY(7474, TTL_7474) - ENTRY(7483, TTL_7483) - ENTRY(7490, TTL_7490) - ENTRY(7493, TTL_7493) - ENTRY(nic74107, TTL_74107) - ENTRY(nic74107A, TTL_74107A) - ENTRY(nic74153, TTL_74153) - ENTRY(9316, TTL_9316) - ENTRY(NE555, NETDEV_NE555) - ENTRY(nicNE555N_MSTABLE, NE555N_MSTABLE) + ENTRY(R, NETDEV_R) + ENTRY(POT, NETDEV_POT) + ENTRY(C, NETDEV_C) + ENTRY(D, NETDEV_D) + ENTRY(VCVS, NETDEV_VCVS) + ENTRY(VCCS, NETDEV_VCCS) + ENTRY(QPNP_switch, NETDEV_QPNP) + ENTRY(QNPN_switch, NETDEV_QNPN) + ENTRY(ttl_const, NETDEV_TTL_CONST) + ENTRY(analog_const, NETDEV_ANALOG_CONST) + ENTRY(logic_input, NETDEV_LOGIC_INPUT) + ENTRY(analog_input, NETDEV_ANALOG_INPUT) + ENTRY(log, NETDEV_LOG) + ENTRY(logD, NETDEV_LOGD) + ENTRY(clock, NETDEV_CLOCK) + ENTRY(mainclock, NETDEV_MAINCLOCK) + ENTRY(solver, NETDEV_SOLVER) + ENTRY(nicMultiSwitch, NETDEV_SWITCH2) + ENTRY(nicRSFF, NETDEV_RSFF) + ENTRY(nicMixer8, NETDEV_MIXER) + ENTRY(7400, TTL_7400_NAND) + ENTRY(7402, TTL_7402_NOR) + ENTRY(nic7404, TTL_7404_INVERT) + ENTRY(7410, TTL_7410_NAND) + ENTRY(7420, TTL_7420_NAND) + ENTRY(7425, TTL_7425_NOR) + ENTRY(7427, TTL_7427_NOR) + ENTRY(7430, TTL_7430_NAND) + ENTRY(nic7450, TTL_7450_ANDORINVERT) + ENTRY(7486, TTL_7486_XOR) + ENTRY(nic7448, TTL_7448) + ENTRY(7474, TTL_7474) + ENTRY(7483, TTL_7483) + ENTRY(7490, TTL_7490) + ENTRY(7493, TTL_7493) + ENTRY(nic74107, TTL_74107) + ENTRY(nic74107A, TTL_74107A) + ENTRY(nic74153, TTL_74153) + ENTRY(9316, TTL_9316) + ENTRY(NE555, NETDEV_NE555) + ENTRY(nicNE555N_MSTABLE, NE555N_MSTABLE) } netlist_device_t *netlist_factory::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const { - for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e)) - { - net_device_t_base_factory *p = e->object(); - if (strcmp(p->classname(), classname) == 0) - { - netlist_device_t *ret = p->Create(); - return ret; - } - p++; - } - setup.netlist().xfatalerror("Class %s not found!\n", classname.cstr()); - return NULL; // appease code analysis + for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e)) + { + net_device_t_base_factory *p = e->object(); + if (strcmp(p->classname(), classname) == 0) + { + netlist_device_t *ret = p->Create(); + return ret; + } + p++; + } + setup.netlist().xfatalerror("Class %s not found!\n", classname.cstr()); + return NULL; // appease code analysis } netlist_device_t *netlist_factory::new_device_by_name(const pstring &name, netlist_setup_t &setup) const { - for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e)) - { - net_device_t_base_factory *p = e->object(); - if (strcmp(p->name(), name) == 0) - { - netlist_device_t *ret = p->Create(); - return ret; - } - p++; - } - setup.netlist().xfatalerror("Class %s not found!\n", name.cstr()); - return NULL; // appease code analysis + for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e)) + { + net_device_t_base_factory *p = e->object(); + if (strcmp(p->name(), name) == 0) + { + netlist_device_t *ret = p->Create(); + return ret; + } + p++; + } + setup.netlist().xfatalerror("Class %s not found!\n", name.cstr()); + return NULL; // appease code analysis } - diff --git a/src/emu/netlist/devices/net_lib.h b/src/emu/netlist/devices/net_lib.h index da225bc3f1e..2c696588f97 100644 --- a/src/emu/netlist/devices/net_lib.h +++ b/src/emu/netlist/devices/net_lib.h @@ -136,7 +136,7 @@ NETLIB_DEVICE(nic7450, */ NETLIB_SUBDEVICE(nic74107Asub, - netlist_ttl_input_t m_clk; + netlist_ttl_input_t m_clk; netlist_ttl_output_t m_Q; netlist_ttl_output_t m_QQ; diff --git a/src/emu/netlist/devices/nld_7400.h b/src/emu/netlist/devices/nld_7400.h index 809ea87334e..76af3043c4b 100644 --- a/src/emu/netlist/devices/nld_7400.h +++ b/src/emu/netlist/devices/nld_7400.h @@ -43,34 +43,34 @@ NETLIB_SIGNAL(7400, 2, 0, 0); NETLIB_DEVICE(7400pin, - NETLIB_NAME(7400) m_1; - NETLIB_NAME(7400) m_2; - NETLIB_NAME(7400) m_3; - NETLIB_NAME(7400) m_4; + NETLIB_NAME(7400) m_1; + NETLIB_NAME(7400) m_2; + NETLIB_NAME(7400) m_3; + NETLIB_NAME(7400) m_4; ); inline NETLIB_START(7400pin) { - register_sub(m_1, "1"); - register_sub(m_2, "2"); - register_sub(m_3, "3"); - register_sub(m_4, "4"); + register_sub(m_1, "1"); + register_sub(m_2, "2"); + register_sub(m_3, "3"); + register_sub(m_4, "4"); - register_subalias("1", m_1.m_i[0]); - register_subalias("2", m_1.m_i[1]); - register_subalias("3", m_1.m_Q); + register_subalias("1", m_1.m_i[0]); + register_subalias("2", m_1.m_i[1]); + register_subalias("3", m_1.m_Q); - register_subalias("4", m_2.m_i[0]); - register_subalias("5", m_2.m_i[1]); - register_subalias("6", m_2.m_Q); + register_subalias("4", m_2.m_i[0]); + register_subalias("5", m_2.m_i[1]); + register_subalias("6", m_2.m_Q); - register_subalias("9", m_3.m_i[0]); - register_subalias("10", m_3.m_i[1]); - register_subalias("8", m_3.m_Q); + register_subalias("9", m_3.m_i[0]); + register_subalias("10", m_3.m_i[1]); + register_subalias("8", m_3.m_Q); - register_subalias("12", m_4.m_i[0]); - register_subalias("13", m_4.m_i[1]); - register_subalias("11", m_4.m_Q); + register_subalias("12", m_4.m_i[0]); + register_subalias("13", m_4.m_i[1]); + register_subalias("11", m_4.m_Q); } #endif /* NLD_7400_H_ */ diff --git a/src/emu/netlist/devices/nld_7402.h b/src/emu/netlist/devices/nld_7402.h index 0d5990478c0..63a91d25ce8 100644 --- a/src/emu/netlist/devices/nld_7402.h +++ b/src/emu/netlist/devices/nld_7402.h @@ -35,9 +35,9 @@ #include "nld_signal.h" #define TTL_7402_NOR(_name, _I1, _I2) \ - NET_REGISTER_DEV(7402, _name) \ - NET_CONNECT(_name, A, _I1) \ - NET_CONNECT(_name, B, _I2) + NET_REGISTER_DEV(7402, _name) \ + NET_CONNECT(_name, A, _I1) \ + NET_CONNECT(_name, B, _I2) NETLIB_SIGNAL(7402, 2, 1, 0); diff --git a/src/emu/netlist/devices/nld_7404.c b/src/emu/netlist/devices/nld_7404.c index e285eb54f06..42b7e341c39 100644 --- a/src/emu/netlist/devices/nld_7404.c +++ b/src/emu/netlist/devices/nld_7404.c @@ -7,14 +7,14 @@ NETLIB_START(nic7404) { - register_input("A", m_I); - register_output("Q", m_Q); - m_Q.initial(1); + register_input("A", m_I); + register_output("Q", m_Q); + m_Q.initial(1); } NETLIB_UPDATE(nic7404) { - static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; - UINT8 t = (INPLOGIC(m_I)) ^ 1; - OUTLOGIC(m_Q, t, delay[t]); + static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; + UINT8 t = (INPLOGIC(m_I)) ^ 1; + OUTLOGIC(m_Q, t, delay[t]); } diff --git a/src/emu/netlist/devices/nld_7404.h b/src/emu/netlist/devices/nld_7404.h index 15c16652f75..5432a1dd9f7 100644 --- a/src/emu/netlist/devices/nld_7404.h +++ b/src/emu/netlist/devices/nld_7404.h @@ -33,12 +33,12 @@ #include "nld_signal.h" NETLIB_DEVICE(nic7404, - netlist_ttl_input_t m_I; - netlist_ttl_output_t m_Q; + netlist_ttl_input_t m_I; + netlist_ttl_output_t m_Q; ); #define TTL_7404_INVERT(_name, _A) \ - NET_REGISTER_DEV(nic7404, _name) \ - NET_CONNECT(_name, A, _A) + NET_REGISTER_DEV(nic7404, _name) \ + NET_CONNECT(_name, A, _A) #endif /* NLD_7404_H_ */ diff --git a/src/emu/netlist/devices/nld_7410.h b/src/emu/netlist/devices/nld_7410.h index 860d5fcab21..b8a1c55aee6 100644 --- a/src/emu/netlist/devices/nld_7410.h +++ b/src/emu/netlist/devices/nld_7410.h @@ -35,10 +35,10 @@ #include "nld_signal.h" #define TTL_7410_NAND(_name, _I1, _I2, _I3) \ - NET_REGISTER_DEV(7410, _name) \ - NET_CONNECT(_name, A, _I1) \ - NET_CONNECT(_name, B, _I2) \ - NET_CONNECT(_name, C, _I3) + NET_REGISTER_DEV(7410, _name) \ + NET_CONNECT(_name, A, _I1) \ + NET_CONNECT(_name, B, _I2) \ + NET_CONNECT(_name, C, _I3) NETLIB_SIGNAL(7410, 3, 0, 0); diff --git a/src/emu/netlist/devices/nld_7420.h b/src/emu/netlist/devices/nld_7420.h index 5ff5bd12ac5..6ac7c477743 100644 --- a/src/emu/netlist/devices/nld_7420.h +++ b/src/emu/netlist/devices/nld_7420.h @@ -36,11 +36,11 @@ #include "nld_signal.h" #define TTL_7420_NAND(_name, _I1, _I2, _I3, _I4) \ - NET_REGISTER_DEV(7420, _name) \ - NET_CONNECT(_name, A, _I1) \ - NET_CONNECT(_name, B, _I2) \ - NET_CONNECT(_name, C, _I3) \ - NET_CONNECT(_name, D, _I4) + NET_REGISTER_DEV(7420, _name) \ + NET_CONNECT(_name, A, _I1) \ + NET_CONNECT(_name, B, _I2) \ + NET_CONNECT(_name, C, _I3) \ + NET_CONNECT(_name, D, _I4) NETLIB_SIGNAL(7420, 4, 0, 0); diff --git a/src/emu/netlist/devices/nld_7425.h b/src/emu/netlist/devices/nld_7425.h index 5e2fff4f946..26ae9b8476c 100644 --- a/src/emu/netlist/devices/nld_7425.h +++ b/src/emu/netlist/devices/nld_7425.h @@ -39,11 +39,11 @@ #include "nld_signal.h" #define TTL_7425_NOR(_name, _I1, _I2, _I3, _I4) \ - NET_REGISTER_DEV(7425, _name) \ - NET_CONNECT(_name, A, _I1) \ - NET_CONNECT(_name, B, _I2) \ - NET_CONNECT(_name, C, _I3) \ - NET_CONNECT(_name, D, _I4) + NET_REGISTER_DEV(7425, _name) \ + NET_CONNECT(_name, A, _I1) \ + NET_CONNECT(_name, B, _I2) \ + NET_CONNECT(_name, C, _I3) \ + NET_CONNECT(_name, D, _I4) NETLIB_SIGNAL(7425, 4, 1, 0); diff --git a/src/emu/netlist/devices/nld_7427.h b/src/emu/netlist/devices/nld_7427.h index c5a8ede870a..9863acc9f5d 100644 --- a/src/emu/netlist/devices/nld_7427.h +++ b/src/emu/netlist/devices/nld_7427.h @@ -35,10 +35,10 @@ #include "nld_signal.h" #define TTL_7427_NOR(_name, _I1, _I2, _I3) \ - NET_REGISTER_DEV(7427, _name) \ - NET_CONNECT(_name, A, _I1) \ - NET_CONNECT(_name, B, _I2) \ - NET_CONNECT(_name, C, _I3) + NET_REGISTER_DEV(7427, _name) \ + NET_CONNECT(_name, A, _I1) \ + NET_CONNECT(_name, B, _I2) \ + NET_CONNECT(_name, C, _I3) NETLIB_SIGNAL(7427, 3, 1, 0); diff --git a/src/emu/netlist/devices/nld_7430.h b/src/emu/netlist/devices/nld_7430.h index 783e8bb6816..2d9ff87f385 100644 --- a/src/emu/netlist/devices/nld_7430.h +++ b/src/emu/netlist/devices/nld_7430.h @@ -40,15 +40,15 @@ #include "nld_signal.h" #define TTL_7430_NAND(_name, _I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8) \ - NET_REGISTER_DEV(7430, _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) + NET_REGISTER_DEV(7430, _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(7430, 8, 0, 0); diff --git a/src/emu/netlist/devices/nld_7474.c b/src/emu/netlist/devices/nld_7474.c index cd9e64e41af..ef23fe819c5 100644 --- a/src/emu/netlist/devices/nld_7474.c +++ b/src/emu/netlist/devices/nld_7474.c @@ -7,63 +7,63 @@ ATTR_HOT inline void NETLIB_NAME(7474sub)::newstate(const UINT8 state) { - static const netlist_time delay[2] = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(40) }; - OUTLOGIC(m_Q, state, delay[state]); - OUTLOGIC(m_QQ, !state, delay[!state]); + static const netlist_time delay[2] = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(40) }; + OUTLOGIC(m_Q, state, delay[state]); + OUTLOGIC(m_QQ, !state, delay[!state]); } NETLIB_UPDATE(7474sub) { - //if (!INP_LAST(m_clk) & INP(m_clk)) - { - newstate(m_nextD); - m_clk.inactivate(); - } + //if (!INP_LAST(m_clk) & INP(m_clk)) + { + newstate(m_nextD); + m_clk.inactivate(); + } } NETLIB_UPDATE(7474) { - if (!INPLOGIC(m_preQ)) - { - sub.newstate(1); - sub.m_clk.inactivate(); - m_D.inactivate(); - } - else if (!INPLOGIC(m_clrQ)) - { - sub.newstate(0); - sub.m_clk.inactivate(); - m_D.inactivate(); - } - else - { - m_D.activate(); - sub.m_nextD = INPLOGIC(m_D); - sub.m_clk.activate_lh(); - } + if (!INPLOGIC(m_preQ)) + { + sub.newstate(1); + sub.m_clk.inactivate(); + m_D.inactivate(); + } + else if (!INPLOGIC(m_clrQ)) + { + sub.newstate(0); + sub.m_clk.inactivate(); + m_D.inactivate(); + } + else + { + m_D.activate(); + sub.m_nextD = INPLOGIC(m_D); + sub.m_clk.activate_lh(); + } } NETLIB_START(7474) { - register_sub(sub, "sub"); + register_sub(sub, "sub"); - register_subalias("CLK", sub.m_clk); - register_input("D", m_D); - register_input("CLRQ", m_clrQ); - register_input("PREQ", m_preQ); + register_subalias("CLK", sub.m_clk); + register_input("D", m_D); + register_input("CLRQ", m_clrQ); + register_input("PREQ", m_preQ); - register_subalias("Q", sub.m_Q); - register_subalias("QQ", sub.m_QQ); + register_subalias("Q", sub.m_Q); + register_subalias("QQ", sub.m_QQ); } NETLIB_START(7474sub) { - register_input("CLK", m_clk, netlist_input_t::STATE_INP_LH); + register_input("CLK", m_clk, netlist_input_t::STATE_INP_LH); - register_output("Q", m_Q); - register_output("QQ", m_QQ); + register_output("Q", m_Q); + register_output("QQ", m_QQ); - m_Q.initial(1); - m_QQ.initial(0); + m_Q.initial(1); + m_QQ.initial(0); } diff --git a/src/emu/netlist/devices/nld_7474.h b/src/emu/netlist/devices/nld_7474.h index 91375f479e6..31cf80e0d6d 100644 --- a/src/emu/netlist/devices/nld_7474.h +++ b/src/emu/netlist/devices/nld_7474.h @@ -45,28 +45,28 @@ #include "nld_signal.h" #define TTL_7474(_name, _CLK, _D, _CLRQ, _PREQ) \ - NET_REGISTER_DEV(7474, _name) \ - NET_CONNECT(_name, CLK, _CLK) \ - NET_CONNECT(_name, D, _D) \ - NET_CONNECT(_name, CLRQ, _CLRQ) \ - NET_CONNECT(_name, PREQ, _PREQ) + NET_REGISTER_DEV(7474, _name) \ + NET_CONNECT(_name, CLK, _CLK) \ + NET_CONNECT(_name, D, _D) \ + NET_CONNECT(_name, CLRQ, _CLRQ) \ + NET_CONNECT(_name, PREQ, _PREQ) NETLIB_SUBDEVICE(7474sub, - netlist_ttl_input_t m_clk; + netlist_ttl_input_t m_clk; - UINT8 m_nextD; - netlist_ttl_output_t m_Q; - netlist_ttl_output_t m_QQ; + UINT8 m_nextD; + netlist_ttl_output_t m_Q; + netlist_ttl_output_t m_QQ; - ATTR_HOT inline void newstate(const UINT8 state); + ATTR_HOT inline void newstate(const UINT8 state); ); NETLIB_DEVICE(7474, - NETLIB_NAME(7474sub) sub; + NETLIB_NAME(7474sub) sub; - netlist_ttl_input_t m_D; - netlist_ttl_input_t m_clrQ; - netlist_ttl_input_t m_preQ; + netlist_ttl_input_t m_D; + netlist_ttl_input_t m_clrQ; + netlist_ttl_input_t m_preQ; ); diff --git a/src/emu/netlist/devices/nld_7483.c b/src/emu/netlist/devices/nld_7483.c index eca61846241..81624326d6e 100644 --- a/src/emu/netlist/devices/nld_7483.c +++ b/src/emu/netlist/devices/nld_7483.c @@ -7,42 +7,41 @@ NETLIB_START(7483) { - m_lastr = 0; - - register_input("A1", m_A1); - register_input("A2", m_A2); - register_input("A3", m_A3); - register_input("A4", m_A4); - register_input("B1", m_B1); - register_input("B2", m_B2); - register_input("B3", m_B3); - register_input("B4", m_B4); - register_input("C0", m_C0); - - register_output("SA", m_SA); - register_output("SB", m_SB); - register_output("SC", m_SC); - register_output("SD", m_SD); - register_output("C4", m_C4); - - save(NAME(m_lastr)); + m_lastr = 0; + + register_input("A1", m_A1); + register_input("A2", m_A2); + register_input("A3", m_A3); + register_input("A4", m_A4); + register_input("B1", m_B1); + register_input("B2", m_B2); + register_input("B3", m_B3); + register_input("B4", m_B4); + register_input("C0", m_C0); + + register_output("SA", m_SA); + register_output("SB", m_SB); + register_output("SC", m_SC); + register_output("SD", m_SD); + register_output("C4", m_C4); + + save(NAME(m_lastr)); } NETLIB_UPDATE(7483) { - UINT8 a = (INPLOGIC(m_A1) << 0) | (INPLOGIC(m_A2) << 1) | (INPLOGIC(m_A3) << 2) | (INPLOGIC(m_A4) << 3); - UINT8 b = (INPLOGIC(m_B1) << 0) | (INPLOGIC(m_B2) << 1) | (INPLOGIC(m_B3) << 2) | (INPLOGIC(m_B4) << 3); - - UINT8 r = a + b + INPLOGIC(m_C0); - - if (r != m_lastr) - { - m_lastr = r; - OUTLOGIC(m_SA, (r >> 0) & 1, NLTIME_FROM_NS(23)); - OUTLOGIC(m_SB, (r >> 1) & 1, NLTIME_FROM_NS(23)); - OUTLOGIC(m_SC, (r >> 2) & 1, NLTIME_FROM_NS(23)); - OUTLOGIC(m_SD, (r >> 3) & 1, NLTIME_FROM_NS(23)); - OUTLOGIC(m_C4, (r >> 4) & 1, NLTIME_FROM_NS(23)); - } + UINT8 a = (INPLOGIC(m_A1) << 0) | (INPLOGIC(m_A2) << 1) | (INPLOGIC(m_A3) << 2) | (INPLOGIC(m_A4) << 3); + UINT8 b = (INPLOGIC(m_B1) << 0) | (INPLOGIC(m_B2) << 1) | (INPLOGIC(m_B3) << 2) | (INPLOGIC(m_B4) << 3); + + UINT8 r = a + b + INPLOGIC(m_C0); + + if (r != m_lastr) + { + m_lastr = r; + OUTLOGIC(m_SA, (r >> 0) & 1, NLTIME_FROM_NS(23)); + OUTLOGIC(m_SB, (r >> 1) & 1, NLTIME_FROM_NS(23)); + OUTLOGIC(m_SC, (r >> 2) & 1, NLTIME_FROM_NS(23)); + OUTLOGIC(m_SD, (r >> 3) & 1, NLTIME_FROM_NS(23)); + OUTLOGIC(m_C4, (r >> 4) & 1, NLTIME_FROM_NS(23)); + } } - diff --git a/src/emu/netlist/devices/nld_7483.h b/src/emu/netlist/devices/nld_7483.h index 5900b33cc05..2f457435847 100644 --- a/src/emu/netlist/devices/nld_7483.h +++ b/src/emu/netlist/devices/nld_7483.h @@ -7,16 +7,16 @@ * * +--------------+ * A4 |1 ++ 16| B4 - * Æ©3 |2 15| Æ©3 + * ??3 |2 15| ??3 * A3 |3 14| C4 * B3 |4 7483 13| C0 * VCC |5 12| GND - * Æ©3 |6 11| B1 + * ??3 |6 11| B1 * B2 |7 10| A1 - * A2 |8 9| Æ©3 + * A2 |8 9| ??3 * +--------------+ * - * Æ© = (A + B + C) & 0x0f + * ?? = (A + B + C) & 0x0f * * C4 = (A + B + C) > 15 ? 1 : 0 * @@ -30,35 +30,35 @@ #include "../nl_base.h" #define TTL_7483(_name, _A1, _A2, _A3, _A4, _B1, _B2, _B3, _B4, _CI) \ - NET_REGISTER_DEV(7483, _name) \ - NET_CONNECT(_name, A1, _A1) \ - NET_CONNECT(_name, A2, _A2) \ - NET_CONNECT(_name, A3, _A3) \ - NET_CONNECT(_name, A4, _A4) \ - NET_CONNECT(_name, B1, _B1) \ - NET_CONNECT(_name, B2, _B2) \ - NET_CONNECT(_name, B3, _B3) \ - NET_CONNECT(_name, B4, _B4) \ - NET_CONNECT(_name, C0, _CI) + NET_REGISTER_DEV(7483, _name) \ + NET_CONNECT(_name, A1, _A1) \ + NET_CONNECT(_name, A2, _A2) \ + NET_CONNECT(_name, A3, _A3) \ + NET_CONNECT(_name, A4, _A4) \ + NET_CONNECT(_name, B1, _B1) \ + NET_CONNECT(_name, B2, _B2) \ + NET_CONNECT(_name, B3, _B3) \ + NET_CONNECT(_name, B4, _B4) \ + NET_CONNECT(_name, C0, _CI) NETLIB_DEVICE(7483, - netlist_ttl_input_t m_C0; - netlist_ttl_input_t m_A1; - netlist_ttl_input_t m_A2; - netlist_ttl_input_t m_A3; - netlist_ttl_input_t m_A4; - netlist_ttl_input_t m_B1; - netlist_ttl_input_t m_B2; - netlist_ttl_input_t m_B3; - netlist_ttl_input_t m_B4; + netlist_ttl_input_t m_C0; + netlist_ttl_input_t m_A1; + netlist_ttl_input_t m_A2; + netlist_ttl_input_t m_A3; + netlist_ttl_input_t m_A4; + netlist_ttl_input_t m_B1; + netlist_ttl_input_t m_B2; + netlist_ttl_input_t m_B3; + netlist_ttl_input_t m_B4; - UINT8 m_lastr; + UINT8 m_lastr; - netlist_ttl_output_t m_SA; - netlist_ttl_output_t m_SB; - netlist_ttl_output_t m_SC; - netlist_ttl_output_t m_SD; - netlist_ttl_output_t m_C4; + netlist_ttl_output_t m_SA; + netlist_ttl_output_t m_SB; + netlist_ttl_output_t m_SC; + netlist_ttl_output_t m_SD; + netlist_ttl_output_t m_C4; ); diff --git a/src/emu/netlist/devices/nld_7486.c b/src/emu/netlist/devices/nld_7486.c index 55fa712e9ad..fcd94c9f321 100644 --- a/src/emu/netlist/devices/nld_7486.c +++ b/src/emu/netlist/devices/nld_7486.c @@ -7,15 +7,14 @@ NETLIB_START(7486) { - register_input("A", m_A); - register_input("B", m_B); - register_output("Q", m_Q); + register_input("A", m_A); + register_input("B", m_B); + register_output("Q", m_Q); } NETLIB_UPDATE(7486) { - 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]); + 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 index b00d8905ae3..d4fd3d5cda9 100644 --- a/src/emu/netlist/devices/nld_7486.h +++ b/src/emu/netlist/devices/nld_7486.h @@ -35,13 +35,13 @@ #include "nld_signal.h" #define TTL_7486_XOR(_name, _A, _B) \ - NET_REGISTER_DEV(7486, _name) \ - NET_CONNECT(_name, A, _A) \ - NET_CONNECT(_name, B, _B) + NET_REGISTER_DEV(7486, _name) \ + NET_CONNECT(_name, A, _A) \ + NET_CONNECT(_name, B, _B) NETLIB_DEVICE(7486, - netlist_ttl_input_t m_A; - netlist_ttl_input_t m_B; - netlist_ttl_output_t m_Q; + 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/devices/nld_7490.c b/src/emu/netlist/devices/nld_7490.c index 48b8bbc6b5c..cc84a1389c3 100644 --- a/src/emu/netlist/devices/nld_7490.c +++ b/src/emu/netlist/devices/nld_7490.c @@ -7,47 +7,47 @@ NETLIB_START(7490) { - m_cnt = 0; + m_cnt = 0; - register_input("CLK", m_clk); - register_input("R1", m_R1); - register_input("R2", m_R2); - register_input("R91", m_R91); - register_input("R92", m_R92); + register_input("CLK", m_clk); + register_input("R1", m_R1); + register_input("R2", m_R2); + register_input("R91", m_R91); + register_input("R92", m_R92); - register_output("QA", m_Q[0]); - register_output("QB", m_Q[1]); - register_output("QC", m_Q[2]); - register_output("QD", m_Q[3]); + register_output("QA", m_Q[0]); + register_output("QB", m_Q[1]); + register_output("QC", m_Q[2]); + register_output("QD", m_Q[3]); - save(NAME(m_cnt)); + save(NAME(m_cnt)); } NETLIB_UPDATE(7490) { - if (INPLOGIC(m_R91) & INPLOGIC(m_R92)) - { - m_cnt = 9; - update_outputs(); - } - else if (INPLOGIC(m_R1) & INPLOGIC(m_R2)) - { - m_cnt = 0; - update_outputs(); - } - else if (INP_HL(m_clk)) - { - m_cnt++; - if (m_cnt >= 10) - m_cnt = 0; - update_outputs(); - } + if (INPLOGIC(m_R91) & INPLOGIC(m_R92)) + { + m_cnt = 9; + update_outputs(); + } + else if (INPLOGIC(m_R1) & INPLOGIC(m_R2)) + { + m_cnt = 0; + update_outputs(); + } + else if (INP_HL(m_clk)) + { + m_cnt++; + if (m_cnt >= 10) + m_cnt = 0; + update_outputs(); + } } NETLIB_FUNC_VOID(7490, update_outputs, (void)) { - const netlist_time delay[4] = { NLTIME_FROM_NS(18), NLTIME_FROM_NS(36), NLTIME_FROM_NS(54), NLTIME_FROM_NS(72) }; - for (int i=0; i<4; i++) - OUTLOGIC(m_Q[i], (m_cnt >> i) & 1, delay[i]); + const netlist_time delay[4] = { NLTIME_FROM_NS(18), NLTIME_FROM_NS(36), NLTIME_FROM_NS(54), NLTIME_FROM_NS(72) }; + for (int i=0; i<4; i++) + OUTLOGIC(m_Q[i], (m_cnt >> i) & 1, delay[i]); } diff --git a/src/emu/netlist/devices/nld_7490.h b/src/emu/netlist/devices/nld_7490.h index a5380a21cae..288f2cc8864 100644 --- a/src/emu/netlist/devices/nld_7490.h +++ b/src/emu/netlist/devices/nld_7490.h @@ -58,26 +58,26 @@ #include "../nl_base.h" #define TTL_7490(_name, _CLK, _R1, _R2, _R91, _R92) \ - NET_REGISTER_DEV(7490, _name) \ - NET_CONNECT(_name, CLK, _CLK) \ - NET_CONNECT(_name, R1, _R1) \ - NET_CONNECT(_name, R2, _R2) \ - NET_CONNECT(_name, R91, _R91) \ - NET_CONNECT(_name, R92, _R92) + NET_REGISTER_DEV(7490, _name) \ + NET_CONNECT(_name, CLK, _CLK) \ + NET_CONNECT(_name, R1, _R1) \ + NET_CONNECT(_name, R2, _R2) \ + NET_CONNECT(_name, R91, _R91) \ + NET_CONNECT(_name, R92, _R92) NETLIB_DEVICE(7490, - ATTR_HOT void update_outputs(); + ATTR_HOT void update_outputs(); - netlist_ttl_input_t m_R1; - netlist_ttl_input_t m_R2; - netlist_ttl_input_t m_R91; - netlist_ttl_input_t m_R92; - netlist_ttl_input_t m_clk; + netlist_ttl_input_t m_R1; + netlist_ttl_input_t m_R2; + netlist_ttl_input_t m_R91; + netlist_ttl_input_t m_R92; + netlist_ttl_input_t m_clk; - UINT8 m_cnt; + UINT8 m_cnt; - netlist_ttl_output_t m_Q[4]; + netlist_ttl_output_t m_Q[4]; ); #endif /* NLD_7490_H_ */ diff --git a/src/emu/netlist/devices/nld_7493.c b/src/emu/netlist/devices/nld_7493.c index a8c218de5a8..ac633df081b 100644 --- a/src/emu/netlist/devices/nld_7493.c +++ b/src/emu/netlist/devices/nld_7493.c @@ -7,59 +7,59 @@ NETLIB_START(7493) { - register_sub(A, "A"); - register_sub(B, "B"); - register_sub(C, "C"); - register_sub(D, "D"); + register_sub(A, "A"); + register_sub(B, "B"); + register_sub(C, "C"); + register_sub(D, "D"); - register_subalias("CLKA", A.m_I); - register_subalias("CLKB", B.m_I); - register_input("R1", m_R1); - register_input("R2", m_R2); + register_subalias("CLKA", A.m_I); + register_subalias("CLKB", B.m_I); + register_input("R1", m_R1); + register_input("R2", m_R2); - register_subalias("QA", A.m_Q); - register_subalias("QB", B.m_Q); - register_subalias("QC", C.m_Q); - register_subalias("QD", D.m_Q); + register_subalias("QA", A.m_Q); + register_subalias("QB", B.m_Q); + register_subalias("QC", C.m_Q); + register_subalias("QD", D.m_Q); - register_link_internal(C, C.m_I, B.m_Q, netlist_input_t::STATE_INP_HL); - register_link_internal(D, D.m_I, C.m_Q, netlist_input_t::STATE_INP_HL); + register_link_internal(C, C.m_I, B.m_Q, netlist_input_t::STATE_INP_HL); + register_link_internal(D, D.m_I, C.m_Q, netlist_input_t::STATE_INP_HL); } NETLIB_START(7493ff) { - m_reset = 0; + m_reset = 0; - register_input("CLK", m_I, netlist_input_t::STATE_INP_HL); - register_output("Q", m_Q); + register_input("CLK", m_I, netlist_input_t::STATE_INP_HL); + register_output("Q", m_Q); - save(NAME(m_reset)); + save(NAME(m_reset)); } NETLIB_UPDATE(7493ff) { - if (m_reset == 0) - OUTLOGIC(m_Q, !m_Q.net().new_Q(), NLTIME_FROM_NS(18)); + if (m_reset == 0) + OUTLOGIC(m_Q, !m_Q.net().new_Q(), NLTIME_FROM_NS(18)); } NETLIB_UPDATE(7493) { - netlist_sig_t r = INPLOGIC(m_R1) & INPLOGIC(m_R2); + netlist_sig_t r = INPLOGIC(m_R1) & INPLOGIC(m_R2); - if (r) - { - A.m_reset = B.m_reset = C.m_reset = D.m_reset = 1; - A.m_I.inactivate(); - B.m_I.inactivate(); - OUTLOGIC(A.m_Q, 0, NLTIME_FROM_NS(40)); - OUTLOGIC(B.m_Q, 0, NLTIME_FROM_NS(40)); - OUTLOGIC(C.m_Q, 0, NLTIME_FROM_NS(40)); - OUTLOGIC(D.m_Q, 0, NLTIME_FROM_NS(40)); - } - else - { - A.m_reset = B.m_reset = C.m_reset = D.m_reset = 0; - A.m_I.activate_hl(); - B.m_I.activate_hl(); - } + if (r) + { + A.m_reset = B.m_reset = C.m_reset = D.m_reset = 1; + A.m_I.inactivate(); + B.m_I.inactivate(); + OUTLOGIC(A.m_Q, 0, NLTIME_FROM_NS(40)); + OUTLOGIC(B.m_Q, 0, NLTIME_FROM_NS(40)); + OUTLOGIC(C.m_Q, 0, NLTIME_FROM_NS(40)); + OUTLOGIC(D.m_Q, 0, NLTIME_FROM_NS(40)); + } + else + { + A.m_reset = B.m_reset = C.m_reset = D.m_reset = 0; + A.m_I.activate_hl(); + B.m_I.activate_hl(); + } } diff --git a/src/emu/netlist/devices/nld_7493.h b/src/emu/netlist/devices/nld_7493.h index 7cd6e59988b..cc961c389f1 100644 --- a/src/emu/netlist/devices/nld_7493.h +++ b/src/emu/netlist/devices/nld_7493.h @@ -60,27 +60,27 @@ #include "../nl_base.h" #define TTL_7493(_name, _CLKA, _CLKB, _R1, _R2) \ - NET_REGISTER_DEV(7493, _name) \ - NET_CONNECT(_name, CLKA, _CLKA) \ - NET_CONNECT(_name, CLKB, _CLKB) \ - NET_CONNECT(_name, R1, _R1) \ - NET_CONNECT(_name, R2, _R2) + NET_REGISTER_DEV(7493, _name) \ + NET_CONNECT(_name, CLKA, _CLKA) \ + NET_CONNECT(_name, CLKB, _CLKB) \ + NET_CONNECT(_name, R1, _R1) \ + NET_CONNECT(_name, R2, _R2) NETLIB_SUBDEVICE(7493ff, - netlist_ttl_input_t m_I; - netlist_ttl_output_t m_Q; + netlist_ttl_input_t m_I; + netlist_ttl_output_t m_Q; - UINT8 m_reset; + UINT8 m_reset; ); NETLIB_DEVICE(7493, - netlist_ttl_input_t m_R1; - netlist_ttl_input_t m_R2; + netlist_ttl_input_t m_R1; + netlist_ttl_input_t m_R2; - NETLIB_NAME(7493ff) A; - NETLIB_NAME(7493ff) B; - NETLIB_NAME(7493ff) C; - NETLIB_NAME(7493ff) D; + NETLIB_NAME(7493ff) A; + NETLIB_NAME(7493ff) B; + NETLIB_NAME(7493ff) C; + NETLIB_NAME(7493ff) D; ); #endif /* NLD_7493_H_ */ diff --git a/src/emu/netlist/devices/nld_9316.c b/src/emu/netlist/devices/nld_9316.c index ede8e0c0e68..b3b49c171b3 100644 --- a/src/emu/netlist/devices/nld_9316.c +++ b/src/emu/netlist/devices/nld_9316.c @@ -7,148 +7,147 @@ NETLIB_START(9316) { - register_sub(sub, "sub"); + register_sub(sub, "sub"); - register_subalias("CLK", sub.m_clk); + register_subalias("CLK", sub.m_clk); - register_input("ENP", m_ENP); - register_input("ENT", m_ENT); - register_input("CLRQ", m_CLRQ); - register_input("LOADQ", m_LOADQ); + register_input("ENP", m_ENP); + register_input("ENT", m_ENT); + register_input("CLRQ", m_CLRQ); + register_input("LOADQ", m_LOADQ); - register_subalias("A", sub.m_A); - register_subalias("B", sub.m_B); - register_subalias("C", sub.m_C); - register_subalias("D", sub.m_D); + register_subalias("A", sub.m_A); + register_subalias("B", sub.m_B); + register_subalias("C", sub.m_C); + register_subalias("D", sub.m_D); - register_subalias("QA", sub.m_QA); - register_subalias("QB", sub.m_QB); - register_subalias("QC", sub.m_QC); - register_subalias("QD", sub.m_QD); - register_subalias("RC", sub.m_RC); + register_subalias("QA", sub.m_QA); + register_subalias("QB", sub.m_QB); + register_subalias("QC", sub.m_QC); + register_subalias("QD", sub.m_QD); + register_subalias("RC", sub.m_RC); } NETLIB_START(9316_sub) { - m_cnt = 0; - m_loadq = 1; - m_ent = 1; - - register_input("CLK", m_clk, netlist_input_t::STATE_INP_LH); - - register_input("A", m_A, netlist_input_t::STATE_INP_PASSIVE); - register_input("B", m_B, netlist_input_t::STATE_INP_PASSIVE); - register_input("C", m_C, netlist_input_t::STATE_INP_PASSIVE); - register_input("D", m_D, netlist_input_t::STATE_INP_PASSIVE); - - register_output("QA", m_QA); - register_output("QB", m_QB); - register_output("QC", m_QC); - register_output("QD", m_QD); - register_output("RC", m_RC); - - save(NAME(m_cnt)); - save(NAME(m_loadq)); - save(NAME(m_ent)); + m_cnt = 0; + m_loadq = 1; + m_ent = 1; + + register_input("CLK", m_clk, netlist_input_t::STATE_INP_LH); + + register_input("A", m_A, netlist_input_t::STATE_INP_PASSIVE); + register_input("B", m_B, netlist_input_t::STATE_INP_PASSIVE); + register_input("C", m_C, netlist_input_t::STATE_INP_PASSIVE); + register_input("D", m_D, netlist_input_t::STATE_INP_PASSIVE); + + register_output("QA", m_QA); + register_output("QB", m_QB); + register_output("QC", m_QC); + register_output("QD", m_QD); + register_output("RC", m_RC); + + save(NAME(m_cnt)); + save(NAME(m_loadq)); + save(NAME(m_ent)); } NETLIB_UPDATE(9316_sub) { - UINT8 cnt = m_cnt; - if (m_loadq) - { - cnt = ( cnt + 1) & 0x0f; - update_outputs(cnt); - if (cnt == 0x0f) - OUTLOGIC(m_RC, m_ent, NLTIME_FROM_NS(20)); - else if (cnt == 0) - OUTLOGIC(m_RC, 0, NLTIME_FROM_NS(20)); - } - else - { - cnt = (INPLOGIC_PASSIVE(m_D) << 3) | (INPLOGIC_PASSIVE(m_C) << 2) | (INPLOGIC_PASSIVE(m_B) << 1) | (INPLOGIC_PASSIVE(m_A) << 0); - update_outputs_all(cnt); - OUTLOGIC(m_RC, m_ent & (cnt == 0x0f), NLTIME_FROM_NS(20)); - } - m_cnt = cnt; + UINT8 cnt = m_cnt; + if (m_loadq) + { + cnt = ( cnt + 1) & 0x0f; + update_outputs(cnt); + if (cnt == 0x0f) + OUTLOGIC(m_RC, m_ent, NLTIME_FROM_NS(20)); + else if (cnt == 0) + OUTLOGIC(m_RC, 0, NLTIME_FROM_NS(20)); + } + else + { + cnt = (INPLOGIC_PASSIVE(m_D) << 3) | (INPLOGIC_PASSIVE(m_C) << 2) | (INPLOGIC_PASSIVE(m_B) << 1) | (INPLOGIC_PASSIVE(m_A) << 0); + update_outputs_all(cnt); + OUTLOGIC(m_RC, m_ent & (cnt == 0x0f), NLTIME_FROM_NS(20)); + } + m_cnt = cnt; } NETLIB_UPDATE(9316) { - sub.m_loadq = INPLOGIC(m_LOADQ); - sub.m_ent = INPLOGIC(m_ENT); - const netlist_sig_t clrq = INPLOGIC(m_CLRQ); - - if ((!sub.m_loadq || (sub.m_ent & INPLOGIC(m_ENP))) & clrq) - { - sub.m_clk.activate_lh(); - } - else - { - sub.m_clk.inactivate(); - if (!clrq & (sub.m_cnt>0)) - { - sub.m_cnt = 0; - sub.update_outputs(sub.m_cnt); - OUTLOGIC(sub.m_RC, 0, NLTIME_FROM_NS(20)); - return; - } - } - OUTLOGIC(sub.m_RC, sub.m_ent & (sub.m_cnt == 0x0f), NLTIME_FROM_NS(20)); + sub.m_loadq = INPLOGIC(m_LOADQ); + sub.m_ent = INPLOGIC(m_ENT); + const netlist_sig_t clrq = INPLOGIC(m_CLRQ); + + if ((!sub.m_loadq || (sub.m_ent & INPLOGIC(m_ENP))) & clrq) + { + sub.m_clk.activate_lh(); + } + else + { + sub.m_clk.inactivate(); + if (!clrq & (sub.m_cnt>0)) + { + sub.m_cnt = 0; + sub.update_outputs(sub.m_cnt); + OUTLOGIC(sub.m_RC, 0, NLTIME_FROM_NS(20)); + return; + } + } + OUTLOGIC(sub.m_RC, sub.m_ent & (sub.m_cnt == 0x0f), NLTIME_FROM_NS(20)); } inline NETLIB_FUNC_VOID(9316_sub, update_outputs_all, (const UINT8 cnt)) { - const netlist_time out_delay = NLTIME_FROM_NS(20); - OUTLOGIC(m_QA, (cnt >> 0) & 1, out_delay); - OUTLOGIC(m_QB, (cnt >> 1) & 1, out_delay); - OUTLOGIC(m_QC, (cnt >> 2) & 1, out_delay); - OUTLOGIC(m_QD, (cnt >> 3) & 1, out_delay); + const netlist_time out_delay = NLTIME_FROM_NS(20); + OUTLOGIC(m_QA, (cnt >> 0) & 1, out_delay); + OUTLOGIC(m_QB, (cnt >> 1) & 1, out_delay); + OUTLOGIC(m_QC, (cnt >> 2) & 1, out_delay); + OUTLOGIC(m_QD, (cnt >> 3) & 1, out_delay); } inline NETLIB_FUNC_VOID(9316_sub, update_outputs, (const UINT8 cnt)) { - const netlist_time out_delay = NLTIME_FROM_NS(20); + const netlist_time out_delay = NLTIME_FROM_NS(20); #if 0 // for (int i=0; i<4; i++) // OUTLOGIC(m_Q[i], (cnt >> i) & 1, delay[i]); - OUTLOGIC(m_QA, (cnt >> 0) & 1, out_delay); - OUTLOGIC(m_QB, (cnt >> 1) & 1, out_delay); - OUTLOGIC(m_QC, (cnt >> 2) & 1, out_delay); - OUTLOGIC(m_QD, (cnt >> 3) & 1, out_delay); + OUTLOGIC(m_QA, (cnt >> 0) & 1, out_delay); + OUTLOGIC(m_QB, (cnt >> 1) & 1, out_delay); + OUTLOGIC(m_QC, (cnt >> 2) & 1, out_delay); + OUTLOGIC(m_QD, (cnt >> 3) & 1, out_delay); #else - if ((cnt & 1) == 1) - OUTLOGIC(m_QA, 1, out_delay); - else - { - OUTLOGIC(m_QA, 0, out_delay); - switch (cnt) - { - case 0x00: - OUTLOGIC(m_QB, 0, out_delay); - OUTLOGIC(m_QC, 0, out_delay); - OUTLOGIC(m_QD, 0, out_delay); - break; - case 0x02: - case 0x06: - case 0x0A: - case 0x0E: - OUTLOGIC(m_QB, 1, out_delay); - break; - case 0x04: - case 0x0C: - OUTLOGIC(m_QB, 0, out_delay); - OUTLOGIC(m_QC, 1, out_delay); - break; - case 0x08: - OUTLOGIC(m_QB, 0, out_delay); - OUTLOGIC(m_QC, 0, out_delay); - OUTLOGIC(m_QD, 1, out_delay); - break; - } - - } + if ((cnt & 1) == 1) + OUTLOGIC(m_QA, 1, out_delay); + else + { + OUTLOGIC(m_QA, 0, out_delay); + switch (cnt) + { + case 0x00: + OUTLOGIC(m_QB, 0, out_delay); + OUTLOGIC(m_QC, 0, out_delay); + OUTLOGIC(m_QD, 0, out_delay); + break; + case 0x02: + case 0x06: + case 0x0A: + case 0x0E: + OUTLOGIC(m_QB, 1, out_delay); + break; + case 0x04: + case 0x0C: + OUTLOGIC(m_QB, 0, out_delay); + OUTLOGIC(m_QC, 1, out_delay); + break; + case 0x08: + OUTLOGIC(m_QB, 0, out_delay); + OUTLOGIC(m_QC, 0, out_delay); + OUTLOGIC(m_QD, 1, out_delay); + break; + } + + } #endif } - diff --git a/src/emu/netlist/devices/nld_9316.h b/src/emu/netlist/devices/nld_9316.h index 886ef1c956c..7aa340a76d1 100644 --- a/src/emu/netlist/devices/nld_9316.h +++ b/src/emu/netlist/devices/nld_9316.h @@ -52,45 +52,45 @@ #include "../nl_base.h" #define TTL_9316(_name, _CLK, _ENP, _ENT, _CLRQ, _LOADQ, _A, _B, _C, _D) \ - NET_REGISTER_DEV(9316, _name) \ - NET_CONNECT(_name, CLK, _CLK) \ - NET_CONNECT(_name, ENP, _ENP) \ - NET_CONNECT(_name, ENT, _ENT) \ - NET_CONNECT(_name, CLRQ, _CLRQ) \ - NET_CONNECT(_name, LOADQ,_LOADQ) \ - NET_CONNECT(_name, A, _A) \ - NET_CONNECT(_name, B, _B) \ - NET_CONNECT(_name, C, _C) \ - NET_CONNECT(_name, D, _D) + NET_REGISTER_DEV(9316, _name) \ + NET_CONNECT(_name, CLK, _CLK) \ + NET_CONNECT(_name, ENP, _ENP) \ + NET_CONNECT(_name, ENT, _ENT) \ + NET_CONNECT(_name, CLRQ, _CLRQ) \ + NET_CONNECT(_name, LOADQ,_LOADQ) \ + NET_CONNECT(_name, A, _A) \ + NET_CONNECT(_name, B, _B) \ + NET_CONNECT(_name, C, _C) \ + NET_CONNECT(_name, D, _D) NETLIB_SUBDEVICE(9316_sub, - ATTR_HOT void update_outputs_all(const UINT8 cnt); - ATTR_HOT void update_outputs(const UINT8 cnt); + ATTR_HOT void update_outputs_all(const UINT8 cnt); + ATTR_HOT void update_outputs(const UINT8 cnt); - netlist_ttl_input_t m_clk; + netlist_ttl_input_t m_clk; - netlist_ttl_input_t m_A; - netlist_ttl_input_t m_B; - netlist_ttl_input_t m_C; - netlist_ttl_input_t m_D; + netlist_ttl_input_t m_A; + netlist_ttl_input_t m_B; + netlist_ttl_input_t m_C; + netlist_ttl_input_t m_D; - UINT8 m_cnt; - netlist_sig_t m_loadq; - netlist_sig_t m_ent; + UINT8 m_cnt; + netlist_sig_t m_loadq; + netlist_sig_t m_ent; - netlist_ttl_output_t m_QA; - netlist_ttl_output_t m_QB; - netlist_ttl_output_t m_QC; - netlist_ttl_output_t m_QD; - netlist_ttl_output_t m_RC; + netlist_ttl_output_t m_QA; + netlist_ttl_output_t m_QB; + netlist_ttl_output_t m_QC; + netlist_ttl_output_t m_QD; + netlist_ttl_output_t m_RC; ); NETLIB_DEVICE(9316, - NETLIB_NAME(9316_sub) sub; - netlist_ttl_input_t m_ENP; - netlist_ttl_input_t m_ENT; - netlist_ttl_input_t m_CLRQ; - netlist_ttl_input_t m_LOADQ; + NETLIB_NAME(9316_sub) sub; + netlist_ttl_input_t m_ENP; + netlist_ttl_input_t m_ENT; + netlist_ttl_input_t m_CLRQ; + netlist_ttl_input_t m_LOADQ; ); #endif /* NLD_9316_H_ */ diff --git a/src/emu/netlist/devices/nld_legacy.c b/src/emu/netlist/devices/nld_legacy.c index 4afe74a45d8..e23c7287ea0 100644 --- a/src/emu/netlist/devices/nld_legacy.c +++ b/src/emu/netlist/devices/nld_legacy.c @@ -7,141 +7,141 @@ NETLIB_START(nicMultiSwitch) { - static const char *sIN[8] = { "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8" }; - int i; + static const char *sIN[8] = { "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8" }; + int i; - m_position = 0; - m_low.initial(0); + m_position = 0; + m_low.initial(0); - for (i=0; i<8; i++) - { - register_input(sIN[i], m_I[i]); - m_low.net().register_con(m_I[i]); - //m_I[i].set_net(m_low.m_net); - } - register_param("POS", m_POS, 0); - register_output("Q", m_Q); + for (i=0; i<8; i++) + { + register_input(sIN[i], m_I[i]); + m_low.net().register_con(m_I[i]); + //m_I[i].set_net(m_low.m_net); + } + register_param("POS", m_POS, 0); + register_output("Q", m_Q); - save(NAME(m_position)); + save(NAME(m_position)); } NETLIB_UPDATE(nicMultiSwitch) { - assert(m_position<8); - OUTANALOG(m_Q, INPANALOG(m_I[m_position]), NLTIME_FROM_NS(1)); + assert(m_position<8); + OUTANALOG(m_Q, INPANALOG(m_I[m_position]), NLTIME_FROM_NS(1)); } NETLIB_UPDATE_PARAM(nicMultiSwitch) { - m_position = m_POS.Value(); - //update(); + m_position = m_POS.Value(); + //update(); } NETLIB_START(nicMixer8) { - static const char *sI[8] = { "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8" }; - static const char *sR[8] = { "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8" }; - int i; - - m_low.initial(0); - - for (i=0; i<8; i++) - { - register_input(sI[i], m_I[i]); - m_low.net().register_con(m_I[i]); - //m_I[i].set_output(m_low); - register_param(sR[i], m_R[i], 1e12); - } - register_output("Q", m_Q); + static const char *sI[8] = { "I1", "I2", "I3", "I4", "I5", "I6", "I7", "I8" }; + static const char *sR[8] = { "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8" }; + int i; + + m_low.initial(0); + + for (i=0; i<8; i++) + { + register_input(sI[i], m_I[i]); + m_low.net().register_con(m_I[i]); + //m_I[i].set_output(m_low); + register_param(sR[i], m_R[i], 1e12); + } + register_output("Q", m_Q); } NETLIB_UPDATE(nicMixer8) { - int i; - double r = 0; - - for (i=0; i<8; i++) - { - r += m_w[i] * INPANALOG(m_I[i]); - } - OUTANALOG(m_Q, r, NLTIME_IMMEDIATE); + int i; + double r = 0; + + for (i=0; i<8; i++) + { + r += m_w[i] * INPANALOG(m_I[i]); + } + OUTANALOG(m_Q, r, NLTIME_IMMEDIATE); } NETLIB_UPDATE_PARAM(nicMixer8) { - double t = 0; - int i; + double t = 0; + int i; - for (i=0; i<8; i++) - t += 1.0 / m_R[i].Value(); - t = 1.0 / t; + for (i=0; i<8; i++) + t += 1.0 / m_R[i].Value(); + t = 1.0 / t; - for (i=0; i<8; i++) - m_w[i] = t / m_R[i].Value(); + for (i=0; i<8; i++) + m_w[i] = t / m_R[i].Value(); } NETLIB_START(nicRSFF) { - register_input("S", m_S); - register_input("R", m_R); - register_output("Q", m_Q); - register_output("QQ", m_QQ); - m_Q.initial(0); - m_QQ.initial(1); + register_input("S", m_S); + register_input("R", m_R); + register_output("Q", m_Q); + register_output("QQ", m_QQ); + m_Q.initial(0); + m_QQ.initial(1); } NETLIB_UPDATE(nicRSFF) { - if (INPLOGIC(m_S)) - { - OUTLOGIC(m_Q, 1, NLTIME_FROM_NS(10)); - OUTLOGIC(m_QQ, 0, NLTIME_FROM_NS(10)); - } - else if (INPLOGIC(m_R)) - { - OUTLOGIC(m_Q, 0, NLTIME_FROM_NS(10)); - OUTLOGIC(m_QQ, 1, NLTIME_FROM_NS(10)); - } + if (INPLOGIC(m_S)) + { + OUTLOGIC(m_Q, 1, NLTIME_FROM_NS(10)); + OUTLOGIC(m_QQ, 0, NLTIME_FROM_NS(10)); + } + else if (INPLOGIC(m_R)) + { + OUTLOGIC(m_Q, 0, NLTIME_FROM_NS(10)); + OUTLOGIC(m_QQ, 1, NLTIME_FROM_NS(10)); + } } NETLIB_START(nicNE555N_MSTABLE) { - register_input("TRIG", m_trigger); - register_input("CV", m_CV); + register_input("TRIG", m_trigger); + register_input("CV", m_CV); - register_output("Q", m_Q); - register_param("R", m_R, 0.0); - register_param("C", m_C, 0.0); - register_param("VS", m_VS, 5.0); - register_param("VL", m_VL, 0.0 *5.0); + register_output("Q", m_Q); + register_param("R", m_R, 0.0); + register_param("C", m_C, 0.0); + register_param("VS", m_VS, 5.0); + register_param("VL", m_VL, 0.0 *5.0); - m_THRESHOLD_OUT.init_object(*this, name() + "THRESHOLD"); - register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, netlist_input_t::STATE_INP_ACTIVE); + m_THRESHOLD_OUT.init_object(*this, name() + "THRESHOLD"); + register_link_internal(m_THRESHOLD, m_THRESHOLD_OUT, netlist_input_t::STATE_INP_ACTIVE); - m_Q.initial(5.0 * 0.4); - m_last = false; + m_Q.initial(5.0 * 0.4); + m_last = false; - save(NAME(m_last)); + save(NAME(m_last)); } inline double NETLIB_NAME(nicNE555N_MSTABLE)::nicNE555N_cv() { - return (m_CV.is_highz() ? 0.67 * m_VS.Value() : INPANALOG(m_CV)); + return (m_CV.is_highz() ? 0.67 * m_VS.Value() : INPANALOG(m_CV)); } inline double NETLIB_NAME(nicNE555N_MSTABLE)::nicNE555N_clamp(const double v, const double a, const double b) { - double ret = v; - if (ret > m_VS.Value() - a) - ret = m_VS.Value() - a; - if (ret < b) - ret = b; - return ret; + double ret = v; + if (ret > m_VS.Value() - a) + ret = m_VS.Value() - a; + if (ret < b) + ret = b; + return ret; } NETLIB_UPDATE_PARAM(nicNE555N_MSTABLE) @@ -150,46 +150,46 @@ NETLIB_UPDATE_PARAM(nicNE555N_MSTABLE) NETLIB_UPDATE(nicNE555N_MSTABLE) { - update_param(); // FIXME : m_CV should be on a sub device ... - - double vt = nicNE555N_clamp(nicNE555N_cv(), 0.7, 1.4); - bool bthresh = (INPANALOG(m_THRESHOLD) > vt); - bool btrig = (INPANALOG(m_trigger) > nicNE555N_clamp(nicNE555N_cv() * 0.5, 0.7, 1.4)); - bool out = m_last; - - if (!btrig) - { - out = true; - } - else if (bthresh) - { - out = false; - } - - if (!m_last && out) - { - double vl = m_VL.Value(); - double time; - - // FIXME : m_CV should be on a sub device ... - - // TI datasheet states minimum pulse of 10 us - if (vt<vl) - time = 10; - else - { - time = - log((m_VS.Value()-vt)/(m_VS.Value()-vl)) * m_R.Value() * m_C.Value() * 1.0e6; // in us - if (time < 10.0) - time = 10.0; - } - - OUTANALOG(m_Q, m_VS.Value() * 0.7, NLTIME_FROM_NS(100)); - OUTANALOG(m_THRESHOLD_OUT, m_VS.Value(), NLTIME_FROM_US(time )); - } - else if (m_last && !out) - { - OUTANALOG(m_Q, 0.25, NLTIME_FROM_NS(100)); - OUTANALOG(m_THRESHOLD_OUT, 0.0, NLTIME_FROM_NS(1)); - } - m_last = out; + update_param(); // FIXME : m_CV should be on a sub device ... + + double vt = nicNE555N_clamp(nicNE555N_cv(), 0.7, 1.4); + bool bthresh = (INPANALOG(m_THRESHOLD) > vt); + bool btrig = (INPANALOG(m_trigger) > nicNE555N_clamp(nicNE555N_cv() * 0.5, 0.7, 1.4)); + bool out = m_last; + + if (!btrig) + { + out = true; + } + else if (bthresh) + { + out = false; + } + + if (!m_last && out) + { + double vl = m_VL.Value(); + double time; + + // FIXME : m_CV should be on a sub device ... + + // TI datasheet states minimum pulse of 10 us + if (vt<vl) + time = 10; + else + { + time = - log((m_VS.Value()-vt)/(m_VS.Value()-vl)) * m_R.Value() * m_C.Value() * 1.0e6; // in us + if (time < 10.0) + time = 10.0; + } + + OUTANALOG(m_Q, m_VS.Value() * 0.7, NLTIME_FROM_NS(100)); + OUTANALOG(m_THRESHOLD_OUT, m_VS.Value(), NLTIME_FROM_US(time )); + } + else if (m_last && !out) + { + OUTANALOG(m_Q, 0.25, NLTIME_FROM_NS(100)); + OUTANALOG(m_THRESHOLD_OUT, 0.0, NLTIME_FROM_NS(1)); + } + m_last = out; } diff --git a/src/emu/netlist/devices/nld_legacy.h b/src/emu/netlist/devices/nld_legacy.h index eb94dbfaba0..43cdd5f6be3 100644 --- a/src/emu/netlist/devices/nld_legacy.h +++ b/src/emu/netlist/devices/nld_legacy.h @@ -20,83 +20,83 @@ // ---------------------------------------------------------------------------------------- #define NETDEV_RSFF(_name, _S, _R) \ - NET_REGISTER_DEV(nicRSFF, _name) \ - NET_CONNECT(_name, S, _S) \ - NET_CONNECT(_name, R, _R) + NET_REGISTER_DEV(nicRSFF, _name) \ + NET_CONNECT(_name, S, _S) \ + NET_CONNECT(_name, R, _R) #define NE555N_MSTABLE(_name, _TRIG, _CV) \ - NET_REGISTER_DEV(nicNE555N_MSTABLE, _name) \ - NET_CONNECT(_name, TRIG, _TRIG) \ - NET_CONNECT(_name, CV, _CV) + NET_REGISTER_DEV(nicNE555N_MSTABLE, _name) \ + NET_CONNECT(_name, TRIG, _TRIG) \ + NET_CONNECT(_name, CV, _CV) #define NETDEV_MIXER3(_name, _I1, _I2, _I3) \ - NET_REGISTER_DEV(nicMixer8, _name) \ - NET_CONNECT(_name, I1, _I1) \ - NET_CONNECT(_name, I2, _I2) \ - NET_CONNECT(_name, I3, _I3) + NET_REGISTER_DEV(nicMixer8, _name) \ + NET_CONNECT(_name, I1, _I1) \ + NET_CONNECT(_name, I2, _I2) \ + NET_CONNECT(_name, I3, _I3) #define NETDEV_SWITCH2(_name, _i1, _i2) \ - NET_REGISTER_DEV(nicMultiSwitch, _name) \ - NET_CONNECT(_name, i1, _i1) \ - NET_CONNECT(_name, i2, _i2) + NET_REGISTER_DEV(nicMultiSwitch, _name) \ + NET_CONNECT(_name, i1, _i1) \ + NET_CONNECT(_name, i2, _i2) // ---------------------------------------------------------------------------------------- // Devices ... // ---------------------------------------------------------------------------------------- NETLIB_DEVICE(nicRSFF, - netlist_ttl_input_t m_S; - netlist_ttl_input_t m_R; + netlist_ttl_input_t m_S; + netlist_ttl_input_t m_R; - netlist_ttl_output_t m_Q; - netlist_ttl_output_t m_QQ; + netlist_ttl_output_t m_Q; + netlist_ttl_output_t m_QQ; ); NETLIB_DEVICE_WITH_PARAMS(nicMixer8, - netlist_analog_input_t m_I[8]; + netlist_analog_input_t m_I[8]; - netlist_analog_output_t m_Q; - netlist_analog_output_t m_low; + netlist_analog_output_t m_Q; + netlist_analog_output_t m_low; - netlist_param_double_t m_R[8]; + netlist_param_double_t m_R[8]; - double m_w[8]; + double m_w[8]; ); NETLIB_DEVICE_WITH_PARAMS(nicNE555N_MSTABLE, - //ATTR_HOT void timer_cb(INT32 timer_id); + //ATTR_HOT void timer_cb(INT32 timer_id); - netlist_analog_input_t m_trigger; - netlist_analog_input_t m_CV; - netlist_analog_input_t m_THRESHOLD; /* internal */ + netlist_analog_input_t m_trigger; + netlist_analog_input_t m_CV; + netlist_analog_input_t m_THRESHOLD; /* internal */ - bool m_last; + bool m_last; - netlist_analog_output_t m_Q; - netlist_analog_output_t m_THRESHOLD_OUT; /* internal */ + netlist_analog_output_t m_Q; + netlist_analog_output_t m_THRESHOLD_OUT; /* internal */ - //netlist_base_timer_t *m_timer; - netlist_param_double_t m_R; - netlist_param_double_t m_C; - netlist_param_double_t m_VS; - netlist_param_double_t m_VL; + //netlist_base_timer_t *m_timer; + netlist_param_double_t m_R; + netlist_param_double_t m_C; + netlist_param_double_t m_VS; + netlist_param_double_t m_VL; - double nicNE555N_cv(); - double nicNE555N_clamp(const double v, const double a, const double b); + double nicNE555N_cv(); + double nicNE555N_clamp(const double v, const double a, const double b); ); NETLIB_DEVICE_WITH_PARAMS(nicMultiSwitch, - netlist_analog_input_t m_I[8]; + netlist_analog_input_t m_I[8]; - netlist_analog_output_t m_Q; - netlist_analog_output_t m_low; + netlist_analog_output_t m_Q; + netlist_analog_output_t m_low; - netlist_param_int_t m_POS; + netlist_param_int_t m_POS; - int m_position; + int m_position; ); diff --git a/src/emu/netlist/devices/nld_log.c b/src/emu/netlist/devices/nld_log.c index e175c4670a8..837923154ab 100644 --- a/src/emu/netlist/devices/nld_log.c +++ b/src/emu/netlist/devices/nld_log.c @@ -10,31 +10,31 @@ NETLIB_START(log) { - register_input("I", m_I); + register_input("I", m_I); - pstring filename = "netlist_" + name() + ".log"; - m_file = fopen(filename, "w"); + pstring filename = "netlist_" + name() + ".log"; + m_file = fopen(filename, "w"); } NETLIB_UPDATE(log) { - fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I)); + fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I)); } NETLIB_NAME(log)::~NETLIB_NAME(log)() { - fclose(m_file); + fclose(m_file); } NETLIB_START(logD) { - NETLIB_NAME(log)::start(); - register_input("I2", m_I2); + NETLIB_NAME(log)::start(); + register_input("I2", m_I2); } NETLIB_UPDATE(logD) { - fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I) - INPANALOG(m_I2)); + fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I) - INPANALOG(m_I2)); } // FIXME: Implement wav later, this must be clock triggered device where the input to be written @@ -42,19 +42,19 @@ NETLIB_UPDATE(logD) #if 0 NETLIB_START(wav) { - register_input("I", m_I); + register_input("I", m_I); - pstring filename = "netlist_" + name() + ".wav"; - m_file = wav_open(filename, sample_rate(), active_inputs()/2) + pstring filename = "netlist_" + name() + ".wav"; + m_file = wav_open(filename, sample_rate(), active_inputs()/2) } NETLIB_UPDATE(wav) { - fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I)); + fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I)); } NETLIB_NAME(log)::~NETLIB_NAME(wav)() { - fclose(m_file); + fclose(m_file); } #endif diff --git a/src/emu/netlist/devices/nld_log.h b/src/emu/netlist/devices/nld_log.h index f8910f51112..16d389263b8 100644 --- a/src/emu/netlist/devices/nld_log.h +++ b/src/emu/netlist/devices/nld_log.h @@ -21,32 +21,32 @@ #include "../nl_base.h" #define NETDEV_LOG(_name, _I) \ - NET_REGISTER_DEV(log, _name) \ - NET_CONNECT(_name, I, _I) + NET_REGISTER_DEV(log, _name) \ + NET_CONNECT(_name, I, _I) NETLIB_DEVICE(log, - ~NETLIB_NAME(log)(); - netlist_analog_input_t m_I; + ~NETLIB_NAME(log)(); + netlist_analog_input_t m_I; protected: - FILE *m_file; + FILE *m_file; ); #define NETDEV_LOGD(_name, _I, _I2) \ - NET_REGISTER_DEV(logD, _name) \ - NET_CONNECT(_name, I, _I) \ - NET_CONNECT(_name, I2, _I2) + NET_REGISTER_DEV(logD, _name) \ + NET_CONNECT(_name, I, _I) \ + NET_CONNECT(_name, I2, _I2) NETLIB_DEVICE_DERIVED(logD, log, - netlist_analog_input_t m_I2; + netlist_analog_input_t m_I2; ); #if 0 NETLIB_DEVICE(wav, - ~NETLIB_NAME(wav)(); - netlist_analog_input_t m_I; + ~NETLIB_NAME(wav)(); + netlist_analog_input_t m_I; private: - // FIXME: rewrite sound/wavwrite.h to be an object ... - void *m_file; + // FIXME: rewrite sound/wavwrite.h to be an object ... + void *m_file; ); #endif diff --git a/src/emu/netlist/devices/nld_ne555.c b/src/emu/netlist/devices/nld_ne555.c index 06a616f2bb9..4eb20c75980 100644 --- a/src/emu/netlist/devices/nld_ne555.c +++ b/src/emu/netlist/devices/nld_ne555.c @@ -11,74 +11,73 @@ inline double NETLIB_NAME(NE555)::clamp(const double v, const double a, const double b) { - double ret = v; - double vcc = TERMANALOG(m_R1.m_P); + double ret = v; + double vcc = TERMANALOG(m_R1.m_P); - if (ret > vcc - a) - ret = vcc - a; - if (ret < b) - ret = b; - return ret; + if (ret > vcc - a) + ret = vcc - a; + if (ret < b) + ret = b; + return ret; } NETLIB_START(NE555) { + register_sub(m_R1, "R1"); + register_sub(m_R2, "R2"); + register_sub(m_R3, "R3"); + register_sub(m_RDIS, "RDIS"); - register_sub(m_R1, "R1"); - register_sub(m_R2, "R2"); - register_sub(m_R3, "R3"); - register_sub(m_RDIS, "RDIS"); + register_subalias("GND", m_R3.m_N); // Pin 1 + register_input("TRIG", m_TRIG); // Pin 2 + register_output("OUT", m_OUT); // Pin 3 + register_input("RESET", m_RESET); // Pin 4 + register_subalias("CONT", m_R1.m_N); // Pin 5 + register_input("THRESH", m_THRES); // Pin 6 + register_subalias("DISCH", m_RDIS.m_P); // Pin 7 + register_subalias("VCC", m_R1.m_P); // Pin 8 - register_subalias("GND", m_R3.m_N); // Pin 1 - register_input("TRIG", m_TRIG); // Pin 2 - register_output("OUT", m_OUT); // Pin 3 - register_input("RESET", m_RESET); // Pin 4 - register_subalias("CONT", m_R1.m_N); // Pin 5 - register_input("THRESH", m_THRES); // Pin 6 - register_subalias("DISCH", m_RDIS.m_P); // Pin 7 - register_subalias("VCC", m_R1.m_P); // Pin 8 + m_R1.set_R(5000); + m_R2.set_R(5000); + m_R3.set_R(5000); + m_RDIS.set_R(R_OFF); - m_R1.set_R(5000); - m_R2.set_R(5000); - m_R3.set_R(5000); - m_RDIS.set_R(R_OFF); + setup().connect(m_R1.m_N, m_R2.m_P); + setup().connect(m_R2.m_N, m_R3.m_P); + setup().connect(m_RDIS.m_N, m_R3.m_N); - setup().connect(m_R1.m_N, m_R2.m_P); - setup().connect(m_R2.m_N, m_R3.m_P); - setup().connect(m_RDIS.m_N, m_R3.m_N); + m_last_out = false; - m_last_out = false; - - save(NAME(m_last_out)); + save(NAME(m_last_out)); } NETLIB_UPDATE(NE555) { - // FIXME: assumes GND is connected to 0V. + // FIXME: assumes GND is connected to 0V. - double vt = clamp(TERMANALOG(m_R2.m_P), 0.7, 1.4); - bool bthresh = (INPANALOG(m_THRES) > vt); - bool btrig = (INPANALOG(m_TRIG) > clamp(TERMANALOG(m_R2.m_N), 0.7, 1.4)); - bool out = m_last_out; + double vt = clamp(TERMANALOG(m_R2.m_P), 0.7, 1.4); + bool bthresh = (INPANALOG(m_THRES) > vt); + bool btrig = (INPANALOG(m_TRIG) > clamp(TERMANALOG(m_R2.m_N), 0.7, 1.4)); + bool out = m_last_out; - if (!btrig) - { - out = true; - } - else if (bthresh) - { - out = false; - } + if (!btrig) + { + out = true; + } + else if (bthresh) + { + out = false; + } - if (!m_last_out && out) - { - OUTANALOG(m_OUT, TERMANALOG(m_R1.m_P), NLTIME_FROM_NS(100)); - m_RDIS.set_R(R_OFF); - } - else if (m_last_out && !out) - { - OUTANALOG(m_OUT, TERMANALOG(m_R3.m_N), NLTIME_FROM_NS(100)); - m_RDIS.set_R(R_ON); - } - m_last_out = out; + if (!m_last_out && out) + { + OUTANALOG(m_OUT, TERMANALOG(m_R1.m_P), NLTIME_FROM_NS(100)); + m_RDIS.set_R(R_OFF); + } + else if (m_last_out && !out) + { + OUTANALOG(m_OUT, TERMANALOG(m_R3.m_N), NLTIME_FROM_NS(100)); + m_RDIS.set_R(R_ON); + } + m_last_out = out; } diff --git a/src/emu/netlist/devices/nld_ne555.h b/src/emu/netlist/devices/nld_ne555.h index a350a684c28..487e8d33789 100644 --- a/src/emu/netlist/devices/nld_ne555.h +++ b/src/emu/netlist/devices/nld_ne555.h @@ -23,22 +23,21 @@ #include "nld_twoterm.h" #define NETDEV_NE555(_name) \ - NET_REGISTER_DEV(NE555, _name) \ - + NET_REGISTER_DEV(NE555, _name) NETLIB_DEVICE(NE555, - NETLIB_NAME(R) m_R1; - NETLIB_NAME(R) m_R2; - NETLIB_NAME(R) m_R3; - NETLIB_NAME(R) m_RDIS; + NETLIB_NAME(R) m_R1; + NETLIB_NAME(R) m_R2; + NETLIB_NAME(R) m_R3; + NETLIB_NAME(R) m_RDIS; - netlist_logic_input_t m_RESET; - netlist_analog_input_t m_THRES; - netlist_analog_input_t m_TRIG; - netlist_analog_output_t m_OUT; + netlist_logic_input_t m_RESET; + netlist_analog_input_t m_THRES; + netlist_analog_input_t m_TRIG; + netlist_analog_output_t m_OUT; - bool m_last_out; + bool m_last_out; - double clamp(const double v, const double a, const double b); + double clamp(const double v, const double a, const double b); ); diff --git a/src/emu/netlist/devices/nld_signal.h b/src/emu/netlist/devices/nld_signal.h index a9e99ec381d..e54eaac7372 100644 --- a/src/emu/netlist/devices/nld_signal.h +++ b/src/emu/netlist/devices/nld_signal.h @@ -93,7 +93,7 @@ public: { register_input(sIN[i], m_i[i]); } - save(NAME(m_active)); + save(NAME(m_active)); } #if (USE_DEACTIVE_DEVICE) @@ -167,7 +167,7 @@ public: { register_input(sIN[i], m_i[i], netlist_input_t::STATE_INP_ACTIVE); } - save(NAME(m_active)); + save(NAME(m_active)); } #if (USE_DEACTIVE_DEVICE) diff --git a/src/emu/netlist/devices/nld_solver.c b/src/emu/netlist/devices/nld_solver.c index b02f5e4d701..7c8ed65d0e5 100644 --- a/src/emu/netlist/devices/nld_solver.c +++ b/src/emu/netlist/devices/nld_solver.c @@ -15,155 +15,155 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &aowner) { - m_owner = &aowner; - for (netlist_net_t::list_t::entry_t *pn = nets.first(); pn != NULL; pn = nets.next(pn)) - { - NL_VERBOSE_OUT(("setting up net\n")); - - m_nets.add(pn->object()); - pn->object()->m_solver = this; - - for (netlist_core_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next) - { - switch (p->type()) - { - case netlist_terminal_t::TERMINAL: - switch (p->netdev().family()) - { - case netlist_device_t::CAPACITOR: - if (!m_steps.contains(&p->netdev())) - m_steps.add(&p->netdev()); - break; - case netlist_device_t::DIODE: - //case netlist_device_t::VCVS: - //case netlist_device_t::BJT_SWITCH: - if (!m_dynamic.contains(&p->netdev())) - m_dynamic.add(&p->netdev()); - break; - default: - break; - } - pn->object()->m_terms.add(static_cast<netlist_terminal_t *>(p)); - NL_VERBOSE_OUT(("Added terminal\n")); - break; - case netlist_terminal_t::INPUT: - if (!m_inps.contains(&p->netdev())) - m_inps.add(&p->netdev()); - NL_VERBOSE_OUT(("Added input\n")); - break; - default: - owner().netlist().xfatalerror("unhandled element found\n"); - break; - } - } - } + m_owner = &aowner; + for (netlist_net_t::list_t::entry_t *pn = nets.first(); pn != NULL; pn = nets.next(pn)) + { + NL_VERBOSE_OUT(("setting up net\n")); + + m_nets.add(pn->object()); + pn->object()->m_solver = this; + + for (netlist_core_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next) + { + switch (p->type()) + { + case netlist_terminal_t::TERMINAL: + switch (p->netdev().family()) + { + case netlist_device_t::CAPACITOR: + if (!m_steps.contains(&p->netdev())) + m_steps.add(&p->netdev()); + break; + case netlist_device_t::DIODE: + //case netlist_device_t::VCVS: + //case netlist_device_t::BJT_SWITCH: + if (!m_dynamic.contains(&p->netdev())) + m_dynamic.add(&p->netdev()); + break; + default: + break; + } + pn->object()->m_terms.add(static_cast<netlist_terminal_t *>(p)); + NL_VERBOSE_OUT(("Added terminal\n")); + break; + case netlist_terminal_t::INPUT: + if (!m_inps.contains(&p->netdev())) + m_inps.add(&p->netdev()); + NL_VERBOSE_OUT(("Added input\n")); + break; + default: + owner().netlist().xfatalerror("unhandled element found\n"); + break; + } + } + } } ATTR_HOT inline void netlist_matrix_solver_t::step(const netlist_time delta) { - const double dd = delta.as_double(); - for (dev_list_t::entry_t *p = m_steps.first(); p != NULL; p = m_steps.next(p)) - p->object()->step_time(dd); + const double dd = delta.as_double(); + for (dev_list_t::entry_t *p = m_steps.first(); p != NULL; p = m_steps.next(p)) + p->object()->step_time(dd); } ATTR_HOT inline void netlist_matrix_solver_t::update_inputs() { - for (dev_list_t::entry_t *p = m_inps.first(); p != NULL; p = m_inps.next(p)) - p->object()->update_dev(); + for (dev_list_t::entry_t *p = m_inps.first(); p != NULL; p = m_inps.next(p)) + p->object()->update_dev(); } ATTR_HOT inline bool netlist_matrix_solver_t::solve() { - bool resched = false; - - /* update all non-linear devices */ - for (dev_list_t::entry_t *p = m_dynamic.first(); p != NULL; p = m_dynamic.next(p)) - switch (p->object()->family()) - { - case netlist_device_t::DIODE: - static_cast<NETLIB_NAME(D) *>(p->object())->update_terminals(); - break; - default: - p->object()->update_terminals(); - break; - } - - for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn)) - { - netlist_net_t *net = pn->object(); - - double gtot = 0; - double gabs = 0; - double iIdr = 0; - const netlist_net_t::terminal_list_t &terms = net->m_terms; + bool resched = false; + + /* update all non-linear devices */ + for (dev_list_t::entry_t *p = m_dynamic.first(); p != NULL; p = m_dynamic.next(p)) + switch (p->object()->family()) + { + case netlist_device_t::DIODE: + static_cast<NETLIB_NAME(D) *>(p->object())->update_terminals(); + break; + default: + p->object()->update_terminals(); + break; + } + + for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn)) + { + netlist_net_t *net = pn->object(); + + double gtot = 0; + double gabs = 0; + double iIdr = 0; + const netlist_net_t::terminal_list_t &terms = net->m_terms; #if 1 - switch (terms.count()) - { - case 1: - { - const netlist_terminal_t *pt = terms.first()->object(); - gtot = pt->m_gt; - gabs = fabs(pt->m_go); - iIdr = pt->m_Idr + pt->m_go * pt->m_otherterm->net().Q_Analog(); - } - break; - case 2: - { - const netlist_terminal_t *pt1 = terms[0]; - const netlist_terminal_t *pt2 = terms[1]; - gtot = pt1->m_gt + pt2->m_gt; - gabs = fabs(pt1->m_go) + fabs(pt2->m_go); - iIdr = pt1->m_Idr + pt1->m_go * pt1->m_otherterm->net().Q_Analog() - + pt2->m_Idr + pt2->m_go * pt2->m_otherterm->net().Q_Analog(); - } - break; - case 3: - { - const netlist_terminal_t *pt1 = terms[0]; - const netlist_terminal_t *pt2 = terms[1]; - const netlist_terminal_t *pt3 = terms[2]; - gtot = pt1->m_gt + pt2->m_gt + pt3->m_gt; - gabs = fabs(pt1->m_go) + fabs(pt2->m_go) + fabs(pt3->m_go); - iIdr = pt1->m_Idr + pt1->m_go * pt1->m_otherterm->net().Q_Analog() - + pt2->m_Idr + pt2->m_go * pt2->m_otherterm->net().Q_Analog() - + pt3->m_Idr + pt3->m_go * pt3->m_otherterm->net().Q_Analog(); - } - break; - default: - for (netlist_net_t::terminal_list_t::entry_t *e = terms.first(); e != NULL; e = terms.next(e)) - { - netlist_terminal_t *pt = e->object(); - gtot += pt->m_gt; - gabs += fabs(pt->m_go); - iIdr += pt->m_Idr + pt->m_go * pt->m_otherterm->net().Q_Analog(); - } - break; - } + switch (terms.count()) + { + case 1: + { + const netlist_terminal_t *pt = terms.first()->object(); + gtot = pt->m_gt; + gabs = fabs(pt->m_go); + iIdr = pt->m_Idr + pt->m_go * pt->m_otherterm->net().Q_Analog(); + } + break; + case 2: + { + const netlist_terminal_t *pt1 = terms[0]; + const netlist_terminal_t *pt2 = terms[1]; + gtot = pt1->m_gt + pt2->m_gt; + gabs = fabs(pt1->m_go) + fabs(pt2->m_go); + iIdr = pt1->m_Idr + pt1->m_go * pt1->m_otherterm->net().Q_Analog() + + pt2->m_Idr + pt2->m_go * pt2->m_otherterm->net().Q_Analog(); + } + break; + case 3: + { + const netlist_terminal_t *pt1 = terms[0]; + const netlist_terminal_t *pt2 = terms[1]; + const netlist_terminal_t *pt3 = terms[2]; + gtot = pt1->m_gt + pt2->m_gt + pt3->m_gt; + gabs = fabs(pt1->m_go) + fabs(pt2->m_go) + fabs(pt3->m_go); + iIdr = pt1->m_Idr + pt1->m_go * pt1->m_otherterm->net().Q_Analog() + + pt2->m_Idr + pt2->m_go * pt2->m_otherterm->net().Q_Analog() + + pt3->m_Idr + pt3->m_go * pt3->m_otherterm->net().Q_Analog(); + } + break; + default: + for (netlist_net_t::terminal_list_t::entry_t *e = terms.first(); e != NULL; e = terms.next(e)) + { + netlist_terminal_t *pt = e->object(); + gtot += pt->m_gt; + gabs += fabs(pt->m_go); + iIdr += pt->m_Idr + pt->m_go * pt->m_otherterm->net().Q_Analog(); + } + break; + } #else - for (netlist_net_t::terminal_list_t::entry_t *e = terms.first(); e != NULL; e = terms.next(e)) - { - netlist_terminal_t *pt = e->object(); - gtot += pt->m_gt; - gabs += fabs(pt->m_go); - iIdr += pt->m_Idr + pt->m_go * pt->m_otherterm->net().Q_Analog(); - } + for (netlist_net_t::terminal_list_t::entry_t *e = terms.first(); e != NULL; e = terms.next(e)) + { + netlist_terminal_t *pt = e->object(); + gtot += pt->m_gt; + gabs += fabs(pt->m_go); + iIdr += pt->m_Idr + pt->m_go * pt->m_otherterm->net().Q_Analog(); + } #endif - double new_val; - gabs *= m_convergence_factor; - if (gabs > gtot) - new_val = (net->m_cur.Analog * gabs + iIdr) / (gtot + gabs); - else - new_val = iIdr / gtot; - - if (fabs(new_val - net->m_cur.Analog) > m_accuracy) - resched = true; - net->m_cur.Analog = net->m_new.Analog = new_val; - - NL_VERBOSE_OUT(("Info: %d\n", pn->object()->m_num_cons)); - //NL_VERBOSE_OUT(("New: %lld %f %f\n", netlist().time().as_raw(), netlist().time().as_double(), new_val)); - } - return resched; + double new_val; + gabs *= m_convergence_factor; + if (gabs > gtot) + new_val = (net->m_cur.Analog * gabs + iIdr) / (gtot + gabs); + else + new_val = iIdr / gtot; + + if (fabs(new_val - net->m_cur.Analog) > m_accuracy) + resched = true; + net->m_cur.Analog = net->m_new.Analog = new_val; + + NL_VERBOSE_OUT(("Info: %d\n", pn->object()->m_num_cons)); + //NL_VERBOSE_OUT(("New: %lld %f %f\n", netlist().time().as_raw(), netlist().time().as_double(), new_val)); + } + return resched; } // ---------------------------------------------------------------------------------------- @@ -174,160 +174,159 @@ typedef netlist_net_t::list_t *net_groups_t; static bool already_processed(net_groups_t groups, int &cur_group, netlist_net_t *net) { - if (net->isRailNet()) - return true; - for (int i = 0; i <= cur_group; i++) - { - if (groups[i].contains(net)) - return true; - } - return false; + if (net->isRailNet()) + return true; + for (int i = 0; i <= cur_group; i++) + { + if (groups[i].contains(net)) + return true; + } + return false; } static void process_net(net_groups_t groups, int &cur_group, netlist_net_t *net) { - /* add the net */ - if (net->m_head == NULL) - return; - groups[cur_group].add(net); - for (netlist_core_terminal_t *p = net->m_head; p != NULL; p = p->m_update_list_next) - { - if (p->isType(netlist_terminal_t::TERMINAL)) - { - netlist_terminal_t *pt = static_cast<netlist_terminal_t *>(p); - netlist_net_t *nnet = &pt->m_otherterm->net(); - if (!already_processed(groups, cur_group, nnet)) - process_net(groups, cur_group, nnet); - } - } + /* add the net */ + if (net->m_head == NULL) + return; + groups[cur_group].add(net); + for (netlist_core_terminal_t *p = net->m_head; p != NULL; p = p->m_update_list_next) + { + if (p->isType(netlist_terminal_t::TERMINAL)) + { + netlist_terminal_t *pt = static_cast<netlist_terminal_t *>(p); + netlist_net_t *nnet = &pt->m_otherterm->net(); + if (!already_processed(groups, cur_group, nnet)) + process_net(groups, cur_group, nnet); + } + } } NETLIB_START(solver) { - register_output("Q_sync", m_Q_sync); - register_output("Q_step", m_Q_step); - //register_input("FB", m_feedback); + register_output("Q_sync", m_Q_sync); + register_output("Q_step", m_Q_step); + //register_input("FB", m_feedback); - register_param("SYNC_DELAY", m_sync_delay, NLTIME_FROM_NS(10).as_double()); - m_nt_sync_delay = m_sync_delay.Value(); + register_param("SYNC_DELAY", m_sync_delay, NLTIME_FROM_NS(10).as_double()); + m_nt_sync_delay = m_sync_delay.Value(); - register_param("FREQ", m_freq, 48000.0); - m_inc = netlist_time::from_hz(m_freq.Value()); + register_param("FREQ", m_freq, 48000.0); + m_inc = netlist_time::from_hz(m_freq.Value()); - register_param("ACCURACY", m_accuracy, 1e-3); - register_param("CONVERG", m_convergence, 0.3); + register_param("ACCURACY", m_accuracy, 1e-3); + register_param("CONVERG", m_convergence, 0.3); - // internal staff + // internal staff - register_input("FB_sync", m_fb_sync, netlist_input_t::STATE_INP_ACTIVE); - register_input("FB_step", m_fb_step, netlist_input_t::STATE_INP_ACTIVE); + register_input("FB_sync", m_fb_sync, netlist_input_t::STATE_INP_ACTIVE); + register_input("FB_step", m_fb_step, netlist_input_t::STATE_INP_ACTIVE); - setup().connect(m_fb_sync, m_Q_sync); - setup().connect(m_fb_step, m_Q_step); + setup().connect(m_fb_sync, m_Q_sync); + setup().connect(m_fb_step, m_Q_step); - m_last_step = netlist_time::zero; + m_last_step = netlist_time::zero; - save(NAME(m_last_step)); + save(NAME(m_last_step)); } NETLIB_UPDATE_PARAM(solver) { - m_inc = netlist_time::from_hz(m_freq.Value()); + m_inc = netlist_time::from_hz(m_freq.Value()); } NETLIB_NAME(solver)::~NETLIB_NAME(solver)() { - netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); - while (e != NULL) - { - netlist_matrix_solver_t::list_t::entry_t *en = m_mat_solvers.next(e); - delete e->object(); - e = en; - } + netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); + while (e != NULL) + { + netlist_matrix_solver_t::list_t::entry_t *en = m_mat_solvers.next(e); + delete e->object(); + e = en; + } } NETLIB_FUNC_VOID(solver, post_start, ()) { - netlist_net_t::list_t groups[100]; - int cur_group = -1; - - SOLVER_VERBOSE_OUT(("Scanning net groups ...\n")); - // determine net groups - for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn)) - { - if (!already_processed(groups, cur_group, pn->object())) - { - cur_group++; - process_net(groups, cur_group, pn->object()); - } - } - - // setup the solvers - SOLVER_VERBOSE_OUT(("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count())); - for (int i = 0; i <= cur_group; i++) - { - netlist_matrix_solver_t *ms = new netlist_matrix_solver_t(); - ms->m_accuracy = m_accuracy.Value(); - ms->m_convergence_factor = m_convergence.Value(); - ms->setup(groups[i], *this); - m_mat_solvers.add(ms); - SOLVER_VERBOSE_OUT(("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr())); - SOLVER_VERBOSE_OUT((" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic")); - } + netlist_net_t::list_t groups[100]; + int cur_group = -1; + + SOLVER_VERBOSE_OUT(("Scanning net groups ...\n")); + // determine net groups + for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn)) + { + if (!already_processed(groups, cur_group, pn->object())) + { + cur_group++; + process_net(groups, cur_group, pn->object()); + } + } + + // setup the solvers + SOLVER_VERBOSE_OUT(("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count())); + for (int i = 0; i <= cur_group; i++) + { + netlist_matrix_solver_t *ms = new netlist_matrix_solver_t(); + ms->m_accuracy = m_accuracy.Value(); + ms->m_convergence_factor = m_convergence.Value(); + ms->setup(groups[i], *this); + m_mat_solvers.add(ms); + SOLVER_VERBOSE_OUT(("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr())); + SOLVER_VERBOSE_OUT((" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic")); + } } NETLIB_UPDATE(solver) { - //m_Q.setToNoCheck(!m_Q.new_Q(), m_inc ); - //OUTLOGIC(m_Q, !m_Q.net().new_Q(), m_inc ); - - bool resched = false; - int resched_cnt = 0; - netlist_time now = netlist().time(); - netlist_time delta = now - m_last_step; - - if (delta >= m_inc) - { - NL_VERBOSE_OUT(("Step!\n")); - /* update all terminals for new time step */ - m_last_step = now; - for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e)) - { - e->object()->step(delta); - } - } - bool global_resched = false; - for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e)) - { - resched_cnt = (e->object()->is_dynamic() ? 0 : 1); - do { - resched = e->object()->solve(); - resched_cnt++; - } while ((resched && (resched_cnt < 5)) || (resched_cnt <= 1)); - global_resched = global_resched || resched; - } - //if (global_resched) - // printf("rescheduled\n"); - if (global_resched) - { - schedule(); - } - else - { - /* update all inputs connected */ - for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e)) - { - e->object()->update_inputs(); - } - - /* step circuit */ - if (!m_Q_step.net().is_queued()) - m_Q_step.net().push_to_queue(m_inc); - } + //m_Q.setToNoCheck(!m_Q.new_Q(), m_inc ); + //OUTLOGIC(m_Q, !m_Q.net().new_Q(), m_inc ); + + bool resched = false; + int resched_cnt = 0; + netlist_time now = netlist().time(); + netlist_time delta = now - m_last_step; + + if (delta >= m_inc) + { + NL_VERBOSE_OUT(("Step!\n")); + /* update all terminals for new time step */ + m_last_step = now; + for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e)) + { + e->object()->step(delta); + } + } + bool global_resched = false; + for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e)) + { + resched_cnt = (e->object()->is_dynamic() ? 0 : 1); + do { + resched = e->object()->solve(); + resched_cnt++; + } while ((resched && (resched_cnt < 5)) || (resched_cnt <= 1)); + global_resched = global_resched || resched; + } + //if (global_resched) + // printf("rescheduled\n"); + if (global_resched) + { + schedule(); + } + else + { + /* update all inputs connected */ + for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e)) + { + e->object()->update_inputs(); + } + + /* step circuit */ + if (!m_Q_step.net().is_queued()) + m_Q_step.net().push_to_queue(m_inc); + } } - diff --git a/src/emu/netlist/devices/nld_solver.h b/src/emu/netlist/devices/nld_solver.h index 55216f70143..0f9d0f54c28 100644 --- a/src/emu/netlist/devices/nld_solver.h +++ b/src/emu/netlist/devices/nld_solver.h @@ -14,7 +14,7 @@ // ---------------------------------------------------------------------------------------- #define NETDEV_SOLVER(_name) \ - NET_REGISTER_DEV(solver, _name) + NET_REGISTER_DEV(solver, _name) // ---------------------------------------------------------------------------------------- // solver @@ -25,70 +25,70 @@ class NETLIB_NAME(solver); class netlist_matrix_solver_t { public: - typedef netlist_list_t<netlist_matrix_solver_t *> list_t; - typedef netlist_core_device_t::list_t dev_list_t; + typedef netlist_list_t<netlist_matrix_solver_t *> list_t; + typedef netlist_core_device_t::list_t dev_list_t; - ATTR_COLD void setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &owner); + ATTR_COLD void setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &owner); - // return true if a reschedule is needed ... - ATTR_HOT bool solve(); - ATTR_HOT void step(const netlist_time delta); - ATTR_HOT void update_inputs(); + // return true if a reschedule is needed ... + ATTR_HOT bool solve(); + ATTR_HOT void step(const netlist_time delta); + ATTR_HOT void update_inputs(); - ATTR_HOT inline bool is_dynamic() { return m_dynamic.count() > 0; } + ATTR_HOT inline bool is_dynamic() { return m_dynamic.count() > 0; } - inline const NETLIB_NAME(solver) &owner() const; + inline const NETLIB_NAME(solver) &owner() const; - double m_accuracy; - double m_convergence_factor; + double m_accuracy; + double m_convergence_factor; private: - netlist_net_t::list_t m_nets; - dev_list_t m_dynamic; - dev_list_t m_inps; - dev_list_t m_steps; + netlist_net_t::list_t m_nets; + dev_list_t m_dynamic; + dev_list_t m_inps; + dev_list_t m_steps; - NETLIB_NAME(solver) *m_owner; + NETLIB_NAME(solver) *m_owner; }; NETLIB_DEVICE_WITH_PARAMS(solver, - typedef netlist_core_device_t::list_t dev_list_t; + typedef netlist_core_device_t::list_t dev_list_t; - netlist_ttl_input_t m_fb_sync; - netlist_ttl_output_t m_Q_sync; + netlist_ttl_input_t m_fb_sync; + netlist_ttl_output_t m_Q_sync; - netlist_ttl_input_t m_fb_step; - netlist_ttl_output_t m_Q_step; + netlist_ttl_input_t m_fb_step; + netlist_ttl_output_t m_Q_step; - netlist_param_double_t m_freq; - netlist_param_double_t m_sync_delay; - netlist_param_double_t m_accuracy; - netlist_param_double_t m_convergence; + netlist_param_double_t m_freq; + netlist_param_double_t m_sync_delay; + netlist_param_double_t m_accuracy; + netlist_param_double_t m_convergence; - netlist_time m_inc; - netlist_time m_last_step; - netlist_time m_nt_sync_delay; + netlist_time m_inc; + netlist_time m_last_step; + netlist_time m_nt_sync_delay; - netlist_matrix_solver_t::list_t m_mat_solvers; + netlist_matrix_solver_t::list_t m_mat_solvers; public: - ~NETLIB_NAME(solver)(); + ~NETLIB_NAME(solver)(); - ATTR_HOT inline void schedule(); + ATTR_HOT inline void schedule(); - ATTR_COLD void post_start(); + ATTR_COLD void post_start(); ); inline void NETLIB_NAME(solver)::schedule() { - // FIXME: time should be parameter; - if (!m_Q_sync.net().is_queued()) - m_Q_sync.net().push_to_queue(m_nt_sync_delay); + // FIXME: time should be parameter; + if (!m_Q_sync.net().is_queued()) + m_Q_sync.net().push_to_queue(m_nt_sync_delay); } inline const NETLIB_NAME(solver) &netlist_matrix_solver_t::owner() const { - return *m_owner; + return *m_owner; } diff --git a/src/emu/netlist/devices/nld_system.c b/src/emu/netlist/devices/nld_system.c index f1ab75e9f8e..33bef136082 100644 --- a/src/emu/netlist/devices/nld_system.c +++ b/src/emu/netlist/devices/nld_system.c @@ -12,8 +12,8 @@ NETLIB_START(ttl_const) { - register_output("Q", m_Q); - register_param("CONST", m_const, 0); + register_output("Q", m_Q); + register_param("CONST", m_const, 0); } NETLIB_UPDATE(ttl_const) @@ -22,13 +22,13 @@ NETLIB_UPDATE(ttl_const) NETLIB_UPDATE_PARAM(ttl_const) { - OUTLOGIC(m_Q, m_const.Value(), NLTIME_IMMEDIATE); + OUTLOGIC(m_Q, m_const.Value(), NLTIME_IMMEDIATE); } NETLIB_START(analog_const) { - register_output("Q", m_Q); - register_param("CONST", m_const, 0.0); + register_output("Q", m_Q); + register_param("CONST", m_const, 0.0); } NETLIB_UPDATE(analog_const) @@ -37,7 +37,7 @@ NETLIB_UPDATE(analog_const) NETLIB_UPDATE_PARAM(analog_const) { - m_Q.initial(m_const.Value()); + m_Q.initial(m_const.Value()); } // ---------------------------------------------------------------------------------------- @@ -46,24 +46,24 @@ NETLIB_UPDATE_PARAM(analog_const) NETLIB_START(clock) { - register_output("Q", m_Q); - //register_input("FB", m_feedback); + register_output("Q", m_Q); + //register_input("FB", m_feedback); - register_param("FREQ", m_freq, 7159000.0 * 5.0); - m_inc = netlist_time::from_hz(m_freq.Value()*2); + register_param("FREQ", m_freq, 7159000.0 * 5.0); + m_inc = netlist_time::from_hz(m_freq.Value()*2); - register_link_internal(m_feedback, m_Q, netlist_input_t::STATE_INP_ACTIVE); + register_link_internal(m_feedback, m_Q, netlist_input_t::STATE_INP_ACTIVE); } NETLIB_UPDATE_PARAM(clock) { - m_inc = netlist_time::from_hz(m_freq.Value()*2); + m_inc = netlist_time::from_hz(m_freq.Value()*2); } NETLIB_UPDATE(clock) { - OUTLOGIC(m_Q, !m_Q.net().new_Q(), m_inc ); + OUTLOGIC(m_Q, !m_Q.net().new_Q(), m_inc ); } // ---------------------------------------------------------------------------------------- @@ -72,7 +72,7 @@ NETLIB_UPDATE(clock) NETLIB_START(logic_input) { - register_output("Q", m_Q); + register_output("Q", m_Q); } NETLIB_UPDATE(logic_input) @@ -85,7 +85,7 @@ NETLIB_UPDATE(logic_input) NETLIB_START(analog_input) { - register_output("Q", m_Q); + register_output("Q", m_Q); } NETLIB_UPDATE(analog_input) diff --git a/src/emu/netlist/devices/nld_system.h b/src/emu/netlist/devices/nld_system.h index 0859d9cddef..323a10b4196 100644 --- a/src/emu/netlist/devices/nld_system.h +++ b/src/emu/netlist/devices/nld_system.h @@ -25,16 +25,16 @@ NETDEV_PARAM(_name.CONST, _v) #define NETDEV_MAINCLOCK(_name) \ - NET_REGISTER_DEV(mainclock, _name) + NET_REGISTER_DEV(mainclock, _name) #define NETDEV_CLOCK(_name) \ - NET_REGISTER_DEV(clock, _name) + NET_REGISTER_DEV(clock, _name) #define NETDEV_LOGIC_INPUT(_name) \ - NET_REGISTER_DEV(logic_input, _name) + NET_REGISTER_DEV(logic_input, _name) #define NETDEV_ANALOG_INPUT(_name) \ - NET_REGISTER_DEV(analog_input, _name) + NET_REGISTER_DEV(analog_input, _name) // ---------------------------------------------------------------------------------------- // netdev_*_const @@ -56,7 +56,7 @@ NETLIB_DEVICE_WITH_PARAMS(analog_const, NETLIB_DEVICE_WITH_PARAMS(mainclock, public: - netlist_ttl_output_t m_Q; + netlist_ttl_output_t m_Q; netlist_param_double_t m_freq; netlist_time m_inc; @@ -69,11 +69,11 @@ public: // ---------------------------------------------------------------------------------------- NETLIB_DEVICE_WITH_PARAMS(clock, - netlist_ttl_input_t m_feedback; - netlist_ttl_output_t m_Q; + netlist_ttl_input_t m_feedback; + netlist_ttl_output_t m_Q; - netlist_param_double_t m_freq; - netlist_time m_inc; + netlist_param_double_t m_freq; + netlist_time m_inc; ); @@ -82,11 +82,11 @@ NETLIB_DEVICE_WITH_PARAMS(clock, // ---------------------------------------------------------------------------------------- NETLIB_DEVICE(logic_input, - netlist_ttl_output_t m_Q; + netlist_ttl_output_t m_Q; ); NETLIB_DEVICE(analog_input, - netlist_analog_output_t m_Q; + netlist_analog_output_t m_Q; ); diff --git a/src/emu/netlist/devices/nld_twoterm.c b/src/emu/netlist/devices/nld_twoterm.c index ddf7fc128cd..67262ea0cdd 100644 --- a/src/emu/netlist/devices/nld_twoterm.c +++ b/src/emu/netlist/devices/nld_twoterm.c @@ -12,10 +12,10 @@ // ---------------------------------------------------------------------------------------- ATTR_COLD NETLIB_NAME(twoterm)::NETLIB_NAME(twoterm)(const family_t afamily) : - netlist_device_t(afamily) + netlist_device_t(afamily) { - m_P.m_otherterm = &m_N; - m_N.m_otherterm = &m_P; + m_P.m_otherterm = &m_N; + m_N.m_otherterm = &m_P; } NETLIB_START(twoterm) @@ -24,8 +24,8 @@ NETLIB_START(twoterm) NETLIB_UPDATE(twoterm) { - /* only called if connected to a rail net ==> notify the solver to recalculate */ - netlist().solver()->schedule(); + /* only called if connected to a rail net ==> notify the solver to recalculate */ + netlist().solver()->schedule(); } // ---------------------------------------------------------------------------------------- @@ -34,29 +34,29 @@ NETLIB_UPDATE(twoterm) NETLIB_START(R_base) { - register_terminal("1", m_P); - register_terminal("2", m_N); + register_terminal("1", m_P); + register_terminal("2", m_N); } NETLIB_UPDATE(R_base) { - NETLIB_NAME(twoterm)::update(); + NETLIB_NAME(twoterm)::update(); } NETLIB_START(R) { - NETLIB_NAME(R_base)::start(); - register_param("R", m_R, 1.0 / NETLIST_GMIN); + NETLIB_NAME(R_base)::start(); + register_param("R", m_R, 1.0 / NETLIST_GMIN); } NETLIB_UPDATE(R) { - NETLIB_NAME(twoterm)::update(); + NETLIB_NAME(twoterm)::update(); } NETLIB_UPDATE_PARAM(R) { - set_R(m_R.Value()); + set_R(m_R.Value()); } // ---------------------------------------------------------------------------------------- @@ -65,30 +65,30 @@ NETLIB_UPDATE_PARAM(R) NETLIB_START(POT) { - register_sub(m_R1, "R1"); - register_sub(m_R2, "R2"); + register_sub(m_R1, "R1"); + register_sub(m_R2, "R2"); - register_subalias("1", m_R1.m_P); - register_subalias("2", m_R1.m_N); - register_subalias("3", m_R2.m_N); + register_subalias("1", m_R1.m_P); + register_subalias("2", m_R1.m_N); + register_subalias("3", m_R2.m_N); - setup().connect(m_R2.m_P, m_R1.m_N); + setup().connect(m_R2.m_P, m_R1.m_N); - register_param("R", m_R, 1.0 / NETLIST_GMIN); - register_param("DIAL", m_Dial, 0.5); + register_param("R", m_R, 1.0 / NETLIST_GMIN); + register_param("DIAL", m_Dial, 0.5); } NETLIB_UPDATE(POT) { - m_R1.update_dev(); - m_R2.update_dev(); + m_R1.update_dev(); + m_R2.update_dev(); } NETLIB_UPDATE_PARAM(POT) { - m_R1.set_R(MAX(m_R.Value() * m_Dial.Value(), NETLIST_GMIN)); - m_R2.set_R(MAX(m_R.Value() * (1.0 - m_Dial.Value()), NETLIST_GMIN)); + m_R1.set_R(MAX(m_R.Value() * m_Dial.Value(), NETLIST_GMIN)); + m_R2.set_R(MAX(m_R.Value() * (1.0 - m_Dial.Value()), NETLIST_GMIN)); } // ---------------------------------------------------------------------------------------- // nld_C @@ -96,21 +96,21 @@ NETLIB_UPDATE_PARAM(POT) NETLIB_START(C) { - register_terminal("1", m_P); - register_terminal("2", m_N); + register_terminal("1", m_P); + register_terminal("2", m_N); - register_param("C", m_C, 1e-6); + register_param("C", m_C, 1e-6); } NETLIB_UPDATE_PARAM(C) { - // set to some very small step time for now - step_time(1e-9); + // set to some very small step time for now + step_time(1e-9); } NETLIB_UPDATE(C) { - NETLIB_NAME(twoterm)::update(); + NETLIB_NAME(twoterm)::update(); } // ---------------------------------------------------------------------------------------- @@ -119,59 +119,59 @@ NETLIB_UPDATE(C) NETLIB_START(D) { - register_terminal("A", m_P); - register_terminal("K", m_N); - register_param("model", m_model, ""); + register_terminal("A", m_P); + register_terminal("K", m_N); + register_param("model", m_model, ""); - m_Vd = 0.7; + m_Vd = 0.7; - save(NAME(m_Vd)); + save(NAME(m_Vd)); } NETLIB_UPDATE_PARAM(D) { - m_Is = m_model.dValue("Is", 1e-15); - m_n = m_model.dValue("N", 1); + m_Is = m_model.dValue("Is", 1e-15); + m_n = m_model.dValue("N", 1); - m_Vt = 0.0258 * m_n; + m_Vt = 0.0258 * m_n; - m_Vcrit = m_Vt * log(m_Vt / m_Is / sqrt(2.0)); - m_VtInv = 1.0 / m_Vt; - NL_VERBOSE_OUT(("VCutoff: %f\n", m_Vcrit)); + m_Vcrit = m_Vt * log(m_Vt / m_Is / sqrt(2.0)); + m_VtInv = 1.0 / m_Vt; + NL_VERBOSE_OUT(("VCutoff: %f\n", m_Vcrit)); } NETLIB_UPDATE(D) { - NETLIB_NAME(twoterm)::update(); + NETLIB_NAME(twoterm)::update(); } class diode { public: - diode() : m_Is(1e-15), m_VT(0.0258), m_VT_inv(1.0 / m_VT) {} - diode(const double Is, const double n) - { - m_Is = Is; - m_VT = 0.0258 * n; - m_VT_inv = 1.0 / m_VT; - } - void set(const double Is, const double n) - { - m_Is = Is; - m_VT = 0.0258 * n; - m_VT_inv = 1.0 / m_VT; - } - double I(const double V) const { return m_Is * exp(V * m_VT_inv) - m_Is; } - double g(const double V) const { return m_Is * m_VT_inv * exp(V * m_VT_inv); } - double V(const double I) const { return log(1.0 + I / m_Is) * m_VT; } - double gI(const double I) const { return m_VT_inv * (I + m_Is); } + diode() : m_Is(1e-15), m_VT(0.0258), m_VT_inv(1.0 / m_VT) {} + diode(const double Is, const double n) + { + m_Is = Is; + m_VT = 0.0258 * n; + m_VT_inv = 1.0 / m_VT; + } + void set(const double Is, const double n) + { + m_Is = Is; + m_VT = 0.0258 * n; + m_VT_inv = 1.0 / m_VT; + } + double I(const double V) const { return m_Is * exp(V * m_VT_inv) - m_Is; } + double g(const double V) const { return m_Is * m_VT_inv * exp(V * m_VT_inv); } + double V(const double I) const { return log(1.0 + I / m_Is) * m_VT; } + double gI(const double I) const { return m_VT_inv * (I + m_Is); } private: - double m_Is; - double m_VT; - double m_VT_inv; + double m_Is; + double m_VT; + double m_VT_inv; }; // ---------------------------------------------------------------------------------------- @@ -180,61 +180,61 @@ private: NETLIB_START(Q) { - register_param("model", m_model, ""); + register_param("model", m_model, ""); } template <NETLIB_NAME(Q)::q_type _type> NETLIB_START(QBJT_switch<_type>) { - NETLIB_NAME(Q)::start(); + NETLIB_NAME(Q)::start(); - register_sub(m_RB, "RB"); - register_sub(m_RC, "RC"); - register_input("BV", m_BV); - register_input("EV", m_EV); + register_sub(m_RB, "RB"); + register_sub(m_RC, "RC"); + register_input("BV", m_BV); + register_input("EV", m_EV); - register_subalias("B", m_RB.m_P); - register_subalias("E", m_RB.m_N); - register_subalias("C", m_RC.m_P); + register_subalias("B", m_RB.m_P); + register_subalias("E", m_RB.m_N); + register_subalias("C", m_RC.m_P); - setup().connect(m_RB.m_N, m_RC.m_N); - setup().connect(m_RB.m_P, m_BV); - setup().connect(m_RB.m_N, m_EV); + setup().connect(m_RB.m_N, m_RC.m_N); + setup().connect(m_RB.m_P, m_BV); + setup().connect(m_RB.m_N, m_EV); - save(NAME(m_state_on)); + save(NAME(m_state_on)); } NETLIB_UPDATE(Q) { - netlist().solver()->schedule(); + netlist().solver()->schedule(); } template <NETLIB_NAME(Q)::q_type _type> NETLIB_UPDATE_PARAM(QBJT_switch<_type>) { - double IS = m_model.dValue("IS", 1e-15); - double BF = m_model.dValue("BF", 100); - double NF = m_model.dValue("NF", 1); - //double VJE = m_model.dValue("VJE", 0.75); + double IS = m_model.dValue("IS", 1e-15); + double BF = m_model.dValue("BF", 100); + double NF = m_model.dValue("NF", 1); + //double VJE = m_model.dValue("VJE", 0.75); - double alpha = BF / (1.0 + BF); + double alpha = BF / (1.0 + BF); - diode d(IS, NF); + diode d(IS, NF); - // Assume 5mA Collector current for switch operation + // Assume 5mA Collector current for switch operation - if (_type == BJT_NPN) - m_V = d.V(0.005 / alpha); - else - m_V = - d.V(0.005 / alpha); + if (_type == BJT_NPN) + m_V = d.V(0.005 / alpha); + else + m_V = - d.V(0.005 / alpha); - m_gB = d.gI(0.005 / alpha); - if (m_gB < NETLIST_GMIN) - m_gB = NETLIST_GMIN; - m_gC = BF * m_gB; // very rough estimate - //printf("%f %f \n", m_V, m_gB); - m_RB.set(NETLIST_GMIN, 0.0, 0.0); - m_RC.set(NETLIST_GMIN, 0.0, 0.0); + m_gB = d.gI(0.005 / alpha); + if (m_gB < NETLIST_GMIN) + m_gB = NETLIST_GMIN; + m_gC = BF * m_gB; // very rough estimate + //printf("%f %f \n", m_V, m_gB); + m_RB.set(NETLIST_GMIN, 0.0, 0.0); + m_RC.set(NETLIST_GMIN, 0.0, 0.0); } template NETLIB_START(QBJT_switch<NETLIB_NAME(Q)::BJT_NPN>); @@ -248,40 +248,39 @@ template NETLIB_UPDATE_PARAM(QBJT_switch<NETLIB_NAME(Q)::BJT_PNP>); NETLIB_START(VCCS) { - configure(1.0, NETLIST_GMIN); + configure(1.0, NETLIST_GMIN); } ATTR_COLD void NETLIB_NAME(VCCS)::configure(const double Gfac, const double GI) { - - register_param("G", m_G, 1.0); - - register_terminal("IP", m_IP); - register_terminal("IN", m_IN); - register_terminal("OP", m_OP); - register_terminal("ON", m_ON); - - m_OP1.init_object(*this, name() + ".OP1", netlist_core_terminal_t::STATE_INP_ACTIVE); - m_ON1.init_object(*this, name() + ".ON1", netlist_core_terminal_t::STATE_INP_ACTIVE); - - const double m_mult = m_G.Value() * Gfac; // 1.0 ==> 1V ==> 1A - m_IP.set(GI); - m_IP.m_otherterm = &m_IN; // <= this should be NULL and terminal be filtered out prior to solving... - m_IN.set(GI); - m_IN.m_otherterm = &m_IP; // <= this should be NULL and terminal be filtered out prior to solving... - - m_OP.set(m_mult, 0.0); - m_OP.m_otherterm = &m_IP; - m_OP1.set(-m_mult, 0.0); - m_OP1.m_otherterm = &m_IN; - - m_ON.set(-m_mult, 0.0); - m_ON.m_otherterm = &m_IP; - m_ON1.set(m_mult, 0.0); - m_ON1.m_otherterm = &m_IN; - - setup().connect(m_OP, m_OP1); - setup().connect(m_ON, m_ON1); + register_param("G", m_G, 1.0); + + register_terminal("IP", m_IP); + register_terminal("IN", m_IN); + register_terminal("OP", m_OP); + register_terminal("ON", m_ON); + + m_OP1.init_object(*this, name() + ".OP1", netlist_core_terminal_t::STATE_INP_ACTIVE); + m_ON1.init_object(*this, name() + ".ON1", netlist_core_terminal_t::STATE_INP_ACTIVE); + + const double m_mult = m_G.Value() * Gfac; // 1.0 ==> 1V ==> 1A + m_IP.set(GI); + m_IP.m_otherterm = &m_IN; // <= this should be NULL and terminal be filtered out prior to solving... + m_IN.set(GI); + m_IN.m_otherterm = &m_IP; // <= this should be NULL and terminal be filtered out prior to solving... + + m_OP.set(m_mult, 0.0); + m_OP.m_otherterm = &m_IP; + m_OP1.set(-m_mult, 0.0); + m_OP1.m_otherterm = &m_IN; + + m_ON.set(-m_mult, 0.0); + m_ON.m_otherterm = &m_IP; + m_ON1.set(m_mult, 0.0); + m_ON1.m_otherterm = &m_IN; + + setup().connect(m_OP, m_OP1); + setup().connect(m_ON, m_ON1); } NETLIB_UPDATE_PARAM(VCCS) @@ -290,8 +289,8 @@ NETLIB_UPDATE_PARAM(VCCS) NETLIB_UPDATE(VCCS) { - /* only called if connected to a rail net ==> notify the solver to recalculate */ - netlist().solver()->schedule(); + /* only called if connected to a rail net ==> notify the solver to recalculate */ + netlist().solver()->schedule(); } // ---------------------------------------------------------------------------------------- @@ -300,25 +299,24 @@ NETLIB_UPDATE(VCCS) NETLIB_START(VCVS) { - register_param("RO", m_RO, 1.0); + register_param("RO", m_RO, 1.0); - const double gRO = 1.0 / m_RO.Value(); + const double gRO = 1.0 / m_RO.Value(); - configure(gRO, NETLIST_GMIN); + configure(gRO, NETLIST_GMIN); - m_OP2.init_object(*this, "OP2", netlist_core_terminal_t::STATE_INP_ACTIVE); - m_ON2.init_object(*this, "ON2", netlist_core_terminal_t::STATE_INP_ACTIVE); + m_OP2.init_object(*this, "OP2", netlist_core_terminal_t::STATE_INP_ACTIVE); + m_ON2.init_object(*this, "ON2", netlist_core_terminal_t::STATE_INP_ACTIVE); - m_OP2.set(gRO); - m_ON2.set(gRO); - m_OP2.m_otherterm = &m_ON2; - m_ON2.m_otherterm = &m_OP2; + m_OP2.set(gRO); + m_ON2.set(gRO); + m_OP2.m_otherterm = &m_ON2; + m_ON2.m_otherterm = &m_OP2; - setup().connect(m_OP2, m_OP1); - setup().connect(m_ON2, m_ON1); + setup().connect(m_OP2, m_OP1); + setup().connect(m_ON2, m_ON1); } NETLIB_UPDATE_PARAM(VCVS) { } - diff --git a/src/emu/netlist/devices/nld_twoterm.h b/src/emu/netlist/devices/nld_twoterm.h index 49b6ca3c629..6ebebf36903 100644 --- a/src/emu/netlist/devices/nld_twoterm.h +++ b/src/emu/netlist/devices/nld_twoterm.h @@ -40,30 +40,30 @@ // ---------------------------------------------------------------------------------------- #define NETDEV_R(_name, _R) \ - NET_REGISTER_DEV(R, _name) \ - NETDEV_PARAMI(_name, R, _R) + NET_REGISTER_DEV(R, _name) \ + NETDEV_PARAMI(_name, R, _R) #define NETDEV_POT(_name, _R) \ - NET_REGISTER_DEV(POT, _name) \ - NETDEV_PARAMI(_name, R, _R) + NET_REGISTER_DEV(POT, _name) \ + NETDEV_PARAMI(_name, R, _R) #define NETDEV_C(_name, _C) \ - NET_REGISTER_DEV(C, _name) \ - NETDEV_PARAMI(_name, C, _C) + NET_REGISTER_DEV(C, _name) \ + NETDEV_PARAMI(_name, C, _C) /* Generic Diode */ #define NETDEV_D(_name, _model) \ - NET_REGISTER_DEV(D, _name) \ - NETDEV_PARAMI(_name, model, # _model) + NET_REGISTER_DEV(D, _name) \ + NETDEV_PARAMI(_name, model, # _model) #define NETDEV_QPNP(_name, _model) \ - NET_REGISTER_DEV(QPNP_switch, _name) \ - NETDEV_PARAMI(_name, model, # _model) + NET_REGISTER_DEV(QPNP_switch, _name) \ + NETDEV_PARAMI(_name, model, # _model) #define NETDEV_QNPN(_name, _model) \ - NET_REGISTER_DEV(QNPN_switch, _name) \ - NETDEV_PARAMI(_name, model, # _model) + NET_REGISTER_DEV(QNPN_switch, _name) \ + NETDEV_PARAMI(_name, model, # _model) // ---------------------------------------------------------------------------------------- // Implementation @@ -76,24 +76,24 @@ class NETLIB_NAME(twoterm) : public netlist_device_t { public: - ATTR_COLD NETLIB_NAME(twoterm)(const family_t afamily); + ATTR_COLD NETLIB_NAME(twoterm)(const family_t afamily); - netlist_terminal_t m_P; - netlist_terminal_t m_N; + netlist_terminal_t m_P; + netlist_terminal_t m_N; - virtual NETLIB_UPDATE_TERMINALS() - { - } + virtual NETLIB_UPDATE_TERMINALS() + { + } - ATTR_HOT inline void set(const double G, const double V, const double I) - { - m_P.m_go = m_N.m_go = m_P.m_gt = m_N.m_gt = G; - m_N.m_Idr = ( -V) * G + I; - m_P.m_Idr = ( V) * G - I; - } + ATTR_HOT inline void set(const double G, const double V, const double I) + { + m_P.m_go = m_N.m_go = m_P.m_gt = m_N.m_gt = G; + m_N.m_Idr = ( -V) * G + I; + m_P.m_Idr = ( V) * G - I; + } protected: - ATTR_COLD virtual void start(); - ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_HOT ATTR_ALIGN void update(); private: }; @@ -105,17 +105,17 @@ private: class NETLIB_NAME(R_base) : public NETLIB_NAME(twoterm) { public: - ATTR_COLD NETLIB_NAME(R_base)() : NETLIB_NAME(twoterm)(RESISTOR) { } + ATTR_COLD NETLIB_NAME(R_base)() : NETLIB_NAME(twoterm)(RESISTOR) { } - inline void set_R(const double R) { set(1.0 / R, 0.0, 0.0); } + inline void set_R(const double R) { set(1.0 / R, 0.0, 0.0); } protected: - ATTR_COLD virtual void start(); - ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_HOT ATTR_ALIGN void update(); }; NETLIB_DEVICE_WITH_PARAMS_DERIVED(R, R_base, - netlist_param_double_t m_R; + netlist_param_double_t m_R; ); // ---------------------------------------------------------------------------------------- @@ -123,11 +123,11 @@ NETLIB_DEVICE_WITH_PARAMS_DERIVED(R, R_base, // ---------------------------------------------------------------------------------------- NETLIB_DEVICE_WITH_PARAMS(POT, - NETLIB_NAME(R_base) m_R1; - NETLIB_NAME(R_base) m_R2; + NETLIB_NAME(R_base) m_R1; + NETLIB_NAME(R_base) m_R2; - netlist_param_double_t m_R; - netlist_param_double_t m_Dial; + netlist_param_double_t m_R; + netlist_param_double_t m_Dial; ); @@ -138,21 +138,21 @@ NETLIB_DEVICE_WITH_PARAMS(POT, class NETLIB_NAME(C) : public NETLIB_NAME(twoterm) { public: - ATTR_COLD NETLIB_NAME(C)() : NETLIB_NAME(twoterm)(CAPACITOR) { } + ATTR_COLD NETLIB_NAME(C)() : NETLIB_NAME(twoterm)(CAPACITOR) { } - ATTR_HOT void step_time(const double st) - { - double G = m_C.Value() / st; - double I = -G * (m_P.net().Q_Analog()- m_N.net().Q_Analog()); - set(G, 0.0, I); - } + ATTR_HOT void step_time(const double st) + { + double G = m_C.Value() / st; + double I = -G * (m_P.net().Q_Analog()- m_N.net().Q_Analog()); + set(G, 0.0, I); + } protected: - ATTR_COLD virtual void start(); - ATTR_COLD virtual void update_param(); - ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_COLD virtual void update_param(); + ATTR_HOT ATTR_ALIGN void update(); - netlist_param_double_t m_C; + netlist_param_double_t m_C; }; @@ -167,87 +167,87 @@ protected: #if 0 inline double fastexp_h(const double x) { - static const double ln2r = 1.442695040888963387; - static const double ln2 = 0.693147180559945286; - //static const double c3 = 0.166666666666666667; + static const double ln2r = 1.442695040888963387; + static const double ln2 = 0.693147180559945286; + //static const double c3 = 0.166666666666666667; - const double y = x * ln2r; - const unsigned int t = y; - const double z = (x - ln2 * (double) t); - const double zz = z * z; - //const double zzz = zz * z; + const double y = x * ln2r; + const unsigned int t = y; + const double z = (x - ln2 * (double) t); + const double zz = z * z; + //const double zzz = zz * z; - return (double)(1 << t)*(1.0 + z + 0.5 * zz); // + c3*zzz; + return (double)(1 << t)*(1.0 + z + 0.5 * zz); // + c3*zzz; } inline double fastexp(const double x) { - if (x<0) - return 1.0 / fastexp_h(-x); - else - return fastexp_h(x); + if (x<0) + return 1.0 / fastexp_h(-x); + else + return fastexp_h(x); } #endif class NETLIB_NAME(D) : public NETLIB_NAME(twoterm) { public: - ATTR_COLD NETLIB_NAME(D)() : NETLIB_NAME(twoterm)(DIODE) { } - - NETLIB_UPDATE_TERMINALS() - { - const double nVd = m_P.net().Q_Analog()- m_N.net().Q_Analog(); - - //FIXME: Optimize cutoff case - - double Id; - double G; - - if (nVd < -5.0 * m_Vt) - { - m_Vd = nVd; - G = NETLIST_GMIN; - Id = - m_Is; - } - else if (nVd < m_Vcrit) - { - m_Vd = nVd; - - const double eVDVt = exp(m_Vd * m_VtInv); - Id = m_Is * (eVDVt - 1.0); - G = m_Is * m_VtInv * eVDVt; - } - else - { + ATTR_COLD NETLIB_NAME(D)() : NETLIB_NAME(twoterm)(DIODE) { } + + NETLIB_UPDATE_TERMINALS() + { + const double nVd = m_P.net().Q_Analog()- m_N.net().Q_Analog(); + + //FIXME: Optimize cutoff case + + double Id; + double G; + + if (nVd < -5.0 * m_Vt) + { + m_Vd = nVd; + G = NETLIST_GMIN; + Id = - m_Is; + } + else if (nVd < m_Vcrit) + { + m_Vd = nVd; + + const double eVDVt = exp(m_Vd * m_VtInv); + Id = m_Is * (eVDVt - 1.0); + G = m_Is * m_VtInv * eVDVt; + } + else + { #if defined(_MSC_VER) && _MSC_VER < 1800 - m_Vd = m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt; + m_Vd = m_Vd + log((nVd - m_Vd) * m_VtInv + 1.0) * m_Vt; #else - m_Vd = m_Vd + log1p((nVd - m_Vd) * m_VtInv) * m_Vt; + m_Vd = m_Vd + log1p((nVd - m_Vd) * m_VtInv) * m_Vt; #endif - const double eVDVt = exp(m_Vd * m_VtInv); - Id = m_Is * (eVDVt - 1.0); + const double eVDVt = exp(m_Vd * m_VtInv); + Id = m_Is * (eVDVt - 1.0); - G = m_Is * m_VtInv * eVDVt; - } + G = m_Is * m_VtInv * eVDVt; + } - double I = (Id - m_Vd * G); - set(G, 0.0, I); - } + double I = (Id - m_Vd * G); + set(G, 0.0, I); + } protected: - ATTR_COLD virtual void start(); - ATTR_COLD virtual void update_param(); - ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_COLD virtual void update_param(); + ATTR_HOT ATTR_ALIGN void update(); - netlist_param_model_t m_model; + netlist_param_model_t m_model; - double m_Vt; - double m_Is; - double m_n; + double m_Vt; + double m_Is; + double m_n; - double m_VtInv; - double m_Vcrit; - double m_Vd; + double m_VtInv; + double m_Vcrit; + double m_Vd; }; @@ -269,32 +269,32 @@ protected: class NETLIB_NAME(Q) : public netlist_device_t { public: - enum q_type { - BJT_NPN, - BJT_PNP - }; + enum q_type { + BJT_NPN, + BJT_PNP + }; - ATTR_COLD NETLIB_NAME(Q)(const q_type atype, const family_t afamily) - : netlist_device_t(afamily) - , m_qtype(atype) { } + ATTR_COLD NETLIB_NAME(Q)(const q_type atype, const family_t afamily) + : netlist_device_t(afamily) + , m_qtype(atype) { } - inline q_type qtype() const { return m_qtype; } - inline bool is_qtype(q_type atype) const { return m_qtype == atype; } + inline q_type qtype() const { return m_qtype; } + inline bool is_qtype(q_type atype) const { return m_qtype == atype; } protected: - ATTR_COLD virtual void start(); - ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_HOT ATTR_ALIGN void update(); - netlist_param_model_t m_model; + netlist_param_model_t m_model; private: - q_type m_qtype; + q_type m_qtype; }; class NETLIB_NAME(QBJT) : public NETLIB_NAME(Q) { public: - ATTR_COLD NETLIB_NAME(QBJT)(const q_type atype, const family_t afamily) - : NETLIB_NAME(Q)(atype, afamily) { } + ATTR_COLD NETLIB_NAME(QBJT)(const q_type atype, const family_t afamily) + : NETLIB_NAME(Q)(atype, afamily) { } protected: @@ -306,51 +306,51 @@ template <NETLIB_NAME(Q)::q_type _type> class NETLIB_NAME(QBJT_switch) : public NETLIB_NAME(QBJT) { public: - ATTR_COLD NETLIB_NAME(QBJT_switch)() - : NETLIB_NAME(QBJT)(_type, BJT_SWITCH), m_gB(NETLIST_GMIN), m_gC(NETLIST_GMIN), m_V(0.0), m_state_on(0) { } - - NETLIB_UPDATEI() - { - double vE = INPANALOG(m_EV); - double vB = INPANALOG(m_BV); - - int new_state = (vB - vE > m_V ) ? 1 : 0; - if (m_state_on ^ new_state) - { - double gb = m_gB; - double gc = m_gC; - double v = m_V; - if (!new_state ) - { - // not conducting - gb = NETLIST_GMIN; - v = 0; - gc = NETLIST_GMIN; - } - m_RB.set(gb, v, 0.0); - m_RC.set(gc, 0.0, 0.0); - m_state_on = new_state; - m_RB.update_dev(); - m_RC.update_dev(); - } - - } - - NETLIB_NAME(R) m_RB; - NETLIB_NAME(R) m_RC; - - netlist_analog_input_t m_BV; - netlist_analog_input_t m_EV; + ATTR_COLD NETLIB_NAME(QBJT_switch)() + : NETLIB_NAME(QBJT)(_type, BJT_SWITCH), m_gB(NETLIST_GMIN), m_gC(NETLIST_GMIN), m_V(0.0), m_state_on(0) { } + + NETLIB_UPDATEI() + { + double vE = INPANALOG(m_EV); + double vB = INPANALOG(m_BV); + + int new_state = (vB - vE > m_V ) ? 1 : 0; + if (m_state_on ^ new_state) + { + double gb = m_gB; + double gc = m_gC; + double v = m_V; + if (!new_state ) + { + // not conducting + gb = NETLIST_GMIN; + v = 0; + gc = NETLIST_GMIN; + } + m_RB.set(gb, v, 0.0); + m_RC.set(gc, 0.0, 0.0); + m_state_on = new_state; + m_RB.update_dev(); + m_RC.update_dev(); + } + + } + + NETLIB_NAME(R) m_RB; + NETLIB_NAME(R) m_RC; + + netlist_analog_input_t m_BV; + netlist_analog_input_t m_EV; protected: - ATTR_COLD virtual void start(); - ATTR_COLD void update_param(); + ATTR_COLD virtual void start(); + ATTR_COLD void update_param(); - double m_gB; // base conductance / switch on - double m_gC; // collector conductance / switch on - double m_V; // internal voltage source - UINT8 m_state_on; + double m_gB; // base conductance / switch on + double m_gC; // collector conductance / switch on + double m_V; // internal voltage source + UINT8 m_state_on; private: }; @@ -380,35 +380,34 @@ typedef NETLIB_NAME(QBJT_switch)<NETLIB_NAME(Q)::BJT_NPN> NETLIB_NAME(QNPN_switc */ #define NETDEV_VCCS(_name) \ - NET_REGISTER_DEV(VCCS, _name) \ - + NET_REGISTER_DEV(VCCS, _name) //NETDEV_PARAMI(_name, model, _model) class NETLIB_NAME(VCCS) : public netlist_device_t { public: - ATTR_COLD NETLIB_NAME(VCCS)() - : netlist_device_t(VCCS) { } - ATTR_COLD NETLIB_NAME(VCCS)(const family_t afamily) - : netlist_device_t(afamily) { } + ATTR_COLD NETLIB_NAME(VCCS)() + : netlist_device_t(VCCS) { } + ATTR_COLD NETLIB_NAME(VCCS)(const family_t afamily) + : netlist_device_t(afamily) { } protected: - ATTR_COLD virtual void start(); - ATTR_COLD virtual void update_param(); - ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_COLD virtual void update_param(); + ATTR_HOT ATTR_ALIGN void update(); - ATTR_COLD void configure(const double Gfac, const double GI); + ATTR_COLD void configure(const double Gfac, const double GI); - netlist_terminal_t m_OP; - netlist_terminal_t m_ON; + netlist_terminal_t m_OP; + netlist_terminal_t m_ON; - netlist_terminal_t m_IP; - netlist_terminal_t m_IN; + netlist_terminal_t m_IP; + netlist_terminal_t m_IN; - netlist_terminal_t m_OP1; - netlist_terminal_t m_ON1; + netlist_terminal_t m_OP1; + netlist_terminal_t m_ON1; - netlist_param_double_t m_G; + netlist_param_double_t m_G; }; // ---------------------------------------------------------------------------------------- @@ -439,28 +438,27 @@ protected: */ #define NETDEV_VCVS(_name) \ - NET_REGISTER_DEV(VCVS, _name) \ - + NET_REGISTER_DEV(VCVS, _name) //NETDEV_PARAMI(_name, model, _model) class NETLIB_NAME(VCVS) : public NETLIB_NAME(VCCS) { public: - ATTR_COLD NETLIB_NAME(VCVS)() - : NETLIB_NAME(VCCS)(VCVS) { } + ATTR_COLD NETLIB_NAME(VCVS)() + : NETLIB_NAME(VCCS)(VCVS) { } protected: - ATTR_COLD virtual void start(); - ATTR_COLD virtual void update_param(); - //ATTR_HOT ATTR_ALIGN void update(); + ATTR_COLD virtual void start(); + ATTR_COLD virtual void update_param(); + //ATTR_HOT ATTR_ALIGN void update(); - netlist_terminal_t m_OP2; - netlist_terminal_t m_ON2; + netlist_terminal_t m_OP2; + netlist_terminal_t m_ON2; - double m_mult; + double m_mult; - netlist_param_double_t m_RO; + netlist_param_double_t m_RO; }; diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c index cf7f4b28e3b..0e1e11db908 100644 --- a/src/emu/netlist/nl_base.c +++ b/src/emu/netlist/nl_base.c @@ -22,21 +22,21 @@ ATTR_COLD netlist_object_t::netlist_object_t(const type_t atype, const family_t ATTR_COLD netlist_object_t::~netlist_object_t() { - //delete m_name; + //delete m_name; } ATTR_COLD void netlist_object_t::init_object(netlist_base_t &nl, const pstring &aname) { - m_netlist = &nl; - m_name = aname; - save_register(); + m_netlist = &nl; + m_name = aname; + save_register(); } ATTR_COLD const pstring &netlist_object_t::name() const { - if (m_name == "") - netlist().xfatalerror("object not initialized"); - return m_name; + if (m_name == "") + netlist().xfatalerror("object not initialized"); + return m_name; } // ---------------------------------------------------------------------------------------- @@ -44,17 +44,17 @@ ATTR_COLD const pstring &netlist_object_t::name() const // ---------------------------------------------------------------------------------------- ATTR_COLD netlist_owned_object_t::netlist_owned_object_t(const type_t atype, - const family_t afamily) + const family_t afamily) : netlist_object_t(atype, afamily) , m_netdev(NULL) { } ATTR_COLD void netlist_owned_object_t::init_object(netlist_core_device_t &dev, - const pstring &aname) + const pstring &aname) { - netlist_object_t::init_object(dev.netlist(), aname); - m_netdev = &dev; + netlist_object_t::init_object(dev.netlist(), aname); + m_netdev = &dev; } // ---------------------------------------------------------------------------------------- @@ -62,186 +62,186 @@ ATTR_COLD void netlist_owned_object_t::init_object(netlist_core_device_t &dev, // ---------------------------------------------------------------------------------------- netlist_base_t::netlist_base_t() - : netlist_object_t(NETLIST, GENERIC), - m_time_ps(netlist_time::zero), - m_rem(0), - m_div(NETLIST_DIV), - m_mainclock(NULL), - m_solver(NULL) + : netlist_object_t(NETLIST, GENERIC), + m_time_ps(netlist_time::zero), + m_rem(0), + m_div(NETLIST_DIV), + m_mainclock(NULL), + m_solver(NULL) { } template <class T> static void tagmap_free_entries(T &tm) { - for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry)) - { - delete entry->object(); - } - tm.reset(); + for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry)) + { + delete entry->object(); + } + tm.reset(); } netlist_base_t::~netlist_base_t() { - tagmap_free_entries<tagmap_devices_t>(m_devices); + tagmap_free_entries<tagmap_devices_t>(m_devices); - netlist_net_t::list_t::entry_t *p = m_nets.first(); - while (p != NULL) - { - netlist_net_t::list_t::entry_t *pn = m_nets.next(p); - if (!p->object()->isRailNet()) - delete p->object(); - p = pn; - } + netlist_net_t::list_t::entry_t *p = m_nets.first(); + while (p != NULL) + { + netlist_net_t::list_t::entry_t *pn = m_nets.next(p); + if (!p->object()->isRailNet()) + delete p->object(); + p = pn; + } - m_nets.reset(); - pstring::resetmem(); + m_nets.reset(); + pstring::resetmem(); } ATTR_COLD netlist_net_t *netlist_base_t::find_net(const pstring &name) { - for (netlist_net_t::list_t::entry_t *p = m_nets.first(); p != NULL; p = m_nets.next(p)) - { - if (p->object()->name() == name) - return p->object(); - } - return NULL; + for (netlist_net_t::list_t::entry_t *p = m_nets.first(); p != NULL; p = m_nets.next(p)) + { + if (p->object()->name() == name) + return p->object(); + } + return NULL; } ATTR_COLD void netlist_base_t::set_mainclock_dev(NETLIB_NAME(mainclock) *dev) { - m_mainclock = dev; + m_mainclock = dev; } ATTR_COLD void netlist_base_t::set_solver_dev(NETLIB_NAME(solver) *dev) { - m_solver = dev; + m_solver = dev; } ATTR_COLD void netlist_base_t::reset() { - m_time_ps = netlist_time::zero; - m_rem = 0; - m_queue.clear(); - if (m_mainclock != NULL) - m_mainclock->m_Q.net().set_time(netlist_time::zero); + m_time_ps = netlist_time::zero; + m_rem = 0; + m_queue.clear(); + if (m_mainclock != NULL) + m_mainclock->m_Q.net().set_time(netlist_time::zero); - // FIXME: some const devices rely on this - /* make sure params are set now .. */ - for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) - { - entry->object()->update_param(); - } + // FIXME: some const devices rely on this + /* make sure params are set now .. */ + for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) + { + entry->object()->update_param(); + } - // Step all devices once ! - for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) - { - netlist_device_t *dev = entry->object(); - dev->update_dev(); - } + // Step all devices once ! + for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) + { + netlist_device_t *dev = entry->object(); + dev->update_dev(); + } } void netlist_base_t::set_clock_freq(UINT64 clockfreq) { - m_div = netlist_time::from_hz(clockfreq).as_raw(); - m_rem = 0; - assert_always(m_div == NETLIST_DIV, "netlist: illegal clock!"); - NL_VERBOSE_OUT(("Setting clock %" I64FMT "d and divisor %d\n", clockfreq, m_div)); + m_div = netlist_time::from_hz(clockfreq).as_raw(); + m_rem = 0; + assert_always(m_div == NETLIST_DIV, "netlist: illegal clock!"); + NL_VERBOSE_OUT(("Setting clock %" I64FMT "d and divisor %d\n", clockfreq, m_div)); } ATTR_HOT ATTR_ALIGN inline void netlist_base_t::update_time(const netlist_time t, INT32 &atime) { - if (NETLIST_DIV_BITS == 0) - { - const netlist_time delta = t - m_time_ps; - m_time_ps = t; - atime -= delta.as_raw(); - } else { - const netlist_time delta = t - m_time_ps + netlist_time::from_raw(m_rem); - m_time_ps = t; - m_rem = delta.as_raw() & NETLIST_MASK; - atime -= (delta.as_raw() >> NETLIST_DIV_BITS); + if (NETLIST_DIV_BITS == 0) + { + const netlist_time delta = t - m_time_ps; + m_time_ps = t; + atime -= delta.as_raw(); + } else { + const netlist_time delta = t - m_time_ps + netlist_time::from_raw(m_rem); + m_time_ps = t; + m_rem = delta.as_raw() & NETLIST_MASK; + atime -= (delta.as_raw() >> NETLIST_DIV_BITS); - // The folling is suitable for non-power of 2 m_divs ... - // atime -= divu_64x32_rem(delta.as_raw(), m_div, &m_rem); - } + // The folling is suitable for non-power of 2 m_divs ... + // atime -= divu_64x32_rem(delta.as_raw(), m_div, &m_rem); + } } ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(INT32 &atime) { - if (m_mainclock == NULL) - { - while ( (atime > 0) && (m_queue.is_not_empty())) - { - const queue_t::entry_t &e = m_queue.pop(); - update_time(e.time(), atime); + if (m_mainclock == NULL) + { + while ( (atime > 0) && (m_queue.is_not_empty())) + { + const queue_t::entry_t &e = m_queue.pop(); + update_time(e.time(), atime); - //if (FATAL_ERROR_AFTER_NS) - // NL_VERBOSE_OUT(("%s\n", e.object().netdev()->name().cstr()); + //if (FATAL_ERROR_AFTER_NS) + // NL_VERBOSE_OUT(("%s\n", e.object().netdev()->name().cstr()); - e.object().update_devs(); + e.object().update_devs(); - add_to_stat(m_perf_out_processed, 1); + add_to_stat(m_perf_out_processed, 1); - if (FATAL_ERROR_AFTER_NS) - if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS)) - xfatalerror("Stopped"); - } + if (FATAL_ERROR_AFTER_NS) + if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS)) + xfatalerror("Stopped"); + } - if (atime > 0) - { - m_time_ps += netlist_time::from_raw(atime * m_div); - atime = 0; - } - } else { - netlist_net_t &mcQ = m_mainclock->m_Q.net(); - const netlist_time inc = m_mainclock->m_inc; + if (atime > 0) + { + m_time_ps += netlist_time::from_raw(atime * m_div); + atime = 0; + } + } else { + netlist_net_t &mcQ = m_mainclock->m_Q.net(); + const netlist_time inc = m_mainclock->m_inc; - while (atime > 0) - { - if (m_queue.is_not_empty()) - { - while (m_queue.peek().time() > mcQ.time()) - { - update_time(mcQ.time(), atime); + while (atime > 0) + { + if (m_queue.is_not_empty()) + { + while (m_queue.peek().time() > mcQ.time()) + { + update_time(mcQ.time(), atime); - NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc); + NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc); - } - const queue_t::entry_t &e = m_queue.pop(); + } + const queue_t::entry_t &e = m_queue.pop(); - update_time(e.time(), atime); + update_time(e.time(), atime); - e.object().update_devs(); + e.object().update_devs(); - } else { - update_time(mcQ.time(), atime); + } else { + update_time(mcQ.time(), atime); - NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc); - } - if (FATAL_ERROR_AFTER_NS) - if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS)) - xfatalerror("Stopped"); + NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc); + } + if (FATAL_ERROR_AFTER_NS) + if (time() > NLTIME_FROM_NS(FATAL_ERROR_AFTER_NS)) + xfatalerror("Stopped"); - add_to_stat(m_perf_out_processed, 1); - } + add_to_stat(m_perf_out_processed, 1); + } - if (atime > 0) - { - m_time_ps += netlist_time::from_raw(atime * m_div); - atime = 0; - } - } + if (atime > 0) + { + m_time_ps += netlist_time::from_raw(atime * m_div); + atime = 0; + } + } } ATTR_COLD void netlist_base_t::xfatalerror(const char *format, ...) const { - va_list ap; - va_start(ap, format); - //emu_fatalerror error(format, ap); - vfatalerror(format, ap); - va_end(ap); - //throw error; + va_list ap; + va_start(ap, format); + //emu_fatalerror error(format, ap); + vfatalerror(format, ap); + va_end(ap); + //throw error; } @@ -267,15 +267,15 @@ ATTR_COLD netlist_core_device_t::netlist_core_device_t(const family_t afamily) ATTR_COLD void netlist_core_device_t::init(netlist_base_t &anetlist, const pstring &name) { - init_object(anetlist, name); + init_object(anetlist, name); #if USE_DELEGATES #if USE_PMFDELEGATES - void (netlist_core_device_t::* pFunc)() = &netlist_core_device_t::update; - static_update = reinterpret_cast<net_update_delegate>((this->*pFunc)); + void (netlist_core_device_t::* pFunc)() = &netlist_core_device_t::update; + static_update = reinterpret_cast<net_update_delegate>((this->*pFunc)); #else - static_update = net_update_delegate(&netlist_core_device_t::update, "update", this); - // get the pointer to the member function + static_update = net_update_delegate(&netlist_core_device_t::update, "update", this); + // get the pointer to the member function #endif #endif @@ -287,15 +287,15 @@ ATTR_COLD netlist_core_device_t::~netlist_core_device_t() ATTR_HOT ATTR_ALIGN const netlist_sig_t netlist_core_device_t::INPLOGIC_PASSIVE(netlist_logic_input_t &inp) { - if (inp.state() == netlist_input_t::STATE_INP_PASSIVE) - { - inp.activate(); - const netlist_sig_t ret = inp.Q(); - inp.inactivate(); - return ret; - } - else - return inp.Q(); + if (inp.state() == netlist_input_t::STATE_INP_PASSIVE) + { + inp.activate(); + const netlist_sig_t ret = inp.Q(); + inp.inactivate(); + return ret; + } + else + return inp.Q(); } @@ -304,109 +304,109 @@ ATTR_HOT ATTR_ALIGN const netlist_sig_t netlist_core_device_t::INPLOGIC_PASSIVE( // ---------------------------------------------------------------------------------------- netlist_device_t::netlist_device_t() - : netlist_core_device_t(), - m_terminals(20) + : netlist_core_device_t(), + m_terminals(20) { } netlist_device_t::netlist_device_t(const family_t afamily) - : netlist_core_device_t(afamily), - m_terminals(20){ + : netlist_core_device_t(afamily), + m_terminals(20){ } netlist_device_t::~netlist_device_t() { - //NL_VERBOSE_OUT(("~net_device_t\n"); + //NL_VERBOSE_OUT(("~net_device_t\n"); } ATTR_COLD netlist_setup_t &netlist_device_t::setup() { - return netlist().setup(); + return netlist().setup(); } ATTR_COLD void netlist_device_t::init(netlist_base_t &anetlist, const pstring &name) { - netlist_core_device_t::init(anetlist, name); - start(); + netlist_core_device_t::init(anetlist, name); + start(); } ATTR_COLD void netlist_device_t::register_sub(netlist_device_t &dev, const pstring &name) { - dev.init(netlist(), this->name() + "." + name); + dev.init(netlist(), this->name() + "." + name); } ATTR_COLD void netlist_device_t::register_subalias(const pstring &name, const netlist_core_terminal_t &term) { - pstring alias = this->name() + "." + name; + pstring alias = this->name() + "." + name; - setup().register_alias(alias, term.name()); + setup().register_alias(alias, term.name()); - if (term.isType(netlist_terminal_t::INPUT)) - m_terminals.add(name); + if (term.isType(netlist_terminal_t::INPUT)) + m_terminals.add(name); } ATTR_COLD void netlist_device_t::register_terminal(const pstring &name, netlist_terminal_t &port) { - setup().register_object(*this,*this,name, port, netlist_terminal_t::STATE_INP_ACTIVE); + setup().register_object(*this,*this,name, port, netlist_terminal_t::STATE_INP_ACTIVE); } ATTR_COLD void netlist_device_t::register_output(const pstring &name, netlist_output_t &port) { - setup().register_object(*this,*this,name, port, netlist_terminal_t::STATE_OUT); + setup().register_object(*this,*this,name, port, netlist_terminal_t::STATE_OUT); } ATTR_COLD void netlist_device_t::register_input(const pstring &name, netlist_input_t &inp, netlist_input_t::state_e type) { - m_terminals.add(name); - setup().register_object(*this, *this, name, inp, type); + m_terminals.add(name); + setup().register_object(*this, *this, name, inp, type); } //FIXME: Get rid of this static void init_term(netlist_core_device_t &dev, netlist_core_terminal_t &term, netlist_input_t::state_e aState) { - if (!term.isInitalized()) - { - switch (term.type()) - { - case netlist_terminal_t::OUTPUT: - dynamic_cast<netlist_output_t &>(term).init_object(dev, dev.name() + ".INTOUT"); - break; - case netlist_terminal_t::INPUT: - dynamic_cast<netlist_input_t &>(term).init_object(dev, dev.name() + ".INTINP", aState); - break; - case netlist_terminal_t::TERMINAL: - dynamic_cast<netlist_terminal_t &>(term).init_object(dev, dev.name() + ".INTTERM", aState); - break; - default: - dev.netlist().xfatalerror("Unknown terminal type"); - break; - } - } + if (!term.isInitalized()) + { + switch (term.type()) + { + case netlist_terminal_t::OUTPUT: + dynamic_cast<netlist_output_t &>(term).init_object(dev, dev.name() + ".INTOUT"); + break; + case netlist_terminal_t::INPUT: + dynamic_cast<netlist_input_t &>(term).init_object(dev, dev.name() + ".INTINP", aState); + break; + case netlist_terminal_t::TERMINAL: + dynamic_cast<netlist_terminal_t &>(term).init_object(dev, dev.name() + ".INTTERM", aState); + break; + default: + dev.netlist().xfatalerror("Unknown terminal type"); + break; + } + } } // FIXME: Revise internal links ... //FIXME: Get rid of this ATTR_COLD void netlist_device_t::register_link_internal(netlist_core_device_t &dev, netlist_input_t &in, netlist_output_t &out, const netlist_input_t::state_e aState) { - init_term(dev, in, aState); - init_term(dev, out, aState); - setup().connect(in, out); + init_term(dev, in, aState); + init_term(dev, out, aState); + setup().connect(in, out); } ATTR_COLD void netlist_device_t::register_link_internal(netlist_input_t &in, netlist_output_t &out, const netlist_input_t::state_e aState) { - register_link_internal(*this, in, out, aState); + register_link_internal(*this, in, out, aState); } template <class C, class T> ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, C ¶m, const T initialVal) { - pstring fullname = dev.name() + "." + sname; - param.init_object(dev, fullname); - param.initial(initialVal); - //FIXME: pass fullname from above - setup().register_object(*this, *this, fullname, param, netlist_terminal_t::STATE_NONEX); + pstring fullname = dev.name() + "." + sname; + param.init_object(dev, fullname); + param.initial(initialVal); + //FIXME: pass fullname from above + setup().register_object(*this, *this, fullname, param, netlist_terminal_t::STATE_NONEX); } template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t &dev, const pstring &sname, netlist_param_double_t ¶m, const double initialVal); @@ -422,112 +422,111 @@ template ATTR_COLD void netlist_device_t::register_param(netlist_core_device_t & // ---------------------------------------------------------------------------------------- ATTR_COLD netlist_net_t::netlist_net_t(const type_t atype, const family_t afamily) - : netlist_object_t(atype, afamily) - , m_head(NULL) - , m_num_cons(0) - , m_time(netlist_time::zero) - , m_active(0) - , m_in_queue(2) - , m_railterminal(NULL) + : netlist_object_t(atype, afamily) + , m_head(NULL) + , m_num_cons(0) + , m_time(netlist_time::zero) + , m_active(0) + , m_in_queue(2) + , m_railterminal(NULL) { }; ATTR_COLD void netlist_net_t::init_object(netlist_base_t &nl, const pstring &aname) { - netlist_object_t::init_object(nl, aname); - nl.m_nets.add(this); + netlist_object_t::init_object(nl, aname); + nl.m_nets.add(this); } ATTR_COLD void netlist_net_t::register_railterminal(netlist_output_t &mr) { - assert(m_railterminal == NULL); - m_railterminal = &mr; + assert(m_railterminal == NULL); + m_railterminal = &mr; } ATTR_COLD void netlist_net_t::merge_net(netlist_net_t *othernet) { - NL_VERBOSE_OUT(("merging nets ...\n")); - if (othernet == NULL) - return; // Nothing to do + NL_VERBOSE_OUT(("merging nets ...\n")); + if (othernet == NULL) + return; // Nothing to do - if (this->isRailNet() && othernet->isRailNet()) - netlist().xfatalerror("Trying to merge to rail nets\n"); + if (this->isRailNet() && othernet->isRailNet()) + netlist().xfatalerror("Trying to merge to rail nets\n"); - if (othernet->isRailNet()) - { - NL_VERBOSE_OUT(("othernet is railnet\n")); - othernet->merge_net(this); - } - else - { - netlist_core_terminal_t *p = othernet->m_head; - while (p != NULL) - { - netlist_core_terminal_t *pn = p->m_update_list_next; - register_con(*p); - p = pn; - } + if (othernet->isRailNet()) + { + NL_VERBOSE_OUT(("othernet is railnet\n")); + othernet->merge_net(this); + } + else + { + netlist_core_terminal_t *p = othernet->m_head; + while (p != NULL) + { + netlist_core_terminal_t *pn = p->m_update_list_next; + register_con(*p); + p = pn; + } - othernet->m_head = NULL; // FIXME: othernet needs to be free'd from memory - } + othernet->m_head = NULL; // FIXME: othernet needs to be free'd from memory + } } ATTR_COLD void netlist_net_t::register_con(netlist_core_terminal_t &terminal) { - terminal.set_net(*this); + terminal.set_net(*this); - terminal.m_update_list_next = m_head; - m_head = &terminal; - m_num_cons++; + terminal.m_update_list_next = m_head; + m_head = &terminal; + m_num_cons++; - if (terminal.state() != netlist_input_t::STATE_INP_PASSIVE) - m_active++; + if (terminal.state() != netlist_input_t::STATE_INP_PASSIVE) + m_active++; } ATTR_HOT inline void netlist_net_t::update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const { - if ((inp->state() & mask) != 0) - { - netlist_core_device_t &netdev = inp->netdev(); - begin_timing(netdev.total_time); - inc_stat(netdev.stat_count); - netdev.update_dev(); - end_timing(netdev().total_time); - } + if ((inp->state() & mask) != 0) + { + netlist_core_device_t &netdev = inp->netdev(); + begin_timing(netdev.total_time); + inc_stat(netdev.stat_count); + netdev.update_dev(); + end_timing(netdev().total_time); + } } ATTR_HOT inline void netlist_net_t::update_devs() { - assert(m_num_cons != 0); - - assert(this->isRailNet()); - { - - const UINT32 masks[4] = { 1, 5, 3, 1 }; - m_cur = m_new; - m_in_queue = 2; /* mark as taken ... */ - - const UINT32 mask = masks[ (m_last.Q << 1) | m_cur.Q ]; - - netlist_core_terminal_t *p = m_head; - switch (m_num_cons) - { - case 2: - update_dev(p, mask); - p = p->m_update_list_next; - case 1: - update_dev(p, mask); - break; - default: - do - { - update_dev(p, mask); - p = p->m_update_list_next; - } while (p != NULL); - break; - } - m_last = m_cur; - } + assert(m_num_cons != 0); + + assert(this->isRailNet()); + { + const UINT32 masks[4] = { 1, 5, 3, 1 }; + m_cur = m_new; + m_in_queue = 2; /* mark as taken ... */ + + const UINT32 mask = masks[ (m_last.Q << 1) | m_cur.Q ]; + + netlist_core_terminal_t *p = m_head; + switch (m_num_cons) + { + case 2: + update_dev(p, mask); + p = p->m_update_list_next; + case 1: + update_dev(p, mask); + break; + default: + do + { + update_dev(p, mask); + p = p->m_update_list_next; + } while (p != NULL); + break; + } + m_last = m_cur; + } } // ---------------------------------------------------------------------------------------- @@ -540,7 +539,6 @@ ATTR_COLD netlist_core_terminal_t::netlist_core_terminal_t(const type_t atype, c , m_net(NULL) , m_state(STATE_NONEX) { - } ATTR_COLD netlist_terminal_t::netlist_terminal_t() @@ -549,18 +547,17 @@ ATTR_COLD netlist_terminal_t::netlist_terminal_t() , m_go(NETLIST_GMIN) , m_gt(NETLIST_GMIN) { - } ATTR_COLD void netlist_core_terminal_t::init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate) { - set_state(astate); - netlist_owned_object_t::init_object(dev, aname); + set_state(astate); + netlist_owned_object_t::init_object(dev, aname); } ATTR_COLD void netlist_core_terminal_t::set_net(netlist_net_t &anet) { - m_net = &anet; + m_net = &anet; } // ---------------------------------------------------------------------------------------- @@ -572,41 +569,41 @@ ATTR_COLD void netlist_core_terminal_t::set_net(netlist_net_t &anet) // ---------------------------------------------------------------------------------------- netlist_output_t::netlist_output_t(const type_t atype, const family_t afamily) - : netlist_core_terminal_t(atype, afamily) - , m_low_V(0.0) - , m_high_V(0.0) - , m_my_net(NET, afamily) + : netlist_core_terminal_t(atype, afamily) + , m_low_V(0.0) + , m_high_V(0.0) + , m_my_net(NET, afamily) { - //m_net = new net_net_t(NET_DIGITAL); - this->set_net(m_my_net); + //m_net = new net_net_t(NET_DIGITAL); + this->set_net(m_my_net); } ATTR_COLD void netlist_output_t::init_object(netlist_core_device_t &dev, const pstring &aname) { - netlist_core_terminal_t::init_object(dev, aname, STATE_OUT); - net().init_object(dev.netlist(), aname + ".net"); - net().register_railterminal(*this); + netlist_core_terminal_t::init_object(dev, aname, STATE_OUT); + net().init_object(dev.netlist(), aname + ".net"); + net().register_railterminal(*this); } ATTR_COLD void netlist_logic_output_t::initial(const netlist_sig_t val) { - net().m_cur.Q = val; - net().m_new.Q = val; - net().m_last.Q = !val; + net().m_cur.Q = val; + net().m_new.Q = val; + net().m_last.Q = !val; } ATTR_COLD netlist_logic_output_t::netlist_logic_output_t() - : netlist_output_t(OUTPUT, LOGIC) + : netlist_output_t(OUTPUT, LOGIC) { - // Default to TTL - m_low_V = 0.1; // these depend on sinked/sourced current. Values should be suitable for typical applications. - m_high_V = 4.8; + // Default to TTL + m_low_V = 0.1; // these depend on sinked/sourced current. Values should be suitable for typical applications. + m_high_V = 4.8; } ATTR_COLD void netlist_logic_output_t::set_levels(const double low, const double high) { - m_low_V = low; - m_high_V = high; + m_low_V = low; + m_high_V = high; } // ---------------------------------------------------------------------------------------- @@ -614,9 +611,9 @@ ATTR_COLD void netlist_logic_output_t::set_levels(const double low, const double // ---------------------------------------------------------------------------------------- ATTR_COLD netlist_ttl_output_t::netlist_ttl_output_t() - : netlist_logic_output_t() + : netlist_logic_output_t() { - set_levels(0.3, 3.4); + set_levels(0.3, 3.4); } // ---------------------------------------------------------------------------------------- @@ -624,16 +621,16 @@ ATTR_COLD netlist_ttl_output_t::netlist_ttl_output_t() // ---------------------------------------------------------------------------------------- ATTR_COLD netlist_analog_output_t::netlist_analog_output_t() - : netlist_output_t(OUTPUT, ANALOG) + : netlist_output_t(OUTPUT, ANALOG) { - net().m_cur.Analog = 0.0; - net().m_new.Analog = 99.0; + net().m_cur.Analog = 0.0; + net().m_new.Analog = 99.0; } ATTR_COLD void netlist_analog_output_t::initial(const double val) { - net().m_cur.Analog = val; - net().m_new.Analog = 99.0; + net().m_cur.Analog = val; + net().m_new.Analog = 99.0; } // ---------------------------------------------------------------------------------------- @@ -641,71 +638,71 @@ ATTR_COLD void netlist_analog_output_t::initial(const double val) // ---------------------------------------------------------------------------------------- ATTR_COLD netlist_param_t::netlist_param_t(const param_type_t atype) - : netlist_owned_object_t(PARAM, ANALOG) - , m_param_type(atype) + : netlist_owned_object_t(PARAM, ANALOG) + , m_param_type(atype) { } ATTR_COLD netlist_param_double_t::netlist_param_double_t() - : netlist_param_t(DOUBLE) - , m_param(0.0) + : netlist_param_t(DOUBLE) + , m_param(0.0) { } ATTR_COLD netlist_param_int_t::netlist_param_int_t() - : netlist_param_t(INTEGER) - , m_param(0) + : netlist_param_t(INTEGER) + , m_param(0) { } ATTR_COLD netlist_param_logic_t::netlist_param_logic_t() - : netlist_param_int_t() + : netlist_param_int_t() { } ATTR_COLD netlist_param_str_t::netlist_param_str_t() - : netlist_param_t(STRING) - , m_param("") + : netlist_param_t(STRING) + , m_param("") { } ATTR_COLD netlist_param_model_t::netlist_param_model_t() - : netlist_param_t(MODEL) - , m_param("") + : netlist_param_t(MODEL) + , m_param("") { } ATTR_COLD double netlist_param_model_t::dValue(const pstring &entity, const double defval) const { - pstring tmp = this->Value(); - // .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon) - int p = tmp.ucase().find(entity.ucase() + "="); - if (p>=0) - { - int pblank = tmp.find(" ", p); - if (pblank < 0) pblank = tmp.len() + 1; - tmp = tmp.substr(p, pblank - p); - int pequal = tmp.find("=", 0); - if (pequal < 0) - netlist().xfatalerror("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr()); - tmp = tmp.substr(pequal+1); - double factor = 1.0; - switch (*(tmp.right(1).cstr())) - { - case 'm': factor = 1e-3; break; - case 'u': factor = 1e-6; break; - case 'n': factor = 1e-9; break; - case 'p': factor = 1e-12; break; - case 'f': factor = 1e-15; break; - case 'a': factor = 1e-18; break; - - } - if (factor != 1.0) - tmp = tmp.left(tmp.len() - 1); - return atof(tmp.cstr()) * factor; - } - else - return defval; + pstring tmp = this->Value(); + // .model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon) + int p = tmp.ucase().find(entity.ucase() + "="); + if (p>=0) + { + int pblank = tmp.find(" ", p); + if (pblank < 0) pblank = tmp.len() + 1; + tmp = tmp.substr(p, pblank - p); + int pequal = tmp.find("=", 0); + if (pequal < 0) + netlist().xfatalerror("parameter %s misformat in model %s temp %s\n", entity.cstr(), Value().cstr(), tmp.cstr()); + tmp = tmp.substr(pequal+1); + double factor = 1.0; + switch (*(tmp.right(1).cstr())) + { + case 'm': factor = 1e-3; break; + case 'u': factor = 1e-6; break; + case 'n': factor = 1e-9; break; + case 'p': factor = 1e-12; break; + case 'f': factor = 1e-15; break; + case 'a': factor = 1e-18; break; + + } + if (factor != 1.0) + tmp = tmp.left(tmp.len() - 1); + return atof(tmp.cstr()) * factor; + } + else + return defval; } @@ -715,28 +712,28 @@ ATTR_COLD double netlist_param_model_t::dValue(const pstring &entity, const doub ATTR_HOT inline void NETLIB_NAME(mainclock)::mc_update(netlist_net_t &net, const netlist_time curtime) { - net.m_new.Q = !net.m_new.Q; - net.set_time(curtime); - net.update_devs(); + net.m_new.Q = !net.m_new.Q; + net.set_time(curtime); + net.update_devs(); } NETLIB_START(mainclock) { - register_output("Q", m_Q); + register_output("Q", m_Q); - register_param("FREQ", m_freq, 7159000.0 * 5); - m_inc = netlist_time::from_hz(m_freq.Value()*2); + register_param("FREQ", m_freq, 7159000.0 * 5); + m_inc = netlist_time::from_hz(m_freq.Value()*2); } NETLIB_UPDATE_PARAM(mainclock) { - m_inc = netlist_time::from_hz(m_freq.Value()*2); + m_inc = netlist_time::from_hz(m_freq.Value()*2); } NETLIB_UPDATE(mainclock) { - netlist_net_t &net = m_Q.net(); - // this is only called during setup ... - net.m_new.Q = !net.m_new.Q; - net.set_time(netlist().time() + m_inc); + netlist_net_t &net = m_Q.net(); + // this is only called during setup ... + net.m_new.Q = !net.m_new.Q; + net.set_time(netlist().time() + m_inc); } diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h index 60b0df807d2..9bea1e4579e 100644 --- a/src/emu/netlist/nl_base.h +++ b/src/emu/netlist/nl_base.h @@ -192,17 +192,17 @@ typedef delegate<void ()> net_update_delegate; #define NETLIB_UPDATEI() ATTR_HOT ATTR_ALIGN inline void update(void) #define NETLIB_DEVICE_BASE(_name, _pclass, _extra, _priv) \ - class _name : public _pclass \ - { \ - public: \ - _name() \ - : _pclass() { } \ - protected: \ - _extra \ - ATTR_HOT void update(); \ - ATTR_HOT void start(); \ - _priv \ - } + class _name : public _pclass \ + { \ + public: \ + _name() \ + : _pclass() { } \ + protected: \ + _extra \ + ATTR_HOT void update(); \ + ATTR_HOT void start(); \ + _priv \ + } #define NETLIB_DEVICE_DERIVED(_name, _pclass, _priv) \ NETLIB_DEVICE_BASE(NETLIB_NAME(_name), NETLIB_NAME(_pclass), , _priv) @@ -211,28 +211,28 @@ typedef delegate<void ()> net_update_delegate; NETLIB_DEVICE_BASE(NETLIB_NAME(_name), netlist_device_t, , _priv) #define NETLIB_SUBDEVICE(_name, _priv) \ - class NETLIB_NAME(_name) : public netlist_device_t \ - { \ - public: \ - NETLIB_NAME(_name) () \ - : netlist_device_t() \ - { } \ - /*protected:*/ \ - ATTR_HOT void update(); \ - ATTR_HOT void start(); \ - public: \ - _priv \ - } + class NETLIB_NAME(_name) : public netlist_device_t \ + { \ + public: \ + NETLIB_NAME(_name) () \ + : netlist_device_t() \ + { } \ + /*protected:*/ \ + ATTR_HOT void update(); \ + ATTR_HOT void start(); \ + public: \ + _priv \ + } #define NETLIB_DEVICE_WITH_PARAMS(_name, _priv) \ - NETLIB_DEVICE_BASE(NETLIB_NAME(_name), netlist_device_t, \ - ATTR_HOT void update_param(); \ - , _priv) + NETLIB_DEVICE_BASE(NETLIB_NAME(_name), netlist_device_t, \ + ATTR_HOT void update_param(); \ + , _priv) #define NETLIB_DEVICE_WITH_PARAMS_DERIVED(_name, _pclass, _priv) \ - NETLIB_DEVICE_BASE(NETLIB_NAME(_name), NETLIB_NAME(_pclass), \ - ATTR_HOT void update_param(); \ - , _priv) + NETLIB_DEVICE_BASE(NETLIB_NAME(_name), NETLIB_NAME(_pclass), \ + ATTR_HOT void update_param(); \ + , _priv) // ---------------------------------------------------------------------------------------- // forward definitions @@ -253,73 +253,73 @@ class NETLIB_NAME(mainclock); class netlist_object_t { - NETLIST_PREVENT_COPYING(netlist_object_t) + NETLIST_PREVENT_COPYING(netlist_object_t) public: enum type_t { - TERMINAL = 0, + TERMINAL = 0, INPUT = 1, OUTPUT = 2, PARAM = 3, NET = 4, - DEVICE = 5, - NETLIST = 6, + DEVICE = 5, + NETLIST = 6, + }; + enum family_t { + // Terminal families + LOGIC = 1, + ANALOG = 2, + // Device families + GENERIC = 3, // <== devices usually fall into this category + RESISTOR = 4, // Resistor + CAPACITOR = 5, // Capacitor + DIODE = 6, // Diode + BJT_SWITCH = 7, // BJT(Switch) + VCVS = 8, // Voltage controlled voltage source + VCCS = 9, // Voltage controlled voltage source }; - enum family_t { - // Terminal families - LOGIC = 1, - ANALOG = 2, - // Device families - GENERIC = 3, // <== devices usually fall into this category - RESISTOR = 4, // Resistor - CAPACITOR = 5, // Capacitor - DIODE = 6, // Diode - BJT_SWITCH = 7, // BJT(Switch) - VCVS = 8, // Voltage controlled voltage source - VCCS = 9, // Voltage controlled voltage source - }; ATTR_COLD netlist_object_t(const type_t atype, const family_t afamily); virtual ~netlist_object_t(); ATTR_COLD void init_object(netlist_base_t &nl, const pstring &aname); - ATTR_COLD bool isInitalized() { return (m_netlist != NULL); } + ATTR_COLD bool isInitalized() { return (m_netlist != NULL); } - ATTR_COLD const pstring &name() const; + ATTR_COLD const pstring &name() const; - PSTATE_INTERFACE(*m_netlist, name()) + PSTATE_INTERFACE(*m_netlist, name()) #if 0 - template<class C> ATTR_COLD void save(C &state, const pstring &stname) - { - save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), &state); - } + template<class C> ATTR_COLD void save(C &state, const pstring &stname) + { + save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), &state); + } #endif ATTR_HOT inline const type_t type() const { return m_objtype; } - ATTR_HOT inline const family_t family() const { return m_family; } + ATTR_HOT inline const family_t family() const { return m_family; } ATTR_HOT inline const bool isType(const type_t atype) const { return (m_objtype == atype); } - ATTR_HOT inline const bool isFamily(const family_t afamily) const { return (m_family == afamily); } + ATTR_HOT inline const bool isFamily(const family_t afamily) const { return (m_family == afamily); } - ATTR_HOT inline netlist_base_t & RESTRICT netlist() { return *m_netlist; } - ATTR_HOT inline const netlist_base_t & RESTRICT netlist() const { return *m_netlist; } + ATTR_HOT inline netlist_base_t & RESTRICT netlist() { return *m_netlist; } + ATTR_HOT inline const netlist_base_t & RESTRICT netlist() const { return *m_netlist; } protected: #if 0 - // pstate_interface virtual - ATTR_COLD virtual void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, const int count, void *ptr); + // pstate_interface virtual + ATTR_COLD virtual void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, const int count, void *ptr); #endif - // must call parent save_register ! - ATTR_COLD virtual void save_register() { }; + // must call parent save_register ! + ATTR_COLD virtual void save_register() { }; private: - pstring m_name; + pstring m_name; const type_t m_objtype; - const family_t m_family; - netlist_base_t * RESTRICT m_netlist; + const family_t m_family; + netlist_base_t * RESTRICT m_netlist; }; // ---------------------------------------------------------------------------------------- @@ -328,15 +328,15 @@ private: class netlist_owned_object_t : public netlist_object_t { - NETLIST_PREVENT_COPYING(netlist_owned_object_t) + NETLIST_PREVENT_COPYING(netlist_owned_object_t) public: - ATTR_COLD netlist_owned_object_t(const type_t atype, const family_t afamily); + ATTR_COLD netlist_owned_object_t(const type_t atype, const family_t afamily); - ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname); + ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname); - ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; } + ATTR_HOT inline netlist_core_device_t & RESTRICT netdev() const { return *m_netdev; } private: - netlist_core_device_t * RESTRICT m_netdev; + netlist_core_device_t * RESTRICT m_netdev; }; // ---------------------------------------------------------------------------------------- @@ -345,46 +345,46 @@ private: class netlist_core_terminal_t : public netlist_owned_object_t { - NETLIST_PREVENT_COPYING(netlist_core_terminal_t) + NETLIST_PREVENT_COPYING(netlist_core_terminal_t) public: - /* needed here ... */ + /* needed here ... */ - enum state_e { - STATE_INP_PASSIVE = 0, - STATE_INP_ACTIVE = 1, - STATE_INP_HL = 2, - STATE_INP_LH = 4, - STATE_OUT = 128, - STATE_NONEX = 256 - }; + enum state_e { + STATE_INP_PASSIVE = 0, + STATE_INP_ACTIVE = 1, + STATE_INP_HL = 2, + STATE_INP_LH = 4, + STATE_OUT = 128, + STATE_NONEX = 256 + }; ATTR_COLD netlist_core_terminal_t(const type_t atype, const family_t afamily); ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname, const state_e astate); - ATTR_COLD void set_net(netlist_net_t &anet); - ATTR_COLD inline bool has_net() const { return (m_net != NULL); } - ATTR_HOT inline const netlist_net_t & RESTRICT net() const { return *m_net;} - ATTR_HOT inline netlist_net_t & RESTRICT net() { return *m_net;} + ATTR_COLD void set_net(netlist_net_t &anet); + ATTR_COLD inline bool has_net() const { return (m_net != NULL); } + ATTR_HOT inline const netlist_net_t & RESTRICT net() const { return *m_net;} + ATTR_HOT inline netlist_net_t & RESTRICT net() { return *m_net;} - ATTR_HOT inline const bool is_state(const state_e astate) const { return (m_state == astate); } - ATTR_HOT inline const state_e state() const { return m_state; } - ATTR_HOT inline void set_state(const state_e astate) - { - assert(astate != STATE_NONEX); - m_state = astate; - } + ATTR_HOT inline const bool is_state(const state_e astate) const { return (m_state == astate); } + ATTR_HOT inline const state_e state() const { return m_state; } + ATTR_HOT inline void set_state(const state_e astate) + { + assert(astate != STATE_NONEX); + m_state = astate; + } - netlist_core_terminal_t *m_update_list_next; + netlist_core_terminal_t *m_update_list_next; protected: - ATTR_COLD virtual void save_register() { save(NAME(m_state)); netlist_owned_object_t::save_register(); } + ATTR_COLD virtual void save_register() { save(NAME(m_state)); netlist_owned_object_t::save_register(); } private: - netlist_net_t * RESTRICT m_net; - state_e m_state; + netlist_net_t * RESTRICT m_net; + state_e m_state; }; NETLIST_SAVE_TYPE(netlist_core_terminal_t::state_e, DT_INT); @@ -392,45 +392,45 @@ NETLIST_SAVE_TYPE(netlist_core_terminal_t::state_e, DT_INT); class netlist_terminal_t : public netlist_core_terminal_t { - NETLIST_PREVENT_COPYING(netlist_terminal_t) + NETLIST_PREVENT_COPYING(netlist_terminal_t) public: - ATTR_COLD netlist_terminal_t(); + ATTR_COLD netlist_terminal_t(); - double m_Idr; // drive current - double m_go; // conductance for Voltage from other term - double m_gt; // conductance for total conductance + double m_Idr; // drive current + double m_go; // conductance for Voltage from other term + double m_gt; // conductance for total conductance - ATTR_HOT inline void set(const double G) - { - m_Idr = 0; - m_go = m_gt = G; - } + ATTR_HOT inline void set(const double G) + { + m_Idr = 0; + m_go = m_gt = G; + } - ATTR_HOT inline void set(const double GO, const double GT) - { - m_Idr = 0; - m_go = GO; - m_gt = GT; - } + ATTR_HOT inline void set(const double GO, const double GT) + { + m_Idr = 0; + m_go = GO; + m_gt = GT; + } - ATTR_HOT inline void set(const double GO, const double GT, const double I) - { - m_Idr = I; - m_go = GO; - m_gt = GT; - } + ATTR_HOT inline void set(const double GO, const double GT, const double I) + { + m_Idr = I; + m_go = GO; + m_gt = GT; + } - netlist_terminal_t *m_otherterm; + netlist_terminal_t *m_otherterm; protected: - ATTR_COLD virtual void save_register() - { - save(NAME(m_Idr)); - save(NAME(m_go)); - save(NAME(m_gt)); - netlist_core_terminal_t::save_register(); - } + ATTR_COLD virtual void save_register() + { + save(NAME(m_Idr)); + save(NAME(m_go)); + save(NAME(m_gt)); + netlist_core_terminal_t::save_register(); + } }; @@ -446,10 +446,10 @@ public: ATTR_COLD netlist_input_t(const type_t atype, const family_t afamily) : netlist_core_terminal_t(atype, afamily) - , m_low_thresh_V(0) - , m_high_thresh_V(0) + , m_low_thresh_V(0) + , m_high_thresh_V(0) { - set_state(STATE_INP_ACTIVE); + set_state(STATE_INP_ACTIVE); } ATTR_HOT inline void inactivate(); @@ -521,115 +521,115 @@ public: class netlist_net_t : public netlist_object_t { - NETLIST_PREVENT_COPYING(netlist_net_t) + NETLIST_PREVENT_COPYING(netlist_net_t) public: - typedef netlist_list_t<netlist_net_t *> list_t; + typedef netlist_list_t<netlist_net_t *> list_t; - friend class NETLIB_NAME(mainclock); - friend class netlist_matrix_solver_t; - friend class netlist_logic_output_t; - friend class netlist_analog_output_t; + friend class NETLIB_NAME(mainclock); + friend class netlist_matrix_solver_t; + friend class netlist_logic_output_t; + friend class netlist_analog_output_t; - // FIXME: union does not work - struct hybrid_t - { - inline hybrid_t() : Q(0), Analog(0.0) {} - netlist_sig_t Q; - double Analog; - }; + // FIXME: union does not work + struct hybrid_t + { + inline hybrid_t() : Q(0), Analog(0.0) {} + netlist_sig_t Q; + double Analog; + }; - ATTR_COLD netlist_net_t(const type_t atype, const family_t afamily); - ATTR_COLD void init_object(netlist_base_t &nl, const pstring &aname); + ATTR_COLD netlist_net_t(const type_t atype, const family_t afamily); + ATTR_COLD void init_object(netlist_base_t &nl, const pstring &aname); - ATTR_COLD void register_con(netlist_core_terminal_t &terminal); - ATTR_COLD void merge_net(netlist_net_t *othernet); - ATTR_COLD void register_railterminal(netlist_output_t &mr); + ATTR_COLD void register_con(netlist_core_terminal_t &terminal); + ATTR_COLD void merge_net(netlist_net_t *othernet); + ATTR_COLD void register_railterminal(netlist_output_t &mr); - /* inline not always works out */ - ATTR_HOT inline void update_devs(); + /* inline not always works out */ + ATTR_HOT inline void update_devs(); - ATTR_HOT inline const netlist_time time() const { return m_time; } - ATTR_HOT inline void set_time(const netlist_time ntime) { m_time = ntime; } + ATTR_HOT inline const netlist_time time() const { return m_time; } + ATTR_HOT inline void set_time(const netlist_time ntime) { m_time = ntime; } - ATTR_HOT inline bool isRailNet() const { return !(m_railterminal == NULL); } - ATTR_HOT inline const netlist_core_terminal_t & RESTRICT railterminal() const { return *m_railterminal; } + ATTR_HOT inline bool isRailNet() const { return !(m_railterminal == NULL); } + ATTR_HOT inline const netlist_core_terminal_t & RESTRICT railterminal() const { return *m_railterminal; } - /* Everything below is used by the logic subsystem */ + /* Everything below is used by the logic subsystem */ - ATTR_HOT inline void inc_active(); - ATTR_HOT inline void dec_active(); + ATTR_HOT inline void inc_active(); + ATTR_HOT inline void dec_active(); - ATTR_HOT inline const int active_count() const { return m_active; } + ATTR_HOT inline const int active_count() const { return m_active; } - ATTR_HOT inline const netlist_sig_t Q() const - { - assert(family() == LOGIC); - return m_cur.Q; - } + ATTR_HOT inline const netlist_sig_t Q() const + { + assert(family() == LOGIC); + return m_cur.Q; + } - ATTR_HOT inline const netlist_sig_t last_Q() const - { - assert(family() == LOGIC); - return m_last.Q; - } + ATTR_HOT inline const netlist_sig_t last_Q() const + { + assert(family() == LOGIC); + return m_last.Q; + } - ATTR_HOT inline const netlist_sig_t new_Q() const - { - assert(family() == LOGIC); - return m_new.Q; - } + ATTR_HOT inline const netlist_sig_t new_Q() const + { + assert(family() == LOGIC); + return m_new.Q; + } - ATTR_HOT inline const double Q_Analog() const - { - //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); - assert(family() == ANALOG); - return m_cur.Analog; - } + ATTR_HOT inline const double Q_Analog() const + { + //assert(object_type(SIGNAL_MASK) == SIGNAL_ANALOG); + assert(family() == ANALOG); + return m_cur.Analog; + } - ATTR_HOT inline void push_to_queue(const netlist_time &delay); - ATTR_HOT bool is_queued() { return m_in_queue == 1; } + ATTR_HOT inline void push_to_queue(const netlist_time &delay); + ATTR_HOT bool is_queued() { return m_in_queue == 1; } - // m_terms is only used by analog subsystem - typedef netlist_list_t<netlist_terminal_t *> terminal_list_t; + // m_terms is only used by analog subsystem + typedef netlist_list_t<netlist_terminal_t *> terminal_list_t; - terminal_list_t m_terms; - netlist_matrix_solver_t *m_solver; + terminal_list_t m_terms; + netlist_matrix_solver_t *m_solver; - netlist_core_terminal_t *m_head; + netlist_core_terminal_t *m_head; protected: - hybrid_t m_last; - hybrid_t m_cur; - hybrid_t m_new; + hybrid_t m_last; + hybrid_t m_cur; + hybrid_t m_new; - UINT32 m_num_cons; + UINT32 m_num_cons; protected: - ATTR_COLD virtual void save_register() - { - save(NAME(m_last.Analog)); - save(NAME(m_cur.Analog)); - save(NAME(m_new.Analog)); - save(NAME(m_last.Q)); - save(NAME(m_cur.Q)); - save(NAME(m_new.Q)); - save(NAME(m_time)); - save(NAME(m_active)); - save(NAME(m_in_queue)); - netlist_object_t::save_register(); - } + ATTR_COLD virtual void save_register() + { + save(NAME(m_last.Analog)); + save(NAME(m_cur.Analog)); + save(NAME(m_new.Analog)); + save(NAME(m_last.Q)); + save(NAME(m_cur.Q)); + save(NAME(m_new.Q)); + save(NAME(m_time)); + save(NAME(m_active)); + save(NAME(m_in_queue)); + netlist_object_t::save_register(); + } private: - ATTR_HOT void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const; + ATTR_HOT void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const; - netlist_time m_time; - INT32 m_active; - UINT32 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ + netlist_time m_time; + INT32 m_active; + UINT32 m_in_queue; /* 0: not in queue, 1: in queue, 2: last was taken */ - netlist_core_terminal_t * RESTRICT m_railterminal; + netlist_core_terminal_t * RESTRICT m_railterminal; }; @@ -639,12 +639,12 @@ private: class netlist_output_t : public netlist_core_terminal_t { - NETLIST_PREVENT_COPYING(netlist_output_t) + NETLIST_PREVENT_COPYING(netlist_output_t) public: ATTR_COLD netlist_output_t(const type_t atype, const family_t afamily); - ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname); + ATTR_COLD void init_object(netlist_core_device_t &dev, const pstring &aname); double m_low_V; double m_high_V; @@ -658,23 +658,23 @@ private: class netlist_logic_output_t : public netlist_output_t { - NETLIST_PREVENT_COPYING(netlist_logic_output_t) + NETLIST_PREVENT_COPYING(netlist_logic_output_t) public: ATTR_COLD netlist_logic_output_t(); ATTR_COLD void initial(const netlist_sig_t val); - ATTR_COLD void set_levels(const double low, const double high); + ATTR_COLD void set_levels(const double low, const double high); ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time &delay) { - netlist_net_t &anet = net(); + netlist_net_t &anet = net(); if (EXPECTED(newQ != anet.m_new.Q)) { - anet.m_new.Q = newQ; + anet.m_new.Q = newQ; if (anet.m_num_cons) - anet.push_to_queue(delay); + anet.push_to_queue(delay); } } }; @@ -689,19 +689,19 @@ public: class netlist_analog_output_t : public netlist_output_t { - NETLIST_PREVENT_COPYING(netlist_analog_output_t) + NETLIST_PREVENT_COPYING(netlist_analog_output_t) public: ATTR_COLD netlist_analog_output_t(); - ATTR_COLD void initial(const double val); + ATTR_COLD void initial(const double val); - ATTR_HOT inline void set_Q(const double newQ, const netlist_time &delay) + ATTR_HOT inline void set_Q(const double newQ, const netlist_time &delay) { if (newQ != net().m_new.Analog) { - net().m_new.Analog = newQ; - net().push_to_queue(delay); + net().m_new.Analog = newQ; + net().push_to_queue(delay); } } @@ -713,105 +713,105 @@ public: class netlist_param_t : public netlist_owned_object_t { - NETLIST_PREVENT_COPYING(netlist_param_t) + NETLIST_PREVENT_COPYING(netlist_param_t) public: - enum param_type_t { - MODEL, - STRING, - DOUBLE, - INTEGER, - LOGIC - }; + enum param_type_t { + MODEL, + STRING, + DOUBLE, + INTEGER, + LOGIC + }; - ATTR_COLD netlist_param_t(const param_type_t atype); + ATTR_COLD netlist_param_t(const param_type_t atype); - ATTR_HOT inline const param_type_t param_type() const { return m_param_type; } + ATTR_HOT inline const param_type_t param_type() const { return m_param_type; } private: - const param_type_t m_param_type; + const param_type_t m_param_type; }; class netlist_param_double_t : public netlist_param_t { - NETLIST_PREVENT_COPYING(netlist_param_double_t) + NETLIST_PREVENT_COPYING(netlist_param_double_t) public: - ATTR_COLD netlist_param_double_t(); + ATTR_COLD netlist_param_double_t(); - ATTR_HOT inline void setTo(const double param); - ATTR_COLD inline void initial(const double val) { m_param = val; } - ATTR_HOT inline const double Value() const { return m_param; } + ATTR_HOT inline void setTo(const double param); + ATTR_COLD inline void initial(const double val) { m_param = val; } + ATTR_HOT inline const double Value() const { return m_param; } protected: - ATTR_COLD virtual void save_register() - { - save(NAME(m_param)); - netlist_param_t::save_register(); - } + ATTR_COLD virtual void save_register() + { + save(NAME(m_param)); + netlist_param_t::save_register(); + } private: - double m_param; + double m_param; }; class netlist_param_int_t : public netlist_param_t { - NETLIST_PREVENT_COPYING(netlist_param_int_t) + NETLIST_PREVENT_COPYING(netlist_param_int_t) public: - ATTR_COLD netlist_param_int_t(); + ATTR_COLD netlist_param_int_t(); - ATTR_HOT inline void setTo(const int param); - ATTR_COLD inline void initial(const int val) { m_param = val; } + ATTR_HOT inline void setTo(const int param); + ATTR_COLD inline void initial(const int val) { m_param = val; } - ATTR_HOT inline const int Value() const { return m_param; } + ATTR_HOT inline const int Value() const { return m_param; } protected: - ATTR_COLD virtual void save_register() - { - save(NAME(m_param)); - netlist_param_t::save_register(); - } + ATTR_COLD virtual void save_register() + { + save(NAME(m_param)); + netlist_param_t::save_register(); + } private: - int m_param; + int m_param; }; class netlist_param_logic_t : public netlist_param_int_t { - NETLIST_PREVENT_COPYING(netlist_param_logic_t) + NETLIST_PREVENT_COPYING(netlist_param_logic_t) public: - ATTR_COLD netlist_param_logic_t(); + ATTR_COLD netlist_param_logic_t(); }; class netlist_param_str_t : public netlist_param_t { - NETLIST_PREVENT_COPYING(netlist_param_str_t) + NETLIST_PREVENT_COPYING(netlist_param_str_t) public: - ATTR_COLD netlist_param_str_t(); + ATTR_COLD netlist_param_str_t(); - ATTR_HOT inline void setTo(const pstring ¶m); - ATTR_COLD inline void initial(const pstring &val) { m_param = val; } + ATTR_HOT inline void setTo(const pstring ¶m); + ATTR_COLD inline void initial(const pstring &val) { m_param = val; } - ATTR_HOT inline const pstring &Value() const { return m_param; } + ATTR_HOT inline const pstring &Value() const { return m_param; } private: - pstring m_param; + pstring m_param; }; class netlist_param_model_t : public netlist_param_t { - NETLIST_PREVENT_COPYING(netlist_param_model_t) + NETLIST_PREVENT_COPYING(netlist_param_model_t) public: - ATTR_COLD netlist_param_model_t(); + ATTR_COLD netlist_param_model_t(); - ATTR_COLD inline void initial(const pstring &val) { m_param = val; } + ATTR_COLD inline void initial(const pstring &val) { m_param = val; } - ATTR_HOT inline const pstring &Value() const { return m_param; } + ATTR_HOT inline const pstring &Value() const { return m_param; } - /* these should be cached! */ - ATTR_COLD double dValue(const pstring &entity, const double defval = 0.0) const; + /* these should be cached! */ + ATTR_COLD double dValue(const pstring &entity, const double defval = 0.0) const; private: - pstring m_param; + pstring m_param; }; // ---------------------------------------------------------------------------------------- @@ -820,15 +820,15 @@ private: class netlist_core_device_t : public netlist_object_t { - NETLIST_PREVENT_COPYING(netlist_core_device_t) + NETLIST_PREVENT_COPYING(netlist_core_device_t) public: - typedef netlist_list_t<netlist_core_device_t *> list_t; + typedef netlist_list_t<netlist_core_device_t *> list_t; - ATTR_COLD netlist_core_device_t(); - ATTR_COLD netlist_core_device_t(const family_t afamily); + ATTR_COLD netlist_core_device_t(); + ATTR_COLD netlist_core_device_t(const family_t afamily); - ATTR_COLD virtual ~netlist_core_device_t(); + ATTR_COLD virtual ~netlist_core_device_t(); ATTR_COLD virtual void init(netlist_base_t &anetlist, const pstring &name); @@ -848,7 +848,7 @@ public: #endif } - ATTR_HOT const netlist_sig_t INPLOGIC_PASSIVE(netlist_logic_input_t &inp); + ATTR_HOT const netlist_sig_t INPLOGIC_PASSIVE(netlist_logic_input_t &inp); ATTR_HOT inline const netlist_sig_t INPLOGIC(const netlist_logic_input_t &inp) const { @@ -885,10 +885,10 @@ public: ATTR_HOT virtual void dec_active() { } ATTR_HOT virtual void step_time(const double st) { } - ATTR_HOT virtual void update_terminals() { } + ATTR_HOT virtual void update_terminals() { } #if (NL_KEEP_STATISTICS) - /* stats */ + /* stats */ osd_ticks_t total_time; INT32 stat_count; #endif @@ -908,11 +908,11 @@ private: class netlist_device_t : public netlist_core_device_t { - NETLIST_PREVENT_COPYING(netlist_device_t) + NETLIST_PREVENT_COPYING(netlist_device_t) public: ATTR_COLD netlist_device_t(); - ATTR_COLD netlist_device_t(const family_t afamily); + ATTR_COLD netlist_device_t(const family_t afamily); ATTR_COLD virtual ~netlist_device_t(); @@ -921,9 +921,9 @@ public: ATTR_COLD netlist_setup_t &setup(); ATTR_COLD void register_sub(netlist_device_t &dev, const pstring &name); - ATTR_COLD void register_subalias(const pstring &name, const netlist_core_terminal_t &term); + ATTR_COLD void register_subalias(const pstring &name, const netlist_core_terminal_t &term); - ATTR_COLD void register_terminal(const pstring &name, netlist_terminal_t &port); + ATTR_COLD void register_terminal(const pstring &name, netlist_terminal_t &port); ATTR_COLD void register_output(const pstring &name, netlist_output_t &out); @@ -932,23 +932,23 @@ public: ATTR_COLD void register_link_internal(netlist_input_t &in, netlist_output_t &out, const netlist_input_t::state_e aState); ATTR_COLD void register_link_internal(netlist_core_device_t &dev, netlist_input_t &in, netlist_output_t &out, const netlist_input_t::state_e aState); - /* driving logic outputs don't count in here */ + /* driving logic outputs don't count in here */ netlist_list_t<pstring, 20> m_terminals; protected: ATTR_HOT virtual void update() { } ATTR_HOT virtual void start() { } - ATTR_HOT virtual void update_terminals() { } + ATTR_HOT virtual void update_terminals() { } - template <class C, class T> + template <class C, class T> ATTR_COLD void register_param(const pstring &sname, C ¶m, const T initialVal) { - register_param(*this, sname, param, initialVal); + register_param(*this, sname, param, initialVal); } template <class C, class T> - ATTR_COLD void register_param(netlist_core_device_t &dev, const pstring &sname, C ¶m, const T initialVal); + ATTR_COLD void register_param(netlist_core_device_t &dev, const pstring &sname, C ¶m, const T initialVal); private: }; @@ -962,7 +962,7 @@ typedef tagmap_t<netlist_device_t *, 393> tagmap_devices_t; class netlist_base_t : public netlist_object_t, public pstate_manager_t { - NETLIST_PREVENT_COPYING(netlist_base_t) + NETLIST_PREVENT_COPYING(netlist_base_t) public: typedef netlist_timed_queue<netlist_net_t, netlist_time, 512> queue_t; @@ -970,8 +970,8 @@ public: netlist_base_t(); virtual ~netlist_base_t(); - ATTR_HOT inline const queue_t &queue() const { return m_queue; } - ATTR_HOT inline queue_t &queue() { return m_queue; } + ATTR_HOT inline const queue_t &queue() const { return m_queue; } + ATTR_HOT inline queue_t &queue() { return m_queue; } ATTR_HOT inline void push_to_queue(netlist_net_t &out, const netlist_time &attime) { @@ -984,21 +984,21 @@ public: ATTR_HOT inline const netlist_time &time() const { return m_time_ps; } - ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev); - ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev); - ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup; } + ATTR_COLD void set_mainclock_dev(NETLIB_NAME(mainclock) *dev); + ATTR_COLD void set_solver_dev(NETLIB_NAME(solver) *dev); + ATTR_COLD void set_setup(netlist_setup_t *asetup) { m_setup = asetup; } - ATTR_COLD netlist_net_t *find_net(const pstring &name); + ATTR_COLD netlist_net_t *find_net(const pstring &name); - ATTR_COLD void set_clock_freq(UINT64 clockfreq); + ATTR_COLD void set_clock_freq(UINT64 clockfreq); - ATTR_COLD netlist_setup_t &setup() { return *m_setup; } + ATTR_COLD netlist_setup_t &setup() { return *m_setup; } ATTR_COLD void reset(); ATTR_COLD void xfatalerror(const char *format, ...) const; - tagmap_devices_t m_devices; - netlist_net_t::list_t m_nets; + tagmap_devices_t m_devices; + netlist_net_t::list_t m_nets; protected: @@ -1006,14 +1006,14 @@ protected: virtual void vfatalerror(const char *format, va_list ap) const = 0; protected: - ATTR_COLD virtual void save_register() - { - //queue_t m_queue; - save(NAME(m_time_ps)); - save(NAME(m_rem)); - save(NAME(m_div)); - netlist_object_t::save_register(); - } + ATTR_COLD virtual void save_register() + { + //queue_t m_queue; + save(NAME(m_time_ps)); + save(NAME(m_rem)); + save(NAME(m_div)); + netlist_object_t::save_register(); + } #if (NL_KEEP_STATISTICS) // performance @@ -1023,17 +1023,17 @@ protected: #endif private: - ATTR_HOT void update_time(const netlist_time t, INT32 &atime); + ATTR_HOT void update_time(const netlist_time t, INT32 &atime); - netlist_time m_time_ps; - queue_t m_queue; + netlist_time m_time_ps; + queue_t m_queue; UINT32 m_rem; UINT32 m_div; NETLIB_NAME(mainclock) * m_mainclock; - NETLIB_NAME(solver) * m_solver; + NETLIB_NAME(solver) * m_solver; - netlist_setup_t *m_setup; + netlist_setup_t *m_setup; }; // ---------------------------------------------------------------------------------------- @@ -1060,8 +1060,8 @@ public: protected: ATTR_COLD void start() { - register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE); - register_output("Q", m_Q); + register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE); + register_output("Q", m_Q); m_Q.initial(1); } @@ -1072,7 +1072,7 @@ protected: else if (m_I.Q_Analog() < m_I.m_low_thresh_V) OUTLOGIC(m_Q, 0, NLTIME_FROM_NS(1)); else - OUTLOGIC(m_Q, m_Q.net().last_Q(), NLTIME_FROM_NS(1)); + OUTLOGIC(m_Q, m_Q.net().last_Q(), NLTIME_FROM_NS(1)); } }; @@ -1084,7 +1084,7 @@ protected: class nld_d_to_a_proxy : public netlist_device_t { public: - ATTR_COLD nld_d_to_a_proxy(netlist_output_t &out_proxied) + ATTR_COLD nld_d_to_a_proxy(netlist_output_t &out_proxied) : netlist_device_t() { //assert(out_proxied.object_type(SIGNAL_MASK) == SIGNAL_DIGITAL); @@ -1093,7 +1093,7 @@ public: m_high_V = out_proxied.m_high_V; } - ATTR_COLD virtual ~nld_d_to_a_proxy() {} + ATTR_COLD virtual ~nld_d_to_a_proxy() {} netlist_ttl_input_t m_I; netlist_analog_output_t m_Q; @@ -1101,8 +1101,8 @@ public: protected: ATTR_COLD void start() { - register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE); - register_output("Q", m_Q); + register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE); + register_output("Q", m_Q); m_Q.initial(0); } @@ -1122,20 +1122,20 @@ private: ATTR_HOT inline void netlist_param_str_t::setTo(const pstring ¶m) { - m_param = param; - netdev().update_param(); + m_param = param; + netdev().update_param(); } ATTR_HOT inline void netlist_param_int_t::setTo(const int param) { - m_param = param; - netdev().update_param(); + m_param = param; + netdev().update_param(); } ATTR_HOT inline void netlist_param_double_t::setTo(const double param) { - m_param = param; - netdev().update_param(); + m_param = param; + netdev().update_param(); } @@ -1193,12 +1193,12 @@ ATTR_HOT inline void netlist_net_t::inc_active() m_active++; if (USE_DEACTIVE_DEVICE) - if (m_active == 1 && m_in_queue > 0) - { - m_last = m_cur; - railterminal().netdev().inc_active(); - m_cur = m_new; - } + if (m_active == 1 && m_in_queue > 0) + { + m_last = m_cur; + railterminal().netdev().inc_active(); + m_cur = m_new; + } if (EXPECTED(m_active == 1 && m_in_queue == 0)) { @@ -1219,8 +1219,8 @@ ATTR_HOT inline void netlist_net_t::dec_active() { m_active--; if (USE_DEACTIVE_DEVICE) - if (m_active == 0) - railterminal().netdev().dec_active(); + if (m_active == 0) + railterminal().netdev().dec_active(); } @@ -1251,7 +1251,7 @@ ATTR_HOT inline const bool netlist_analog_input_t::is_highz() const class net_device_t_base_factory { - NETLIST_PREVENT_COPYING(net_device_t_base_factory) + NETLIST_PREVENT_COPYING(net_device_t_base_factory) public: net_device_t_base_factory(const pstring &name, const pstring &classname) : m_name(name), m_classname(classname) @@ -1271,7 +1271,7 @@ protected: template <class C> class net_device_t_factory : public net_device_t_base_factory { - NETLIST_PREVENT_COPYING(net_device_t_factory) + NETLIST_PREVENT_COPYING(net_device_t_factory) public: net_device_t_factory(const pstring &name, const pstring &classname) : net_device_t_base_factory(name, classname) { } @@ -1288,23 +1288,23 @@ class netlist_factory { public: - netlist_factory(); - ~netlist_factory(); + netlist_factory(); + ~netlist_factory(); - void initialize(); + void initialize(); - template<class _C> - void register_device(const pstring &name, const pstring &classname) - { - m_list.add(new net_device_t_factory< _C >(name, classname) ); - } + template<class _C> + void register_device(const pstring &name, const pstring &classname) + { + m_list.add(new net_device_t_factory< _C >(name, classname) ); + } - netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const; - netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const; + netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const; + netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const; private: - typedef netlist_list_t<net_device_t_base_factory *> list_t; - list_t m_list; + typedef netlist_list_t<net_device_t_base_factory *> list_t; + list_t m_list; }; diff --git a/src/emu/netlist/nl_config.h b/src/emu/netlist/nl_config.h index 63f8e8c8c6c..0f73d57b78c 100644 --- a/src/emu/netlist/nl_config.h +++ b/src/emu/netlist/nl_config.h @@ -65,10 +65,9 @@ typedef UINT8 netlist_sig_t; // prevent implicit copying #define NETLIST_PREVENT_COPYING(_name) \ - private: \ - _name(const _name &); \ - _name &operator=(const _name &); \ - + private: \ + _name(const _name &); \ + _name &operator=(const _name &); #if NL_KEEP_STATISTICS #define add_to_stat(v,x) do { v += (x); } while (0) #define inc_stat(v) add_to_stat(v, 1) diff --git a/src/emu/netlist/nl_lists.h b/src/emu/netlist/nl_lists.h index 3d4d70c0231..ef32fb03c1f 100644 --- a/src/emu/netlist/nl_lists.h +++ b/src/emu/netlist/nl_lists.h @@ -20,13 +20,12 @@ struct netlist_list_t { public: - struct entry_t { + struct entry_t { + // keep compatibility with tagmap + _ListClass object() { return m_obj; } - // keep compatibility with tagmap - _ListClass object() { return m_obj; } - - _ListClass m_obj; - }; + _ListClass m_obj; + }; ATTR_COLD netlist_list_t(int numElements = _NumElem) { @@ -36,25 +35,25 @@ public: m_ptr--; } - ATTR_COLD netlist_list_t(const netlist_list_t &rhs) - { - m_list = new entry_t[m_num_elements]; - m_ptr = m_list; - m_ptr--; - for (int i=0; i<rhs.count(); i++) - { - this->add(rhs[i]); - } - } - - ATTR_COLD netlist_list_t &operator=(const netlist_list_t &rhs) - { - for (int i=0; i<rhs.count(); i++) - { - this->add(rhs[i]); - } - return *this; - } + ATTR_COLD netlist_list_t(const netlist_list_t &rhs) + { + m_list = new entry_t[m_num_elements]; + m_ptr = m_list; + m_ptr--; + for (int i=0; i<rhs.count(); i++) + { + this->add(rhs[i]); + } + } + + ATTR_COLD netlist_list_t &operator=(const netlist_list_t &rhs) + { + for (int i=0; i<rhs.count(); i++) + { + this->add(rhs[i]); + } + return *this; + } ATTR_COLD ~netlist_list_t() @@ -64,50 +63,50 @@ public: ATTR_HOT inline void add(const _ListClass elem) { if (m_ptr-m_list >= m_num_elements - 1) - resize(m_num_elements * 2); + resize(m_num_elements * 2); (++m_ptr)->m_obj = elem; } ATTR_HOT inline void resize(const int new_size) { - int cnt = count(); - entry_t *m_new = new entry_t[new_size]; - entry_t *pd = m_new; - - for (entry_t *ps = m_list; ps <= m_ptr; ps++, pd++) - *pd = *ps; - delete[] m_list; - m_list = m_new; - m_ptr = m_list + cnt - 1; - m_num_elements = new_size; + int cnt = count(); + entry_t *m_new = new entry_t[new_size]; + entry_t *pd = m_new; + + for (entry_t *ps = m_list; ps <= m_ptr; ps++, pd++) + *pd = *ps; + delete[] m_list; + m_list = m_new; + m_ptr = m_list + cnt - 1; + m_num_elements = new_size; + } + ATTR_HOT inline void remove(const _ListClass elem) + { + for (entry_t *i = m_list; i <= m_ptr; i++) + { + if (i->object() == elem) + { + while (i < m_ptr) + { + *i = *(i+1); + i++; + } + m_ptr--; + return; + } + } + } + ATTR_HOT inline bool contains(const _ListClass elem) const + { + for (entry_t *i = m_list; i <= m_ptr; i++) + { + if (i->object() == elem) + return true; + } + return false; } - ATTR_HOT inline void remove(const _ListClass elem) - { - for (entry_t *i = m_list; i <= m_ptr; i++) - { - if (i->object() == elem) - { - while (i < m_ptr) - { - *i = *(i+1); - i++; - } - m_ptr--; - return; - } - } - } - ATTR_HOT inline bool contains(const _ListClass elem) const - { - for (entry_t *i = m_list; i <= m_ptr; i++) - { - if (i->object() == elem) - return true; - } - return false; - } ATTR_HOT inline entry_t *first() const { return (m_ptr >= m_list ? &m_list[0] : NULL ); } - ATTR_HOT inline entry_t *next(entry_t *lc) const { return (lc < last() ? lc + 1 : NULL ); } + ATTR_HOT inline entry_t *next(entry_t *lc) const { return (lc < last() ? lc + 1 : NULL ); } ATTR_HOT inline entry_t *last() const { return m_ptr; } ATTR_HOT inline int count() const { return m_ptr - m_list + 1; } ATTR_HOT inline bool empty() const { return (m_ptr < m_list); } @@ -115,16 +114,16 @@ public: ATTR_COLD void reset_and_free() { - for (entry_t *i = m_list; i <= m_ptr; i++) - { - delete i->object(); - } - reset(); + for (entry_t *i = m_list; i <= m_ptr; i++) + { + delete i->object(); + } + reset(); } - //ATTR_HOT inline entry_t *item(int i) const { return &m_list[i]; } + //ATTR_HOT inline entry_t *item(int i) const { return &m_list[i]; } ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index].m_obj; } - ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index].m_obj; } + ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index].m_obj; } private: entry_t * m_ptr; @@ -140,7 +139,7 @@ private: template <class _Element, class _Time, int _Size> class netlist_timed_queue { - NETLIST_PREVENT_COPYING(netlist_timed_queue) + NETLIST_PREVENT_COPYING(netlist_timed_queue) public: struct entry_t @@ -153,7 +152,7 @@ public: ATTR_HOT inline _Element & object() const { return *m_object; } ATTR_HOT inline const _Time *time_ptr() const { return &m_time; } - ATTR_HOT inline _Element *object_ptr() const { return m_object; } + ATTR_HOT inline _Element *object_ptr() const { return m_object; } private: _Time m_time; _Element *m_object; @@ -165,7 +164,7 @@ public: clear(); } - ATTR_HOT inline int capacity() const { return _Size; } + ATTR_HOT inline int capacity() const { return _Size; } ATTR_HOT inline bool is_empty() const { return (m_end == &m_list[0]); } ATTR_HOT inline bool is_not_empty() const { return (m_end > &m_list[0]); } diff --git a/src/emu/netlist/nl_parser.c b/src/emu/netlist/nl_parser.c index 42ccbda80b2..3766cba3117 100644 --- a/src/emu/netlist/nl_parser.c +++ b/src/emu/netlist/nl_parser.c @@ -27,18 +27,18 @@ void netlist_parser::parse(const char *buf) NL_VERBOSE_OUT(("Parser: Device: %s\n", n.cstr())); if (n == "NET_ALIAS") net_alias(); - else if (n == "NET_C") - net_c(); + else if (n == "NET_C") + net_c(); else if (n == "NETDEV_PARAM") netdev_param(); - else if (n == "NETDEV_R") - netdev_device(n, "R"); - else if (n == "NETDEV_C") - netdev_device(n, "C"); - else if (n == "NETDEV_POT") - netdev_device(n, "R"); - else if (n == "NETDEV_D") - netdev_device(n, "model", true); + else if (n == "NETDEV_R") + netdev_device(n, "R"); + else if (n == "NETDEV_C") + netdev_device(n, "C"); + else if (n == "NETDEV_POT") + netdev_device(n, "R"); + else if (n == "NETDEV_D") + netdev_device(n, "model", true); else if ((n == "NETDEV_TTL_CONST") || (n == "NETDEV_ANALOG_CONST")) netdev_const(n); else @@ -60,14 +60,14 @@ void netlist_parser::net_alias() void netlist_parser::net_c() { - pstring t1; - pstring t2; - skipws(); - t1 = getname(','); - skipws(); - t2 = getname(')'); - NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", t1.cstr(), t2.cstr())); - m_setup.register_link(t1 , t2); + pstring t1; + pstring t2; + skipws(); + t1 = getname(','); + skipws(); + t2 = getname(')'); + NL_VERBOSE_OUT(("Parser: Connect: %s %s\n", t1.cstr(), t2.cstr())); + m_setup.register_link(t1 , t2); } void netlist_parser::netdev_param() @@ -98,7 +98,7 @@ void netlist_parser::netdev_const(const pstring &dev_name) val = eval_param(); paramfq = name + ".CONST"; NL_VERBOSE_OUT(("Parser: Const: %s %f\n", name.cstr(), val)); - check_char(')'); + check_char(')'); m_setup.register_param(paramfq, val); } @@ -126,43 +126,43 @@ void netlist_parser::netdev_device(const pstring &dev_type) } /* if (cnt != dev->m_terminals.count() && !dev->variable_input_count()) - fatalerror("netlist: input count mismatch for %s - expected %d found %d\n", devname.cstr(), dev->m_terminals.count(), cnt); - if (dev->variable_input_count()) - { - NL_VERBOSE_OUT(("variable inputs %s: %d\n", dev->name().cstr(), cnt)); - } - */ + fatalerror("netlist: input count mismatch for %s - expected %d found %d\n", devname.cstr(), dev->m_terminals.count(), cnt); + if (dev->variable_input_count()) + { + NL_VERBOSE_OUT(("variable inputs %s: %d\n", dev->name().cstr(), cnt)); + } + */ } void netlist_parser::netdev_device(const pstring &dev_type, const pstring &default_param, bool isString) { - netlist_device_t *dev; + netlist_device_t *dev; - skipws(); - pstring devname = getname2(',', ')'); - pstring defparam = devname + "." + default_param; - dev = m_setup.factory().new_device_by_name(dev_type, m_setup); - m_setup.register_dev(dev, devname); - NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr())); - if (getc() != ')') - { - // have a default param - skipws(); - if (isString) - { - pstring val = getname(')'); - ungetc(); - NL_VERBOSE_OUT(("Parser: Default param: %s %s\n", defparam.cstr(), val.cstr())); - m_setup.register_param(defparam, val); - } - else - { - double val = eval_param(); - NL_VERBOSE_OUT(("Parser: Default param: %s %f\n", defparam.cstr(), val)); - m_setup.register_param(defparam, val); - } - } - check_char(')'); + skipws(); + pstring devname = getname2(',', ')'); + pstring defparam = devname + "." + default_param; + dev = m_setup.factory().new_device_by_name(dev_type, m_setup); + m_setup.register_dev(dev, devname); + NL_VERBOSE_OUT(("Parser: IC: %s\n", devname.cstr())); + if (getc() != ')') + { + // have a default param + skipws(); + if (isString) + { + pstring val = getname(')'); + ungetc(); + NL_VERBOSE_OUT(("Parser: Default param: %s %s\n", defparam.cstr(), val.cstr())); + m_setup.register_param(defparam, val); + } + else + { + double val = eval_param(); + NL_VERBOSE_OUT(("Parser: Default param: %s %f\n", defparam.cstr(), val)); + m_setup.register_param(defparam, val); + } + } + check_char(')'); } // ---------------------------------------------------------------------------------------- @@ -171,7 +171,7 @@ void netlist_parser::netdev_device(const pstring &dev_type, const pstring &defau void netlist_parser::skipeol() { - char c = getc(); + char c = getc(); while (c) { if (c == 10) @@ -197,27 +197,27 @@ void netlist_parser::skipws() case 13: break; case '/': - c = getc(); + c = getc(); if (c == '/') { - skipeol(); + skipeol(); } else if (c == '*') { - int f=0; - while ((c = getc()) != 0 ) - { - if (f == 0 && c == '*') - f=1; - else if (f == 1 && c== '/' ) - break; - else - f=0; - } + int f=0; + while ((c = getc()) != 0 ) + { + if (f == 0 && c == '*') + f=1; + else if (f == 1 && c== '/' ) + break; + else + f=0; + } } break; default: - ungetc(); + ungetc(); return; } } @@ -243,8 +243,8 @@ pstring netlist_parser::getname2(char sep1, char sep2) while ((c != sep1) && (c != sep2)) { - *p1++ = c; - c = getc(); + *p1++ = c; + c = getc(); } *p1 = 0; ungetc(); @@ -278,21 +278,21 @@ double netlist_parser::eval_param() f = i; ret = s.substr(strlen(macs[f])).as_double(&e); if ((f>0) && e) - m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n"); - if (f>0) - check_char(')'); + m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n"); + if (f>0) + check_char(')'); return ret * facs[f]; } unsigned char netlist_parser::getc() { - if (*m_px) - return *(m_px++); - else - return *m_px; + if (*m_px) + return *(m_px++); + else + return *m_px; } void netlist_parser::ungetc() { - m_px--; + m_px--; } diff --git a/src/emu/netlist/nl_parser.h b/src/emu/netlist/nl_parser.h index 4f673f18572..e985e05167f 100644 --- a/src/emu/netlist/nl_parser.h +++ b/src/emu/netlist/nl_parser.h @@ -12,7 +12,7 @@ class netlist_parser { - NETLIST_PREVENT_COPYING(netlist_parser) + NETLIST_PREVENT_COPYING(netlist_parser) public: netlist_parser(netlist_setup_t &setup) : m_setup(setup) {} @@ -20,10 +20,10 @@ public: void parse(const char *buf); void net_alias(); void netdev_param(); - void net_c(); + void net_c(); void netdev_const(const pstring &dev_name); void netdev_device(const pstring &dev_type); - void netdev_device(const pstring &dev_type, const pstring &default_param, bool isString = false); + void netdev_device(const pstring &dev_type, const pstring &default_param, bool isString = false); private: diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c index 21072b4ba45..e78b7299a16 100644 --- a/src/emu/netlist/nl_setup.c +++ b/src/emu/netlist/nl_setup.c @@ -17,9 +17,9 @@ static NETLIST_START(base) NETDEV_TTL_CONST(ttllow, 0) NETDEV_ANALOG_CONST(NC, NETLIST_HIGHIMP_V) - NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") - NET_MODEL(".model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") - NET_MODEL(".MODEL BC237B NPN(IS=1.8E-14 ISE=5.0E-14 ISC=1.72E-13 XTI=3 BF=400 BR=35.5 IKF=0.14 IKR=0.03 XTB=1.5 VAF=80 VAR=12.5 VJE=0.58 VJC=0.54 RE=0.6 RC=0.25 RB=0.56 CJE=13E-12 CJC=4E-12 XCJC=0.75 FC=0.5 NF=0.9955 NR=1.005 NE=1.46 NC=1.27 MJE=0.33 MJC=0.33 TF=0.64E-9 TR=50.72E-9 EG=1.11 KF=0 AF=1 VCEO=45V ICRATING=100M MFG=ZETEX)") + NET_MODEL(".model 1N914 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") + NET_MODEL(".model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)") + NET_MODEL(".MODEL BC237B NPN(IS=1.8E-14 ISE=5.0E-14 ISC=1.72E-13 XTI=3 BF=400 BR=35.5 IKF=0.14 IKR=0.03 XTB=1.5 VAF=80 VAR=12.5 VJE=0.58 VJC=0.54 RE=0.6 RC=0.25 RB=0.56 CJE=13E-12 CJC=4E-12 XCJC=0.75 FC=0.5 NF=0.9955 NR=1.005 NE=1.46 NC=1.27 MJE=0.33 MJC=0.33 TF=0.64E-9 TR=50.72E-9 EG=1.11 KF=0 AF=1 VCEO=45V ICRATING=100M MFG=ZETEX)") NETLIST_END @@ -30,15 +30,15 @@ NETLIST_END netlist_setup_t::netlist_setup_t(netlist_base_t &netlist) : m_netlist(netlist) - , m_proxy_cnt(0) + , m_proxy_cnt(0) { - netlist.set_setup(this); + netlist.set_setup(this); } void netlist_setup_t::init() { - m_factory.initialize(); - NETLIST_NAME(base)(*this); + m_factory.initialize(); + NETLIST_NAME(base)(*this); } @@ -59,7 +59,7 @@ netlist_setup_t::~netlist_setup_t() netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const pstring &name) { if (!(netlist().m_devices.add(name, dev, false)==TMERR_NONE)) - netlist().xfatalerror("Error adding %s to device list\n", name.cstr()); + netlist().xfatalerror("Error adding %s to device list\n", name.cstr()); return dev; } @@ -85,7 +85,7 @@ void netlist_setup_t::remove_dev(const pstring &name) netlist_device_t *dev = netlist().m_devices.find(name); pstring temp = name + "."; if (dev == NULL) - netlist().xfatalerror("Device %s does not exist\n", name.cstr()); + netlist().xfatalerror("Device %s does not exist\n", name.cstr()); //remove_start_with<tagmap_input_t>(m_inputs, temp); remove_start_with<tagmap_terminal_t>(m_terminals, temp); @@ -94,193 +94,193 @@ void netlist_setup_t::remove_dev(const pstring &name) tagmap_link_t::entry_t *p = m_links.first(); while (p != NULL) { - tagmap_link_t::entry_t *n = m_links.next(p); - if (temp.equals(p->object().e1.substr(0,temp.len())) || temp.equals(p->object().e2.substr(0,temp.len()))) - m_links.remove(p->object()); - p = n; + tagmap_link_t::entry_t *n = m_links.next(p); + if (temp.equals(p->object().e1.substr(0,temp.len())) || temp.equals(p->object().e2.substr(0,temp.len()))) + m_links.remove(p->object()); + p = n; } netlist().m_devices.remove(name); } void netlist_setup_t::register_model(const pstring &model) { - m_models.add(model); + m_models.add(model); } void netlist_setup_t::register_alias(const pstring &alias, const pstring &out) { - //if (!(m_alias.add(alias, new nstring(out), false)==TMERR_NONE)) + //if (!(m_alias.add(alias, new nstring(out), false)==TMERR_NONE)) if (!(m_alias.add(alias, out, false)==TMERR_NONE)) - netlist().xfatalerror("Error adding alias %s to alias list\n", alias.cstr()); + netlist().xfatalerror("Error adding alias %s to alias list\n", alias.cstr()); } pstring netlist_setup_t::objtype_as_astr(netlist_object_t &in) { - switch (in.type()) - { - case netlist_terminal_t::TERMINAL: - return "TERMINAL"; - break; - case netlist_terminal_t::INPUT: - return "INPUT"; - break; - case netlist_terminal_t::OUTPUT: - return "OUTPUT"; - break; - case netlist_terminal_t::NET: - return "NET"; - break; - case netlist_terminal_t::PARAM: - return "PARAM"; - break; - case netlist_terminal_t::DEVICE: - return "DEVICE"; - break; - case netlist_terminal_t::NETLIST: - return "NETLIST"; - break; - } - // FIXME: noreturn - netlist().xfatalerror("Unknown object type %d\n", in.type()); - return "Error"; + switch (in.type()) + { + case netlist_terminal_t::TERMINAL: + return "TERMINAL"; + break; + case netlist_terminal_t::INPUT: + return "INPUT"; + break; + case netlist_terminal_t::OUTPUT: + return "OUTPUT"; + break; + case netlist_terminal_t::NET: + return "NET"; + break; + case netlist_terminal_t::PARAM: + return "PARAM"; + break; + case netlist_terminal_t::DEVICE: + return "DEVICE"; + break; + case netlist_terminal_t::NETLIST: + return "NETLIST"; + break; + } + // FIXME: noreturn + netlist().xfatalerror("Unknown object type %d\n", in.type()); + return "Error"; } void netlist_setup_t::register_object(netlist_device_t &dev, netlist_core_device_t &upd_dev, const pstring &name, netlist_object_t &obj, const netlist_input_t::state_e state) { - switch (obj.type()) - { - case netlist_terminal_t::TERMINAL: - case netlist_terminal_t::INPUT: - case netlist_terminal_t::OUTPUT: - { - netlist_core_terminal_t &term = dynamic_cast<netlist_core_terminal_t &>(obj); - if (obj.isType(netlist_terminal_t::OUTPUT)) - dynamic_cast<netlist_output_t &>(term).init_object(upd_dev, dev.name() + "." + name); - else - term.init_object(upd_dev, dev.name() + "." + name, state); - - if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE)) - netlist().xfatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr()); - NL_VERBOSE_OUT(("%s %s\n", objtype_as_astr(term).cstr(), name.cstr())); - } - break; - case netlist_terminal_t::NET: - break; - case netlist_terminal_t::PARAM: - { - netlist_param_t ¶m = dynamic_cast<netlist_param_t &>(obj); - const pstring val = m_params_temp.find(name); - if (val != "") - { - switch (param.param_type()) - { - case netlist_param_t::DOUBLE: - { - NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr())); - double vald = 0; - if (sscanf(val.cstr(), "%lf", &vald) != 1) - netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr()); - dynamic_cast<netlist_param_double_t &>(param).initial(vald); - } - break; - case netlist_param_t::INTEGER: - case netlist_param_t::LOGIC: - { - NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", name.cstr(), val->cstr())); - int vald = 0; - if (sscanf(val.cstr(), "%d", &vald) != 1) - netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr()); - dynamic_cast<netlist_param_int_t &>(param).initial(vald); - } - break; - case netlist_param_t::STRING: - { - dynamic_cast<netlist_param_str_t &>(param).initial(val); - } - break; - case netlist_param_t::MODEL: - { - pstring search = (".model " + val + " ").ucase(); - bool found = false; - for (int i=0; i < m_models.count(); i++) - { - if (m_models[i].ucase().startsWith(search)) - { - int pl=m_models[i].find("("); - int pr=m_models[i].find("("); - dynamic_cast<netlist_param_model_t &>(param).initial(m_models[i].substr(pl+1,pr-pl-1)); - found = true; - break; - } - } - if (!found) - netlist().xfatalerror("Model %s not found\n", val.cstr()); - } - break; - default: - netlist().xfatalerror("Parameter is not supported %s : %s\n", name.cstr(), val.cstr()); - } - } - if (!(m_params.add(name, ¶m, false)==TMERR_NONE)) - netlist().xfatalerror("Error adding parameter %s to parameter list\n", name.cstr()); - } - break; - case netlist_terminal_t::DEVICE: - netlist().xfatalerror("Device registration not yet supported - \n", name.cstr()); - break; - case netlist_terminal_t::NETLIST: - netlist().xfatalerror("Netlist registration not yet supported - \n", name.cstr()); - break; - } + switch (obj.type()) + { + case netlist_terminal_t::TERMINAL: + case netlist_terminal_t::INPUT: + case netlist_terminal_t::OUTPUT: + { + netlist_core_terminal_t &term = dynamic_cast<netlist_core_terminal_t &>(obj); + if (obj.isType(netlist_terminal_t::OUTPUT)) + dynamic_cast<netlist_output_t &>(term).init_object(upd_dev, dev.name() + "." + name); + else + term.init_object(upd_dev, dev.name() + "." + name, state); + + if (!(m_terminals.add(term.name(), &term, false)==TMERR_NONE)) + netlist().xfatalerror("Error adding %s %s to terminal list\n", objtype_as_astr(term).cstr(), term.name().cstr()); + NL_VERBOSE_OUT(("%s %s\n", objtype_as_astr(term).cstr(), name.cstr())); + } + break; + case netlist_terminal_t::NET: + break; + case netlist_terminal_t::PARAM: + { + netlist_param_t ¶m = dynamic_cast<netlist_param_t &>(obj); + const pstring val = m_params_temp.find(name); + if (val != "") + { + switch (param.param_type()) + { + case netlist_param_t::DOUBLE: + { + NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr())); + double vald = 0; + if (sscanf(val.cstr(), "%lf", &vald) != 1) + netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr()); + dynamic_cast<netlist_param_double_t &>(param).initial(vald); + } + break; + case netlist_param_t::INTEGER: + case netlist_param_t::LOGIC: + { + NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", name.cstr(), val->cstr())); + int vald = 0; + if (sscanf(val.cstr(), "%d", &vald) != 1) + netlist().xfatalerror("Invalid number conversion %s : %s\n", name.cstr(), val.cstr()); + dynamic_cast<netlist_param_int_t &>(param).initial(vald); + } + break; + case netlist_param_t::STRING: + { + dynamic_cast<netlist_param_str_t &>(param).initial(val); + } + break; + case netlist_param_t::MODEL: + { + pstring search = (".model " + val + " ").ucase(); + bool found = false; + for (int i=0; i < m_models.count(); i++) + { + if (m_models[i].ucase().startsWith(search)) + { + int pl=m_models[i].find("("); + int pr=m_models[i].find("("); + dynamic_cast<netlist_param_model_t &>(param).initial(m_models[i].substr(pl+1,pr-pl-1)); + found = true; + break; + } + } + if (!found) + netlist().xfatalerror("Model %s not found\n", val.cstr()); + } + break; + default: + netlist().xfatalerror("Parameter is not supported %s : %s\n", name.cstr(), val.cstr()); + } + } + if (!(m_params.add(name, ¶m, false)==TMERR_NONE)) + netlist().xfatalerror("Error adding parameter %s to parameter list\n", name.cstr()); + } + break; + case netlist_terminal_t::DEVICE: + netlist().xfatalerror("Device registration not yet supported - \n", name.cstr()); + break; + case netlist_terminal_t::NETLIST: + netlist().xfatalerror("Netlist registration not yet supported - \n", name.cstr()); + break; + } } void netlist_setup_t::register_link(const pstring &sin, const pstring &sout) { link_t temp = link_t(sin, sout); NL_VERBOSE_OUT(("link %s <== %s\n", sin.cstr(), sout.cstr())); - m_links.add(temp); + m_links.add(temp); //if (!(m_links.add(sin + "." + sout, temp, false)==TMERR_NONE)) - // fatalerror("Error adding link %s<==%s to link list\n", sin.cstr(), sout.cstr()); + // fatalerror("Error adding link %s<==%s to link list\n", sin.cstr(), sout.cstr()); } void netlist_setup_t::register_param(const pstring ¶m, const double value) { - // FIXME: there should be a better way - register_param(param, pstring::sprintf("%.9e", value)); + // FIXME: there should be a better way + register_param(param, pstring::sprintf("%.9e", value)); } void netlist_setup_t::register_param(const pstring ¶m, const pstring &value) { - //if (!(m_params_temp.add(param, new nstring(value), false)==TMERR_NONE)) - if (!(m_params_temp.add(param, value, false)==TMERR_NONE)) - netlist().xfatalerror("Error adding parameter %s to parameter list\n", param.cstr()); + //if (!(m_params_temp.add(param, new nstring(value), false)==TMERR_NONE)) + if (!(m_params_temp.add(param, value, false)==TMERR_NONE)) + netlist().xfatalerror("Error adding parameter %s to parameter list\n", param.cstr()); } const pstring netlist_setup_t::resolve_alias(const pstring &name) const { - pstring temp = name; - pstring ret; + pstring temp = name; + pstring ret; - /* FIXME: Detect endless loop */ - do { - ret = temp; - temp = m_alias.find(ret); - } while (temp != ""); + /* FIXME: Detect endless loop */ + do { + ret = temp; + temp = m_alias.find(ret); + } while (temp != ""); - int p = ret.find(".["); + int p = ret.find(".["); if (p > 0) { - pstring dname = ret; - netlist_device_t *dev = netlist().m_devices.find(dname.substr(0,p)); - if (dev == NULL) - netlist().xfatalerror("Device for %s not found\n", name.cstr()); - int c = atoi(ret.substr(p+2,ret.len()-p-3)); - temp = dev->name() + "." + dev->m_terminals[c]; - // reresolve .... - do { - ret = temp; - temp = m_alias.find(ret); - } while (temp != ""); + pstring dname = ret; + netlist_device_t *dev = netlist().m_devices.find(dname.substr(0,p)); + if (dev == NULL) + netlist().xfatalerror("Device for %s not found\n", name.cstr()); + int c = atoi(ret.substr(p+2,ret.len()-p-3)); + temp = dev->name() + "." + dev->m_terminals[c]; + // reresolve .... + do { + ret = temp; + temp = m_alias.find(ret); + } while (temp != ""); } NL_VERBOSE_OUT(("%s==>%s\n", name.cstr(), ret.cstr())); @@ -289,22 +289,22 @@ const pstring netlist_setup_t::resolve_alias(const pstring &name) const netlist_core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_in, bool required) { - const pstring &tname = resolve_alias(terminal_in); - netlist_core_terminal_t *ret; - - ret = m_terminals.find(tname); - /* look for default */ - if (ret == NULL) - { - /* look for ".Q" std output */ - pstring s = tname + ".Q"; - ret = m_terminals.find(s); - } - if (ret == NULL && required) - netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr()); - if (ret != NULL) - NL_VERBOSE_OUT(("Found input %s\n", tname.cstr())); - return ret; + const pstring &tname = resolve_alias(terminal_in); + netlist_core_terminal_t *ret; + + ret = m_terminals.find(tname); + /* look for default */ + if (ret == NULL) + { + /* look for ".Q" std output */ + pstring s = tname + ".Q"; + ret = m_terminals.find(s); + } + if (ret == NULL && required) + netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr()); + if (ret != NULL) + NL_VERBOSE_OUT(("Found input %s\n", tname.cstr())); + return ret; } netlist_core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_in, netlist_object_t::type_t atype, bool required) @@ -322,15 +322,15 @@ netlist_core_terminal_t *netlist_setup_t::find_terminal(const pstring &terminal_ } if (ret == NULL && required) netlist().xfatalerror("terminal %s(%s) not found!\n", terminal_in.cstr(), tname.cstr()); - if (ret != NULL && ret->type() != atype) - { - if (required) - netlist().xfatalerror("object %s(%s) found but wrong type\n", terminal_in.cstr(), tname.cstr()); - else - ret = NULL; - } - if (ret != NULL) - NL_VERBOSE_OUT(("Found input %s\n", tname.cstr())); + if (ret != NULL && ret->type() != atype) + { + if (required) + netlist().xfatalerror("object %s(%s) found but wrong type\n", terminal_in.cstr(), tname.cstr()); + else + ret = NULL; + } + if (ret != NULL) + NL_VERBOSE_OUT(("Found input %s\n", tname.cstr())); return ret; } @@ -341,269 +341,267 @@ netlist_param_t *netlist_setup_t::find_param(const pstring ¶m_in, bool requi ret = m_params.find(outname); if (ret == NULL && required) - netlist().xfatalerror("parameter %s(%s) not found!\n", param_in.cstr(), outname.cstr()); + netlist().xfatalerror("parameter %s(%s) not found!\n", param_in.cstr(), outname.cstr()); if (ret != NULL) - NL_VERBOSE_OUT(("Found parameter %s\n", outname.cstr())); + NL_VERBOSE_OUT(("Found parameter %s\n", outname.cstr())); return ret; } void netlist_setup_t::connect_input_output(netlist_input_t &in, netlist_output_t &out) { - if (out.isFamily(netlist_terminal_t::ANALOG) && in.isFamily(netlist_terminal_t::LOGIC)) - { - nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(in); - pstring x = pstring::sprintf("proxy_ad_%d", m_proxy_cnt); - m_proxy_cnt++; - - proxy->init(netlist(), x); - register_dev(proxy, x); - - proxy->m_Q.net().register_con(in); - out.net().register_con(proxy->m_I); - - } - else if (out.isFamily(netlist_terminal_t::LOGIC) && in.isFamily(netlist_terminal_t::ANALOG)) - { - nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out); - pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); - m_proxy_cnt++; - - proxy->init(netlist(), x); - register_dev(proxy, x); - - proxy->m_Q.net().register_con(in); - out.net().register_con(proxy->m_I); - } - else - { - out.net().register_con(in); - } + if (out.isFamily(netlist_terminal_t::ANALOG) && in.isFamily(netlist_terminal_t::LOGIC)) + { + nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(in); + pstring x = pstring::sprintf("proxy_ad_%d", m_proxy_cnt); + m_proxy_cnt++; + + proxy->init(netlist(), x); + register_dev(proxy, x); + + proxy->m_Q.net().register_con(in); + out.net().register_con(proxy->m_I); + + } + else if (out.isFamily(netlist_terminal_t::LOGIC) && in.isFamily(netlist_terminal_t::ANALOG)) + { + nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out); + pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); + m_proxy_cnt++; + + proxy->init(netlist(), x); + register_dev(proxy, x); + + proxy->m_Q.net().register_con(in); + out.net().register_con(proxy->m_I); + } + else + { + out.net().register_con(in); + } } void netlist_setup_t::connect_terminal_input(netlist_terminal_t &term, netlist_input_t &inp) { - if (inp.isFamily(netlist_terminal_t::ANALOG)) - { - connect_terminals(inp, term); - } - else if (inp.isFamily(netlist_terminal_t::LOGIC)) - { - NL_VERBOSE_OUT(("connect_terminal_input: connecting proxy\n")); - nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(inp); - pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); - m_proxy_cnt++; - - proxy->init(netlist(), x); - register_dev(proxy, x); - - connect_terminals(term, proxy->m_I); - - if (inp.has_net()) - //fatalerror("logic inputs can only belong to one net!\n"); - proxy->m_Q.net().merge_net(&inp.net()); - else - proxy->m_Q.net().register_con(inp); - } - else - { - netlist().xfatalerror("Netlist: Severe Error"); - } + if (inp.isFamily(netlist_terminal_t::ANALOG)) + { + connect_terminals(inp, term); + } + else if (inp.isFamily(netlist_terminal_t::LOGIC)) + { + NL_VERBOSE_OUT(("connect_terminal_input: connecting proxy\n")); + nld_a_to_d_proxy *proxy = new nld_a_to_d_proxy(inp); + pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); + m_proxy_cnt++; + + proxy->init(netlist(), x); + register_dev(proxy, x); + + connect_terminals(term, proxy->m_I); + + if (inp.has_net()) + //fatalerror("logic inputs can only belong to one net!\n"); + proxy->m_Q.net().merge_net(&inp.net()); + else + proxy->m_Q.net().register_con(inp); + } + else + { + netlist().xfatalerror("Netlist: Severe Error"); + } } // FIXME: optimize code ... void netlist_setup_t::connect_terminal_output(netlist_terminal_t &in, netlist_output_t &out) { - if (out.isFamily(netlist_terminal_t::ANALOG)) - { - /* no proxy needed, just merge existing terminal net */ - if (in.has_net()) - out.net().merge_net(&in.net()); - else - out.net().register_con(in); - - } - else if (out.isFamily(netlist_terminal_t::LOGIC)) - { - NL_VERBOSE_OUT(("connect_terminal_output: connecting proxy\n")); - nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out); - pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); - m_proxy_cnt++; - - proxy->init(netlist(), x); - register_dev(proxy, x); - - out.net().register_con(proxy->m_I); - - if (in.has_net()) - proxy->m_Q.net().merge_net(&in.net()); - else - proxy->m_Q.net().register_con(in); - } - else - { - netlist().xfatalerror("Netlist: Severe Error"); - } + if (out.isFamily(netlist_terminal_t::ANALOG)) + { + /* no proxy needed, just merge existing terminal net */ + if (in.has_net()) + out.net().merge_net(&in.net()); + else + out.net().register_con(in); + + } + else if (out.isFamily(netlist_terminal_t::LOGIC)) + { + NL_VERBOSE_OUT(("connect_terminal_output: connecting proxy\n")); + nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out); + pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); + m_proxy_cnt++; + + proxy->init(netlist(), x); + register_dev(proxy, x); + + out.net().register_con(proxy->m_I); + + if (in.has_net()) + proxy->m_Q.net().merge_net(&in.net()); + else + proxy->m_Q.net().register_con(in); + } + else + { + netlist().xfatalerror("Netlist: Severe Error"); + } } void netlist_setup_t::connect_terminals(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2) { - //assert(in.isType(netlist_terminal_t::TERMINAL)); - //assert(out.isType(netlist_terminal_t::TERMINAL)); - - if (t1.has_net() && t2.has_net()) - { - NL_VERBOSE_OUT(("T2 and T1 have net\n")); - t1.net().merge_net(&t2.net()); - } - else if (t2.has_net()) - { - NL_VERBOSE_OUT(("T2 has net\n")); - t2.net().register_con(t1); - } - else if (t1.has_net()) - { - NL_VERBOSE_OUT(("T1 has net\n")); - t1.net().register_con(t2); - } - else - { - NL_VERBOSE_OUT(("adding net ...\n")); - netlist_net_t *anet = new netlist_net_t(netlist_object_t::NET, netlist_object_t::ANALOG); - t1.set_net(*anet); - //m_netlist.solver()->m_nets.add(anet); - // FIXME: Nets should have a unique name - t1.net().init_object(netlist(),"net." + t1.name() ); - t1.net().register_con(t2); - t1.net().register_con(t1); - } + //assert(in.isType(netlist_terminal_t::TERMINAL)); + //assert(out.isType(netlist_terminal_t::TERMINAL)); + + if (t1.has_net() && t2.has_net()) + { + NL_VERBOSE_OUT(("T2 and T1 have net\n")); + t1.net().merge_net(&t2.net()); + } + else if (t2.has_net()) + { + NL_VERBOSE_OUT(("T2 has net\n")); + t2.net().register_con(t1); + } + else if (t1.has_net()) + { + NL_VERBOSE_OUT(("T1 has net\n")); + t1.net().register_con(t2); + } + else + { + NL_VERBOSE_OUT(("adding net ...\n")); + netlist_net_t *anet = new netlist_net_t(netlist_object_t::NET, netlist_object_t::ANALOG); + t1.set_net(*anet); + //m_netlist.solver()->m_nets.add(anet); + // FIXME: Nets should have a unique name + t1.net().init_object(netlist(),"net." + t1.name() ); + t1.net().register_con(t2); + t1.net().register_con(t1); + } } void netlist_setup_t::connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2) { - NL_VERBOSE_OUT(("Connecting %s to %s\n", t1.name().cstr(), t2.name().cstr())); - // FIXME: amend device design so that warnings can be turned into errors - // Only variable inputs have this issue - if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT)) - { - if (t2.has_net()) - NL_VERBOSE_OUT(("Input %s already connected\n", t2.name().cstr())); - connect_input_output(dynamic_cast<netlist_input_t &>(t2), dynamic_cast<netlist_output_t &>(t1)); - } - else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::OUTPUT)) - { - if (t1.has_net()) - NL_VERBOSE_OUT(("Input %s already connected\n", t1.name().cstr())); - connect_input_output(dynamic_cast<netlist_input_t &>(t1), dynamic_cast<netlist_output_t &>(t2)); - } - else if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::TERMINAL)) - { - connect_terminal_output(dynamic_cast<netlist_terminal_t &>(t2), dynamic_cast<netlist_output_t &>(t1)); - } - else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::OUTPUT)) - { - connect_terminal_output(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_output_t &>(t2)); - } - else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::TERMINAL)) - { - connect_terminal_input(dynamic_cast<netlist_terminal_t &>(t2), dynamic_cast<netlist_input_t &>(t1)); - } - else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::INPUT)) - { - connect_terminal_input(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_input_t &>(t2)); - } - else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::TERMINAL)) - { - connect_terminals(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_terminal_t &>(t2)); - } - else - netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr()); + NL_VERBOSE_OUT(("Connecting %s to %s\n", t1.name().cstr(), t2.name().cstr())); + // FIXME: amend device design so that warnings can be turned into errors + // Only variable inputs have this issue + if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT)) + { + if (t2.has_net()) + NL_VERBOSE_OUT(("Input %s already connected\n", t2.name().cstr())); + connect_input_output(dynamic_cast<netlist_input_t &>(t2), dynamic_cast<netlist_output_t &>(t1)); + } + else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::OUTPUT)) + { + if (t1.has_net()) + NL_VERBOSE_OUT(("Input %s already connected\n", t1.name().cstr())); + connect_input_output(dynamic_cast<netlist_input_t &>(t1), dynamic_cast<netlist_output_t &>(t2)); + } + else if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::TERMINAL)) + { + connect_terminal_output(dynamic_cast<netlist_terminal_t &>(t2), dynamic_cast<netlist_output_t &>(t1)); + } + else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::OUTPUT)) + { + connect_terminal_output(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_output_t &>(t2)); + } + else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::TERMINAL)) + { + connect_terminal_input(dynamic_cast<netlist_terminal_t &>(t2), dynamic_cast<netlist_input_t &>(t1)); + } + else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::INPUT)) + { + connect_terminal_input(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_input_t &>(t2)); + } + else if (t1.isType(netlist_core_terminal_t::TERMINAL) && t2.isType(netlist_core_terminal_t::TERMINAL)) + { + connect_terminals(dynamic_cast<netlist_terminal_t &>(t1), dynamic_cast<netlist_terminal_t &>(t2)); + } + else + netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr()); } void netlist_setup_t::resolve_inputs() { + NL_VERBOSE_OUT(("Resolving ...\n")); + for (tagmap_link_t::entry_t *entry = m_links.first(); entry != NULL; entry = m_links.next(entry)) + { + const pstring t1s = entry->object().e1; + const pstring t2s = entry->object().e2; + netlist_core_terminal_t *t1 = find_terminal(t1s); + netlist_core_terminal_t *t2 = find_terminal(t2s); + + connect(*t1, *t2); + } - NL_VERBOSE_OUT(("Resolving ...\n")); - for (tagmap_link_t::entry_t *entry = m_links.first(); entry != NULL; entry = m_links.next(entry)) - { - const pstring t1s = entry->object().e1; - const pstring t2s = entry->object().e2; - netlist_core_terminal_t *t1 = find_terminal(t1s); - netlist_core_terminal_t *t2 = find_terminal(t2s); - - connect(*t1, *t2); - } - - /* print all outputs */ - for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry)) - { - ATTR_UNUSED netlist_output_t *out = dynamic_cast<netlist_output_t *>(entry->object()); - //if (out != NULL) - //VERBOSE_OUT(("%s %d\n", out->netdev()->name(), *out->Q_ptr())); - } + /* print all outputs */ + for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry)) + { + ATTR_UNUSED netlist_output_t *out = dynamic_cast<netlist_output_t *>(entry->object()); + //if (out != NULL) + //VERBOSE_OUT(("%s %d\n", out->netdev()->name(), *out->Q_ptr())); + } #if 0 - NL_VERBOSE_OUT(("deleting empty nets ...\n")); - - // delete empty nets ... - for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn)) - { - if (pn->object()->m_head == NULL) - { - NL_VERBOSE_OUT(("Deleting net ...\n")); - netlist_net_t *to_delete = pn->object(); - netlist().m_nets.remove(to_delete); - if (!to_delete->isRailNet()) - delete to_delete; - pn--; - } - } + NL_VERBOSE_OUT(("deleting empty nets ...\n")); + + // delete empty nets ... + for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn)) + { + if (pn->object()->m_head == NULL) + { + NL_VERBOSE_OUT(("Deleting net ...\n")); + netlist_net_t *to_delete = pn->object(); + netlist().m_nets.remove(to_delete); + if (!to_delete->isRailNet()) + delete to_delete; + pn--; + } + } #endif - if (m_netlist.solver() != NULL) - m_netlist.solver()->post_start(); + if (m_netlist.solver() != NULL) + m_netlist.solver()->post_start(); } void netlist_setup_t::start_devices() { + if (getenv("NL_LOGS")) + { + NL_VERBOSE_OUT(("Creating dynamic logs ...\n")); + nl_util::pstring_list ll = nl_util::split(getenv("NL_LOGS"), ":"); + for (int i=0; i < ll.count(); i++) + { + NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); + netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this); + pstring name = "log_" + ll[i]; + register_dev(nc, name); + register_link(name + ".I", ll[i]); + } + } + + + NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n")); + /* find the main clock ... */ + for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) + { + netlist_device_t *dev = entry->object(); + if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL) + { + m_netlist.set_mainclock_dev(dynamic_cast<NETLIB_NAME(mainclock)*>(dev)); + } + if (dynamic_cast<NETLIB_NAME(solver)*>(dev) != NULL) + { + m_netlist.set_solver_dev(dynamic_cast<NETLIB_NAME(solver)*>(dev)); + } + } - if (getenv("NL_LOGS")) - { - NL_VERBOSE_OUT(("Creating dynamic logs ...\n")); - nl_util::pstring_list ll = nl_util::split(getenv("NL_LOGS"), ":"); - for (int i=0; i < ll.count(); i++) - { - NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); - netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this); - pstring name = "log_" + ll[i]; - register_dev(nc, name); - register_link(name + ".I", ll[i]); - } - } - - - NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n")); - /* find the main clock ... */ - for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) - { - netlist_device_t *dev = entry->object(); - if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL) - { - m_netlist.set_mainclock_dev(dynamic_cast<NETLIB_NAME(mainclock)*>(dev)); - } - if (dynamic_cast<NETLIB_NAME(solver)*>(dev) != NULL) - { - m_netlist.set_solver_dev(dynamic_cast<NETLIB_NAME(solver)*>(dev)); - } - } - - NL_VERBOSE_OUT(("Initializing devices ...\n")); - for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) - { - netlist_device_t *dev = entry->object(); - dev->init(netlist(), entry->tag().cstr()); - } + NL_VERBOSE_OUT(("Initializing devices ...\n")); + for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) + { + netlist_device_t *dev = entry->object(); + dev->init(netlist(), entry->tag().cstr()); + } } diff --git a/src/emu/netlist/nl_setup.h b/src/emu/netlist/nl_setup.h index 627a539dce7..13d456b76e2 100644 --- a/src/emu/netlist/nl_setup.h +++ b/src/emu/netlist/nl_setup.h @@ -19,7 +19,7 @@ #define NET_STR(_x) # _x #define NET_MODEL(_model) \ - netlist.register_model(_model); + netlist.register_model(_model); #define NET_ALIAS(_alias, _name) \ netlist.register_alias(# _alias, # _name); @@ -39,13 +39,13 @@ netlist.register_link(# _name "." # _input, # _output); #define NET_C(_input, _output) \ - netlist.register_link(NET_STR(_input) , NET_STR(_output)); + netlist.register_link(NET_STR(_input) , NET_STR(_output)); #define NETDEV_PARAM(_name, _val) \ netlist.register_param(# _name, _val); #define NETDEV_PARAMI(_name, _param, _val) \ - netlist.register_param(# _name "." # _param, _val); + netlist.register_param(# _name "." # _param, _val); #define NETLIST_NAME(_name) netlist ## _ ## _name @@ -69,30 +69,30 @@ ATTR_COLD void NETLIST_NAME(_name)(netlist_setup_t &netlist) \ class netlist_setup_t { - NETLIST_PREVENT_COPYING(netlist_setup_t) + NETLIST_PREVENT_COPYING(netlist_setup_t) public: - struct link_t - { - link_t() { } - // Copy constructor - link_t(const link_t &from) - { - e1 = from.e1; - e2 = from.e2; - } - - link_t(const pstring &ae1, const pstring &ae2) - { - e1 = ae1; - e2 = ae2; - } - pstring e1; - pstring e2; - - bool operator==(const link_t &rhs) const { return (e1 == rhs.e1) && (e2 == rhs.e2); } - link_t &operator=(const link_t &rhs) { e1 = rhs.e1; e2 = rhs.e2; return *this; } - }; + struct link_t + { + link_t() { } + // Copy constructor + link_t(const link_t &from) + { + e1 = from.e1; + e2 = from.e2; + } + + link_t(const pstring &ae1, const pstring &ae2) + { + e1 = ae1; + e2 = ae2; + } + pstring e1; + pstring e2; + + bool operator==(const link_t &rhs) const { return (e1 == rhs.e1) && (e2 == rhs.e2); } + link_t &operator=(const link_t &rhs) { e1 = rhs.e1; e2 = rhs.e2; return *this; } + }; typedef tagmap_t<pstring, 393> tagmap_nstring_t; typedef tagmap_t<netlist_param_t *, 393> tagmap_param_t; @@ -105,29 +105,29 @@ public: void init(); netlist_base_t &netlist() { return m_netlist; } - const netlist_base_t &netlist() const { return m_netlist; } + const netlist_base_t &netlist() const { return m_netlist; } netlist_factory &factory() { return m_factory; } netlist_device_t *register_dev(netlist_device_t *dev, const pstring &name); void remove_dev(const pstring &name); - void register_model(const pstring &model); - void register_alias(const pstring &alias, const pstring &out); - void register_link(const pstring &sin, const pstring &sout); - void register_param(const pstring ¶m, const pstring &value); - void register_param(const pstring ¶m, const double value); + void register_model(const pstring &model); + void register_alias(const pstring &alias, const pstring &out); + void register_link(const pstring &sin, const pstring &sout); + void register_param(const pstring ¶m, const pstring &value); + void register_param(const pstring ¶m, const double value); - 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); - void connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2); + 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); + void connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2); - netlist_core_terminal_t *find_terminal(const pstring &outname_in, bool required = true); - netlist_core_terminal_t *find_terminal(const pstring &outname_in, netlist_object_t::type_t atype, bool required = true); + netlist_core_terminal_t *find_terminal(const pstring &outname_in, bool required = true); + netlist_core_terminal_t *find_terminal(const pstring &outname_in, netlist_object_t::type_t atype, bool required = true); - netlist_param_t *find_param(const pstring ¶m_in, bool required = true); + netlist_param_t *find_param(const pstring ¶m_in, bool required = true); - void parse(const char *buf); + void parse(const char *buf); - void start_devices(); + void start_devices(); void resolve_inputs(); /* not ideal, but needed for save_state */ @@ -144,21 +144,21 @@ private: tagmap_nstring_t m_alias; tagmap_param_t m_params; tagmap_link_t m_links; - tagmap_nstring_t m_params_temp; + tagmap_nstring_t m_params_temp; - netlist_factory m_factory; + netlist_factory m_factory; - netlist_list_t<pstring> m_models; + netlist_list_t<pstring> m_models; int m_proxy_cnt; void connect_terminals(netlist_core_terminal_t &in, netlist_core_terminal_t &out); void connect_input_output(netlist_input_t &in, netlist_output_t &out); - void connect_terminal_output(netlist_terminal_t &in, netlist_output_t &out); - void connect_terminal_input(netlist_terminal_t &term, netlist_input_t &inp); + void connect_terminal_output(netlist_terminal_t &in, netlist_output_t &out); + void connect_terminal_input(netlist_terminal_t &term, netlist_input_t &inp); - // helpers - pstring objtype_as_astr(netlist_object_t &in); + // helpers + pstring objtype_as_astr(netlist_object_t &in); const pstring resolve_alias(const pstring &name) const; }; diff --git a/src/emu/netlist/nl_time.h b/src/emu/netlist/nl_time.h index bfdeda38c32..33729fb38d9 100644 --- a/src/emu/netlist/nl_time.h +++ b/src/emu/netlist/nl_time.h @@ -26,87 +26,87 @@ struct netlist_time { public: - typedef UINT64 INTERNALTYPE; + typedef UINT64 INTERNALTYPE; - static const INTERNALTYPE RESOLUTION = NETLIST_INTERNAL_RES; + static const INTERNALTYPE RESOLUTION = NETLIST_INTERNAL_RES; - ATTR_HOT inline netlist_time() : m_time(0) {} + ATTR_HOT inline netlist_time() : m_time(0) {} - ATTR_HOT friend inline const netlist_time operator-(const netlist_time &left, const netlist_time &right); - ATTR_HOT friend inline const netlist_time operator+(const netlist_time &left, const netlist_time &right); - ATTR_HOT friend inline const netlist_time operator*(const netlist_time &left, const UINT32 factor); - ATTR_HOT friend inline const UINT32 operator/(const netlist_time &left, const netlist_time &right); - ATTR_HOT friend inline bool operator>(const netlist_time &left, const netlist_time &right); - ATTR_HOT friend inline bool operator<(const netlist_time &left, const netlist_time &right); - ATTR_HOT friend inline bool operator>=(const netlist_time &left, const netlist_time &right); - ATTR_HOT friend inline bool operator<=(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline const netlist_time operator-(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline const netlist_time operator+(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline const netlist_time operator*(const netlist_time &left, const UINT32 factor); + ATTR_HOT friend inline const UINT32 operator/(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline bool operator>(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline bool operator<(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline bool operator>=(const netlist_time &left, const netlist_time &right); + ATTR_HOT friend inline bool operator<=(const netlist_time &left, const netlist_time &right); - ATTR_HOT inline const netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; } - ATTR_HOT inline const netlist_time &operator=(const double &right) { m_time = (INTERNALTYPE) ( right * (double) RESOLUTION); return *this; } - ATTR_HOT inline operator double() const { return as_double(); } + ATTR_HOT inline const netlist_time &operator=(const netlist_time &right) { m_time = right.m_time; return *this; } + ATTR_HOT inline const netlist_time &operator=(const double &right) { m_time = (INTERNALTYPE) ( right * (double) RESOLUTION); return *this; } + ATTR_HOT inline operator double() const { return as_double(); } - ATTR_HOT inline const netlist_time &operator+=(const netlist_time &right) { m_time += right.m_time; return *this; } + ATTR_HOT inline const netlist_time &operator+=(const netlist_time &right) { m_time += right.m_time; return *this; } - ATTR_HOT inline const INTERNALTYPE as_raw() const { return m_time; } - ATTR_HOT inline const double as_double() const { return (double) m_time / (double) RESOLUTION; } + ATTR_HOT inline const INTERNALTYPE as_raw() const { return m_time; } + ATTR_HOT inline const double as_double() const { return (double) m_time / (double) RESOLUTION; } - // for save states .... - ATTR_HOT inline INTERNALTYPE *get_internaltype_ptr() { return &m_time; } + // for save states .... + ATTR_HOT inline INTERNALTYPE *get_internaltype_ptr() { return &m_time; } - ATTR_HOT static inline const netlist_time from_nsec(const int ns) { return netlist_time((UINT64) ns * (RESOLUTION / U64(1000000000))); } - ATTR_HOT static inline const netlist_time from_usec(const int us) { return netlist_time((UINT64) us * (RESOLUTION / U64(1000000))); } - ATTR_HOT static inline const netlist_time from_msec(const int ms) { return netlist_time((UINT64) ms * (RESOLUTION / U64(1000))); } - ATTR_HOT static inline const netlist_time from_hz(const UINT64 hz) { return netlist_time(RESOLUTION / hz); } - ATTR_HOT static inline const netlist_time from_double(const double t) { return netlist_time((INTERNALTYPE) ( t * (double) RESOLUTION)); } - ATTR_HOT static inline const netlist_time from_raw(const INTERNALTYPE raw) { return netlist_time(raw); } + ATTR_HOT static inline const netlist_time from_nsec(const int ns) { return netlist_time((UINT64) ns * (RESOLUTION / U64(1000000000))); } + ATTR_HOT static inline const netlist_time from_usec(const int us) { return netlist_time((UINT64) us * (RESOLUTION / U64(1000000))); } + ATTR_HOT static inline const netlist_time from_msec(const int ms) { return netlist_time((UINT64) ms * (RESOLUTION / U64(1000))); } + ATTR_HOT static inline const netlist_time from_hz(const UINT64 hz) { return netlist_time(RESOLUTION / hz); } + ATTR_HOT static inline const netlist_time from_double(const double t) { return netlist_time((INTERNALTYPE) ( t * (double) RESOLUTION)); } + ATTR_HOT static inline const netlist_time from_raw(const INTERNALTYPE raw) { return netlist_time(raw); } - static const netlist_time zero; + static const netlist_time zero; protected: - ATTR_HOT inline netlist_time(const INTERNALTYPE val) : m_time(val) {} + ATTR_HOT inline netlist_time(const INTERNALTYPE val) : m_time(val) {} - INTERNALTYPE m_time; + INTERNALTYPE m_time; }; ATTR_HOT inline const netlist_time operator-(const netlist_time &left, const netlist_time &right) { - return netlist_time::from_raw(left.m_time - right.m_time); + return netlist_time::from_raw(left.m_time - right.m_time); } ATTR_HOT inline const netlist_time operator*(const netlist_time &left, const UINT32 factor) { - return netlist_time::from_raw(left.m_time * factor); + return netlist_time::from_raw(left.m_time * factor); } ATTR_HOT inline const UINT32 operator/(const netlist_time &left, const netlist_time &right) { - return left.m_time / right.m_time; + return left.m_time / right.m_time; } ATTR_HOT inline const netlist_time operator+(const netlist_time &left, const netlist_time &right) { - return netlist_time::from_raw(left.m_time + right.m_time); + return netlist_time::from_raw(left.m_time + right.m_time); } ATTR_HOT inline bool operator<(const netlist_time &left, const netlist_time &right) { - return (left.m_time < right.m_time); + return (left.m_time < right.m_time); } ATTR_HOT inline bool operator>(const netlist_time &left, const netlist_time &right) { - return (left.m_time > right.m_time); + return (left.m_time > right.m_time); } ATTR_HOT inline bool operator<=(const netlist_time &left, const netlist_time &right) { - return (left.m_time <= right.m_time); + return (left.m_time <= right.m_time); } ATTR_HOT inline bool operator>=(const netlist_time &left, const netlist_time &right) { - return (left.m_time >= right.m_time); + return (left.m_time >= right.m_time); } diff --git a/src/emu/netlist/nl_util.h b/src/emu/netlist/nl_util.h index 5016befe098..17c467752a3 100644 --- a/src/emu/netlist/nl_util.h +++ b/src/emu/netlist/nl_util.h @@ -13,29 +13,29 @@ class nl_util { // this is purely static private: - nl_util() {}; + nl_util() {}; public: - typedef netlist_list_t<pstring, 10> pstring_list; - - static pstring_list split(const pstring &str, const pstring &onstr) - { - pstring_list temp; - - int p = 0; - int pn; - - pn = str.find(onstr, p); - while (pn>=0) - { - temp.add(str.substr(p, pn - p)); - p = pn + onstr.len(); - pn = str.find(onstr, p); - } - if (p<str.len()) - temp.add(str.substr(p)); - return temp; - } + typedef netlist_list_t<pstring, 10> pstring_list; + + static pstring_list split(const pstring &str, const pstring &onstr) + { + pstring_list temp; + + int p = 0; + int pn; + + pn = str.find(onstr, p); + while (pn>=0) + { + temp.add(str.substr(p, pn - p)); + p = pn + onstr.len(); + pn = str.find(onstr, p); + } + if (p<str.len()) + temp.add(str.substr(p)); + return temp; + } }; #endif /* NL_UTIL_H_ */ diff --git a/src/emu/netlist/pstate.c b/src/emu/netlist/pstate.c index 25543afced5..770f2581b77 100644 --- a/src/emu/netlist/pstate.c +++ b/src/emu/netlist/pstate.c @@ -7,24 +7,24 @@ ATTR_COLD pstate_manager_t::~pstate_manager_t() { - m_save.reset_and_free(); + m_save.reset_and_free(); } ATTR_COLD void pstate_manager_t::save_state_ptr(const pstring &stname, const netlist_data_type_e dt, const int size, const int count, void *ptr) { - pstring fullname = stname; - ATTR_UNUSED pstring ts[] = { - "NOT_SUPPORTED", - "DT_DOUBLE", - "DT_INT64", - "DT_INT8", - "DT_INT", - "DT_BOOLEAN" - }; + pstring fullname = stname; + ATTR_UNUSED pstring ts[] = { + "NOT_SUPPORTED", + "DT_DOUBLE", + "DT_INT64", + "DT_INT8", + "DT_INT", + "DT_BOOLEAN" + }; - NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr)); - pstate_entry_t *p = new pstate_entry_t(stname, dt, size, count, ptr); - m_save.add(p); + NL_VERBOSE_OUT(("SAVE: <%s> %s(%d) %p\n", fullname.cstr(), ts[dt].cstr(), size, ptr)); + pstate_entry_t *p = new pstate_entry_t(stname, dt, size, count, ptr); + m_save.add(p); } diff --git a/src/emu/netlist/pstate.h b/src/emu/netlist/pstate.h index e5432f523b2..3c0b1eeaeb6 100644 --- a/src/emu/netlist/pstate.h +++ b/src/emu/netlist/pstate.h @@ -16,18 +16,18 @@ // ---------------------------------------------------------------------------------------- #define PSTATE_INTERFACE(manager, module) \ - template<class C> ATTR_COLD void save(C &state, const pstring &stname) \ - { \ - dynamic_cast<pstate_manager_t &>(manager).save_manager(state, module + "." + stname); \ - } + template<class C> ATTR_COLD void save(C &state, const pstring &stname) \ + { \ + dynamic_cast<pstate_manager_t &>(manager).save_manager(state, module + "." + stname); \ + } enum netlist_data_type_e { - NOT_SUPPORTED, - DT_DOUBLE, - DT_INT64, - DT_INT8, - DT_INT, - DT_BOOLEAN + NOT_SUPPORTED, + DT_DOUBLE, + DT_INT64, + DT_INT8, + DT_INT, + DT_BOOLEAN }; template<typename _ItemType> struct nl_datatype { static const netlist_data_type_e type = netlist_data_type_e(NOT_SUPPORTED); }; @@ -46,50 +46,50 @@ NETLIST_SAVE_TYPE(INT32, DT_INT); struct pstate_entry_t { - typedef netlist_list_t<pstate_entry_t *> list_t; - - pstate_entry_t(const pstring &stname, const netlist_data_type_e dt, const int size, const int count, void *ptr) : - m_name(stname), m_dt(dt), m_size(size), m_count(count), m_ptr(ptr) { } - pstring m_name; - netlist_data_type_e m_dt; - int m_size; - int m_count; - void *m_ptr; + typedef netlist_list_t<pstate_entry_t *> list_t; + + pstate_entry_t(const pstring &stname, const netlist_data_type_e dt, const int size, const int count, void *ptr) : + m_name(stname), m_dt(dt), m_size(size), m_count(count), m_ptr(ptr) { } + pstring m_name; + netlist_data_type_e m_dt; + int m_size; + int m_count; + void *m_ptr; }; class pstate_manager_t { public: - ATTR_COLD ~pstate_manager_t(); + ATTR_COLD ~pstate_manager_t(); - template<class C> ATTR_COLD void save_manager(C &state, const pstring &stname) - { - save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), 1, &state); - } + template<class C> ATTR_COLD void save_manager(C &state, const pstring &stname) + { + save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), 1, &state); + } - template<class C> ATTR_COLD void save_manager(C *state, const pstring &stname, const int count) - { - save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), count, state); - } + template<class C> ATTR_COLD void save_manager(C *state, const pstring &stname, const int count) + { + save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), count, state); + } - template<class C, std::size_t N> ATTR_COLD void save_manager(C (&state)[N], const pstring &stname) - { - save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), N, &(state[0])); - } + template<class C, std::size_t N> ATTR_COLD void save_manager(C (&state)[N], const pstring &stname) + { + save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), N, &(state[0])); + } - inline const pstate_entry_t::list_t &save_list() const { return m_save; } + inline const pstate_entry_t::list_t &save_list() const { return m_save; } protected: - ATTR_COLD void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, const int count, void *ptr); + ATTR_COLD void save_state_ptr(const pstring &stname, const netlist_data_type_e, const int size, const int count, void *ptr); private: - pstate_entry_t::list_t m_save; + pstate_entry_t::list_t m_save; }; template<> ATTR_COLD inline void pstate_manager_t::save_manager(netlist_time &nlt, const pstring &stname) { - save_state_ptr(stname, DT_INT64, sizeof(netlist_time::INTERNALTYPE), 1, nlt.get_internaltype_ptr()); + save_state_ptr(stname, DT_INT64, sizeof(netlist_time::INTERNALTYPE), 1, nlt.get_internaltype_ptr()); } diff --git a/src/emu/netlist/pstring.c b/src/emu/netlist/pstring.c index 7d5a55ff166..6287fac8109 100644 --- a/src/emu/netlist/pstring.c +++ b/src/emu/netlist/pstring.c @@ -24,68 +24,68 @@ pstring::str_t *pstring::m_zero = NULL; //#define DEBUG_MODE (0) #ifdef MAME_DEBUG - #ifndef IMMEDIATE_MODE - #define IMMEDIATE_MODE (0) - #endif - #ifndef DEBUG_MODE - #define DEBUG_MODE (1) - #endif + #ifndef IMMEDIATE_MODE + #define IMMEDIATE_MODE (0) + #endif + #ifndef DEBUG_MODE + #define DEBUG_MODE (1) + #endif #else - #ifndef IMMEDIATE_MODE - #define IMMEDIATE_MODE (1) - #endif - #ifndef DEBUG_MODE - #define DEBUG_MODE (0) - #endif + #ifndef IMMEDIATE_MODE + #define IMMEDIATE_MODE (1) + #endif + #ifndef DEBUG_MODE + #define DEBUG_MODE (0) + #endif #endif pstring::~pstring() { - sfree(m_ptr); + sfree(m_ptr); } void pstring::pcat(const char *s) { - int slen = strlen(s); - str_t *n = salloc(m_ptr->len() + slen); - if (m_ptr->len() > 0) - memcpy(n->str(), m_ptr->str(), m_ptr->len()); - if (slen > 0) - memcpy(n->str() + m_ptr->len(), s, slen); - *(n->str() + n->len()) = 0; - sfree(m_ptr); - m_ptr = n; + int slen = strlen(s); + str_t *n = salloc(m_ptr->len() + slen); + if (m_ptr->len() > 0) + memcpy(n->str(), m_ptr->str(), m_ptr->len()); + if (slen > 0) + memcpy(n->str() + m_ptr->len(), s, slen); + *(n->str() + n->len()) = 0; + sfree(m_ptr); + m_ptr = n; } void pstring::pcopy(const char *from, int size) { - str_t *n = salloc(size); - if (size > 0) - memcpy(n->str(), from, size); - *(n->str() + size) = 0; - sfree(m_ptr); - m_ptr = n; + str_t *n = salloc(size); + if (size > 0) + memcpy(n->str(), from, size); + *(n->str() + size) = 0; + sfree(m_ptr); + m_ptr = n; } pstring pstring::substr(unsigned int start, int count) const { - int alen = len(); - if (start >= alen) - return pstring(); - if (count <0 || start + count > alen) - count = alen - start; - pstring ret; - ret.pcopy(cstr() + start, count); - return ret; + int alen = len(); + if (start >= alen) + return pstring(); + if (count <0 || start + count > alen) + count = alen - start; + pstring ret; + ret.pcopy(cstr() + start, count); + return ret; } pstring pstring::ucase() const { - pstring ret = *this; - ret.pcopy(cstr(), len()); - for (int i=0; i<ret.len(); i++) - ret.m_ptr->m_str[i] = toupper((unsigned) ret.m_ptr->m_str[i]); - return ret; + pstring ret = *this; + ret.pcopy(cstr(), len()); + for (int i=0; i<ret.len(); i++) + ret.m_ptr->m_str[i] = toupper((unsigned) ret.m_ptr->m_str[i]); + return ret; } //------------------------------------------------- @@ -94,58 +94,58 @@ pstring pstring::ucase() const int pstring::pcmpi(const char *lhs, const char *rhs, int count) const { - // loop while equal until we hit the end of strings - int index; - for (index = 0; index < count; index++) - if (lhs[index] == 0 || tolower(lhs[index]) != tolower(rhs[index])) - break; - - // determine the final result - if (index < count) - return tolower(lhs[index]) - tolower(rhs[index]); - if (lhs[index] == 0) - return 0; - return 1; + // loop while equal until we hit the end of strings + int index; + for (index = 0; index < count; index++) + if (lhs[index] == 0 || tolower(lhs[index]) != tolower(rhs[index])) + break; + + // determine the final result + if (index < count) + return tolower(lhs[index]) - tolower(rhs[index]); + if (lhs[index] == 0) + return 0; + return 1; } double pstring::as_double(bool *error) const { - double ret; - char *e = NULL; - - if (error != NULL) - *error = false; - ret = strtod(cstr(), &e); - if (*e != 0) - if (error != NULL) - *error = true; - return ret; + double ret; + char *e = NULL; + + if (error != NULL) + *error = false; + ret = strtod(cstr(), &e); + if (*e != 0) + if (error != NULL) + *error = true; + return ret; } long pstring::as_long(bool *error) const { - double ret; - char *e = NULL; - - if (error != NULL) - *error = false; - if (startsWith("0x")) - ret = strtol(&(cstr()[2]), &e, 16); - else - ret = strtol(cstr(), &e, 10); - if (*e != 0) - if (error != NULL) - *error = true; - return ret; + double ret; + char *e = NULL; + + if (error != NULL) + *error = false; + if (startsWith("0x")) + ret = strtol(&(cstr()[2]), &e, 16); + else + ret = strtol(cstr(), &e, 10); + if (*e != 0) + if (error != NULL) + *error = true; + return ret; } pstring pstring::vprintf(va_list args) const { - // sprintf into the temporary buffer - char tempbuf[4096]; - vsprintf(tempbuf, cstr(), args); + // sprintf into the temporary buffer + char tempbuf[4096]; + vsprintf(tempbuf, cstr(), args); - return pstring(tempbuf); + return pstring(tempbuf); } // ---------------------------------------------------------------------------------------- @@ -154,35 +154,35 @@ pstring pstring::vprintf(va_list args) const void pstring::sfree(str_t *s) { - s->m_ref_count--; - if (s->m_ref_count == 0) - m_pool.dealloc(s); + s->m_ref_count--; + if (s->m_ref_count == 0) + m_pool.dealloc(s); } pstring::str_t *pstring::salloc(int n) { - str_t *ret = new(m_pool, n+1) str_t(n); - return ret; + str_t *ret = new(m_pool, n+1) str_t(n); + return ret; } pstring pstring::sprintf(const char *format, ...) { - va_list ap; - va_start(ap, format); - pstring ret = pstring(format).vprintf(ap); - va_end(ap); - return ret; + va_list ap; + va_start(ap, format); + pstring ret = pstring(format).vprintf(ap); + va_end(ap); + return ret; } void pstring::resetmem() { - // Release the 0 string - if (m_zero != NULL) - sfree(m_zero); - m_zero = NULL; - m_pool.m_shutdown = true; - m_pool.resetmem(); + // Release the 0 string + if (m_zero != NULL) + sfree(m_zero); + m_zero = NULL; + m_pool.m_shutdown = true; + m_pool.resetmem(); } // ---------------------------------------------------------------------------------------- @@ -191,10 +191,10 @@ void pstring::resetmem() pblockpool::pblockpool() - : m_shutdown(false) - , m_first(NULL) - , m_blocksize((DEBUG_MODE) ? 16384 : 16384) - , m_align(8) + : m_shutdown(false) + , m_first(NULL) + , m_blocksize((DEBUG_MODE) ? 16384 : 16384) + , m_align(8) { } @@ -205,105 +205,105 @@ pblockpool::~pblockpool() void *pblockpool::alloc(const std::size_t n) { - if (IMMEDIATE_MODE) - return (char *) malloc(n); - else - { - int memsize = ((n + m_align - 1) / m_align) * m_align; - int min_alloc = MAX(m_blocksize, memsize+sizeof(memblock)-MINDATASIZE); - 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 > memsize) - { - ret = p->cur; - p->cur += memsize; - p->allocated += 1; - p->remaining -= memsize; - } - } - - 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)-MINDATASIZE); - p->next = m_first; - //std::printf("allocated block size %d\n", sizeof(p->data)); - - ret = p->cur; - p->cur += memsize; - p->allocated += 1; - p->remaining -= memsize; - - m_first = p; - } - - return ret; - } + if (IMMEDIATE_MODE) + return (char *) malloc(n); + else + { + int memsize = ((n + m_align - 1) / m_align) * m_align; + int min_alloc = MAX(m_blocksize, memsize+sizeof(memblock)-MINDATASIZE); + 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 > memsize) + { + ret = p->cur; + p->cur += memsize; + p->allocated += 1; + p->remaining -= memsize; + } + } + + 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)-MINDATASIZE); + p->next = m_first; + //std::printf("allocated block size %d\n", sizeof(p->data)); + + ret = p->cur; + p->cur += memsize; + p->allocated += 1; + p->remaining -= memsize; + + m_first = p; + } + + return ret; + } } void pblockpool::dealloc(void *ptr) { - if (IMMEDIATE_MODE) - free(ptr); - else - { - for (memblock *p = m_first; p != NULL; p = p->next) - { - if (ptr >= &p->data[0] && ptr < &p->data[p->size]) - { - p->allocated -= 1; - if (p->allocated < 0) - std::fprintf(stderr, "nstring: memory corruption - crash likely\n"); - if (p->allocated == 0) - { - //std::printf("Block entirely freed\n"); - p->remaining = p->size; - p->cur = &p->data[0]; - } - // shutting down ? - if (m_shutdown) - resetmem(); // try to free blocks - return; - } - } - std::fprintf(stderr, "nstring: string <%p> not found on free\n", ptr); - } + if (IMMEDIATE_MODE) + free(ptr); + else + { + for (memblock *p = m_first; p != NULL; p = p->next) + { + if (ptr >= &p->data[0] && ptr < &p->data[p->size]) + { + p->allocated -= 1; + if (p->allocated < 0) + std::fprintf(stderr, "nstring: memory corruption - crash likely\n"); + if (p->allocated == 0) + { + //std::printf("Block entirely freed\n"); + p->remaining = p->size; + p->cur = &p->data[0]; + } + // shutting down ? + if (m_shutdown) + resetmem(); // try to free blocks + return; + } + } + std::fprintf(stderr, "nstring: string <%p> not found on free\n", ptr); + } } void pblockpool::resetmem() { - if (!IMMEDIATE_MODE) - { - memblock **p = &m_first; - int totalblocks = 0; - int freedblocks = 0; - - while (*p != NULL) - { - 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 (!IMMEDIATE_MODE) + { + memblock **p = &m_first; + int totalblocks = 0; + int freedblocks = 0; + + while (*p != NULL) + { + 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); + } } diff --git a/src/emu/netlist/pstring.h b/src/emu/netlist/pstring.h index 892ade87ef5..f4b1dd5078e 100644 --- a/src/emu/netlist/pstring.h +++ b/src/emu/netlist/pstring.h @@ -15,56 +15,56 @@ // ---------------------------------------------------------------------------------------- struct pblockpool { - NETLIST_PREVENT_COPYING(pblockpool) + NETLIST_PREVENT_COPYING(pblockpool) public: - static const int MINDATASIZE = 8; + static const int MINDATASIZE = 8; - pblockpool(); - ~pblockpool(); + pblockpool(); + ~pblockpool(); - void resetmem(); + void resetmem(); - void *alloc(std::size_t n); - void dealloc(void *ptr); + void *alloc(std::size_t n); + void dealloc(void *ptr); - template<class T> - void destroy(T* object) - { - object->~T(); - dealloc(object); - } - bool m_shutdown; + template<class T> + void destroy(T* object) + { + object->~T(); + dealloc(object); + } + bool m_shutdown; private: - struct memblock - { - memblock *next; - int size; - int allocated; - int remaining; - char *cur; - char data[MINDATASIZE]; - }; - - memblock *m_first; - int m_blocksize; - int m_align; + struct memblock + { + memblock *next; + int size; + int allocated; + int remaining; + char *cur; + char data[MINDATASIZE]; + }; + + memblock *m_first; + int m_blocksize; + int m_align; }; /* objects must be destroyed using destroy above */ inline void *operator new(std::size_t size, pblockpool &pool, int extra = 0) throw (std::bad_alloc) { - void *result = pool.alloc(size + extra); - //std::printf("allocating %ld + %d\n", size, extra); - if (result == NULL) - throw std::bad_alloc(); - return result; + void *result = pool.alloc(size + extra); + //std::printf("allocating %ld + %d\n", size, extra); + if (result == NULL) + throw std::bad_alloc(); + return result; } inline void operator delete(void *pMem, pblockpool &pool, int extra) { - pool.dealloc(pMem); + pool.dealloc(pMem); } // ---------------------------------------------------------------------------------------- @@ -77,158 +77,157 @@ inline void operator delete(void *pMem, pblockpool &pool, int extra) struct pstring { public: - // simple construction/destruction - pstring() - { - init(); - } - ~pstring(); + // simple construction/destruction + pstring() + { + init(); + } + ~pstring(); - // construction with copy - pstring(const char *string) {init(); if (string != NULL && *string != 0) pcopy(string); } - pstring(const pstring &string) {init(); pcopy(string); } + // construction with copy + pstring(const char *string) {init(); if (string != NULL && *string != 0) pcopy(string); } + pstring(const pstring &string) {init(); pcopy(string); } - // assignment operators - pstring &operator=(const char *string) { pcopy(string); return *this; } - pstring &operator=(const pstring &string) { pcopy(string); return *this; } + // assignment operators + pstring &operator=(const char *string) { pcopy(string); return *this; } + pstring &operator=(const pstring &string) { pcopy(string); return *this; } - // C string conversion operators and helpers - operator const char *() const { return m_ptr->str(); } - inline const char *cstr() const { return m_ptr->str(); } + // C string conversion operators and helpers + operator const char *() const { return m_ptr->str(); } + inline const char *cstr() const { return m_ptr->str(); } - // concatenation operators - pstring& operator+=(const pstring &string) { pcat(string.cstr()); return *this; } - friend pstring operator+(const pstring &lhs, const pstring &rhs) { return pstring(lhs) += rhs; } - friend pstring operator+(const pstring &lhs, const char *rhs) { return pstring(lhs) += rhs; } - friend pstring operator+(const char *lhs, const pstring &rhs) { return pstring(lhs) += rhs; } + // concatenation operators + pstring& operator+=(const pstring &string) { pcat(string.cstr()); return *this; } + friend pstring operator+(const pstring &lhs, const pstring &rhs) { return pstring(lhs) += rhs; } + friend pstring operator+(const pstring &lhs, const char *rhs) { return pstring(lhs) += rhs; } + friend pstring operator+(const char *lhs, const pstring &rhs) { return pstring(lhs) += rhs; } - // comparison operators - bool operator==(const char *string) const { return (pcmp(string) == 0); } - bool operator==(const pstring &string) const { return (pcmp(string.cstr()) == 0); } - bool operator!=(const char *string) const { return (pcmp(string) != 0); } - bool operator!=(const pstring &string) const { return (pcmp(string.cstr()) != 0); } - bool operator<(const char *string) const { return (pcmp(string) < 0); } - bool operator<(const pstring &string) const { return (pcmp(string.cstr()) < 0); } - bool operator<=(const char *string) const { return (pcmp(string) <= 0); } - bool operator<=(const pstring &string) const { return (pcmp(string.cstr()) <= 0); } - bool operator>(const char *string) const { return (pcmp(string) > 0); } - bool operator>(const pstring &string) const { return (pcmp(string.cstr()) > 0); } - bool operator>=(const char *string) const { return (pcmp(string) >= 0); } - bool operator>=(const pstring &string) const { return (pcmp(string.cstr()) >= 0); } + // comparison operators + bool operator==(const char *string) const { return (pcmp(string) == 0); } + bool operator==(const pstring &string) const { return (pcmp(string.cstr()) == 0); } + bool operator!=(const char *string) const { return (pcmp(string) != 0); } + bool operator!=(const pstring &string) const { return (pcmp(string.cstr()) != 0); } + bool operator<(const char *string) const { return (pcmp(string) < 0); } + bool operator<(const pstring &string) const { return (pcmp(string.cstr()) < 0); } + bool operator<=(const char *string) const { return (pcmp(string) <= 0); } + bool operator<=(const pstring &string) const { return (pcmp(string.cstr()) <= 0); } + bool operator>(const char *string) const { return (pcmp(string) > 0); } + bool operator>(const pstring &string) const { return (pcmp(string.cstr()) > 0); } + bool operator>=(const char *string) const { return (pcmp(string) >= 0); } + bool operator>=(const pstring &string) const { return (pcmp(string.cstr()) >= 0); } - // - inline int len() const { return m_ptr->len(); } + // + inline int len() const { return m_ptr->len(); } - inline bool equals(const pstring &string) { return (pcmp(string.cstr(), m_ptr->str()) == 0); } - inline bool iequals(const pstring &string) { return (pcmpi(string.cstr(), m_ptr->str()) == 0); } + inline bool equals(const pstring &string) { return (pcmp(string.cstr(), m_ptr->str()) == 0); } + inline bool iequals(const pstring &string) { return (pcmpi(string.cstr(), m_ptr->str()) == 0); } - inline int cmp(const pstring &string) const { return pcmp(string.cstr()); } - inline int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); } + inline int cmp(const pstring &string) const { return pcmp(string.cstr()); } + inline int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); } - inline int find(const char *search, int start = 0) const - { - int alen = len(); - const char *result = strstr(cstr() + MIN(start, alen), search); - return (result != NULL) ? (result - cstr()) : -1; - } + inline int find(const char *search, int start = 0) const + { + int alen = len(); + const char *result = strstr(cstr() + MIN(start, alen), search); + return (result != NULL) ? (result - cstr()) : -1; + } - // various + // various - inline bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); } - inline bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); } + inline bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); } + inline bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); } - // these return nstring ... - inline pstring cat(const pstring &s) const { return *this + s; } - inline pstring cat(const char *s) const { return *this + s; } + // these return nstring ... + inline pstring cat(const pstring &s) const { return *this + s; } + inline pstring cat(const char *s) const { return *this + s; } - pstring substr(unsigned int start, int count = -1) const ; + pstring substr(unsigned int start, int count = -1) const ; - inline pstring left(unsigned int count) const { return substr(0, count); } - inline pstring right(unsigned int count) const { return substr(len() - count, count); } + inline pstring left(unsigned int count) const { return substr(0, count); } + inline pstring right(unsigned int count) const { return substr(len() - count, count); } - pstring ucase() const; + pstring ucase() const; - // conversions + // conversions - double as_double(bool *error = NULL) const; + double as_double(bool *error = NULL) const; - long as_long(bool *error = NULL) const; + long as_long(bool *error = NULL) const; - // printf using string as format ... + // printf using string as format ... - pstring vprintf(va_list args) const; + pstring vprintf(va_list args) const; - // static - static pstring sprintf(const char *format, ...); - static void resetmem(); + // static + static pstring sprintf(const char *format, ...); + static void resetmem(); protected: - struct str_t - { - str_t(int alen) : m_ref_count(1), m_len(alen) { m_str[0] = 0; } + struct str_t + { + str_t(int alen) : m_ref_count(1), m_len(alen) { m_str[0] = 0; } - char *str() { return &m_str[0]; } - int len() { return m_len; } - //private: - int m_ref_count; - int m_len; - char m_str[1]; - }; + char *str() { return &m_str[0]; } + int len() { return m_len; } + //private: + int m_ref_count; + int m_len; + char m_str[1]; + }; - str_t *m_ptr; + str_t *m_ptr; - static pblockpool m_pool; + static pblockpool m_pool; private: - inline void init() - { - if (m_zero == NULL) - { - m_zero = new(pstring::m_pool, 0) pstring::str_t(0); - } - m_ptr = m_zero; - m_ptr->m_ref_count++; - } - - inline int pcmp(const char *right) const - { - return pcmp(m_ptr->str(), right); - } - - inline int pcmp(const char *left, const char *right, int count = -1) const - { - if (count < 0) - return strcmp(left, right); - else - return strncmp(left, right, count); - } - - int pcmpi(const char *lhs, const char *rhs, int count = -1) const; - - void pcopy(const char *from, int size); - - inline void pcopy(const char *from) - { - pcopy(from, strlen(from)); - } - - inline void pcopy(const pstring &from) - { - sfree(m_ptr); - m_ptr = from.m_ptr; - m_ptr->m_ref_count++; - } - - void pcat(const char *s); - - static str_t *salloc(int n); - static void sfree(str_t *s); - - static str_t *m_zero; + inline void init() + { + if (m_zero == NULL) + { + m_zero = new(pstring::m_pool, 0) pstring::str_t(0); + } + m_ptr = m_zero; + m_ptr->m_ref_count++; + } + + inline int pcmp(const char *right) const + { + return pcmp(m_ptr->str(), right); + } + + inline int pcmp(const char *left, const char *right, int count = -1) const + { + if (count < 0) + return strcmp(left, right); + else + return strncmp(left, right, count); + } + + int pcmpi(const char *lhs, const char *rhs, int count = -1) const; + + void pcopy(const char *from, int size); + + inline void pcopy(const char *from) + { + pcopy(from, strlen(from)); + } + + inline void pcopy(const pstring &from) + { + sfree(m_ptr); + m_ptr = from.m_ptr; + m_ptr->m_ref_count++; + } + + void pcat(const char *s); + + static str_t *salloc(int n); + static void sfree(str_t *s); + + static str_t *m_zero; }; #endif /* _PSTRING_H_ */ - diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index ac2a0ace351..f7d5e93a490 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -698,7 +698,7 @@ void discrete_device::init_nodes(const sound_block_list_t &block_list) { const discrete_block *block = block_list[i]; - //discrete_base_node *node = block->factory->Create(this, block); + //discrete_base_node *node = block->factory->Create(this, block); discrete_base_node *node = block->factory(this, block); /* keep track of special nodes */ if (block->node == NODE_SPECIAL) diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index 8db5e8e03a6..c796ee79bd9 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -4531,7 +4531,7 @@ discrete_base_node * discrete_node_factory<C>::Create(discrete_device * pdev, co template <class C> discrete_base_node *discrete_create_node(discrete_device * pdev, const discrete_block *block) { - return discrete_node_factory< C >().Create(pdev, block); + return discrete_node_factory< C >().Create(pdev, block); } #define DISCRETE_SOUND_EXTERN(name) extern const discrete_block name##_discrete_interface[] diff --git a/src/emu/sound/es5506.c b/src/emu/sound/es5506.c index 14d07739453..43748fab3ee 100644 --- a/src/emu/sound/es5506.c +++ b/src/emu/sound/es5506.c @@ -381,7 +381,7 @@ void es5505_device::device_start() /* initialize the regions */ m_region_base[0] = m_es5505_region0 ? (UINT16 *)machine().root_device().memregion(m_es5505_region0)->base() : NULL; m_region_base[1] = m_es5505_region1 ? (UINT16 *)machine().root_device().memregion(m_es5505_region1)->base() : NULL; - + /* initialize the rest of the structure */ m_master_clock = clock(); m_irq_callback_func.resolve(m_es5505_irq_callback, *this); @@ -2208,7 +2208,6 @@ READ16_MEMBER( es5505_device::read ) void es5505_device::voice_bank_w(int voice, int bank) { - #if RAINE_CHECK m_voice[voice].control = CONTROL_STOPMASK; #endif @@ -2226,7 +2225,6 @@ void es550x_device::sound_stream_update(sound_stream &stream, stream_sample_t ** void es5506_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { - #if MAKE_WAVS /* start the logging once we have a sample rate */ if (m_sample_rate) @@ -2273,7 +2271,6 @@ void es5506_device::sound_stream_update(sound_stream &stream, stream_sample_t ** void es5505_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { - #if MAKE_WAVS /* start the logging once we have a sample rate */ if (m_sample_rate) @@ -2316,4 +2313,4 @@ void es5505_device::sound_stream_update(sound_stream &stream, stream_sample_t ** offset += length; samples -= length; } -}
\ No newline at end of file +} diff --git a/src/emu/sound/es5506.h b/src/emu/sound/es5506.h index f4e264e315f..a900ac1dd5e 100644 --- a/src/emu/sound/es5506.h +++ b/src/emu/sound/es5506.h @@ -64,7 +64,7 @@ struct es550x_voice index(0), filtcount(0), accum_mask(0) {} - + /* external state */ UINT32 control; /* control register */ UINT32 freqcount; /* frequency count register */ @@ -139,9 +139,9 @@ protected: #if MAKE_WAVS void * m_wavraw; /* raw waveform */ #endif - + FILE *m_eslog; - + void update_irq_state(); void update_internal_irq_state(); void compute_tables(); @@ -158,7 +158,7 @@ class es5506_device : public es550x_device, public: es5506_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~es5506_device() {} - + DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); void voice_bank_w(int voice, int bank); @@ -170,8 +170,8 @@ protected: // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - - + + void generate_samples(INT32 **outputs, int offset, int samples); private: @@ -191,7 +191,7 @@ class es5505_device : public es550x_device, { public: es5505_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + DECLARE_READ16_MEMBER( read ); DECLARE_WRITE16_MEMBER( write ); void voice_bank_w(int voice, int bank); @@ -200,11 +200,11 @@ protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); - + virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - + void generate_samples(INT32 **outputs, int offset, int samples); - + private: // internal state inline void reg_write_low(es550x_voice *voice, offs_t offset, UINT16 data, UINT16 mem_mask); diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index 8c3a782afda..99667233549 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -63,14 +63,14 @@ void k054539_device::static_set_interface(device_t &device, const k054539_interf 22d: Data read/write port 22e: ROM/RAM select (00..7f == ROM banks, 80 = Reverb RAM) 22f: Global control: - .......x - Enable PCM - ......x. - Timer related? - ...x.... - Enable ROM/RAM readback from 0x22d - ..x..... - Timer output enable? - x....... - Disable register RAM updates - - The chip has an optional 0x8000 byte reverb buffer. - The reverb delay is actually an offset in this buffer. + .......x - Enable PCM + ......x. - Timer related? + ...x.... - Enable ROM/RAM readback from 0x22d + ..x..... - Timer output enable? + x....... - Disable register RAM updates + + The chip has an optional 0x8000 byte reverb buffer. + The reverb delay is actually an offset in this buffer. */ void k054539_device::init_flags(int _flags) @@ -440,7 +440,7 @@ WRITE8_MEMBER(k054539_device::write) cur_limit = data == 0x80 ? 0x4000 : 0x20000; cur_ptr = 0; break; - + case 0x22f: if (!(data & 0x20)) // Disable timer output? { @@ -537,4 +537,4 @@ void k054539_device::device_start() void k054539_device::device_reset() { m_timer->enable(false); -}
\ No newline at end of file +} diff --git a/src/emu/sound/k054539.h b/src/emu/sound/k054539.h index c1be626ca06..30369e4a7eb 100644 --- a/src/emu/sound/k054539.h +++ b/src/emu/sound/k054539.h @@ -49,9 +49,9 @@ public: k054539_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); // static configuration helpers - static void static_set_interface(device_t &device, const k054539_interface &interface); + static void static_set_interface(device_t &device, const k054539_interface &interface); template<class _Object> static devcb2_base &set_timer_handler(device_t &device, _Object object) { return downcast<k054539_device &>(device).m_timer_handler.set_callback(object); } - + DECLARE_WRITE8_MEMBER(write); DECLARE_READ8_MEMBER(read); @@ -109,10 +109,10 @@ private: channel channels[8]; sound_stream *stream; - - emu_timer *m_timer; - UINT32 m_timer_state; - devcb2_write_line m_timer_handler; + + emu_timer *m_timer; + UINT32 m_timer_state; + devcb2_write_line m_timer_handler; bool regupdate(); void keyon(int channel); diff --git a/src/emu/sound/k056800.c b/src/emu/sound/k056800.c index 44ae81f6c9f..60443468b6d 100644 --- a/src/emu/sound/k056800.c +++ b/src/emu/sound/k056800.c @@ -59,7 +59,7 @@ READ8_MEMBER( k056800_device::host_r ) { UINT32 r = offset & 7; UINT8 data = 0; - + switch (r) { case 0: @@ -102,7 +102,7 @@ WRITE8_MEMBER( k056800_device::host_w ) // .... ...x - Mute front // .... ..x. - Mute rear break; - + case 7: // Sound interrupt m_int_pending = true; @@ -119,7 +119,7 @@ READ8_MEMBER( k056800_device::sound_r ) { UINT32 r = offset & 7; UINT8 data = 0; - + switch (r) { case 0: @@ -144,7 +144,7 @@ WRITE8_MEMBER( k056800_device::sound_w ) case 1: m_snd_to_host_regs[r] = data; break; - + case 2: case 3: // TODO: Unknown @@ -167,9 +167,9 @@ WRITE8_MEMBER( k056800_device::sound_w ) m_int_handler(CLEAR_LINE); } break; - + case 5: // TODO: Unknown break; } -}
\ No newline at end of file +} diff --git a/src/emu/sound/k056800.h b/src/emu/sound/k056800.h index 2942f3616f4..121244e950b 100644 --- a/src/emu/sound/k056800.h +++ b/src/emu/sound/k056800.h @@ -13,8 +13,7 @@ ***************************************************************************/ #define MCFG_K056800_ADD(_tag, _clock) \ - MCFG_DEVICE_ADD(_tag, K056800, _clock) \ - + MCFG_DEVICE_ADD(_tag, K056800, _clock) #define MCFG_K056800_INT_HANDLER(_devcb) \ devcb = &k056800_device::set_int_handler(*device, DEVCB2_##_devcb); @@ -45,12 +44,12 @@ protected: private: // internal state - bool m_int_pending; - bool m_int_enabled; - UINT8 m_host_to_snd_regs[4]; - UINT8 m_snd_to_host_regs[2]; + bool m_int_pending; + bool m_int_enabled; + UINT8 m_host_to_snd_regs[4]; + UINT8 m_snd_to_host_regs[2]; - devcb2_write_line m_int_handler; + devcb2_write_line m_int_handler; }; extern const device_type K056800; diff --git a/src/emu/sound/mpeg_audio.c b/src/emu/sound/mpeg_audio.c index d1160026dd3..82622e4abff 100644 --- a/src/emu/sound/mpeg_audio.c +++ b/src/emu/sound/mpeg_audio.c @@ -128,7 +128,7 @@ bool mpeg_audio::read_header_amm(bool layer25) int stereo_mode_ext = gb(2); param_index = gb(3); gb(1); // must be zero - + channel_count = stereo_mode != 3 ? 2 : 1; total_bands = total_band_counts[param_index]; @@ -137,7 +137,7 @@ bool mpeg_audio::read_header_amm(bool layer25) joint_bands = joint_band_counts[stereo_mode_ext]; if(joint_bands > total_bands ) joint_bands = total_bands; - + return true; } diff --git a/src/emu/sound/nes_apu.h b/src/emu/sound/nes_apu.h index 996bd1027ed..a47c246e034 100644 --- a/src/emu/sound/nes_apu.h +++ b/src/emu/sound/nes_apu.h @@ -34,9 +34,9 @@ * Also make sure to correspond the memory regions to those used in the * processor, as each is shared. */ - + #include "nes_defs.h" - + /* GLOBAL CONSTANTS */ #define SYNCS_MAX1 0x20 #define SYNCS_MAX2 0x80 @@ -56,7 +56,7 @@ public: DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); - + protected: // device-level overrides virtual void device_config_complete(); @@ -77,7 +77,7 @@ private: uint32 m_sync_times1[SYNCS_MAX1]; /* Samples per sync table */ uint32 m_sync_times2[SYNCS_MAX2]; /* Samples per sync table */ sound_stream *m_stream; - + void create_syncs(unsigned long sps); int8 apu_square(square_t *chan); int8 apu_triangle(triangle_t *chan); diff --git a/src/emu/sound/sn76477.c b/src/emu/sound/sn76477.c index 7fc9224f8da..ba4f85b9cf5 100644 --- a/src/emu/sound/sn76477.c +++ b/src/emu/sound/sn76477.c @@ -301,7 +301,7 @@ void sn76477_device::device_start() } intialize_noise(); - + /* set up interface values */ _SN76477_enable_w(m_intf_enable); _SN76477_vco_w(m_intf_vco); diff --git a/src/emu/sound/sn76477.h b/src/emu/sound/sn76477.h index 7f446669d15..c472fc19e41 100644 --- a/src/emu/sound/sn76477.h +++ b/src/emu/sound/sn76477.h @@ -82,7 +82,7 @@ class sn76477_device : public device_t, public: sn76477_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); ~sn76477_device() {} - + /* these functions take 0 or 1 as a logic input */ WRITE_LINE_MEMBER( enable_w ); /* active LO, 0 = enabled, 1 = disabled */ WRITE_LINE_MEMBER( mixer_a_w ); @@ -106,8 +106,8 @@ public: /* these functions take a capacitor value in Farads or the voltage on it in Volts */ #define SN76477_EXTERNAL_VOLTAGE_DISCONNECT (-1.0) /* indicates that the voltage is internally computed, - can be used in all the functions that take a - voltage on a capacitor */ + can be used in all the functions that take a + voltage on a capacitor */ void one_shot_cap_w(double data); void one_shot_cap_voltage_w(double data); void slf_cap_w(double data); @@ -131,7 +131,7 @@ protected: // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - + private: /* chip's external interface */ UINT32 m_enable; @@ -167,7 +167,7 @@ private: double m_amplitude_res; double m_feedback_res; double m_pitch_voltage; - + // internal state double m_one_shot_cap_voltage; /* voltage on the one-shot cap */ UINT32 m_one_shot_running_ff; /* 1 = one-shot running, 0 = stopped */ @@ -191,9 +191,9 @@ private: /* others */ sound_stream *m_channel; /* returned by stream_create() */ int m_our_sample_rate; /* from machine.sample_rate() */ - + wav_file *m_file; /* handle of the wave file to produce */ - + double compute_one_shot_cap_charging_rate(); double compute_one_shot_cap_discharging_rate(); double compute_slf_cap_charging_rate(); @@ -206,7 +206,7 @@ private: double compute_attack_decay_cap_charging_rate(); double compute_attack_decay_cap_discharging_rate(); double compute_center_to_peak_voltage_out(); - + void log_enable_line(); void log_mixer_mode(); void log_envelope_mode(); @@ -223,16 +223,16 @@ private: void log_decay_time(); void log_voltage_out(); void log_complete_state(); - + void open_wav_file(); void close_wav_file(); void add_wav_data(INT16 data_l, INT16 data_r); - + void intialize_noise(); inline UINT32 generate_next_real_noise_bit(); - + void state_save_register(); - + void _SN76477_enable_w(UINT32 data); void _SN76477_vco_w(UINT32 data); void _SN76477_mixer_a_w(UINT32 data); diff --git a/src/emu/sound/speaker.h b/src/emu/sound/speaker.h index 88ed216fa89..d439f0897eb 100644 --- a/src/emu/sound/speaker.h +++ b/src/emu/sound/speaker.h @@ -83,7 +83,7 @@ private: void speaker_postload(); // DC blocker state - double m_prevx, m_prevy; + double m_prevx, m_prevy; }; extern const device_type SPEAKER_SOUND; diff --git a/src/emu/sound/wave.h b/src/emu/sound/wave.h index c6a22b23e60..1f67e950d91 100644 --- a/src/emu/sound/wave.h +++ b/src/emu/sound/wave.h @@ -13,9 +13,9 @@ class wave_device : public device_t, { public: wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - + static void static_set_cassette_tag(device_t &device, const char *cassette_tag); - + protected: // device-level overrides virtual void device_config_complete(); diff --git a/src/emu/sound/ymz770.c b/src/emu/sound/ymz770.c index 94a9c8df248..3bc23445285 100644 --- a/src/emu/sound/ymz770.c +++ b/src/emu/sound/ymz770.c @@ -163,7 +163,7 @@ void ymz770_device::sound_stream_update(sound_stream &stream, stream_sample_t ** } } } - + // process channels INT32 mix = 0; @@ -174,11 +174,11 @@ void ymz770_device::sound_stream_update(sound_stream &stream, stream_sample_t ** // force finish current block mix += (m_channels[ch].output_data[m_channels[ch].output_ptr++]*m_channels[ch].volume); m_channels[ch].output_remaining--; - + if (m_channels[ch].output_remaining == 0 && !m_channels[ch].is_playing) m_channels[ch].decoder->clear(); } - + else if (m_channels[ch].is_playing) { retry: @@ -254,11 +254,11 @@ void ymz770_device::internal_reg_write(UINT8 reg, UINT8 data) m_mute = data & 1; m_doen = data >> 1 & 1; break; - + case 0x01: m_vlma = data; break; - + case 0x02: m_bsl = data & 7; m_cpl = data >> 4 & 7; @@ -308,7 +308,7 @@ void ymz770_device::internal_reg_write(UINT8 reg, UINT8 data) break; } } - + // sequencer registers else { diff --git a/src/emu/video/fixfreq.c b/src/emu/video/fixfreq.c index 0ab0c7f7b88..3437c604c39 100644 --- a/src/emu/video/fixfreq.c +++ b/src/emu/video/fixfreq.c @@ -114,27 +114,27 @@ void fixedfreq_device::device_start() //m_vblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vga_device::vblank_timer_cb),this)); recompute_parameters(false); - save_item(NAME(m_vid)); - save_item(NAME(m_last_x)); - save_item(NAME(m_last_y)); - save_item(NAME(m_last_time)); - save_item(NAME(m_line_time)); - save_item(NAME(m_last_hsync_time)); - save_item(NAME(m_last_vsync_time)); - save_item(NAME(m_refresh)); - save_item(NAME(m_clock_period)); - //save_item(NAME(m_bitmap[0])); - //save_item(NAME(m_bitmap[1])); - save_item(NAME(m_cur_bm)); - - /* sync separator */ - save_item(NAME(m_vint)); - save_item(NAME(m_int_trig)); - save_item(NAME(m_mult)); - - save_item(NAME(m_sig_vsync)); - save_item(NAME(m_sig_composite)); - save_item(NAME(m_sig_field)); + save_item(NAME(m_vid)); + save_item(NAME(m_last_x)); + save_item(NAME(m_last_y)); + save_item(NAME(m_last_time)); + save_item(NAME(m_line_time)); + save_item(NAME(m_last_hsync_time)); + save_item(NAME(m_last_vsync_time)); + save_item(NAME(m_refresh)); + save_item(NAME(m_clock_period)); + //save_item(NAME(m_bitmap[0])); + //save_item(NAME(m_bitmap[1])); + save_item(NAME(m_cur_bm)); + + /* sync separator */ + save_item(NAME(m_vint)); + save_item(NAME(m_int_trig)); + save_item(NAME(m_mult)); + + save_item(NAME(m_sig_vsync)); + save_item(NAME(m_sig_composite)); + save_item(NAME(m_sig_field)); @@ -210,7 +210,7 @@ int fixedfreq_device::sync_separator(attotime time, double newval) int ret = 0; m_vint += ((double) last_comp - m_vint) * (1.0 - exp(-time.as_double() * m_mult)); - m_sig_composite = (newval < m_sync_threshold) ? 1 : 0 ; + m_sig_composite = (newval < m_sync_threshold) ? 1 : 0 ; m_sig_vsync = (m_vint > m_int_trig) ? 1 : 0; diff --git a/src/emu/video/mb_vcu.c b/src/emu/video/mb_vcu.c index 8df59404254..ac0b9899281 100644 --- a/src/emu/video/mb_vcu.c +++ b/src/emu/video/mb_vcu.c @@ -278,7 +278,7 @@ READ8_MEMBER( mb_vcu_device::load_gfx ) UINT8 pen = 0; UINT8 cur_layer; -// cur_layer = (m_mode & 0x3); +// cur_layer = (m_mode & 0x3); cur_layer = 0; switch(m_mode >> 2) diff --git a/src/emu/video/v9938.c b/src/emu/video/v9938.c index 0ae5e770375..8ecdaa22ef8 100644 --- a/src/emu/video/v9938.c +++ b/src/emu/video/v9938.c @@ -1425,7 +1425,7 @@ void v99x8_device::mode_graphic7(const pen_t *pens, _PixelType *ln, int line) for (x=0;x<64;x++) { int colour[4]; - int ind; + int ind; colour[0] = m_vram_space->read_byte(((nametbl_addr&1) << 16) | (nametbl_addr>>1)); nametbl_addr++; @@ -1435,8 +1435,8 @@ void v99x8_device::mode_graphic7(const pen_t *pens, _PixelType *ln, int line) nametbl_addr++; colour[3] = m_vram_space->read_byte(((nametbl_addr&1) << 16) | (nametbl_addr>>1)); - ind = (colour[0] & 7) << 11 | (colour[1] & 7) << 14 | - (colour[2] & 7) << 5 | (colour[3] & 7) << 8; + ind = (colour[0] & 7) << 11 | (colour[1] & 7) << 14 | + (colour[2] & 7) << 5 | (colour[3] & 7) << 8; *ln++ = s_pal_indYJK[ind | ((colour[0] >> 3) & 31)]; if (_Width > 512) @@ -1465,7 +1465,7 @@ void v99x8_device::mode_graphic7(const pen_t *pens, _PixelType *ln, int line) for (x=0;x<64;x++) { int colour[4]; - int ind; + int ind; colour[0] = m_vram_space->read_byte(((nametbl_addr&1) << 16) | (nametbl_addr>>1)); nametbl_addr++; @@ -1475,8 +1475,8 @@ void v99x8_device::mode_graphic7(const pen_t *pens, _PixelType *ln, int line) nametbl_addr++; colour[3] = m_vram_space->read_byte(((nametbl_addr&1) << 16) | (nametbl_addr>>1)); - ind = (colour[0] & 7) << 11 | (colour[1] & 7) << 14 | - (colour[2] & 7) << 5 | (colour[3] & 7) << 8; + ind = (colour[0] & 7) << 11 | (colour[1] & 7) << 14 | + (colour[2] & 7) << 5 | (colour[3] & 7) << 8; *ln++ = colour[0] & 8 ? m_pal_ind16[colour[0] >> 4] : s_pal_indYJK[ind | ((colour[0] >> 3) & 30)]; if (_Width > 512) |
