diff options
Diffstat (limited to 'src/lib/netlist/nl_parser.cpp')
-rw-r--r-- | src/lib/netlist/nl_parser.cpp | 134 |
1 files changed, 106 insertions, 28 deletions
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index 92473fcdb74..bf12c97f141 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -47,6 +47,13 @@ bool parser_t::parse(const pstring &nlname) m_tok_TT_LINE = register_token("TT_LINE"); m_tok_TT_FAMILY = register_token("TT_FAMILY"); + register_token("RES_R"); + register_token("RES_K"); + register_token("RES_M"); + register_token("CAP_U"); + register_token("CAP_N"); + register_token("CAP_P"); + bool in_nl = false; while (true) @@ -347,56 +354,127 @@ void parser_t::netdev_hint() void parser_t::device(const pstring &dev_type) { +#if 1 + std::vector<pstring> params; + + pstring devname = get_identifier(); + + m_setup.log().debug("Parser: IC: {1}\n", devname); + + auto tok(get_token()); + + //printf("enter\n"); + while (tok.is(m_tok_comma)) + { + tok = get_token(); + //printf("%d %s\n", tok.type(), tok.str().c_str()); + if (tok.is_type(IDENTIFIER)) + params.push_back(tok.str()); + else if (tok.is_type(STRING)) + { + params.push_back(tok.str()); + } + else + { + // FIXME: Do we really need this? + nl_fptype value = eval_param(tok); + if (plib::abs(value - plib::floor(value)) > nlconst::magic(1e-30) + || plib::abs(value) > nlconst::magic(1e9)) + params.push_back(plib::pfmt("{1:.9}").e(value)); + else + params.push_back(plib::pfmt("{1}")(static_cast<long>(value))); + } + tok = get_token(); + } + + require_token(tok, m_tok_param_right); + m_setup.register_dev(dev_type, devname, params); + +#else factory::element_t *f = m_setup.factory().factory_by_name(dev_type); auto paramlist = plib::psplit(f->param_desc(), ","); + std::vector<pstring> params; pstring devname = get_identifier(); m_setup.register_dev(dev_type, devname); m_setup.log().debug("Parser: IC: {1}\n", devname); - for (const pstring &tp : paramlist) + auto tok(get_token()); + + //printf("enter\n"); + while (tok.is(m_tok_comma)) { - if (plib::startsWith(tp, "+")) + tok = get_token(); + //printf("%d %s\n", tok.type(), tok.str().c_str()); + if (tok.is_type(IDENTIFIER)) + params.push_back(tok.str()); + else if (tok.is_type(STRING)) { - require_token(m_tok_comma); - pstring output_name = get_identifier(); - m_setup.log().debug("Link: {1} {2}\n", tp, output_name); - - m_setup.register_link(devname + "." + tp.substr(1), output_name); + params.push_back(tok.str()); } - else if (plib::startsWith(tp, "@")) + else { - pstring term = tp.substr(1); - m_setup.log().debug("Link: {1} {2}\n", tp, term); - - //FIXME - if (term == "VCC") - m_setup.register_link(devname + "." + term, "V5"); + // FIXME: Do we really need this? + nl_fptype value = eval_param(tok); + if (plib::abs(value - plib::floor(value)) > nlconst::magic(1e-30) + || plib::abs(value) > nlconst::magic(1e9)) + params.push_back(plib::pfmt("{1:.9}").e(value)); else - m_setup.register_link(devname + "." + term, term); + params.push_back(plib::pfmt("{1}")(static_cast<long>(value))); } - else - { - require_token(m_tok_comma); - pstring paramfq = devname + "." + tp; + tok = get_token(); + } + + require_token(tok, m_tok_param_right); + + if (params.size() > 0) + { + auto ptok(params.begin()); - m_setup.log().debug("Defparam: {1}\n", paramfq); - token_t tok = get_token(); - if (tok.is_type(STRING)) + for (const pstring &tp : paramlist) + { + //printf("x %s %s\n", tp.c_str(), ptok->c_str()); + if (plib::startsWith(tp, "+")) + { + if (ptok == params.end()) + { + error(plib::pfmt("Input count mismatch for {1} - only found {2}")(devname)(params.size())); + break; + } + pstring output_name = *ptok; + m_setup.log().debug("Link: {1} {2}\n", tp, output_name); + + m_setup.register_link(devname + "." + tp.substr(1), output_name); + ++ptok; + } + else if (plib::startsWith(tp, "@")) { - m_setup.register_param(paramfq, tok.str()); + pstring term = tp.substr(1); + m_setup.log().debug("Link: {1} {2}\n", tp, term); + + m_setup.register_link(devname + "." + term, term); } else { - nl_fptype val = eval_param(tok); - m_setup.register_param(paramfq, val); + if (ptok == params.end()) + { + error(plib::pfmt("Input count mismatch for {1} - only found {2}")(devname)(params.size())); + break; + } + pstring paramfq = devname + "." + tp; + + m_setup.log().debug("Defparam: {1}\n", paramfq); + m_setup.register_param(paramfq, *ptok); + ++ptok; } } + if (ptok != params.end()) + { + error(plib::pfmt("Input count exceed for {1} - found {2}")(devname)(params.size())); + } } - - // error(plib::pfmt("Input count mismatch for {1} - expected {2} found {3}")(devname)(termlist.size())(cnt)); - require_token(m_tok_param_right); +#endif } |