Added strm2mag tool and support for Magic options

This commit is contained in:
Matthias Koefferlein 2019-11-30 20:54:15 +01:00
parent f16a5085c5
commit 6003727561
11 changed files with 132 additions and 3 deletions

View File

@ -21,6 +21,7 @@ SOURCES = \
strmcmp.cc \
strmxor.cc \
strmrun.cc \
strm2mag.cc
HEADERS = \
bdCommon.h \

View File

@ -48,7 +48,11 @@ GenericReaderOptions::GenericReaderOptions ()
m_dxf_contour_accuracy (0.0),
m_dxf_render_texts_as_polygons (false),
m_dxf_keep_layer_names (false),
m_dxf_keep_other_cells (false)
m_dxf_keep_other_cells (false),
m_magic_lambda (1.0),
m_magic_dbu (0.001),
m_magic_keep_layer_names (false),
m_magic_merge (true)
{
// .. nothing yet ..
}
@ -238,6 +242,27 @@ GenericReaderOptions::add_options (tl::CommandLineOptions &cmd)
)
;
}
{
std::string group ("[" + m_group_prefix + " options - MAG (Magic) specific]");
cmd << tl::arg (group +
"--" + m_long_prefix + "magic-lambda=lambda", &m_magic_lambda, "Specifies the lambda value",
"The lambda value is used as a scaling factor to turn the dimensionless Magic drawings into "
"physical layout."
)
<< tl::arg (group +
"#!--" + m_long_prefix + "magic-dont-merge", &m_magic_merge, "Disables polygon merging",
"With this option, the rectangles and triangles of the Magic file are not merged into polygons."
)
<< tl::arg (group +
"--" + m_long_prefix + "magic-lib-path=path", &m_magic_lib_path, "Specifies the library search path for Magic file loading",
"The library search path gives the locations where the reader looks up files for child cells. "
"This option either specifies a comma-separated list of paths to search or it can be present multiple times "
"for multiple search locations."
)
;
}
}
void GenericReaderOptions::set_layer_map (const std::string &lm)
@ -256,12 +281,14 @@ void GenericReaderOptions::set_read_named_layers (bool f)
{
m_dxf_keep_layer_names = f;
m_cif_keep_layer_names = f;
m_magic_keep_layer_names = f;
}
void GenericReaderOptions::set_dbu (double dbu)
{
m_dxf_dbu = dbu;
m_cif_dbu = dbu;
m_magic_dbu = dbu;
}
void
@ -297,6 +324,14 @@ GenericReaderOptions::configure (db::LoadLayoutOptions &load_options) const
load_options.set_option_by_name ("dxf_render_texts_as_polygons", m_dxf_render_texts_as_polygons);
load_options.set_option_by_name ("dxf_keep_layer_names", m_dxf_keep_layer_names);
load_options.set_option_by_name ("dxf_keep_other_cells", m_dxf_keep_other_cells);
load_options.set_option_by_name ("mag_layer_map", tl::Variant::make_variant (m_layer_map));
load_options.set_option_by_name ("mag_create_other_layers", m_create_other_layers);
load_options.set_option_by_name ("mag_dbu", m_magic_dbu);
load_options.set_option_by_name ("mag_lambda", m_magic_lambda);
load_options.set_option_by_name ("mag_merge", m_magic_merge);
load_options.set_option_by_name ("mag_keep_layer_names", m_magic_keep_layer_names);
load_options.set_option_by_name ("mag_library_paths", tl::Variant (m_magic_lib_path.begin (), m_magic_lib_path.end ()));
}
}

View File

@ -130,6 +130,13 @@ private:
bool m_dxf_keep_layer_names;
bool m_dxf_keep_other_cells;
// MAGIC
double m_magic_lambda;
double m_magic_dbu;
bool m_magic_keep_layer_names;
bool m_magic_merge;
std::vector<std::string> m_magic_lib_path;
void set_layer_map (const std::string &lm);
void set_dbu (double dbu);
void set_read_named_layers (bool f);

View File

