mirror of https://github.com/KLayout/klayout.git
Fixed issue #1245 by using a smarter implementation for the backward compatibility fallback. Added unit tests and new (old) GSI bindings for that purpose.
This commit is contained in:
parent
5952974095
commit
500fee3ff6
|
|
@ -498,6 +498,7 @@ NetTracerTechnologyComponent::NetTracerTechnologyComponent ()
|
||||||
// NetTracerConnectivity implementation
|
// NetTracerConnectivity implementation
|
||||||
|
|
||||||
NetTracerConnectivity::NetTracerConnectivity ()
|
NetTracerConnectivity::NetTracerConnectivity ()
|
||||||
|
: m_is_fallback_default (false)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
@ -510,6 +511,7 @@ NetTracerConnectivity::NetTracerConnectivity (const NetTracerConnectivity &d)
|
||||||
NetTracerConnectivity &NetTracerConnectivity::operator= (const NetTracerConnectivity &d)
|
NetTracerConnectivity &NetTracerConnectivity::operator= (const NetTracerConnectivity &d)
|
||||||
{
|
{
|
||||||
if (this != &d) {
|
if (this != &d) {
|
||||||
|
m_is_fallback_default = d.m_is_fallback_default;
|
||||||
m_connections = d.m_connections;
|
m_connections = d.m_connections;
|
||||||
m_symbols = d.m_symbols;
|
m_symbols = d.m_symbols;
|
||||||
m_name = d.m_name;
|
m_name = d.m_name;
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,16 @@ public:
|
||||||
NetTracerConnectivity (const NetTracerConnectivity &d);
|
NetTracerConnectivity (const NetTracerConnectivity &d);
|
||||||
NetTracerConnectivity &operator= (const NetTracerConnectivity &d);
|
NetTracerConnectivity &operator= (const NetTracerConnectivity &d);
|
||||||
|
|
||||||
|
bool is_fallback_default () const
|
||||||
|
{
|
||||||
|
return m_is_fallback_default;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_fallback_default (bool f)
|
||||||
|
{
|
||||||
|
m_is_fallback_default = f;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &name () const
|
const std::string &name () const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
|
|
@ -491,6 +501,7 @@ private:
|
||||||
std::vector<NetTracerConnectionInfo> m_connections;
|
std::vector<NetTracerConnectionInfo> m_connections;
|
||||||
std::vector<NetTracerSymbolInfo> m_symbols;
|
std::vector<NetTracerSymbolInfo> m_symbols;
|
||||||
std::string m_name, m_description;
|
std::string m_name, m_description;
|
||||||
|
bool m_is_fallback_default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DB_PLUGIN_PUBLIC NetTracerTechnologyComponent
|
class DB_PLUGIN_PUBLIC NetTracerTechnologyComponent
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,18 @@ namespace tl
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const db::NetTracerConnectivity *
|
||||||
|
get_fallback_default (const db::NetTracerTechnologyComponent &tc)
|
||||||
|
{
|
||||||
|
for (auto d = tc.begin (); d != tc.end (); ++d) {
|
||||||
|
if (d->is_fallback_default ()) {
|
||||||
|
return d.operator-> ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const db::NetTracerConnectivity *
|
static const db::NetTracerConnectivity *
|
||||||
get_default (const db::NetTracerTechnologyComponent &tc)
|
get_default (const db::NetTracerTechnologyComponent &tc)
|
||||||
{
|
{
|
||||||
|
|
@ -88,28 +100,29 @@ get_default (const db::NetTracerTechnologyComponent &tc)
|
||||||
template <class Value>
|
template <class Value>
|
||||||
struct FallbackXMLWriteAdaptor
|
struct FallbackXMLWriteAdaptor
|
||||||
{
|
{
|
||||||
FallbackXMLWriteAdaptor (void (db::NetTracerConnectivity::*member) (const Value &), void (db::NetTracerConnectivity::*clear) ())
|
FallbackXMLWriteAdaptor (void (db::NetTracerConnectivity::*member) (const Value &))
|
||||||
: mp_member (member), mp_clear (clear)
|
: mp_member (member)
|
||||||
{
|
{
|
||||||
// .. nothing yet ..
|
// .. nothing yet ..
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator () (db::NetTracerTechnologyComponent &owner, tl::XMLReaderState &reader) const
|
void operator () (db::NetTracerTechnologyComponent &owner, tl::XMLReaderState &reader) const
|
||||||
{
|
{
|
||||||
db::NetTracerConnectivity *stack = const_cast<db::NetTracerConnectivity *> (get_default (owner));
|
db::NetTracerConnectivity *stack = const_cast<db::NetTracerConnectivity *> (get_fallback_default (owner));
|
||||||
if (! stack) {
|
if (! stack && owner.begin () == owner.end ()) {
|
||||||
owner.push_back (db::NetTracerConnectivity ());
|
owner.push_back (db::NetTracerConnectivity ());
|
||||||
stack = (owner.end () - 1).operator-> ();
|
stack = (owner.end () - 1).operator-> ();
|
||||||
|
stack->set_fallback_default (true);
|
||||||
}
|
}
|
||||||
(stack->*mp_clear) ();
|
|
||||||
|
|
||||||
|
if (stack) {
|
||||||
tl::XMLObjTag<Value> tag;
|
tl::XMLObjTag<Value> tag;
|
||||||
(stack->*mp_member) (*reader.back (tag));
|
(stack->*mp_member) (*reader.back (tag));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void (db::NetTracerConnectivity::*mp_member) (const Value &);
|
void (db::NetTracerConnectivity::*mp_member) (const Value &);
|
||||||
void (db::NetTracerConnectivity::*mp_clear) ();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Value, class Iter>
|
template <class Value, class Iter>
|
||||||
|
|
@ -184,10 +197,10 @@ public:
|
||||||
// Fallback readers for migrating pre-0.28 setups to 0.28 and backward compatibility
|
// Fallback readers for migrating pre-0.28 setups to 0.28 and backward compatibility
|
||||||
tl::XMLMember<NetTracerConnectionInfo, NetTracerTechnologyComponent, FallbackXMLReadAdaptor <NetTracerConnectionInfo, NetTracerConnectivity::const_iterator>, FallbackXMLWriteAdaptor <NetTracerConnectionInfo>, tl::XMLStdConverter <NetTracerConnectionInfo> > (
|
tl::XMLMember<NetTracerConnectionInfo, NetTracerTechnologyComponent, FallbackXMLReadAdaptor <NetTracerConnectionInfo, NetTracerConnectivity::const_iterator>, FallbackXMLWriteAdaptor <NetTracerConnectionInfo>, tl::XMLStdConverter <NetTracerConnectionInfo> > (
|
||||||
FallbackXMLReadAdaptor <NetTracerConnectionInfo, NetTracerConnectivity::const_iterator> (&NetTracerConnectivity::begin, &NetTracerConnectivity::end),
|
FallbackXMLReadAdaptor <NetTracerConnectionInfo, NetTracerConnectivity::const_iterator> (&NetTracerConnectivity::begin, &NetTracerConnectivity::end),
|
||||||
FallbackXMLWriteAdaptor <NetTracerConnectionInfo> (&NetTracerConnectivity::add, &NetTracerConnectivity::clear_connections), "connection") +
|
FallbackXMLWriteAdaptor <NetTracerConnectionInfo> (&NetTracerConnectivity::add), "connection") +
|
||||||
tl::XMLMember<NetTracerSymbolInfo, NetTracerTechnologyComponent, FallbackXMLReadAdaptor <NetTracerSymbolInfo, NetTracerConnectivity::const_symbol_iterator>, FallbackXMLWriteAdaptor <NetTracerSymbolInfo>, tl::XMLStdConverter <NetTracerSymbolInfo> > (
|
tl::XMLMember<NetTracerSymbolInfo, NetTracerTechnologyComponent, FallbackXMLReadAdaptor <NetTracerSymbolInfo, NetTracerConnectivity::const_symbol_iterator>, FallbackXMLWriteAdaptor <NetTracerSymbolInfo>, tl::XMLStdConverter <NetTracerSymbolInfo> > (
|
||||||
FallbackXMLReadAdaptor <NetTracerSymbolInfo, NetTracerConnectivity::const_symbol_iterator> (&NetTracerConnectivity::begin_symbols, &NetTracerConnectivity::end_symbols),
|
FallbackXMLReadAdaptor <NetTracerSymbolInfo, NetTracerConnectivity::const_symbol_iterator> (&NetTracerConnectivity::begin_symbols, &NetTracerConnectivity::end_symbols),
|
||||||
FallbackXMLWriteAdaptor <NetTracerSymbolInfo> (&NetTracerConnectivity::add_symbol, &NetTracerConnectivity::clear_symbols), "symbols")
|
FallbackXMLWriteAdaptor <NetTracerSymbolInfo> (&NetTracerConnectivity::add_symbol), "symbols")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,41 @@ static void def_symbol (db::NetTracerConnectivity *tech, const std::string &name
|
||||||
tech->add_symbol (db::NetTracerSymbolInfo (db::LayerProperties (name), expr));
|
tech->add_symbol (db::NetTracerSymbolInfo (db::LayerProperties (name), expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string get_layer_a (const db::NetTracerConnectionInfo *info)
|
||||||
|
{
|
||||||
|
return info->layer_a ().to_string ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string get_via_layer (const db::NetTracerConnectionInfo *info)
|
||||||
|
{
|
||||||
|
return info->via_layer ().to_string ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string get_layer_b (const db::NetTracerConnectionInfo *info)
|
||||||
|
{
|
||||||
|
return info->layer_b ().to_string ();
|
||||||
|
}
|
||||||
|
|
||||||
|
gsi::Class<db::NetTracerConnectionInfo> decl_NetTracerConnectionInfo ("db", "NetTracerConnectionInfo",
|
||||||
|
gsi::method_ext ("layer_a", &get_layer_a, "@brief Gets the expression for the A layer") +
|
||||||
|
gsi::method_ext ("via_layer", &get_via_layer, "@brief Gets the expression for the Via layer") +
|
||||||
|
gsi::method_ext ("layer_b", &get_layer_b, "@brief Gets the expression for the B layer"),
|
||||||
|
"@brief Represents a single connection info line for the net tracer technology definition\n"
|
||||||
|
"This class has been introduced in version 0.28.3."
|
||||||
|
);
|
||||||
|
|
||||||
|
static std::string get_symbol (const db::NetTracerSymbolInfo *info)
|
||||||
|
{
|
||||||
|
return info->symbol ().to_string ();
|
||||||
|
}
|
||||||
|
|
||||||
|
gsi::Class<db::NetTracerSymbolInfo> decl_NetTracerSymbolInfo ("db", "NetTracerSymbolInfo",
|
||||||
|
gsi::method_ext ("symbol", &get_symbol, "@brief Gets the symbol") +
|
||||||
|
gsi::method ("expression", &db::NetTracerSymbolInfo::expression, "@brief Gets the expression"),
|
||||||
|
"@brief Represents a single symbol info line for the net tracer technology definition\n"
|
||||||
|
"This class has been introduced in version 0.28.3."
|
||||||
|
);
|
||||||
|
|
||||||
gsi::Class<db::NetTracerConnectivity> decl_NetTracerConnectivity ("db", "NetTracerConnectivity",
|
gsi::Class<db::NetTracerConnectivity> decl_NetTracerConnectivity ("db", "NetTracerConnectivity",
|
||||||
gsi::method ("name", &db::NetTracerConnectivity::name,
|
gsi::method ("name", &db::NetTracerConnectivity::name,
|
||||||
"@brief Gets the name of the connectivty definition\n"
|
"@brief Gets the name of the connectivty definition\n"
|
||||||
|
|
@ -79,6 +114,14 @@ gsi::Class<db::NetTracerConnectivity> decl_NetTracerConnectivity ("db", "NetTrac
|
||||||
"@brief Defines a symbol for use in the material expressions.\n"
|
"@brief Defines a symbol for use in the material expressions.\n"
|
||||||
"Defines a sub-expression to be used in further symbols or material expressions. "
|
"Defines a sub-expression to be used in further symbols or material expressions. "
|
||||||
"For the detailed notation of the expression see the description of the net tracer feature."
|
"For the detailed notation of the expression see the description of the net tracer feature."
|
||||||
|
) +
|
||||||
|
gsi::iterator ("each_connection", static_cast<db::NetTracerConnectivity::const_iterator (db::NetTracerConnectivity::*) () const> (&db::NetTracerConnectivity::begin), static_cast<db::NetTracerConnectivity::const_iterator (db::NetTracerConnectivity::*) () const> (&db::NetTracerConnectivity::end),
|
||||||
|
"@brief Gets the connection information.\n"
|
||||||
|
"This iterator method has been introduced in version 0.28.3.\n"
|
||||||
|
) +
|
||||||
|
gsi::iterator ("each_symbol", static_cast<db::NetTracerConnectivity::const_symbol_iterator (db::NetTracerConnectivity::*) () const> (&db::NetTracerConnectivity::begin_symbols), static_cast<db::NetTracerConnectivity::const_symbol_iterator (db::NetTracerConnectivity::*) () const> (&db::NetTracerConnectivity::end_symbols),
|
||||||
|
"@brief Gets the symbol information.\n"
|
||||||
|
"This iterator method has been introduced in version 0.28.3.\n"
|
||||||
),
|
),
|
||||||
"@brief A connectivity description for the net tracer\n"
|
"@brief A connectivity description for the net tracer\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
@ -99,6 +142,18 @@ gsi::Class<db::NetTracerConnectivity> decl_NetTracerConnectivity ("db", "NetTrac
|
||||||
"has been generalized.\n"
|
"has been generalized.\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
DB_PUBLIC gsi::Class<db::TechnologyComponent> &decl_dbTechnologyComponent ();
|
||||||
|
|
||||||
|
gsi::Class<db::NetTracerTechnologyComponent> decl_NetTracerTechnologyComponent (decl_dbTechnologyComponent (), "db", "NetTracerTechnologyComponent",
|
||||||
|
gsi::iterator ("each", static_cast<db::NetTracerTechnologyComponent::const_iterator (db::NetTracerTechnologyComponent::*) () const> (&db::NetTracerTechnologyComponent::begin), static_cast<db::NetTracerTechnologyComponent::const_iterator (db::NetTracerTechnologyComponent::*) () const> (&db::NetTracerTechnologyComponent::end),
|
||||||
|
"@brief Gets the connectivity definitions from the net tracer technology component.\n"
|
||||||
|
),
|
||||||
|
"@brief Represents the technology information for the net tracer.\n"
|
||||||
|
"This class has been redefined in version 0.28 and re-introduced in version 0.28.3. Since version 0.28, "
|
||||||
|
"multiple stacks are supported and the individual stack definition is provided through a list of stacks. Use \\each "
|
||||||
|
"to iterate the stacks."
|
||||||
|
);
|
||||||
|
|
||||||
static void trace1 (db::NetTracer *net_tracer, const db::NetTracerConnectivity &tech, const db::Layout &layout, const db::Cell &cell, const db::Point &start_point, unsigned int start_layer)
|
static void trace1 (db::NetTracer *net_tracer, const db::NetTracerConnectivity &tech, const db::Layout &layout, const db::Cell &cell, const db::Point &start_point, unsigned int start_layer)
|
||||||
{
|
{
|
||||||
db::NetTracerData tracer_data = tech.get_tracer_data (layout);
|
db::NetTracerData tracer_data = tech.get_tracer_data (layout);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,14 @@ end
|
||||||
|
|
||||||
load("test_prologue.rb")
|
load("test_prologue.rb")
|
||||||
|
|
||||||
|
def nt_tech_to_s(t)
|
||||||
|
t.each.collect do |s|
|
||||||
|
([ "Stack [" + s.name + "]:" ] +
|
||||||
|
s.each_connection.collect { |c| " conn: " + c.layer_a + "," + c.via_layer + "," + c.layer_b } +
|
||||||
|
s.each_symbol.collect { |c| " symbol: " + c.symbol + "=" + c.expression }).join("\n")
|
||||||
|
end.join("\n") + "\n"
|
||||||
|
end
|
||||||
|
|
||||||
class LAYTechnologies_TestClass < TestBase
|
class LAYTechnologies_TestClass < TestBase
|
||||||
|
|
||||||
def test_1
|
def test_1
|
||||||
|
|
@ -117,7 +125,88 @@ END
|
||||||
|
|
||||||
assert_equal(tech.component_names.size > 0, true)
|
assert_equal(tech.component_names.size > 0, true)
|
||||||
assert_equal(tech.component_names.find("connectivity") != nil, true)
|
assert_equal(tech.component_names.find("connectivity") != nil, true)
|
||||||
assert_equal(tech.component("connectivity").class.to_s, "RBA::TechnologyComponent")
|
assert_equal(tech.component("connectivity").class.to_s, "RBA::NetTracerTechnologyComponent")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# issue 1245
|
||||||
|
def test_3
|
||||||
|
|
||||||
|
# empty connectivity
|
||||||
|
tech = RBA::Technology::technology_from_xml(<<END)
|
||||||
|
<technology>
|
||||||
|
<name>X</name>
|
||||||
|
<connectivity/>
|
||||||
|
</technology>
|
||||||
|
END
|
||||||
|
|
||||||
|
nt_tech = tech.component("connectivity")
|
||||||
|
|
||||||
|
assert_equal(nt_tech_to_s(nt_tech), "\n")
|
||||||
|
|
||||||
|
# 0.27 to 0.28 migration
|
||||||
|
tech = RBA::Technology::technology_from_xml(<<END)
|
||||||
|
<technology>
|
||||||
|
<name>X</name>
|
||||||
|
<connectivity>
|
||||||
|
<connection>11,2,3</connection>
|
||||||
|
<connection>14,5,6</connection>
|
||||||
|
<symbols>AA=17</symbols>
|
||||||
|
<symbols>BB=42</symbols>
|
||||||
|
</connectivity>
|
||||||
|
</technology>
|
||||||
|
END
|
||||||
|
|
||||||
|
nt_tech = tech.component("connectivity")
|
||||||
|
|
||||||
|
assert_equal(nt_tech_to_s(nt_tech), <<END)
|
||||||
|
Stack []:
|
||||||
|
conn: 11,2,3
|
||||||
|
conn: 14,5,6
|
||||||
|
symbol: AA=17
|
||||||
|
symbol: BB=42
|
||||||
|
END
|
||||||
|
|
||||||
|
# 0.28 way
|
||||||
|
tech = RBA::Technology::technology_from_xml(<<END)
|
||||||
|
<technology>
|
||||||
|
<name>X</name>
|
||||||
|
<connectivity>
|
||||||
|
<stack>
|
||||||
|
<name>ST1</name>
|
||||||
|
<connection>1,2,3</connection>
|
||||||
|
<connection>4,5,6</connection>
|
||||||
|
<symbols>A=17</symbols>
|
||||||
|
<symbols>B=42</symbols>
|
||||||
|
</stack>
|
||||||
|
<stack>
|
||||||
|
<name>ST2</name>
|
||||||
|
<connection>1,2,3</connection>
|
||||||
|
<connection>4,5,7</connection>
|
||||||
|
<symbols>A=1</symbols>
|
||||||
|
</stack>
|
||||||
|
<!-- ignored: -->
|
||||||
|
<connection>1,2,3</connection>
|
||||||
|
<connection>4,5,6</connection>
|
||||||
|
<symbols>AA=17</symbols>
|
||||||
|
<symbols>BB=42</symbols>
|
||||||
|
</connectivity>
|
||||||
|
</technology>
|
||||||
|
END
|
||||||
|
|
||||||
|
nt_tech = tech.component("connectivity")
|
||||||
|
|
||||||
|
assert_equal(nt_tech_to_s(nt_tech), <<END)
|
||||||
|
Stack [ST1]:
|
||||||
|
conn: 1,2,3
|
||||||
|
conn: 4,5,6
|
||||||
|
symbol: A=17
|
||||||
|
symbol: B=42
|
||||||
|
Stack [ST2]:
|
||||||
|
conn: 1,2,3
|
||||||
|
conn: 4,5,7
|
||||||
|
symbol: A=1
|
||||||
|
END
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue