Previous 199869 Revisions Next

r26784 Friday 27th December, 2013 at 18:14:07 UTC by Couriersud
Alignment of netlist with MAME standards. Inputs to netlist are now registered using by MCFG_* as mame subdevices and exhibit the usual writeXX/readXX methods including a PORT_CHANGED method. This allows direct linking to inputs. [Couriersud]
[src/emu/machine]netlist.c netlist.h
[src/emu/netlist]nl_base.c nl_base.h nl_config.h nl_lists.h nl_setup.c pstate.c pstate.h pstring.c
[src/emu/netlist/devices]nld_74107.c nld_74107.h nld_74153.c nld_74153.h nld_9316.c nld_system.c nld_system.h nld_twoterm.c nld_twoterm.h
[src/mame/drivers]pong.c
[src/tools]nltool.c

trunk/src/mame/drivers/pong.c
r26783r26784
370370   // ----------------------------------------------------------------------------------------
371371
372372   NETDEV_POT(ic_b9_POT, RES_K(1))     // This is a guess!!
373   NETDEV_PARAM(ic_b9_POT.DIALLOG, 1)  // Log Dial ...
373374   NETDEV_R(ic_b9_RPRE, 470)
374375
375376   NET_C(ic_b9_POT.1, V5)
r26783r26784
377378   NET_C(ic_b9_POT.2, ic_b9_RPRE.1)
378379   NET_C(ic_b9_RPRE.2, ic_b9.CONT)
379380
380   NETDEV_R(ic_b9_R, RES_K(71))
381   NETDEV_R(ic_b9_R, RES_K(81))        // Adjustment pot
381382   NETDEV_C(ic_b9_C, CAP_U(.1))
382383   NETDEV_D(ic_b9_D, 1N914)
383384   NETDEV_NE555(ic_b9)
r26783r26784
409410   // ----------------------------------------------------------------------------------------
410411
411412   NETDEV_POT(ic_a9_POT, RES_K(1))     // This is a guess!!
413    NETDEV_PARAM(ic_a9_POT.DIALLOG, 1)  // Log Dial ...
412414   NETDEV_R(ic_a9_RPRE, 470)
413415
414416   NET_C(ic_a9_POT.1, V5)
r26783r26784
416418   NET_C(ic_a9_POT.2, ic_a9_RPRE.1)
417419   NET_C(ic_a9_RPRE.2, ic_a9.CONT)
418420
419   NETDEV_R(ic_a9_R, RES_K(71))
421   NETDEV_R(ic_a9_R, RES_K(81))        // Adjustment pot
420422   NETDEV_C(ic_a9_C, CAP_U(.1))
421423   NETDEV_D(ic_a9_D, 1N914)
422424   NETDEV_NE555(ic_a9)
r26783r26784
792794         m_video(*this, "fixfreq"),
793795
794796         m_dac(*this, "dac"),                /* just to have a sound device */
795         m_srst(*this, "maincpu", "SRST"),
796         m_p_P0(*this, "maincpu", "ic_b9_POT.DIAL"),
797         m_p_P1(*this, "maincpu", "ic_a9_POT.DIAL"),
798         m_sw1a(*this, "maincpu", "sw1a.POS"),
799         m_sw1b(*this, "maincpu", "sw1b.POS"),
800         m_p_R0(*this, "maincpu", "ic_a9_R.R"),
801         m_p_R1(*this, "maincpu", "ic_b9_R.R")
797         m_sw1a(*this, "maincpu:sw1a"),
798         m_sw1b(*this, "maincpu:sw1b")
802799   {
803800   }
804801
805802   // devices
806   required_device<netlist_mame_device> m_maincpu;
803   required_device<netlist_mame_device_t> m_maincpu;
807804   required_device<fixedfreq_device> m_video;
808805   required_device<dac_device> m_dac; /* just to have a sound device */
809806
810807   // sub devices
811   netlist_mame_device::required_output<netlist_logic_output_t> m_srst;
812   netlist_mame_device::required_param<netlist_param_double_t> m_p_P0;
813   netlist_mame_device::required_param<netlist_param_double_t> m_p_P1;
814   netlist_mame_device::required_param<netlist_param_int_t> m_sw1a;
815   netlist_mame_device::required_param<netlist_param_int_t> m_sw1b;
816   netlist_mame_device::required_param<netlist_param_double_t> m_p_R0;
817   netlist_mame_device::required_param<netlist_param_double_t> m_p_R1;
808   required_device<netlist_mame_logic_input_t> m_sw1a;
809   required_device<netlist_mame_logic_input_t> m_sw1b;
818810
819811   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
820812
r26783r26784
827819      m_dac->write_unsigned8(64*data);
828820   }
829821
830   NETDEV_ANALOG_CALLBACK_MEMBER(video_cb)
831   {
832      m_video->update_vid(data, time);
833      //printf("%20.15f\n", newval);
834   }
835
836822protected:
837823
838824   // driver_device overrides
r26783r26784
851837   NETLIST_MEMREGION("maincpu")
852838
853839   NETDEV_ANALOG_CALLBACK(sound_cb, sound, pong_state, sound_cb, "")
854   NETDEV_ANALOG_CALLBACK(video_cb, videomix, pong_state, video_cb, "")
840   NETDEV_ANALOG_CALLBACK(video_cb, videomix, fixedfreq_device, update_vid, "fixfreq")
855841NETLIST_END
856842
857843static NETLIST_START(pong_fast)
r26783r26784
859845   NETLIST_INCLUDE(pong_schematics)
860846
861847   NETDEV_ANALOG_CALLBACK(sound_cb, sound, pong_state, sound_cb, "")
862   NETDEV_ANALOG_CALLBACK(video_cb, videomix, pong_state, video_cb, "")
848    NETDEV_ANALOG_CALLBACK(video_cb, videomix, fixedfreq_device, update_vid, "fixfreq")
863849
864850NETLIST_END
865851
r26783r26784
879865
880866INPUT_CHANGED_MEMBER(pong_state::input_changed)
881867{
882   double pad;
883868   int numpad = (FPTR) (param);
884869
885870   switch (numpad)
886871   {
887   case IC_PADDLE1:
888   case IC_PADDLE2:
889   {
890      // http://ion.chem.usu.edu/~sbialkow/Classes/564/Thevenin/Thevenin.html
891
892      double fac = (double) newval / (double) 256;
893      fac = (exp(fac) - 1.0) / (exp(1.0) -1.0) ;
894      switch (numpad)
895      {
896      case IC_PADDLE1:    m_p_P0->setTo(fac); break;
897      case IC_PADDLE2:    m_p_P1->setTo(fac); break;
898      }
899      break;
900   }
901872   case IC_SWITCH:
902      m_sw1a->setTo(newval ? 1 : 0);
903      m_sw1b->setTo(newval ? 1 : 0);
873      m_sw1a->write(newval ? 1 : 0);
874      m_sw1b->write(newval ? 1 : 0);
904875      break;
905   case IC_COIN:
906      m_srst->set_Q(newval & 1, NLTIME_FROM_US(500));
907      break;
908   case IC_VR1:
909   case IC_VR2:
910      pad = (double) newval / (double) 100 * RES_K(50) + RES_K(56);
911      switch (numpad)
912      {
913      case IC_VR1:    m_p_R0->setTo(pad); break;
914      case IC_VR2:    m_p_R1->setTo(pad); break;
915      }
916      break;
917876   }
918
919
920877}
921878
922879static INPUT_PORTS_START( pong )
923880   PORT_START( "PADDLE0" ) /* fake input port for player 1 paddle */
924   PORT_BIT( 0xff, 0x00, IPT_PADDLE ) PORT_SENSITIVITY(2) PORT_KEYDELTA(100) PORT_CENTERDELTA(0)   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed,IC_PADDLE1)
881    PORT_BIT( 0xff, 0x00, IPT_PADDLE ) PORT_SENSITIVITY(2) PORT_KEYDELTA(100) PORT_CENTERDELTA(0)   NETLIST_ANALOG_PORT_CHANGED("maincpu", "pot0")
925882
926883   PORT_START( "PADDLE1" ) /* fake input port for player 2 paddle */
927   PORT_BIT( 0xff, 0x00, IPT_PADDLE ) PORT_SENSITIVITY(2) PORT_KEYDELTA(100) PORT_CENTERDELTA(0) PORT_PLAYER(2) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_PADDLE2)
884    PORT_BIT( 0xff, 0x00, IPT_PADDLE ) PORT_SENSITIVITY(2) PORT_KEYDELTA(100) PORT_CENTERDELTA(0) PORT_PLAYER(2) NETLIST_ANALOG_PORT_CHANGED("maincpu", "pot1")
928885
929886   PORT_START("IN0") /* fake as well */
930   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )     PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_COIN)
887   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )     NETLIST_LOGIC_PORT_CHANGED("maincpu", "srst")
931888   PORT_DIPNAME( 0x06, 0x00, "Game Won" )          PORT_DIPLOCATION("SW1A:1,SW1B:1") PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_SWITCH)
932889   PORT_DIPSETTING(    0x00, "11" )
933890   PORT_DIPSETTING(    0x06, "15" )
934891
935892   PORT_START("VR1")
936   PORT_ADJUSTER( 50, "VR1 - 50k, Paddle 1 adjustment" )   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1)
893   PORT_ADJUSTER( 50, "VR1 - 50k, Paddle 1 adjustment" )   NETLIST_ANALOG_PORT_CHANGED("maincpu", "vr0")
937894   PORT_START("VR2")
938   PORT_ADJUSTER( 50, "VR2 - 50k, Paddle 2 adjustment" )   PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2)
895   PORT_ADJUSTER( 50, "VR2 - 50k, Paddle 2 adjustment" )   NETLIST_ANALOG_PORT_CHANGED("maincpu", "vr1")
939896   //PORT_START("GATESPEED")
940897   //PORT_ADJUSTER( 100, "Logic Gate Delay" ) PORT_MINMAX(10, 200) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_GATEDELAY)
941898
r26783r26784
945902
946903   /* basic machine hardware */
947904   MCFG_NETLIST_ADD("maincpu", pong)
905    MCFG_NETLIST_ANALOG_INPUT("maincpu", "vr0", "ic_b9_R.R")
906    MCFG_NETLIST_ANALOG_INPUT_MULT_OFFSET(1.0 / 100.0 * RES_K(50), RES_K(56) )
907    MCFG_NETLIST_ANALOG_INPUT("maincpu", "vr1", "ic_a9_R.R")
908    MCFG_NETLIST_ANALOG_INPUT_MULT_OFFSET(1.0 / 100.0 * RES_K(50), RES_K(56) )
909    MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot0", "ic_b9_POT.DIAL")
910    MCFG_NETLIST_ANALOG_INPUT("maincpu", "pot1", "ic_a9_POT.DIAL")
911    MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1a", "sw1a.POS", 0, 0x01)
912    MCFG_NETLIST_LOGIC_INPUT("maincpu", "sw1b", "sw1b.POS", 0, 0x01)
913    MCFG_NETLIST_LOGIC_INPUT("maincpu", "srst", "SRST.OUT", 0, 0x01)
948914
949915   /* video hardware */
950916
r26783r26784
962928static MACHINE_CONFIG_DERIVED( pongf, pong )
963929
964930   /* basic machine hardware */
965   MCFG_NETLIST_REPLACE("maincpu", pong_fast)
931    MCFG_DEVICE_MODIFY("maincpu")
932   MCFG_NETLIST_SETUP(pong_fast)
966933
967934MACHINE_CONFIG_END
968935
trunk/src/tools/nltool.c
r26783r26784
110110
111111   virtual ~netlist_tool_t() { };
112112
113   void read_netlist(const char *buffer)
114   {
115      m_setup = new netlist_setup_t(*this);
116      this->set_clock_freq(NETLIST_CLOCK);
113    void read_netlist(const char *buffer)
114    {
115        m_setup = new netlist_setup_t(*this);
116        this->init_object(*this, "netlist");
117        m_setup->init();
117118
118      // register additional devices
119      //m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback");
119        this->set_clock_freq(NETLIST_CLOCK);
120120
121121      // read the netlist ...
122122      //m_setup_func(*m_setup);
trunk/src/emu/machine/netlist.c
r26783r26784
5454//#define LOG_DEV_CALLS(x)   printf x
5555#define LOG_DEV_CALLS(x)   do { } while (0)
5656
57const device_type NETLIST = &device_creator<netlist_mame_device_t>;
58const device_type NETLIST_ANALOG_INPUT = &device_creator<netlist_mame_analog_input_t>;
59const device_type NETLIST_LOGIC_INPUT = &device_creator<netlist_mame_logic_input_t>;
60
61netlist_mame_analog_input_t::netlist_mame_analog_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
62      : device_t(mconfig, NETLIST_ANALOG_INPUT, "netlist analog input", tag, owner, clock, "netlist_analog_input", __FILE__),
63         netlist_mame_sub_interface(*this),
64         m_offset(0.0),
65         m_mult(1.0),
66         m_auto_port(true),
67         m_param_name("")
68{
69}
70
71void netlist_mame_analog_input_t::static_set_name(device_t &device, const char *param_name)
72{
73   netlist_mame_analog_input_t &netlist = downcast<netlist_mame_analog_input_t &>(device);
74   netlist.m_param_name = param_name;
75}
76
77void netlist_mame_analog_input_t::static_set_mult_offset(device_t &device, const double mult, const double offset)
78{
79   netlist_mame_analog_input_t &netlist = downcast<netlist_mame_analog_input_t &>(device);
80   netlist.m_mult = mult;
81   netlist.m_offset = offset;
82   // disable automatic scaling for ioports
83   netlist.m_auto_port = false;
84}
85
86void netlist_mame_analog_input_t::device_start()
87{
88   LOG_DEV_CALLS(("start %s\n", tag()));
89   netlist_param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
90   m_param = dynamic_cast<netlist_param_double_t *>(p);
91   if (m_param == NULL)
92   {
93      fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
94   }
95}
96
97netlist_mame_logic_input_t::netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
98      : device_t(mconfig, NETLIST_ANALOG_INPUT, "netlist analog input", tag, owner, clock, "netlist_analog_input", __FILE__),
99         netlist_mame_sub_interface(*this),
100         m_mask(0xffffffff),
101         m_shift(0),
102         m_param_name("")
103{
104}
105
106void netlist_mame_logic_input_t::static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift)
107{
108   netlist_mame_logic_input_t &netlist = downcast<netlist_mame_logic_input_t &>(device);
109   netlist.m_param_name = param_name;
110   netlist.m_shift = shift;
111   netlist.m_mask = mask;
112}
113
114void netlist_mame_logic_input_t::device_start()
115{
116   LOG_DEV_CALLS(("start %s\n", tag()));
117   netlist_param_t *p = downcast<netlist_mame_device_t *>(this->owner())->setup().find_param(m_param_name);
118   m_param = dynamic_cast<netlist_param_int_t *>(p);
119   if (m_param == NULL)
120   {
121      fatalerror("device %s wrong parameter type for %s\n", basetag(), m_param_name.cstr());
122   }
123}
124
125
57126// ----------------------------------------------------------------------------------------
58127// netlist_mame_device
59128// ----------------------------------------------------------------------------------------
60129
61const device_type NETLIST = &device_creator<netlist_mame_device>;
62
63static ADDRESS_MAP_START(program_dummy, AS_PROGRAM, 8, netlist_mame_device)
64    AM_RANGE(0x000, 0x3ff) AM_ROM
130static ADDRESS_MAP_START(program_dummy, AS_PROGRAM, 8, netlist_mame_device_t)
131   AM_RANGE(0x000, 0x3ff) AM_ROM
65132ADDRESS_MAP_END
66133
67netlist_mame_device::netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
134netlist_mame_device_t::netlist_mame_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
68135   : device_t(mconfig, NETLIST, "netlist", tag, owner, clock, "netlist_mame", __FILE__),
69136      device_execute_interface(mconfig, *this),
70        device_state_interface(mconfig, *this),
71        device_disasm_interface(mconfig, *this),
72        device_memory_interface(mconfig, *this),
73      m_device_start_list(100),
74        m_program_config("program", ENDIANNESS_LITTLE, 8, 12, 0, ADDRESS_MAP_NAME(program_dummy)),
137      device_state_interface(mconfig, *this),
138      device_disasm_interface(mconfig, *this),
139      device_memory_interface(mconfig, *this),
140      m_program_config("program", ENDIANNESS_LITTLE, 8, 12, 0, ADDRESS_MAP_NAME(program_dummy)),
75141      m_netlist(NULL),
76142      m_setup(NULL),
77143      m_setup_func(NULL),
r26783r26784
80146{
81147}
82148
83void netlist_mame_device::static_set_constructor(device_t &device, void (*setup_func)(netlist_setup_t &))
149void netlist_mame_device_t::static_set_constructor(device_t &device, void (*setup_func)(netlist_setup_t &))
84150{
85   netlist_mame_device &netlist = downcast<netlist_mame_device &>(device);
151   LOG_DEV_CALLS(("static_set_constructor\n"));
152   netlist_mame_device_t &netlist = downcast<netlist_mame_device_t &>(device);
86153   netlist.m_setup_func = setup_func;
87   LOG_DEV_CALLS(("static_set_constructor\n"));
88154}
89155
90void netlist_mame_device::device_config_complete()
156void netlist_mame_device_t::device_config_complete()
91157{
92158   LOG_DEV_CALLS(("device_config_complete\n"));
93159}
94160
95void netlist_mame_device::device_start()
161void netlist_mame_device_t::device_start()
96162{
97   LOG_DEV_CALLS(("device_start\n"));
163   LOG_DEV_CALLS(("device_start %s\n", tag()));
98164
99165   m_netlist = global_alloc_clear(netlist_mame_t(*this));
100166   m_setup = global_alloc_clear(netlist_setup_t(*m_netlist));
r26783r26784
109175
110176   m_setup_func(*m_setup);
111177
178   /* let sub-devices tweak the netlist */
179   for( device_t *d = this->first_subdevice(); d != NULL; d = d->next() )
180   {
181      netlist_mame_sub_interface *sdev = dynamic_cast<netlist_mame_sub_interface *>(d);
182      if( sdev != NULL )
183      {
184         LOG_DEV_CALLS(("Found subdevice %s/%s\n", d->name(), d->shortname()));
185         sdev->custom_netlist_additions(*m_netlist);
186      }
187   }
188
112189   m_setup->start_devices();
113190   m_setup->resolve_inputs();
114191
115   bool allok = true;
116   for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods))
117      allok &= ods->object()->OnDeviceStart();
118
119   if (!allok)
120      m_netlist->xfatalerror("required elements not found\n");
121
122192   save_state();
123193
124194   // State support
125195
126    state_add(STATE_GENPC, "curpc", m_genPC).noshow();
196   state_add(STATE_GENPC, "curpc", m_genPC).noshow();
127197
128    for (int i=0; i < m_netlist->m_nets.count(); i++)
129    {
130        netlist_net_t *n = m_netlist->m_nets[i];
131        if (n->isRailNet())
132        {
133            state_add(i*2, n->name(), n->m_cur.Q);
134        }
135        else
136        {
137            state_add(i*2+1, n->name(), n->m_cur.Analog).formatstr("%20s");
138        }
139    }
198   for (int i=0; i < m_netlist->m_nets.count(); i++)
199   {
200      netlist_net_t *n = m_netlist->m_nets[i];
201      if (n->isRailNet())
202      {
203         state_add(i*2, n->name(), n->m_cur.Q);
204      }
205      else
206      {
207         state_add(i*2+1, n->name(), n->m_cur.Analog).formatstr("%20s");
208      }
209   }
140210
141211   // set our instruction counter
142212   m_icountptr = &m_icount;
143213}
144214
145void netlist_mame_device::device_reset()
215void netlist_mame_device_t::device_reset()
146216{
147217   LOG_DEV_CALLS(("device_reset\n"));
148218   m_netlist->reset();
149219}
150220
151void netlist_mame_device::device_stop()
221void netlist_mame_device_t::device_stop()
152222{
153223   LOG_DEV_CALLS(("device_stop\n"));
154224   m_setup->print_stats();
r26783r26784
159229   m_netlist = NULL;
160230}
161231
162ATTR_COLD void netlist_mame_device::device_post_load()
232ATTR_COLD void netlist_mame_device_t::device_post_load()
163233{
164    LOG_DEV_CALLS(("device_post_load\n"));
234   LOG_DEV_CALLS(("device_post_load\n"));
165235
166    m_netlist->post_load();
236   m_netlist->post_load();
167237}
168238
169ATTR_COLD void netlist_mame_device::device_pre_save()
239ATTR_COLD void netlist_mame_device_t::device_pre_save()
170240{
171241   LOG_DEV_CALLS(("device_pre_save\n"));
172242
173243   m_netlist->pre_save();
174244}
175245
176void netlist_mame_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
246void netlist_mame_device_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
177247{
178248}
179249
180250
181251
182ATTR_COLD void netlist_mame_device::save_state()
252ATTR_COLD void netlist_mame_device_t::save_state()
183253{
184    for (pstate_entry_t::list_t::entry_t *p = m_netlist->save_list().first(); p != NULL; p = m_netlist->save_list().next(p))
185    {
186        pstate_entry_t *s = p->object();
187        NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr()));
188        switch (s->m_dt)
189        {
190            case DT_DOUBLE:
191                save_pointer((double *) s->m_ptr, s->m_name, s->m_count);
192                break;
193            case DT_INT64:
194                save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count);
195                break;
196            case DT_INT8:
197                save_pointer((INT8 *) s->m_ptr, s->m_name, s->m_count);
198                break;
199            case DT_INT:
200                save_pointer((int *) s->m_ptr, s->m_name, s->m_count);
201                break;
202            case DT_BOOLEAN:
203                save_pointer((bool *) s->m_ptr, s->m_name, s->m_count);
204                break;
205            case DT_CUSTOM:
206            case NOT_SUPPORTED:
207            default:
208                m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr());
209                break;
210        }
211    }
254   for (pstate_entry_t::list_t::entry_t *p = m_netlist->save_list().first(); p != NULL; p = m_netlist->save_list().next(p))
255   {
256      pstate_entry_t *s = p->object();
257      NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr()));
258      switch (s->m_dt)
259      {
260         case DT_DOUBLE:
261            save_pointer((double *) s->m_ptr, s->m_name, s->m_count);
262            break;
263         case DT_INT64:
264            save_pointer((INT64 *) s->m_ptr, s->m_name, s->m_count);
265            break;
266         case DT_INT8:
267            save_pointer((INT8 *) s->m_ptr, s->m_name, s->m_count);
268            break;
269         case DT_INT:
270            save_pointer((int *) s->m_ptr, s->m_name, s->m_count);
271            break;
272         case DT_BOOLEAN:
273            save_pointer((bool *) s->m_ptr, s->m_name, s->m_count);
274            break;
275         case DT_CUSTOM:
276         case NOT_SUPPORTED:
277         default:
278            m_netlist->xfatalerror("found unsupported save element %s\n", s->m_name.cstr());
279            break;
280      }
281   }
212282
213283}
214284
215ATTR_COLD UINT64 netlist_mame_device::execute_clocks_to_cycles(UINT64 clocks) const
285ATTR_COLD UINT64 netlist_mame_device_t::execute_clocks_to_cycles(UINT64 clocks) const
216286{
217287   return clocks;
218288}
219289
220ATTR_COLD UINT64 netlist_mame_device::execute_cycles_to_clocks(UINT64 cycles) const
290ATTR_COLD UINT64 netlist_mame_device_t::execute_cycles_to_clocks(UINT64 cycles) const
221291{
222292   return cycles;
223293}
224294
225ATTR_COLD offs_t netlist_mame_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
295ATTR_COLD offs_t netlist_mame_device_t::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
226296{
227    //char tmp[16];
228    unsigned startpc = pc;
229    int relpc = pc - m_genPC;
230    //UINT16 opcode = (oprom[pc - startpc] << 8) | oprom[pc+1 - startpc];
231    //UINT8 inst = opcode >> 13;
297   //char tmp[16];
298   unsigned startpc = pc;
299   int relpc = pc - m_genPC;
300   //UINT16 opcode = (oprom[pc - startpc] << 8) | oprom[pc+1 - startpc];
301   //UINT8 inst = opcode >> 13;
232302
233    if (relpc >= 0 && relpc < m_netlist->queue().count())
234    {
235        //            sprintf(buffer, "%04x %02d %s", pc, relpc, m_netlist->queue()[m_netlist->queue().count() - relpc - 1].object().name().cstr());
236        int dpc = m_netlist->queue().count() - relpc - 1;
237        sprintf(buffer, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', m_netlist->queue()[dpc].object().name().cstr(),
238                m_netlist->queue()[dpc].time().as_double());
239    }
240    else
241        sprintf(buffer, "%s", "");
242    pc+=1;
243    return (pc - startpc);
303   if (relpc >= 0 && relpc < m_netlist->queue().count())
304   {
305      //            sprintf(buffer, "%04x %02d %s", pc, relpc, m_netlist->queue()[m_netlist->queue().count() - relpc - 1].object().name().cstr());
306      int dpc = m_netlist->queue().count() - relpc - 1;
307      sprintf(buffer, "%c %s @%10.7f", (relpc == 0) ? '*' : ' ', m_netlist->queue()[dpc].object().name().cstr(),
308            m_netlist->queue()[dpc].time().as_double());
309   }
310   else
311      sprintf(buffer, "%s", "");
312   pc+=1;
313   return (pc - startpc);
244314}
245315
246ATTR_HOT void netlist_mame_device::execute_run()
316ATTR_HOT void netlist_mame_device_t::execute_run()
247317{
248318   bool check_debugger = ((device_t::machine().debug_flags & DEBUG_FLAG_ENABLED) != 0);
249319   // debugging
250320   //m_ppc = m_pc; // copy PC to previous PC
251321   if (check_debugger)
252322   {
253       while (m_icount > 0)
254       {
255           int m_temp = 1;
256            m_genPC++;
257            m_genPC &= 255;
258           debugger_instruction_hook(this, m_genPC);
259           m_netlist->process_queue(m_temp);
260           m_icount -= (1 - m_temp);
261       }
323      while (m_icount > 0)
324      {
325         int m_temp = 1;
326         m_genPC++;
327         m_genPC &= 255;
328         debugger_instruction_hook(this, m_genPC);
329         m_netlist->process_queue(m_temp);
330         m_icount -= (1 - m_temp);
331      }
262332   }
263333   else
264       m_netlist->process_queue(m_icount);
334      m_netlist->process_queue(m_icount);
265335}
266
trunk/src/emu/machine/netlist.h
r26783r26784
5959#define MCFG_NETLIST_ADD(_tag, _setup )                                             \
6060   MCFG_DEVICE_ADD(_tag, NETLIST, NETLIST_CLOCK)                                   \
6161   MCFG_NETLIST_SETUP(_setup)
62
6263#define MCFG_NETLIST_REPLACE(_tag, _setup)                                          \
6364   MCFG_DEVICE_REPLACE(_tag, NETLIST, NETLIST_CLOCK)                               \
6465   MCFG_NETLIST_SETUP(_setup)
66
6567#define MCFG_NETLIST_SETUP(_setup)                                                  \
66   netlist_mame_device::static_set_constructor(*device, NETLIST_NAME(_setup));
68   netlist_mame_device_t::static_set_constructor(*device, NETLIST_NAME(_setup));
6769
70#define MCFG_NETLIST_ANALOG_INPUT(_basetag, _tag, _name)                            \
71   MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_ANALOG_INPUT, 0)                     \
72   netlist_mame_analog_input_t::static_set_name(*device, _name);
73
74#define MCFG_NETLIST_ANALOG_INPUT_MULT_OFFSET(_mult, _offset)                       \
75   netlist_mame_analog_input_t::static_set_mult_offset(*device, _mult, _offset);
76
77#define NETLIST_ANALOG_PORT_CHANGED(_base, _tag)                                    \
78   PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_analog_input_t, input_changed, 0)
79
80#define MCFG_NETLIST_LOGIC_INPUT(_basetag, _tag, _name, _shift, _mask)              \
81   MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_LOGIC_INPUT, 0)                      \
82   netlist_mame_logic_input_t::static_set_params(*device, _name, _mask, _shift);
83
84#define NETLIST_LOGIC_PORT_CHANGED(_base, _tag)                                     \
85   PORT_CHANGED_MEMBER(_base ":" _tag, netlist_mame_logic_input_t, input_changed, 0)
86
6887// ----------------------------------------------------------------------------------------
6988// Extensions to interface netlist with MAME code ....
7089// ----------------------------------------------------------------------------------------
r26783r26784
83102#define NETDEV_ANALOG_CALLBACK_MEMBER(_name) \
84103   void _name(const double data, const attotime &time)
85104
86class netlist_mame_device;
105class netlist_mame_device_t;
87106
88107class netlist_mame_t : public netlist_base_t
89108{
90109public:
91110
92   netlist_mame_t(netlist_mame_device &parent)
111   netlist_mame_t(netlist_mame_device_t &parent)
93112   : netlist_base_t(),
94113      m_parent(parent)
95114   {}
r26783r26784
97116
98117   inline running_machine &machine();
99118
100   netlist_mame_device &parent() { return m_parent; }
119   netlist_mame_device_t &parent() { return m_parent; }
101120
102121protected:
103122
r26783r26784
108127   }
109128
110129private:
111   netlist_mame_device &m_parent;
130   netlist_mame_device_t &m_parent;
112131};
113132
114133// ----------------------------------------------------------------------------------------
115// MAME glue classes
134// netlist_mame_device_t
116135// ----------------------------------------------------------------------------------------
117136
118
119
120
121// ======================> netlist_mame_device
122
123class netlist_mame_device : public device_t,
124                      public device_execute_interface,
125                          public device_state_interface,
126                          public device_disasm_interface,
127                      public device_memory_interface
137class netlist_mame_device_t : public device_t,
138                        public device_execute_interface,
139                        public device_state_interface,
140                        public device_disasm_interface,
141                        public device_memory_interface
128142{
129143public:
130144
131   template<bool _Required, class _NETClass>
132   class output_finder;
133   template<class C>
134   class optional_output;
135   template<class C>
136   class required_output;
137   template<class C>
138   class optional_param;
139   template<class C>
140   class required_param;
141   class on_device_start;
142
143145   // construction/destruction
144   netlist_mame_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
145   virtual ~netlist_mame_device() {}
146   netlist_mame_device_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
147   virtual ~netlist_mame_device_t() {}
146148
147149   static void static_set_constructor(device_t &device, void (*setup_func)(netlist_setup_t &));
148150
149151   netlist_setup_t &setup() { return *m_setup; }
150152   netlist_mame_t &netlist() { return *m_netlist; }
151153
152   typedef netlist_list_t<on_device_start *> device_start_list_t;
153
154   device_start_list_t m_device_start_list;
155
156154protected:
157155   // device-level overrides
158156   virtual void device_config_complete();
r26783r26784
167165
168166   ATTR_HOT virtual void execute_run();
169167
170    // device_disasm_interface overrides
171    ATTR_COLD virtual UINT32 disasm_min_opcode_bytes() const { return 1; }
172    ATTR_COLD virtual UINT32 disasm_max_opcode_bytes() const { return 1; }
173    ATTR_COLD virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
168   // device_disasm_interface overrides
169   ATTR_COLD virtual UINT32 disasm_min_opcode_bytes() const { return 1; }
170   ATTR_COLD virtual UINT32 disasm_max_opcode_bytes() const { return 1; }
171   ATTR_COLD virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
174172
175    // device_memory_interface overrides
173   // device_memory_interface overrides
176174
177    address_space_config m_program_config;
175   address_space_config m_program_config;
178176
179    virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const
180    {
181        switch (spacenum)
182        {
183            case AS_PROGRAM: return &m_program_config;
184            case AS_IO:      return NULL;
185            default:         return NULL;
186        }
187    }
177   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const
178   {
179      switch (spacenum)
180      {
181         case AS_PROGRAM: return &m_program_config;
182         case AS_IO:      return NULL;
183         default:         return NULL;
184      }
185   }
188186
189    virtual void state_string_export(const device_state_entry &entry, astring &string)
190    {
191        if (entry.index() >= 0)
192        {
193            if (entry.index() & 1)
194                string.format("%10.6f", *((double *) entry.dataptr()));
195            else
196                string.format("%d", *((netlist_sig_t *) entry.dataptr()));
197        }
198    }
187   virtual void state_string_export(const device_state_entry &entry, astring &string)
188   {
189      if (entry.index() >= 0)
190      {
191         if (entry.index() & 1)
192            string.format("%10.6f", *((double *) entry.dataptr()));
193         else
194            string.format("%d", *((netlist_sig_t *) entry.dataptr()));
195      }
196   }
199197
200198
201199   netlist_mame_t *m_netlist;
r26783r26784
208206   void (*m_setup_func)(netlist_setup_t &);
209207
210208   int m_icount;
211    int m_genPC;
209   int m_genPC;
212210
213
214
215211};
216212
217213inline running_machine &netlist_mame_t::machine()
r26783r26784
220216}
221217
222218// ----------------------------------------------------------------------------------------
219// netlist_mame_sub_interface
220// ----------------------------------------------------------------------------------------
221
222class netlist_mame_sub_interface
223{
224public:
225   // construction/destruction
226   netlist_mame_sub_interface(netlist_mame_device_t &obj) : m_object(obj) {}
227   virtual ~netlist_mame_sub_interface() { }
228
229   virtual void custom_netlist_additions(netlist_base_t &netlist) { }
230
231   inline netlist_mame_device_t &object() { return m_object; }
232private:
233   netlist_mame_device_t &m_object;
234};
235
236// ----------------------------------------------------------------------------------------
237// netlist_mame_analog_input_t
238// ----------------------------------------------------------------------------------------
239
240class netlist_mame_analog_input_t : public device_t,
241                           public netlist_mame_sub_interface
242{
243public:
244
245   // construction/destruction
246   netlist_mame_analog_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
247   virtual ~netlist_mame_analog_input_t() { }
248
249   static void static_set_name(device_t &device, const char *param_name);
250   static void static_set_mult_offset(device_t &device, const double mult, const double offset);
251
252   inline void write(const double val) { m_param->setTo(val * m_mult + m_offset); }
253
254   inline DECLARE_INPUT_CHANGED_MEMBER(input_changed)
255   {
256      if (m_auto_port)
257         write(((double) newval - (double) field.minval())/((double) (field.maxval()-field.minval()) ) );
258      else
259         write(newval);
260   }
261   inline DECLARE_WRITE_LINE_MEMBER(write_line)       { write(state);  }
262   inline DECLARE_WRITE8_MEMBER(write8)               { write(data);   }
263   inline DECLARE_WRITE16_MEMBER(write16)             { write(data);   }
264   inline DECLARE_WRITE32_MEMBER(write32)             { write(data);   }
265   inline DECLARE_WRITE64_MEMBER(write64)             { write(data);   }
266
267protected:
268   // device-level overrides
269   virtual void device_start();
270
271private:
272   netlist_param_double_t *m_param;
273   double m_offset;
274   double m_mult;
275   bool   m_auto_port;
276   pstring m_param_name;
277};
278
279// ----------------------------------------------------------------------------------------
280// netlist_mame_logic_input_t
281// ----------------------------------------------------------------------------------------
282
283class netlist_mame_logic_input_t :  public device_t,
284                           public netlist_mame_sub_interface
285{
286public:
287
288   // construction/destruction
289   netlist_mame_logic_input_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
290   virtual ~netlist_mame_logic_input_t() { }
291
292   static void static_set_params(device_t &device, const char *param_name, const UINT32 mask, const UINT32 shift);
293
294   inline void write(const UINT32 val) { m_param->setTo((val >> m_shift) & m_mask); }
295
296   inline DECLARE_INPUT_CHANGED_MEMBER(input_changed) { write(newval); }
297   DECLARE_WRITE_LINE_MEMBER(write_line)       { write(state);  }
298   DECLARE_WRITE8_MEMBER(write8)               { write(data);   }
299   DECLARE_WRITE16_MEMBER(write16)             { write(data);   }
300   DECLARE_WRITE32_MEMBER(write32)             { write(data);   }
301   DECLARE_WRITE64_MEMBER(write64)             { write(data);   }
302
303protected:
304   // device-level overrides
305   virtual void device_start();
306
307private:
308   netlist_param_int_t *m_param;
309   UINT32 m_mask;
310   UINT32 m_shift;
311   pstring m_param_name;
312};
313
314// ----------------------------------------------------------------------------------------
223315// netdev_callback
224316// ----------------------------------------------------------------------------------------
225317
r26783r26784
300392};
301393
302394
303// ======================> netlist_output_finder
304
305class netlist_mame_device::on_device_start
306{
307public:
308   virtual bool OnDeviceStart() = 0;
309   virtual ~on_device_start() {}
310};
311
312// device finder template
313template<bool _Required, class _NETClass>
314class netlist_mame_device::output_finder : public object_finder_base<_NETClass>,
315      netlist_mame_device::on_device_start
316{
317public:
318   // construction/destruction
319   output_finder(device_t &base, const char *tag, const char *output)
320      : object_finder_base<_NETClass>(base, tag), m_netlist(NULL), m_output(output) { }
321
322   // finder
323   virtual bool findit(bool isvalidation = false)
324   {
325      if (isvalidation) return true;
326      device_t *device = this->m_base.subdevice(this->m_tag);
327      m_netlist = dynamic_cast<netlist_mame_device *>(device);
328      if (device != NULL && m_netlist == NULL)
329      {
330         void mame_printf_warning(const char *format, ...) ATTR_PRINTF(1,2);
331         mame_printf_warning("Device '%s' found but is not netlist\n", this->m_tag);
332      }
333      m_netlist->m_device_start_list.add(this);
334      return this->report_missing(m_netlist != NULL, "device", _Required);
335   }
336
337protected:
338   netlist_mame_device *m_netlist;
339   const char *m_output;
340};
341
342// optional device finder
343template<class C>
344class netlist_mame_device::optional_output : public netlist_mame_device::output_finder<false, C>
345{
346public:
347   optional_output(device_t &base, const char *tag, const char *output) : output_finder<false, C>(base, tag, output) { }
348
349   virtual ~optional_output() {};
350
351   virtual bool OnDeviceStart()
352   {
353      this->m_target = dynamic_cast<C *>(this->m_netlist->setup().find_terminal(this->m_output, netlist_object_t::OUTPUT, false));
354      return this->report_missing(this->m_target != NULL, "output", false);
355   }
356
357};
358
359// required devices are similar but throw an error if they are not found
360template<class C>
361class netlist_mame_device::required_output : public netlist_mame_device::output_finder<true, C>
362{
363public:
364   required_output(device_t &base, const char *tag, const char *output) : output_finder<true, C>(base, tag, output) { }
365
366   virtual ~required_output() {};
367
368   virtual bool OnDeviceStart()
369   {
370      this->m_target = dynamic_cast<C *>(this->m_netlist->setup().find_terminal(this->m_output, netlist_object_t::OUTPUT));
371      return this->report_missing(this->m_target != NULL, "output", true);
372   }
373
374};
375
376// optional device finder
377template<class C>
378class netlist_mame_device::optional_param : public netlist_mame_device::output_finder<false, C>
379{
380public:
381   optional_param(device_t &base, const char *tag, const char *output) : output_finder<false, C>(base, tag, output) { }
382
383   virtual bool OnDeviceStart()
384   {
385      this->m_target = dynamic_cast<C *>(this->m_netlist->setup().find_param(this->m_output, false));
386      return this->report_missing(this->m_target != NULL, "parameter", false);
387   }
388
389};
390
391// required devices are similar but throw an error if they are not found
392template<class C>
393class netlist_mame_device::required_param : public netlist_mame_device::output_finder<true, C>
394{
395public:
396   required_param(device_t &base, const char *tag, const char *output) : output_finder<true, C>(base, tag, output) { }
397
398   virtual bool OnDeviceStart()
399   {
400      this->m_target = dynamic_cast<C *>( this->m_netlist->setup().find_param(this->m_output));
401      return this->report_missing(this->m_target != NULL, "parameter", true);
402   }
403};
404
405
406395// device type definition
407396extern const device_type NETLIST;
397extern const device_type NETLIST_ANALOG_INPUT;
398extern const device_type NETLIST_LOGIC_INPUT;
408399
409400#endif
trunk/src/emu/netlist/pstring.c
r26783r26784
2424//#define DEBUG_MODE      (0)
2525
2626#ifdef MAME_DEBUG
27    #ifndef IMMEDIATE_MODE
28        #define IMMEDIATE_MODE  (1)
29    #endif
30    #ifndef DEBUG_MODE
31        #define DEBUG_MODE      (0)
32    #endif
27   #ifndef IMMEDIATE_MODE
28      #define IMMEDIATE_MODE  (1)
29   #endif
30   #ifndef DEBUG_MODE
31      #define DEBUG_MODE      (0)
32   #endif
3333#else
3434   #ifndef IMMEDIATE_MODE
3535      #define IMMEDIATE_MODE  (1)
trunk/src/emu/netlist/nl_setup.c
r26783r26784
1111#include "nl_util.h"
1212#include "devices/nld_system.h"
1313#include "devices/nld_solver.h"
14#include "devices/nld_twoterm.h"
1415
1516static NETLIST_START(base)
1617   NETDEV_TTL_CONST(ttlhigh, 1)
r26783r26784
521522
522523void netlist_setup_t::resolve_inputs()
523524{
525    bool has_twoterms = false;
526
524527   NL_VERBOSE_OUT(("Resolving ...\n"));
525528   for (tagmap_link_t::entry_t *entry = m_links.first(); entry != NULL; entry = m_links.next(entry))
526529   {
r26783r26784
540543         //VERBOSE_OUT(("%s %d\n", out->netdev()->name(), *out->Q_ptr()));
541544   }
542545
543#if 0
544546   NL_VERBOSE_OUT(("deleting empty nets ...\n"));
545547
546548   // delete empty nets ...
r26783r26784
556558         pn--;
557559      }
558560   }
559#endif
560   if (m_netlist.solver() != NULL)
561
562    /* now that nets were deleted ... register all net items */
563    NL_VERBOSE_OUT(("late state saving for nets ...\n"));
564
565    for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
566        pn->object()->late_save_register();
567
568    NL_VERBOSE_OUT(("looking for terminals not connected ...\n"));
569    for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry))
570    {
571        if (!entry->object()->has_net())
572            netlist().xfatalerror("Found terminal %s without a net\n",
573                    entry->object()->name().cstr());
574    }
575
576
577    NL_VERBOSE_OUT(("looking for two terms connected to rail nets ...\n"));
578    for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry))
579    {
580        NETLIB_NAME(twoterm) *t = dynamic_cast<NETLIB_NAME(twoterm) *>(entry->object());
581        if (t != NULL)
582        {
583            has_twoterms = true;
584            if (t->m_N.net().isRailNet() && t->m_P.net().isRailNet())
585                netlist().xfatalerror("Found device %s connected only to railterminals %s/%s\n",
586                        t->name().cstr(), t->m_N.net().name().cstr(), t->m_P.net().name().cstr());
587        }
588    }
589
590    NL_VERBOSE_OUT(("initialize solver ...\n"));
591
592   if (m_netlist.solver() == NULL)
593   {
594       if (!has_twoterms)
595           netlist().xfatalerror("No solver found for this net although analog elements are present\n");
596   }
597   else
561598      m_netlist.solver()->post_start();
562599
563
564600}
565601
566602void netlist_setup_t::start_devices()
r26783r26784
581617
582618
583619   NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n"));
584   /* find the main clock ... */
620
621   /* find the main clock and solver ... */
622   bool has_mainclock = false;
623    bool has_solver = false;
624
585625   for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry))
586626   {
587627      netlist_device_t *dev = entry->object();
588628      if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL)
589629      {
630          if (has_mainclock)
631              m_netlist.xfatalerror("Found more than one mainclock");
590632         m_netlist.set_mainclock_dev(dynamic_cast<NETLIB_NAME(mainclock)*>(dev));
633         has_mainclock = true;
591634      }
592635      if (dynamic_cast<NETLIB_NAME(solver)*>(dev) != NULL)
593636      {
637          if (has_solver)
638                m_netlist.xfatalerror("Found more than one solver");
594639         m_netlist.set_solver_dev(dynamic_cast<NETLIB_NAME(solver)*>(dev));
640         has_solver = true;
595641      }
596642   }
597643
trunk/src/emu/netlist/nl_lists.h
r26783r26784
209209
210210   ATTR_COLD entry_t *listptr() { return &m_list[0]; }
211211   ATTR_COLD int count() const { return m_end - m_list; }
212    ATTR_HOT inline entry_t & operator[](const int & index) { return m_list[index]; }
212   ATTR_HOT inline entry_t & operator[](const int & index) { return m_list[index]; }
213213
214214#if (NL_KEEP_STATISTICS)
215215   // profiling
trunk/src/emu/netlist/pstate.c
r26783r26784
3232
3333ATTR_COLD void pstate_manager_t::pre_save()
3434{
35    for (int i=0; i < m_callback.count(); i++)
36        m_callback[i]->on_pre_save();
35   for (int i=0; i < m_callback.count(); i++)
36      m_callback[i]->on_pre_save();
3737}
3838
3939ATTR_COLD void pstate_manager_t::post_load()
4040{
41    for (int i=0; i < m_callback.count(); i++)
42        m_callback[i]->on_post_load();
41   for (int i=0; i < m_callback.count(); i++)
42      m_callback[i]->on_post_load();
4343}
trunk/src/emu/netlist/devices/nld_74107.c
r26783r26784
77
88NETLIB_START(nic74107Asub)
99{
10    register_input("CLK", m_clk, netlist_input_t::STATE_INP_HL);
11    register_output("Q", m_Q);
12    register_output("QQ", m_QQ);
10   register_input("CLK", m_clk, netlist_input_t::STATE_INP_HL);
11   register_output("Q", m_Q);
12   register_output("QQ", m_QQ);
1313
14    m_Q.initial(0);
15    m_QQ.initial(1);
14   m_Q.initial(0);
15   m_QQ.initial(1);
1616
17    m_Q1 = 0;
18    m_Q2 = 0;
19    m_F = 0;
17   m_Q1 = 0;
18   m_Q2 = 0;
19   m_F = 0;
2020
21    save(NAME(m_Q1));
22    save(NAME(m_Q2));
23    save(NAME(m_F));
21   save(NAME(m_Q1));
22   save(NAME(m_Q2));
23   save(NAME(m_F));
2424}
2525
2626NETLIB_START(nic74107A)
2727{
28    register_sub(sub, "sub");
28   register_sub(sub, "sub");
2929
30    register_subalias("CLK", sub.m_clk);
31    register_input("J", m_J);
32    register_input("K", m_K);
33    register_input("CLRQ", m_clrQ);
34    register_subalias("Q", sub.m_Q);
35    register_subalias("QQ", sub.m_QQ);
30   register_subalias("CLK", sub.m_clk);
31   register_input("J", m_J);
32   register_input("K", m_K);
33   register_input("CLRQ", m_clrQ);
34   register_subalias("Q", sub.m_Q);
35   register_subalias("QQ", sub.m_QQ);
3636
3737}
3838
3939ATTR_HOT inline void NETLIB_NAME(nic74107Asub)::newstate(const netlist_sig_t state)
4040{
41    const netlist_time delay[2] = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) };
41   const netlist_time delay[2] = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) };
4242
43    OUTLOGIC(m_Q, state, delay[state ^ 1]);
44    OUTLOGIC(m_QQ, state ^ 1, delay[state]);
43   OUTLOGIC(m_Q, state, delay[state ^ 1]);
44   OUTLOGIC(m_QQ, state ^ 1, delay[state]);
4545}
4646
4747NETLIB_UPDATE(nic74107Asub)
4848{
49    const netlist_sig_t t = m_Q.net().Q();
50    newstate((!t & m_Q1) | (t & m_Q2) | m_F);
51    if (!m_Q1)
52        m_clk.inactivate();
49   const netlist_sig_t t = m_Q.net().Q();
50   newstate((!t & m_Q1) | (t & m_Q2) | m_F);
51   if (!m_Q1)
52      m_clk.inactivate();
5353}
5454
5555NETLIB_UPDATE(nic74107A)
5656{
57    const UINT8 JK = (INPLOGIC(m_J) << 1) | INPLOGIC(m_K);
57   const UINT8 JK = (INPLOGIC(m_J) << 1) | INPLOGIC(m_K);
5858
59    switch (JK)
60    {
61        case 0:
62            sub.m_Q1 = 0;
63            sub.m_Q2 = 1;
64            sub.m_F  = 0;
65            sub.m_clk.inactivate();
66            break;
67        case 1:             // (!INPLOGIC(m_J) & INPLOGIC(m_K))
68            sub.m_Q1 = 0;
69            sub.m_Q2 = 0;
70            sub.m_F  = 0;
71            break;
72        case 2:             // (INPLOGIC(m_J) & !INPLOGIC(m_K))
73            sub.m_Q1 = 0;
74            sub.m_Q2 = 0;
75            sub.m_F  = 1;
76            break;
77        case 3:             // (INPLOGIC(m_J) & INPLOGIC(m_K))
78            sub.m_Q1 = 1;
79            sub.m_Q2 = 0;
80            sub.m_F  = 0;
81            break;
82        default:
83            break;
84    }
59   switch (JK)
60   {
61      case 0:
62         sub.m_Q1 = 0;
63         sub.m_Q2 = 1;
64         sub.m_F  = 0;
65         sub.m_clk.inactivate();
66         break;
67      case 1:             // (!INPLOGIC(m_J) & INPLOGIC(m_K))
68         sub.m_Q1 = 0;
69         sub.m_Q2 = 0;
70         sub.m_F  = 0;
71         break;
72      case 2:             // (INPLOGIC(m_J) & !INPLOGIC(m_K))
73         sub.m_Q1 = 0;
74         sub.m_Q2 = 0;
75         sub.m_F  = 1;
76         break;
77      case 3:             // (INPLOGIC(m_J) & INPLOGIC(m_K))
78         sub.m_Q1 = 1;
79         sub.m_Q2 = 0;
80         sub.m_F  = 0;
81         break;
82      default:
83         break;
84   }
8585
86    if (!INPLOGIC(m_clrQ))
87    {
88        sub.m_clk.inactivate();
89        sub.newstate(0);
90    }
91    else if (!sub.m_Q2)
92        sub.m_clk.activate_hl();
86   if (!INPLOGIC(m_clrQ))
87   {
88      sub.m_clk.inactivate();
89      sub.newstate(0);
90   }
91   else if (!sub.m_Q2)
92      sub.m_clk.activate_hl();
9393}
trunk/src/emu/netlist/devices/nld_system.c
r26783r26784
7373NETLIB_START(logic_input)
7474{
7575   register_output("Q", m_Q);
76   register_param("OUT", m_OUT, 0);
7677}
7778
7879NETLIB_UPDATE(logic_input)
7980{
8081}
8182
83NETLIB_UPDATE_PARAM(logic_input)
84{
85   OUTLOGIC(m_Q, m_OUT.Value() & 1, NLTIME_IMMEDIATE);
86}
87
8288// ----------------------------------------------------------------------------------------
8389// analog_input
8490// ----------------------------------------------------------------------------------------
trunk/src/emu/netlist/devices/nld_74107.h
r26783r26784
6262#include "../nl_base.h"
6363
6464#define TTL_74107A(_name, _CLK, _J, _K, _CLRQ)                                      \
65        NET_REGISTER_DEV(nic74107A, _name)                                          \
66        NET_CONNECT(_name, CLK, _CLK)                                               \
67        NET_CONNECT(_name, J,  _J)                                                  \
68        NET_CONNECT(_name, K,  _K)                                                  \
69        NET_CONNECT(_name, CLRQ,  _CLRQ)
65      NET_REGISTER_DEV(nic74107A, _name)                                          \
66      NET_CONNECT(_name, CLK, _CLK)                                               \
67      NET_CONNECT(_name, J,  _J)                                                  \
68      NET_CONNECT(_name, K,  _K)                                                  \
69      NET_CONNECT(_name, CLRQ,  _CLRQ)
7070
7171#define TTL_74107(_name, _CLK, _J, _K, _CLRQ)                                       \
72        TTL_74107A(_name, _CLK, _J, _K, _CLRQ)
72      TTL_74107A(_name, _CLK, _J, _K, _CLRQ)
7373
7474NETLIB_SUBDEVICE(nic74107Asub,
75    netlist_ttl_input_t m_clk;
75   netlist_ttl_input_t m_clk;
7676
77    netlist_ttl_output_t m_Q;
78    netlist_ttl_output_t m_QQ;
77   netlist_ttl_output_t m_Q;
78   netlist_ttl_output_t m_QQ;
7979
80    netlist_sig_t m_Q1;
81    netlist_sig_t m_Q2;
82    netlist_sig_t m_F;
80   netlist_sig_t m_Q1;
81   netlist_sig_t m_Q2;
82   netlist_sig_t m_F;
8383
84    ATTR_HOT void newstate(const netlist_sig_t state);
84   ATTR_HOT void newstate(const netlist_sig_t state);
8585
8686);
8787
8888NETLIB_DEVICE(nic74107A,
89    NETLIB_NAME(nic74107Asub) sub;
89   NETLIB_NAME(nic74107Asub) sub;
9090
91    netlist_ttl_input_t m_J;
92    netlist_ttl_input_t m_K;
93    netlist_ttl_input_t m_clrQ;
91   netlist_ttl_input_t m_J;
92   netlist_ttl_input_t m_K;
93   netlist_ttl_input_t m_clrQ;
9494
9595);
9696
9797class NETLIB_NAME(nic74107) : public NETLIB_NAME(nic74107A)
9898{
9999public:
100    NETLIB_NAME(nic74107) ()
101    :   NETLIB_NAME(nic74107A) () {}
100   NETLIB_NAME(nic74107) ()
101   :   NETLIB_NAME(nic74107A) () {}
102102
103103};
104104
trunk/src/emu/netlist/devices/nld_system.h
r26783r26784
8181// Special support devices ...
8282// ----------------------------------------------------------------------------------------
8383
84NETLIB_DEVICE(logic_input,
84NETLIB_DEVICE_WITH_PARAMS(logic_input,
8585   netlist_ttl_output_t m_Q;
86
87   netlist_param_logic_t m_OUT;
8688);
8789
8890NETLIB_DEVICE(analog_input,
trunk/src/emu/netlist/devices/nld_9316.c
r26783r26784
9898   OUTLOGIC(sub.m_RC, sub.m_ent & (sub.m_cnt == 0x0f), NLTIME_FROM_NS(20));
9999}
100100
101inline NETLIB_FUNC_VOID(9316_sub, update_outputs_all, (const UINT8 cnt))
101NETLIB_FUNC_VOID(9316_sub, update_outputs_all, (const UINT8 cnt))
102102{
103103   const netlist_time out_delay = NLTIME_FROM_NS(20);
104104   OUTLOGIC(m_QA, (cnt >> 0) & 1, out_delay);
r26783r26784
107107   OUTLOGIC(m_QD, (cnt >> 3) & 1, out_delay);
108108}
109109
110inline NETLIB_FUNC_VOID(9316_sub, update_outputs, (const UINT8 cnt))
110NETLIB_FUNC_VOID(9316_sub, update_outputs, (const UINT8 cnt))
111111{
112112   const netlist_time out_delay = NLTIME_FROM_NS(20);
113113#if 0
trunk/src/emu/netlist/devices/nld_74153.c
r26783r26784
77
88NETLIB_START(nic74153)
99{
10    register_input("C0", m_C[0]);
11    register_input("C1", m_C[1]);
12    register_input("C2", m_C[2]);
13    register_input("C3", m_C[3]);
14    register_input("A", m_A);
15    register_input("B", m_B);
16    register_input("G", m_G);
10   register_input("C0", m_C[0]);
11   register_input("C1", m_C[1]);
12   register_input("C2", m_C[2]);
13   register_input("C3", m_C[3]);
14   register_input("A", m_A);
15   register_input("B", m_B);
16   register_input("G", m_G);
1717
18    register_output("AY", m_Y); //FIXME: Change netlists
18   register_output("AY", m_Y); //FIXME: Change netlists
1919}
2020
2121/* FIXME: timing is not 100% accurate, Strobe and Select inputs have a
r26783r26784
2525
2626NETLIB_UPDATE(nic74153)
2727{
28    const netlist_time delay[2] = { NLTIME_FROM_NS(23), NLTIME_FROM_NS(18) };
29    if (!INPLOGIC(m_G))
30    {
31        UINT8 chan = (INPLOGIC(m_A) | (INPLOGIC(m_B)<<1));
32        UINT8 t = INPLOGIC(m_C[chan]);
33        OUTLOGIC(m_Y, t, delay[t] );
34    }
35    else
36    {
37        OUTLOGIC(m_Y, 0, delay[0]);
38    }
28   const netlist_time delay[2] = { NLTIME_FROM_NS(23), NLTIME_FROM_NS(18) };
29   if (!INPLOGIC(m_G))
30   {
31      UINT8 chan = (INPLOGIC(m_A) | (INPLOGIC(m_B)<<1));
32      UINT8 t = INPLOGIC(m_C[chan]);
33      OUTLOGIC(m_Y, t, delay[t] );
34   }
35   else
36   {
37      OUTLOGIC(m_Y, 0, delay[0]);
38   }
3939}
40
41
trunk/src/emu/netlist/devices/nld_74153.h
r26783r26784
4848#include "../nl_base.h"
4949
5050#define TTL_74153(_name, _C0, _C1, _C2, _C3, _A, _B, _G)                            \
51        NET_REGISTER_DEV(nic74153, _name)                                           \
52        NET_CONNECT(_name, C0, _C0)                                                 \
53        NET_CONNECT(_name, C1, _C1)                                                 \
54        NET_CONNECT(_name, C2, _C2)                                                 \
55        NET_CONNECT(_name, C3, _C3)                                                 \
56        NET_CONNECT(_name, A, _A)                                                   \
57        NET_CONNECT(_name, B, _B)                                                   \
58        NET_CONNECT(_name, G, _G)
51      NET_REGISTER_DEV(nic74153, _name)                                           \
52      NET_CONNECT(_name, C0, _C0)                                                 \
53      NET_CONNECT(_name, C1, _C1)                                                 \
54      NET_CONNECT(_name, C2, _C2)                                                 \
55      NET_CONNECT(_name, C3, _C3)                                                 \
56      NET_CONNECT(_name, A, _A)                                                   \
57      NET_CONNECT(_name, B, _B)                                                   \
58      NET_CONNECT(_name, G, _G)
5959
6060NETLIB_DEVICE(nic74153,
61    netlist_ttl_input_t m_C[4];
62    netlist_ttl_input_t m_A;
63    netlist_ttl_input_t m_B;
64    netlist_ttl_input_t m_G;
61   netlist_ttl_input_t m_C[4];
62   netlist_ttl_input_t m_A;
63   netlist_ttl_input_t m_B;
64   netlist_ttl_input_t m_G;
6565
66    netlist_ttl_output_t m_Y;
66   netlist_ttl_output_t m_Y;
6767);
6868
6969#endif /* NLD_74153_H_ */
trunk/src/emu/netlist/devices/nld_twoterm.c
r26783r26784
5656
5757NETLIB_UPDATE_PARAM(R)
5858{
59   //printf("updating %s to %f\n", name().cstr(), m_R.Value());
5960   set_R(m_R.Value());
6061}
6162
r26783r26784
7677
7778   register_param("R", m_R, 1.0 / NETLIST_GMIN);
7879   register_param("DIAL", m_Dial, 0.5);
80   register_param("DIALLOG", m_DialIsLog, 0);
7981
8082}
8183
r26783r26784
8789
8890NETLIB_UPDATE_PARAM(POT)
8991{
90   m_R1.set_R(MAX(m_R.Value() * m_Dial.Value(), NETLIST_GMIN));
91   m_R2.set_R(MAX(m_R.Value() * (1.0 - m_Dial.Value()), NETLIST_GMIN));
92   double v = m_Dial.Value();
93   if (m_DialIsLog.Value())
94      v = (exp(v) - 1.0) / (exp(1.0) - 1.0);
95   m_R1.set_R(MAX(m_R.Value() * v, NETLIST_GMIN));
96   m_R2.set_R(MAX(m_R.Value() * (1.0 - v), NETLIST_GMIN));
9297}
9398// ----------------------------------------------------------------------------------------
9499// nld_C
trunk/src/emu/netlist/devices/nld_twoterm.h
r26783r26784
128128
129129   netlist_param_double_t m_R;
130130   netlist_param_double_t m_Dial;
131   netlist_param_logic_t m_DialIsLog;
131132);
132133
133134
r26783r26784
345346protected:
346347
347348   ATTR_COLD virtual void start();
348   ATTR_COLD void update_param();
349   ATTR_HOT void update_param();
349350
350351   double m_gB; // base conductance / switch on
351352   double m_gC; // collector conductance / switch on
trunk/src/emu/netlist/nl_config.h
r26783r26784
4747//  DEBUGGING
4848//============================================================
4949
50#define fatalerror xxbreakme
50//#define fatalerror xxbreakme
5151
5252#define NL_VERBOSE                  (0)
5353#define NL_KEEP_STATISTICS          (0)
trunk/src/emu/netlist/nl_base.c
r26783r26784
1515// ----------------------------------------------------------------------------------------
1616
1717netlist_queue_t::netlist_queue_t(netlist_base_t &nl)
18    : netlist_timed_queue<netlist_net_t, netlist_time, 512>(), pstate_callback_t(),
19      m_netlist(nl),
20      m_qsize(0)
18   : netlist_timed_queue<netlist_net_t, netlist_time, 512>(), pstate_callback_t(),
19      m_netlist(nl),
20      m_qsize(0)
2121{  }
2222
2323void netlist_queue_t::register_state(pstate_manager_t &manager, const pstring &module)
2424{
25    NL_VERBOSE_OUT(("register_state\n"));
26    manager.save_manager(m_qsize, module + "." + "qsize");
27    manager.save_manager(m_times, module + "." + "times");
28    manager.save_manager(&(m_name[0][0]), module + "." + "names", sizeof(m_name));
25   NL_VERBOSE_OUT(("register_state\n"));
26   manager.save_item(m_qsize, module + "." + "qsize");
27   manager.save_item(m_times, module + "." + "times");
28   manager.save_item(&(m_name[0][0]), module + "." + "names", sizeof(m_name));
2929}
3030void netlist_queue_t::on_pre_save()
3131{
32    NL_VERBOSE_OUT(("on_pre_save\n"));
33    m_qsize = this->count();
34    NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize));
35    for (int i = 0; i < m_qsize; i++ )
36    {
37        m_times[i] =  this->listptr()[i].time().as_raw();
38        const char *p = this->listptr()[i].object().name().cstr();
39        int n = MIN(63, strlen(p));
40        strncpy(&(m_name[i][0]), p, n);
41        m_name[i][n] = 0;
42    }
32   NL_VERBOSE_OUT(("on_pre_save\n"));
33   m_qsize = this->count();
34   NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize));
35   for (int i = 0; i < m_qsize; i++ )
36   {
37      m_times[i] =  this->listptr()[i].time().as_raw();
38      const char *p = this->listptr()[i].object().name().cstr();
39      int n = MIN(63, strlen(p));
40      strncpy(&(m_name[i][0]), p, n);
41      m_name[i][n] = 0;
42   }
4343}
4444
4545
4646void netlist_queue_t::on_post_load()
4747{
48    this->clear();
49    NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize));
50    for (int i = 0; i < m_qsize; i++ )
51    {
52        netlist_net_t *n = m_netlist.find_net(&(m_name[i][0]));
53        NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n));
54        NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double()));
55        this->push(netlist_queue_t::entry_t(netlist_time::from_raw(m_times[i]), *n));
56    }
48   this->clear();
49   NL_VERBOSE_OUT(("current time %f qsize %d\n", m_netlist->time().as_double(), qsize));
50   for (int i = 0; i < m_qsize; i++ )
51   {
52      netlist_net_t *n = m_netlist.find_net(&(m_name[i][0]));
53      NL_VERBOSE_OUT(("Got %s ==> %p\n", qtemp[i].m_name, n));
54      NL_VERBOSE_OUT(("schedule time %f (%f)\n", n->time().as_double(), qtemp[i].m_time.as_double()));
55      this->push(netlist_queue_t::entry_t(netlist_time::from_raw(m_times[i]), *n));
56   }
5757}
5858
5959// ----------------------------------------------------------------------------------------
r26783r26784
108108// ----------------------------------------------------------------------------------------
109109
110110netlist_base_t::netlist_base_t()
111    :   netlist_object_t(NETLIST, GENERIC),
112        m_time_ps(netlist_time::zero),
113        m_queue(*this),
114        m_rem(0),
115        m_div(NETLIST_DIV),
116        m_mainclock(NULL),
117        m_solver(NULL)
111   :   netlist_object_t(NETLIST, GENERIC),
112      m_time_ps(netlist_time::zero),
113      m_queue(*this),
114      m_rem(0),
115      m_div(NETLIST_DIV),
116      m_mainclock(NULL),
117      m_solver(NULL)
118118{
119119}
120120
r26783r26784
216216
217217ATTR_HOT ATTR_ALIGN void netlist_base_t::process_queue(INT32 &atime)
218218{
219    if (m_mainclock == NULL)
220    {
221        while ( (atime > 0) && (m_queue.is_not_empty()))
222        {
223            const netlist_queue_t::entry_t &e = m_queue.pop();
224            update_time(e.time(), atime);
219   if (m_mainclock == NULL)
220   {
221      while ( (atime > 0) && (m_queue.is_not_empty()))
222      {
223         const netlist_queue_t::entry_t &e = m_queue.pop();
224         update_time(e.time(), atime);
225225
226226         //if (FATAL_ERROR_AFTER_NS)
227227         //  NL_VERBOSE_OUT(("%s\n", e.object().netdev()->name().cstr());
r26783r26784
254254
255255               NETLIB_NAME(mainclock)::mc_update(mcQ, time() + inc);
256256
257                }
258                const netlist_queue_t::entry_t &e = m_queue.pop();
257            }
258            const netlist_queue_t::entry_t &e = m_queue.pop();
259259
260260            update_time(e.time(), atime);
261261
trunk/src/emu/netlist/pstate.h
r26783r26784
1616// ----------------------------------------------------------------------------------------
1717
1818#define PSTATE_INTERFACE_DECL()               \
19    template<typename C> ATTR_COLD void save(C &state, const pstring &stname);
19   template<typename C> ATTR_COLD void save(C &state, const pstring &stname);
2020
2121#define PSTATE_INTERFACE(obj, manager, module)               \
22    template<typename C> ATTR_COLD void obj::save(C &state, const pstring &stname) \
23    {                                                                       \
24        manager->save_manager(state, module + "." + stname);  \
25    }
22   template<typename C> ATTR_COLD void obj::save(C &state, const pstring &stname) \
23   {                                                                       \
24      manager->save_item(state, module + "." + stname);  \
25   }
2626
2727enum pstate_data_type_e {
28    NOT_SUPPORTED,
29    DT_CUSTOM,
30    DT_DOUBLE,
31    DT_INT64,
32    DT_INT8,
33    DT_INT,
34    DT_BOOLEAN
28   NOT_SUPPORTED,
29   DT_CUSTOM,
30   DT_DOUBLE,
31   DT_INT64,
32   DT_INT8,
33   DT_INT,
34   DT_BOOLEAN
3535};
3636
3737template<typename _ItemType> struct nl_datatype { static const pstate_data_type_e type = pstate_data_type_e(NOT_SUPPORTED); };
r26783r26784
5454{
5555   typedef netlist_list_t<pstate_entry_t *> list_t;
5656
57    pstate_entry_t(const pstring &stname, const pstate_data_type_e dt, const int size, const int count, void *ptr) :
58        m_name(stname), m_dt(dt), m_size(size), m_count(count), m_ptr(ptr) { }
59    pstring m_name;
60    pstate_data_type_e m_dt;
61    int m_size;
62    int m_count;
63    void *m_ptr;
57   pstate_entry_t(const pstring &stname, const pstate_data_type_e dt, const int size, const int count, void *ptr) :
58      m_name(stname), m_dt(dt), m_size(size), m_count(count), m_ptr(ptr) { }
59   pstring m_name;
60   pstate_data_type_e m_dt;
61   int m_size;
62   int m_count;
63   void *m_ptr;
6464};
6565
6666class pstate_manager_t;
r26783r26784
6868class pstate_callback_t
6969{
7070public:
71    typedef netlist_list_t<pstate_callback_t *> list_t;
71   typedef netlist_list_t<pstate_callback_t *> list_t;
7272
73    virtual ~pstate_callback_t() { };
73   virtual ~pstate_callback_t() { };
7474
75    virtual void register_state(pstate_manager_t &manager, const pstring &module) = 0;
76    virtual void on_pre_save() = 0;
77    virtual void on_post_load() = 0;
75   virtual void register_state(pstate_manager_t &manager, const pstring &module) = 0;
76   virtual void on_pre_save() = 0;
77   virtual void on_post_load() = 0;
7878protected:
7979};
8080
r26783r26784
8484
8585   ATTR_COLD ~pstate_manager_t();
8686
87    template<typename C> ATTR_COLD void save_manager(C &state, const pstring &stname)
88    {
89        save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), 1, &state);
90    }
87   template<typename C> ATTR_COLD void save_item(C &state, const pstring &stname)
88   {
89      save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), 1, &state);
90   }
9191
92    template<typename C, std::size_t N> ATTR_COLD void save_manager(C (&state)[N], const pstring &stname)
93    {
94        save_state_ptr(stname, nl_datatype<C>::type, sizeof(state[0]), N, &(state[0]));
95    }
92   template<typename C, std::size_t N> ATTR_COLD void save_item(C (&state)[N], const pstring &stname)
93   {
94      save_state_ptr(stname, nl_datatype<C>::type, sizeof(state[0]), N, &(state[0]));
95   }
9696
97    template<typename C> ATTR_COLD void save_manager(C *state, const pstring &stname, const int count)
98    {
99        save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), count, state);
100    }
97   template<typename C> ATTR_COLD void save_item(C *state, const pstring &stname, const int count)
98   {
99      save_state_ptr(stname, nl_datatype<C>::type, sizeof(C), count, state);
100   }
101101
102    ATTR_COLD void pre_save();
103    ATTR_COLD void post_load();
102   ATTR_COLD void pre_save();
103   ATTR_COLD void post_load();
104104
105105   inline const pstate_entry_t::list_t &save_list() const { return m_save; }
106106
107107protected:
108    ATTR_COLD void save_state_ptr(const pstring &stname, const pstate_data_type_e, const int size, const int count, void *ptr);
108   ATTR_COLD void save_state_ptr(const pstring &stname, const pstate_data_type_e, const int size, const int count, void *ptr);
109109
110110private:
111111   pstate_entry_t::list_t m_save;
112112   pstate_callback_t::list_t m_callback;
113113};
114114
115template<> ATTR_COLD inline void pstate_manager_t::save_manager(pstate_callback_t &state, const pstring &stname)
115template<> ATTR_COLD inline void pstate_manager_t::save_item(pstate_callback_t &state, const pstring &stname)
116116{
117    //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
118    m_callback.add(&state);
119    state.register_state(*this, stname);
117   //save_state_ptr(stname, DT_CUSTOM, 0, 1, &state);
118   m_callback.add(&state);
119   state.register_state(*this, stname);
120120}
121121
122template<> ATTR_COLD inline void pstate_manager_t::save_manager(netlist_time &nlt, const pstring &stname)
122template<> ATTR_COLD inline void pstate_manager_t::save_item(netlist_time &nlt, const pstring &stname)
123123{
124124   save_state_ptr(stname, DT_INT64, sizeof(netlist_time::INTERNALTYPE), 1, nlt.get_internaltype_ptr());
125125}
trunk/src/emu/netlist/nl_base.h
r26783r26784
185185//#define NETLIB_CONSTRUCTOR(_chip) ATTR_COLD _chip :: _chip (netlist_setup_t &setup, const char *name)
186186//          : net_device_t(setup, name)
187187
188#define NETLIB_UPDATE_PARAM(_chip) ATTR_COLD ATTR_ALIGN void NETLIB_NAME(_chip) :: update_param(void)
188#define NETLIB_UPDATE_PARAM(_chip) ATTR_HOT ATTR_ALIGN void NETLIB_NAME(_chip) :: update_param(void)
189189#define NETLIB_FUNC_VOID(_chip, _name, _params) ATTR_HOT ATTR_ALIGN void NETLIB_NAME(_chip) :: _name _params
190190
191191#define NETLIB_UPDATE_TERMINALS() ATTR_HOT ATTR_ALIGN inline void update_terminals(void)
r26783r26784
370370protected:
371371   ATTR_COLD virtual void save_register()
372372   {
373       save(NAME(m_state));
374       netlist_owned_object_t::save_register();
373      save(NAME(m_state));
374      netlist_owned_object_t::save_register();
375375   }
376376
377377private:
r26783r26784
462462class netlist_logic_input_t : public netlist_input_t
463463{
464464public:
465    ATTR_COLD netlist_logic_input_t()
465   ATTR_COLD netlist_logic_input_t()
466466      : netlist_input_t(INPUT, LOGIC)
467467   {
468468      // default to TTL
r26783r26784
487487class netlist_ttl_input_t : public netlist_logic_input_t
488488{
489489public:
490    ATTR_COLD netlist_ttl_input_t()
490   ATTR_COLD netlist_ttl_input_t()
491491      : netlist_logic_input_t() { set_thresholds(0.8 , 2.0); }
492492};
493493
r26783r26784
498498class netlist_analog_input_t : public netlist_input_t
499499{
500500public:
501    ATTR_COLD netlist_analog_input_t()
501   ATTR_COLD netlist_analog_input_t()
502502      : netlist_input_t(INPUT, ANALOG) { }
503503
504504   ATTR_HOT inline const double Q_Analog() const;
r26783r26784
596596   hybrid_t m_cur;
597597   hybrid_t m_new;
598598
599    /* use this to register state.... */
600    ATTR_COLD virtual void late_save_register()
601    {
602        save(NAME(m_last.Analog));
603        save(NAME(m_cur.Analog));
604        save(NAME(m_new.Analog));
605        save(NAME(m_last.Q));
606        save(NAME(m_cur.Q));
607        save(NAME(m_new.Q));
608        save(NAME(m_time));
609        save(NAME(m_active));
610        save(NAME(m_in_queue));
611        netlist_object_t::save_register();
612    }
613
599614protected:
600615   UINT32 m_num_cons;
601616
617   /* we don't use this to save state
618    * because we may get deleted again ...
619    */
602620   ATTR_COLD virtual void save_register()
603621   {
604      save(NAME(m_last.Analog));
605      save(NAME(m_cur.Analog));
606      save(NAME(m_new.Analog));
607      save(NAME(m_last.Q));
608      save(NAME(m_cur.Q));
609      save(NAME(m_new.Q));
610      save(NAME(m_time));
611      save(NAME(m_active));
612      save(NAME(m_in_queue));
613      netlist_object_t::save_register();
622       //assert_always(false, "trying too early to register state in netlist_net_t");
614623   }
615624
625
616626private:
617627   ATTR_HOT void update_dev(const netlist_core_terminal_t *inp, const UINT32 mask) const;
618628
r26783r26784
950960// ----------------------------------------------------------------------------------------
951961
952962class netlist_queue_t : public netlist_timed_queue<netlist_net_t, netlist_time, 512>,
953                        public pstate_callback_t
963                  public pstate_callback_t
954964{
955965public:
956966
957    netlist_queue_t(netlist_base_t &nl);
967   netlist_queue_t(netlist_base_t &nl);
958968
959    void register_state(pstate_manager_t &manager, const pstring &module);
960    void on_pre_save();
961    void on_post_load();
969   void register_state(pstate_manager_t &manager, const pstring &module);
970   void on_pre_save();
971   void on_post_load();
962972
963    pstate_callback_t &callback() { return *this; }
973   pstate_callback_t &callback() { return *this; }
964974
965975private:
966    netlist_base_t &m_netlist;
967    int m_qsize;
968    netlist_time::INTERNALTYPE m_times[512];
969    char m_name[512][64];
976   netlist_base_t &m_netlist;
977   int m_qsize;
978   netlist_time::INTERNALTYPE m_times[512];
979   char m_name[512][64];
970980};
971981
972982// ----------------------------------------------------------------------------------------
r26783r26784
984994   netlist_base_t();
985995   virtual ~netlist_base_t();
986996
987    ATTR_HOT inline const netlist_queue_t &queue() const { return m_queue; }
988    ATTR_HOT inline netlist_queue_t &queue() { return m_queue; }
997   ATTR_HOT inline const netlist_queue_t &queue() const { return m_queue; }
998   ATTR_HOT inline netlist_queue_t &queue() { return m_queue; }
989999
9901000   ATTR_HOT inline void push_to_queue(netlist_net_t &out, const netlist_time &attime)
9911001   {
r26783r26784
10201030   virtual void vfatalerror(const char *format, va_list ap) const = 0;
10211031
10221032protected:
1023    ATTR_COLD virtual void save_register()
1024    {
1025        save(NAME(m_queue.callback()));
1026        save(NAME(m_time_ps));
1027        save(NAME(m_rem));
1028        save(NAME(m_div));
1029        netlist_object_t::save_register();
1030    }
1033   ATTR_COLD virtual void save_register()
1034   {
1035      save(NAME(m_queue.callback()));
1036      save(NAME(m_time_ps));
1037      save(NAME(m_rem));
1038      save(NAME(m_div));
1039      netlist_object_t::save_register();
1040   }
10311041
10321042#if (NL_KEEP_STATISTICS)
10331043   // performance
r26783r26784
10391049private:
10401050   ATTR_HOT void update_time(const netlist_time t, INT32 &atime);
10411051
1042    netlist_time                m_time_ps;
1043    netlist_queue_t             m_queue;
1052   netlist_time                m_time_ps;
1053   netlist_queue_t             m_queue;
10441054   UINT32                      m_rem;
10451055   UINT32                      m_div;
10461056
r26783r26784
12981308{
12991309public:
13001310
1301    ATTR_COLD netlist_factory();
1302    ATTR_COLD ~netlist_factory();
1311   ATTR_COLD netlist_factory();
1312   ATTR_COLD ~netlist_factory();
13031313
1304    ATTR_COLD void initialize();
1314   ATTR_COLD void initialize();
13051315
1306    template<class _C>
1307    ATTR_COLD void register_device(const pstring &name, const pstring &classname)
1316   template<class _C>
1317   ATTR_COLD void register_device(const pstring &name, const pstring &classname)
13081318   {
13091319      m_list.add(new net_device_t_factory< _C >(name, classname) );
13101320   }
13111321
1312    ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
1313    ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
1322   ATTR_COLD netlist_device_t *new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const;
1323   ATTR_COLD netlist_device_t *new_device_by_name(const pstring &name, netlist_setup_t &setup) const;
13141324
13151325private:
13161326   typedef netlist_list_t<net_device_t_base_factory *> list_t;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team