@ -53,6 +53,7 @@ GenericWriterOptions::GenericWriterOptions ()
m_oasis_subst_char ("*"),
m_cif_dummy_calls (false),
m_cif_blank_separator (false),
m_magic_lambda (1.0),
m_dxf_polygon_mode (0)
{
// .. nothing yet ..
@ -63,6 +64,7 @@ const std::string GenericWriterOptions::gds2text_format_name = "GDS2Text"; //
const std::string GenericWriterOptions::oasis_format_name = "OASIS";
const std::string GenericWriterOptions::dxf_format_name = "DXF";
const std::string GenericWriterOptions::cif_format_name = "CIF";
const std::string GenericWriterOptions::mag_format_name = "MAG";
void
GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::string &format)
@ -267,6 +269,21 @@ GenericWriterOptions::add_options (tl::CommandLineOptions &cmd, const std::strin
;
}
if (format.empty () || format == mag_format_name) {
// Add MAG format options
std::string group = "[Output options - MAG (Magic) specific]";
cmd << tl::arg (group +
"--magic-lambda-out=lambda", &m_magic_lambda, "Specifies the lambda value when writing Magic files (which are unitless)"
)
<< tl::arg (group +
"--magic-tech", &m_magic_tech, "Specifies the technology to include in the Magic files"
)
;
}
}
void GenericWriterOptions::set_oasis_substitution_char (const std::string &text)
@ -353,6 +370,9 @@ GenericWriterOptions::configure (db::SaveLayoutOptions &save_options, const db::
save_options.set_option_by_name ("dxf_polygon_mode", m_dxf_polygon_mode);
save_options.set_option_by_name ("mag_lambda", m_magic_lambda);
save_options.set_option_by_name ("mag_tech", m_magic_tech);
if (!m_cell_selection.empty ()) {
std::set<db::cell_index_type> selected;

View File

@ -103,6 +103,7 @@ public:
static const std::string oasis_format_name;
static const std::string cif_format_name;
static const std::string dxf_format_name;
static const std::string mag_format_name;
private:
double m_scale_factor;
@ -133,6 +134,9 @@ private:
bool m_cif_dummy_calls;
bool m_cif_blank_separator;
double m_magic_lambda;
std::string m_magic_tech;
int m_dxf_polygon_mode;
void set_oasis_substitution_char (const std::string &text);

View File

@ -0,0 +1,29 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2019 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "bdConverterMain.h"
#include "bdWriterOptions.h"
BD_PUBLIC int strm2mag (int argc, char *argv[])
{
return bd::converter_main (argc, argv, bd::GenericWriterOptions::mag_format_name);
}

View File

@ -8,6 +8,7 @@ SUBDIRS = \
strm2gds \
strm2gdstxt \
strm2oas \
strm2mag \
strm2txt \
strmclip \
strmcmp \
@ -19,6 +20,7 @@ strm2dxf.depends += bd
strm2gds.depends += bd
strm2gdstxt.depends += bd
strm2oas.depends += bd
strm2mag.depends += bd
strm2txt.depends += bd
strmclip.depends += bd
strmcmp.depends += bd

View File

@ -0,0 +1,2 @@
include($$PWD/../buddy_app.pri)

View File

@ -158,3 +158,31 @@ TEST(5)
db::compare_layouts (this, layout, input, db::NoNormalization);
}
// Testing the converter main implementation (MAG)
TEST(6)
{
std::string input = tl::testsrc ();
input += "/testdata/gds/t10.gds";
std::string input_au = tl::testsrc ();
input_au += "/testdata/magic/strm2mag_au.gds";
std::string output = this->tmp_file ("RINGO.mag");
const char *argv[] = { "x", input.c_str (), output.c_str (), "--magic-lambda-out=0.005" };
EXPECT_EQ (bd::converter_main (sizeof (argv) / sizeof (argv[0]), (char **) argv, bd::GenericWriterOptions::mag_format_name), 0);
db::Layout layout;
{
tl::InputStream stream (output);
db::LoadLayoutOptions options;
options.set_option_by_name ("mag_lambda", 0.005);
db::Reader reader (stream);
reader.read (layout, options);
EXPECT_EQ (reader.format (), "MAG");
}
db::compare_layouts (this, layout, input_au, db::WriteGDS2);
}

View File

@ -38,7 +38,7 @@ class Buddies_TestClass < TestBase
def test_basic
# Basic - buddies can be called
%w(strm2cif strm2dxf strm2gds strm2gdstxt strm2oas strm2txt strmclip strmcmp strmrun strmxor).each do |bin|
%w(strm2cif strm2dxf strm2gds strm2gdstxt strm2oas strm2mag strm2txt strmclip strmcmp strmrun strmxor).each do |bin|
version = bin + " " + `#{self.buddy_bin(bin)} --version`
assert_equal(version =~ /^#{bin} \d+\./, 0)
end
@ -54,6 +54,7 @@ class Buddies_TestClass < TestBase
"strm2gdstxt" => 0x48454144,
"strm2oas" => 0x2553454d,
"strm2txt" => 0x62656769,
"strm2mag" => 0x0,
}
# Windows CRLF -> LF translation
@ -61,7 +62,7 @@ class Buddies_TestClass < TestBase
0x300d0a53 => 0x300a5345
}
%w(strm2cif strm2dxf strm2gds strm2gdstxt strm2oas strm2txt).each do |bin|
%w(strm2cif strm2dxf strm2gds strm2gdstxt strm2oas strm2txt strm2mag).each do |bin|
puts "Testing #{bin} ..."

BIN
testdata/magic/strm2mag_au.gds vendored Normal file

Binary file not shown.