Skip to content

Commit

Permalink
Merge pull request #1502 from KLayout/issue-1499
Browse files Browse the repository at this point in the history
Fixed issue #1499 (strm2oas: support LAYER <layername> TYPE OVERLAP ;…
  • Loading branch information
klayoutmatthias authored Nov 7, 2023
2 parents 6a58745 + ac4b02c commit 42183ef
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "dbLEFDEFImporter.h"
#include "dbLayoutUtils.h"
#include "dbTechnology.h"
#include "dbShapeProcessor.h"

#include "tlStream.h"
#include "tlProgress.h"
Expand Down Expand Up @@ -480,6 +481,55 @@ GeometryBasedLayoutGenerator::add_via (const std::string &vn, const db::Trans &t
m_vias.back ().top_mask = top_mask;
}

void
GeometryBasedLayoutGenerator::subtract_overlap_from_outline (const std::set<std::string> &overlap_layers)
{
db::Shapes all_overlaps;

std::vector<std::map <std::pair<std::string, LayerDetailsKey>, db::Shapes>::iterator> to_remove;
for (auto s = m_shapes.begin (); s != m_shapes.end (); ++s) {
if (overlap_layers.find (s->first.first) != overlap_layers.end ()) {
all_overlaps.insert (s->second);
to_remove.push_back (s);
}
}

for (auto i = to_remove.begin (); i != to_remove.end (); ++i) {
m_shapes.erase (*i);
}

if (all_overlaps.empty ()) {
return;
}

for (auto s = m_shapes.begin (); s != m_shapes.end (); ++s) {

if (s->first.second.purpose != Outline) {
continue;
}

db::ShapeProcessor proc;

size_t pn = 0;
for (auto sh = s->second.begin (db::ShapeIterator::All); ! sh.at_end (); ++sh) {
proc.insert (*sh, pn);
pn += 2;
}

pn = 1;
for (auto sh = all_overlaps.begin (db::ShapeIterator::All); ! sh.at_end (); ++sh) {
proc.insert (*sh, pn);
pn += 2;
}

db::BooleanOp op (db::BooleanOp::And);
db::ShapeGenerator sg (s->second, true /*clear shapes*/);
db::PolygonGenerator out (sg, true, true);
proc.process (out, op);

}
}

// -----------------------------------------------------------------------------------
// LEFDEFTechnologyComponent implementation

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,8 @@ class DB_PLUGIN_PUBLIC GeometryBasedLayoutGenerator
m_fixedmask = f;
}

void subtract_overlap_from_outline (const std::set<std::string> &overlap_layers);

private:
struct Via {
Via () : bottom_mask (0), cut_mask (0), top_mask (0) { }
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ LEFImporter::read_layer (Layout & /*layout*/)
m_routing_layers.insert (ln);
} else if (type == "CUT") {
m_cut_layers.insert (ln);
} else if (type == "OVERLAP") {
m_overlap_layers.insert (ln);
}
expect (";");

Expand Down Expand Up @@ -1029,6 +1031,7 @@ LEFImporter::read_macro (Layout &layout)
}

mg->add_box (std::string (), Outline, db::Box (-origin, -origin + size), 0, 0);
mg->subtract_overlap_from_outline (m_overlap_layers);

MacroDesc macro_desc;
macro_desc.foreign_name = foreign_name;
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/streamers/lefdef/db_plugin/dbLEFImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class DB_PLUGIN_PUBLIC LEFImporter
return m_cut_layers.find (layer) != m_cut_layers.end ();
}

/**
* @brief Returns true if the given layer is an overlap layer
*/
bool is_overlap_layer (const std::string &layer) const
{
return m_overlap_layers.find (layer) != m_overlap_layers.end ();
}

/**
* @brief Returns the number of masks for the given layer
*/
Expand Down Expand Up @@ -141,7 +149,7 @@ class DB_PLUGIN_PUBLIC LEFImporter
std::map<std::string, std::pair<double, double> > m_min_widths;
std::map<std::string, MacroDesc> m_macros;
std::map<std::string, ViaDesc> m_vias;
std::set<std::string> m_routing_layers, m_cut_layers;
std::set<std::string> m_routing_layers, m_cut_layers, m_overlap_layers;
std::map<std::string, unsigned int> m_num_masks;

std::vector <db::Trans> get_iteration (double dbu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,10 @@ TEST(209_invalid_split_paths)
run_test (_this, "issue-1472", "map:tech.map+lef:tech.lef.gz+def:test.def.gz", "au.oas", default_options (), false);
}

// issue-1499
TEST(210_overlaps)
{
run_test (_this, "issue-1499", "map:tech.map+lef:tech.lef+lef:blocks.lef+def:top.def", "au.oas", default_options (), false);
}


Binary file added testdata/lefdef/issue-1499/au.oas
Binary file not shown.
31 changes: 31 additions & 0 deletions testdata/lefdef/issue-1499/blocks.lef
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
VERSION 5.8 ;

MACRO a
ORIGIN 0 0 ;
SIZE 600 BY 600 ;
OBS
LAYER M1 ;
RECT 10 10 590 590 ;
END
END a

MACRO b
ORIGIN -600 0 ;
SIZE 400 BY 500 ;
OBS
LAYER M1 ;
RECT 610 10 990 490 ;
END
END b

MACRO c
ORIGIN -500 -500 ;
SIZE 500 BY 500 ;
OBS
LAYER M1 ;
POLYGON 510 610 610 610 610 510 990 510 990 990 510 990 ;
LAYER overlap ;
RECT 500 700 1000 1000 ;
POLYGON 500 600 600 600 600 500 1000 500 1000 700 500 700 ;
END
END c
12 changes: 12 additions & 0 deletions testdata/lefdef/issue-1499/tech.lef
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
VERSION 5.8 ;

LAYER M1
TYPE ROUTING ;
DIRECTION HORIZONTAL ;
WIDTH 0.1 ;
PITCH 0.1 ;
END M1

LAYER overlap
TYPE OVERLAP ;
END overlap
6 changes: 6 additions & 0 deletions testdata/lefdef/issue-1499/tech.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DIEAREA ALL 1 0
#BOUNDARY DIEAREA 1 0
BOUNDARY MACRO 1 0
#M1 LEFOBS 2 0
M1 LEFOBS 3 0
M1 BLOCKAGE 3 0
10 changes: 10 additions & 0 deletions testdata/lefdef/issue-1499/top.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VERSION 5.8 ;
DESIGN top ;
UNITS DISTANCE MICRONS 1000 ;
DIEAREA ( 0 0 ) ( 1000000 1000000 ) ;
COMPONENTS 3 ;
- a a + PLACED ( 0 0 ) N ;
- b b + PLACED ( 600000 0 ) N ;
- c c + PLACED ( 500000 500000 ) N ;
END COMPONENTS
END DESIGN

0 comments on commit 42183ef

Please sign in to comment.