From 738e830c8d0d48b741ffbe95655650336018d5fb Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 15 Mar 2021 15:40:02 +0100 Subject: [PATCH] Important bug fix for LVS It's very important for LVS to use the same compare delegates for layout and schematic. Otherwise the sorting of the devices won't be identical and fake mismatches will occure. This is achieved in a bit hacky way to imposing the layout compare delegates to the schematic netlist. --- src/db/db/dbDeviceClass.h | 19 +++++++++++++++++++ src/db/db/dbNetlistCompare.cc | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/db/db/dbDeviceClass.h b/src/db/db/dbDeviceClass.h index 96bb0dc6e..d77048e2b 100644 --- a/src/db/db/dbDeviceClass.h +++ b/src/db/db/dbDeviceClass.h @@ -252,6 +252,7 @@ public: DeviceParameterCompareDelegate () { } virtual ~DeviceParameterCompareDelegate () { } + virtual DeviceParameterCompareDelegate *clone () const = 0; virtual bool less (const db::Device &a, const db::Device &b) const = 0; virtual bool equal (const db::Device &a, const db::Device &b) const = 0; }; @@ -273,6 +274,11 @@ public: virtual bool less (const db::Device &a, const db::Device &b) const; virtual bool equal (const db::Device &a, const db::Device &b) const; + virtual DeviceParameterCompareDelegate *clone () const + { + return new EqualDeviceParameters (*this); + } + EqualDeviceParameters &operator+= (const EqualDeviceParameters &other); EqualDeviceParameters operator+ (const EqualDeviceParameters &other) const @@ -298,6 +304,11 @@ public: virtual bool less (const db::Device &a, const db::Device &b) const; virtual bool equal (const db::Device &a, const db::Device &b) const; + virtual DeviceParameterCompareDelegate *clone () const + { + return new AllDeviceParametersAreEqual (*this); + } + private: double m_relative; }; @@ -574,6 +585,14 @@ public: /** * @brief Gets the parameter compare delegate or null if no such delegate is registered */ + const db::DeviceParameterCompareDelegate *parameter_compare_delegate () const + { + return mp_pc_delegate.get (); + } + + /** + * @brief Gets the parameter compare delegate or null if no such delegate is registered (non-const version) + */ db::DeviceParameterCompareDelegate *parameter_compare_delegate () { return mp_pc_delegate.get (); diff --git a/src/db/db/dbNetlistCompare.cc b/src/db/db/dbNetlistCompare.cc index d687a9e3f..99ad08829 100644 --- a/src/db/db/dbNetlistCompare.cc +++ b/src/db/db/dbNetlistCompare.cc @@ -2991,6 +2991,23 @@ NetlistComparer::compare (const db::Netlist *a, const db::Netlist *b) const } } + // impose the compare tolerances of the layout (first netlist) on the schematic (second netlist) + // TODO: this is kind of clumsy. But it's very important to use the same device sorting for both netlists, so we play this trick. + // A better solution was to have a common compare framework for both netlists. + for (std::map >::const_iterator i = cat2dc.begin (); i != cat2dc.end (); ++i) { + + if (i->second.first && i->second.second) { + + const db::DeviceClass *da = i->second.first; + db::DeviceClass *db = const_cast (i->second.second); + + const db::DeviceParameterCompareDelegate *cmp = da->parameter_compare_delegate (); + db->set_parameter_compare_delegate (cmp ? cmp->clone () : 0); + + } + + } + // device whether to use a device category in strict mode device_categorizer.clear_strict_device_categories ();