From 1f63aaabf51e4e57f20acb48521828ab1acb2544 Mon Sep 17 00:00:00 2001
From: Matthias Koefferlein
Date: Sat, 13 Jun 2026 19:18:20 +0200
Subject: [PATCH] WIP, debugging tests
---
src/db/db/dbNetlistDeviceClasses.cc | 3 +-
src/db/db/dbNetlistSpiceWriter.cc | 16 ++++++-----
src/db/db/dbNetlistSpiceWriter.h | 2 +-
src/db/unit_tests/dbNetlistCompareTests.cc | 2 +-
src/doc/doc/about/expressions.xml | 33 ++++++++++++++++++++++
5 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/src/db/db/dbNetlistDeviceClasses.cc b/src/db/db/dbNetlistDeviceClasses.cc
index 57c9bd1f1..90993cadd 100644
--- a/src/db/db/dbNetlistDeviceClasses.cc
+++ b/src/db/db/dbNetlistDeviceClasses.cc
@@ -502,8 +502,9 @@ DeviceClassResistor::DeviceClassResistor ()
{ "M", "" }, // drop
// apply scaling if available
{ "R", "(R||$)/M" },
+ { "L", "L*M" },
+ { "W", "W" },
{ "A", "A*M" },
- { "W", "W*M" },
{ "P", "P*M" }
};
diff --git a/src/db/db/dbNetlistSpiceWriter.cc b/src/db/db/dbNetlistSpiceWriter.cc
index f91c2c962..cb7eb95b8 100644
--- a/src/db/db/dbNetlistSpiceWriter.cc
+++ b/src/db/db/dbNetlistSpiceWriter.cc
@@ -99,7 +99,7 @@ void NetlistSpiceWriterDelegate::write_device (const db::Device &dev) const
const db::DeviceClass *dc = dev.device_class ();
const db::DeviceClass::SpiceProfile &profile = dc->spice_profile (mp_writer->profile ());
- if (! profile.element.empty ()) {
+ if (! profile.outgoing_parameters.empty ()) {
write_device_profile (dev, profile);
} else {
write_device_default (dev);
@@ -113,7 +113,6 @@ void NetlistSpiceWriterDelegate::write_device_profile (const db::Device &dev, co
os << profile.element;
os << format_name (dev.expanded_name ());
os << format_terminals_with_order (dev, profile.terminal_order);
- os << " ";
if (! dev.device_class ()->name ().empty ()) {
os << " ";
os << format_name (dev.device_class ()->name ());
@@ -152,7 +151,7 @@ void NetlistSpiceWriterDelegate::write_device_default (const db::Device &dev) co
os << format_name (dev.device_class ()->name ());
}
- os << format_params (dev, db::DeviceClassCapacitor::param_id_C);
+ os << format_params (dev, db::DeviceClassCapacitor::param_id_C, true);
} else if (ind) {
@@ -165,7 +164,7 @@ void NetlistSpiceWriterDelegate::write_device_default (const db::Device &dev) co
os << " ";
os << format_name (dev.device_class ()->name ());
}
- os << format_params (dev, db::DeviceClassInductor::param_id_L);
+ os << format_params (dev, db::DeviceClassInductor::param_id_L, true);
} else if (res || res3) {
@@ -178,7 +177,7 @@ void NetlistSpiceWriterDelegate::write_device_default (const db::Device &dev) co
os << " ";
os << format_name (dev.device_class ()->name ());
}
- os << format_params (dev, db::DeviceClassResistor::param_id_R);
+ os << format_params (dev, db::DeviceClassResistor::param_id_R, true);
} else if (diode) {
@@ -270,9 +269,12 @@ std::string NetlistSpiceWriterDelegate::format_terminals_with_order (const db::D
return os.str ();
}
-std::string NetlistSpiceWriterDelegate::format_params (const db::Device &dev, size_t without_id) const
+std::string NetlistSpiceWriterDelegate::format_params (const db::Device &dev, size_t without_id, bool only_primary) const
{
- bool only_primary = ! m_write_all_parameters;
+ if (m_write_all_parameters) {
+ only_primary = false;
+ }
+
std::ostringstream os;
const std::vector &pd = dev.device_class ()->parameter_definitions ();
diff --git a/src/db/db/dbNetlistSpiceWriter.h b/src/db/db/dbNetlistSpiceWriter.h
index 1577a9a18..03ccbbfbc 100644
--- a/src/db/db/dbNetlistSpiceWriter.h
+++ b/src/db/db/dbNetlistSpiceWriter.h
@@ -67,7 +67,7 @@ public:
std::string format_name (const std::string &s) const;
std::string format_terminals (const db::Device &dev, size_t max_terminals = std::numeric_limits::max ()) const;
std::string format_terminals_with_order (const db::Device &dev, const std::vector &terminal_order) const;
- std::string format_params (const db::Device &dev, size_t without_id = std::numeric_limits::max ()) const;
+ std::string format_params (const db::Device &dev, size_t without_id = std::numeric_limits::max (), bool only_primary = false) const;
private:
friend class NetlistSpiceWriter;
diff --git a/src/db/unit_tests/dbNetlistCompareTests.cc b/src/db/unit_tests/dbNetlistCompareTests.cc
index 49a64c93b..e2f31a414 100644
--- a/src/db/unit_tests/dbNetlistCompareTests.cc
+++ b/src/db/unit_tests/dbNetlistCompareTests.cc
@@ -4673,7 +4673,7 @@ TEST(26_JoinSymmetricNets)
nl.combine_devices ();
EXPECT_EQ (nl.to_string (),
"circuit RESCUBE (A=A,B=B);\n"
- " device RES $10 (A=A,B=B) (R=833.333333333,L=0,W=0,A=0,P=0);\n"
+ " device RES $10 (A=A,B=B) (R=833.333333333333,L=0,W=0,A=0,P=0);\n"
"end;\n"
)
}
diff --git a/src/doc/doc/about/expressions.xml b/src/doc/doc/about/expressions.xml
index 4f350f1b0..5d0b21ec1 100644
--- a/src/doc/doc/about/expressions.xml
+++ b/src/doc/doc/about/expressions.xml
@@ -75,6 +75,39 @@ Box.new(-10, 0, 90, 60).width
as "false" but as "true"!
+
+ The "nil" value shortcuts numerical expressions the following way:
+
+
+
+nil + x -> nil
+x + nil -> x
+nil + nil -> nil
+
+
+
+ The same applies to the other binary operators "*", "/", "-", "&" "|", "<< and ">>".
+
+
+
+ The unary operators "-" and "~" deliver "nil" when used with a "nil" argument.
+
+
+
+ The logical binary operators "||" and "&&" behave this way:
+
+
+
+x || y -> x if x is not "nil" or "false", y otherwise
+x || nil -> x
+nil || x -> x
+nil || nil -> nil
+x && y -> y if x is not "nil" or "false", x otherwise
+x && nil -> nil
+nil && x -> nil
+nil && nil -> nil
+
+
Constants