netlist: necessary changes towards runtime processing of macro directory

This commit is contained in:
couriersud 2020-07-28 20:42:27 +02:00
parent c00cbad238
commit 09e987486a
12 changed files with 59 additions and 45 deletions

View File

@ -28,17 +28,16 @@
#define IND_P(ind) ((ind) * 1e-12) #define IND_P(ind) ((ind) * 1e-12)
#endif #endif
NETLIST_EXTERNAL(base)
NETLIST_EXTERNAL(CD4XXX_lib)
NETLIST_EXTERNAL(OPAMP_lib)
NETLIST_EXTERNAL(otheric_lib)
NETLIST_EXTERNAL(TTL74XX_lib)
NETLIST_EXTERNAL(ROMS_lib)
#if NL_AUTO_DEVICES #if NL_AUTO_DEVICES
#include "nld_devinc.h" #include "nld_devinc.h"
#include "netlist/macro/nlm_cd4xxx.h"
#include "netlist/macro/nlm_opamp.h"
#include "netlist/macro/nlm_other.h"
#include "netlist/macro/nlm_ttl74xx.h"
#include "netlist/macro/nlm_roms.h"
#include "nld_7448.h"
#else #else
#define SOLVER(name, freq) \ #define SOLVER(name, freq) \

View File

@ -1,7 +1,6 @@
// license:GPL-2.0+ // license:GPL-2.0+
// copyright-holders:Couriersud // copyright-holders:Couriersud
#include "netlist/devices/net_lib.h" #include "netlist/devices/net_lib.h"
#include "nlm_base.h"
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Diode Models * Diode Models

View File

@ -64,13 +64,14 @@
#define CD4538_DIP(name) \ #define CD4538_DIP(name) \
NET_REGISTER_DEV(CD4538_DIP, name) NET_REGISTER_DEV(CD4538_DIP, name)
#endif #endif // !NL_AUTO_DEVICES
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* External declarations * External declarations
* ---------------------------------------------------------------------------*/ * ---------------------------------------------------------------------------*/
NETLIST_EXTERNAL(CD4XXX_lib) // moved to net_lib.h
#endif #endif
#endif #endif // NLD_CD4XXX_H_

View File

@ -60,7 +60,7 @@
* External declarations * External declarations
* ---------------------------------------------------------------------------*/ * ---------------------------------------------------------------------------*/
NETLIST_EXTERNAL(OPAMP_lib) // moved to net_lib.h
#endif // __PLIB_PREPROCESSOR__ #endif // __PLIB_PREPROCESSOR__

View File

@ -33,7 +33,7 @@
* External declarations * External declarations
* ---------------------------------------------------------------------------*/ * ---------------------------------------------------------------------------*/
NETLIST_EXTERNAL(otheric_lib) // moved to net_lib.h
#endif #endif

View File

@ -37,7 +37,7 @@
* External declarations * External declarations
* ---------------------------------------------------------------------------*/ * ---------------------------------------------------------------------------*/
NETLIST_EXTERNAL(ROMS_lib) // moved to net_lib.h
#endif // __PLIB_PREPROCESSOR__ #endif // __PLIB_PREPROCESSOR__

View File

@ -3,6 +3,20 @@
#include "netlist/devices/net_lib.h" #include "netlist/devices/net_lib.h"
#ifndef NL_USE_TRUTHTABLE_74107
#define NL_USE_TRUTHTABLE_74107 0
#endif
#ifndef NL_USE_TRUTHTABLE_7448
#define NL_USE_TRUTHTABLE_7448 0
#endif
#if 1
//
#elif %&/()
//
#endif
/* /*
* DM7400: Quad 2-Input NAND Gates * DM7400: Quad 2-Input NAND Gates
* *
@ -1139,9 +1153,8 @@ NETLIST_END()
* Naming conventions follow Fairchild Semiconductor datasheet * Naming conventions follow Fairchild Semiconductor datasheet
* *
*/ */
#if !NL_AUTO_DEVICES
#ifndef __PLIB_PREPROCESSOR__ #ifndef __PLIB_PREPROCESSOR__
#if !NL_AUTO_DEVICES
#define TTL_74279A(name) \ #define TTL_74279A(name) \
NET_REGISTER_DEV(TTL_74279A, name) NET_REGISTER_DEV(TTL_74279A, name)
#define TTL_74279B(name) \ #define TTL_74279B(name) \
@ -1299,13 +1312,8 @@ NETLIST_END()
* *
*/ */
#ifndef __PLIB_PREPROCESSOR__
#define DM9312_TT(name) \
NET_REGISTER_DEV(DM9312, name)
#endif
static NETLIST_START(DM9312_DIP) static NETLIST_START(DM9312_DIP)
DM9312_TT(s) DM9312(s)
DIPPINS( /* +--------------+ */ DIPPINS( /* +--------------+ */
s.D0, /* D0 |1 ++ 16| VCC */ s.VCC, s.D0, /* D0 |1 ++ 16| VCC */ s.VCC,

View File

@ -333,22 +333,8 @@
#define TTL_74379_DIP(name) \ #define TTL_74379_DIP(name) \
NET_REGISTER_DEV(TTL_74379_DIP, name) NET_REGISTER_DEV(TTL_74379_DIP, name)
#define DM9312(name, cA, cB, cC, cSTROBE, cD0, cD1, cD2, cD3, cD4, cD5, cD6, cD7) \ #define DM9312(...) \
NET_REGISTER_DEV(DM9312, name) \ NET_REGISTER_DEVEXT(DM9312, __VA_ARGS__)
NET_CONNECT(name, VCC, VCC) \
NET_CONNECT(name, GND, GND) \
NET_CONNECT(name, A, cA) \
NET_CONNECT(name, B, cB) \
NET_CONNECT(name, C, cC) \
NET_CONNECT(name, G, cSTROBE) \
NET_CONNECT(name, D0, cD0) \
NET_CONNECT(name, D1, cD1) \
NET_CONNECT(name, D2, cD2) \
NET_CONNECT(name, D3, cD3) \
NET_CONNECT(name, D4, cD4) \
NET_CONNECT(name, D5, cD5) \
NET_CONNECT(name, D6, cD6) \
NET_CONNECT(name, D7, cD7)
#define DM9312_DIP(name) \ #define DM9312_DIP(name) \
NET_REGISTER_DEV(DM9312_DIP, name) NET_REGISTER_DEV(DM9312_DIP, name)
@ -359,7 +345,7 @@
* External declarations * External declarations
* ---------------------------------------------------------------------------*/ * ---------------------------------------------------------------------------*/
NETLIST_EXTERNAL(TTL74XX_lib) // moved to net_lib.h
#endif // __PLIB_PREPROCESSOR__ #endif // __PLIB_PREPROCESSOR__

View File

@ -142,7 +142,19 @@ namespace netlist
"#define IND_N(ind) ((ind) * 1e-9) \n" "#define IND_N(ind) ((ind) * 1e-9) \n"
"#define IND_P(ind) ((ind) * 1e-12) \n"; "#define IND_P(ind) ((ind) * 1e-12) \n";
m_setup->parser().add_include<a>("netlist/devices/net_lib.h", content); m_setup->parser().add_include<a>("netlist/devices/net_lib.h", content);
#if 1
NETLIST_NAME(base)(m_setup->parser()); NETLIST_NAME(base)(m_setup->parser());
#else
// FIXME: This is very slow - need optimized parsing scanning
pstring dir = "src/lib/netlist/macro/";
m_setup->parser().register_source<source_file_t>(dir + "nlm_base.cpp");
m_setup->parser().register_source<source_file_t>(dir + "nlm_opamp.cpp");
m_setup->parser().register_source<source_file_t>(dir + "nlm_roms.cpp");
m_setup->parser().register_source<source_file_t>(dir + "nlm_cd4xxx.cpp");
m_setup->parser().register_source<source_file_t>(dir + "nlm_other.cpp");
m_setup->parser().register_source<source_file_t>(dir + "nlm_ttl74xx.cpp");
m_setup->parser().include("base");
#endif
} }

