diff options
author | 2020-09-06 23:24:21 +0200 | |
---|---|---|
committer | 2020-09-12 23:20:16 +0200 | |
commit | ca31c844cde7f54a285e3b9da358989e42258f5b (patch) | |
tree | f9e4a963b999e1352a4611a43a7c10c2d80957e7 /src/lib/netlist/nl_parser.cpp | |
parent | cda35c94020dbcb8dad8309aba11374c356c501e (diff) |
netlist: move to generated header and link support files files.
* Removed device and macro header files.
* All of those can be generated automatically so going forward there is
no need for these any longer.
* Introduced the modules concept. Modules are netlists for which
automatic lib entries are generated.
* Going forward you just store them in macro/modules and they will be
automatically registered as device elements.
* You need to do a "make generated" is src/lib/netlist/build
* Some_device.cpp still needs to be added to netlist.lua
* Added documentation on how to add devices to netlist.
* Please refer to adding_devices.md for more information.
Diffstat (limited to 'src/lib/netlist/nl_parser.cpp')
-rw-r--r-- | src/lib/netlist/nl_parser.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/netlist/nl_parser.cpp b/src/lib/netlist/nl_parser.cpp index f032a50076e..d5823d2e930 100644 --- a/src/lib/netlist/nl_parser.cpp +++ b/src/lib/netlist/nl_parser.cpp @@ -44,6 +44,7 @@ parser_t::parser_t(nlparse_t &setup) m_tok_INCLUDE = m_tokenizer.register_token("INCLUDE"); m_tok_LOCAL_SOURCE = m_tokenizer.register_token("LOCAL_SOURCE"); m_tok_LOCAL_LIB_ENTRY = m_tokenizer.register_token("LOCAL_LIB_ENTRY"); + m_tok_EXTERNAL_LIB_ENTRY = m_tokenizer.register_token("EXTERNAL_LIB_ENTRY"); m_tok_SUBMODEL = m_tokenizer.register_token("SUBMODEL"); m_tok_NETLIST_START = m_tokenizer.register_token("NETLIST_START"); m_tok_NETLIST_END = m_tokenizer.register_token("NETLIST_END"); @@ -141,6 +142,8 @@ bool parser_t::parse(const token_store &tokstor, const pstring &nlname) //m_cur_local->push_back(token_t(m_tok_paren_right)); in_nl = true; } + // FIXME: do we really need this going forward ? there should be no need + // for NETLIST_EXTERNAL in netlist files else if (token.is(m_tok_NETLIST_EXTERNAL)) { if (in_nl) @@ -197,17 +200,10 @@ void parser_t::parse_netlist(const pstring &nlname) net_local_source(); else if (token.is(m_tok_EXTERNAL_SOURCE)) net_external_source(); - //else if (token.is(m_tok_TRUTHTABLE_START)) - // net_truthtable_start(nlname); else if (token.is(m_tok_LOCAL_LIB_ENTRY)) - { - require_token(m_tok_paren_left); - pstring name(get_identifier()); - register_local_as_source(name); - // FIXME: Need to pass in parameter definition FIXME: get line number right - m_setup.register_lib_entry(name, "", plib::source_location("parser: " + nlname, 1)); - require_token(m_tok_paren_right); - } + net_lib_entry(true); + else if (token.is(m_tok_EXTERNAL_LIB_ENTRY)) + net_lib_entry(false); else if (token.is(m_tok_TRUTHTABLE_ENTRY)) { require_token(m_tok_paren_left); @@ -232,6 +228,21 @@ void parser_t::parse_netlist(const pstring &nlname) } } +void parser_t::net_lib_entry(bool is_local) +{ + require_token(m_tok_paren_left); + pstring name(get_identifier()); + + if (is_local) + register_local_as_source(name); + else if (m_local.find(name) != m_local.end()) + error(MF_EXTERNAL_SOURCE_IS_LOCAL_1(name)); + + // FIXME: Need to pass in parameter definition FIXME: get line number right + m_setup.register_lib_entry(name, "", sourceloc()); + require_token(m_tok_paren_right); +} + void parser_t::net_truthtable_start(const pstring &nlname) { bool head_found(false); @@ -282,7 +293,7 @@ void parser_t::net_truthtable_start(const pstring &nlname) require_token(m_tok_paren_left); require_token(m_tok_paren_right); // FIXME: proper location - m_setup.truthtable_create(desc, def_param, plib::source_location(nlname, 1)); + m_setup.truthtable_create(desc, def_param, sourceloc()); return; } } @@ -355,9 +366,7 @@ void parser_t::register_local_as_source(const pstring &name) { auto p = m_local.find(name); if (p != m_local.end()) - { m_setup.register_source<source_token_t>(name, p->second); - } else error(MF_LOCAL_SOURCE_NOT_FOUND_1(name)); } |