WIP: removed traces of CIF copy

This commit is contained in:
Matthias Koefferlein 2019-11-28 00:45:47 +01:00
parent 4ac5801cc7
commit 11e3209d4a
7 changed files with 52 additions and 38 deletions

View File

@ -62,6 +62,17 @@ MAGWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::SaveLa
m_layer_names.clear ();
m_timestamp = 0; // @@@ set timestamp?
double lambda = m_options.lambda;
if (lambda <= 0.0) {
const std::string &lv = layout.meta_info_value ("lambda");
if (lv.empty ()) {
throw tl::Exception (tl::to_string (tr ("No lambda value configured for MAG writer and no 'lambda' metadata present in layout.")));
}
tl::from_string (lv, lambda);
}
m_sf = layout.dbu () / lambda;
if (layout.end_top_cells () - layout.begin_top_down () == 1) {
// write the one top cell to the given stream. Otherwise
@ -155,7 +166,9 @@ MAGWriter::write_cell (db::cell_index_type ci, db::Layout &layout, tl::OutputStr
if (! cell.shapes (li).empty ()) {
os << "<< " << tl::to_word_or_quoted_string (layer_name (li, layout)) << " >>\n";
for (db::Shapes::shape_iterator s = cell.shapes (li).begin (db::ShapeIterator::Boxes | db::ShapeIterator::Polygons | db::ShapeIterator::Paths); ! s.at_end (); ++s) {
write_polygon (s->polygon (), layout, os);
db::Polygon poly;
s->polygon (poly);
write_polygon (poly, layout, os);
}
}
@ -168,7 +181,9 @@ MAGWriter::write_cell (db::cell_index_type ci, db::Layout &layout, tl::OutputStr
if (! any) {
os << "<< labels >>\n";
}
write_label (layer_name ((*i).first, layout), s->text (), layout, os);
db::Text text;
s->text (text);
write_label (layer_name ((*i).first, layout), text, layout, os);
}
}
@ -210,16 +225,16 @@ namespace {
}
void
MAGWriter::write_polygon (const db::Polygon &poly, const db::Layout &layout, tl::OutputStream &os)
MAGWriter::write_polygon (const db::Polygon &poly, const db::Layout & /*layout*/, tl::OutputStream &os)
{
TrapezoidWriter writer (os, layout.dbu () / m_options.lambda);
TrapezoidWriter writer (os, m_sf);
db::decompose_trapezoids (poly, TD_simple, writer);
}
void
MAGWriter::write_label (const std::string &layer, const db::Text &text, const db::Layout &layout, tl::OutputStream &os)
MAGWriter::write_label (const std::string &layer, const db::Text &text, const db::Layout & /*layout*/, tl::OutputStream &os)
{
db::DVector v = db::DVector (text.trans ().disp ()) * (layout.dbu () / m_options.lambda);
db::DVector v = db::DVector (text.trans ().disp ()) * m_sf;
std::string s = text.string ();
if (s.find ("\n") != std::string::npos) {
@ -232,8 +247,6 @@ MAGWriter::write_label (const std::string &layer, const db::Text &text, const db
void
MAGWriter::write_instance (const db::CellInstArray &inst, const db::Layout &layout, tl::OutputStream &os)
{
double sf = layout.dbu () / m_options.lambda;
int id = (m_cell_id [inst.object ().cell_index ()] += 1);
std::string cn = layout.cell_name (inst.object ().cell_index ());
os << "use " << tl::to_word_or_quoted_string (cn) << " " << tl::to_word_or_quoted_string (cn + "_" + tl::to_string (id));
@ -243,7 +256,7 @@ MAGWriter::write_instance (const db::CellInstArray &inst, const db::Layout &layo
db::ICplxTrans tr = inst.complex_trans ();
db::Matrix2d m = tr.to_matrix2d ();
db::DVector d = db::DVector (tr.disp ()) * sf;
db::DVector d = db::DVector (tr.disp ()) * m_sf;
os << "transform " << m.m11 () << " " << m.m12 () << " " << d.x () << " " << m.m21 () << " " << m.m22 () << " " << d.y () << "\n";
{
@ -259,15 +272,15 @@ MAGWriter::write_instance (const db::CellInstArray &inst, const db::Layout &layo
std::swap (na, nb);
}
db::DVector da = db::DVector (a) * sf;
db::DVector db = db::DVector (b) * sf;
db::DVector da = db::DVector (a) * m_sf;
db::DVector db = db::DVector (b) * m_sf;
os << "array " << 0 << " " << (na - 1) << " " << da.x () << " " << 0 << " " << (nb - 1) << " " << db.y () << "\n";
}
}
{
db::DBox b = db::DBox (inst.bbox (db::box_convert<db::CellInst> ())) * sf;
db::DBox b = db::DBox (inst.bbox (db::box_convert<db::CellInst> ())) * m_sf;
os << "box " << b.left () << " " << b.bottom () << " " << b.right () << " " << b.top () << "\n";
}
}

View File

@ -72,6 +72,7 @@ private:
std::map<unsigned int, std::string> m_layer_names;
size_t m_timestamp;
std::map<db::cell_index_type, size_t> m_cell_id;
double m_sf;
std::string filename_for_cell (db::cell_index_type ci, db::Layout &layout);
void write_cell (db::cell_index_type ci, db::Layout &layout, tl::OutputStream &os);

View File

@ -1,5 +1,5 @@
TARGET = cif
TARGET = mag
DESTDIR = $$OUT_PWD/../../../../db_plugins
include($$PWD/../../../db_plugin.pri)

View File

@ -32,7 +32,7 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>CIF Writer Options</string>
<string>Magic Writer Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">

View File

@ -1,12 +1,12 @@
TARGET = cif_ui
TARGET = mag_ui
DESTDIR = $$OUT_PWD/../../../../lay_plugins
include($$PWD/../../../lay_plugin.pri)
INCLUDEPATH += $$PWD/../db_plugin
DEPENDPATH += $$PWD/../db_plugin
LIBS += -L$$DESTDIR/../db_plugins -lcif
LIBS += -L$$DESTDIR/../db_plugins -lmag
!isEmpty(RPATH) {
QMAKE_RPATHDIR += $$RPATH/db_plugins

View File

@ -55,11 +55,11 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
options.set_options (opt);
db::Manager m;
db::Layout layout (&m), layout2 (&m), layout2_cif (&m), layout_au (&m);
db::Layout layout (&m), layout2 (&m), layout2_mag (&m), layout_au (&m);
{
std::string fn (base);
fn += "/testdata/cif/";
fn += "/testdata/mag/";
fn += file;
tl::InputStream stream (fn);
db::Reader reader (stream);
@ -75,7 +75,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
// normalize the layout by writing to GDS and reading from ..
std::string tmp_gds_file = _this->tmp_file (tl::sprintf ("tmp_%x.gds", hash));
std::string tmp_cif_file = _this->tmp_file (tl::sprintf ("tmp_%x.cif", hash));
std::string tmp_mag_file = _this->tmp_file (tl::sprintf ("tmp_%x.mag", hash));
{
tl::OutputStream stream (tmp_gds_file);
@ -94,7 +94,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
// normalize the layout by writing to MAG and reading from ..
{
tl::OutputStream stream (tmp_cif_file);
tl::OutputStream stream (tmp_mag_file);
db::MAGWriterOptions *opt = new db::MAGWriterOptions();
opt->lambda = 0.5;
@ -106,7 +106,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
}
{
tl::InputStream stream (tmp_cif_file);
tl::InputStream stream (tmp_mag_file);
db::MAGReaderOptions *opt = new db::MAGReaderOptions();
opt->dbu = dbu;
@ -114,12 +114,12 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
reread_options.set_options (opt);
db::Reader reader (stream);
reader.read (layout2_cif, reread_options);
reader.read (layout2_mag, reread_options);
}
{
std::string fn (base);
fn += "/testdata/cif/";
fn += "/testdata/mag/";
fn += file_au;
tl::InputStream stream (fn);
db::Reader reader (stream);
@ -131,67 +131,67 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char *
_this->raise (tl::sprintf ("Compare failed after reading - see %s vs %s\n", tmp_gds_file, file_au));
}
equal = db::compare_layouts (layout, layout2_cif, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 1);
equal = db::compare_layouts (layout, layout2_mag, db::layout_diff::f_boxes_as_polygons | db::layout_diff::f_verbose | db::layout_diff::f_flatten_array_insts, 1);
if (! equal) {
_this->raise (tl::sprintf ("Compare failed after writing - see %s vs %s\n", file, tmp_cif_file));
_this->raise (tl::sprintf ("Compare failed after writing - see %s vs %s\n", file, tmp_mag_file));
}
}
#if 0 // @@@
TEST(1a)
{
run_test (_this, tl::testsrc_private (), "t1.cif.gz", "t1a_au.gds.gz");
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1a_au.gds.gz");
}
TEST(1b)
{
run_test (_this, tl::testsrc_private (), "t1.cif.gz", "t1b_au.gds.gz", 0, 0.01);
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1b_au.gds.gz", 0, 0.01);
}
TEST(1c)
{
run_test (_this, tl::testsrc_private (), "t1.cif.gz", "t1b_au.gds.gz", 0, 0.01, true);
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1b_au.gds.gz", 0, 0.01, true);
}
TEST(1d)
{
run_test (_this, tl::testsrc_private (), "t1.cif.gz", "t1b_au.gds.gz", 0, 0.01, false, true);
run_test (_this, tl::testsrc_private (), "t1.mag.gz", "t1b_au.gds.gz", 0, 0.01, false, true);
}
TEST(2)
{
run_test (_this, tl::testsrc_private (), "t2.cif.gz", "t2_au.gds.gz");
run_test (_this, tl::testsrc_private (), "t2.mag.gz", "t2_au.gds.gz");
}
TEST(3a)
{
run_test (_this, tl::testsrc_private (), "t3.cif.gz", "t3a_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26");
run_test (_this, tl::testsrc_private (), "t3.mag.gz", "t3a_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26");
}
TEST(3b)
{
run_test (_this, tl::testsrc_private (), "t3.cif.gz", "t3b_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26", 0.00012);
run_test (_this, tl::testsrc_private (), "t3.mag.gz", "t3b_au.gds.gz", "CAA:43,CCA:48,CCP:47,CMF:49,CMS:51,CPG:46,CSN:45,CSP:44,CVA:50,CWN:42,XP:26", 0.00012);
}
TEST(4)
{
run_test (_this, tl::testsrc_private (), "t4.cif.gz", "t4_au.gds.gz");
run_test (_this, tl::testsrc_private (), "t4.mag.gz", "t4_au.gds.gz");
}
TEST(5)
{
run_test (_this, tl::testsrc_private (), "t5.cif.gz", "t5_au.gds.gz");
run_test (_this, tl::testsrc_private (), "t5.mag.gz", "t5_au.gds.gz");
}
// Issue #28
TEST(lasi)
{
run_test (_this, tl::testsrc (), "lasi.cif.gz", "lasi_au.gds.gz");
run_test (_this, tl::testsrc (), "lasi.mag.gz", "lasi_au.gds.gz");
}
// Issue #305
TEST(rot_boxes)
{
run_test (_this, tl::testsrc (), "issue_305.cif", "issue_305_au.gds");
run_test (_this, tl::testsrc (), "issue_305.mag", "issue_305_au.gds");
}
#endif // @@@

View File

@ -1,7 +1,7 @@
DESTDIR_UT = $$OUT_PWD/../../../..
TARGET = cif_tests
TARGET = mag_tests
include($$PWD/../../../../lib_ut.pri)
@ -16,4 +16,4 @@ LIBS += -L$$DESTDIR_UT -lklayout_db -lklayout_tl -lklayout_gsi
PLUGINPATH = $$OUT_PWD/../../../../db_plugins
QMAKE_RPATHDIR += $$PLUGINPATH
LIBS += -L$$PLUGINPATH -lcif
LIBS += -L$$PLUGINPATH -lmag