mirror of https://github.com/KLayout/klayout.git
WIP: Spice reader - resolve model and net names by variables
This commit is contained in:
parent
18f2b57c3d
commit
44e123f343
|
|
@ -193,14 +193,28 @@ void NetlistSpiceReaderDelegate::parse_element_components (const std::string &s,
|
||||||
std::string n;
|
std::string n;
|
||||||
|
|
||||||
if (ex.try_read_word (n) && ex.test ("=")) {
|
if (ex.try_read_word (n) && ex.test ("=")) {
|
||||||
|
|
||||||
// a parameter. Note that parameter names are always made upper case.
|
// a parameter. Note that parameter names are always made upper case.
|
||||||
pv.insert (std::make_pair (tl::to_upper_case (n), read_value (ex, variables)));
|
pv.insert (std::make_pair (tl::to_upper_case (n), read_value (ex, variables)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// a net/model component
|
||||||
ex = ex0;
|
ex = ex0;
|
||||||
if (in_params) {
|
if (in_params) {
|
||||||
ex.error (tl::to_string (tr ("Invalid syntax for parameter assignment - needs keyword followed by '='")));
|
ex.error (tl::to_string (tr ("Invalid syntax for parameter assignment - needs keyword followed by '='")));
|
||||||
}
|
}
|
||||||
strings.push_back (parse_component (ex));
|
|
||||||
|
std::string comp_name = parse_component (ex);
|
||||||
|
|
||||||
|
// resolve variables if string type
|
||||||
|
auto v = variables.find (comp_name);
|
||||||
|
if (v != variables.end () && v->second.is_a_string ()) {
|
||||||
|
comp_name = v->second.to_string ();
|
||||||
|
}
|
||||||
|
|
||||||
|
strings.push_back (comp_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -525,24 +539,14 @@ bool NetlistSpiceReaderDelegate::element (db::Circuit *circuit, const std::strin
|
||||||
double
|
double
|
||||||
NetlistSpiceReaderDelegate::read_value (tl::Extractor &ex, const std::map<std::string, tl::Variant> &variables)
|
NetlistSpiceReaderDelegate::read_value (tl::Extractor &ex, const std::map<std::string, tl::Variant> &variables)
|
||||||
{
|
{
|
||||||
std::map<std::string, tl::Variant> vvariables;
|
NetlistSpiceReaderExpressionParser parser (&variables);
|
||||||
for (auto i = variables.begin (); i != variables.end (); ++i) {
|
|
||||||
vvariables.insert (std::make_pair (i->first, tl::Variant (i->second)));
|
|
||||||
}
|
|
||||||
|
|
||||||
NetlistSpiceReaderExpressionParser parser (&vvariables);
|
|
||||||
return parser.read (ex).to_double ();
|
return parser.read (ex).to_double ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NetlistSpiceReaderDelegate::try_read_value (const std::string &s, double &v, const std::map<std::string, tl::Variant> &variables)
|
NetlistSpiceReaderDelegate::try_read_value (const std::string &s, double &v, const std::map<std::string, tl::Variant> &variables)
|
||||||
{
|
{
|
||||||
std::map<std::string, tl::Variant> vvariables;
|
NetlistSpiceReaderExpressionParser parser (&variables);
|
||||||
for (auto i = variables.begin (); i != variables.end (); ++i) {
|
|
||||||
vvariables.insert (std::make_pair (i->first, tl::Variant (i->second)));
|
|
||||||
}
|
|
||||||
|
|
||||||
NetlistSpiceReaderExpressionParser parser (&vvariables);
|
|
||||||
|
|
||||||
tl::Variant vv;
|
tl::Variant vv;
|
||||||
tl::Extractor ex (s.c_str ());
|
tl::Extractor ex (s.c_str ());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue