diff --git a/src/layui/layui/layNetlistBrowserModel.cc b/src/layui/layui/layNetlistBrowserModel.cc index 8d88f1529..84f99efed 100644 --- a/src/layui/layui/layNetlistBrowserModel.cc +++ b/src/layui/layui/layNetlistBrowserModel.cc @@ -237,7 +237,9 @@ static std::string formatted_value (double v) { double va = fabs (v); - if (va < 100e-15) { + if (va < 1e-20) { + return "0"; + } else if (va < 100e-15) { return tl::to_string (v * 1e15) + "f"; } else if (va < 100e-12) { return tl::to_string (v * 1e12) + "p"; @@ -269,25 +271,50 @@ std::string device_parameter_string (const db::Device *device) } bool first = true; + std::string term; + const std::vector &pd = device->device_class ()->parameter_definitions (); + for (std::vector::const_iterator p = pd.begin (); p != pd.end (); ++p) { - double v = device->parameter_value (p->id ()); - if (v > 0.0) { + if (p->is_primary ()) { + double v = device->parameter_value (p->id ()); if (first) { s += " ["; - first = false; } else { s += ", "; } s += p->name (); s += "="; s += formatted_value (v); + term = "]"; + first = false; } } - if (! first) { - s += "]"; + + bool first_sec = true; + + for (std::vector::const_iterator p = pd.begin (); p != pd.end (); ++p) { + double v = device->parameter_value (p->id ()); + std::string vs = formatted_value (v); + std::string vs_def = formatted_value (p->default_value ()); + if (! p->is_primary () && vs != vs_def) { + if (first) { + s += " [("; + } else if (first_sec) { + s += ", ("; + } else { + s += ", "; + } + s += p->name (); + s += "="; + s += vs; + term = ")]"; + first = false; + first_sec = false; + } } - return s; + + return s + term; } static diff --git a/src/layui/unit_tests/layNetlistBrowserModelTests.cc b/src/layui/unit_tests/layNetlistBrowserModelTests.cc index b9f2e5032..b38eb945a 100644 --- a/src/layui/unit_tests/layNetlistBrowserModelTests.cc +++ b/src/layui/unit_tests/layNetlistBrowserModelTests.cc @@ -321,7 +321,7 @@ TEST (2) // INV2, net 1 has one pin and one terminal at BULK EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, inv2Net0Index), Qt::UserRole).toString ()), "B|B|PMOS|PMOS|$1|$1"); - EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, inv2Net0Index), Qt::DisplayRole).toString ()), "B / PMOS [L=0.25, W=3.5, AS=1.4, AD=1.4, PS=6.85, PD=6.85]"); + EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, inv2Net0Index), Qt::DisplayRole).toString ()), "B / PMOS [L=0.25, W=3.5, (AS=1.4, AD=1.4, PS=6.85, PD=6.85)]"); EXPECT_EQ (tl::to_string (model->data (model->index (0, 2, inv2Net0Index), Qt::DisplayRole).toString ()), "$1"); EXPECT_EQ (tl::to_string (model->data (model->index (0, 3, inv2Net0Index), Qt::DisplayRole).toString ()), "$1"); @@ -357,8 +357,8 @@ TEST (2) // first of devices in INV2 circuit EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, sn_devices), Qt::UserRole).toString ()), "$1|$1|PMOS|PMOS"); EXPECT_EQ (tl::to_string (model->data (model->index (0, 0, sn_devices), Qt::DisplayRole).toString ()), "PMOS"); - EXPECT_EQ (tl::to_string (model->data (model->index (0, 2, sn_devices), Qt::DisplayRole).toString ()), "$1 / PMOS [L=0.25, W=3.5, AS=1.4, AD=1.4, PS=6.85, PD=6.85]"); - EXPECT_EQ (tl::to_string (model->data (model->index (0, 3, sn_devices), Qt::DisplayRole).toString ()), "$1 / PMOS [L=0.25, W=3.5, AS=1.4, AD=1.4, PS=6.85, PD=6.85]"); + EXPECT_EQ (tl::to_string (model->data (model->index (0, 2, sn_devices), Qt::DisplayRole).toString ()), "$1 / PMOS [L=0.25, W=3.5, (AS=1.4, AD=1.4, PS=6.85, PD=6.85)]"); + EXPECT_EQ (tl::to_string (model->data (model->index (0, 3, sn_devices), Qt::DisplayRole).toString ()), "$1 / PMOS [L=0.25, W=3.5, (AS=1.4, AD=1.4, PS=6.85, PD=6.85)]"); QModelIndex inv2PairIndex = model->index (2, 0, QModelIndex ()); EXPECT_EQ (model->parent (inv2PairIndex).isValid (), false);