Implemented #527 (wildcard layer mapping targets)

commit d77702cd86066f3a97d740a95923fa598c2ff07b
Author: Matthias Koefferlein <[email protected]>
Date:   Sat Mar 28 21:28:39 2020 +0100

    Wildcard expansion feature on layer mapping

    Finished feature, added doc and test.

    The solution is to use placeholder indexes for the
    layer mapping which are substituted by the real
    layers when they are encountered.

commit af60b5f18acfe3c5e2f1d4e6bc6ee752a246dc0d
Author: Matthias Koefferlein <[email protected]>
Date:   Sat Mar 28 19:11:32 2020 +0100

    Preparations for new feature: introduce relative and wildcard target layer specs
This commit is contained in:
Matthias Koefferlein
2020-03-28 22:49:57 +01:00
parent 53f69ea90d
commit 99d3610a6a
16 changed files with 903 additions and 209 deletions
@@ -383,7 +383,7 @@ DXFReader::do_read (db::Layout &layout, db::cell_index_type top)
// create the zero layer - this is not mapped to GDS but can be specified in the layer mapping as
// a layer named "0".
std::pair<bool, unsigned int> ll = layer_map ().logical (zero_layer_name);
std::pair<bool, unsigned int> ll = layer_map ().logical (zero_layer_name, layout);
if (ll.first) {
// create the layer if it is not part of the layout yet.
@@ -176,7 +176,7 @@ GDS2ReaderBase::finish_element (db::PropertiesRepository &rep)
std::pair <bool, unsigned int>
GDS2ReaderBase::open_dl (db::Layout &layout, const LDPair &dl, bool create)
{
std::pair<bool, unsigned int> ll = m_layer_map.logical (dl);
std::pair<bool, unsigned int> ll = m_layer_map.logical (dl, layout);
if (ll.first) {
return ll;
@@ -391,3 +391,46 @@ TEST(Bug_121_2)
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
}
TEST(3_AdvancedMapping)
{
db::Manager m (false);
db::Layout layout (&m);
db::LoadLayoutOptions options;
db::LayerMap lm, lm_read;
unsigned int n = 0;
lm.map_expr ("*/*: *+100/*", n++);
lm.map_expr ("1/*: */*", n++);
lm.map_expr ("1/10: 1/0", n++);
lm.map_expr ("1/20-30: 1/*+1000", n++);
lm.map_expr ("2/*", n++);
lm.map_expr ("2/10-20: */*", n++);
options.get_options<db::CommonReaderOptions> ().layer_map = lm;
{
tl::InputStream file (tl::testsrc () + "/testdata/gds/alm.gds");
db::Reader reader (file);
lm_read = reader.read (layout, options);
}
EXPECT_EQ (lm_read.to_string_file_format (),
"1/10 : 1/0\n"
"2/0-9,21-*\n"
"1/0 : 1/0\n"
"1/1 : 1/1\n"
"1/20 : 1/1020\n"
"1/21 : 1/1021\n"
"2/10 : 2/10\n"
"2/11 : 2/11\n"
"42/42 : 142/42\n"
"100/0 : 200/0\n"
"2/12-20 : */*\n"
"1/22-30 : 1/*+1000\n"
"1/2-9,11-19,31-* : */*\n"
"0/*;3-41/*;42/0-41,43-*;43-99/*;100/1-*;101-*/* : *+100/*\n"
);
std::string fn_au (tl::testsrc () + "/testdata/gds/alm_au.gds");
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
}
@@ -174,7 +174,7 @@ LEFDEFLayerDelegate::open_layer (db::Layout &layout, const std::string &n, Layer
lp.datatype = 0;
}
std::pair<bool, unsigned int> ll = m_layer_map.logical (lp);
std::pair<bool, unsigned int> ll = m_layer_map.logical (lp, layout);
if (ll.first) {
@@ -243,7 +243,7 @@ LEFDEFLayerDelegate::open_layer (db::Layout &layout, const std::string &n, Layer
return std::make_pair (false, 0);
}
std::pair<bool, unsigned int> ll = m_layer_map.logical (name);
std::pair<bool, unsigned int> ll = m_layer_map.logical (name, layout);
if (ll.first) {
@@ -256,14 +256,14 @@ LEFDEFLayerDelegate::open_layer (db::Layout &layout, const std::string &n, Layer
} else {
std::pair<bool, unsigned int> ll_raw = m_layer_map.logical (n);
std::pair<bool, unsigned int> ll_raw = m_layer_map.logical (n, layout);
int ln = -1;
if (ll_raw.first && (ln = layout.get_properties (ll_raw.second).layer) >= 0) {
m_layer_map.map (db::LayerProperties (name), layout.layers (), db::LayerProperties (ln, dt, name));
m_layer_map.prepare (layout);
return m_layer_map.logical (name);
return m_layer_map.logical (name, layout);
} else if (! m_create_layers) {
@@ -554,7 +554,7 @@ OASISReader::warn (const std::string &msg)
std::pair <bool, unsigned int>
OASISReader::open_dl (db::Layout &layout, const LDPair &dl, bool create)
{
std::pair<bool, unsigned int> ll = m_layer_map.logical (dl);
std::pair<bool, unsigned int> ll = m_layer_map.logical (dl, layout);
if (ll.first) {
return ll;