trunk/src/mame/drivers/pong.c
| r26659 | r26660 | |
| 58 | 58 | fixedfreq_interface fixedfreq_mode_pong = { |
| 59 | 59 | MASTER_CLOCK, |
| 60 | 60 | H_TOTAL-67,H_TOTAL-40,H_TOTAL-8,H_TOTAL, |
| 61 | | V_TOTAL-22,V_TOTAL-19,V_TOTAL-16,V_TOTAL, |
| 62 | | 1, /* interlaced */ |
| 61 | V_TOTAL-22,V_TOTAL-19,V_TOTAL-12,V_TOTAL, |
| 62 | 1, /* non-interlaced */ |
| 63 | 63 | 0.32 |
| 64 | 64 | }; |
| 65 | 65 | |
| r26659 | r26660 | |
| 67 | 67 | MASTER_CLOCK * 2, |
| 68 | 68 | (H_TOTAL-67) * 2, (H_TOTAL-40) * 2, (H_TOTAL-8) * 2, (H_TOTAL) * 2, |
| 69 | 69 | V_TOTAL-22,V_TOTAL-19,V_TOTAL-16,V_TOTAL, |
| 70 | | 1, /* interlaced */ |
| 70 | 1, /* non-interlaced */ |
| 71 | 71 | 0.32 |
| 72 | 72 | }; |
| 73 | 73 | |
| r26659 | r26660 | |
| 933 | 933 | PORT_DIPSETTING( 0x06, "15" ) |
| 934 | 934 | |
| 935 | 935 | PORT_START("VR1") |
| 936 | | PORT_ADJUSTER( 63, "VR1 - 50k, Paddle 1 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1) |
| 936 | PORT_ADJUSTER( 50, "VR1 - 50k, Paddle 1 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR1) |
| 937 | 937 | PORT_START("VR2") |
| 938 | | PORT_ADJUSTER( 63, "VR2 - 50k, Paddle 2 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2) |
| 938 | PORT_ADJUSTER( 50, "VR2 - 50k, Paddle 2 adjustment" ) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_VR2) |
| 939 | 939 | //PORT_START("GATESPEED") |
| 940 | 940 | //PORT_ADJUSTER( 100, "Logic Gate Delay" ) PORT_MINMAX(10, 200) PORT_CHANGED_MEMBER(DEVICE_SELF, pong_state, input_changed, IC_GATEDELAY) |
| 941 | 941 | |
trunk/src/tools/nltool.c
| r0 | r26660 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | nltool.c |
| 4 | |
| 5 | Simple tool to debug netlists outside MAME. |
| 6 | |
| 7 | ****************************************************************************/ |
| 8 | |
| 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> |
| 11 | #include <string.h> |
| 12 | #include <ctype.h> |
| 13 | #include "astring.h" |
| 14 | #include "corefile.h" |
| 15 | #include "corestr.h" |
| 16 | #include "sha1.h" |
| 17 | #include "netlist/nl_base.h" |
| 18 | #include "netlist/nl_setup.h" |
| 19 | #include "options.h" |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | MAME COMPATIBILITY ... |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #if 0 |
| 26 | void mame_printf_warning(const char *format, ...) |
| 27 | { |
| 28 | va_list argptr; |
| 29 | |
| 30 | /* do the output */ |
| 31 | va_start(argptr, format); |
| 32 | vprintf(format, argptr); |
| 33 | va_end(argptr); |
| 34 | } |
| 35 | #endif |
| 36 | |
| 37 | void *malloc_file_line(size_t size, const char *file, int line) |
| 38 | { |
| 39 | // allocate the memory and fail if we can't |
| 40 | void *ret = osd_malloc(size); |
| 41 | memset(ret, 0, size); |
| 42 | return ret; |
| 43 | } |
| 44 | |
| 45 | void *malloc_array_file_line(size_t size, const char *file, int line) |
| 46 | { |
| 47 | // allocate the memory and fail if we can't |
| 48 | void *ret = osd_malloc_array(size); |
| 49 | memset(ret, 0, size); |
| 50 | return ret; |
| 51 | } |
| 52 | |
| 53 | void free_file_line( void *memory, const char *file, int line ) |
| 54 | { |
| 55 | osd_free( memory ); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | struct options_entry oplist[] = |
| 60 | { |
| 61 | { "time_to_run;ttr", "1.0", OPTION_FLOAT, "time to run the emulation (seconds)" }, |
| 62 | { "f", "-", OPTION_STRING, "file to process (default is stdin)" }, |
| 63 | { "help;h", "0", OPTION_BOOLEAN, "display help" }, |
| 64 | { NULL } |
| 65 | }; |
| 66 | |
| 67 | /*************************************************************************** |
| 68 | CORE IMPLEMENTATION |
| 69 | ***************************************************************************/ |
| 70 | |
| 71 | const char *filetobuf(pstring fname) |
| 72 | { |
| 73 | static pstring pbuf = ""; |
| 74 | |
| 75 | if (fname == "-") |
| 76 | { |
| 77 | char lbuf[1024]; |
| 78 | while (!feof(stdin)) |
| 79 | { |
| 80 | fgets(lbuf, 1024, stdin); |
| 81 | pbuf += lbuf; |
| 82 | } |
| 83 | printf("%d\n",*(pbuf.right(1).cstr()+1)); |
| 84 | return pbuf.cstr(); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | FILE *f; |
| 89 | f = fopen(fname, "rb"); |
| 90 | fseek(f, 0, SEEK_END); |
| 91 | long fsize = ftell(f); |
| 92 | fseek(f, 0, SEEK_SET); |
| 93 | |
| 94 | char *buf = (char *) malloc(fsize); |
| 95 | fread(buf, fsize, 1, f); |
| 96 | buf[fsize] = 0; |
| 97 | fclose(f); |
| 98 | return buf; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | class netlist_tool_t : public netlist_base_t |
| 103 | { |
| 104 | public: |
| 105 | |
| 106 | netlist_tool_t() |
| 107 | : netlist_base_t(), m_setup(NULL) |
| 108 | { |
| 109 | |
| 110 | } |
| 111 | |
| 112 | virtual ~netlist_tool_t() { }; |
| 113 | |
| 114 | void read_netlist(const char *buffer) |
| 115 | { |
| 116 | m_setup = new netlist_setup_t(*this); |
| 117 | this->set_clock_freq(NETLIST_CLOCK); |
| 118 | |
| 119 | // register additional devices |
| 120 | //m_setup->factory().register_device<nld_analog_callback>( "NETDEV_CALLBACK", "nld_analog_callback"); |
| 121 | |
| 122 | // read the netlist ... |
| 123 | //m_setup_func(*m_setup); |
| 124 | |
| 125 | m_setup->parse(buffer); |
| 126 | |
| 127 | // start devices |
| 128 | m_setup->start_devices(); |
| 129 | m_setup->resolve_inputs(); |
| 130 | // reset |
| 131 | this->reset(); |
| 132 | } |
| 133 | |
| 134 | protected: |
| 135 | |
| 136 | void vfatalerror(const char *format, va_list ap) const |
| 137 | { |
| 138 | vprintf(format, ap); |
| 139 | throw; |
| 140 | } |
| 141 | |
| 142 | private: |
| 143 | netlist_setup_t *m_setup; |
| 144 | }; |
| 145 | |
| 146 | void usage(core_options &opts) |
| 147 | { |
| 148 | astring buffer; |
| 149 | fprintf(stderr, |
| 150 | "Usage:\n" |
| 151 | " nltool -help\n" |
| 152 | " nltool [options]\n" |
| 153 | "\n" |
| 154 | "Where:\n" |
| 155 | ); |
| 156 | fprintf(stderr, "%s\n", opts.output_help(buffer)); |
| 157 | } |
| 158 | |
| 159 | /*------------------------------------------------- |
| 160 | main - primary entry point |
| 161 | -------------------------------------------------*/ |
| 162 | |
| 163 | int main(int argc, char *argv[]) |
| 164 | { |
| 165 | //int result; |
| 166 | netlist_tool_t nt; |
| 167 | core_options opts(oplist); |
| 168 | astring aerror(""); |
| 169 | osd_ticks_t t = osd_ticks(); |
| 170 | |
| 171 | fprintf(stderr, "%s", "WARNING: This is Work In Progress! - It may fail anytime\n"); |
| 172 | if (!opts.parse_command_line(argc, argv, OPTION_PRIORITY_DEFAULT, aerror)) |
| 173 | { |
| 174 | fprintf(stderr, "%s\n", aerror.cstr()); |
| 175 | usage(opts); |
| 176 | return 1; |
| 177 | } |
| 178 | if (opts.bool_value("h")) |
| 179 | { |
| 180 | usage(opts); |
| 181 | return 1; |
| 182 | } |
| 183 | |
| 184 | nt.read_netlist(filetobuf(opts.value("f"))); |
| 185 | double ttr = opts.float_value("ttr"); |
| 186 | |
| 187 | INT64 tt = ttr * NETLIST_CLOCK; |
| 188 | |
| 189 | printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() ); |
| 190 | printf("runnning ...\n"); |
| 191 | t = osd_ticks(); |
| 192 | while (tt>0) |
| 193 | { |
| 194 | INT32 tr = MIN(tt, NETLIST_CLOCK / 10); |
| 195 | tt -= tr; |
| 196 | nt.process_queue(tr); |
| 197 | } |
| 198 | double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second(); |
| 199 | printf("%f seconds emulation took %f real time ==> %5.2f%%\n", ttr, emutime, ttr/emutime*100.0); |
| 200 | } |
trunk/src/emu/machine/netlist.c
| r26659 | r26660 | |
| 50 | 50 | #include "netlist/nl_setup.h" |
| 51 | 51 | #include "netlist/devices/net_lib.h" |
| 52 | 52 | |
| 53 | #define LOG_DEV_CALLS(x) do { } while (0); |
| 54 | |
| 53 | 55 | // ---------------------------------------------------------------------------------------- |
| 54 | 56 | // netlist_mame_device |
| 55 | 57 | // ---------------------------------------------------------------------------------------- |
| r26659 | r26660 | |
| 71 | 73 | { |
| 72 | 74 | netlist_mame_device &netlist = downcast<netlist_mame_device &>(device); |
| 73 | 75 | netlist.m_setup_func = setup_func; |
| 76 | LOG_DEV_CALLS(("static_set_constructor\n")); |
| 74 | 77 | } |
| 75 | 78 | |
| 76 | 79 | void netlist_mame_device::device_config_complete() |
| 77 | 80 | { |
| 81 | LOG_DEV_CALLS(("device_config_complete\n")); |
| 78 | 82 | } |
| 79 | 83 | |
| 80 | 84 | void netlist_mame_device::device_start() |
| 81 | 85 | { |
| 86 | LOG_DEV_CALLS(("device_start\n")); |
| 87 | |
| 82 | 88 | m_netlist = global_alloc_clear(netlist_mame_t(*this)); |
| 83 | 89 | m_netlist->set_clock_freq(this->clock()); |
| 84 | 90 | |
| r26659 | r26660 | |
| 91 | 97 | m_setup_func(*m_setup); |
| 92 | 98 | |
| 93 | 99 | m_setup->start_devices(); |
| 100 | m_setup->resolve_inputs(); |
| 94 | 101 | |
| 95 | | bool allok = true; |
| 96 | | for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods)) |
| 97 | | allok &= ods->object()->OnDeviceStart(); |
| 102 | bool allok = true; |
| 103 | for (device_start_list_t::entry_t *ods = m_device_start_list.first(); ods != NULL; ods = m_device_start_list.next(ods)) |
| 104 | allok &= ods->object()->OnDeviceStart(); |
| 98 | 105 | |
| 99 | | if (!allok) |
| 100 | | m_netlist->xfatalerror("required elements not found\n"); |
| 106 | if (!allok) |
| 107 | m_netlist->xfatalerror("required elements not found\n"); |
| 101 | 108 | |
| 102 | | m_setup->resolve_inputs(); |
| 103 | | |
| 104 | 109 | save_state(); |
| 105 | 110 | /* TODO: we have to save the round robin queue as well */ |
| 106 | 111 | |
| r26659 | r26660 | |
| 110 | 115 | |
| 111 | 116 | void netlist_mame_device::device_reset() |
| 112 | 117 | { |
| 118 | LOG_DEV_CALLS(("device_reset\n")); |
| 113 | 119 | m_netlist->reset(); |
| 114 | | m_setup->step_devices_once(); |
| 115 | 120 | } |
| 116 | 121 | |
| 117 | 122 | void netlist_mame_device::device_stop() |
| 118 | 123 | { |
| 124 | LOG_DEV_CALLS(("device_stop\n")); |
| 119 | 125 | m_setup->print_stats(); |
| 120 | 126 | |
| 121 | 127 | global_free(m_setup); |
trunk/src/emu/netlist/devices/nld_solver.c
| r26659 | r26660 | |
| 10 | 10 | // netlist_matrix_solver |
| 11 | 11 | // ---------------------------------------------------------------------------------------- |
| 12 | 12 | |
| 13 | #define SOLVER_VERBOSE_OUT(x) do {} while (0) |
| 14 | //#define SOLVER_VERBOSE_OUT(x) printf x |
| 13 | 15 | |
| 14 | 16 | ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLIB_NAME(solver) &aowner) |
| 15 | 17 | { |
| r26659 | r26660 | |
| 264 | 266 | } |
| 265 | 267 | } |
| 266 | 268 | |
| 267 | | printf("Scanning net groups ...\n"); |
| 269 | SOLVER_VERBOSE_OUT(("Scanning net groups ...\n")); |
| 268 | 270 | // determine net groups |
| 269 | 271 | for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn)) |
| 270 | 272 | { |
| r26659 | r26660 | |
| 276 | 278 | } |
| 277 | 279 | |
| 278 | 280 | // setup the solvers |
| 279 | | printf("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count()); |
| 281 | SOLVER_VERBOSE_OUT(("Found %d net groups in %d nets\n", cur_group + 1, m_nets.count())); |
| 280 | 282 | for (int i = 0; i <= cur_group; i++) |
| 281 | 283 | { |
| 282 | 284 | netlist_matrix_solver_t *ms = new netlist_matrix_solver_t(); |
| r26659 | r26660 | |
| 284 | 286 | ms->m_convergence_factor = m_convergence.Value(); |
| 285 | 287 | ms->setup(groups[i], *this); |
| 286 | 288 | m_mat_solvers.add(ms); |
| 287 | | printf("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr()); |
| 288 | | printf(" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic"); |
| 289 | SOLVER_VERBOSE_OUT(("%d ==> %d nets %s\n", i, groups[i].count(), groups[i].first()->object()->m_head->name().cstr())); |
| 290 | SOLVER_VERBOSE_OUT((" has %s elements\n", ms->is_dynamic() ? "dynamic" : "no dynamic")); |
| 289 | 291 | } |
| 290 | 292 | |
| 291 | 293 | } |
trunk/src/emu/netlist/nl_parser.c
| r26659 | r26660 | |
| 7 | 7 | |
| 8 | 8 | #include "nl_parser.h" |
| 9 | 9 | |
| 10 | | #undef NL_VERBOSE_OUT |
| 11 | | #define NL_VERBOSE_OUT(x) printf x |
| 10 | //#undef NL_VERBOSE_OUT |
| 11 | //#define NL_VERBOSE_OUT(x) printf x |
| 12 | 12 | |
| 13 | 13 | // ---------------------------------------------------------------------------------------- |
| 14 | 14 | // A netlist parser |
| 15 | 15 | // ---------------------------------------------------------------------------------------- |
| 16 | 16 | |
| 17 | | void netlist_parser::parse(char *buf) |
| 17 | void netlist_parser::parse(const char *buf) |
| 18 | 18 | { |
| 19 | | char c; |
| 20 | 19 | m_px = buf; |
| 21 | | c = getc(); |
| 22 | 20 | |
| 23 | | while (c) |
| 21 | while (!eof()) |
| 24 | 22 | { |
| 25 | 23 | pstring n; |
| 26 | 24 | skipws(); |
| r26659 | r26660 | |
| 45 | 43 | netdev_const(n); |
| 46 | 44 | else |
| 47 | 45 | netdev_device(n); |
| 48 | | c = getc(); |
| 49 | 46 | } |
| 50 | 47 | } |
| 51 | 48 | |
| r26659 | r26660 | |
| 83 | 80 | val = eval_param(); |
| 84 | 81 | NL_VERBOSE_OUT(("Parser: Param: %s %f\n", param.cstr(), val)); |
| 85 | 82 | m_setup.register_param(param, val); |
| 86 | | //m_setup.find_param(param).initial(val); |
| 87 | 83 | check_char(')'); |
| 88 | 84 | } |
| 89 | 85 | |
| r26659 | r26660 | |
| 103 | 99 | paramfq = name + ".CONST"; |
| 104 | 100 | NL_VERBOSE_OUT(("Parser: Const: %s %f\n", name.cstr(), val)); |
| 105 | 101 | check_char(')'); |
| 106 | | //m_setup.find_param(paramfq).initial(val); |
| 107 | 102 | m_setup.register_param(paramfq, val); |
| 108 | 103 | } |
| 109 | 104 | |
| r26659 | r26660 | |
| 273 | 268 | static double facs[6] = {1, 1e3, 1e6, 1e-6, 1e-9, 1e-12}; |
| 274 | 269 | int i; |
| 275 | 270 | int f=0; |
| 276 | | char *e; |
| 271 | bool e; |
| 277 | 272 | double ret; |
| 278 | 273 | |
| 279 | 274 | pstring s = getname2(')',','); |
| 280 | 275 | |
| 281 | | printf("Got %s\n", s.cstr()); |
| 282 | 276 | for (i=1; i<6;i++) |
| 283 | 277 | if (strncmp(s.cstr(), macs[i], strlen(macs[i])) == 0) |
| 284 | 278 | f = i; |
| 285 | | ret = strtod(s.substr(strlen(macs[f])).cstr(), &e); |
| 286 | | if ((f>0) && (*e != 0)) |
| 279 | ret = s.substr(strlen(macs[f])).as_double(&e); |
| 280 | if ((f>0) && e) |
| 287 | 281 | m_setup.netlist().xfatalerror("Parser: Error with parameter ...\n"); |
| 288 | 282 | if (f>0) |
| 289 | 283 | check_char(')'); |
| 290 | | //if (f == 0) |
| 291 | | // ungetc(); |
| 292 | | //if (f>0) |
| 293 | | // e++; |
| 294 | | //m_p = e; |
| 295 | 284 | return ret * facs[f]; |
| 296 | 285 | } |
| 297 | 286 | |
| 298 | 287 | unsigned char netlist_parser::getc() |
| 299 | 288 | { |
| 300 | | return *(m_px++); |
| 289 | if (*m_px) |
| 290 | return *(m_px++); |
| 291 | else |
| 292 | return *m_px; |
| 301 | 293 | } |
| 302 | 294 | |
| 303 | 295 | void netlist_parser::ungetc() |
trunk/src/emu/netlist/nl_setup.c
| r26659 | r26660 | |
| 37 | 37 | NETLIST_NAME(base)(*this); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | | template <class T> |
| 41 | | static void tagmap_free_entries(T &tm) |
| 42 | | { |
| 43 | | for (typename T::entry_t *entry = tm.first(); entry != NULL; entry = tm.next(entry)) |
| 44 | | { |
| 45 | | delete entry->object(); |
| 46 | | } |
| 47 | | tm.reset(); |
| 48 | | } |
| 49 | 40 | |
| 50 | 41 | netlist_setup_t::~netlist_setup_t() |
| 51 | 42 | { |
| 52 | | tagmap_free_entries<tagmap_devices_t>(m_devices); |
| 53 | | //tagmap_free_entries<tagmap_link_t>(m_links); |
| 54 | | //tagmap_free_entries<tagmap_nstring_t>(m_alias); |
| 55 | 43 | m_links.reset(); |
| 56 | 44 | m_alias.reset(); |
| 57 | 45 | m_params.reset(); |
| r26659 | r26660 | |
| 63 | 51 | pstring::resetmem(); |
| 64 | 52 | } |
| 65 | 53 | |
| 54 | // FIXME: Move to netlist ... |
| 66 | 55 | netlist_device_t *netlist_setup_t::register_dev(netlist_device_t *dev, const pstring &name) |
| 67 | 56 | { |
| 68 | | if (!(m_devices.add(name, dev, false)==TMERR_NONE)) |
| 57 | if (!(netlist().m_devices.add(name, dev, false)==TMERR_NONE)) |
| 69 | 58 | netlist().xfatalerror("Error adding %s to device list\n", name.cstr()); |
| 70 | 59 | return dev; |
| 71 | 60 | } |
| r26659 | r26660 | |
| 89 | 78 | |
| 90 | 79 | void netlist_setup_t::remove_dev(const pstring &name) |
| 91 | 80 | { |
| 92 | | netlist_device_t *dev = m_devices.find(name); |
| 81 | netlist_device_t *dev = netlist().m_devices.find(name); |
| 93 | 82 | pstring temp = name + "."; |
| 94 | 83 | if (dev == NULL) |
| 95 | 84 | netlist().xfatalerror("Device %s does not exist\n", name.cstr()); |
| r26659 | r26660 | |
| 106 | 95 | m_links.remove(p->object()); |
| 107 | 96 | p = n; |
| 108 | 97 | } |
| 109 | | m_devices.remove(name); |
| 98 | netlist().m_devices.remove(name); |
| 110 | 99 | } |
| 111 | 100 | |
| 112 | 101 | void netlist_setup_t::register_model(const pstring &model) |
| r26659 | r26660 | |
| 182 | 171 | { |
| 183 | 172 | case netlist_param_t::DOUBLE: |
| 184 | 173 | { |
| 185 | | //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()); |
| 174 | NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr())); |
| 186 | 175 | double vald = 0; |
| 187 | 176 | if (sscanf(val.cstr(), "%lf", &vald) != 1) |
| 188 | 177 | netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr()); |
| r26659 | r26660 | |
| 192 | 181 | case netlist_param_t::INTEGER: |
| 193 | 182 | case netlist_param_t::LOGIC: |
| 194 | 183 | { |
| 195 | | //printf("Found parameter ... %s : %s\n", temp.cstr(), val->cstr()); |
| 184 | NL_VERBOSE_OUT(("Found parameter ... %s : %s\n", temp.cstr(), val->cstr())); |
| 196 | 185 | int vald = 0; |
| 197 | 186 | if (sscanf(val.cstr(), "%d", &vald) != 1) |
| 198 | 187 | netlist().xfatalerror("Invalid number conversion %s : %s\n", temp.cstr(), val.cstr()); |
| r26659 | r26660 | |
| 273 | 262 | if (p > 0) |
| 274 | 263 | { |
| 275 | 264 | pstring dname = ret; |
| 276 | | netlist_device_t *dev = m_devices.find(dname.substr(0,p)); |
| 265 | netlist_device_t *dev = netlist().m_devices.find(dname.substr(0,p)); |
| 277 | 266 | if (dev == NULL) |
| 278 | 267 | netlist().xfatalerror("Device for %s not found\n", name.cstr()); |
| 279 | 268 | int c = atoi(ret.substr(p+2,ret.len()-p-3)); |
| r26659 | r26660 | |
| 285 | 274 | } while (temp != ""); |
| 286 | 275 | } |
| 287 | 276 | |
| 288 | | //printf("%s==>%s\n", name.cstr(), ret.cstr()); |
| 277 | NL_VERBOSE_OUT(("%s==>%s\n", name.cstr(), ret.cstr())); |
| 289 | 278 | return ret; |
| 290 | 279 | } |
| 291 | 280 | |
| r26659 | r26660 | |
| 367 | 356 | } |
| 368 | 357 | else if (out.isFamily(netlist_terminal_t::LOGIC) && in.isFamily(netlist_terminal_t::ANALOG)) |
| 369 | 358 | { |
| 370 | | //printf("here 1\n"); |
| 371 | 359 | nld_d_to_a_proxy *proxy = new nld_d_to_a_proxy(out); |
| 372 | 360 | pstring x = pstring::sprintf("proxy_da_%d", m_proxy_cnt); |
| 373 | 361 | m_proxy_cnt++; |
| r26659 | r26660 | |
| 490 | 478 | if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::INPUT)) |
| 491 | 479 | { |
| 492 | 480 | if (t2.has_net()) |
| 493 | | mame_printf_warning("Input %s already connected\n", t2.name().cstr()); |
| 481 | NL_VERBOSE_OUT(("Input %s already connected\n", t2.name().cstr())); |
| 494 | 482 | connect_input_output(dynamic_cast<netlist_input_t &>(t2), dynamic_cast<netlist_output_t &>(t1)); |
| 495 | 483 | } |
| 496 | 484 | else if (t1.isType(netlist_core_terminal_t::INPUT) && t2.isType(netlist_core_terminal_t::OUTPUT)) |
| 497 | 485 | { |
| 498 | 486 | if (t1.has_net()) |
| 499 | | mame_printf_warning("Input %s already connected\n", t1.name().cstr()); |
| 487 | NL_VERBOSE_OUT(("Input %s already connected\n", t1.name().cstr())); |
| 500 | 488 | connect_input_output(dynamic_cast<netlist_input_t &>(t1), dynamic_cast<netlist_output_t &>(t2)); |
| 501 | 489 | } |
| 502 | 490 | else if (t1.isType(netlist_core_terminal_t::OUTPUT) && t2.isType(netlist_core_terminal_t::TERMINAL)) |
| r26659 | r26660 | |
| 523 | 511 | netlist().xfatalerror("Connecting %s to %s not supported!\n", t1.name().cstr(), t2.name().cstr()); |
| 524 | 512 | } |
| 525 | 513 | |
| 526 | | void netlist_setup_t::resolve_inputs(void) |
| 514 | void netlist_setup_t::resolve_inputs() |
| 527 | 515 | { |
| 528 | 516 | |
| 529 | 517 | NL_VERBOSE_OUT(("Resolving ...\n")); |
| r26659 | r26660 | |
| 551 | 539 | |
| 552 | 540 | } |
| 553 | 541 | |
| 554 | | void netlist_setup_t::start_devices(void) |
| 542 | void netlist_setup_t::start_devices() |
| 555 | 543 | { |
| 556 | 544 | |
| 557 | 545 | if (getenv("NL_LOGS")) |
| r26659 | r26660 | |
| 560 | 548 | nl_util::pstring_list ll = nl_util::split(getenv("NL_LOGS"), ":"); |
| 561 | 549 | for (int i=0; i < ll.count(); i++) |
| 562 | 550 | { |
| 563 | | printf("%d: <%s>\n",i, ll[i].cstr()); |
| 551 | NL_VERBOSE_OUT(("%d: <%s>\n",i, ll[i].cstr())); |
| 564 | 552 | netlist_device_t *nc = factory().new_device_by_classname("nld_log", *this); |
| 565 | | pstring name = "log" + ll[i]; |
| 553 | pstring name = "log_" + ll[i]; |
| 566 | 554 | register_dev(nc, name); |
| 567 | 555 | register_link(name + ".I", ll[i]); |
| 568 | 556 | } |
| r26659 | r26660 | |
| 571 | 559 | |
| 572 | 560 | NL_VERBOSE_OUT(("Searching for mainclock and solver ...\n")); |
| 573 | 561 | /* find the main clock ... */ |
| 574 | | for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) |
| 562 | for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) |
| 575 | 563 | { |
| 576 | 564 | netlist_device_t *dev = entry->object(); |
| 577 | 565 | if (dynamic_cast<NETLIB_NAME(mainclock)*>(dev) != NULL) |
| r26659 | r26660 | |
| 585 | 573 | } |
| 586 | 574 | |
| 587 | 575 | NL_VERBOSE_OUT(("Initializing devices ...\n")); |
| 588 | | for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) |
| 576 | for (tagmap_devices_t::entry_t *entry = netlist().m_devices.first(); entry != NULL; entry = netlist().m_devices.next(entry)) |
| 589 | 577 | { |
| 590 | 578 | netlist_device_t *dev = entry->object(); |
| 591 | 579 | dev->init(netlist(), entry->tag().cstr()); |
| 592 | 580 | } |
| 593 | 581 | } |
| 594 | 582 | |
| 595 | | void netlist_setup_t::step_devices_once(void) |
| 583 | void netlist_setup_t::parse(const char *buf) |
| 596 | 584 | { |
| 597 | | /* make sure params are set now .. */ |
| 598 | | for (tagmap_param_t::entry_t *entry = m_params.first(); entry != NULL; entry = m_params.next(entry)) |
| 599 | | { |
| 600 | | entry->object()->netdev().update_param(); |
| 601 | | } |
| 602 | | |
| 603 | | for (tagmap_devices_t::entry_t *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry)) |
| 604 | | { |
| 605 | | netlist_device_t *dev = entry->object(); |
| 606 | | dev->update_dev(); |
| 607 | | } |
| 608 | | } |
| 609 | | |
| 610 | | |
| 611 | | void netlist_setup_t::parse(char *buf) |
| 612 | | { |
| 613 | 585 | netlist_parser parser(*this); |
| 614 | 586 | parser.parse(buf); |
| 615 | 587 | } |
trunk/src/emu/netlist/pstring.h
| r26659 | r26660 | |
| 122 | 122 | inline bool equals(const pstring &string) { return (pcmp(string.cstr(), m_ptr->str()) == 0); } |
| 123 | 123 | inline bool iequals(const pstring &string) { return (pcmpi(string.cstr(), m_ptr->str()) == 0); } |
| 124 | 124 | |
| 125 | | int cmp(const pstring &string) const { return pcmp(string.cstr()); } |
| 126 | | int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); } |
| 125 | inline int cmp(const pstring &string) const { return pcmp(string.cstr()); } |
| 126 | inline int cmpi(const pstring &string) const { return pcmpi(cstr(), string.cstr()); } |
| 127 | 127 | |
| 128 | | int find(const char *search, int start = 0) const |
| 128 | inline int find(const char *search, int start = 0) const |
| 129 | 129 | { |
| 130 | 130 | int alen = len(); |
| 131 | 131 | const char *result = strstr(cstr() + MIN(start, alen), search); |
| r26659 | r26660 | |
| 134 | 134 | |
| 135 | 135 | // various |
| 136 | 136 | |
| 137 | | bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); } |
| 138 | | bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); } |
| 137 | inline bool startsWith(const pstring &arg) const { return (pcmp(cstr(), arg.cstr(), arg.len()) == 0); } |
| 138 | inline bool startsWith(const char *arg) const { return (pcmp(cstr(), arg, strlen(arg)) == 0); } |
| 139 | 139 | |
| 140 | 140 | // these return nstring ... |
| 141 | | pstring cat(const pstring &s) const { return *this + s; } |
| 142 | | pstring cat(const char *s) const { return *this + s; } |
| 141 | inline pstring cat(const pstring &s) const { return *this + s; } |
| 142 | inline pstring cat(const char *s) const { return *this + s; } |
| 143 | 143 | |
| 144 | 144 | pstring substr(unsigned int start, int count = -1) const ; |
| 145 | 145 | |
| 146 | | pstring left(unsigned int count) const { return substr(0, count); } |
| 147 | | pstring right(unsigned int count) const { return substr(len() - count, count); } |
| 146 | inline pstring left(unsigned int count) const { return substr(0, count); } |
| 147 | inline pstring right(unsigned int count) const { return substr(len() - count, count); } |
| 148 | |
| 148 | 149 | pstring ucase() const; |
| 149 | 150 | |
| 151 | // conversions |
| 152 | |
| 153 | double as_double(bool *error = NULL) const; |
| 154 | |
| 155 | long as_long(bool *error = NULL) const; |
| 156 | |
| 150 | 157 | // printf using string as format ... |
| 151 | 158 | |
| 152 | 159 | pstring vprintf(va_list args) const; |