From 8b6d6cef5204d893c6452967c518a4cc4d64f9bc Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 31 May 2026 20:39:48 +0200 Subject: [PATCH] WIP --- src/db/db/dbNetlistSpiceReaderDelegate.cc | 2 +- src/db/db/dbNetlistSpiceWriter.cc | 6 +++--- src/db/db/gsiDeclDbNetlistSpiceReader.cc | 16 ++++++++++++++++ src/db/db/gsiDeclDbNetlistSpiceWriter.cc | 16 ++++++++++++++++ src/db/unit_tests/dbNetlistReaderTests.cc | 8 -------- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/db/db/dbNetlistSpiceReaderDelegate.cc b/src/db/db/dbNetlistSpiceReaderDelegate.cc index b95750a80..fc707a2cf 100644 --- a/src/db/db/dbNetlistSpiceReaderDelegate.cc +++ b/src/db/db/dbNetlistSpiceReaderDelegate.cc @@ -47,7 +47,7 @@ NetlistSpiceReaderOptions::NetlistSpiceReaderOptions () // ------------------------------------------------------------------------------------------------------ NetlistSpiceReaderDelegate::NetlistSpiceReaderDelegate () - : mp_netlist (0), m_options (), m_profile (), m_read_all_parameters (true) + : mp_netlist (0), m_options (), m_profile (), m_read_all_parameters (false) { // .. nothing yet .. } diff --git a/src/db/db/dbNetlistSpiceWriter.cc b/src/db/db/dbNetlistSpiceWriter.cc index 947a452cf..f91c2c962 100644 --- a/src/db/db/dbNetlistSpiceWriter.cc +++ b/src/db/db/dbNetlistSpiceWriter.cc @@ -44,7 +44,7 @@ static const char *s_not_connect_prefix = "nc_"; // -------------------------------------------------------------------------------- NetlistSpiceWriterDelegate::NetlistSpiceWriterDelegate () - : mp_writer (0), mp_netlist (0), m_write_all_parameters (true) + : mp_writer (0), mp_netlist (0), m_write_all_parameters (false) { // .. nothing yet .. } @@ -288,9 +288,9 @@ std::string NetlistSpiceWriterDelegate::format_params (const db::Device &dev, si double sis = i->si_scaling (); // for compatibility if (fabs (sis * 1e6 - 1.0) < db::epsilon) { - os << tl::to_string (v) << "U"; + os << tl::to_string (v.to_double ()) << "U"; } else if (fabs (sis * 1e12 - 1.0) < db::epsilon) { - os << tl::to_string (v) << "P"; + os << tl::to_string (v.to_double ()) << "P"; } else { os << tl::to_string (v.to_double () * sis); } diff --git a/src/db/db/gsiDeclDbNetlistSpiceReader.cc b/src/db/db/gsiDeclDbNetlistSpiceReader.cc index 56f58e739..2b9ac667a 100644 --- a/src/db/db/gsiDeclDbNetlistSpiceReader.cc +++ b/src/db/db/gsiDeclDbNetlistSpiceReader.cc @@ -418,6 +418,22 @@ Class db_NetlistSpiceReaderDelegate ("db", "Netl gsi::method_ext ("parse_element", &parse_element_fb, "@hide") + gsi::method_ext ("control_statement", &control_statement_fb, "@hide") + gsi::method_ext ("translate_net_name", &translate_net_name_fb, "@hide") + + gsi::method ("read_all_parameters=", &NetlistSpiceReaderDelegateImpl::read_all_parameters, + "@brief Sets a flag indicating whether to read all device parameters.\n" + "If this flag is set to true, all parameters of the devices are read in the default implementation. " + "If set to false (the default), only known parameters (i.e. only parameters declared by the device classes in the netlist) are read.\n" + "\n" + "Note, that you can customize the reader's device input also by reimplementing \\parse_element or \\element. This reimplementation may " + "chose to ignore the \\read_all_parameters attribute.\n" + "\n" + "This attribute has been introduced in version 0.31.0." + ) + + gsi::method ("read_all_parameters=", &NetlistSpiceReaderDelegateImpl::set_read_all_parameters, gsi::arg ("f"), + "@brief Gets a flag indicating whether to read all device parameters.\n" + "See \\read_all_parameters= for a description of this attribute.\n" + "\n" + "This attribute has been introduced in version 0.31.0." + ) + gsi::callback ("start", &NetlistSpiceReaderDelegateImpl::start, &NetlistSpiceReaderDelegateImpl::cb_start, gsi::arg ("netlist"), "@brief This method is called when the reader starts reading a netlist\n" ) + diff --git a/src/db/db/gsiDeclDbNetlistSpiceWriter.cc b/src/db/db/gsiDeclDbNetlistSpiceWriter.cc index f7206d5d0..774692fde 100644 --- a/src/db/db/gsiDeclDbNetlistSpiceWriter.cc +++ b/src/db/db/gsiDeclDbNetlistSpiceWriter.cc @@ -133,6 +133,22 @@ Class db_NetlistSpiceWriterDelegate ("db", "Netl ) + gsi::method ("format_name", &NetlistSpiceWriterDelegateImpl::format_name, gsi::arg ("name"), "@brief Formats the given name in a SPICE-compatible way" + ) + + gsi::method ("write_all_parameters=", &NetlistSpiceWriterDelegateImpl::set_write_all_parameters, + "@brief Sets a flag indicating whether to write all device parameters.\n" + "If this flag is set to true, all parameters of the devices are written in the default implementation. " + "If set to false (the default), only primary parameters are written.\n" + "\n" + "Note, that you can customize the writer's device output also by reimplementing \\write_device. This reimplementation may " + "chose to ignore the \\write_all_parameters attribute.\n" + "\n" + "This attribute has been introduced in version 0.31.0." + ) + + gsi::method ("write_all_parameters=", &NetlistSpiceWriterDelegateImpl::set_write_all_parameters, gsi::arg ("f"), + "@brief Gets a flag indicating whether to write all device parameters.\n" + "See \\write_all_parameters= for a description of this attribute.\n" + "\n" + "This attribute has been introduced in version 0.31.0." ), "@brief Provides a delegate for the SPICE writer for doing special formatting for devices\n" "Supply a customized class to provide a specialized writing scheme for devices. " diff --git a/src/db/unit_tests/dbNetlistReaderTests.cc b/src/db/unit_tests/dbNetlistReaderTests.cc index 77db5d44e..ca26e68f8 100644 --- a/src/db/unit_tests/dbNetlistReaderTests.cc +++ b/src/db/unit_tests/dbNetlistReaderTests.cc @@ -379,7 +379,6 @@ TEST(9_DeviceMultipliers) { db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl); @@ -426,7 +425,6 @@ TEST(9_DeviceMultipliers) // read once again, this time with known classes (must not trigger issue-652) { db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl); @@ -646,7 +644,6 @@ TEST(17_RecursiveExpansion) std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader17.cir"); db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl); @@ -683,7 +680,6 @@ TEST(17_RecursiveExpansion) std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader17b.cir"); db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl2); @@ -699,7 +695,6 @@ TEST(18_XSchemOutput) std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader18.cir"); db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl); @@ -735,7 +730,6 @@ TEST(19_ngspice_ref) std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader19.cir"); db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl); @@ -772,7 +766,6 @@ TEST(19b_ngspice_ref) std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader19b.cir"); db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl); @@ -809,7 +802,6 @@ TEST(20_precendence) std::string path = tl::combine_path (tl::combine_path (tl::testdata (), "algo"), "nreader20.cir"); db::NetlistSpiceReader reader; - reader.delegate ()->set_read_all_parameters (false); tl::InputStream is (path); reader.read (is, nl);