View File

@ -110,7 +110,7 @@ namespace netlist
//break; //break;
} }
pstring output_name = *ptok; pstring output_name = *ptok;
log().debug("Link: {1} {2}\n", tp, output_name); log().debug("Link: {1} {2}", tp, output_name);
register_link(name + "." + tp.substr(1), output_name); register_link(name + "." + tp.substr(1), output_name);
++ptok; ++ptok;
@ -118,7 +118,7 @@ namespace netlist
else if (plib::startsWith(tp, "@")) else if (plib::startsWith(tp, "@"))
{ {
pstring term = tp.substr(1); pstring term = tp.substr(1);
log().debug("Link: {1} {2}\n", tp, term); log().debug("Link: {1} {2}", tp, term);
register_link(name + "." + term, term); register_link(name + "." + term, term);
} }
@ -353,7 +353,7 @@ namespace netlist
bool nlparse_t::parse_stream(plib::psource_t::stream_ptr &&istrm, const pstring &name) bool nlparse_t::parse_stream(plib::psource_t::stream_ptr &&istrm, const pstring &name)
{ {
auto y = std::make_unique<plib::ppreprocessor>(m_includes, &m_defines); auto y = std::make_unique<plib::ppreprocessor>(m_includes, &m_defines);
y->process(std::move(istrm)); y->process(std::move(istrm), "<stream>");
return parser_t(std::move(y), *this).parse(name); return parser_t(std::move(y), *this).parse(name);
//return parser_t(std::move(plib::ppreprocessor(&m_defines).process(std::move(istrm))), *this).parse(name); //return parser_t(std::move(plib::ppreprocessor(&m_defines).process(std::move(istrm))), *this).parse(name);
} }

View File

@ -68,10 +68,17 @@ namespace plib {
delete rdbuf(); delete rdbuf();
} }
/// \brief process stream
///
/// \param filename a filename or identifier identifying the stream.
///
/// FIXME: this is sub-optimal. Refactor input_context into pinput_context
/// and pass this to ppreprocessor.
///
template <typename T> template <typename T>
ppreprocessor & process(T &&istrm) ppreprocessor & process(T &&istrm, const pstring &filename)
{ {
m_stack.emplace_back(input_context(std::forward<T>(istrm),"","<stream>")); m_stack.emplace_back(input_context(std::forward<T>(istrm),plib::util::path(filename), filename));
process_stack(); process_stack();
return *this; return *this;
} }

View File

@ -26,11 +26,13 @@
#define SLOW_BUT_ACCURATE 0 #define SLOW_BUT_ACCURATE 0
#ifndef __PLIB_PREPROCESSOR__
#if defined(__GNUC__) && !defined(__clang__) #if defined(__GNUC__) && !defined(__clang__)
#if defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) && ((__GNUC__ > 10) || ((__GNUC__ == 10) && (__GNUC_MINOR__ >= 0))) #if defined(__MINGW32__) && !defined(__x86_64) && defined(__i386__) && ((__GNUC__ > 10) || ((__GNUC__ == 10) && (__GNUC_MINOR__ >= 0)))
#pragma GCC optimize ("O1") #pragma GCC optimize ("O1")
#endif #endif
#endif #endif
#endif
NETLIST_START(palestra) NETLIST_START(palestra)