diff options
29 files changed, 292 insertions, 54 deletions
diff --git a/nl_examples/msx_mixer_stage.c b/nl_examples/msx_mixer_stage.c index ea13aa0c9cd..1e7bbb821b7 100644 --- a/nl_examples/msx_mixer_stage.c +++ b/nl_examples/msx_mixer_stage.c @@ -13,7 +13,7 @@ NETLIST_START(msx) NETDEV_PARAM(clk.FREQ, 1000) // 1000 Hz NETDEV_SOLVER(Solver) NETDEV_PARAM(Solver.FREQ, 48000) - NETDEV_PARAM(Solver.ACCURACY, 1e-5) + NETDEV_PARAM(Solver.ACCURACY, 1e-4) NETDEV_R(RAY8910, 2345) // Max Voltage diff --git a/src/emu/machine/netlist.h b/src/emu/machine/netlist.h index b1d7f8aec32..514371879b1 100644 --- a/src/emu/machine/netlist.h +++ b/src/emu/machine/netlist.h @@ -374,6 +374,10 @@ public: m_cpu_device = downcast<netlist_mame_cpu_device_t *>(&downcast<netlist_mame_t &>(netlist()).parent()); } + ATTR_COLD void reset() + { + } + ATTR_COLD void register_callback(netlist_analog_output_delegate callback) { m_callback = callback; @@ -403,11 +407,15 @@ public: 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_COLD void reset() + { + 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() { diff --git a/src/emu/netlist/analog/nld_bjt.c b/src/emu/netlist/analog/nld_bjt.c index 7662a5584a4..cb67bc45662 100644 --- a/src/emu/netlist/analog/nld_bjt.c +++ b/src/emu/netlist/analog/nld_bjt.c @@ -45,6 +45,14 @@ NETLIB_START(Q) register_param("model", m_model, ""); } +NETLIB_RESET(Q) +{ +} + +// ---------------------------------------------------------------------------------------- +// nld_QBJT_switch +// ---------------------------------------------------------------------------------------- + NETLIB_START(QBJT_switch) { NETLIB_NAME(Q)::start(); @@ -155,6 +163,11 @@ NETLIB_START(QBJT_EB) } } +NETLIB_RESET(QBJT_EB) +{ + NETLIB_NAME(Q)::reset(); +} + NETLIB_UPDATE(QBJT_EB) { #if !(USE_ALTERNATE_SCHEDULING) diff --git a/src/emu/netlist/analog/nld_bjt.h b/src/emu/netlist/analog/nld_bjt.h index 962e28e9e89..1c5aaca0806 100644 --- a/src/emu/netlist/analog/nld_bjt.h +++ b/src/emu/netlist/analog/nld_bjt.h @@ -45,6 +45,7 @@ public: inline void set_qtype(q_type atype) { m_qtype = atype; } protected: ATTR_COLD virtual void start(); + ATTR_COLD virtual void reset(); ATTR_HOT ATTR_ALIGN void update(); netlist_param_model_t m_model; @@ -168,6 +169,7 @@ public: protected: ATTR_COLD virtual void start(); + ATTR_COLD virtual void reset(); ATTR_HOT void update_param(); ATTR_HOT ATTR_ALIGN void virtual update(); diff --git a/src/emu/netlist/analog/nld_fourterm.c b/src/emu/netlist/analog/nld_fourterm.c index 0dea6c8281e..41e8a9dd591 100644 --- a/src/emu/netlist/analog/nld_fourterm.c +++ b/src/emu/netlist/analog/nld_fourterm.c @@ -16,6 +16,10 @@ NETLIB_START(VCCS) configure(1.0, NETLIST_GMIN); } +NETLIB_RESET(VCCS) +{ +} + ATTR_COLD void NETLIB_NAME(VCCS)::configure(const double Gfac, const double GI) { register_param("G", m_G, 1.0); diff --git a/src/emu/netlist/analog/nld_fourterm.h b/src/emu/netlist/analog/nld_fourterm.h index 0520329a08d..6ce1cceb586 100644 --- a/src/emu/netlist/analog/nld_fourterm.h +++ b/src/emu/netlist/analog/nld_fourterm.h @@ -79,6 +79,7 @@ public: protected: ATTR_COLD virtual void start(); + ATTR_COLD virtual void reset(); ATTR_COLD virtual void update_param(); ATTR_HOT ATTR_ALIGN void update(); diff --git a/src/emu/netlist/analog/nld_solver.c b/src/emu/netlist/analog/nld_solver.c index 3329f575c0f..5ccbfb5a38f 100644 --- a/src/emu/netlist/analog/nld_solver.c +++ b/src/emu/netlist/analog/nld_solver.c @@ -271,6 +271,12 @@ NETLIB_START(solver) } +NETLIB_RESET(solver) +{ + m_last_step = netlist_time::zero; +} + + NETLIB_UPDATE_PARAM(solver) { m_inc = netlist_time::from_hz(m_freq.Value()); diff --git a/src/emu/netlist/analog/nld_solver.h b/src/emu/netlist/analog/nld_solver.h index d19cb4912b2..9bf07f9f66f 100644 --- a/src/emu/netlist/analog/nld_solver.h +++ b/src/emu/netlist/analog/nld_solver.h @@ -88,10 +88,6 @@ public: ATTR_HOT inline void schedule1(); ATTR_COLD void post_start(); - ATTR_COLD void reset() - { - m_last_step = netlist_time::zero; - } ); ATTR_HOT inline void NETLIB_NAME(solver)::schedule1() diff --git a/src/emu/netlist/analog/nld_switches.c b/src/emu/netlist/analog/nld_switches.c index 0598af86133..9f97e526b6d 100644 --- a/src/emu/netlist/analog/nld_switches.c +++ b/src/emu/netlist/analog/nld_switches.c @@ -11,15 +11,11 @@ NETLIB_START(switch2) { - register_sub(m_R[0], "R1"); register_sub(m_R[1], "R2"); register_param("POS", m_POS, 0); - m_R[0].set_R(R_ON); - m_R[1].set_R(R_OFF); - setup().connect(m_R[0].m_N, m_R[1].m_N); register_subalias("i1", m_R[0].m_P); @@ -28,6 +24,15 @@ NETLIB_START(switch2) register_subalias("Q", m_R[0].m_N); } +NETLIB_RESET(switch2) +{ + m_R[0].do_reset(); + m_R[1].do_reset(); + + m_R[0].set_R(R_ON); + m_R[1].set_R(R_OFF); +} + NETLIB_UPDATE(switch2) { } diff --git a/src/emu/netlist/analog/nld_twoterm.c b/src/emu/netlist/analog/nld_twoterm.c index 27f385a7125..f868a04e8c6 100644 --- a/src/emu/netlist/analog/nld_twoterm.c +++ b/src/emu/netlist/analog/nld_twoterm.c @@ -21,6 +21,11 @@ NETLIB_START(twoterm) { } +NETLIB_RESET(twoterm) +{ +} + + NETLIB_UPDATE(twoterm) { /* only called if connected to a rail net ==> notify the solver to recalculate */ @@ -43,6 +48,12 @@ NETLIB_START(R_base) register_terminal("2", m_N); } +NETLIB_RESET(R_base) +{ + NETLIB_NAME(twoterm)::reset(); + set_R(1.0 / NETLIST_GMIN); +} + NETLIB_UPDATE(R_base) { NETLIB_NAME(twoterm)::update(); @@ -54,6 +65,11 @@ NETLIB_START(R) register_param("R", m_R, 1.0 / NETLIST_GMIN); } +NETLIB_RESET(R) +{ + NETLIB_NAME(R_base)::reset(); +} + NETLIB_UPDATE(R) { NETLIB_NAME(twoterm)::update(); @@ -88,6 +104,12 @@ NETLIB_START(POT) } +NETLIB_RESET(POT) +{ + m_R1.do_reset(); + m_R2.do_reset(); +} + NETLIB_UPDATE(POT) { m_R1.update_dev(); diff --git a/src/emu/netlist/analog/nld_twoterm.h b/src/emu/netlist/analog/nld_twoterm.h index a77bcd0734e..94cc0e1420a 100644 --- a/src/emu/netlist/analog/nld_twoterm.h +++ b/src/emu/netlist/analog/nld_twoterm.h @@ -88,6 +88,7 @@ public: protected: ATTR_COLD virtual void start(); + ATTR_COLD virtual void reset(); ATTR_HOT ATTR_ALIGN void update(); private: @@ -106,6 +107,7 @@ public: protected: ATTR_COLD virtual void start(); + ATTR_COLD virtual void reset(); ATTR_HOT ATTR_ALIGN void update(); }; diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c index 9171c8c66fd..c9193ea013a 100644 --- a/src/emu/netlist/devices/net_lib.c +++ b/src/emu/netlist/devices/net_lib.c @@ -72,6 +72,11 @@ NETLIB_START(nic7448) register_subalias("g", sub.m_g); } +NETLIB_RESET(nic7448) +{ + sub.do_reset(); +} + NETLIB_UPDATE(nic7448) { if (INPLOGIC(m_BIQ) && !INPLOGIC(m_LTQ)) @@ -103,8 +108,6 @@ NETLIB_UPDATE(nic7448) NETLIB_START(nic7448_sub) { - m_state = 0; - register_input("A0", m_A0); register_input("A1", m_A1); register_input("A2", m_A2); @@ -122,6 +125,11 @@ NETLIB_START(nic7448_sub) save(NAME(m_state)); } +NETLIB_RESET(nic7448_sub) +{ + m_state = 0; +} + NETLIB_UPDATE(nic7448_sub) { UINT8 v; @@ -179,6 +187,10 @@ NETLIB_START(nic7450) register_output("Q", m_Q); } +NETLIB_RESET(nic7450) +{ +} + NETLIB_UPDATE(nic7450) { m_I0.activate(); diff --git a/src/emu/netlist/devices/nld_7400.h b/src/emu/netlist/devices/nld_7400.h index 76af3043c4b..b9b06ec484f 100644 --- a/src/emu/netlist/devices/nld_7400.h +++ b/src/emu/netlist/devices/nld_7400.h @@ -73,4 +73,12 @@ inline NETLIB_START(7400pin) register_subalias("11", m_4.m_Q); } +inline NETLIB_RESET(7400pin) +{ + m_1.do_reset(); + m_2.do_reset(); + m_3.do_reset(); + m_4.do_reset(); +} + #endif /* NLD_7400_H_ */ diff --git a/src/emu/netlist/devices/nld_7404.c b/src/emu/netlist/devices/nld_7404.c index 42b7e341c39..d8e2191afe9 100644 --- a/src/emu/netlist/devices/nld_7404.c +++ b/src/emu/netlist/devices/nld_7404.c @@ -9,7 +9,11 @@ NETLIB_START(nic7404) { register_input("A", m_I); register_output("Q", m_Q); - m_Q.initial(1); +} + +NETLIB_RESET(nic7404) +{ + m_Q.initial(1); } NETLIB_UPDATE(nic7404) diff --git a/src/emu/netlist/devices/nld_74107.c b/src/emu/netlist/devices/nld_74107.c index 7249f9fa4f5..46d155d1d93 100644 --- a/src/emu/netlist/devices/nld_74107.c +++ b/src/emu/netlist/devices/nld_74107.c @@ -11,18 +11,21 @@ NETLIB_START(nic74107Asub) register_output("Q", m_Q); register_output("QQ", m_QQ); - m_Q.initial(0); - m_QQ.initial(1); - - m_Q1 = 0; - m_Q2 = 0; - m_F = 0; - save(NAME(m_Q1)); save(NAME(m_Q2)); save(NAME(m_F)); } +NETLIB_RESET(nic74107Asub) +{ + m_Q.initial(0); + m_QQ.initial(1); + + m_Q1 = 0; + m_Q2 = 0; + m_F = 0; +} + NETLIB_START(nic74107A) { register_sub(sub, "sub"); @@ -36,6 +39,11 @@ NETLIB_START(nic74107A) } +NETLIB_RESET(nic74107A) +{ + sub.reset(); +} + 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) }; diff --git a/src/emu/netlist/devices/nld_74153.c b/src/emu/netlist/devices/nld_74153.c index d646407307e..528ee935671 100644 --- a/src/emu/netlist/devices/nld_74153.c +++ b/src/emu/netlist/devices/nld_74153.c @@ -18,6 +18,10 @@ NETLIB_START(nic74153) register_output("AY", m_Y); //FIXME: Change netlists } +NETLIB_RESET(nic74153) +{ +} + /* FIXME: timing is not 100% accurate, Strobe and Select inputs have a * slightly longer timing. * Convert this to sub-devices at some time. diff --git a/src/emu/netlist/devices/nld_7474.c b/src/emu/netlist/devices/nld_7474.c index 90d11c3e284..b64a9a880b6 100644 --- a/src/emu/netlist/devices/nld_7474.c +++ b/src/emu/netlist/devices/nld_7474.c @@ -57,6 +57,11 @@ NETLIB_START(7474) } +NETLIB_RESET(7474) +{ + sub.do_reset(); +} + NETLIB_START(7474sub) { register_input("CLK", m_clk, netlist_input_t::STATE_INP_LH); @@ -64,9 +69,13 @@ NETLIB_START(7474sub) register_output("Q", m_Q); register_output("QQ", m_QQ); - m_nextD = 0; - m_Q.initial(1); - m_QQ.initial(0); - save(NAME(m_nextD)); } + +NETLIB_RESET(7474sub) +{ + m_nextD = 0; + m_Q.initial(1); + m_QQ.initial(0); +} + diff --git a/src/emu/netlist/devices/nld_7483.c b/src/emu/netlist/devices/nld_7483.c index 81624326d6e..4ffadcc06d2 100644 --- a/src/emu/netlist/devices/nld_7483.c +++ b/src/emu/netlist/devices/nld_7483.c @@ -7,8 +7,6 @@ NETLIB_START(7483) { - m_lastr = 0; - register_input("A1", m_A1); register_input("A2", m_A2); register_input("A3", m_A3); @@ -28,6 +26,11 @@ NETLIB_START(7483) save(NAME(m_lastr)); } +NETLIB_RESET(7483) +{ + m_lastr = 0; +} + NETLIB_UPDATE(7483) { UINT8 a = (INPLOGIC(m_A1) << 0) | (INPLOGIC(m_A2) << 1) | (INPLOGIC(m_A3) << 2) | (INPLOGIC(m_A4) << 3); diff --git a/src/emu/netlist/devices/nld_7486.c b/src/emu/netlist/devices/nld_7486.c index fcd94c9f321..72fa43615a0 100644 --- a/src/emu/netlist/devices/nld_7486.c +++ b/src/emu/netlist/devices/nld_7486.c @@ -12,6 +12,10 @@ NETLIB_START(7486) register_output("Q", m_Q); } +NETLIB_RESET(7486) +{ +} + NETLIB_UPDATE(7486) { static const netlist_time delay[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; diff --git a/src/emu/netlist/devices/nld_7490.c b/src/emu/netlist/devices/nld_7490.c index cc84a1389c3..cb951b481f6 100644 --- a/src/emu/netlist/devices/nld_7490.c +++ b/src/emu/netlist/devices/nld_7490.c @@ -7,8 +7,6 @@ NETLIB_START(7490) { - m_cnt = 0; - register_input("CLK", m_clk); register_input("R1", m_R1); register_input("R2", m_R2); @@ -24,6 +22,11 @@ NETLIB_START(7490) } +NETLIB_RESET(7490) +{ + m_cnt = 0; +} + NETLIB_UPDATE(7490) { if (INPLOGIC(m_R91) & INPLOGIC(m_R92)) diff --git a/src/emu/netlist/devices/nld_7493.c b/src/emu/netlist/devices/nld_7493.c index ac633df081b..432b81cbfab 100644 --- a/src/emu/netlist/devices/nld_7493.c +++ b/src/emu/netlist/devices/nld_7493.c @@ -26,16 +26,27 @@ NETLIB_START(7493) register_link_internal(D, D.m_I, C.m_Q, netlist_input_t::STATE_INP_HL); } -NETLIB_START(7493ff) +NETLIB_RESET(7493) { - m_reset = 0; + A.do_reset(); + B.do_reset(); + C.do_reset(); + D.do_reset(); +} +NETLIB_START(7493ff) +{ register_input("CLK", m_I, netlist_input_t::STATE_INP_HL); register_output("Q", m_Q); save(NAME(m_reset)); } +NETLIB_RESET(7493ff) +{ + m_reset = 0; +} + NETLIB_UPDATE(7493ff) { if (m_reset == 0) diff --git a/src/emu/netlist/devices/nld_9316.c b/src/emu/netlist/devices/nld_9316.c index 03138aaf0d6..119a29df4e2 100644 --- a/src/emu/netlist/devices/nld_9316.c +++ b/src/emu/netlist/devices/nld_9316.c @@ -29,12 +29,13 @@ NETLIB_START(9316) } -NETLIB_START(9316_sub) +NETLIB_RESET(9316) { - m_cnt = 0; - m_loadq = 1; - m_ent = 1; + sub.do_reset(); +} +NETLIB_START(9316_sub) +{ register_input("CLK", m_clk, netlist_input_t::STATE_INP_LH); register_input("A", m_A, netlist_input_t::STATE_INP_PASSIVE); @@ -53,6 +54,13 @@ NETLIB_START(9316_sub) save(NAME(m_ent)); } +NETLIB_RESET(9316_sub) +{ + m_cnt = 0; + m_loadq = 1; + m_ent = 1; +} + NETLIB_UPDATE(9316_sub) { UINT8 cnt = m_cnt; diff --git a/src/emu/netlist/devices/nld_legacy.c b/src/emu/netlist/devices/nld_legacy.c index 9c976d00484..529d5325651 100644 --- a/src/emu/netlist/devices/nld_legacy.c +++ b/src/emu/netlist/devices/nld_legacy.c @@ -12,8 +12,12 @@ NETLIB_START(nicRSFF) register_input("R", m_R); register_output("Q", m_Q); register_output("QQ", m_QQ); - m_Q.initial(0); - m_QQ.initial(1); +} + +NETLIB_RESET(nicRSFF) +{ + m_Q.initial(0); + m_QQ.initial(1); } NETLIB_UPDATE(nicRSFF) diff --git a/src/emu/netlist/devices/nld_log.c b/src/emu/netlist/devices/nld_log.c index 837923154ab..ae925043d79 100644 --- a/src/emu/netlist/devices/nld_log.c +++ b/src/emu/netlist/devices/nld_log.c @@ -16,6 +16,10 @@ NETLIB_START(log) m_file = fopen(filename, "w"); } +NETLIB_RESET(log) +{ +} + NETLIB_UPDATE(log) { fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I)); @@ -32,6 +36,10 @@ NETLIB_START(logD) register_input("I2", m_I2); } +NETLIB_RESET(logD) +{ +} + NETLIB_UPDATE(logD) { fprintf(m_file, "%e %e\n", netlist().time().as_double(), INPANALOG(m_I) - INPANALOG(m_I2)); diff --git a/src/emu/netlist/devices/nld_ne555.c b/src/emu/netlist/devices/nld_ne555.c index 4eb20c75980..0829739b42b 100644 --- a/src/emu/netlist/devices/nld_ne555.c +++ b/src/emu/netlist/devices/nld_ne555.c @@ -37,20 +37,28 @@ NETLIB_START(NE555) 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); - 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; - save(NAME(m_last_out)); } +NETLIB_RESET(NE555) +{ + m_R1.do_reset(); + m_R2.do_reset(); + m_R3.do_reset(); + m_RDIS.do_reset(); + + m_R1.set_R(5000); + m_R2.set_R(5000); + m_R3.set_R(5000); + m_RDIS.set_R(R_OFF); + + m_last_out = false; +} + NETLIB_UPDATE(NE555) { // FIXME: assumes GND is connected to 0V. diff --git a/src/emu/netlist/devices/nld_signal.h b/src/emu/netlist/devices/nld_signal.h index 3b0742eef6c..4cc790c2025 100644 --- a/src/emu/netlist/devices/nld_signal.h +++ b/src/emu/netlist/devices/nld_signal.h @@ -42,10 +42,15 @@ public: { register_input(sIN[i], m_i[i], netlist_input_t::STATE_INP_ACTIVE); } - m_Q.initial(1); save(NAME(m_active)); } + ATTR_COLD void reset() + { + m_Q.initial(1); + m_active = 1; + } + #if (USE_DEACTIVE_DEVICE) ATTR_HOT void inc_active() { @@ -79,7 +84,6 @@ public: net_signal_t() : netlist_device_t(), m_active(1) { - m_Q.initial(1); } ATTR_COLD void start() @@ -94,6 +98,12 @@ public: save(NAME(m_active)); } + ATTR_COLD void reset() + { + m_Q.initial(1); + m_active = 1; + } + #if (USE_DEACTIVE_DEVICE) ATTR_HOT void inc_active() { @@ -151,7 +161,6 @@ public: xx_net_signal_t() : netlist_device_t(), m_active(1) { - m_Q.initial(1); } ATTR_COLD void start() @@ -166,6 +175,12 @@ public: save(NAME(m_active)); } + ATTR_COLD void reset() + { + m_Q.initial(1); + m_active = 1; + } + #if (USE_DEACTIVE_DEVICE) ATTR_HOT void inc_active() { diff --git a/src/emu/netlist/devices/nld_system.c b/src/emu/netlist/devices/nld_system.c index cc2e47b9249..cde61ef1527 100644 --- a/src/emu/netlist/devices/nld_system.c +++ b/src/emu/netlist/devices/nld_system.c @@ -16,6 +16,10 @@ NETLIB_START(ttl_const) register_param("CONST", m_const, 0); } +NETLIB_RESET(ttl_const) +{ +} + NETLIB_UPDATE(ttl_const) { OUTLOGIC(m_Q, m_const.Value(), NLTIME_IMMEDIATE); @@ -32,6 +36,10 @@ NETLIB_START(analog_const) register_param("CONST", m_const, 0.0); } +NETLIB_RESET(analog_const) +{ +} + NETLIB_UPDATE(analog_const) { OUTANALOG(m_Q, m_const.Value(), NLTIME_IMMEDIATE); @@ -59,6 +67,10 @@ NETLIB_START(clock) } +NETLIB_RESET(clock) +{ +} + NETLIB_UPDATE_PARAM(clock) { m_inc = netlist_time::from_hz(m_freq.Value()*2); @@ -79,6 +91,10 @@ NETLIB_START(logic_input) register_param("OUT", m_OUT, 0); } +NETLIB_RESET(logic_input) +{ +} + NETLIB_UPDATE(logic_input) { OUTLOGIC(m_Q, m_OUT.Value() & 1, NLTIME_IMMEDIATE); @@ -99,6 +115,10 @@ NETLIB_START(analog_input) register_param("OUT", m_OUT, 0.0); } +NETLIB_RESET(analog_input) +{ +} + NETLIB_UPDATE(analog_input) { OUTANALOG(m_Q, m_OUT.Value(), NLTIME_IMMEDIATE); diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c index 5345c15b593..c738bc10fce 100644 --- a/src/emu/netlist/nl_base.c +++ b/src/emu/netlist/nl_base.c @@ -167,12 +167,24 @@ ATTR_COLD void netlist_base_t::set_solver_dev(NETLIB_NAME(solver) *dev) ATTR_COLD void netlist_base_t::reset() { + printf("in reset\n"); m_time_ps = netlist_time::zero; m_queue.clear(); if (m_mainclock != NULL) m_mainclock->m_Q.net().set_time(netlist_time::zero); if (m_solver != NULL) - m_solver->reset(); + m_solver->do_reset(); + + // Reset all nets once ! + for (int i = 0; i < m_nets.count(); i++) + m_nets[i]->reset(); + + // Reset 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->do_reset(); + } // Step all devices once ! for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) @@ -427,7 +439,8 @@ template ATTR_COLD void netlist_device_t::register_param(const pstring &sname, n 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_solver(NULL) + , m_head(NULL) , m_num_cons(0) , m_time(netlist_time::zero) , m_active(0) @@ -439,6 +452,19 @@ ATTR_COLD netlist_net_t::netlist_net_t(const type_t atype, const family_t afamil m_cur.Analog = 0.0; }; +ATTR_COLD void netlist_net_t::reset() +{ + m_last.Analog = -123456789.0; // set to something we will never hit. + m_new.Analog = 0.0; + m_cur.Analog = 0.0; + m_last.Q = 0; // set to something we will never hit. + m_new.Q = 0; + m_cur.Q = 0; + m_time = netlist_time::zero; + //m_active = 0; // FIXME + m_in_queue = 2; +} + ATTR_COLD void netlist_net_t::init_object(netlist_base_t &nl, const pstring &aname) { netlist_object_t::init_object(nl, aname); @@ -752,6 +778,11 @@ NETLIB_START(mainclock) m_inc = netlist_time::from_hz(m_freq.Value()*2); } +NETLIB_RESET(mainclock) +{ + m_Q.net().set_time(netlist_time::zero); +} + NETLIB_UPDATE_PARAM(mainclock) { m_inc = netlist_time::from_hz(m_freq.Value()*2); diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h index 2e8579d767c..eed6b0143d8 100644 --- a/src/emu/netlist/nl_base.h +++ b/src/emu/netlist/nl_base.h @@ -182,6 +182,8 @@ typedef void (*net_update_delegate)(netlist_core_device_t *); //#define NETLIB_CONSTRUCTOR(_chip) ATTR_COLD _chip :: _chip (netlist_setup_t &setup, const char *name) // : net_device_t(setup, name) +#define NETLIB_RESET(_chip) ATTR_COLD void NETLIB_NAME(_chip) :: reset(void) + #define NETLIB_UPDATE_PARAM(_chip) ATTR_HOT ATTR_ALIGN void NETLIB_NAME(_chip) :: update_param(void) #define NETLIB_FUNC_VOID(_chip, _name, _params) ATTR_HOT ATTR_ALIGN void NETLIB_NAME(_chip) :: _name _params @@ -198,6 +200,7 @@ typedef void (*net_update_delegate)(netlist_core_device_t *); _extra \ ATTR_HOT void update(); \ ATTR_HOT void start(); \ + ATTR_HOT void reset(); \ _priv \ } @@ -217,6 +220,7 @@ typedef void (*net_update_delegate)(netlist_core_device_t *); /*protected:*/ \ ATTR_HOT void update(); \ ATTR_HOT void start(); \ + ATTR_HOT void reset(); \ public: \ _priv \ } @@ -532,6 +536,7 @@ public: 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 reset(); ATTR_COLD void register_con(netlist_core_terminal_t &terminal); ATTR_COLD void merge_net(netlist_net_t *othernet); @@ -910,10 +915,16 @@ public: net_update_delegate static_update; #endif + ATTR_COLD void inline do_reset() + { + reset(); + } + protected: ATTR_HOT virtual void update() { } ATTR_COLD virtual void start() { } + ATTR_COLD virtual void reset() = 0; private: }; @@ -1085,9 +1096,13 @@ protected: { register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE); register_output("Q", m_Q); - m_Q.initial(1); } + ATTR_COLD void reset() + { + m_Q.initial(1); + } + ATTR_HOT ATTR_ALIGN void update() { if (m_I.Q_Analog() > m_I.m_high_thresh_V) @@ -1125,9 +1140,13 @@ protected: { register_input("I", m_I, netlist_terminal_t::STATE_INP_ACTIVE); register_output("Q", m_Q); - m_Q.initial(0); } + ATTR_COLD void reset() + { + m_Q.initial(0); + } + ATTR_HOT ATTR_ALIGN void update() { OUTANALOG(m_Q, INPLOGIC(m_I) ? m_high_V : m_low_V, NLTIME_FROM_NS(1)); |
