From 07ae4886525a805c2ab550d220dfbb4e10d33ba5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 4 Jul 2019 00:57:52 +0200 Subject: [PATCH] WIP: bugfix - don't uppercase file names in SPICE .include, typos fixed. --- src/db/db/dbNetlistSpiceReader.cc | 9 ++++++--- src/db/db/dbNetlistSpiceReader.h | 1 + src/db/db/gsiDeclDbNetlist.cc | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/db/db/dbNetlistSpiceReader.cc b/src/db/db/dbNetlistSpiceReader.cc index 204239ec1..93d6fee70 100644 --- a/src/db/db/dbNetlistSpiceReader.cc +++ b/src/db/db/dbNetlistSpiceReader.cc @@ -292,7 +292,7 @@ std::string NetlistSpiceReader::get_line () tl::Extractor ex (l.c_str ()); if (ex.test_without_case (".include")) { - std::string path = read_name (ex); + std::string path = read_name_with_case (ex); push_stream (path); @@ -564,7 +564,7 @@ inline static int hex_num (char c) } } -std::string NetlistSpiceReader::read_name (tl::Extractor &ex) +std::string NetlistSpiceReader::read_name_with_case (tl::Extractor &ex) { std::string n; ex.read_word_or_quoted (n, allowed_name_chars); @@ -603,10 +603,13 @@ std::string NetlistSpiceReader::read_name (tl::Extractor &ex) } } +} +std::string NetlistSpiceReader::read_name (tl::Extractor &ex) +{ // TODO: allow configuring Spice reader as case sensitive? // this is easy to do: just avoid to_upper here: - return tl::to_upper_case (nn); + return tl::to_upper_case (read_name_with_case (ex)); } bool NetlistSpiceReader::read_element (tl::Extractor &ex, const std::string &element, const std::string &name) diff --git a/src/db/db/dbNetlistSpiceReader.h b/src/db/db/dbNetlistSpiceReader.h index 6f400cb6e..056b2b2d4 100644 --- a/src/db/db/dbNetlistSpiceReader.h +++ b/src/db/db/dbNetlistSpiceReader.h @@ -139,6 +139,7 @@ private: void skip_circuit (tl::Extractor &ex); bool read_card (); double read_value (tl::Extractor &ex); + std::string read_name_with_case (tl::Extractor &ex); std::string read_name (tl::Extractor &ex); double read_atomic_value (tl::Extractor &ex); double read_dot_expr (tl::Extractor &ex); diff --git a/src/db/db/gsiDeclDbNetlist.cc b/src/db/db/gsiDeclDbNetlist.cc index 14ff416cc..5db3e0393 100644 --- a/src/db/db/gsiDeclDbNetlist.cc +++ b/src/db/db/gsiDeclDbNetlist.cc @@ -1507,12 +1507,10 @@ Class db_NetlistSpiceWriterDelegate ("db", "Netl "@brief Inserts a text for the given device class\n" "Reimplement this method to insert your own text at the beginning of the file for the given device class" ) + + gsi::method ("write_device", &NetlistSpiceWriterDelegateImpl::org_write_device, gsi::arg ("device"), "@hide") + gsi::callback ("write_device", &NetlistSpiceWriterDelegateImpl::reimpl_write_device, &NetlistSpiceWriterDelegateImpl::cb_write_device, gsi::arg ("device"), "@brief Inserts a text for the given device\n" - "Reimplement this method to write the given device in the desired way" - ) + - gsi::method ("write_device", &NetlistSpiceWriterDelegateImpl::org_write_device, gsi::arg ("device"), - "@brief Calls the default implementation of the \\write_device method.\n" + "Reimplement this method to write the given device in the desired way. " "The default implementation will utilize the device class information to write native SPICE " "elements for the devices." ) + @@ -1620,7 +1618,7 @@ Class db_NetlistSpiceWriter (db_NetlistWriter, "db", "Ne "@ul\n" "@li A global header (\\NetlistSpiceWriterDelegate#write_header): this method is called to print the part right after the headline @/li\n" "@li A per-device class header (\\NetlistSpiceWriterDelegate#write_device_intro): this method is called for every device class and may print device-class specific headers (e.g. model definitions) @/li\n" - "@li Per-device output: this method (\\NetlistSpiceWriterDelegate#write_device): this method is called for every device and may print the device statement(s) in a specific way.\n" + "@li Per-device output: this method (\\NetlistSpiceWriterDelegate#write_device): this method is called for every device and may print the device statement(s) in a specific way. @/li\n" "@/ul\n" "\n" "The delegate must use \\NetlistSpiceWriterDelegate#emit_line to print a line, \\NetlistSpiceWriterDelegate#emit_comment to print a comment etc.\n" @@ -1641,10 +1639,13 @@ Class db_NetlistSpiceWriter (db_NetlistWriter, "db", "Ne "\n" " def write_device(dev)\n" " if dev.device_class.name != \"MYDEVICE\"\n" - " emit_comment(\"Terminal #1: \" + net_to_string(dev.net_for_terminal(0)))\n" - " emit_comment(\"Terminal #2: \" + net_to_string(dev.net_for_terminal(1)))\n" - " super(dev)\n" - " emit_comment(\"After device \" + dev.expanded_name)\n" + " emit_comment(\"Terminal #1: \" + net_to_string(dev.net_for_terminal(0)))\n" + " emit_comment(\"Terminal #2: \" + net_to_string(dev.net_for_terminal(1)))\n" + " super(dev)\n" + " emit_comment(\"After device \" + dev.expanded_name)\n" + " else\n" + " super(dev)\n" + " end\n" " end\n" "\n" "end\n"