mirror of https://github.com/KLayout/klayout.git
Revert change of making spice parameters primary - will create problems in swappable parameters such as AD and AS
This commit is contained in:
parent
9f3d26af25
commit
4303e1ab73
|
|
@ -109,6 +109,52 @@ bool AllDeviceParametersAreEqual::less (const db::Device &a, const db::Device &b
|
|||
return false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// PrimaryDeviceParametersAreEqual class implementation
|
||||
|
||||
class DB_PUBLIC PrimaryDeviceParametersAreEqual
|
||||
: public DeviceParameterCompareDelegate
|
||||
{
|
||||
public:
|
||||
PrimaryDeviceParametersAreEqual (double relative);
|
||||
|
||||
virtual bool less (const db::Device &a, const db::Device &b) const;
|
||||
|
||||
virtual DeviceParameterCompareDelegate *clone () const
|
||||
{
|
||||
return new PrimaryDeviceParametersAreEqual (*this);
|
||||
}
|
||||
|
||||
private:
|
||||
double m_relative;
|
||||
};
|
||||
|
||||
PrimaryDeviceParametersAreEqual::PrimaryDeviceParametersAreEqual (double relative)
|
||||
: m_relative (relative)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
bool PrimaryDeviceParametersAreEqual::less (const db::Device &a, const db::Device &b) const
|
||||
{
|
||||
const std::vector<db::DeviceParameterDefinition> &pd = a.device_class ()->parameter_definitions ();
|
||||
for (std::vector<db::DeviceParameterDefinition>::const_iterator p = pd.begin (); p != pd.end (); ++p) {
|
||||
const db::DeviceParameterDefinition *pdb = b.device_class ()->parameter_definition (p->id ());
|
||||
if (! pdb) {
|
||||
continue;
|
||||
}
|
||||
if (! pdb->is_primary () && ! p->is_primary ()) {
|
||||
continue;
|
||||
}
|
||||
int cmp = compare_parameters (a.parameter_value (p->id ()), b.parameter_value (p->id ()), 0.0, m_relative);
|
||||
if (cmp != 0) {
|
||||
return cmp < 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
// DeviceClass class implementation
|
||||
|
||||
|
|
@ -236,6 +282,9 @@ size_t DeviceClass::terminal_id_for_name (const std::string &name) const
|
|||
// a default relative tolerance.
|
||||
const double relative_tolerance = 1e-6;
|
||||
|
||||
// The default compare delegate
|
||||
static PrimaryDeviceParametersAreEqual default_compare (relative_tolerance);
|
||||
|
||||
bool DeviceClass::less (const db::Device &a, const db::Device &b)
|
||||
{
|
||||
tl_assert (a.device_class () != 0);
|
||||
|
|
@ -245,25 +294,11 @@ bool DeviceClass::less (const db::Device &a, const db::Device &b)
|
|||
if (! pcd) {
|
||||
pcd = b.device_class ()->mp_pc_delegate.get ();
|
||||
}
|
||||
|
||||
if (pcd != 0) {
|
||||
return pcd->less (a, b);
|
||||
} else {
|
||||
|
||||
const std::vector<db::DeviceParameterDefinition> &pd = a.device_class ()->parameter_definitions ();
|
||||
for (std::vector<db::DeviceParameterDefinition>::const_iterator p = pd.begin (); p != pd.end (); ++p) {
|
||||
if (! p->is_primary ()) {
|
||||
continue;
|
||||
}
|
||||
int cmp = compare_parameters (a.parameter_value (p->id ()), b.parameter_value (p->id ()), 0.0, relative_tolerance);
|
||||
if (cmp != 0) {
|
||||
return cmp < 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
if (! pcd) {
|
||||
pcd = &default_compare;
|
||||
}
|
||||
|
||||
return pcd->less (a, b);
|
||||
}
|
||||
|
||||
bool DeviceClass::equal (const db::Device &a, const db::Device &b)
|
||||
|
|
@ -275,25 +310,11 @@ bool DeviceClass::equal (const db::Device &a, const db::Device &b)
|
|||
if (! pcd) {
|
||||
pcd = b.device_class ()->mp_pc_delegate.get ();
|
||||
}
|
||||
|
||||
if (pcd != 0) {
|
||||
return ! pcd->less (a, b) && ! pcd->less (b, a);
|
||||
} else {
|
||||
|
||||
const std::vector<db::DeviceParameterDefinition> &pd = a.device_class ()->parameter_definitions ();
|
||||
for (std::vector<db::DeviceParameterDefinition>::const_iterator p = pd.begin (); p != pd.end (); ++p) {
|
||||
if (! p->is_primary ()) {
|
||||
continue;
|
||||
}
|
||||
int cmp = compare_parameters (a.parameter_value (p->id ()), b.parameter_value (p->id ()), 0.0, relative_tolerance);
|
||||
if (cmp != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
if (! pcd) {
|
||||
pcd = &default_compare;
|
||||
}
|
||||
|
||||
return ! pcd->less (a, b) && ! pcd->less (b, a);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -625,8 +625,6 @@ bool NetlistSpiceReaderDelegate::element (db::Circuit *circuit, const std::strin
|
|||
std::map<std::string, double>::const_iterator v = params.find (i->name ());
|
||||
if (v != params.end ()) {
|
||||
device->set_parameter_value (i->id (), v->second / i->si_scaling ());
|
||||
// parameters read from the netlist are made primary so they are shown in the netlist browser
|
||||
cls->parameter_definition_non_const (i->id ())->set_is_primary (true);
|
||||
} else if (i->id () == defp) {
|
||||
device->set_parameter_value (i->id (), value / i->si_scaling ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "layIndexedNetlistModel.h"
|
||||
#include "layNetlistCrossReferenceModel.h"
|
||||
#include "dbNetlistDeviceClasses.h"
|
||||
#include "tlMath.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QIcon>
|
||||
|
|
@ -324,7 +325,8 @@ std::string device_parameter_string (const db::Device *device)
|
|||
bool first = true;
|
||||
const std::vector<db::DeviceParameterDefinition> &pd = device->device_class ()->parameter_definitions ();
|
||||
for (std::vector<db::DeviceParameterDefinition>::const_iterator p = pd.begin (); p != pd.end (); ++p) {
|
||||
if (p->is_primary ()) {
|
||||
double v = device->parameter_value (p->id ());
|
||||
if (! tl::equal (v, p->default_value ())) {
|
||||
if (first) {
|
||||
s += " [";
|
||||
first = false;
|
||||
|
|
@ -333,7 +335,7 @@ std::string device_parameter_string (const db::Device *device)
|
|||
}
|
||||
s += p->name ();
|
||||
s += "=";
|
||||
s += formatted_value (device->parameter_value (p->id ()));
|
||||
s += formatted_value (v);
|
||||
}
|
||||
}
|
||||
if (! first) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue